Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OTP interface in release script #12528

Merged
merged 1 commit into from Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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