Skip to content

Commit

Permalink
Enter OTP via enquirer (#12528)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Mar 24, 2022
1 parent 67edeea commit 0e6c1d5
Show file tree
Hide file tree
Showing 3 changed files with 376 additions and 583 deletions.
1 change: 1 addition & 0 deletions scripts/release/package.json
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"chalk": "4.1.2",
"enquirer": "2.3.6",
"execa": "6.1.0",
"minimist": "1.2.5",
"node-fetch": "3.2.3",
Expand Down
12 changes: 8 additions & 4 deletions scripts/release/steps/publish-to-npm.js
Expand Up @@ -2,6 +2,7 @@ import chalk from "chalk";
import outdent from "outdent";
import { execa } from "execa";
import semver from "semver";
import enquirer from "enquirer";
import {
getBlogPostInfo,
getChangelogContent,
Expand All @@ -15,11 +16,14 @@ const outdentString = outdent.string;
* Retry "npm publish" when to enter OTP is failed.
*/
async function retryNpmPublish() {
const runNpmPublish = () =>
execa("npm", ["publish"], {
cwd: "./dist",
stdio: "inherit", // we need to input OTP if 2FA enabled
const runNpmPublish = async () => {
const { otp } = await enquirer.prompt({
type: "input",
name: "otp",
message: "Please enter your npm OTP",
});
await execa("npm", ["publish", "--otp", otp], { cwd: "./dist" });
};
for (let i = 5; i > 0; i--) {
try {
return await runNpmPublish();
Expand Down

0 comments on commit 0e6c1d5

Please sign in to comment.