@samitouri / QOS-React-1 / commits / b195a947de

[compiler:publish] Prompt for OTP

Makes running the script a little more ergonomic by prompting for OTP upfront. ghstack-source-id: e9967bfde1ab01ff9417a848154743ae1926318d Pull Request resolved: https://github.com/facebook/react/pull/29149

Lauren Tan committed May 17, 2024 at 14:55 UTC b195a947deb47e507b8976721e2c5ba9febb35a5
4 files changed +47 -1
compiler/package.json
+1
@@ -40,6 +40,7 @@
40 "concurrently": "^7.4.0",
41 "folder-hash": "^4.0.4",
42 "ora": "5.4.1",
43 + "prompt-promise": "^1.0.3",
44 "rollup": "^4.13.2",
45 "rollup-plugin-banner2": "^1.2.3",
46 "rollup-plugin-prettier": "^4.1.1",
compiler/scripts/release/prompt-for-otp.js new
+18
@@ -0,0 +1,18 @@
1 +#!/usr/bin/env node
2 +
3 +const prompt = require("prompt-promise");
4 +
5 +const run = async () => {
6 + while (true) {
7 + const otp = await prompt("NPM 2-factor auth code: ");
8 + prompt.done();
9 + if (otp) {
10 + return otp;
11 + } else {
12 + console.error("\nTwo-factor auth is required to publish.");
13 + // (Ask again.)
14 + }
15 + }
16 +};
17 +
18 +module.exports = run;
compiler/scripts/release/publish-manual.js
+3 -1
@@ -4,6 +4,7 @@ const path = require("path");
4 const yargs = require("yargs");
5 const util = require("util");
6 const { hashElement } = require("folder-hash");
7 +const promptForOTP = require("./prompt-for-otp");
8
9 const PUBLISHABLE_PACKAGES = [
10 "babel-plugin-react-compiler",
@@ -145,6 +146,7 @@ async function main() {
146 }
147
148 if (forReal === true) {
149 + const otp = await promptForOTP();
150 const commit = await execHelper(
151 "git show -s --no-show-signature --format=%h",
152 {
@@ -204,7 +206,7 @@ async function main() {
206 try {
207 await spawnHelper(
208 "npm",
207 - [...opts, "--registry=https://registry.npmjs.org"],
209 + [...opts, "--registry=https://registry.npmjs.org", `--otp=${otp}`],
210 {
211 cwd: pkgDir,
212 stdio: "inherit",
compiler/yarn.lock
+25
@@ -7456,6 +7456,11 @@ json5@^2.1.2, json5@^2.2.3:
7456 array-includes "^3.1.5"
7457 object.assign "^4.1.3"
7458
7459 +keypress@~0.2.1:
7460 + version "0.2.1"
7461 + resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.2.1.tgz#1e80454250018dbad4c3fe94497d6e67b6269c77"
7462 + integrity sha512-HjorDJFNhnM4SicvaUXac0X77NiskggxJdesG72+O5zBKpSqKFCrqmndKVqpu3pFqkla0St6uGk8Ju0sCurrmg==
7463 +
7464 kind-of@^6.0.2:
7465 version "6.0.3"
7466 resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
@@ -7784,6 +7789,18 @@ nanoid@^3.3.6:
7789 resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
7790 integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
7791
7792 +native-or-another@~2.0.0:
7793 + version "2.0.0"
7794 + resolved "https://registry.yarnpkg.com/native-or-another/-/native-or-another-2.0.0.tgz#17a567f92beea9cd71acff96a7681a735eca3bff"
7795 + integrity sha512-rDE50rrX/PSk2StV5EnwpRk35TENl4I4ZsSGZsMJufLdAJ1P4YzNwVf5UOhjQodwz+RdTP9eZSG7FiqnoY25nA==
7796 + dependencies:
7797 + native-or-bluebird "^1.1.2"
7798 +
7799 +native-or-bluebird@^1.1.2:
7800 + version "1.2.0"
7801 + resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9"
7802 + integrity sha512-0SH8UubxDfe382eYiwmd12qxAbiWGzlGZv6CkMA+DPojWa/Y0oH4hE0lRtFfFgJmPQFyKXeB8XxPbZz6TvvKaQ==
7803 +
7804 natural-compare@^1.4.0:
7805 version "1.4.0"
7806 resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@@ -8373,6 +8390,14 @@ pretty-format@^29.3.1, pretty-format@^29.5.0:
8390 ansi-styles "^5.0.0"
8391 react-is "^18.0.0"
8392
8393 +prompt-promise@^1.0.3:
8394 + version "1.0.3"
8395 + resolved "https://registry.yarnpkg.com/prompt-promise/-/prompt-promise-1.0.3.tgz#78ce4fcb9a14a108c49174f2d808c440d1bde265"
8396 + integrity sha512-xIbGSzK59hFiwn9kmD0Cki4igpUqTVx7c6D8lqZoENAZyTwxhMhh/QleHWoRFVVusi7CTj/ByHP3N+2EmkhKIA==
8397 + dependencies:
8398 + keypress "~0.2.1"
8399 + native-or-another "~2.0.0"
8400 +
8401 prompts@^2.0.1:
8402 version "2.4.2"
8403 resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069"