Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// inject --dist-tag into opts, if present
const distTag = this.getDistTag();
if (distTag) {
this.conf.set("tag", distTag.trim(), "cli");
}
// a "rooted leaf" is the regrettable pattern of adding "." to the "packages" config in lerna.json
this.hasRootedLeaf = this.packageGraph.has(this.project.manifest.name);
if (this.hasRootedLeaf) {
this.logger.info("publish", "rooted leaf detected, skipping synthetic root lifecycles");
}
this.runPackageLifecycle = createRunner(this.options);
// don't execute recursively if run from a poorly-named script
this.runRootLifecycle = /^(pre|post)?publish$/.test(process.env.npm_lifecycle_event)
? stage => {
this.logger.warn("lifecycle", "Skipping root %j because it has already been called", stage);
}
: stage => this.runPackageLifecycle(this.project.manifest, stage);
let chain = Promise.resolve();
if (this.options.bump === "from-git") {
chain = chain.then(() => this.detectFromGit());
} else if (this.options.bump === "from-package") {
chain = chain.then(() => this.detectFromPackage());
} else if (this.options.canary) {
chain = chain.then(() => this.detectCanaryVersions());
if (!this.updates.length) {
this.logger.success(`No changed packages to ${this.composed ? "publish" : "version"}`);
// still exits zero, aka "ok"
return false;
}
// a "rooted leaf" is the regrettable pattern of adding "." to the "packages" config in lerna.json
this.hasRootedLeaf = this.packageGraph.has(this.project.manifest.name);
if (this.hasRootedLeaf && !this.composed) {
this.logger.info("version", "rooted leaf detected, skipping synthetic root lifecycles");
}
this.runPackageLifecycle = createRunner(this.options);
// don't execute recursively if run from a poorly-named script
this.runRootLifecycle = /^(pre|post)?version$/.test(process.env.npm_lifecycle_event)
? stage => {
this.logger.warn("lifecycle", "Skipping root %j because it has already been called", stage);
}
: stage => this.runPackageLifecycle(this.project.manifest, stage);
const tasks = [
() => this.getVersionsForUpdates(),
versions => this.setUpdatesForVersions(versions),
() => this.confirmVersions(),
];
// amending a commit probably means the working tree is dirty
if (this.commitAndTag && this.gitOpts.amend !== true) {
if (nohoist) {
if (!Array.isArray(nohoist)) {
// `--nohoist` single
hoisting = hoisting.concat(`!${nohoist}`);
} else {
// `--nohoist` multiple or lerna.json `nohoist: [...]`
hoisting = hoisting.concat(nohoist.map(str => `!${str}`));
}
}
this.logger.verbose("hoist", "using globs %j", hoisting);
this.hoisting = hoisting;
}
this.runPackageLifecycle = createRunner({ registry });
this.npmConfig = {
registry,
npmClient,
npmClientArgs,
mutex,
};
if (npmClient === "npm" && this.options.ci && hasNpmVersion(">=5.7.0")) {
// never `npm ci` when hoisting
this.npmConfig.subCommand = this.hoisting ? "install" : "ci";
if (this.hoisting) {
// don't mutate lockfiles in CI
this.npmConfig.npmClientArgs.unshift("--no-save");
}
}