Fixing package.json
181956
static function packageJson($project_directory, $app_engine_project, $app_engine_service, $package_json_defaults = []) {
        $package_json_location = $project_directory . DIRECTORY_SEPARATOR . "package.json";
        $package_json_content = Files::getJson($package_json_location, []);
        $package_json_content = array_merge([
            "name" => null,
            "project" => null,
            "private" => null,
        ], $package_json_content);
        $project_name = $app_engine_project . '-' . $app_engine_service;
        $package_json_defaults["private"] = true;
        $package_json_content["name"] = $project_name;
        $package_json_content["project"] = $app_engine_project;
        foreach ($package_json_defaults as $key => $val) {
            $package_json_content[$key] = $val;
        }
        if ($app_engine_service == "default") {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml queue.yaml --project $npm_package_project --promote --quiet';
        } else {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml --project $npm_package_project --promote --quiet';
        }
        $gaeutil_json = Files::getJson(Conf::getGaeUtilJsonPath($project_directory), []);

        $project_key_name = $gaeutil_json[Secrets::CONF_PROJECT_KEY_NAME];
        $project_key = Secrets::reverseKmsKey($project_key_name);
        $crypt_params = [
            "ciphertext-file" => "config/secrets.cipher",
            "plaintext-file" => "secrets.json",
            "project" => $project_key["project"],
            "location" => $project_key["location"],
            "keyring" => $project_key["keyRing"],
            "key" => $project_key["cryptoKey"]
        ];
        $package_json_content["scripts"]["encrypt"] = self::commandMaker("gcloud kms encrypt", $crypt_params);
        $package_json_content["scripts"]["decrypt"] = self::commandMaker("gcloud kms decrypt", $crypt_params);
        $package_json_content["scripts"]["devserve"] = 'dev_appserver.py --port=5000 . -A $npm_package_project';
        if (Files::putJson($package_json_location, $package_json_content)) {
            Util::cmdline("Updated package.json in $project_name");
        }

    }
830914
function updateAllPackages(rootPkgPath, packagesPath) {
  const paths = findPackages(packagesPath);

  return paths.reduce((promise, pkgPath) => promise.then(() => updateSinglePackage(rootPkgPath, pkgPath)), Promise.resolve());
}
934646
function ()
		{
			var nmPath = this.modulePath + 'node_modules/';
			var pkgJson;
			var pkgName;
			var pkgInfo;
			var packageList = {};
			var validScript = /[\w|\W]+\.[js|coffee]+$/;
			if (fs.existsSync(nmPath))
			{
				this.e.log&&this.e.log('Importing packages...','system');
				var packages = fs.readdirSync(nmPath);
				for (p in packages)
				{
					try {
						if (packages[p].indexOf('wns')!==-1 &&
							(packages[p].indexOf('pkg') !== -1 || packages[p].indexOf('package') !== -1))
						{
							pkgName = packages[p];
							pkgDir = nmPath + pkgName;
							pkgJson = pkgDir + '/package.json';
							if (fs.existsSync(pkgJson))
							{
								pkgInfo = JSON.parse(fs.readFileSync(pkgJson));
								pkgInfo.require = pkgInfo.require||{};
								Object.defineProperty(pkgInfo,'classes',{ value: {}, enumerable: false })
								var files = fs.readdirSync(pkgDir);
								for (f in files)
								{
									var fileName = files[f].split('/').pop();
									if (validScript.test(fileName))
									{
										var className = fileName.split('.');
										className.splice(-1);
										pkgInfo.classes[className] = pkgDir+'/'+fileName;
									}
								}
								packageList[pkgInfo.name]=pkgInfo;
							}
						}
					} catch (e)
					{
						console.error('Error on loading package `'+pkgName+"`.")
						throw e;
					}
				}
			}

			this.removeInvalidPackages(packageList);
			this.loadPackages(packageList);
		}
1295693
function loadPackageJSONConfigFile(filePath) {
    debug(`Loading package.json config file: ${filePath}`);
    try {
        return loadJSONConfigFile(filePath).eslintConfig || null;
    } catch (e) {
        debug(`Error reading package.json file: ${filePath}`);
        e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
        throw e;
    }
}
393894
def fix(self, to_file=None):
        
        self.packer_cmd = self.packer.fix

        self._add_opt(self.packerfile)

        result = self.packer_cmd()
        if to_file:
            with open(to_file, 'w') as f:
                f.write(result.stdout.decode())
        result.fixed = json.loads(result.stdout.decode())
        return result
