Returns the locally install apollo-codegen version as found in the package.json file.

@return null if build/apollo-codegen/node_modules/apollo-codegen/package.json wasn't found, version otherwise
765419
private String getApolloVersion() {
    File packageFile = new File(getProject().getBuildDir(), INSTALL_DIR + "/package.json");
    if (!packageFile.isFile()) {
      return null;
    }

    Moshi moshi = new Moshi.Builder().build();
    JsonAdapter<PackageJson> adapter = moshi.adapter(PackageJson.class);
    try {
      PackageJson packageJson = adapter.fromJson(Okio.buffer(Okio.source(packageFile)));
      return packageJson.version;
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
1131145
private function getUpgradeRepository()
    {
        $upgradeFile = $this->getTensideDataDir() . DIRECTORY_SEPARATOR . 'upgrades.json';
        if (!file_exists($upgradeFile)) {
            return null;
        }

        $packageLoader  = new ArrayLoader();
        $packageChanges = new WritableArrayRepository();
        $upgrades       = new JsonFile($upgradeFile, null);
        foreach ($upgrades->getEntries('/') as $packageName) {
            if ($pkgData = $upgrades->get($packageName . '/target')) {
                $packageChanges->addPackage($packageLoader->load($pkgData));
            }
        }

        return $packageChanges;
    }
1236566
public static String getVersion() {
        Package pkg = RoseVersion.class.getPackage();
        return (pkg != null ? pkg.getImplementationVersion() : null);
    }
1068447
private static String getVersion() {
        Properties properties = new Properties();
        try (InputStream ins = HttpRosetteAPI.class.getClassLoader().getResourceAsStream("version.properties")) {
            properties.load(ins);
        } catch (IOException e) {
            // should not happen
        }
        return properties.getProperty("version", "undefined");
    }
372472
public ISREInstall getSpecificSRE() {
		final int index = this.runtimeEnvironmentCombo.getSelectionIndex();
		if (index >= 0 && index < this.runtimeEnvironments.size()) {
			return this.runtimeEnvironments.get(index);
		}
		return null;
	}
406276
def get_version():
    
    with open(os.path.join(DIR, 'include/libjsonnet.h')) as f:
        for line in f:
            if '#define' in line and 'LIB_JSONNET_VERSION' in line:
                v_code = line.partition('LIB_JSONNET_VERSION')[2].strip('\n "')
                if v_code[0] == "v":
                    v_code = v_code[1:]
                return v_code
280624
private static int getAppVersion(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(), 0);
            return packageInfo.versionCode;
        } catch (NameNotFoundException e) {
            // should never happen
            throw new RuntimeException("Coult not get package name: " + e);
        }
    }
1129859
final protected function getVersion() {
        if(CB_VERSION!='@@VERSION@@') {
            return CB_VERSION.' '.CB_BUILD_DATE;
        }
        
        // Tries to obtain version number from composer.lock if it exists
        $composerLockPath=BASE_PATH.'/composer.lock';
        if(file_exists($composerLockPath)) {
            $cache=SS_Cache::factory('CodeBank_Version');
            $cacheKey=filemtime($composerLockPath);
            $version=$cache->load($cacheKey);
            if($version) {
                $version=$version;
            }else {
                $version='';
            }
            
            if(!$version && $jsonData=file_get_contents($composerLockPath)) {
                $lockData=json_decode($jsonData);
                if($lockData && isset($lockData->packages)) {
                    foreach ($lockData->packages as $package) {
                        if($package->name=='undefinedoffset/silverstripe-codebank' && isset($package->version)) {
                            $version=$package->version;
                            break;
                        }
                    }
                    
                    $cache->save($version, $cacheKey);
                }
            }
        }
        
        if(!empty($version)) {
            return $version;
        }
        
        return _t('CodeBank.DEVELOPMENT_BUILD', '_Development Build');
    }
