////////////////////////////////////////////////////////////////////////////////
// 'pkg-deploy' subcommand.
341281
func cmdDeploy() *subcommands.Command {
	return &subcommands.Command{
		Advanced:  true,
		UsageLine: "pkg-deploy <package instance file> [options]",
		ShortDesc: "deploys a package instance file",
		LongDesc:  "Deploys a *.cipd package instance into a site root.",
		CommandRun: func() subcommands.CommandRun {
			c := &deployRun{}
			c.registerBaseFlags()
			c.hashOptions.registerFlags(&c.Flags)
			c.Flags.StringVar(&c.rootDir, "root", "<path>", "Path to an installation site root directory.")
			return c
		},
	}
}
981754
function getModulesAnswered(command, argv, globs) {
  let modulesCalled = {};
  let modulesAnswered = [];

  globs.forEach(pkg => {
    const dirName = path.dirname(pkg);
    let pkgJson = {};
    let module;

    try {
      module = require(dirName);
      pkgJson = require(pkg);
    } catch (err) {
      logger.verbose(`Error loading module: ${pkg}`);
    }

    if (module && typeof module.runCommand === 'function') {
      const pkgName = pkgJson.name || dirName;

      if (modulesCalled[pkgName]) {
        logger.verbose(`Multiple instances found. Skipping passing command to ${pkgName}`);
      } else {
        logger.verbose(`Passing command to ${pkgName}`);

        modulesCalled[pkgName] = true;
        if (module.runCommand(command, argv)) {
          modulesAnswered.push(pkgName);
        }

      }
    }
  });

  return modulesAnswered;
}
1372644
func cmdCreate(params Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "create [options]",
		ShortDesc: "builds and uploads a package instance file",
		LongDesc:  "Builds and uploads a package instance file.",
		CommandRun: func() subcommands.CommandRun {
			c := &createRun{}
			c.registerBaseFlags()
			c.Opts.inputOptions.registerFlags(&c.Flags)
			c.Opts.refsOptions.registerFlags(&c.Flags)
			c.Opts.tagsOptions.registerFlags(&c.Flags)
			c.Opts.clientOptions.registerFlags(&c.Flags, params, withoutRootDir)
			c.Opts.uploadOptions.registerFlags(&c.Flags)
			c.Opts.hashOptions.registerFlags(&c.Flags)
			return c
		},
	}
}
153917
def _resolve_deps(name, pkgs, **kwargs):
    '''
    
    '''
    missing_deps = []
    for pkg_file in pkgs:
        deb = apt.debfile.DebPackage(filename=pkg_file, cache=apt.Cache())
        if deb.check():
            missing_deps.extend(deb.missing_deps)

    if missing_deps:
        cmd = ['apt-get', '-q', '-y']
        cmd = cmd + ['-o', 'DPkg::Options::=--force-confold']
        cmd = cmd + ['-o', 'DPkg::Options::=--force-confdef']
        cmd.append('install')
        cmd.extend(missing_deps)

        ret = __salt__['cmd.retcode'](
            cmd,
            env=kwargs.get('env'),
            python_shell=False
        )

        if ret != 0:
            raise CommandExecutionError(
                'Error: unable to resolve dependencies for: {0}'.format(name)
            )
        else:
            try:
                cmd = ['apt-mark', 'auto'] + missing_deps
                __salt__['cmd.run'](
                    cmd,
                    env=kwargs.get('env'),
                    python_shell=False
                )
            except MinionError as exc:
                raise CommandExecutionError(exc)
    return