1335698
function(o) {
        this.__base(o);
        this.root = o.root;
        this.target = o.target;
        this.npmPackages = o.npmPackages === undefined? ['package.json']: o.npmPackages;
    }
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 + '.')
      })
    })
  })
}
1330085
function updateMaster () {
    pushCmds.push(
        comment('update package.json in master'),
        'git checkout master',
        `git pull --rebase ${origin} master --strategy=theirs`,
        `git checkout release/${newVersion} -- CHANGELOG.md`,
        `node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`,
        'git add CHANGELOG.md',
        'git add package.json',
        `git commit -m "update version number in package.json to ${newVersion}"`,
        `git push ${origin} master`
    );

    function buildCommand () {
      require('fs').writeFileSync('package.json', JSON.stringify(getUpdatedJson(), null, 2));
      function getUpdatedJson () {
        const json = require('./package.json');
        json.version = newVersion;
        return json;
      }
    }

    function stringifyFunction (method) {
      return method
          .toString()
          .split('\n')
          .slice(1, -1)
          .map(function (line) { return line.trim(); })
          .join(' ')
          .replace(/"/g, '\\"');
    }
  }
61457
def npm(package_json, output_file, pinned_file):
    """"""
    amd_build_deprecation_warning()
    try:
        version = get_distribution(current_app.name).version
    except DistributionNotFound:
        version = ''

    output = {
        'name': current_app.name,
        'version': make_semver(version) if version else version,
        'dependencies': {},
    }

    # Load base file
    if package_json:
        output = dict(output, **json.load(package_json))

    # Iterate over bundles
    deps = extract_deps(current_app.extensions['invenio-assets'].env,
                        click.echo)
    output['dependencies'].update(deps)

    # Load pinned dependencies
    if pinned_file:
        output['dependencies'].update(
            json.load(pinned_file).get('dependencies', {}))

    # Write to static folder if output file is not specified
    if output_file is None:
        if not os.path.exists(current_app.static_folder):
            os.makedirs(current_app.static_folder)
        output_file = open(
            os.path.join(current_app.static_folder, 'package.json'),
            'w')

    click.echo('Writing {0}'.format(output_file.name))
    json.dump(output, output_file, indent=4)
    output_file.close()
133689
function() {
  var originalPackageJson;
  var cleanPackageJson = function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(){
      return originalPackageJson;
    }, {
      'end_with_newline': true
    }))
    .pipe(gulp.dest(__dirname + '/'));
  };

  /* Lazy dependencies installation */
  gulp.task('dirty-install-dep', function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      var
        tplName = addons.templates[
          (config.modules && config.modules.templates) || 'handlebars'
        ].name,
        styleName = addons.styles[
          (config.modules && config.modules.styles) || 'less'
        ].name;
      originalPackageJson = JSON.parse(JSON.stringify(json));
      json.dependencies[tplName] = lazyDependencies[tplName];
      json.dependencies[styleName] = lazyDependencies[styleName];
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dep', ['dirty-install-dep'], cleanPackageJson);

  /* Lazy dev dependencies installation */
  gulp.task('dirty-install-dev-dep', ['dirty-install-dep'], function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      addons.dev.forEach(function(moduleName) {
        json.dependencies[moduleName] = lazyDependencies[moduleName];
      });
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dev-dep', ['dirty-install-dev-dep'], cleanPackageJson);
}
1321429
function getPackageVersion() {
  var packageJson = path.join(process.cwd(), 'package.json'),
    version;
  try {
    version = require(packageJson).version;
  } catch (unused) {
    throw new Error('Could not load package.json, please make sure it exists');
  }
  if (!semver.valid(version)) {
    throw new Error('Invalid version number found in package.json, please make sure it is valid');
  }

  return [ semver.major(version), semver.minor(version), semver.patch(version) ].join('.');
}
133047
function (done) {
      var p = clone(pkg);
      delete p.devDependencies;
      var content = JSON.stringify(p, null, 2);
      write_if_not_exists('package.json', content, done);
    }
176968
function _updatePjson(siteId) {
  pjson.vapid.site = siteId;
  writePkg.sync(pjsonPath, pjson);
}
6410
def _fix_json_agents(ag_obj):
    """"""
    if isinstance(ag_obj, str):
        logger.info("Fixing string agent: %s." % ag_obj)
        ret = {'name': ag_obj, 'db_refs': {'TEXT': ag_obj}}
    elif isinstance(ag_obj, list):
        # Recursive for complexes and similar.
        ret = [_fix_json_agents(ag) for ag in ag_obj]
    elif isinstance(ag_obj, dict) and 'TEXT' in ag_obj.keys():
        ret = deepcopy(ag_obj)
        text = ret.pop('TEXT')
        ret['db_refs']['TEXT'] = text
    else:
        ret = ag_obj
    return ret
1222420
def get_package(repo_url, pkg_name, timeout=1):
    """"""
    url = repo_url + "/packages/" + pkg_name
    headers = {'accept': 'application/json'}
    resp = requests.get(url, headers=headers, timeout=timeout)
    if resp.status_code == 404:
        return None
    return resp.json()
339199
function _copyPackageJson(from, to) {
  return new Promise((resolve, reject) => {
    const origin = path.join(from, 'package.json');
    const destination = path.join(to, 'package.json');
    let data = JSON.parse(fs.readFileSync(origin, 'utf-8'));
    delete data.engines;
    delete data.scripts;
    delete data.devDependencies;
    fs.writeFileSync(destination, JSON.stringify(data, null, 2));
    resolve();
  });
}
1190150
function(next) {
            core.allowPackages.forEach(function(pkg) {
                try {
                    var mod = path.dirname(require.resolve(pkg)).replace(/\/lib$/, "");
                    core.packages[pkg] = { path: mod };
                    if (lib.statSync(mod + "/etc").isDirectory()) {
                        core.packages[pkg].etc = 1;
                        var cfg = lib.readFileSync(mod + "/etc/config");
                        if (cfg) {
                            config = cfg + "\n" + config;
                            core.packages[pkg].config = 1;
                            core.parseConfig(cfg, 1);
                        }
                    }
                    ["modules","locales","views","web"].forEach(function(x) {
                        if (lib.statSync(mod + "/" + x).isDirectory()) {
                            core.path[x].unshift(mod + "/" + x);
                            core.packages[pkg][x] = 1;
                        }
                    });
                    logger.debug("init:", "npm package:", pkg, core.packages[pkg]);
                } catch(e) {
                    logger.error("init:", "npm package:", pkg, e);
                }
            });
            next();
        }