From 6d7184879057d8e87644e16772aea79fbc9fa6bd Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Fri, 21 Oct 2022 16:32:08 -0700 Subject: [PATCH] feat(version): specify npmClientArgs with version command --- commands/version/command.js | 4 ++++ commands/version/index.js | 10 ++++++++-- core/lerna/schemas/lerna-schema.json | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/commands/version/command.js b/commands/version/command.js index 80b9c6e7278..1d6d5205fc5 100644 --- a/commands/version/command.js +++ b/commands/version/command.js @@ -164,6 +164,10 @@ exports.builder = (yargs, composed) => { requiresArg: true, defaultDescription: "v", }, + "npm-client-args": { + describe: "Additional arguments to pass to the npm client when performing 'npm install'.", + type: "array", + }, y: { describe: "Skip all confirmation prompts.", alias: "yes", diff --git a/commands/version/index.js b/commands/version/index.js index a6bfa7d5d68..85a03571f47 100644 --- a/commands/version/index.js +++ b/commands/version/index.js @@ -614,11 +614,13 @@ class VersionCommand extends Command { ); } + const npmClientArgs = this.options.npmClientArgs || []; + if (this.options.npmClient === "pnpm") { chain = chain.then(() => { this.logger.verbose("version", "Updating root pnpm-lock.yaml"); return childProcess - .exec("pnpm", ["install", "--lockfile-only", "--ignore-scripts"], this.execOpts) + .exec("pnpm", ["install", "--lockfile-only", "--ignore-scripts", ...npmClientArgs], this.execOpts) .then(() => { const lockfilePath = path.join(this.project.rootPath, "pnpm-lock.yaml"); changedFiles.add(lockfilePath); @@ -632,7 +634,11 @@ class VersionCommand extends Command { chain = chain.then(() => { this.logger.verbose("version", "Updating root package-lock.json"); return childProcess - .exec("npm", ["install", "--package-lock-only", "--ignore-scripts"], this.execOpts) + .exec( + "npm", + ["install", "--package-lock-only", "--ignore-scripts", ...npmClientArgs], + this.execOpts + ) .then(() => { changedFiles.add(lockfilePath); }); diff --git a/core/lerna/schemas/lerna-schema.json b/core/lerna/schemas/lerna-schema.json index f052890fe13..10b4e387e2c 100644 --- a/core/lerna/schemas/lerna-schema.json +++ b/core/lerna/schemas/lerna-schema.json @@ -1120,6 +1120,9 @@ "npmClient": { "$ref": "#/$defs/globals/npmClient" }, + "npmClientArgs": { + "$ref": "#/$defs/globals/npmClientArgs" + }, "loglevel": { "$ref": "#/$defs/globals/loglevel" }, @@ -1420,6 +1423,13 @@ "default": "npm", "enum": ["npm", "yarn", "pnpm"] }, + "npmClientArgs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Arguments to pass to the npm client when running commands." + }, "loglevel": { "type": "string", "description": "The level of logging to use when running commands. Defaults to info if unspecified.",