1170453
function checkPkg(pkgDir, scopes) {
  var errors;
  try {
    var config = {packageDir: pkgDir};
    if (scopes) {
      config.scopeList = scopes;
    }
    var checked = checkDeps.sync(config);
    if (checked.error.length) {
      errors = checked.error;
    }
  } finally {
    // eslint-disable-next-line no-unsafe-finally
    return errors;
  }
}
1373449
function linkMans (pkg, cb) {
  log.verbose(pkg._id, "linkMans")
  log.silly(pkg.man, "linkMans")
  var man = pkg.man
    , manroot = npm.config.get("manroot")
    , pkgDir = path.join(npm.dir, pkg.name, pkg.version, "package")
  if (!man || !manroot) return cb()
  exec("manpath", [], null, false, function (er, code, stdout, stderr) {
    var manpath = er ? [] : stdout.trim().split(":")
    if (manpath.indexOf(manroot) === -1) {
      log.warn("man pages installing to " + manroot + ", outside MANPATH")
    }
    asyncMap(man, function (man, cb) {
      var parseMan = man.match(/(.*)\.([0-9]+)(\.gz)?$/)
        , stem = parseMan[1]
        , sxn = parseMan[2]
        , gz = parseMan[3] || ""
        , bn = path.basename(stem)
        , manSrc = path.join( pkgDir, man )
        , manDest = path.join( manroot
                             , "man"+sxn
                             , (bn.indexOf(pkg.name) === 0 ? bn
                               : pkg.name + "-" + bn)
                               + "@" + pkg.version
                               + "." + sxn + gz
                             )
      // ln {cwd}/man {manroot}/man{sxn}/{bn}-{ver}.{sxn}{gz}
      log.silly(manSrc, "manSrc")
      log.silly(manDest, "manDest")
      linkIfExists(manSrc, manDest, cb)
    }, cb)
  })
}
326161
def main(mode):
    
    # see:
    # https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
    version = subprocess.check_output(['python', 'setup.py', '--version']).decode().strip()

    twine_repo = os.getenv('TWINE_REPOSITORY_URL') or os.getenv('TWINE_REPOSITORY')
    print('tagging and releasing %r as a %s release to %s as Twine user %s' % (
        version,
        mode.name,
        twine_repo,
        os.getenv('TWINE_USERNAME')
    ))

    print('python - preparing environment')
    subprocess.check_call(['apk', 'update'])
    subprocess.check_call(['apk', 'add', 'git'])
    # Pin twine to 1.11 due to https://github.com/pypa/twine/issues/404
    subprocess.check_call(['pip', 'install', 'twine<1.12'])
    url = subprocess.check_output(['git', 'remote', 'get-url', 'origin'])
    new_url = git_url_ssh_to_https(url.decode())
    subprocess.check_call(['git', 'remote', 'set-url', 'origin', new_url])
    branch_spec = 'origin/%s' % os.getenv('CIRCLE_BRANCH')
    subprocess.check_call(['git', 'branch', '--set-upstream-to', branch_spec])
    subprocess.check_call(['git', 'fetch', '--tags', '--force'])

    # tags
    subprocess.check_call(['git', 'tag', '-a', version, '-m', 'release %s' % version])
    subprocess.check_call(['git', 'tag', '-f', 'latest'])
    if mode == release_target_map['prod']:
        print('git - pushing %s tags' % mode.name)
        subprocess.check_call(['git', 'push', '-f', 'origin', '--tags'])

    print('git - add changes')
    subprocess.check_call(['git', 'add', 'src/mbed_cloud/_version.py'])
    subprocess.check_call(['git', 'add', 'CHANGELOG.rst'])
    subprocess.check_call(['git', 'add', 'docs/news/*'])
    message = ':checkered_flag: :newspaper: releasing version %s\n[skip ci]' % version
    subprocess.check_call(['git', 'commit', '-m', message])

    if mode == release_target_map['prod']:
        print('git - pushing %s changelog commit' % mode.name)
        subprocess.check_call(['git', 'push', 'origin'])

    print('pypi - uploading')
    subprocess.check_call(['python', '-m', 'twine', 'upload', mode.bundle])
    print('pypi - uploading successful')
