stacks 0.58.57 → 0.58.59

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 (184) hide show
  1. package/core/actions/dist/src/build.js +18 -26
  2. package/core/actions/dist/src/bump.js +9 -3
  3. package/core/actions/dist/src/changelog.js +11 -3
  4. package/core/actions/dist/src/dev/index.js +18 -26
  5. package/core/actions/dist/src/generate/index.js +18 -26
  6. package/core/actions/dist/src/helpers/index.js +18 -26
  7. package/core/actions/dist/src/helpers/utils.js +18 -26
  8. package/core/actions/dist/src/index.js +35 -37
  9. package/core/actions/dist/src/lint/fix.js +3 -2
  10. package/core/actions/dist/src/release.js +39 -38
  11. package/core/actions/dist/src/upgrade/index.js +18 -26
  12. package/core/actions/dist/src/upgrade.js +1 -1
  13. package/core/actions/package.json +1 -1
  14. package/core/actions/src/action.ts +11 -3
  15. package/core/actions/src/bump.ts +13 -6
  16. package/core/actions/src/changelog.ts +14 -4
  17. package/core/actions/src/helpers/utils.ts +24 -36
  18. package/core/actions/src/lint/fix.ts +3 -2
  19. package/core/actions/src/release.ts +4 -1
  20. package/core/ai/dist/index.js +31 -29
  21. package/core/ai/package.json +3 -3
  22. package/core/alias/package.json +1 -1
  23. package/core/analytics/package.json +1 -1
  24. package/core/api/dist/index.js +6 -3
  25. package/core/api/package.json +1 -1
  26. package/core/arrays/package.json +1 -1
  27. package/core/auth/package.json +1 -1
  28. package/core/buddy/dist/chunk-59a9de11428ba763.js +993 -0
  29. package/core/buddy/dist/{chunk-e9c0ec1a3b7be088.js → chunk-7b24d1e3e585766e.js} +594 -563
  30. package/core/buddy/dist/cli.js +3916 -19
  31. package/core/buddy/dist/index.js +2 -5
  32. package/core/buddy/package.json +1 -1
  33. package/core/buddy/src/cli.ts +91 -17
  34. package/core/buddy/src/commands/add.ts +3 -0
  35. package/core/buddy/src/commands/build.ts +42 -27
  36. package/core/buddy/src/commands/changelog.ts +13 -6
  37. package/core/buddy/src/commands/clean.ts +3 -1
  38. package/core/buddy/src/commands/cloud.ts +14 -2
  39. package/core/buddy/src/commands/commit.ts +2 -0
  40. package/core/buddy/src/commands/configure.ts +6 -3
  41. package/core/buddy/src/commands/create.ts +3 -1
  42. package/core/buddy/src/commands/deploy.ts +3 -1
  43. package/core/buddy/src/commands/dev.ts +50 -36
  44. package/core/buddy/src/commands/dns.ts +7 -1
  45. package/core/buddy/src/commands/domains.ts +7 -1
  46. package/core/buddy/src/commands/fresh.ts +4 -2
  47. package/core/buddy/src/commands/generate.ts +36 -26
  48. package/core/buddy/src/commands/http.ts +6 -4
  49. package/core/buddy/src/commands/index.ts +0 -2
  50. package/core/buddy/src/commands/install.ts +3 -1
  51. package/core/buddy/src/commands/key.ts +2 -0
  52. package/core/buddy/src/commands/lint.ts +4 -0
  53. package/core/buddy/src/commands/list.ts +6 -2
  54. package/core/buddy/src/commands/make.ts +52 -30
  55. package/core/buddy/src/commands/migrate.ts +6 -2
  56. package/core/buddy/src/commands/prepublish.ts +3 -0
  57. package/core/buddy/src/commands/release.ts +12 -2
  58. package/core/buddy/src/commands/seed.ts +3 -1
  59. package/core/buddy/src/commands/setup.ts +16 -8
  60. package/core/buddy/src/commands/tinker.ts +3 -1
  61. package/core/buddy/src/commands/types.ts +4 -2
  62. package/core/buddy/src/commands/upgrade.ts +37 -25
  63. package/core/buddy/src/commands/version.ts +7 -0
  64. package/core/build/package.json +1 -1
  65. package/core/bun-create/bud/package.json +1 -1
  66. package/core/bun-create/buddy/package.json +1 -1
  67. package/core/bun-create/stack/package.json +1 -1
  68. package/core/bun-create/stacks/package.json +1 -1
  69. package/core/bun-create/stx/package.json +1 -1
  70. package/core/bun-plugin-yaml/package.json +1 -1
  71. package/core/cache/package.json +2 -2
  72. package/core/chat/package.json +8 -8
  73. package/core/cli/dist/index.js +462 -87
  74. package/core/cli/package.json +1 -1
  75. package/core/cli/src/cli.ts +9 -31
  76. package/core/cli/src/console.ts +1 -1
  77. package/core/cli/src/exec.ts +28 -14
  78. package/core/cli/src/helpers.ts +3 -3
  79. package/core/cli/src/index.ts +1 -1
  80. package/core/cli/src/parse.ts +95 -17
  81. package/core/cli/src/run.ts +7 -7
  82. package/core/cli/src/utils.ts +62 -0
  83. package/core/cloud/dist/index.js +70 -41
  84. package/core/cloud/package.json +32 -32
  85. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package-lock.json +6 -6
  86. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +2 -2
  87. package/core/cloud/src/cloud/queue.ts +96 -55
  88. package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
  89. package/core/collections/package.json +1 -1
  90. package/core/config/dist/index.js +49 -27
  91. package/core/config/package.json +1 -1
  92. package/core/config/src/config.ts +1 -1
  93. package/core/config/src/defaults.ts +28 -14
  94. package/core/config/src/overrides.ts +2 -0
  95. package/core/database/package.json +1 -1
  96. package/core/datetime/package.json +1 -1
  97. package/core/desktop/package.json +9 -9
  98. package/core/development/package.json +1 -1
  99. package/core/dns/package.json +7 -7
  100. package/core/docs/package.json +1 -1
  101. package/core/email/package.json +14 -14
  102. package/core/enums/dist/index.js +2 -2
  103. package/core/enums/package.json +1 -1
  104. package/core/enums/src/index.ts +2 -2
  105. package/core/env/package.json +3 -2
  106. package/core/env/src/utils.ts +1 -0
  107. package/core/error-handling/package.json +1 -1
  108. package/core/eslint-config/package.json +10 -10
  109. package/core/events/package.json +1 -1
  110. package/core/faker/package.json +2 -2
  111. package/core/git/package.json +1 -1
  112. package/core/health/package.json +1 -1
  113. package/core/http/package.json +1 -1
  114. package/core/lint/package.json +1 -1
  115. package/core/logging/build.ts +1 -1
  116. package/core/logging/dist/index.js +10932 -1773
  117. package/core/logging/package.json +1 -1
  118. package/core/logging/src/index.ts +79 -13
  119. package/core/notifications/package.json +23 -23
  120. package/core/objects/package.json +1 -1
  121. package/core/orm/package.json +1 -1
  122. package/core/path/dist/index.js +10 -0
  123. package/core/path/package.json +1 -1
  124. package/core/path/src/index.ts +10 -0
  125. package/core/payments/dist/index.js +34 -10
  126. package/core/payments/package.json +2 -2
  127. package/core/push/package.json +5 -5
  128. package/core/query-builder/package.json +1 -1
  129. package/core/queue/dist/index.js +3 -1
  130. package/core/queue/package.json +1 -1
  131. package/core/queue/src/index.ts +3 -1
  132. package/core/raycast/package.json +1 -1
  133. package/core/realtime/package.json +1 -1
  134. package/core/repl/package.json +1 -1
  135. package/core/router/dist/index.js +517 -14
  136. package/core/router/package.json +1 -1
  137. package/core/router/src/router.ts +10 -3
  138. package/core/scheduler/dist/index.js +4 -0
  139. package/core/scheduler/package.json +1 -1
  140. package/core/scheduler/src/index.ts +1 -0
  141. package/core/scheduler/src/schedule.ts +5 -0
  142. package/core/search-engine/package.json +1 -1
  143. package/core/security/package.json +1 -1
  144. package/core/server/package.json +2 -2
  145. package/core/signals/package.json +1 -1
  146. package/core/slug/package.json +1 -1
  147. package/core/sms/package.json +11 -11
  148. package/core/storage/package.json +1 -1
  149. package/core/strings/package.json +1 -1
  150. package/core/tables/package.json +2 -2
  151. package/core/testing/package.json +1 -1
  152. package/core/tinker/package.json +1 -1
  153. package/core/tunnel/package.json +1 -1
  154. package/core/types/dist/index.js +1787 -6
  155. package/core/types/package.json +7 -7
  156. package/core/types/src/ai.ts +1 -0
  157. package/core/types/src/binary.ts +1 -0
  158. package/core/types/src/cli.ts +13 -3
  159. package/core/types/src/cron-jobs.ts +6 -1
  160. package/core/types/src/docs.ts +5 -1
  161. package/core/types/src/index.ts +1 -0
  162. package/core/types/src/logger.ts +54 -0
  163. package/core/types/src/router.ts +2 -1
  164. package/core/types/src/stacks.ts +10 -0
  165. package/core/types/src/team.ts +1 -1
  166. package/core/ui/package.json +6 -6
  167. package/core/utils/dist/index.js +39 -2
  168. package/core/utils/package.json +2 -2
  169. package/core/utils/src/hash.ts +10 -1
  170. package/core/utils/src/index.ts +1 -0
  171. package/core/utils/src/retry.ts +33 -0
  172. package/core/validation/package.json +1 -1
  173. package/core/vite/dist/index.js +1 -1
  174. package/core/vite/package.json +4 -4
  175. package/core/whois/package.json +1 -1
  176. package/core/x-ray/package.json +1 -1
  177. package/core/zsh-buddy/buddy.plugin.zsh +4 -0
  178. package/core/zsh-buddy/package.json +1 -1
  179. package/ide/dictionary.txt +1 -0
  180. package/ide/vscode/package.json +1 -1
  181. package/package.json +1 -1
  182. package/core/buddy/src/commands/example.ts +0 -66
  183. package/core/buddy/src/commands/inspire.ts +0 -24
  184. package/core/cli/src/utilities.ts +0 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cli",
