@stacksjs/cli 0.58.59 → 0.58.62

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.
package/dist/index.js CHANGED
@@ -42,6 +42,12 @@ async function exec(command, options) {
42
42
  process2.exit(exitCode);
43
43
  }
44
44
  });
45
+ if (options?.stdin === "pipe" && options.input) {
46
+ if (proc.stdin) {
47
+ proc.stdin.write(options.input);
48
+ proc.stdin.end();
49
+ }
50
+ }
45
51
  const exited = await proc.exited;
46
52
  if (exited === ExitCode.Success)
47
53
  return ok(proc);
@@ -382,7 +388,7 @@ stripColors
382
388
  } from "kolorist";
383
389
 
384
390
  // src/console.ts
385
- import {log as log2} from "@stacksjs/logging";
391
+ import {log as log2, logger} from "@stacksjs/logging";
386
392
  import prompts from "prompts";
387
393
 
388
394
  class Prompt {
@@ -399,43 +405,43 @@ class Prompt {
399
405
  }
400
406
  async select(message, options) {
401
407
  if (this.isRequired())
402
- return log2.prompt(message, { ...options, type: "select", required: true });
403
- return log2.prompt(message, { ...options, type: "select" });
408
+ return logger.prompt(message, { ...options, type: "select", required: true });
409
+ return logger.prompt(message, { ...options, type: "select" });
404
410
  }
405
411
  async checkbox(message, options) {
406
412
  if (this.isRequired())
407
- return log2.prompt(message, { ...options, type: "multiselect", required: true });
408
- return log2.prompt(message, { ...options, type: "multiselect" });
413
+ return logger.prompt(message, { ...options, type: "multiselect", required: true });
414
+ return logger.prompt(message, { ...options, type: "multiselect" });
409
415
  }
410
416
  async confirm(message, options) {
411
417
  if (this.isRequired())
412
- return log2.prompt(message, { ...options, type: "confirm", required: true });
413
- return log2.prompt(message, { ...options, type: "confirm" });
418
+ return logger.prompt(message, { ...options, type: "confirm", required: true });
419
+ return logger.prompt(message, { ...options, type: "confirm" });
414
420
  }
415
421
  async input(message, options) {
416
422
  if (this.isRequired())
417
- return log2.prompt(message, { ...options, type: "text", required: true });
418
- return log2.prompt(message, { ...options, type: "text" });
423
+ return logger.prompt(message, { ...options, type: "text", required: true });
424
+ return logger.prompt(message, { ...options, type: "text" });
419
425
  }
420
426
  async password(message, options) {
421
427
  if (this.isRequired())
422
- return log2.prompt(message, { ...options, type: "password", required: true });
423
- return log2.prompt(message, { ...options, type: "password" });
428
+ return logger.prompt(message, { ...options, type: "password", required: true });
429
+ return logger.prompt(message, { ...options, type: "password" });
424
430
  }
425
431
  async number(message, options) {
426
432
  if (this.isRequired())
427
- return log2.prompt(message, { ...options, type: "numeral", required: true });
428
- return log2.prompt(message, { ...options, type: "numeral" });
433
+ return logger.prompt(message, { ...options, type: "numeral", required: true });
434
+ return logger.prompt(message, { ...options, type: "numeral" });
429
435
  }
430
436
  async multiselect(message, options) {
431
437
  if (this.isRequired())
432
- return log2.prompt(message, { ...options, type: "multiselect", required: true });
433
- return log2.prompt(message, { ...options, type: "multiselect" });
438
+ return logger.prompt(message, { ...options, type: "multiselect", required: true });
439
+ return logger.prompt(message, { ...options, type: "multiselect" });
434
440
  }
435
441
  async autocomplete(message, options) {
436
442
  if (this.isRequired())
437
- return log2.prompt(message, { ...options, type: "autocomplete", required: true });
438
- return log2.prompt(message, { ...options, type: "autocomplete" });
443
+ return logger.prompt(message, { ...options, type: "autocomplete", required: true });
444
+ return logger.prompt(message, { ...options, type: "autocomplete" });
439
445
  }
440
446
  }
441
447
  var prompt = () => new Prompt;
@@ -496,7 +502,7 @@ import {log as log3} from "@stacksjs/logging";
496
502
  import {ExitCode as ExitCode2} from "@stacksjs/types";
497
503
  import {bgCyan as bgCyan2, bold as bold2, cyan as cyan2, dim as dim2, gray as gray2, green as green2, italic as italic2} from "kolorist";
498
504
  // package.json
499
- var version = "0.58.59";
505
+ var version = "0.58.62";
500
506
 
501
507
  // src/helpers.ts
502
508
  async function intro(command2, options) {
@@ -644,10 +650,10 @@ function parseOptions(options) {
644
650
  }
645
651
  }
646
652
  if (Object.keys(options).length === 0)