351697
func cmdSetTag(params Parameters) *subcommands.Command {
	return &subcommands.Command{
		UsageLine: "set-tag <package or package prefix> -tag=key:value [options]",
		ShortDesc: "tags package of a specific version",
		LongDesc:  "Tags package of a specific version",
		CommandRun: func() subcommands.CommandRun {
			c := &setTagRun{}
			c.registerBaseFlags()
			c.tagsOptions.registerFlags(&c.Flags)
			c.clientOptions.registerFlags(&c.Flags, params, withoutRootDir)
			c.Flags.StringVar(&c.version, "version", "<version>",
				"Package version to resolve. Could also be itself a tag or ref")
			return c
		},
	}
}
2839
func (cmd *CLI) AddSubCommand(subcmd *SubCommand) *SubCommand {
	subcmd.ErrorHandling = cmd.ErrorHandling
	cmd.subCommands.Add(subcmd.name, subcmd)
	if subcmd.parent != nil {
		panic("command already assigned")
	}
	if &subcmd.CLI == cmd {
		panic("cannot assign subcmd to itself as a subcmd")
	}
	subcmd.parent = cmd
	return subcmd
}
405575
public void mkPackage(String pkgName, File dir) {
        try {
            File metaDir = new File(dir + "/.mdw");
            if (!metaDir.exists() && !metaDir.mkdirs())
                throw new IOException("Cannot create directory: " + metaDir.getAbsolutePath());
            File pkgFile = new File(metaDir + "/package.yaml");
            if (!pkgFile.exists()) {
                JSONObject pkgJson = new JSONObject();
                pkgJson.put("name", pkgName);
                pkgJson.put("version", "1.0.01");
                pkgJson.put("schemaVersion", "6.1");
                Files.write(Paths.get(pkgFile.getPath()), pkgJson.toString(2).getBytes());
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
987731
def package_install(name, **kwargs):
    '''
    
    '''
    cmd = 'pkg_install ' + name
    if kwargs.get('version', False):
        cmd += ' ' + kwargs['version']

    # Send the command to execute
    out, err = DETAILS['server'].sendline(cmd)

    # "scrape" the output and return the right fields as a dict
    return parse(out)
518624
def update(self, *pkgs, **kwargs):
        """"""
        cmd_list = ['update', '--json', '--yes']

        if not pkgs and not kwargs.get('all'):
            raise TypeError("Must specify at least one package to update, or "
                            "all=True.")

        cmd_list.extend(
            self._setup_install_commands_from_kwargs(
                kwargs,
                ('dry_run', 'no_deps', 'override_channels',
                 'no_pin', 'force', 'all', 'use_index_cache', 'use_local',
                 'alt_hint')))

        cmd_list.extend(pkgs)

        return self._call_and_parse(cmd_list, abspath=kwargs.get('abspath',
                                                                 True))
1286027
function pkgdir() {
	var parts,
		len,
		str,
		i;

	parts = cwd().split( path.sep );
	len = parts.length;
	for ( i = 0; i < len; i++ ) {
		str = parts.join( path.sep );
		if ( exists( path.join( str, 'package.json' ) ) ) {
			return str;
		}
		parts.pop();
	}
	return null;
}
71837
def add_package(pkg_type, pkg_name, working=None):
    
    kvp = {pkg_type: pkg_name}
    working = os.getcwd() if not working else os.path.abspath(working)
    if '-dist/scripts' in working:
        config = working + "/config.JSON"
    elif '-dist' in working:
        config = working + "/scripts/config.JSON"
    else:
        config = working + "/*-dist/scripts/config.JSON"
        entropy = glob.glob(config)
        if entropy:
            config = entropy[0]  # we'll just assume it's the first one...
    print("config", config, 'working', working)
    config = load_config(config)
    config.update(kvp)
    export_to_json(config)
116999
async function deploy() {
  // By default deploy to the staging deployment slot
  const remote = getRemote(process.argv.includes('--production') ? null : 'staging');

  // Initialize a new Git repository inside the `/build` folder
  // if it doesn't exist yet
  const repo = await GitRepo.open('build', { init: true });
  await repo.setRemote(remote.name, remote.url);

  // Fetch the remote repository if it exists
  if ((await repo.hasRef(remote.url, 'master'))) {
    await repo.fetch(remote.name);
    await repo.reset(`${remote.name}/master`, { hard: true });
    await repo.clean({ force: true });
  }

  // Build the project in RELEASE mode which
  // generates optimized and minimized bundles
  process.argv.push('--release');
  await run(require('./build'));

  // Push the contents of the build folder to the remote server via Git
  await repo.add('--all .');
  await repo.commit('Update');
  await repo.push(remote.name, 'master');

  // Check if the site was successfully deployed
  const response = await fetch(remote.website);
  console.log(`${remote.website} -> ${response.statusCode}`);
}
504013
function addDeployPlugin(webpackConfig, wpkConfig, env) {
    env = proccessFtpPath(env);

    webpackConfig.plugins.push(new DeployPlugin({
        server: `${env.__ftp_user__}:${env.__ftp_password__}@${env.__ftp_host__}:${env.__ftp_port__}`,
        workspace: wpkConfig.output.path,
        deployTo: env.__ftp_path__
    }));
}
767188
func cmdRegister(params Parameters) *subcommands.Command {
	return &subcommands.Command{
		Advanced:  true,
		UsageLine: "pkg-register <package instance file>",
		ShortDesc: "uploads and registers package instance in the package repository",
		LongDesc:  "Uploads and registers package instance in the package repository.",
		CommandRun: func() subcommands.CommandRun {
			c := &registerRun{}
			c.registerBaseFlags()
			c.Opts.refsOptions.registerFlags(&c.Flags)
			c.Opts.tagsOptions.registerFlags(&c.Flags)
			c.Opts.clientOptions.registerFlags(&c.Flags, params, withoutRootDir)
			c.Opts.uploadOptions.registerFlags(&c.Flags)
			c.Opts.hashOptions.registerFlags(&c.Flags)
			return c
		},
	}
}