@medipass/checkout-sdk 3.3.0-beta.7 → 3.3.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/release.mjs +31 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/checkout-sdk",
3
- "version": "3.3.0-beta.7",
3
+ "version": "3.3.0-beta.9",
4
4
  "description": "Medipass Checkout SDK",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /* eslint-disable no-undef */
3
3
 
4
- import { execSync } from 'child_process';
4
+ import { execSync, spawnSync } from 'child_process';
5
5
  import { readFileSync, writeFileSync } from 'fs';
6
6
  import * as readline from 'readline';
7
7
 
@@ -24,6 +24,22 @@ const exec = (cmd, options = {}) => {
24
24
  return execSync(cmd, { stdio: 'inherit', ...options });
25
25
  };
26
26
 
27
+ const execInteractive = (cmd) => {
28
+ if (dryRun) {
29
+ console.log(`\n[DRY RUN] Would execute: ${cmd}`);
30
+ return { status: 0 };
31
+ }
32
+ console.log(`\n> ${cmd}`);
33
+ const result = spawnSync(cmd, {
34
+ stdio: 'inherit',
35
+ shell: true,
36
+ });
37
+ if (result.status !== 0) {
38
+ throw new Error(`Command failed with exit code ${result.status}`);
39
+ }
40
+ return result;
41
+ };
42
+
27
43
  const execOutput = cmd => execSync(cmd, { encoding: 'utf-8' }).trim();
28
44
 
29
45
  const getCurrentBranch = () => execOutput('git rev-parse --abbrev-ref HEAD');
@@ -252,16 +268,20 @@ const main = async () => {
252
268
  console.log(`Created tag: ${tagName}`);
253
269
 
254
270
  console.log('\n--- Publishing to NPM ---');
255
- const otp = await question('Enter OTP code (or press Enter if 2FA not enabled): ');
256
- const otpFlag = otp.trim() ? ` --otp=${otp.trim()}` : '';
271
+ rl.close();
257
272
 
258
- if (releaseType === 'pre') {
259
- exec(`npm publish --tag next --ignore-scripts${otpFlag}`);
260
- } else {
261
- exec(`npm publish --ignore-scripts${otpFlag}`);
262
- }
263
-
264
- const pushConfirm = await question('\nPush commit and tag to remote? (y/n): ');
273
+ const publishCmd = releaseType === 'pre'
274
+ ? 'npm publish --tag next --ignore-scripts --registry https://registry.npmjs.org/'
275
+ : 'npm publish --ignore-scripts --registry https://registry.npmjs.org/';
276
+ execInteractive(publishCmd);
277
+
278
+ const rl2 = readline.createInterface({
279
+ input: process.stdin,
280
+ output: process.stdout,
281
+ });
282
+ const question2 = prompt => new Promise(resolve => rl2.question(prompt, resolve));
283
+
284
+ const pushConfirm = await question2('\nPush commit and tag to remote? (y/n): ');
265
285
  if (pushConfirm.toLowerCase() === 'y') {
266
286
  exec('git push');
267
287
  exec(`git push origin ${tagName}`);
@@ -275,7 +295,7 @@ const main = async () => {
275
295
  console.log(` Install with: npm install @medipass/checkout-sdk@next`);
276
296
  }
277
297
 
278
- rl.close();
298
+ rl2.close();
279
299
  };
280
300
 
281
301
  main().catch(err => {