Skip to content

Commit

Permalink
feat(npm): add npm otp
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Sep 14, 2022
1 parent e791981 commit b1041d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Things to check before gettings started:
1. Monorepo has correct 'repository' entry in package.json
2. Names in individual packages package.json file is correct (matches glob path). For example, a package in 'packages/@foo/bar' should have '@foo/bar' as name.
3. REPO_COOKER_GITHUB_TOKEN is set in the environment where the script runs.
4. .npmrc has an authToken (npm login).
4. .npmrc has an authToken (npm login) and REPO_COOKER_NPM_OTP is set if you have two factor authentication
5. git login if publishing release (see .travis.yml as example)
6. 'latest' npm tag for packages already released use a semver version matching /^\d+.\d+\.
(any version with appe)
Expand Down
16 changes: 12 additions & 4 deletions src/Cooker/providers/NpmProvider/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ export function publish(config) {

return function publish(packageName, tag) {
const cwd = packagesPaths[packageName]
return runCommand('npm', ['publish', '--tag', tag, '--access', 'public'], {
cwd,
pause: true,
})
return runCommand(
'npm',
['publish', '--tag', tag, '--access', 'public'].concat(
process.env.REPO_COOKER_NPM_OTP
? [`--otp=${process.env.REPO_COOKER_NPM_OTP}`]
: []
),
{
cwd,
pause: true,
}
)
}
}

0 comments on commit b1041d5

Please sign in to comment.