Logic shared between `Model.deploy` and `BundleHandler.deploy`.
199429
async def _deploy(self, charm_url, application, series, config,
                      constraints, endpoint_bindings, resources, storage,
                      channel=None, num_units=None, placement=None,
                      devices=None):
        
        log.info('Deploying %s', charm_url)

        # stringify all config values for API, and convert to YAML
        config = {k: str(v) for k, v in config.items()}
        config = yaml.dump({application: config},
                           default_flow_style=False)

        app_facade = client.ApplicationFacade.from_connection(
            self.connection())

        app = client.ApplicationDeploy(
            charm_url=charm_url,
            application=application,
            series=series,
            channel=channel,
            config_yaml=config,
            constraints=parse_constraints(constraints),
            endpoint_bindings=endpoint_bindings,
            num_units=num_units,
            resources=resources,
            storage=storage,
            placement=placement,
            devices=devices,
        )
        result = await app_facade.Deploy([app])
        errors = [r.error.message for r in result.results if r.error]
        if errors:
            raise JujuError('\n'.join(errors))
        return await self._wait_for_new('application', application)
692466
function continuousBundle() {
    const bundle = b => b.bundle()
        .on('error', (err) => {
            notifier.notify({
                title: 'Browserify Error',
                message: err.message,
            });
            gutil.log('Browserify Error', err);
        })
        .pipe(source('crudl.js'))
        .pipe(gulp.dest(dist))
        .on('end', () => {
            notifier.notify({
                title: 'Browserify',
                message: 'OK',
            });
        })
    const opts = assign({}, watchify.args, browersifyOptions, { debug: true });
    const bundler = watchify(browserify(opts).transform(babelify.configure(babelifyOptions)));
    bundler.on('update', () => bundle(bundler)); // on any dep update, runs the bundler
    bundler.on('log', gutil.log); // output build logs to terminal

    return bundle(bundler)
}
248864
function bundle () {
    var didError = false
    const outStream = fs.createWriteStream(outFile)
    const bStream = w.bundle()

    bStream.on('error', function (err) {
      console.error('[bundle]', String(err))
      didError = true
      outStream.end('console.error(' + JSON.stringify(String(err)) + ')')
    })

    // if we're not splitting vendor files, include them in the bundle
    if (!shouldSplitVendor && vendorFiles.length) {
      multistream(vendorFiles.map(createReadStream).concat(bStream))
        .pipe(outStream)
    } else {
      bStream.pipe(outStream)
    }

    outStream.on('error', function (err) {
      console.error('[bundle]', err)
    })

    outStream.on('close', function () {
      if (verbose && !didError) {
        // TODO: also display size of vendor files
        console.error(
          '[bundle] %d bytes written to %s (%s seconds)',
          bytes, outFile, (time / 1000).toFixed(2)
        )
      }
    })
  }
