@stacksjs/buddy 0.64.5 → 0.65.0

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 (148) hide show
  1. package/dist/chunk-1bcxd9nx.js +5 -0
  2. package/dist/chunk-1bcxd9nx.js.map +17 -0
  3. package/dist/chunk-3gvx3tap.js +5 -0
  4. package/dist/{chunk-wmfxrbxe.js.map → chunk-3gvx3tap.js.map} +1 -1
  5. package/dist/chunk-5mkzknp4.js +5 -0
  6. package/dist/{chunk-4b0aba5k.js.map → chunk-5mkzknp4.js.map} +13 -13
  7. package/dist/chunk-a3d48jzd.js +15 -0
  8. package/dist/chunk-a3d48jzd.js.map +164 -0
  9. package/dist/chunk-a6ba4vgs.js +5 -0
  10. package/dist/{chunk-6qhap62a.js.map → chunk-a6ba4vgs.js.map} +3 -3
  11. package/dist/{chunk-5eg9jpdw.js → chunk-agapayce.js} +3 -3
  12. package/dist/{chunk-5eg9jpdw.js.map → chunk-agapayce.js.map} +1 -1
  13. package/dist/chunk-b9d377d9.js +5 -0
  14. package/dist/{chunk-qkk1z4t3.js.map → chunk-b9d377d9.js.map} +9 -9
  15. package/dist/chunk-bh61bx6h.js +4 -0
  16. package/dist/{chunk-89jmvbwz.js.map → chunk-bh61bx6h.js.map} +2 -2
  17. package/dist/chunk-fqrjh7j8.js +5 -0
  18. package/dist/chunk-fqrjh7j8.js.map +10 -0
  19. package/dist/chunk-jkt9jxar.js +9 -0
  20. package/dist/{chunk-9f43d1kt.js.map → chunk-jkt9jxar.js.map} +3 -3
  21. package/dist/chunk-k1q2z202.js +4 -0
  22. package/dist/chunk-k1q2z202.js.map +16 -0
  23. package/dist/chunk-mmjggjd5.js +849 -0
  24. package/dist/chunk-mmjggjd5.js.map +240 -0
  25. package/dist/chunk-mxwvrbdh.js +6 -0
  26. package/dist/{chunk-a365bfhw.js.map → chunk-mxwvrbdh.js.map} +20 -17
  27. package/dist/chunk-n55kahn5.js +5 -0
  28. package/dist/{chunk-6a30kt0n.js.map → chunk-n55kahn5.js.map} +3 -3
  29. package/dist/chunk-pbpgcz3v.js +5 -0
  30. package/dist/{chunk-1f6t66bt.js.map → chunk-pbpgcz3v.js.map} +4 -4
  31. package/dist/chunk-sadghty0.js +5 -0
  32. package/dist/{chunk-0aqj22dq.js.map → chunk-sadghty0.js.map} +4 -4
  33. package/dist/chunk-smzpmhmp.js +11 -0
  34. package/dist/chunk-smzpmhmp.js.map +10 -0
  35. package/dist/chunk-w4zypt02.js +5 -0
  36. package/dist/{chunk-yxrf386g.js.map → chunk-w4zypt02.js.map} +4 -4
  37. package/dist/chunk-ywfsnx7v.js +5 -0
  38. package/dist/chunk-ywfsnx7v.js.map +22 -0
  39. package/dist/chunk-yxs8vtg9.js +5 -0
  40. package/dist/{chunk-b6hb11ta.js.map → chunk-yxs8vtg9.js.map} +2 -2
  41. package/dist/chunk-z7609s4h.js +12 -0
  42. package/dist/{chunk-knp3sj60.js.map → chunk-z7609s4h.js.map} +2 -2
  43. package/dist/cli.d.ts +1 -0
  44. package/dist/cli.js +2 -2
  45. package/dist/cli.js.map +3 -3
  46. package/dist/commands/add.d.ts +2 -0
  47. package/dist/commands/build.d.ts +2 -0
  48. package/dist/commands/changelog.d.ts +2 -0
  49. package/dist/commands/clean.d.ts +2 -0
  50. package/dist/commands/cloud.d.ts +2 -0
  51. package/dist/commands/commit.d.ts +2 -0
  52. package/dist/commands/configure.d.ts +2 -0
  53. package/dist/commands/create.d.ts +2 -0
  54. package/dist/commands/deploy.d.ts +2 -0
  55. package/dist/commands/dev.d.ts +3 -0
  56. package/dist/commands/dns.d.ts +2 -0
  57. package/dist/commands/domains.d.ts +2 -0
  58. package/dist/commands/fresh.d.ts +2 -0
  59. package/dist/commands/generate.d.ts +2 -0
  60. package/dist/commands/http.d.ts +2 -0
  61. package/dist/commands/index.d.ts +33 -0
  62. package/dist/commands/install.d.ts +2 -0
  63. package/dist/commands/key.d.ts +2 -0
  64. package/dist/commands/lint.d.ts +2 -0
  65. package/dist/commands/list.d.ts +2 -0
  66. package/dist/commands/make.d.ts +2 -0
  67. package/dist/commands/migrate.d.ts +2 -0
  68. package/dist/commands/outdated.d.ts +2 -0
  69. package/dist/commands/ports.d.ts +2 -0
  70. package/dist/commands/prepublish.d.ts +2 -0
  71. package/dist/commands/projects.d.ts +2 -0
  72. package/dist/commands/release.d.ts +2 -0
  73. package/dist/commands/route.d.ts +2 -0
  74. package/dist/commands/seed.d.ts +2 -0
  75. package/dist/commands/setup.d.ts +4 -0
  76. package/dist/commands/test.d.ts +2 -0
  77. package/dist/commands/tinker.d.ts +2 -0
  78. package/dist/commands/types.d.ts +2 -0
  79. package/dist/commands/upgrade.d.ts +2 -0
  80. package/dist/commands/version.d.ts +2 -0
  81. package/dist/custom-cli.d.ts +1 -0
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.js +2 -2
  84. package/dist/index.js.map +1 -1
  85. package/dist/stacks +0 -0
  86. package/package.json +50 -56
  87. package/src/cli.ts +10 -7
  88. package/src/commands/add.ts +2 -2
  89. package/src/commands/build.ts +50 -32
  90. package/src/commands/changelog.ts +2 -2
  91. package/src/commands/clean.ts +2 -2
  92. package/src/commands/cloud.ts +31 -12
  93. package/src/commands/commit.ts +2 -2
  94. package/src/commands/configure.ts +4 -3
  95. package/src/commands/create.ts +3 -3
  96. package/src/commands/deploy.ts +21 -10
  97. package/src/commands/dev.ts +38 -25
  98. package/src/commands/dns.ts +2 -2
  99. package/src/commands/domains.ts +2 -2
  100. package/src/commands/fresh.ts +2 -2
  101. package/src/commands/generate.ts +27 -3
  102. package/src/commands/http.ts +2 -2
  103. package/src/commands/index.ts +3 -3
  104. package/src/commands/install.ts +2 -2
  105. package/src/commands/key.ts +2 -2
  106. package/src/commands/lint.ts +7 -10
  107. package/src/commands/list.ts +2 -2
  108. package/src/commands/make.ts +12 -12
  109. package/src/commands/migrate.ts +2 -2
  110. package/src/commands/outdated.ts +3 -3
  111. package/src/commands/ports.ts +26 -16
  112. package/src/commands/prepublish.ts +2 -2
  113. package/src/commands/projects.ts +6 -4
  114. package/src/commands/release.ts +4 -3
  115. package/src/commands/route.ts +2 -2
  116. package/src/commands/seed.ts +2 -2
  117. package/src/commands/setup.ts +11 -7
  118. package/src/commands/test.ts +77 -54
  119. package/src/commands/tinker.ts +2 -2
  120. package/src/commands/types.ts +2 -2
  121. package/src/commands/upgrade.ts +20 -13
  122. package/src/commands/version.ts +2 -2
  123. package/src/custom-cli.ts +3 -2
  124. package/dist/chunk-0aqj22dq.js +0 -5
  125. package/dist/chunk-1f6t66bt.js +0 -5
  126. package/dist/chunk-4b0aba5k.js +0 -5
  127. package/dist/chunk-6a30kt0n.js +0 -5
  128. package/dist/chunk-6qhap62a.js +0 -5
  129. package/dist/chunk-89jmvbwz.js +0 -4
  130. package/dist/chunk-953dm442.js +0 -5
  131. package/dist/chunk-953dm442.js.map +0 -17
  132. package/dist/chunk-9f43d1kt.js +0 -9
  133. package/dist/chunk-a365bfhw.js +0 -6
  134. package/dist/chunk-b6hb11ta.js +0 -5
  135. package/dist/chunk-gc8bvwm2.js +0 -5
  136. package/dist/chunk-gc8bvwm2.js.map +0 -22
  137. package/dist/chunk-kkb03h19.js +0 -5
  138. package/dist/chunk-kkb03h19.js.map +0 -10
  139. package/dist/chunk-knp3sj60.js +0 -12
  140. package/dist/chunk-p9n9dek4.js +0 -21
  141. package/dist/chunk-p9n9dek4.js.map +0 -170
  142. package/dist/chunk-pe71p33y.js +0 -5
  143. package/dist/chunk-pe71p33y.js.map +0 -16
  144. package/dist/chunk-qkk1z4t3.js +0 -5
  145. package/dist/chunk-s03s5x4g.js +0 -7
  146. package/dist/chunk-s03s5x4g.js.map +0 -60
  147. package/dist/chunk-wmfxrbxe.js +0 -5
  148. package/dist/chunk-yxrf386g.js +0 -5
