Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit ec7d476

Browse files
committed
chore(release): support NPM OTP
- fix publish prompt not defaulting to (yes) as it indicates - fix npm audit warning
1 parent 89a5b97 commit ec7d476

File tree

3 files changed

+76
-86
lines changed

3 files changed

+76
-86
lines changed

package-lock.json

Lines changed: 64 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"fs-extra": "^8.1.0",
2626
"glob": "^7.1.6",
2727
"merge": "^1.2.1",
28-
"node-sass": "^4.13.0",
28+
"node-sass": "^4.13.1",
2929
"postcss": "^7.0.26",
3030
"request": "^2.88.0",
3131
"tar-fs": "^2.0.0",

scripts/release.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ function init() {
7272
success('> Successfully built a release.');
7373
log();
7474

75-
let shouldPublish = prompt('Do you want to publish the new version to NPM? (yes)') === 'yes';
75+
let response = prompt('Do you want to publish the new version to NPM? (yes)');
76+
let shouldPublish = response === 'yes' || response === '';
7677

7778
if (shouldPublish) {
79+
let oneTimePassword = prompt('Enter your NPM one-time password: ');
7880
info('> Publishing to NPM...');
7981

80-
if (publishPackage()) {
82+
if (publishPackage(oneTimePassword)) {
8183
success('> Successfully published package to NPM.');
8284
} else {
8385
error('An error occurred while publishing to NPM');
@@ -158,8 +160,13 @@ function updateVersion(newVersion) {
158160
fse.writeFileSync('../package.json', JSON.stringify(pkg, null, 2));
159161
}
160162

161-
function publishPackage() {
162-
let result = exec('npm publish', {
163+
/**
164+
* @param {string} oneTimePassword NPM 2fa token
165+
* @return {boolean}
166+
*/
167+
function publishPackage(oneTimePassword) {
168+
const publishCommand = oneTimePassword ? `npm publish --otp=${oneTimePassword}` : 'npm publish';
169+
let result = exec(publishCommand, {
163170
cwd: path.join(ROOT, config.outDir)
164171
}).toString().toLowerCase().trim();
165172

0 commit comments

Comments
 (0)