351776
async function build() {
  await run(clean);
  await run(copy);
  await run(bundle);
}
664562
function updateDeploy() {

    function promisedGit(args, options) {
        const argsArr = ['git'];
        Array.prototype.push.apply(argsArr, args);
        options = options || {};
        options.capture = options.capture === undefined ? true : options.capture;
        options.useErrHandler = options.useErrHandler === undefined ? true : options.useErrHandler;
        return promisedSpawn(argsArr, options);
    }

    function chainedPgit(args, options) {
        const arg = args.shift();
        if (!arg) {
            return P.resolve();
        }
        return promisedGit(arg, options)
        .then((data) => {
            if (args.length === 0) {
                return P.resolve(data);
            }
            return chainedPgit(args, options);
        });
    }

    // check if there is an alternative repo name defined
    return P.props({
        name: promisedGit(['config', 'deploy.name'], { ignoreErr: true }),
        remote: promisedGit(['config', 'deploy.remote'], { ignoreErr: true }),
        submodule_ref: promisedGit(['config', 'deploy.submodule'], { ignoreErr: true }),
        deploy_branch: promisedGit(['config', 'deploy.deploybranch'], { ignoreErr: true }),
        src_branch: promisedGit(['config', 'deploy.srcbranch'], { ignoreErr: true })
    }).then((props) => {
        opts.name = props.name || pkg.name;
        opts.remote_name = props.remote || 'origin';
        opts.submodule_ref = props.submodule_ref ||
            `https://gerrit.wikimedia.org/r/mediawiki/services/${opts.name}`;
        opts.src_branch = props.src_branch || 'master';
        opts.deploy_branch = props.deploy_branch || 'master';
        opts.remote_branch = `${opts.remote_name}/${opts.deploy_branch}`;
        // we need to CHDIR into the deploy dir for subsequent operations
        process.chdir(opts.dir);
        return chainedPgit([
            // make sure we are on master
            ['checkout', 'master'],
            // fetch all possible updates
            ['fetch', '--all'],
            // work on a topic branch forked off of the target branch
            ['checkout', '-B', 'sync-repo', opts.remote_branch],
            // check if the submodule is present
            ['submodule', 'status']
       ]);
    }).then((list) => {
        if (list) {
            // the submodule is present
            // in submodule the remote is always called 'origin', so ignore opts.
            opts.submodule = list.split(' ')[1];
            // update it fully
            return promisedGit(['submodule', 'update', '--init'])
            .then(() => {
                process.chdir(`${opts.dir}/${opts.submodule}`);
                return chainedPgit([
                    // fetch new commits
                    ['fetch', 'origin'],
                    // inspect what has changed
                    ['diff', '--name-only', `origin/${opts.src_branch}`]
               ]).then((changes) => {
                    if (/package\.json/.test(changes)) {
                        // package.json has changed, so we need
                        // to rebuild the node_modules directory
                        opts.need_build = true;
                    }
                    // get the SHA1 of the latest commit on the src branch
                    return promisedGit(['rev-parse', '--short', `origin/${opts.src_branch}`]);
                }).then((shortSha1) => {
                    opts.commit_msg = `Update ${opts.name} to ${shortSha1}\n\n`;
                    // get a nice list of commits included in the change
                    return promisedGit(['log',
                        `..origin/${opts.src_branch}`,
                        '--oneline',
                        '--no-merges',
                        '--reverse',
                        '--color=never']);
                }).then((logs) => {
                    if (!logs && !opts.need_build) {
                        // no updates have happened, nothing to do here any more but clean up
                        // go back to the root dir
                        process.chdir(opts.dir);
                        // and get back to master
                        return promisedGit(['checkout', 'master'])
                        .then(() => {
                            console.log('The deploy repository is up to date already, exiting.');
                            process.exit(0);
                        });
                    } else if (logs) {
                        logs += '\n';
                    } else if (!logs) {
                        logs = '';
                    }
                    opts.commit_msg += `List of changes:\n${logs}`;
                    return promisedGit(['checkout', `origin/${opts.src_branch}`]);
                }).then(() => {
                    // go back to the root dir
                    process.chdir(opts.dir);
                    // add the submodule changes
                    return promisedGit(['add', opts.submodule]);
                });
            });
        } else {
            // no submodule, need to add it
            opts.submodule = 'src';
            opts.need_build = true;
            opts.commit_msg = `Initial import of ${opts.name}`;
            return promisedGit(['submodule',
                'add',
                opts.submodule_ref,
                opts.submodule]);
        }
    }).then(() => // make sure the package.json symlink is in place
        fs.symlinkAsync(`${opts.submodule}/package.json`, 'package.json')
    .catch(() => {}).then(() => promisedGit(['add', 'package.json']))).then(() => {
        if (!opts.need_build) {
            return;
        }
        // update the commit message
        if (!/^initial/i.test(opts.commit_msg)) {
            opts.commit_msg += 'xxxxxxx Update node module dependencies\n';
        }
        // a rebuild is needed, start by removing the existing modules
        return promisedGit(['rm', '-r', 'node_modules'], { ignoreErr: true })
        .then(() => promisedSpawn(['rm', '-rf', 'node_modules'],
            { capture: true, ignoreErr: true }))
        // start the container which builds the modules
        .then(() => startContainer(['-v', `${opts.dir}:/opt/service`, '-w', '/opt/service'], true))
        .then(() => {
            // remove unnecessary files
            let findAttr;
            if (os.type() === 'Darwin') {
                findAttr = [
                    'find',
                    '-E',
                    'node_modules/',
                    '-iregex',
                    '.*\\.git.*|.*\\.md|.*readme|.*licence',
                    '-exec', 'rm', '-rf', '{}', ';'
               ];
            } else {
                findAttr = [
                    'find',
                    'node_modules/',
                    '-regextype',
                    'posix-egrep',
                    '-iregex',
                    '(.*\\.git.*|.*\\.md|.*readme|.*licence)',
                    '-exec', 'rm', '-rf', '{}', ';'
               ];
            }
            return promisedSpawn(findAttr, { capture: true, ignoreErr: true });
        }).then(() => // add the built submodules
            promisedGit(['add', 'node_modules']));
    }).then(() => // commit the changes
        promisedGit(['commit', '-m', opts.commit_msg]))
        .then(() => {
            if (!opts.review) {
                console.log('\n\nChanges are sitting in the sync-repo branch in');
                console.log(`${opts.dir} with the commit:`);
                console.log(opts.commit_msg);
                return;
            }
            return chainedPgit([
                // send them for review
                ['review', '-R', opts.deploy_branch],
                // get back to master
                ['checkout', 'master'],
                // and reset the submodule pointer
                ['submodule', 'update', '--init']
           ], { capture: false }).then(() => {
                console.log('\n\nChanges sent to Gerrit for review!');
            });
        });
}
883413
def bind_jobs
      @deployment_plan.releases.each do |release|
        release.bind_jobs
      end

      @deployment_plan.instance_groups.each(&:validate_package_names_do_not_collide!)
      @deployment_plan.instance_groups.each(&:validate_exported_from_matches_stemcell!)
    end
