Add the package to the queue in case the name && version doen't exist or
the version range isn't matched.

@param {Object} queue - contains packages info from NPM registry
@param {String} packageInfo - data retrieved from the NPM registry for a package
974859
function addToQueue(queue, packageInfo) {
  var exists;

  function matchesVersion(version, range) {
    var matches;

    try {
      matches = semver.satisfies(packageInfo.version, item.version);
    }
    catch (err) {
      matches = false;
    }

    return matches;
  }

  exists = queue.some(function(item) {
    var matches = false;

    if (item.name === packageInfo.name) {
      matches = matchesVersion(packageInfo.version, item.version);
    }

    return matches;
  });

  if (!exists) {
    queue.push(packageInfo);
  }
}
951044
def package_install(name, **kwargs):
    '''
    
    '''
    DETAILS = _load_state()
    if kwargs.get('version', False):
        version = kwargs['version']
    else:
        version = '1.0'
    DETAILS['packages'][name] = version
    _save_state(DETAILS)
    return {name: version}
490765
private static void initFromPackage(PackageDescriptor pd,
                                        Package pkg) {

        pd.setExists(true);

        String specificationTitle = pkg.getSpecificationTitle();
        String specificationVersion = pkg.getSpecificationVersion(); 
        String specificationVendor = pkg.getSpecificationVendor();

        String implementationTitle = pkg.getImplementationTitle();
        String implementationVersion = pkg.getImplementationVersion(); 
        String implementationVendor = pkg.getImplementationVendor();

        if (implementationTitle == null) {
            implementationTitle = specificationTitle;
        }

        if (implementationVersion == null) {
            implementationVersion = specificationVersion;
        }

        if (implementationVendor == null) {
            implementationVendor = specificationVendor;
        }


        pd.setSpecificationTitle(specificationTitle);
        pd.setSpecificationVersion(specificationVersion);
        pd.setSpecificationVendor(specificationVendor);

        pd.setImplementationTitle(implementationTitle);
        pd.setImplementationVersion(implementationVersion);
        pd.setImplementationVendor(implementationVendor);

        pd.setProduct(implementationTitle);
        pd.setProductVersion(implementationVersion);
    }
195598
function checkPackageJson () {
        const pkg = requireFresh(path.join(project, 'package.json'));
        expect(pkg.name).toEqual(appId);
        expect(pkg.displayName).toEqual(appName);
        expect(pkg.version).toEqual(appVersion);
    }
549491
function(dependencies) {
        var _dependencies = dependencies || {};
        var _numberOfOudatedPackages = Object.keys(_dependencies).length;
        var _minor = semver.allMinor(dependencies, 'latest');
        var _major = semver.allMajor(dependencies, 'latest');
        var _patch = semver.allPatch(dependencies, 'latest`');
        var _passing = (
          options['up-to-dateness'].number >= _numberOfOudatedPackages &&
          _major.passing === true &&
          _minor.passing === true &&
          _patch.passing === true
        );

        return {
          passing: _passing,
          outdated: _.merge(_major.outdated, _minor.outdated, _patch.outdated)
        };
      }
22777
function bumpTask(complete) {
  util.log('Current version:', util.colors.cyan(pkg.version));
  var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType) {
    return versionType + ' (v' + semver.inc(pkg.version, versionType) + ')';
  });
  inquirer.prompt({
    type: 'list',
    name: 'version',
    message: 'What version update would you like?',
    choices: choices
  }).then(function(res) {
    var increment = res.version.split(' ')[0],
      newVersion = semver.inc(pkg.version, increment);

    // Set the new versions into the package object
    pkg.version = newVersion;

    // Write these to their own files, then build the output
    fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));

    complete();
  });
}
440574
function installPackage(packageInstallFolder, name, version) {
    try {
        console.log(`Installing ${name}...`);
        const npmPath = getNpmPath();
        const result = childProcess.spawnSync(npmPath, ['install'], {
            stdio: 'inherit',
            cwd: packageInstallFolder,
            env: process.env
        });
        if (result.status !== 0) {
            throw new Error('"npm install" encountered an error');
        }
        console.log(`Successfully installed ${name}@${version}`);
    }
    catch (e) {
        throw new Error(`Unable to install package: ${e}`);
    }
}
516839
async function updateVersion(file) {
  const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
  const { packageName } = config;

  const packageInfoFile = `${PACKAGES_PATH}/${packageName}/package.json`;
  const { default: packageInfo } = await import(packageInfoFile);

  if (info.version !== packageInfo.version) {
    const newPackageInfo = {
      ...packageInfo,
      version: info.version,
    };

    writeFileAsync(packageInfoFile, JSON.stringify(newPackageInfo, null, '  '))
      .then(
        () => console.log(`Updated ${packageName} to ${info.version}`),
        error => console.log(error),
      );
  }
}
9803
def listed(self):
        
        print("\nPackages in the queue:\n")
        for pkg in self.packages():
            if pkg:
                print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
                                         self.meta.color["ENDC"]))
                self.quit = True
        if self.quit:
            print("")
17512
def cli(env, package_keyname):
    
    manager = ordering.OrderingManager(env.client)
    table = formatting.Table(COLUMNS)

    locations = manager.package_locations(package_keyname)
    for region in locations:
        for datacenter in region['locations']:
            table.add_row([
                datacenter['location']['id'],
                datacenter['location']['name'],
                region['description'],
                region['keyname']
            ])
    env.fout(table)