@@ -1,14 +1,14 @@
1
+ import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { intro, italic, outro } from '@stacksjs/cli'
3
4
  import { ports as projectPorts } from '@stacksjs/config'
4
5
  import { log } from '@stacksjs/logging'
5
6
  import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
6
- import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
7
7
  import { ExitCode } from '@stacksjs/types'
8
8
  import { findStacksProjects } from '@stacksjs/utils'
9
9
  import { $ } from 'bun'
10
10
 
11
- export function ports(buddy: CLI) {
11
+ export function ports(buddy: CLI): void {
12
12
  const descriptions = {
13
13
  command: 'Let buddy check your project for potential issues and misconfigurations',
14
14
  ports: 'Check if the ports are available',
@@ -31,7 +31,8 @@ export function ports(buddy: CLI) {
31
31
  log.debug('Running `buddy ports` ...', options)
32
32
 
33
33
  let perf
34
- if (!options.quiet) perf = await intro('buddy ports')
34
+ if (!options.quiet)
35
+ perf = await intro('buddy ports')
35
36
 
36
37
  if (options.project) {
37
38
  const path = await findProjectPath(options.project)
@@ -48,7 +49,8 @@ export function ports(buddy: CLI) {
48
49
  outputPorts(projectPorts, options)
49
50
  }
50
51
 
51
- if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
52
+ if (!options.quiet)
53
+ await outro('Exited', { startTime: perf, useSeconds: false })
52
54
 
53
55
  process.exit(ExitCode.Success)
54
56
  })
@@ -64,11 +66,13 @@ export function ports(buddy: CLI) {
64
66
  log.debug('Running `buddy ports:list` ...', options)
65
67
 
66
68
  let perf
67
- if (!options.quiet) perf = await intro('buddy ports:list')
69
+ if (!options.quiet)
70
+ perf = await intro('buddy ports:list')
68
71
 
69
72
  // return the ports for the project
70
73
  if (options.project) {
71
- if (!options.quiet) log.info(`Listing ports for project: ${italic(options.project)}`)
74
+ if (!options.quiet)
75
+ log.info(`Listing ports for project: ${italic(options.project)}`)
72
76
 
73
77
  const path = await findProjectPath(options.project)
74
78
 
@@ -83,7 +87,8 @@ export function ports(buddy: CLI) {
83
87
  outputPorts(projectPorts, options)
84
88
  }
85
89
 
86
- if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
90
+ if (!options.quiet)
91
+ await outro('Exited', { startTime: perf, useSeconds: false })
87
92
 
88
93
  process.exit(ExitCode.Success)
89
94
  })
@@ -99,7 +104,8 @@ export function ports(buddy: CLI) {
99
104
  log.debug('Running `buddy ports:check` ...', options)
100
105
 
101
106
  let perf
102
- if (!options.quiet) perf = await intro('buddy ports:check')
107
+ if (!options.quiet)
108
+ perf = await intro('buddy ports:check')
103
109
 
104
110
  const projects = await findStacksProjects(undefined, { quiet: true })
105
111
 
@@ -113,7 +119,8 @@ export function ports(buddy: CLI) {
113
119
 
114
120
  log.info('ProjectsPorts:', projectsPorts)
115
121
 
116
- if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
122
+ if (!options.quiet)
123
+ await outro('Exited', { startTime: perf, useSeconds: false })
117
124
 
118
125
  process.exit(ExitCode.Success)
119
126
  })
@@ -125,7 +132,8 @@ export function ports(buddy: CLI) {
125
132
  }
126
133
 
127
134
  async function getPortsForProjectPath(path: string, options: PortsOptions) {
128
- if (!options.quiet) log.info(`Checking ports for project: ${italic(path)}`)
135
+ if (!options.quiet)
136
+ log.info(`Checking ports for project: ${italic(path)}`)
129
137
 
130
138
  $.cwd(path)
131
139
  // load the .env file for the project
@@ -137,13 +145,13 @@ async function getPortsForProjectPath(path: string, options: PortsOptions) {
137
145
  // get the list of all Stacks project paths (on the system)
138
146
  const projects = projectList
139
147
  .split('\n')
140
- .filter((line) => line.startsWith(' - '))
141
- .map((line) => line.trim().substring(4))
148
+ .filter(line => line.startsWith(' - '))
149
+ .map(line => line.trim().substring(4))
142
150
  log.debug('Projects:', projects)
143
151
 
144
152
  // since we are targeting a specific project, find its path
145
153
  const ppath = options.project ?? p.projectPath()
146
- let projectPath = projects.find((project) => project.includes(ppath))
154
+ let projectPath = projects.find(project => project.includes(ppath))
147
155
 
148
156
  log.debug(`Checking ports for project: ${projectPath}`)
149
157
  if (projectPath === '' || !projectPath)
@@ -159,7 +167,7 @@ async function getPortsForProjectPath(path: string, options: PortsOptions) {
159
167
  let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"')
160
168
 
161
169
  // Step 2: Remove potential trailing commas before closing braces
162
- validJsonString = validJsonString.replace(/,(\s*})/g, '$1')
170
+ validJsonString = validJsonString.replace(/,(\s*\})/g, '$1')
163
171
 
164
172
  // Now we can parse it into an object
165
173
  const ports = JSON.parse(validJsonString) as Ports
@@ -170,9 +178,11 @@ async function getPortsForProjectPath(path: string, options: PortsOptions) {
170
178
  }
171
179
 
172
180
  function outputPorts(ports: Ports, options: PortsOptions) {
173
- if (!options.quiet) console.log('')
181
+ if (!options.quiet)
182
+ console.log('')
174
183
 
175
184
  console.log(ports)
176
185
 
177
- if (!options.quiet) console.log('')
186
+ if (!options.quiet)
187
+ console.log('')
178
188
  }
@@ -1,10 +1,10 @@
1
+ import type { CLI, PrepublishOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { Action } from '@stacksjs/enums'
4
5
  import { log } from '@stacksjs/logging'
5
- import type { CLI, PrepublishOptions } from '@stacksjs/types'
6
6
 
7
- export function prepublish(buddy: CLI) {
7
+ export function prepublish(buddy: CLI): void {
8
8
  const descriptions = {
9
9
  command: 'Run your prepublish script',
10
10
  project: 'Target a specific project',
@@ -1,10 +1,10 @@
1
+ import type { CLI, ProjectsOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { intro, log } from '@stacksjs/cli'
3
4
  import { ExitCode } from '@stacksjs/types'
4
- import type { CLI, ProjectsOptions } from '@stacksjs/types'
5
5
  import { findStacksProjects } from '@stacksjs/utils'
6
6
 
7
- export function projects(buddy: CLI) {
7
+ export function projects(buddy: CLI): void {
8
8
  const descriptions = {
9
9
  projects: 'Find all Stacks projects on your system',
10
10
  verbose: 'Enable verbose output',
@@ -18,7 +18,8 @@ export function projects(buddy: CLI) {
18
18
  .action(async (options: ProjectsOptions) => {
19
19
  log.debug('Running `buddy projects` ...', options)
20
20
 
21
- if (!options.quiet) await intro('buddy projects')
21
+ if (!options.quiet)
22
+ await intro('buddy projects')
22
23
 
23
24
  const projects = await findStacksProjects(undefined, options)
24
25
 
@@ -35,7 +36,8 @@ export function projects(buddy: CLI) {
35
36
  .action(async (options: ProjectsOptions) => {
36
37
  log.debug('Running `buddy projects` ...', options)
37
38
 
38
- if (!options.quiet) await intro('buddy projects:list')
39
+ if (!options.quiet)
40
+ await intro('buddy projects:list')
39
41
 
40
42
  // uses os.homedir() as the default path
41
43
  const projects = await findStacksProjects(undefined, options)
@@ -1,9 +1,9 @@
1
+ import type { CLI, ReleaseOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { intro, italic, log, outro } from '@stacksjs/cli'
4
5
  import { Action } from '@stacksjs/enums'
5
6
  import { ExitCode } from '@stacksjs/types'
6
- import type { CLI, ReleaseOptions } from '@stacksjs/types'
7
7
 
8
8
  const descriptions = {
9
9
  release: 'Release a new version of your libraries/packages',
@@ -12,7 +12,7 @@ const descriptions = {
12
12
  verbose: 'Enable verbose output',
13
13
  }
14
14
 
15
- export function release(buddy: CLI) {
15
+ export function release(buddy: CLI): void {
16
16
  buddy
17
17
  .command('release', descriptions.release)
18
18
  .option('--dry-run', descriptions.dryRun, { default: false })
@@ -21,7 +21,8 @@ export function release(buddy: CLI) {
21
21
  .action(async (options: ReleaseOptions) => {
22
22
  log.debug('Running `buddy release` ...', options)
23
23
 
24
- if (options.dryRun) log.warn('Dry run enabled. No changes will be made or committed.')
24
+ if (options.dryRun)
25
+ log.warn('Dry run enabled. No changes will be made or committed.')
25
26
 
26
27
  const startTime = await intro('buddy release')
27
28
  const result = await runAction(Action.Release, {
@@ -1,11 +1,11 @@
1
+ import type { CLI, MigrateOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { intro, outro } from '@stacksjs/cli'
4
5
  import { Action } from '@stacksjs/enums'
5
6
  import { ExitCode } from '@stacksjs/types'
6
- import type { CLI, MigrateOptions } from '@stacksjs/types'
7
7
 
8
- export function route(buddy: CLI) {
8
+ export function route(buddy: CLI): void {
9
9
  const descriptions = {
10
10
  route: 'Lists your routes',
11
11
  verbose: 'Enable verbose output',
@@ -1,11 +1,11 @@
1
+ import type { CLI, SeedOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { intro, log, outro } from '@stacksjs/cli'
4
5
  import { Action } from '@stacksjs/enums'
5
6
  import { ExitCode } from '@stacksjs/types'
6
- import type { CLI, SeedOptions } from '@stacksjs/types'
7
7
 
8
- export function seed(buddy: CLI) {
8
+ export function seed(buddy: CLI): void {
9
9
  const descriptions = {
10
10
  seed: 'Seed your database',
11
11
  project: 'Target a specific project',
@@ -1,3 +1,4 @@
1
+ import type { CLI, CliOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { log, runCommand } from '@stacksjs/cli'
@@ -6,9 +7,8 @@ import { handleError } from '@stacksjs/error-handling'
6
7
  import { path as p } from '@stacksjs/path'
7
8
  import { storage } from '@stacksjs/storage'
8
9
  import { ExitCode } from '@stacksjs/types'
9
- import type { CLI, CliOptions } from '@stacksjs/types'
10
10
 
11
- export function setup(buddy: CLI) {
11
+ export function setup(buddy: CLI): void {
12
12
  const descriptions = {
13
13
  setup: 'This command ensures your project is setup correctly',
14
14
  ohMyZsh: 'Enable Oh My Zsh',
@@ -25,7 +25,8 @@ export function setup(buddy: CLI) {
25
25
  .action(async (options: CliOptions) => {
26
26
  log.debug('Running `buddy setup` ...', options)
27
27
 
28
- if (!(await isPkgxInstalled())) await installPkgx()
28
+ if (!(await isPkgxInstalled()))
29
+ await installPkgx()
29
30
 
30
31
  // ensure the minimal amount of deps are written to ./pkgx.yaml
31
32
  await optimizePkgxDeps()
@@ -59,7 +60,8 @@ export function setup(buddy: CLI) {
59
60
  async function isPkgxInstalled(): Promise<boolean> {
60
61
  const result = await runCommand('pkgx --version', { silent: true })
61
62
 
62
- if (result.isOk()) return true
63
+ if (result.isOk())
64
+ return true
63
65
 
64
66
  return false
65
67
  }
@@ -67,7 +69,8 @@ async function isPkgxInstalled(): Promise<boolean> {
67
69
  async function installPkgx(): Promise<void> {
68
70
  const result = await runCommand(p.frameworkPath('scripts/pkgx-install'))
69
71
 
70
- if (result.isOk()) return
72
+ if (result.isOk())
73
+ return
71
74
 
72
75
  handleError(result.error)
73
76
  process.exit(ExitCode.FatalError)
@@ -118,7 +121,7 @@ async function initializeProject(options: CliOptions): Promise<void> {
118
121
  }
119
122
 
120
123
  export async function optimizePkgxDeps(): Promise<void> {
121
- return new Promise((resolve) => setTimeout(resolve, 300))
124
+ return new Promise(resolve => setTimeout(resolve, 300))
122
125
  }
123
126
 
124
127
  export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
@@ -135,7 +138,8 @@ export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
135
138
  }
136
139
 
137
140
  log.success('.env created')
138
- } else {
141
+ }
142
+ else {
139
143
  log.success('.env existed')
140
144
  }
141
145
  }
@@ -1,11 +1,11 @@
1
+ import type { CLI, TestOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
- import { intro, outro } from '@stacksjs/cli'
4
+ import { intro, log, outro } from '@stacksjs/cli'
4
5
  import { Action } from '@stacksjs/enums'
5
6
  import { projectPath } from '@stacksjs/path'
6
- import type { CLI, TestOptions } from '@stacksjs/types'
7
7
 
8
- export function test(buddy: CLI) {
8
+ export function test(buddy: CLI): void {
9
9
  const descriptions = {
10
10
  command: 'Runs your test suite',
11
11
  types: 'Typechecks your codebase',
@@ -20,23 +20,80 @@ export function test(buddy: CLI) {
20
20
 
21
21
  buddy
22
22
  .command('test', descriptions.command)
23
- .option('--ui', descriptions.ui, { default: false })
23
+ .option('-f, --feature', descriptions.feature, { default: false })
24
+ .option('-u, --unit', descriptions.unit, { default: false })
25
+ // .option('--ui', descriptions.ui, { default: false })
24
26
  .option('-p, --project [project]', descriptions.project, { default: false })
25
27
  .option('--verbose', descriptions.verbose, { default: true })
26
28
  .action(async (options: TestOptions) => {
27
29
  const perf = await intro('buddy test')
28
- const result = await runAction(Action.Test, {
29
- ...options,
30
- cwd: projectPath(),
31
- })
32
30
 
33
- if (result.isErr()) {
34
- await outro(
35
- 'While running `buddy test`, there was an issue',
36
- { startTime: perf, useSeconds: true },
37
- result.error,
38
- )
39
- process.exit()
31
+ if (options.feature && options.unit) {
32
+ const result = await runAction(Action.Test, {
33
+ ...options,
34
+ cwd: projectPath(),
35
+ })
36
+
37
+ if (result.isErr()) {
38
+ await outro(
39
+ 'While running `buddy test`, there was an issue',
40
+ { startTime: perf, useSeconds: true },
41
+ result.error,
42
+ )
43
+ process.exit()
44
+ }
45
+ }
46
+
47
+ if (options.feature && !options.unit) {
48
+ log.info('Running Feature tests...')
49
+
50
+ const result = await runAction(Action.TestFeature, {
51
+ ...options,
52
+ cwd: projectPath(),
53
+ })
54
+
55
+ if (result.isErr()) {
56
+ await outro(
57
+ 'While running `buddy test`, there was an issue',
58
+ { startTime: perf, useSeconds: true },
59
+ result.error,
60
+ )
61
+ process.exit()
62
+ }
63
+ }
64
+
65
+ if (!options.feature && options.unit) {
66
+ log.info('Running Unit tests...')
67
+
68
+ const result = await runAction(Action.TestUnit, {
69
+ ...options,
70
+ cwd: projectPath(),
71
+ })
72
+
73
+ if (result.isErr()) {
74
+ await outro(
75
+ 'While running `buddy test`, there was an issue',
76
+ { startTime: perf, useSeconds: true },
77
+ result.error,
78
+ )
79
+ process.exit()
80
+ }
81
+ }
82
+
83
+ if (!options.feature && !options.unit) {
84
+ const result = await runAction(Action.Test, {
85
+ ...options,
86
+ cwd: projectPath(),
87
+ })
88
+
89
+ if (result.isErr()) {
90
+ await outro(
91
+ 'While running `buddy test`, there was an issue',
92
+ { startTime: perf, useSeconds: true },
93
+ result.error,
94
+ )
95
+ process.exit()
96
+ }
40
97
  }
41
98
 
42
99
  await outro('Finished running tests', {
@@ -73,24 +130,14 @@ export function test(buddy: CLI) {
73
130
 
74
131
  buddy
75
132
  .command('test:feature', descriptions.feature)
76
- .option('--show-report', descriptions.showReport, { default: false })
77
133
  .option('--verbose', descriptions.verbose, { default: false })
78
134
  .action(async (options: TestOptions) => {
79
135
  const perf = await intro('buddy test:feature')
80
- let result
81
-
82
- if (options.showReport)
83
- result = await runAction(Action.ShowFeatureTestReport, {
84
- ...options,
85
- verbose: true,
86
- cwd: projectPath(),
87
- })
88
- else
89
- result = await runAction(Action.TestFeature, {
90
- ...options,
91
- verbose: true,
92
- cwd: projectPath(),
93
- })
136
+ const result = await runAction(Action.TestFeature, {
137
+ ...options,
138
+ verbose: true,
139
+ cwd: projectPath(),
140
+ })
94
141
 
95
142
  if (result.isErr()) {
96
143
  await outro(
@@ -160,30 +207,6 @@ export function test(buddy: CLI) {
160
207
  })
161
208
  })
162
209
 
163
- buddy.command('test:coverage', descriptions.coverage).action(async (options: TestOptions) => {
164
- const perf = await intro('buddy test:coverage')
165
- const result = await runAction(Action.TestCoverage, {
166
- ...options,
167
- cwd: projectPath(),
168
- verbose: true,
169
- })
170
-
171
- if (result.isErr()) {
172
- await outro(
173
- 'While running `buddy test:coverage`, there was an issue',
174
- { startTime: perf, useSeconds: true },
175
- result.error,
176
- )
177
- process.exit()
178
- }
179
-
180
- await outro('Generated the test coverage report', {
181
- startTime: perf,
182
- useSeconds: true,
183
- })
184
- process.exit()
185
- })
186
-
187
210
  buddy.on('test:*', () => {
188
211
  console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
189
212
  process.exit(1)
@@ -1,9 +1,9 @@
1
+ import type { CLI, TinkerOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { intro, log, outro, runCommand } from '@stacksjs/cli'
3
4
  import { ExitCode } from '@stacksjs/types'
4
- import type { CLI, TinkerOptions } from '@stacksjs/types'
5
5
 
6
- export function tinker(buddy: CLI) {
6
+ export function tinker(buddy: CLI): void {
7
7
  const descriptions = {
8
8
  tinker: 'Tinker with your code',
9
9
  project: 'Target a specific project',
@@ -1,9 +1,9 @@
1
+ import type { CLI, CliOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { generateTypes } from '@stacksjs/actions'
3
4
  import { log } from '@stacksjs/logging'
4
- import type { CLI, CliOptions } from '@stacksjs/types'
5
5
 
6
- export function types(buddy: CLI) {
6
+ export function types(buddy: CLI): void {
7
7
  const descriptions = {
8
8
  generate: 'Generate the types of & for your library/libraries',
9
9
  fix: 'wip',
@@ -1,12 +1,12 @@
1
+ import type { CLI, UpgradeOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
- import { intro, log, outro } from '@stacksjs/cli'
4
+ import { intro, log, outro, prompts } from '@stacksjs/cli'
4
5
  import { Action } from '@stacksjs/enums'
5
6
  import { ExitCode } from '@stacksjs/types'
6
- import type { CLI, UpgradeOptions } from '@stacksjs/types'
7
7
  import { isString } from '@stacksjs/validation'
8
8
 
9
- export function upgrade(buddy: CLI) {
9
+ export function upgrade(buddy: CLI): void {
10
10
  const descriptions = {
11
11
  command: 'Upgrade dependencies, framework, package manager, JS/TS runtime',
12
12
  framework: 'Upgrade the Stacks framework',
@@ -42,22 +42,29 @@ export function upgrade(buddy: CLI) {
42
42
  const perf = await intro('buddy upgrade')
43
43
 
44
44
  if (hasNoOptions(options)) {
45
- let answers = await log.prompt.require().multiselect(descriptions.select, {
46
- options: [
47
- { value: 'dependencies', label: 'Dependencies' },
48
- { value: 'framework', label: 'Framework' },
49
- { value: 'bun', label: 'Bun' },
50
- { value: 'shell', label: 'Shell' },
51
- { value: 'binary', label: 'Binary' },
45
+ const answers = await prompts({
46
+ type: 'multiselect',
47
+ name: 'value',
48
+ message: descriptions.select,
49
+ choices: [
50
+ { value: 'dependencies', title: 'Dependencies' },
51
+ { value: 'framework', title: 'Framework' },
52
+ { value: 'bun', title: 'Bun' },
53
+ { value: 'shell', title: 'Shell' },
54
+ { value: 'binary', title: 'Binary' },
52
55
  ],
53
56
  })
54
57
 
55
- if (answers !== null) process.exit(ExitCode.InvalidArgument)
58
+ let answersValue = answers.value
59
+
60
+ if (answersValue !== null)
61
+ process.exit(ExitCode.InvalidArgument)
56
62
 
57
- if (isString(answers)) answers = [answers]
63
+ if (isString(answersValue))
64
+ answersValue = [answersValue]
58
65
 
59
66
  // creates an object out of array and sets answers to true
60
- options = answers.reduce((a: any, v: any) => {
67
+ options = answersValue.reduce((a: any, v: any) => {
61
68
  a[v] = true
62
69
  return a
63
70
  }, {})
@@ -1,9 +1,9 @@
1
+ import type { CLI } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { bold, dim, green, intro, log } from '@stacksjs/cli'
3
4
  import { storage } from '@stacksjs/storage'
4
- import type { CLI } from '@stacksjs/types'
5
5
 
6
- export function version(buddy: CLI) {
6
+ export function version(buddy: CLI): void {
7
7
  const descriptions = {
8
8
  version: 'Retrieving Stacks build version',
9
9
  }
package/src/custom-cli.ts CHANGED
@@ -17,14 +17,15 @@ async function main() {
17
17
 
18
18
  // dynamically import and register commands from ./app/Commands/*
19
19
  const commandsDir = p.appPath('Commands')
20
- const commandFiles = fs.readdirSync(commandsDir).filter((file) => file.endsWith('.ts'))
20
+ const commandFiles = fs.readdirSync(commandsDir).filter((file: string) => file.endsWith('.ts'))
21
21
 
22
22
  for (const file of commandFiles) {
23
23
  const commandPath = `${commandsDir}/${file}`
24
24
  const dynamicImport = await import(commandPath)
25
25
 
26
26
  // Correctly use the default export function
27
- if (typeof dynamicImport.default === 'function') dynamicImport.default(buddy)
27
+ if (typeof dynamicImport.default === 'function')
28
+ dynamicImport.default(buddy)
28
29
  else console.error(`Expected a default export function in ${file}, but got:`, dynamicImport.default)
29
30
  }
30
31
 
@@ -1,5 +0,0 @@
1
- // @bun
2
- import"./chunk-wmfxrbxe.js";import"./chunk-b6hb11ta.js";import{lb as i,mb as f}from"./chunk-5eg9jpdw.js";import{sb as y,tb as K,ub as E,xb as C,yb as N}from"./chunk-89jmvbwz.js";var F=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var L=300000,_="To refresh this SSO session run 'aws sso login' with the corresponding profile.";var I={},M=async(e)=>{const{SSOOIDCClient:r}=await import("./chunk-qkk1z4t3.js");if(I[e])return I[e];const s=new r({region:e});return I[e]=s,s};var H=async(e,r)=>{const{CreateTokenCommand:s}=await import("./chunk-qkk1z4t3.js");return(await M(r)).send(new s({clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken,grantType:"refresh_token"}))};var v=(e)=>{if(e.expiration&&e.expiration.getTime()<Date.now())throw new f(`Token is expired. ${_}`,!1)};var m=(e,r,s=!1)=>{if(typeof r==="undefined")throw new f(`Value not present for '${e}' in SSO Token${s?". Cannot refresh":""}. ${_}`,!1)};import{promises as W}from"fs";var{writeFile:j}=W,b=(e,r)=>{const s=K(e),t=JSON.stringify(r,null,2);return j(s,t)};var G=new Date(0),U=(e={})=>async()=>{e.logger?.debug("@aws-sdk/token-providers - fromSso");const r=await N(e),s=y(e),t=r[s];if(!t)throw new f(`Profile '${s}' could not be found in shared credentials file.`,!1);else if(!t.sso_session)throw new f(`Profile '${s}' is missing required property 'sso_session'.`);const a=t.sso_session,c=(await C(e))[a];if(!c)throw new f(`Sso session '${a}' could not be found in shared credentials file.`,!1);for(let n of["sso_start_url","sso_region"])if(!c[n])throw new f(`Sso session '${a}' is missing required property '${n}'.`,!1);const{sso_start_url:p,sso_region:S}=c;let o;try{o=await E(a)}catch(n){throw new f(`The SSO session token associated with profile=${s} was not found or is invalid. ${_}`,!1)}m("accessToken",o.accessToken),m("expiresAt",o.expiresAt);const{accessToken:x,expiresAt:u}=o,l={token:x,expiration:new Date(u)};if(l.expiration.getTime()-Date.now()>L)return l;if(Date.now()-G.getTime()<30000)return v(l),l;m("clientId",o.clientId,!0),m("clientSecret",o.clientSecret,!0),m("refreshToken",o.refreshToken,!0);try{G.setTime(Date.now());const n=await H(o,S);m("accessToken",n.accessToken),m("expiresIn",n.expiresIn);const h=new Date(Date.now()+n.expiresIn*1000);try{await b(a,{...o,accessToken:n.accessToken,expiresAt:h.toISOString(),refreshToken:n.refreshToken})}catch(O){}return{token:n.accessToken,expiration:h}}catch(n){return v(l),l}};var T=!1,P=async({ssoStartUrl:e,ssoSession:r,ssoAccountId:s,ssoRegion:t,ssoRoleName:a,ssoClient:d,clientConfig:c,profile:p,logger:S})=>{let o;const x="To refresh this SSO session run aws sso login with the corresponding profile.";if(r)try{const g=await U({profile:p})();o={accessToken:g.token,expiresAt:new Date(g.expiration).toISOString()}}catch(g){throw new i(g.message,{tryNextLink:T,logger:S})}else try{o=await E(e)}catch(g){throw new i("The SSO session associated with this profile is invalid. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:T,logger:S})}if(new Date(o.expiresAt).getTime()-Date.now()<=0)throw new i("The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile.",{tryNextLink:T,logger:S});const{accessToken:u}=o,{SSOClient:l,GetRoleCredentialsCommand:n}=await import("./chunk-gc8bvwm2.js"),h=d||new l(Object.assign({},c??{},{region:c?.region??t}));let O;try{O=await h.send(new n({accountId:s,roleName:a,accessToken:u}))}catch(g){throw new i(g,{tryNextLink:T,logger:S})}const{roleCredentials:{accessKeyId:w,secretAccessKey:k,sessionToken:R,expiration:D,credentialScope:A,accountId:$}={}}=O;if(!w||!k||!R||!D)throw new i("SSO returns an invalid temporary credential.",{tryNextLink:T,logger:S});return{accessKeyId:w,secretAccessKey:k,sessionToken:R,expiration:new Date(D),...A&&{credentialScope:A},...$&&{accountId:$}}};var q=(e,r)=>{const{sso_start_url:s,sso_account_id:t,sso_region:a,sso_role_name:d}=e;if(!s||!t||!a||!d)throw new i(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(e).join(", ")}\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,{tryNextLink:!1,logger:r});return e};var Ee=(e={})=>async()=>{e.logger?.debug("@aws-sdk/credential-provider-sso - fromSSO");const{ssoStartUrl:r,ssoAccountId:s,ssoRegion:t,ssoRoleName:a,ssoSession:d}=e,{ssoClient:c}=e,p=y(e);if(!r&&!s&&!t&&!a&&!d){const o=(await N(e))[p];if(!o)throw new i(`Profile ${p} was not found.`,{logger:e.logger});if(!F(o))throw new i(`Profile ${p} is not configured with SSO credentials.`,{logger:e.logger});if(o?.sso_session){const w=(await C(e))[o.sso_session],k=` configurations in profile ${p} and sso-session ${o.sso_session}`;if(t&&t!==w.sso_region)throw new i("Conflicting SSO region"+k,{tryNextLink:!1,logger:e.logger});if(r&&r!==w.sso_start_url)throw new i("Conflicting SSO start_url"+k,{tryNextLink:!1,logger:e.logger});o.sso_region=w.sso_region,o.sso_start_url=w.sso_start_url}const{sso_start_url:x,sso_account_id:u,sso_region:l,sso_role_name:n,sso_session:h}=q(o,e.logger);return P({ssoStartUrl:x,ssoSession:h,ssoAccountId:u,ssoRegion:l,ssoRoleName:n,ssoClient:c,clientConfig:e.clientConfig,profile:p})}else if(!r||!s||!t||!a)throw new i('Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"',{tryNextLink:!1,logger:e.logger});else return P({ssoStartUrl:r,ssoSession:d,ssoAccountId:s,ssoRegion:t,ssoRoleName:a,ssoClient:c,clientConfig:e.clientConfig,profile:p})};export{q as validateSsoProfile,F as isSsoProfile,Ee as fromSSO};
3
-
4
- //# debugId=43192A362EC0CB4164756E2164756E21
5
- //# sourceMappingURL=chunk-0aqj22dq.js.map