168629
async function bundleJavaScript() {
    const bundle = await rollup.rollup({
        input: `${__dirname}/src/beedle.js`,
        plugins: [
            uglify()
        ]
    });

    await bundle.write({
        format: 'umd',
        name: 'beedle',
        file: 'beedle.js',
        dir: `${__dirname}/dist/`,
    });
}
1048268
@Override
    public void onDeploy(DeploymentEvent event) {
        AbstractRuntimeManager runtimeManager = (AbstractRuntimeManager) event.getDeployedUnit().getRuntimeManager();        
        KieBase kieBase = runtimeManager.getEnvironment().getKieBase();
        Collection<Process> processes = kieBase.getProcesses(); 
        
        Map<String, DeployedAsset> mapProcessById = event.getDeployedUnit().getDeployedAssets()
                                                                            .stream()
                                                                            .collect(toMap(DeployedAsset::getId, asset -> asset));        
        for( Process process : processes ) {
            if( ((WorkflowProcess)process).isDynamic()) {
                String caseIdPrefix = collectCaseIdPrefix(process);
                Collection<CaseMilestone> caseMilestones = collectMilestoness(process);
                Collection<CaseStage> caseStages = collectCaseStages(event.getDeploymentId(), process.getId(), ((WorkflowProcess)process));                
                Collection<CaseRole> caseRoles = collectCaseRoles(process);
                Collection<AdHocFragment> adHocFragments = collectAdHocFragments((WorkflowProcess)process);
                Map<String, List<String>> dataAccessRestrictions = collectDataAccessRestrictions(process);
                
                CaseDefinitionImpl caseDef = new CaseDefinitionImpl((ProcessAssetDesc) mapProcessById.get(process.getId()), caseIdPrefix, caseStages, caseMilestones, caseRoles, adHocFragments, dataAccessRestrictions);
                
                availableCases.add(caseDef);
                caseIdGenerator.register(caseIdPrefix);
            }
        }
        
        // collect role information
        Collection<DeployedAsset> assets = event.getDeployedUnit().getDeployedAssets();
        List<String> roles = null;
        for( DeployedAsset asset : assets ) {
            if( asset instanceof ProcessAssetDesc ) {  
                // if it's not dynamic it's considered as not case definition
                if (!((ProcessAssetDesc) asset).isDynamic()) {
                    availableProcesses.add((ProcessAssetDesc) asset);
                }
                if (roles == null) {
                    roles = ((ProcessAssetDesc) asset).getRoles();
                }
            }
        }
        if (roles == null) {
            roles = Collections.emptyList();
        }
        deploymentRolesManager.addRolesForDeployment(event.getDeploymentId(), roles);

    }
