Skip to content

Commit

Permalink
Merge pull request #2032 from hydrosquall/cameron.yick/permit-npm-aut…
Browse files Browse the repository at this point in the history
…omation-tokens

feat(plugins/npm): permit lerna publish to use automation tokens
  • Loading branch information
hipstersmoothie authored Aug 12, 2021
2 parents 374d460 + 3cfe77a commit 40f5c49
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
18 changes: 0 additions & 18 deletions plugins/npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,6 @@ No additional setup is required.

> Do you have a package in your monorepo you don't want to publish but still want versioned?
> Just set that `"private": true` you that package's `package.json`!
### Using automation tokens from NPM

If you have 2FA enabled and want to publish using an [automation token](https://github.blog/changelog/2020-10-02-npm-automation-tokens/) you _must_ add the following to your `lerna.json` for it to work.

```json
{
// ... other config here
"command": {
"publish": {
"verifyAccess": false
}
}
}
```

Lerna's verify access step hits an npm api endpoint that treats automation tokens differently than regular user tokens. Disabling it will bypass that failure. See [this lerna issue](https://github.com/lerna/lerna/issues/2788) for more context.

## Options

### setRcToken
Expand Down
1 change: 1 addition & 0 deletions plugins/npm/__tests__/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ describe("canary", () => {
"--no-git-reset",
"--no-git-tag-version",
"--exact",
"--no-verify-access"
]);
});

Expand Down
2 changes: 2 additions & 0 deletions plugins/npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ export default class NPMPlugin implements IPlugin {
"--no-git-reset", // so we can get the version that just published
"--no-git-tag-version", // no need to tag and commit,
"--exact", // do not add ^ to canary versions, this can result in `npm i` resolving the wrong canary version
"--no-verify-access", // permit automation tokens https://github.com/lerna/lerna/issues/2788
...(isIndependent
? ["--preid", canaryIdentifier.replace(/^-/, "")]
: []),
Expand Down Expand Up @@ -1266,6 +1267,7 @@ export default class NPMPlugin implements IPlugin {
"--yes",
// do not add ^ to next versions, this can result in `npm i` resolving the wrong next version
"--exact",
"--no-verify-access", // permit automation tokens https://github.com/lerna/lerna/issues/2788
"--no-commit-hooks",
...verboseArgs,
]);
Expand Down

0 comments on commit 40f5c49

Please sign in to comment.