647
- return;
653
+ return { dryRun: false, quiet: false, verbose: false };
648
654
  Object.keys(options).forEach((key) => {
649
655
  if (!options)
650
- return;
656
+ return { dryRun: false, quiet: false, verbose: false };
651
657
  const value = options[key];
652
658
  if (value === "true" || value === "false")
653
659
  options[key] = value === "true";
@@ -695,6 +701,7 @@ export {
695
701
  parseArgs,
696
702
  outro,
697
703
  magenta,
704
+ logger,
698
705
  log2 as log,
699
706
  link,
700
707
  lightYellow,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cli",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.62",
5
5
  "description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
package/src/console.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { log } from '@stacksjs/logging'
1
+ import { log, logger } from '@stacksjs/logging'
2
2
  import prompts from 'prompts'
3
3
 
4
4
  export class Prompt {
@@ -19,61 +19,61 @@ export class Prompt {
19
19
 
20
20
  async select(message: any, options: any) {
21
21
  if (this.isRequired())
22
- return log.prompt(message, { ...options, type: 'select', required: true })
22
+ return logger.prompt(message, { ...options, type: 'select', required: true })
23
23
 
24
- return log.prompt(message, { ...options, type: 'select' })
24
+ return logger.prompt(message, { ...options, type: 'select' })
25
25
  }
26
26
 
27
27
  async checkbox(message: any, options: any) {
28
28
  if (this.isRequired())
29
- return log.prompt(message, { ...options, type: 'multiselect', required: true })
29
+ return logger.prompt(message, { ...options, type: 'multiselect', required: true })
30
30
 
31
- return log.prompt(message, { ...options, type: 'multiselect' })
31
+ return logger.prompt(message, { ...options, type: 'multiselect' })
32
32
  }
33
33
 
34
34
  async confirm(message: any, options: any) {
35
35
  if (this.isRequired())
36
- return log.prompt(message, { ...options, type: 'confirm', required: true })
36
+ return logger.prompt(message, { ...options, type: 'confirm', required: true })
37
37
 
38
- return log.prompt(message, { ...options, type: 'confirm' })
38
+ return logger.prompt(message, { ...options, type: 'confirm' })
39
39
  }
40
40
 
41
41
  async input(message: any, options: any) {
42
42
  if (this.isRequired())
43
- return log.prompt(message, { ...options, type: 'text', required: true })
43
+ return logger.prompt(message, { ...options, type: 'text', required: true })
44
44
 
45
- return log.prompt(message, { ...options, type: 'text' })
45
+ return logger.prompt(message, { ...options, type: 'text' })
46
46
  }
47
47
 
48
48
  async password(message: any, options: any) {
49
49
  if (this.isRequired())
50
- return log.prompt(message, { ...options, type: 'password', required: true })
50
+ return logger.prompt(message, { ...options, type: 'password', required: true })
51
51
 
52
- return log.prompt(message, { ...options, type: 'password' })
52
+ return logger.prompt(message, { ...options, type: 'password' })
53
53
  }
54
54
 
55
55
  async number(message: any, options: any) {
56
56
  if (this.isRequired())
57
- return log.prompt(message, { ...options, type: 'numeral', required: true })
57
+ return logger.prompt(message, { ...options, type: 'numeral', required: true })
58
58
 
59
- return log.prompt(message, { ...options, type: 'numeral' })
59
+ return logger.prompt(message, { ...options, type: 'numeral' })
60
60
  }
61
61
 
62
62
  async multiselect(message: any, options: any) {
63
63
  if (this.isRequired())
64
- return log.prompt(message, { ...options, type: 'multiselect', required: true })
64
+ return logger.prompt(message, { ...options, type: 'multiselect', required: true })
65
65
 
66
- return log.prompt(message, { ...options, type: 'multiselect' })
66
+ return logger.prompt(message, { ...options, type: 'multiselect' })
67
67
  }
68
68
 
69
69
  async autocomplete(message: any, options: any) {
70
70
  if (this.isRequired())
71
- return log.prompt(message, { ...options, type: 'autocomplete', required: true })
71
+ return logger.prompt(message, { ...options, type: 'autocomplete', required: true })
72
72
 
73
- return log.prompt(message, { ...options, type: 'autocomplete' })
73
+ return logger.prompt(message, { ...options, type: 'autocomplete' })
74
74
  }
75
75
  }
76
76
 
77
- export { prompts, log }
77
+ export { prompts, logger, log }
78
78
 
79
79
  export const prompt = () => new Prompt()
package/src/exec.ts CHANGED
@@ -50,12 +50,15 @@ export async function exec(command: string | string[], options?: CliOptions): Pr
50
50
  })
51
51
 
52
52
  // Check if we need to write to stdin
53
- // if (options?.stdin === 'pipe' && options.input) {
54
- // if (proc.stdin) {
55
- // proc.stdin.write(options.input)
56
- // proc.stdin.end()
57
- // }
58
- // }
53
+ // this is currently only used for `buddy aws:configure`
54
+ if (options?.stdin === 'pipe' && options.input) {
55
+ if (proc.stdin) {
56
+ // @ts-expect-error - this works even though there is a type error
57
+ proc.stdin.write(options.input)
58
+ // @ts-expect-error - this works even though there is a type error
59
+ proc.stdin.end()
60
+ }
61
+ }
59
62
 
60
63
  const exited = await proc.exited
61
64
  if (exited === ExitCode.Success)
package/src/parse.ts CHANGED
@@ -109,7 +109,7 @@ interface CliOptions {
109
109
  [k: string]: string | boolean | number | undefined
110
110
  }
111
111
 
112
- export function parseOptions(options?: CliOptions): CliOptions | undefined {
112
+ export function parseOptions(options?: CliOptions): CliOptions {
113
113
  options = options || {}
114
114
  const args = process.argv.slice(2)
115
115
 
@@ -140,12 +140,12 @@ export function parseOptions(options?: CliOptions): CliOptions | undefined {
140
140
 
141
141
  // if options has no keys, return undefined, e.g. `buddy release`
142
142
  if (Object.keys(options).length === 0)
143
- return undefined
143
+ return { dryRun: false, quiet: false, verbose: false }
144
144
 
145
145
  // convert the string 'true' or 'false' to a boolean
146
146
  Object.keys(options).forEach((key) => {
147
147
  if (!options)
148
- return
148
+ return { dryRun: false, quiet: false, verbose: false }
149
149
 
150
150
  const value = options[key]
151
151