400903
private void deployNetwork(final NetworkContext context, final Handler<AsyncResult<NetworkContext>> doneHandler) {
    log.debug(String.format("%s - Deploying network", NetworkManager.this));
    final CountingCompletionHandler<Void> complete = new CountingCompletionHandler<Void>(context.components().size());
    complete.setHandler(new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> result) {
        if (result.failed()) {
          new DefaultFutureResult<NetworkContext>(result.cause()).setHandler(doneHandler);
        } else {
          new DefaultFutureResult<NetworkContext>(context).setHandler(doneHandler);
        }
      }
    });
    deployComponents(context.components(), complete);
  }
846515
function bundleRelease(minify) {
  var bundler = browserify({
    entries: ['./src/' + entryFileName],
    standalone: standaloneName,
    debug: !minify
  });

  if(minify) {
    bundler = bundler.plugin(collapse);
  }

  var stream = bundler.bundle()
    .on('error', logError);

  if(!minify) {
    stream = stream.pipe(exorcist('./dist/' + bundleFileName + '.map'));
  }

  stream = stream.pipe(source(bundleFileName))
    .pipe(buffer())
    .pipe(derequire())
    .pipe(strip());

  if(minify) {
    return stream.pipe(rename({extname: '.min.js'}))
      .pipe(uglify())
      .pipe(gulp.dest('./dist/'));
  } else {
    return stream.pipe(gulp.dest('./dist/'));
  }
}
1072474
function bundler(loader, options, modules) {
  var stack    = modules.slice(0);
  var mods     = [];
  var finished = {};

  function processModule(mod) {
    if (finished.hasOwnProperty(mod.id)) {
      return;
    }

    mod = loader.getModule(mod.id);

    // browser pack chunk
    var browserpack = {
      id     : mod.id,
      source : mod.source,
      deps   : {}
    };

    // Gather up all dependencies
    var i, length, dep;
    for (i = 0, length = mod.deps.length; i < length; i++) {
      dep = mod.deps[i];
      stack.push(dep);
      browserpack.deps[dep.id] = dep.id;
    }

    finished[mod.id] = browserpack;
    mods.unshift(browserpack);
  }

  // Process all modules
  while (stack.length) {
    processModule(stack.pop());
  }

  var stream = browserPack(options).setEncoding("utf8");
  var promise = pstream(stream);

  stream.end(JSON.stringify(mods));
  return promise;
}
620296
function addBundle(bundleId, incomingRelation, conditions) {
        const bundle = bundles[bundleId];
        let bundleAsset = assetByBundleId[bundleId];
        if (!bundleAsset) {
          bundleAsset = assetByBundleId[bundleId] = assetGraph.addAsset({
            type: 'JavaScript',
            baseName: bundleId,
            text: bundle.source,
            sourceMap: preprocessSourceMap(bundle.sourceMap)
          });
        }
        let keepBundleInGraph = true;
        if (
          incomingRelation.type === 'HtmlServiceWorkerRegistration' ||
          incomingRelation.type === 'JavaScriptServiceWorkerRegistration' ||
          incomingRelation.type === 'JavaScriptWebWorker'
        ) {
          const lastImportScript = assetGraph
            .findRelations({
              type: 'JavaScriptImportScripts',
              from: incomingRelation.to
            })
            .pop();

          incomingRelation.to.addRelation(
            {
              type: 'JavaScriptImportScripts',
              to: bundleAsset,
              hrefType: 'rootRelative'
            },
            lastImportScript ? 'after' : 'first',
            lastImportScript
          );
        } else {
          // assume 'HtmlScript'
          if (htmlScriptsToRemove.includes(incomingRelation)) {
            // The script containing the entry point is marked for removal, don't add the bundle to the graph
            keepBundleInGraph = false;
          } else {
            const htmlScript = incomingRelation.from.addRelation(
              {
                type: 'HtmlScript',
                hrefType: 'rootRelative',
                to: bundleAsset
              },
              'before',
              incomingRelation
            );
            if (conditions && Object.keys(conditions).length > 0) {
              htmlScript.node.setAttribute(
                'data-assetgraph-conditions',
                assetGraphConditions.stringify(conditions)
              );
              htmlScript.from.markDirty();
            }
          }
        }
        if (!keepBundleInGraph) {
          assetGraph.removeAsset(bundleAsset);
        }
        for (const { source, type, url, sourceMap } of bundle.assetList || []) {
          let asset = assetListEntryByUrl[url];
          if (!asset) {
            const assetConfig = { url, sourceMap };
            if (type === 'css') {
              assetConfig.type = 'Css';
            }
            if (typeof source === 'string') {
              assetConfig.text = source;
            }
            asset = assetGraph.addAsset(assetConfig);
            assetListEntryByUrl[url] = asset;
            attachAssetsPromises.push(asset.load());
          }

          if (asset.type === 'Css') {
            const htmlStyle = incomingRelation.from.addRelation(
              {
                type: 'HtmlStyle',
                hrefType: 'rootRelative',
                to: asset
              },
              'last'
            );
            if (conditions && Object.keys(conditions).length > 0) {
              htmlStyle.node.setAttribute(
                'data-assetgraph-conditions',
                assetGraphConditions.stringify(conditions)
              );
              htmlStyle.from.markDirty();
            }
          } else if (keepBundleInGraph) {
            bundleAsset.addRelation(
              {
                type: 'SystemJsBundle',
                hrefType: 'rootRelative',
                to: asset
              },
              'last'
            );
          } else {
            assetGraph.warn(
              new Error(
                `Cannot attach relation to ${
                  asset.urlOrDescription
                } when the <script> containing the entry point has the data-systemjs-remove property`
              )
            );
          }
        }
      }