554166
function npmInstall(packages, callback) {
  callback = utils.defineCallback(callback);
  if (_.isString(packages)) {
    packages = [ packages ];
  }
  return npm.load({
    loglevel: "silent",
    prefix: tmpDir,
  }, function(loadErr) {
    if (loadErr) {
      return callback(new errors.NpmLoadError(loadErr));
    }
    npm.commands.install(packages, function(installErr) {
      if (installErr) {
        return callback(new errors.NpmInstallError(installErr));
      }
      ncp(tmpDir + "/node_modules/", pluginsDir, function(copyError) {
        if (copyError) {
          return callback(new errors.PluginsMoveFromTempError(copyError));
        }
        return callback(null);
      }); // ncp
    }); // npm.commands.install
  }); // npm.load
}
766923
function discoverVersion() {
    // try to understand package name and current version
    // from package.json or bower.json
    let packageFile;
    let packageFileExtension;
    let packageType;
    let results = {
        name: '',
        currentVersion: ''
    };
    let possiblePackageFiles = ['package.json', 'bower.json', 'package.js'];

    for (possiblePackageFile of possiblePackageFiles) {
        if (fs.existsSync(possiblePackageFile)) {
            packageFile = possiblePackageFile;
            break;
        }
    }

    packageFileExtension = packageFile.substr(packageFile.lastIndexOf('.') + 1);

    if (packageFile) {
        let packageData;

        if (packageFileExtension === 'json') {
            packageData = jsonReader(packageFile);
        }
        if (packageFileExtension === 'js') {
            let tmpData = fs.readFileSync(packageFile).toString().split('\n');
            let nameFound = false;
            let versionFound = false;

            packageData = {};

            for (line of tmpData) {
                if (line.indexOf('name:') >= 0) {
                    nameFound = true;
                    packageData.name = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }
                if (line.indexOf('version:') >= 0) {
                    versionFound = true;
                    packageData.version = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }

                if (nameFound && versionFound) {
                    break;
                }
            }
        }

        debugLog('Reading packageFile for init:');
        debugLog('Discovered pacakge name: ' + packageData.name + ' - discovered package version ' + packageData.version);

        if (packageData.name) {
            results.name = packageData.name;
        }
        else {
            print('Can\'t discover package name automatically', 'msgWarning', 'spaced22');
        }

        if (packageData.version) {
            results.currentVersion = packageData.version;
        }
        else {
            print('Can\'t discover package\'s currentVersion automatically', 'msgWarning', 'spaced22');
        }
    }
    else {
        print('Can\'t discover package name and/or currentVersion automatically', 'msgWarning', 'spaced22');
        print('Please fill .versionFilesList.json with the missing informations', 'msgWarning', 'spaced22');
    }

    return results;
}
133024
private boolean isIncluded(String _fqcn) {
        if (includePackageNames.contains(_fqcn)) {
            return true;
        }

        String packageName = _fqcn.substring(0, _fqcn.lastIndexOf('.') + 1);
        for (String str : includePackageNames) {
            if (packageName.startsWith(str)) {
                return true;
            }
        }

        return false;
    }
619172
def add_package_dependency(self, package_name, version):
        
        if not PEP440_VERSION_PATTERN.match(version):
            raise ValueError('Invalid Version: "{}"'.format(version))
        self.dependencies.add(PackageDependency(package_name, version))
727499
async function _expectPackageVersion(args) {
  const packageVersion = require(
    path.resolve(__dirname, '../../package.json')
  ).version;
  await _expectSuccessMessage(args, `${packageVersion}\n`);
}
1147650
function addToQueueCopy(sources, dest, options) {
      if(sources.length === 1) {
        // Simple copy
        queueCopy.push({
          src:      sources[0],
          dest:     dest,
          options:  _.extend({}, options, { realDest: dest, isConcat: false })
        });
      } else {
        // Concat
        sources.forEach(function(src) {

          var def       = Q.defer();
          var cacheDest = join(options.cache, fileUID(src));

          if(!concatPromises[dest]) {
            concatPromises[dest] = [];
          }
          concatPromises[dest].push(def.promise);

          if(!concatSources[dest]) {
            concatSources[dest] = [];
          }
          concatSources[dest].push(cacheDest);

          queueCopy.push({
            src:      src,
            dest:     cacheDest,
            options:  _.extend({}, options, { realDest: dest, isConcat: true })
          }, function(err, changed) {
            if(err) {
              return def.reject(err);
            }
            def.resolve(changed);
          });
        });
      }
    }
571990
public static function packageRemove($packageInfo) {
		
		// run the console and config inits
		self::init();
		
		// see if the package has a listener and remove it
		self::scanForListener($packageInfo["pathBase"],true);
		
		// see if the package is a pattern engine and remove the rule
		if ($packageInfo["type"] == "patternlab-patternengine") {
			self::scanForPatternEngineRule($packageInfo["pathBase"],true);
		}
		
		// remove the component package file if it exists
		$jsonFile = Config::getOption("componentDir")."/packages/".str_replace("/","-",$packageInfo["name"]).".json";
		if (file_exists($jsonFile)) {
			unlink($jsonFile);
		}
		
	}