Skip to content

Commit 4f57275

Browse files
committed
chore: improve release script with OTP prompt
1 parent dd90f39 commit 4f57275

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

cypress/support/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
2222
//
2323
//
24-
// -- This is will overwrite an existing command --
24+
// -- This will overwrite an existing command --
2525
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
2626
import '@4tw/cypress-drag-drop';
2727
import { convertPosition } from './common';

scripts/release.mjs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,7 @@ const pkg = loadJsonFileSync(path.join(__dirname, '../', 'package.json'));
141141
} else if (whichBumpType.includes('beta')) {
142142
publishTagName = 'beta';
143143
}
144-
let otp = '';
145-
if (await promptConfirmation(`${c.bgMagenta(dryRunPrefix)} Do you have OTP (One-Time-Password) enabled?`, undefined, 1)) {
146-
otp = await promptOtp();
147-
}
144+
const otp = await promptOtp(dryRunPrefix);
148145
await publishPackage(publishTagName, { cwd, otp, dryRun: argv.dryRun });
149146
console.log(`${c.bgMagenta(dryRunPrefix)} 📦 Published to NPM - 🔗 https://www.npmjs.com/package/${pkg.name}`.trim())
150147
}
@@ -280,18 +277,20 @@ async function promptConfirmation(message, choices, defaultIndex) {
280277
}
281278

282279
// get and process input
283-
const input = await getConsoleInput(`Enter value (default ${(defaultIndex + 1)}) `);
280+
const input = await getConsoleInput(`Enter value (default ${(defaultIndex + 1)}): `);
284281
var index = !isNaN(input) && !isNaN(parseFloat(input)) ? +input - 1 : defaultIndex;
285282
if (index < 0 || index >= choices.length) {
286283
throw Error(`The input ${input} could not be matched to a selection`);
287284
}
288285
return choices[index].value;
289286
}
290287

291-
async function promptOtp() {
292-
const otp = await getConsoleInput(`Enter OTP value:`);
293-
if (otp.length < 6) {
294-
throw new Error('OTP must be 6 digits.');
288+
async function promptOtp(dryRunPrefix = '') {
289+
const otp = await getConsoleInput(`${c.bgMagenta(dryRunPrefix)} If you have an OTP (One-Time-Password), type it now or press "Enter" to continue: \n`);
290+
if (!otp) {
291+
console.log('No OTP provided, continuing to next step...')
292+
} else if (otp.length > 0 && otp.length < 6) {
293+
throw new Error('OTP must be 6 exactly digits.');
295294
}
296295
return otp;
297296
}

0 commit comments

Comments
 (0)