1354744
function framework(emitter, config, logger) {

    log = logger.create('framework.browserify');

    if (!bundleFile) {
      bundleFile = new BundleFile();
    }

    bundleFile.touch();
    log.debug('created browserify bundle: %s', bundleFile.location);

    b = createBundle(config);

    // TODO(Nikku): hook into karma karmas file update facilities
    // to remove files from the bundle once karma detects the deletion

    // hook into exit for cleanup
    emitter.on('exit', function(done) {
      log.debug('cleaning up');

      if (b.close) {
        b.close();
      }

      bundleFile.remove();
      done();
    });


    // add bundle file to the list of files defined in the
    // configuration. be smart by doing so.
    addBundleFile(bundleFile, config);

    return b;
  }
1161294
function deploy(req, res, next) {
  var dataSource = req.body;

  dataSource._id = req.params.id;

  forms.dataSources.deploy(req.connectionOptions, dataSource, dataSourcesHandler(constants.resultTypes.dataSources, req, next));
}
789822
public function deploy()
    {
        $this->logger->notice('Deploying ' . $this->name . ' (' . $this->releaseIdentifier . ')');
        $this->workflow->run($this);
    }
818321
function (bundle, context, validate, debug) {
        var opts = {
            validate: validate,
            debug: debug
        };
        var ycb = new Ycb(bundle, opts);
        return ycb.read(context, opts);
    }
1337440
public void setDeploy(java.util.Collection<String> deploy) {
        if (deploy == null) {
            this.deploy = null;
            return;
        }

        this.deploy = new com.amazonaws.internal.SdkInternalList<String>(deploy);
    }