Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const child_process = require('child_process');
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const semver = require('semver')
const packages = {};
const fix = (process.argv.indexOf('--fix') !== -1);
const lernaDirectory = path.resolve('.');
const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json');
const lernaConfig = require(lernaConfigFile);
const targetVersion = lernaConfig.version;
const targetDependency = `${targetVersion}`;
packages['lerna.json'] = lernaConfig;
if (!semver.valid(targetVersion)) {
console.error(`Error: the version "${targetVersion}" in "${lernaConfigFile}" is invalid!`);
process.exit(1);
}
const masterPackageFile = path.resolve(lernaDirectory, 'package.json');
const masterPackage = require(masterPackageFile);
packages['package.json'] = masterPackage;
const packagesDirectory = path.resolve(lernaDirectory, 'packages');
const packageNames = fs.readdirSync(packagesDirectory);
packageNames.forEach((packageName) => {
const packageFile = path.resolve(packagesDirectory, packageName, 'package.json');
const thisPackage = require(packageFile);
packages[packageName] = thisPackage;
const child_process = require('child_process');
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const semver = require('semver')
const packages = {};
const fix = (process.argv.indexOf('--fix') !== -1);
const lernaDirectory = path.resolve('.');
const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json');
const lernaConfig = require(lernaConfigFile);
const targetVersion = lernaConfig.version;
const targetDependency = `^${targetVersion}`;
packages['lerna.json'] = lernaConfig;
if (!semver.valid(targetVersion)) {
console.error(`Error: the version "${targetVersion}" in "${lernaConfigFile}" is invalid!`);
process.exit(1);
}
const masterPackageFile = path.resolve(lernaDirectory, 'package.json');
const masterPackage = require(masterPackageFile);
packages['package.json'] = masterPackage;
const packagesDirectory = path.resolve(lernaDirectory, 'packages');
const packageNames = fs.readdirSync(packagesDirectory);
packageNames.forEach((packageName) => {
const packageFile = path.resolve(packagesDirectory, packageName, 'package.json');
const thisPackage = require(packageFile);
packages[packageName] = thisPackage;
const pkg = await loadPackageJson('packages', name.kebab);
pkg.version = newVersion;
if ('dependencies' in pkg) {
const deps = pkg.dependencies;
for (const depName in deps) {
if (depName.startsWith("@aurelia")) {
log(` dep ${name.npm} ${c.yellow(deps[depName])} -> ${c.greenBright(newVersion)}`);
deps[depName] = newVersion;
}
}
}
await savePackageJson(pkg, 'packages', name.kebab);
}
const lernaJson = JSON.parse(readFileSync(project['lerna.json'].path, { encoding: 'utf8' }));
lernaJson.version = newVersion;
writeFileSync(project['lerna.json'].path, `${JSON.stringify(lernaJson, null, 2)}\n`, { encoding: 'utf8' });
}
for (const { name } of project.packages) {
log(`updating dependencies for ${c.magentaBright(name.npm)}`);
const pkg = await loadPackageJson('packages', name.kebab);
pkg.version = newVersion;
if ('dependencies' in pkg) {
const deps = pkg.dependencies;
for (const depName in deps) {
if (depName.startsWith("@aurelia")) {
log(` dep ${name.npm} ${c.yellow(deps[depName])} -> ${c.greenBright(newVersion)}`);
deps[depName] = newVersion;
}
}
}
await savePackageJson(pkg, 'packages', name.kebab);
}
const lernaJson = JSON.parse(readFileSync(project['lerna.json'].path, { encoding: 'utf8' }));
lernaJson.version = newVersion;
writeFileSync(project['lerna.json'].path, `${JSON.stringify(lernaJson, null, 2)}\n`, { encoding: 'utf8' });
}