3
3
  "type": "module",
4
- "version": "0.58.57",
4
+ "version": "0.58.59",
5
5
  "description": "TypeScript framework for CLI artisans. Build beautiful console apps with ease.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,8 +1,7 @@
1
1
  // import type { CliOptions } from '@stacksjs/types'
2
- import cac from 'cac'
3
- import { version } from '../package.json'
2
+ import { CAC } from 'cac'
4
3
 
5
- interface ParsedArgv {
4
+ export interface ParsedArgv {
6
5
  args: ReadonlyArray<string>
7
6
  options: {
8
7
  [k: string]: any
@@ -11,8 +10,8 @@ interface ParsedArgv {
11
10
 
12
11
  interface CliOptions {
13
12
  name?: string
14
- version: string
15
- description: string
13
+ // version: string
14
+ // description: string
16
15
  }
17
16
 
18
17
  export function cli(name?: string | CliOptions, options?: CliOptions) {
@@ -21,32 +20,11 @@ export function cli(name?: string | CliOptions, options?: CliOptions) {
21
20
  name = options.name
22
21
  }
23
22
 
24
- const cli = cac(name || 'buddy') // default to extending buddy
25
-
26
- cli.help()
27
- cli.version(options?.version || version)
28
-
29
- return cli
23
+ return new CAC(name || 'buddy')
30
24
  }
31
25
 
32
- export function command(name: string, description: string, options?: CliOptions) {
33
- return cli(options).command(name, description)
34
- }
35
-
36
- export function parseArgs() {
37
- return cli().parse().args
38
- }
26
+ export { CAC }
39
27
 
40
- export function parseOptions(): ParsedArgv['options'] {
41
- const options = cli().parse().options
42
-
43
- // Iterate over the options and convert "true" and "false" strings to boolean
44
- for (const key in options) {
45
- if (options[key] === 'true')
46
- options[key] = true
47
- else if (options[key] === 'false')
48
- options[key] = false
49
- }
50
-
51
- return options
52
- }
28
+ // export function command(name: string, description: string, options?: CliOptions) {
29
+ // return cli(options).command(name, description)
30
+ // }
@@ -76,4 +76,4 @@ export class Prompt {
76
76
 
77
77
  export { prompts, log }
78
78
 
79
- export const prompt = new Prompt()
79
+ export const prompt = () => new Prompt()
@@ -2,6 +2,7 @@ import process from 'node:process'
2
2
  import { type Result, err, handleError, ok } from '@stacksjs/error-handling'
3
3
  import type { CliOptions, StacksError, Subprocess } from '@stacksjs/types'
4
4
  import { ExitCode } from '@stacksjs/types'
5
+ import { log } from './'
5
6
 
6
7
  /**
7
8
  * Execute a command.
@@ -24,19 +25,21 @@ import { ExitCode } from '@stacksjs/types'
24
25
  * ```
25
26
  */
26
27
  export async function exec(command: string | string[], options?: CliOptions): Promise<Result<Subprocess, StacksError>> {
27
- const cmd = Array.isArray(command) ? command : command.match(/(?:[^\s"]+|"[^"]*")+/g)
28
+ const cmd = Array.isArray(command)
29
+ ? command
30
+ : command.match(/(?:[^\s"]+|"[^"]*")+/g)
28
31
 
29
32
  if (!cmd)
30
33
  return err(handleError(`Failed to parse command: ${cmd}`, options))
31
34
 
32
- if (options?.verbose)
33
- // eslint-disable-next-line no-console
34
- console.log('exec', { command, cmd, options })
35
+ log.debug('exec:', Array.isArray(command) ? command.join(' ') : command)
36
+ log.debug('cmd:', cmd)
37
+ log.debug('exec options:', options)
35
38
 
36
39
  const proc = Bun.spawn(cmd, {
37
40
  ...options,
38
- stdout: options?.silent ? 'ignore' : (options?.stdin ? options.stdin : (options?.stdout || 'inherit')),
39
- stderr: options?.silent ? 'ignore' : (options?.stderr || 'inherit'),
41
+ stdout: (options?.silent || options?.quiet) ? 'ignore' : (options?.stdin ? options.stdin : (options?.stdout || 'inherit')),
42
+ stderr: (options?.silent || options?.quiet) ? 'ignore' : (options?.stderr || 'inherit'),
40
43
  detached: options?.background || false,
41
44
  cwd: options?.cwd || import.meta.dir,
42
45
  // env: { ...e, ...options?.env },
@@ -47,12 +50,12 @@ export async function exec(command: string | string[], options?: CliOptions): Pr
47
50
  })
48
51
 
49
52
  // Check if we need to write to stdin
50
- if (options?.stdin === 'pipe' && options.input) {
51
- if (proc.stdin) {
52
- proc.stdin.write(options.input)
53
- proc.stdin.end()
54
- }
55
- }
53
+ // if (options?.stdin === 'pipe' && options.input) {
54
+ // if (proc.stdin) {
55
+ // proc.stdin.write(options.input)
56
+ // proc.stdin.end()
57
+ // }
58
+ // }
56
59
 
57
60
  const exited = await proc.exited
58
61
  if (exited === ExitCode.Success)
@@ -78,10 +81,21 @@ export async function exec(command: string | string[], options?: CliOptions): Pr
78
81
  * ```
79
82
  */
80
83
  export async function execSync(command: string | string[], options?: CliOptions): Promise<string> {
81
- const cmd = Array.isArray(command) ? command : command.split(' ')
84
+ log.debug('Running execSync:', command)
85
+ log.debug('execSync Options:', options)
86
+
87
+ const cmd = Array.isArray(command)
88
+ ? command
89
+ : command.match(/(?:[^\s"]+|"[^"]*")+/g)
90
+
91
+ if (!cmd) {
92
+ log.error(`Failed to parse command: ${cmd}`, options)
93
+ process.exit(ExitCode.FatalError)
94
+ }
95
+
82
96
  const proc = Bun.spawnSync(cmd, {
83
97
  ...options,
84
- // stdin: 'inherit',
98
+ stdin: options?.stdin ?? 'inherit',
85
99
  stdout: options?.stdout ?? 'pipe',
86
100
  stderr: options?.stderr ?? 'inherit',
87
101
  cwd: options?.cwd ?? import.meta.dir,
@@ -61,14 +61,14 @@ export function outro(text: string, options?: OutroOptions, error?: Error | stri
61
61
  if (error)
62
62
  log.error(`[${time.toFixed(2)}${opts.useSeconds ? 's' : 'ms'}] Failed`)
63
63
  else if (opts.type === 'info')
64
- console.log(`${dim(gray(`[${time.toFixed(2)}${opts.useSeconds ? 's' : 'ms'}]`))} ${opts.message ?? 'Complete'}`)
64
+ log.info(`${dim(gray(`[${time.toFixed(2)}${opts.useSeconds ? 's' : 'ms'}]`))} ${opts.message ?? 'Complete'}`)
65
65
  else
66
- console.log(`${dim(gray(bold(`[${time.toFixed(2)}${opts.useSeconds ? 's' : 'ms'}]`)))} ${bold(green(opts.message ?? 'Complete'))}`)
66
+ log.success(`${dim(gray(bold(`[${time.toFixed(2)}${opts.useSeconds ? 's' : 'ms'}]`)))} ${bold(green(opts.message ?? 'Complete'))}`)
67
67
  }
68
68
 
69
69
  else {
70
70
  if (opts?.type === 'info')
71
- console.log(text)
71
+ log.info(text)
72
72
 
73
73
  // the following condition triggers in the case of "Cleaned up" messages
74
74
  else if (opts?.type === 'success' && opts?.quiet !== true)
@@ -7,4 +7,4 @@ export * from './parse'
7
7
  export * from './exec'
8
8
  export * from './run'
9
9
  export * from './spinner'
10
- export * from './utilities'
10
+ export * from './utils'
@@ -7,7 +7,10 @@ interface ParsedArgv {
7
7
  }
8
8
  }
9
9
 
10
- function isLongOption(arg: string): boolean {
10
+ function isLongOption(arg?: string): boolean {
11
+ if (!arg)
12
+ return false
13
+
11
14
  return arg.startsWith('--')
12
15
  }
13
16
 
@@ -32,14 +35,14 @@ function parseValue(value: string): string | boolean | number {
32
35
  function parseLongOption(arg: string, argv: string[], index: number, options: { [k: string]: string | boolean | number }): number {
33
36
  const [key, value] = arg.slice(2).split('=')
34
37
  if (value !== undefined) {
35
- options[key] = parseValue(value)
38
+ options[key as string] = parseValue(value)
36
39
  }
37
- else if (index + 1 < argv.length && !argv[index + 1].startsWith('-')) {
38
- options[key] = argv[index + 1]
40
+ else if (index + 1 < argv.length && !argv[index + 1]!.startsWith('-')) {
41
+ options[key as string] = argv[index + 1] as string
39
42
  index++
40
43
  }
41
44
  else {
42
- options[key] = true
45
+ options[key as string] = true
43
46
  }
44
47
  return index
45
48
  }
@@ -47,18 +50,22 @@ function parseLongOption(arg: string, argv: string[], index: number, options: {
47
50
  function parseShortOption(arg: string, argv: string[], index: number, options: { [k: string]: string | boolean | number }): number {
48
51
  const [key, value] = arg.slice(1).split('=')
49
52
 
50
- if (value !== undefined) {
53
+ // Check if key is undefined and handle it
54
+ if (key === undefined)
55
+ return index
56
+
57
+ if (value !== undefined && key !== undefined) {
51
58
  for (let j = 0; j < key.length; j++)
52
- options[key[j]] = parseValue(value)
59
+ options[key[j] as string] = parseValue(value)
53
60
  }
54
61
  else {
55
62
  for (let j = 0; j < key.length; j++) {
56
- if (index + 1 < argv.length && j === key.length - 1 && !argv[index + 1].startsWith('-')) {
57
- options[key[j]] = parseValue(argv[index + 1])
63
+ if (index + 1 < argv.length && j === key.length - 1 && !argv[index + 1]!.startsWith('-')) {
64
+ options[key[j] as string] = parseValue(argv[index + 1]!)
58
65
  index++
59
66
  }
60
67
  else {
61
- options[key[j]] = true
68
+ options[key[j] as string] = true
62
69
  }
63
70
  }
64
71
  }
@@ -75,6 +82,8 @@ export function parseArgv(argv?: string[]): ParsedArgv {
75
82
 
76
83
  for (let i = 0; i < argv.length; i++) {
77
84
  const arg = argv[i]
85
+ if (!arg)
86
+ continue
78
87
  if (isLongOption(arg))
79
88
  i = parseLongOption(arg, argv, i, options)
80
89
  else if (isShortOption(arg))
@@ -86,16 +95,85 @@ export function parseArgv(argv?: string[]): ParsedArgv {
86
95
  return { args, options }
87
96
  }
88
97
 
89
- // export function parseOptions(argv?: string[]): { [k: string]: string | boolean | number } {
90
- // if (argv === undefined)
91
- // argv = process.argv.slice(2)
92
-
93
- // return parseArgv(argv).options
94
- // }
95
-
96
98
  export function parseArgs(argv?: string[]): string[] {
97
99
  if (argv === undefined)
98
100
  argv = process.argv.slice(2)
99
101
 
100
102
  return parseArgv(argv).args
101
103
  }
104
+
105
+ interface CliOptions {
106
+ dryRun?: boolean
107
+ quiet?: boolean
108
+ verbose?: boolean
109
+ [k: string]: string | boolean | number | undefined
110
+ }
111
+
112
+ export function parseOptions(options?: CliOptions): CliOptions | undefined {
113
+ options = options || {}
114
+ const args = process.argv.slice(2)
115
+
116
+ for (let i = 0; i < args.length; i++) {
117
+ const arg = args[i]
118
+ if (arg?.startsWith('--')) {
119
+ const key = arg.substring(2) // remove the --
120
+ const camelCaseKey = key.replace(
121
+ /-([a-z])/gi,
122
+ g => (g[1] ? g[1].toUpperCase() : ''), // convert kebab-case to camelCase
123
+ )
124
+
125
+ if (i + 1 < args.length) { // if the next arg exists
126
+ if (args[i + 1] === 'true' || args[i + 1] === 'false') { // if the next arg is a boolean
127
+ options[camelCaseKey] = args[i + 1] === 'true' // set the value to the boolean
128
+ i++
129
+ }
130
+ else {
131
+ options[camelCaseKey] = args[i + 1]
132
+ i++
133
+ }
134
+ }
135
+ else {
136
+ options[camelCaseKey] = true
137
+ }
138
+ }
139
+ }
140
+
141
+ // if options has no keys, return undefined, e.g. `buddy release`
142
+ if (Object.keys(options).length === 0)
143
+ return undefined
144
+
145
+ // convert the string 'true' or 'false' to a boolean
146
+ Object.keys(options).forEach((key) => {
147
+ if (!options)
148
+ return
149
+
150
+ const value = options[key]
151
+
152
+ if (value === 'true' || value === 'false')
153
+ options[key] = value === 'true'
154
+ })
155
+
156
+ return options
157
+ }
158
+ // interface BuddyOptions {
159
+ // dryRun?: boolean
160
+ // verbose?: boolean
161
+ // }
162
+ export function buddyOptions(options?: any): string {
163
+ if (!options) {
164
+ options = process.argv.slice(2)
165
+ options = Array.from(new Set(options))
166
+ // delete the 0 element if it does not start with a -
167
+ // e.g. is used when buddy changelog --dry-run is used
168
+ if (options[0] && !options[0].startsWith('-'))
169
+ options.shift()
170
+ }
171
+
172
+ if (options?.verbose) {
173
+ log.debug('process.argv', process.argv)
174
+ log.debug('process.argv.slice(2)', process.argv.slice(2))
175
+ log.debug('options inside buddyOptions', options)
176
+ }
177
+
178
+ return options.join(' ')
179
+ }
@@ -1,7 +1,7 @@
1
1
  import type { CliOptions, CommandError, Subprocess } from '@stacksjs/types'
2
2
  import type { Result } from '@stacksjs/error-handling'
3
3
  import { exec, execSync } from './exec'
4
- import { italic, underline } from './utilities'
4
+ import { italic } from './utils'
5
5
  import { log } from './console'
6
6
 
7
7
  /**
@@ -30,15 +30,15 @@ import { log } from './console'
30
30
  * ```
31
31
  */
32
32
  export async function runCommand(command: string, options?: CliOptions): Promise<Result<Subprocess, CommandError>> {
33
- if (options?.verbose)
34
- log.debug('Running command:', underline(italic(command)), 'with options:', options)
33
+ log.debug('runCommand:', command)
34
+ log.debug('options:', options)
35
35
 
36
36
  return await exec(command, options)
37
37
  }
38
38
 
39
39
  export async function runProcess(command: string, options?: CliOptions): Promise<Result<Subprocess, CommandError>> {
40
- if (options?.verbose)
41
- log.debug('Running command:', underline(italic(command)), 'with options:', options)
40
+ log.debug('runProcess:', italic(command))
41
+ log.debug('runProcess Options:', options)
42
42
 
43
43
  return await exec(command, options)
44
44
  }
@@ -69,8 +69,8 @@ export async function runProcess(command: string, options?: CliOptions): Promise
69
69
  * ```
70
70
  */
71
71
  export async function runCommandSync(command: string, options?: CliOptions): Promise<string> {
72
- if (options?.verbose)
73
- log.debug('Running command:', underline(italic(command)), 'with options:', options)
72
+ log.debug('runCommandSync:', italic(command))
73
+ log.debug('runCommandSync Options:', options)
74
74
 
75
75
  const result = await execSync(command, options)
76
76
 
@@ -0,0 +1,62 @@
1
+ export * as kolorist from 'kolorist'
2
+
3
+ export {
4
+ stripAnsi,
5
+ centerAlign,
6
+ rightAlign,
7
+ leftAlign,
8
+ align,
9
+ box,
10
+ colors,
11
+ getColor,
12
+ colorize,
13
+ } from 'consola/utils'
14
+
15
+ export {
16
+ ansi256Bg,
17
+ bgBlack,
18
+ bgBlue,
19
+ bgCyan,
20
+ bgGray,
21
+ bgGreen,
22
+ bgLightBlue,
23
+ bgLightCyan,
24
+ bgLightGray,
25
+ bgLightGreen,
26
+ bgLightMagenta,
27
+ bgLightRed,
28
+ bgLightYellow,
29
+ bgMagenta,
30
+ bgRed,
31
+ bgWhite,
32
+ bgYellow,
33
+ black,
34
+ blue,
35
+ bold,
36
+ cyan,
37
+ dim,
38
+ gray,
39
+ green,
40
+ hidden,
41
+ inverse,
42
+ italic,
43
+ lightBlue,
44
+ lightCyan,
45
+ lightGray,
46
+ lightGreen,
47
+ lightMagenta,
48
+ lightRed,
49
+ lightYellow,
50
+ link,
51
+ magenta,
52
+ red,
53
+ reset,
54
+ strikethrough,
55
+ underline,
56
+ white,
57
+ yellow,
58
+ ansi256,
59
+ trueColor,
60
+ trueColorBg,
61
+ stripColors,
62
+ } from 'kolorist'
@@ -1810,46 +1810,25 @@ class QueueStack {
1810
1810
  }
1811
1811
  async init() {
1812
1812
  const jobsDir = path6.jobsPath();
1813
- try {
1814
- const files = await fs.readdir(jobsDir);
1815
- for (const file of files) {
1816
- if (file.endsWith(".ts")) {
1817
- const filePath = path6.jobsPath(file);
1818
- const jobModule = await this.loadJobModule(filePath);
1819
- const rate = jobModule.default.rate || "* * * * *";
1820
- const schedule = Schedule.cron(this.cronScheduleFromRate(rate));
1821
- const id = `QueueRule${pascalCase(file.replace(".ts", ""))}`;
1822
- const rule = new Rule(this.scope, id, {
1823
- ruleName: `${this.props.appName}-${this.props.appEnv}-queue-rule-${slug2(file.replace(".ts", ""))}`,
1824
- schedule
1825
- });
1826
- rule.addTarget(new EcsTask({
1827
- cluster: this.props.cluster,
1828
- taskDefinition: this.props.taskDefinition,
1829
- containerOverrides: [
1830
- {
1831
- containerName: `${this.props.appName}-${this.props.appEnv}-api`,
1832
- environment: [
1833
- {
1834
- name: "QUEUE_WORKER",
1835
- value: "true"
1836
- },
1837
- {
1838
- name: "JOB",
1839
- value: file
1840
- }
1841
- ]
1842
- }
1843
- ],
1844
- retryAttempts: 3,
1845
- subnetSelection: {
1846
- subnetType: ec24.SubnetType.PUBLIC
1847
- }
1848
- }));
1849
- }
1850
- }
1851
- } catch (err2) {
1852
- console.error("Error reading the jobs directory:", err2);
1813
+ const actionsDir = path6.appPath("Actions");
1814
+ const jobFiles = await fs.readdir(jobsDir);
1815
+ const actionFiles = await fs.readdir(actionsDir);
1816
+ const jobs = [];
1817
+ for (const file of jobFiles) {
1818
+ if (!file.endsWith(".ts"))
1819
+ continue;
1820
+ const jobPath = path6.jobsPath(file);
1821
+ const job = await this.loadModule(jobPath);
1822
+ this.createQueueRule(job, file);
1823
+ jobs.push(job);
1824
+ }
1825
+ for (const file of actionFiles) {
1826
+ if (!file.endsWith(".ts"))
1827
+ continue;
1828
+ const actionPath = path6.appPath(`Actions/${file}`);
1829
+ const action = await this.loadModule(actionPath);
1830
+ this.createQueueRule(action, file);
1831
+ jobs.push(action);
1853
1832
  }
1854
1833
  }
1855
1834
  cronScheduleFromRate(rate) {
@@ -1862,10 +1841,60 @@ class QueueStack {
1862
1841
  year: parts[4]
1863
1842
  };
1864
1843
  }
1865
- async loadJobModule(filePath) {
1844
+ async loadModule(filePath) {
1866
1845
  const jobModule = await import(filePath);
1867
1846
  return jobModule;
1868
1847
  }
1848
+ createQueueRule(module, file) {
1849
+ const rate = module.default?.rate;
1850
+ if (!rate || module.default?.enabled === false)
1851
+ return;
1852
+ const schedule = Schedule.cron(this.cronScheduleFromRate(rate));
1853
+ const id = `QueueRule${pascalCase(file.replace(".ts", ""))}`;
1854
+ const rule = new Rule(this.scope, id, {
1855
+ ruleName: `${this.props.appName}-${this.props.appEnv}-queue-rule-${slug2(file.replace(".ts", ""))}`,
1856
+ schedule
1857
+ });
1858
+ rule.addTarget(new EcsTask({
1859
+ cluster: this.props.cluster,
1860
+ taskDefinition: this.props.taskDefinition,
1861
+ containerOverrides: [
1862
+ {
1863
+ containerName: `${this.props.appName}-${this.props.appEnv}-api`,
1864
+ environment: [
1865
+ {
1866
+ name: "QUEUE_WORKER",
1867
+ value: "true"
1868
+ },
1869
+ {
1870
+ name: "JOB",
1871
+ value: file
1872
+ },
1873
+ {
1874
+ name: "JOB_BACKOFF_FACTOR",
1875
+ value: module.default?.backoffFactor
1876
+ },
1877
+ {
1878
+ name: "JOB_RETRIES",
1879
+ value: module.default?.tries
1880
+ },
1881
+ {
1882
+ name: "JOB_INITIAL_DELAY",
1883
+ value: module.default?.initialDelay
1884
+ },
1885
+ {
1886
+ name: "JOB_JITTER",
1887
+ value: module.default?.jitter
1888
+ }
1889
+ ]
1890
+ }
1891
+ ],
1892
+ retryAttempts: 1,
1893
+ subnetSelection: {
1894
+ subnetType: ec24.SubnetType.PUBLIC
1895
+ }
1896
+ }));
1897
+ }
1869
1898
  }
1870
1899
 
1871
1900
  // src/cloud/index.ts
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cloud",
3
3
  "type": "module",
4
- "version": "0.58.57",
4
+ "version": "0.58.59",
5
5
  "description": "The Stacks cloud/serverless integration & implementation.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -55,19 +55,19 @@
55
55
  "prepublishOnly": "bun run build"
56
56
  },
57
57
  "peerDependencies": {
58
- "@aws-sdk/client-bedrock": "^3.507.0",
59
- "@aws-sdk/client-cloudformation": "^3.507.0",
60
- "@aws-sdk/client-cloudfront": "^3.507.0",
61
- "@aws-sdk/client-cloudwatch-logs": "^3.508.0",
62
- "@aws-sdk/client-ec2": "^3.507.0",
63
- "@aws-sdk/client-efs": "^3.507.0",
64
- "@aws-sdk/client-iam": "^3.507.0",
65
- "@aws-sdk/client-lambda": "^3.507.0",
66
- "@aws-sdk/client-route-53-domains": "^3.507.0",
67
- "@aws-sdk/client-s3": "^3.507.0",
68
- "@aws-sdk/client-ses": "^3.507.0",
69
- "@aws-sdk/client-sesv2": "^3.507.0",
70
- "@aws-sdk/client-ssm": "^3.507.0",
58
+ "@aws-sdk/client-bedrock": "^3.511.0",
59
+ "@aws-sdk/client-cloudformation": "^3.511.0",
60
+ "@aws-sdk/client-cloudfront": "^3.511.0",
61
+ "@aws-sdk/client-cloudwatch-logs": "^3.511.0",
62
+ "@aws-sdk/client-ec2": "^3.511.0",
63
+ "@aws-sdk/client-efs": "^3.511.0",
64
+ "@aws-sdk/client-iam": "^3.511.0",
65
+ "@aws-sdk/client-lambda": "^3.511.0",
66
+ "@aws-sdk/client-route-53-domains": "^3.511.0",
67
+ "@aws-sdk/client-s3": "^3.511.0",
68
+ "@aws-sdk/client-ses": "^3.511.0",
69
+ "@aws-sdk/client-sesv2": "^3.511.0",
70
+ "@aws-sdk/client-ssm": "^3.511.0",
71
71
  "@stacksjs/config": "workspace:*",
72
72
  "@stacksjs/env": "workspace:*",
73
73
  "@stacksjs/logging": "workspace:*",
@@ -79,20 +79,20 @@
79
79
  "@stacksjs/validation": "workspace:*"
80
80
  },
81
81
  "dependencies": {
82
- "@aws-sdk/client-bedrock": "^3.507.0",
83
- "@aws-sdk/client-cloudformation": "^3.507.0",
84
- "@aws-sdk/client-cloudfront": "^3.507.0",
85
- "@aws-sdk/client-cloudwatch-logs": "^3.508.0",
86
- "@aws-sdk/client-dynamodb": "3.507.0",
87
- "@aws-sdk/client-ec2": "^3.507.0",
88
- "@aws-sdk/client-efs": "^3.507.0",
89
- "@aws-sdk/client-iam": "^3.507.0",
90
- "@aws-sdk/client-lambda": "^3.507.0",
91
- "@aws-sdk/client-route-53-domains": "^3.507.0",
92
- "@aws-sdk/client-s3": "^3.507.0",
93
- "@aws-sdk/client-ses": "^3.507.0",
94
- "@aws-sdk/client-sesv2": "^3.507.0",
95
- "@aws-sdk/client-ssm": "^3.507.0",
82
+ "@aws-sdk/client-bedrock": "^3.511.0",
83
+ "@aws-sdk/client-cloudformation": "^3.511.0",
84
+ "@aws-sdk/client-cloudfront": "^3.511.0",
85
+ "@aws-sdk/client-cloudwatch-logs": "^3.511.0",
86
+ "@aws-sdk/client-dynamodb": "3.511.0",
87
+ "@aws-sdk/client-ec2": "^3.511.0",
88
+ "@aws-sdk/client-efs": "^3.511.0",
89
+ "@aws-sdk/client-iam": "^3.511.0",
90
+ "@aws-sdk/client-lambda": "^3.511.0",
91
+ "@aws-sdk/client-route-53-domains": "^3.511.0",
92
+ "@aws-sdk/client-s3": "^3.511.0",
93
+ "@aws-sdk/client-ses": "^3.511.0",
94
+ "@aws-sdk/client-sesv2": "^3.511.0",
95
+ "@aws-sdk/client-ssm": "^3.511.0",
96
96
  "@stacksjs/config": "workspace:*",
97
97
  "@stacksjs/dns": "workspace:*",
98
98
  "@stacksjs/env": "workspace:*",
@@ -102,18 +102,18 @@
102
102
  "@stacksjs/storage": "workspace:*",
103
103
  "@stacksjs/utils": "workspace:*",
104
104
  "@stacksjs/validation": "workspace:*",
105
- "aws-cdk": "^2.126.0",
106
- "aws-cdk-lib": "^2.126.0",
105
+ "aws-cdk": "^2.127.0",
106
+ "aws-cdk-lib": "^2.127.0",
107
107
  "aws4fetch": "^1.0.17",
108
108
  "constructs": "^10.3.0"
109
109
  },
110
110
  "devDependencies": {
111
- "@oclif/plugin-plugins": "^4.2.1",
111
+ "@oclif/plugin-plugins": "^4.2.2",
112
112
  "@stacksjs/cli": "workspace:*",
113
113
  "@stacksjs/development": "workspace:*",
114
114
  "@stacksjs/env": "workspace:*",
115
115
  "jszip": "^3.10.1",
116
- "oclif": "^4.4.7",
116
+ "oclif": "^4.4.10",
117
117
  "source-map-support": "^0.5.21"
118
118
  }
119
119
  }