Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
}
// 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')}`);
}
// 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(
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}`],
function getSortedPkgJSON(pkgInfo: T): T {
return fastCloneDeep(sortPackageJson(pkgInfo));
}
},
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;
};