solvapay 1.0.4 → 1.0.6

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 (3) hide show
  1. package/README.md +4 -1
  2. package/dist/cli.js +37 -8
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -7,12 +7,15 @@ SolvaPay CLI.
7
7
  ```bash
8
8
  # Run the SolvaPay CLI init flow
9
9
  npx solvapay init
10
+
11
+ # Skip browser confirmation prompt
12
+ npx solvapay init --yes
10
13
  ```
11
14
 
12
15
  ## What `solvapay init` does
13
16
 
14
17
  - Checks for `package.json` (and can create one if missing)
15
- - Opens browser authentication and waits for approval
18
+ - Shows auth URL and asks you to press Enter before opening browser authentication
16
19
  - Writes `SOLVAPAY_SECRET_KEY` to `.env` (with overwrite confirmation)
17
20
  - Ensures `.env` is ignored in `.gitignore`
18
21
  - Installs `@solvapay/server` and `@solvapay/core`
package/dist/cli.js CHANGED
@@ -353,10 +353,27 @@ var toPackageName = (cwd) => {
353
353
  return sanitized || "solvapay-app";
354
354
  };
355
355
  var askCreatePackageJson = async () => {
356
+ if (!stdin2.isTTY || !stdout2.isTTY) {
357
+ return true;
358
+ }
356
359
  const rl = readline2.createInterface({ input: stdin2, output: stdout2 });
357
360
  try {
358
- const answer = (await rl.question("No package.json found. Create one now? (y/N) ")).trim().toLowerCase();
359
- return answer === "y" || answer === "yes";
361
+ const answer = (await rl.question("No package.json found. Create one now? (Y/n) ")).trim().toLowerCase();
362
+ if (!answer) {
363
+ return true;
364
+ }
365
+ return answer !== "n" && answer !== "no";
366
+ } finally {
367
+ rl.close();
368
+ }
369
+ };
370
+ var waitForEnter = async (message) => {
371
+ if (!stdin2.isTTY || !stdout2.isTTY) {
372
+ return;
373
+ }
374
+ const rl = readline2.createInterface({ input: stdin2, output: stdout2 });
375
+ try {
376
+ await rl.question(message);
360
377
  } finally {
361
378
  rl.close();
362
379
  }
@@ -367,7 +384,7 @@ var ensureNodeProject = async (options = {}) => {
367
384
  if (await fileExists(packageJsonPath)) {
368
385
  return { filePath: packageJsonPath, action: "existing" };
369
386
  }
370
- const shouldCreate = options.confirmCreate ? await options.confirmCreate() : await askCreatePackageJson();
387
+ const shouldCreate = options.autoCreate ? true : options.confirmCreate ? await options.confirmCreate() : await askCreatePackageJson();
371
388
  if (!shouldCreate) {
372
389
  return { filePath: packageJsonPath, action: "cancelled" };
373
390
  }
@@ -457,11 +474,11 @@ var finishInstallProgressReporter = () => {
457
474
  process.stdout.write("\n");
458
475
  }
459
476
  };
460
- var runInitCommand = async () => {
477
+ var runInitCommand = async (options = {}) => {
461
478
  const apiBaseUrl = resolveApiBaseUrl();
462
479
  const cwd = process.cwd();
463
480
  printBanner();
464
- const projectCheck = await ensureNodeProject();
481
+ const projectCheck = await ensureNodeProject({ autoCreate: options.yes });
465
482
  if (projectCheck.action === "cancelled") {
466
483
  process.stdout.write("Initialization cancelled. Run `npm init -y` first, then `solvapay init`.\n");
467
484
  return;
@@ -474,8 +491,15 @@ var runInitCommand = async () => {
474
491
  process.stdout.write(`\u{1F50D} Detected ${packageManager} project (package.json found)
475
492
  `);
476
493
  }
477
- process.stdout.write("\u{1F310} Opening browser for authentication...\n");
478
494
  const initSession = await createInitSession(apiBaseUrl);
495
+ process.stdout.write(`\u{1F310} Browser authentication URL: ${initSession.authUrl}
496
+ `);
497
+ if (!options.yes) {
498
+ await waitForEnter(
499
+ "Press Enter to open your browser to authenticate and set up your account if you do not already have one. "
500
+ );
501
+ }
502
+ process.stdout.write("\u{1F310} Opening browser for authentication...\n");
479
503
  const opened = await openAuthUrl(initSession.authUrl);
480
504
  if (!opened) {
481
505
  process.stdout.write(` If it doesn't open, visit: ${initSession.authUrl}
@@ -543,10 +567,13 @@ var runInitCommand = async () => {
543
567
  var HELP_TEXT = `SolvaPay CLI
544
568
 
545
569
  Usage:
546
- solvapay <command>
570
+ solvapay <command> [flags]
547
571
 
548
572
  Commands:
549
573
  init Authenticate, configure .env, and install SolvaPay SDK packages
574
+
575
+ Flags for init:
576
+ -y, --yes Auto-create package.json and skip browser confirmation prompt
550
577
  `;
551
578
  var main = async () => {
552
579
  const command = process.argv[2];
@@ -556,7 +583,9 @@ var main = async () => {
556
583
  return;
557
584
  }
558
585
  if (command === "init") {
559
- await runInitCommand();
586
+ const initFlags = new Set(process.argv.slice(3));
587
+ const yes = initFlags.has("--yes") || initFlags.has("-y");
588
+ await runInitCommand({ yes });
560
589
  return;
561
590
  }
562
591
  process.stderr.write(`Unknown command: ${command}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solvapay",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "SolvaPay CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,9 +29,9 @@
29
29
  "inquirer": "^13.3.2",
30
30
  "open": "^11.0.0",
31
31
  "ora": "^9.3.0",
32
- "@solvapay/auth": "^1.0.4",
33
- "@solvapay/core": "^1.0.4",
34
- "@solvapay/server": "^1.0.4"
32
+ "@solvapay/server": "^1.0.6",
33
+ "@solvapay/core": "^1.0.6",
34
+ "@solvapay/auth": "^1.0.6"
35
35
  },
36
36
  "devDependencies": {
37
37
  "tsup": "^8.5.1",