Enter OTP via enquirer (#12528)
This commit is contained in:
1 parent
67edeeaf72
commit
0e6c1d58d8
3 files changed
+376
-583
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
@@ -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();
|
||||
|
||||
+367
-579
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user