Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable no-console */
const chalk = require('chalk');
const fs = require('fs-extra');
const lerna = require('lerna');
const npm = require('./npm');
const pack = require('./pack');
const path = require('path');
const Repository = require('lerna/lib/Repository');
const integrationTestsDir = path.join(__dirname, '..', 'integration-tests');
const outputDir = path.join(integrationTestsDir, 'packages');
fs.mkdirsSync(outputDir);
const packages = lerna.getPackages(new Repository());
const packageLookup = packages.reduce((result, pkg) => {
result[pkg.name] = pkg;
return result;
}, {});
const packageTgz = {};
packages.forEach(pkg => {
console.log(`Packing ${pkg.name}...`);
const tgz = pack(pkg.location, pkg, outputDir);
packageTgz[pkg.name] = tgz;
});
const installed = new Set();
const install = pkg => {
if (installed.has(pkg.name)) {
return;
if (!project.get('private')) {
// NPMIGNORE
const ignoreFile = project.file('.npmignore');
const ignoreTemplate = templates.file('npmignore');
// "Append" configuration to `.npmignore`.
configurator(ignoreFile, ignoreTemplate.read(), '# RNA');
}
if (project.get('workspaces')) {
const lernaJson = project.file('lerna.json');
if (!lernaJson.exists()) {
const lernaPackage = require('lerna/package.json');
lernaJson.writeJson({
lerna: lernaPackage.version,
version: project.get('version') || '0.0.0',
npmClient: 'yarn',
useWorkspaces: true,
});
}
}
app.logger.success('package.json updated', project.localPath);
};
function main(argv) {
// For lerna publication to work, the NPM token must be stored in the .npmrc file in the user home directory
if ((process.env.TRAVIS || process.env.APPVEYOR) && process.env.NPM_TOKEN) {
fs.writeFileSync(
path.resolve(process.env.HOME, '.npmrc'),
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n`,
'utf8');
}
const context = {
lernaVersion: pkg.version,
};
// yargs instance.
// Add all the standard lerna commands + our custom travis-publish command
// This is a direct copy of the lerna cli setup with our custom travis command added.
return cli()
.command(addCmd)
.command(bootstrapCmd)
.command(changedCmd)
.command(cleanCmd)
.command(createCmd)
.command(diffCmd)
.command(execCmd)
.command(importCmd)
.command(initCmd)
.command(linkCmd)
function lernaBootstrap(scope) {
const cmd = new lerna.BootstrapCommand('', {
scope: scope,
loglevel: 'silent',
});
return cmd.run();
}
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;
function getAllPackages() {
const repository = new Repository();
return PackageUtilities.getPackages(repository);
}
const getAllPackages = function () {
const Repository = require('lerna/lib/Repository');
const PackageUtilities = require('lerna/lib/PackageUtilities');
return PackageUtilities.getPackages(new Repository());
};
function loadPackages({log = npmlog, packageConfigs} = {log: npmlog}) {
const repo = new Repository()
const effectivePackageConfigs = packageConfigs || repo.packageConfigs
if (packageConfigs) {
log.verbose('loadPackages', 'using provided packageConfigs', {
packageConfigs: effectivePackageConfigs
})
} else {
log.verbose('loadPackages', 'using default packageConfigs', {
packageConfigs: effectivePackageConfigs
})
}
const loadedPackages = PackageUtilities.getPackages({
rootPath: repo.rootPath,
packageConfigs: effectivePackageConfigs
})
const batched = PackageUtilities.topologicallyBatchPackages(loadedPackages)
return _.flatten(batched)
}