How to use sort-package-json - 5 common examples

To help you get started, we’ve selected a few sort-package-json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jaebradley / fruit / src / executor.js View on Github external
});
  }

  // pretty shitty but have to put this last because it has a meaningful deploy script
  if (isSemanticRelease) {
    await writeSemanticReleaseTemplates({
      templateValues,
      destination: destinationDirectory,
    });
  }

  const packageJSONLocation = `${destinationDirectory}/package.json`;
  const packageJSON = fse.readJsonSync(packageJSONLocation, 'utf8');

  normalizePackageData(packageJSON);
  fse.writeJsonSync(packageJSONLocation, sortPackageJSON(packageJSON), 'utf8');

  console.log(chalk.bold.cyanBright('⌛ 🤞 Installing packages'));
  await spawn('npm', ['install'], { cwd: destinationDirectory, stdio: 'inherit' });
  await spawn('git', ['init'], { cwd: destinationDirectory, stdio: 'inherit' });

  console.log(chalk.bold.magentaBright('🥝  🍋  🍐  🍓  🍊  🍍  🍰  Installation complete! 🍒  🍈  🍇  🍉  🍏  🍎  🍌'));
  console.log();

  console.log(`🎭  ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('jest')} ${chalk.bold.magentaBright('tests')}: ${chalk.bold.cyanBright('npm run test')} `);
  console.log(`🏗️  ${chalk.bold.magentaBright('Build')} ${chalk.bold.blueBright('rollup.js')} ${chalk.bold.magentaBright('library')}: ${chalk.bold.cyanBright('npm run build')}`);
  console.log(`👕  ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('eslint')}: ${chalk.bold.cyanBright('npm run lint')}`);

  if (isReact) {
    console.log(`📖  ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('Storybook')}: ${chalk.bold.cyanBright('npm run storybook')}`);
  }
github umijs / umi / packages / umi-build-dev / src / plugins / commands / block / installDependencies.js View on Github external
// find lack conflict, auto install
  if (dryRun) {
    debug('dryRun is true, skip install dependencies');
    return;
  }

  if (skipDependencies) {
    // 中间层转化
    // [["react","16.5"]] => {"react":16.5}
    const dependencies = depsArrayToObject(lacks);
    const devDependencies = depsArrayToObject(devLacks);

    // 格式化 package.json
    const content = JSON.stringify(
      sortPackageJson({
        ...projectPkg,
        dependencies: { ...dependencies, ...projectPkg.dependencies },
        devDependencies: { ...devDependencies, ...projectPkg.devDependencies },
      }),
      null,
      2,
    );
    // 写入文件
    writeFileSync(projectPkgPath, content);
    return;
  }

  // 安装依赖
  if (lacks.length) {
    const deps = lacks.map(dep => `${dep[0]}@${dep[1]}`);
    spinner.start(
github terascope / teraslice / packages / scripts / src / helpers / misc.ts View on Github external
function _getRootInfo(pkgJSONPath: string): RootPackageInfo | undefined {
    const pkg = fse.readJSONSync(pkgJSONPath);
    const isRoot = get(pkg, 'terascope.root', false);
    if (!isRoot) return undefined;

    const dir = path.dirname(pkgJSONPath);
    const folderName = path.basename(dir);

    return sortPackageJson(defaultsDeep(pkg, {
        dir,
        folderName,
        displayName: getName(pkg.name),
        documentation: '',
        homepage: '',
        bugs: {
            url: '',
        },
        terascope: {
            root: isRoot,
            type: 'monorepo',
            tests: {
                services: []
            },
            docker: {
                registries: [`terascope/${folderName}`],
github terascope / teraslice / packages / scripts / src / helpers / packages.ts View on Github external
function getSortedPkgJSON(pkgInfo: T): T {
    return fastCloneDeep(sortPackageJson(pkgInfo));
}
github osdevisnot / klap / src / init.js View on Github external
},
    devDependencies: {
      [cli.name]: cli.version,
    },
  });
  if (template !== 'js') {
    pkg = merge(pkg, { klap: { example: `public/index.${template}` } });
    if (template === 'ts' || template === 'tsx') {
      pkg = merge(pkg, {
        types: 'dist/types',
        scripts: { postbuild: 'tsc -p tsconfig.json' },
        devDependencies: { typescript: cli.devDependencies['typescript'] },
      });
    }
  }
  await write('./package.json', JSON.stringify(sort(pkg), null, '  '));
  info('\t- wrote ./package.json');
  return pkg;
};

sort-package-json

Sort an Object or package.json based on the well-known package.json keys

MIT
Latest version published 25 days ago

Package Health Score

85 / 100
Full package analysis

Popular sort-package-json functions