820092
function updateVersion(pkg) {
  fs.readFile(__dirname + '/../package.json', 'utf8', (err, data) => {
    errorOnFail(err)
    const globalVersion = JSON.parse(data).version

    fs.readFile(__dirname + '/../packages/' + pkg + '/package.json', (err, data) => {
      errorOnFail(err)

      const packageJSON = JSON.parse(data)
      packageJSON.version = globalVersion

      // Update react-look-core dependency version
      if (pkg !== 'react-look-core') {
        packageJSON.dependencies['react-look-core'] = '^' + globalVersion
      }

      // Update react-look dependency version
      if (pkg === 'react-look-test-utils') {
        packageJSON.peerDependencies['react-look'] = '^' + globalVersion
      }

      const newPackageJSON = JSON.stringify(packageJSON, null, 4)

      fs.writeFile(__dirname + '/../packages/' + pkg + '/package.json', newPackageJSON, err => {
        errorOnFail(err)
        console.log('Successfully updated ' + pkg + ' version and react-look-core dependency version to ' + globalVersion + '.')
      })
    })
  })
}
383517
function getPackageName(installPackage) {
  if (installPackage.match(/^.+\.(tgz|tar\.gz)$/)) {
    return getTemporaryDirectory()
      .then(obj => {
        let stream;
        if (/^http/.test(installPackage)) {
          stream = hyperquest(installPackage);
        } else {
          stream = fs.createReadStream(installPackage);
        }
        return extractStream(stream, obj.tmpdir).then(() => obj);
      })
      .then(obj => {
        const packageName = require(path.join(obj.tmpdir, 'package.json')).name;
        obj.cleanup();
        return packageName;
      })
      .catch(err => {
        // The package name could be with or without semver version, e.g. tscomp-0.2.0-alpha.1.tgz
        // However, this function returns package name only without semver version.
        console.log(
          `Could not extract the package name from the archive: ${err.message}`
        );
        const assumedProjectName = installPackage.match(
          /^.+\/(.+?)(?:-\d+.+)?\.(tgz|tar\.gz)$/
        )[1];
        console.log(
          `Based on the filename, assuming it is "${chalk.cyan(
            assumedProjectName
          )}"`
        );
        return Promise.resolve(assumedProjectName);
      });
  } else if (installPackage.indexOf('git+') === 0) {
    // Pull package name out of git urls e.g:
    // git+https://github.com/mycompany/tscomp.git
    // git+ssh://github.com/mycompany/tscomp.git#v1.2.3
    return Promise.resolve(installPackage.match(/([^/]+)\.git(#.*)?$/)[1]);
  } else if (installPackage.match(/.+@/)) {
    // Do not match @scope/ when stripping off @version or @tag
    return Promise.resolve(
      installPackage.charAt(0) + installPackage.substr(1).split('@')[0]
    );
  } else if (installPackage.match(/^file:/)) {
    const installPackagePath = installPackage.match(/^file:(.*)?$/)[1];
    const installPackageJson = require(path.join(
      installPackagePath,
      'package.json'
    ));
    return Promise.resolve(installPackageJson.name);
  }
  return Promise.resolve(installPackage);
}
1114074
function packageVersion(repo) {
    var location = repo ? path.join(repo, 'package.json') : './package.json';
    var pack = require(location);
    return pack['version'];
}
1171117
protected static function fetch_core_version() {
        global $CFG;
        if (self::$version === null) {
            $version = null; // Prevent IDE complaints.
            require($CFG->dirroot . '/version.php');
            self::$version = $version;
        }
        return self::$version;
    }
313961
def get_package_version():
    """"""
    base = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(base, "firepit/__init__.py")) as pkg:
        for line in pkg:
            m = version.match(line.strip())
            if not m:
                continue
            return ".".join(m.groups()[0].split(", "))
155351
private function getInstalledVersion($localRepository, $packageName)
    {
        if (count($installed = $localRepository->findPackages($packageName))) {
            /** @var PackageInterface[] $installed */
            return $installed[0]->getPrettyVersion();
        }

        return null;
    }
1194410
function ensureGagarinVersionsMatch(pathToApp, verbose) {

  var pathToMeteorPackages = path.join(pathToApp, '.meteor', 'packages');
  var nodeModuleVersion    = require('../../package.json').version;

  return new Promise(function (resolve, reject) {

    utils.getGagarinPackageVersion(pathToApp).then(function (packageVersion) {

      if (packageVersion === nodeModuleVersion) {
        logs.system("node module and smart package versions match, " + packageVersion);
        return resolve();
      }

      tools.getReleaseVersion(pathToApp).then(function (meteorReleaseVersion) {

        if (meteorReleaseVersion < "0.9.0") {
          // really, we can do nothing about package version
          // without a decent package management system
          logs.system("meteor version is too old to automatically fix package version");
          return resolve();
        }

        logs.system("meteor add anti:gagarin@=" + nodeModuleVersion);

        var meteor = spawn('meteor', [ 'add', 'anti:gagarin@=' + nodeModuleVersion ], {

          stdio: verbose ? 'inherit' : 'ignore', cwd: pathToApp
        });

        /*
        meteor.stdout.on('data', function (data) {
          if (!verbose) {
            return;
          }
          process.stdout.write(chalk.gray(stripAnsi(data)));
        });
        */

        meteor.on('error', reject);

        meteor.on('exit', function (code) {
          if (code > 0) {
            return reject(new Error('meteor exited with code ' + code));
          }
          logs.system("anti:gagarin is now in version " + nodeModuleVersion);
          resolve();
        });

      }).catch(reject);

    }).catch(reject);

  }); // Promise
}
392558
def get_os_codename_package(package, fatal=True):
    ''''''

    if snap_install_requested():
        cmd = ['snap', 'list', package]
        try:
            out = subprocess.check_output(cmd)
            if six.PY3:
                out = out.decode('UTF-8')
        except subprocess.CalledProcessError:
            return None
        lines = out.split('\n')
        for line in lines:
            if package in line:
                # Second item in list is Version
                return line.split()[1]

    import apt_pkg as apt

    cache = apt_cache()

    try:
        pkg = cache[package]
    except Exception:
        if not fatal:
            return None
        # the package is unknown to the current apt cache.
        e = 'Could not determine version of package with no installation '\
            'candidate: %s' % package
        error_out(e)

    if not pkg.current_ver:
        if not fatal:
            return None
        # package is known, but no version is currently installed.
        e = 'Could not determine version of uninstalled package: %s' % package
        error_out(e)

    vers = apt.upstream_version(pkg.current_ver.ver_str)
    if 'swift' in pkg.name:
        # Fully x.y.z match for swift versions
        match = re.match(r'^(\d+)\.(\d+)\.(\d+)', vers)
    else:
        # x.y match only for 20XX.X
        # and ignore patch level for other packages
        match = re.match(r'^(\d+)\.(\d+)', vers)

    if match:
        vers = match.group(0)

    # Generate a major version number for newer semantic
    # versions of openstack projects
    major_vers = vers.split('.')[0]
    # >= Liberty independent project versions
    if (package in PACKAGE_CODENAMES and
            major_vers in PACKAGE_CODENAMES[package]):
        return PACKAGE_CODENAMES[package][major_vers]
    else:
        # < Liberty co-ordinated project versions
        try:
            if 'swift' in pkg.name:
                return get_swift_codename(vers)
            else:
                return OPENSTACK_CODENAMES[vers]
        except KeyError:
            if not fatal:
                return None
            e = 'Could not determine OpenStack codename for version %s' % vers
            error_out(e)
1229739
public function getVersion()
    {
        $composer = $this->getComposer();

        // try getting the version from the local repository
        $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
        foreach ($packages as $package) {
            if ($package->getName() === static::PACKAGE_NAME) {
                $version = $package->getPrettyVersion();
                break;
            }
        }

        // let's take a look at the aliases
        $aliases = $composer->getLocker()->getAliases();
        foreach ($aliases as $idx => $alias) {
            if ($alias['package'] === static::PACKAGE_NAME) {
                return $alias['alias'];
            }
        }

        // fallback to the hardcoded latest version, if "dev-master" was set
        if ($version === 'dev-master') {
            return $this->getLatestPhantomJsVersion();
        }

        // grab version from commit-reference, e.g. "dev-master#<commit-ref> as version"
        if (preg_match('/dev-master#(?:.*)(\d.\d.\d)/i', $version, $matches)) {
            return $matches[1];
        }

        // grab version from a Composer patch version tag with a patch level, like "1.9.8-p02"
        if (preg_match('/(\d.\d.\d)(?:(?:-p\d{2})?)/i', $version, $matches)) {
            return $matches[1];
        }

        // let's take a look at the root package
        if (!empty($version)) {
            $version = $this->getRequiredVersion($composer->getPackage());
        }

        return $version;
    }