stacks 0.64.6 → 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 (42) hide show
  1. package/buddy/bin/cli.ts +7 -4
  2. package/buddy/build.ts +3 -0
  3. package/buddy/package.json +5 -5
  4. package/buddy/src/cli.ts +10 -7
  5. package/buddy/src/commands/add.ts +2 -2
  6. package/buddy/src/commands/build.ts +50 -32
  7. package/buddy/src/commands/changelog.ts +2 -2
  8. package/buddy/src/commands/clean.ts +2 -2
  9. package/buddy/src/commands/cloud.ts +31 -12
  10. package/buddy/src/commands/commit.ts +2 -2
  11. package/buddy/src/commands/configure.ts +4 -3
  12. package/buddy/src/commands/create.ts +3 -3
  13. package/buddy/src/commands/deploy.ts +21 -10
  14. package/buddy/src/commands/dev.ts +38 -25
  15. package/buddy/src/commands/dns.ts +2 -2
  16. package/buddy/src/commands/domains.ts +2 -2
  17. package/buddy/src/commands/fresh.ts +2 -2
  18. package/buddy/src/commands/generate.ts +27 -3
  19. package/buddy/src/commands/http.ts +2 -2
  20. package/buddy/src/commands/index.ts +3 -3
  21. package/buddy/src/commands/install.ts +2 -2
  22. package/buddy/src/commands/key.ts +2 -2
  23. package/buddy/src/commands/lint.ts +7 -10
  24. package/buddy/src/commands/list.ts +2 -2
  25. package/buddy/src/commands/make.ts +12 -12
  26. package/buddy/src/commands/migrate.ts +2 -2
  27. package/buddy/src/commands/outdated.ts +3 -3
  28. package/buddy/src/commands/ports.ts +26 -16
  29. package/buddy/src/commands/prepublish.ts +2 -2
  30. package/buddy/src/commands/projects.ts +6 -4
  31. package/buddy/src/commands/release.ts +4 -3
  32. package/buddy/src/commands/route.ts +2 -2
  33. package/buddy/src/commands/seed.ts +2 -2
  34. package/buddy/src/commands/setup.ts +11 -7
  35. package/buddy/src/commands/test.ts +77 -54
  36. package/buddy/src/commands/tinker.ts +2 -2
  37. package/buddy/src/commands/types.ts +2 -2
  38. package/buddy/src/commands/upgrade.ts +20 -13
  39. package/buddy/src/commands/version.ts +2 -2
  40. package/buddy/src/custom-cli.ts +3 -2
  41. package/buddy/tsconfig.json +1 -1
  42. package/package.json +53 -62
package/buddy/bin/cli.ts CHANGED
@@ -13,7 +13,8 @@ cli
13
13
  .action(() => {
14
14
  const buddyCli = 'buddy'
15
15
 
16
- if (existsSync(buddyCli)) $`${buddyCli} ${process.argv.slice(2).join(' ')}`
16
+ if (existsSync(buddyCli))
17
+ $`${buddyCli} ${process.argv.slice(2).join(' ')}`
17
18
 
18
19
  let currentDir = process.cwd()
19
20
  let found = false
@@ -33,7 +34,7 @@ cli
33
34
  process.exit(1)
34
35
  }
35
36
 
36
- $`bunx stacks new ${process.argv.slice(2).join(' ')}`
37
+ $`bunx --bun stacks new ${process.argv.slice(2).join(' ')}`
37
38
  })
38
39
 
39
40
  cli
@@ -52,7 +53,8 @@ cli
52
53
  const isDirectory = statSync(contentPath).isDirectory()
53
54
 
54
55
  if (isDirectory) {
55
- if (contentPath.includes(target)) return contentPath // Found the target directory
56
+ if (contentPath.includes(target))
57
+ return contentPath // Found the target directory
56
58
 
57
59
  queue.push(contentPath)
58
60
  }
@@ -68,7 +70,8 @@ cli
68
70
  console.log(`Project found at ${projectPath}.`)
69
71
  console.log(`Run 'cd ${projectPath}' to navigate to the project directory.`)
70
72
  // $`cd ${projectPath}`
71
- } else {
73
+ }
74
+ else {
72
75
  console.error('Project directory not found.')
73
76
  }
74
77
  })
package/buddy/build.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { dts } from 'bun-plugin-dts-auto'
1
2
  import { intro, outro } from '../build/src'
2
3
 
3
4
  const { startTime } = await intro({
@@ -31,6 +32,8 @@ const result = await Bun.build({
31
32
  '@stacksjs/types',
32
33
  'bun',
33
34
  ],
35
+
36
+ plugins: [dts({ root: './src', outdir: './dist' })],
34
37
  })
35
38
 
36
39
  await outro({
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
- "version": "0.64.6",
4
+ "version": "0.65.0",
5
5
  "description": "Meet Buddy. The Stacks runtime.",
6
6
  "author": "Chris Breuer",
7
+ "contributors": ["Chris Breuer <chris@stacksjs.org>"],
7
8
  "license": "MIT",
8
9
  "funding": "https://github.com/sponsors/chrisbbreuer",
9
10
  "homepage": "https://github.com/stacksjs/stacks/tree/main/stacks#readme",
@@ -50,7 +51,6 @@
50
51
  },
51
52
  "module": "dist/index.js",
52
53
  "types": "dist/index.d.ts",
53
- "contributors": ["Chris Breuer <chris@stacksjs.org>"],
54
54
  "bin": {
55
55
  "stacks": "dist/cli.mjs",
56
56
  "stx": "dist/cli.mjs",
@@ -59,8 +59,8 @@
59
59
  },
60
60
  "files": ["README.md", "dist", "src"],
61
61
  "scripts": {
62
- "buddy": "bunx ./src/cli.ts",
63
- "build": "bun --bun build.ts && bun run compile",
62
+ "buddy": "bunx --bun ./src/cli.ts",
63
+ "build": "bun build.ts && bun run compile",
64
64
  "compile": "bun build ./bin/cli.ts --compile --minify --sourcemap --outfile dist/stacks",
65
65
  "compile:linux:x64-modern": "bun build ./bin/cli.ts --compile --target=bun-linux-x64-modern --minify --sourcemap --outfile dist/stacks",
66
66
  "compile:linux:x64-baseline": "bun build ./bin/cli.ts --compile --target=bun-linux-x64-baseline --minify --sourcemap --outfile dist/stacks",
@@ -69,7 +69,7 @@
69
69
  "compile:windows:x64-baseline": "bun build ./bin/cli.ts --compile --target=bun-windows-x64-baseline --minify --sourcemap --outfile dist/stacks",
70
70
  "compile:mac:arm64": "bun build ./bin/cli.ts --compile --target=bun-darwin-arm64 --minify --sourcemap --outfile dist/stacks",
71
71
  "compile:mac:x64": "bun build ./bin/cli.ts --compile --target=bun-darwin-x64 --minify --sourcemap --outfile dist/stacks",
72
- "typecheck": "bun --bun tsc --noEmit",
72
+ "typecheck": "bun tsc --noEmit",
73
73
  "prepublishOnly": "bun run build"
74
74
  },
75
75
  "dependencies": {
package/buddy/src/cli.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import type { CAC } from '@stacksjs/cli'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
- import type { CAC } from '@stacksjs/cli'
4
4
  import { cli, log } from '@stacksjs/cli'
5
5
  import { Action } from '@stacksjs/enums'
6
6
  import { path as p } from '@stacksjs/path'
@@ -10,13 +10,13 @@ import * as cmd from './commands'
10
10
 
11
11
  // setup global error handlers
12
12
  process.on('uncaughtException', (error: Error) => {
13
- log.debug('uncaughtException')
13
+ log.debug('Buddy uncaughtException')
14
14
  log.error(error)
15
15
  process.exit(1)
16
16
  })
17
17
 
18
18
  process.on('unhandledRejection', (error: Error) => {
19
- log.debug('unhandledRejection', error)
19
+ log.debug('Buddy unhandledRejection')
20
20
  log.error(error)
21
21
  process.exit(1)
22
22
  })
@@ -32,7 +32,8 @@ async function main() {
32
32
  const isAppKeySet = await ensureProjectIsInitialized()
33
33
  if (isAppKeySet) {
34
34
  log.debug('Project is initialized')
35
- } else {
35
+ }
36
+ else {
36
37
  log.info('Your `APP_KEY` is not yet set')
37
38
  log.info('Generating application key...')
38
39
  const result = await runAction(Action.KeyGenerate)
@@ -86,17 +87,19 @@ await main()
86
87
  async function dynamicImports(buddy: CAC) {
87
88
  // dynamically import and register commands from ./app/Commands/*
88
89
  const commandsDir = p.appPath('Commands')
89
- const commandFiles = fs.readdirSync(commandsDir).filter((file) => file.endsWith('.ts'))
90
+ const commandFiles = fs.readdirSync(commandsDir).filter((file: string) => file.endsWith('.ts'))
90
91
 
91
92
  for (const file of commandFiles) {
92
93
  const commandPath = `${commandsDir}/${file}`
93
94
  const dynamicImport = await import(commandPath)
94
95
 
95
96
  // Correctly use the default export function
96
- if (typeof dynamicImport.default === 'function') dynamicImport.default(buddy)
97
+ if (typeof dynamicImport.default === 'function')
98
+ dynamicImport.default(buddy)
97
99
  else console.error(`Expected a default export function in ${file}, but got:`, dynamicImport.default)
98
100
  }
99
101
 
100
102
  const listenerImport = await import(p.listenersPath('Console.ts'))
101
- if (typeof listenerImport.default === 'function') listenerImport.default(buddy)
103
+ if (typeof listenerImport.default === 'function')
104
+ listenerImport.default(buddy)
102
105
  }
@@ -1,10 +1,10 @@
1
+ import type { AddOptions, BuildOptions, CLI } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAdd } from '@stacksjs/actions'
3
4
  import { log } from '@stacksjs/logging'
4
- import type { AddOptions, BuildOptions, CLI } from '@stacksjs/types'
5
5
  import { ExitCode } from '@stacksjs/types'
6
6
 
7
- export function add(buddy: CLI) {
7
+ export function add(buddy: CLI): void {
8
8
  const descriptions = {
9
9
  add: 'Add a stack to your project (coming soon)',
10
10
  table: 'Add the Table Stack to your project',
@@ -1,12 +1,11 @@
1
+ import type { BuildOptions, CLI } 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
- import type { BuildOptions, CLI } from '@stacksjs/types'
6
6
  import { ExitCode } from '@stacksjs/types'
7
- import { isString } from '@stacksjs/validation'
8
7
 
9
- export function build(buddy: CLI) {
8
+ export function build(buddy: CLI): void {
10
9
  const descriptions = {
11
10
  build: 'Build any of your libraries (packages) for production use',
12
11
  components: 'Build your component library',
@@ -73,38 +72,57 @@ export function build(buddy: CLI) {
73
72
  options.stacks = true
74
73
  break
75
74
  case 'server':
76
- options.stacks = true
75
+ options.server = true
77
76
  break
78
77
  default:
79
78
  break
80
79
  }
81
80
 
81
+ console.log('server', server, options)
82
+
82
83
  // TODO: uncomment this when prompt is available
83
84
  if (hasNoOptions(options)) {
84
- let answers = await log.prompt.require().multiselect(descriptions.select, {
85
- options: [
86
- { label: 'Components', value: 'components' },
85
+ console.log('has no')
86
+ const answers = await prompts({
87
+ type: 'multiselect',
88
+ name: 'build',
89
+ message: descriptions.select,
90
+ choices: [
91
+ { title: 'Components', value: 'components' },
87
92
  // { label: 'Vue Components', value: 'vue-components' },
88
- { label: 'Web Components', value: 'web-components' },
89
- { label: 'Functions', value: 'functions' },
90
- { label: 'Views', value: 'views' },
91
- { label: 'Documentation', value: 'docs' },
93
+ { title: 'Web Components', value: 'web-components' },
94
+ { title: 'Functions', value: 'functions' },
95
+ { title: 'Views', value: 'views' },
96
+ { title: 'Documentation', value: 'docs' },
92
97
  ],
93
98
  })
94
99
 
95
- if (answers !== null) process.exit(ExitCode.InvalidArgument)
96
-
97
- if (isString(answers)) answers = [answers]
98
-
99
- // creates an object out of array and sets answers to true
100
- options = answers.reduce((a: any, v: any) => {
101
- a[v] = true
102
- return a
103
- }, {})
100
+ console.log('answers', answers)
101
+ if (answers !== null)
102
+ process.exit(ExitCode.InvalidArgument)
103
+ }
104
+ else {
105
+ console.log('has op')
104
106
  }
105
107
 
106
- await runAction(Action.BuildStacks, options)
107
-
108
+ if (options.docs)
109
+ await runAction(Action.BuildDocs)
110
+ if (options.components)
111
+ await runAction(Action.BuildComponentLibs)
112
+ if (options.vueComponents)
113
+ await runAction(Action.BuildVueComponentLib)
114
+ if (options.webComponents)
115
+ await runAction(Action.BuildWebComponentLib)
116
+ if (options.functions)
117
+ await runAction(Action.BuildFunctionLib)
118
+ if (options.views)
119
+ await runAction(Action.BuildViews)
120
+ if (options.stacks)
121
+ await runAction(Action.BuildStacks)
122
+ if (options.buddy)
123
+ await runAction(Action.BuildCli)
124
+ if (options.server)
125
+ await runAction(Action.BuildServer)
108
126
  process.exit(ExitCode.Success)
109
127
  })
110
128
 
@@ -268,14 +286,14 @@ export function build(buddy: CLI) {
268
286
 
269
287
  function hasNoOptions(options: BuildOptions) {
270
288
  return (
271
- !options.components &&
272
- !options.vueComponents &&
273
- !options.webComponents &&
274
- !options.elements &&
275
- !options.functions &&
276
- !options.views &&
277
- !options.docs &&
278
- !options.stacks &&
279
- !options.buddy
289
+ !options.components
290
+ && !options.vueComponents
291
+ && !options.webComponents
292
+ && !options.elements
293
+ && !options.functions
294
+ && !options.views
295
+ && !options.docs
296
+ && !options.stacks
297
+ && !options.buddy
280
298
  )
281
299
  }
@@ -1,10 +1,10 @@
1
+ import type { CLI, FreshOptions } 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
- import type { CLI, FreshOptions } from '@stacksjs/types'
6
6
 
7
- export function changelog(buddy: CLI) {
7
+ export function changelog(buddy: CLI): void {
8
8
  const descriptions = {
9
9
  changelog: 'Create a CHANGELOG.md file',
10
10
  quiet: 'Minimal output',
@@ -1,11 +1,11 @@
1
+ import type { CleanOptions, CLI } 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, CleanOptions } from '@stacksjs/types'
7
7
 
8
- export function clean(buddy: CLI) {
8
+ export function clean(buddy: CLI): void {
9
9
  const descriptions = {
10
10
  clean: 'Removes all node_modules & lock files',
11
11
  project: 'Target a specific project',
@@ -1,3 +1,4 @@
1
+ import type { CLI, CloudCliOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront'
3
4
  import { intro, italic, log, outro, prompts, runCommand, underline } from '@stacksjs/cli'
@@ -10,15 +11,16 @@ import {
10
11
  deleteParameterStore,
11
12
  deleteStacksBuckets,
12
13
  deleteStacksFunctions,
14
+ deleteSubnets,
15
+ deleteVpcs,
13
16
  getCloudFrontDistributionId,
14
17
  getJumpBoxInstanceId,
15
18
  } from '@stacksjs/cloud'
16
19
  import { path as p } from '@stacksjs/path'
17
- import type { CLI, CloudCliOptions } from '@stacksjs/types'
18
20
  import { ExitCode } from '@stacksjs/types'
19
21
  import { loop } from '@stacksjs/utils'
20
22
 
21
- export function cloud(buddy: CLI) {
23
+ export function cloud(buddy: CLI): void {
22
24
  const descriptions = {
23
25
  cloud: 'Interact with the Stacks Cloud',
24
26
  ssh: 'SSH into the Stacks Cloud',
@@ -101,8 +103,8 @@ export function cloud(buddy: CLI) {
101
103
  const command = new CreateInvalidationCommand(params)
102
104
 
103
105
  cloudfront.send(command).then(
104
- (data) => console.log(data),
105
- (err) => console.log(err, err.stack),
106
+ data => console.log(data),
107
+ err => console.log(err, err.stack),
106
108
  )
107
109
 
108
110
  await outro('Exited', { startTime, useSeconds: true })
@@ -110,7 +112,7 @@ export function cloud(buddy: CLI) {
110
112
  }
111
113
 
112
114
  if (options.diff) {
113
- const result = await runCommand('npx cdk diff', {
115
+ const result = await runCommand('bunx --bun cdk diff', {
114
116
  cwd: p.frameworkCloudPath(),
115
117
  stdin: 'pipe',
116
118
  })
@@ -158,7 +160,7 @@ export function cloud(buddy: CLI) {
158
160
  log.info('The jump-box is getting added to your cloud resources...')
159
161
  log.info('This takes a few moments, please be patient.')
160
162
  // sleep for 2 seconds to get the user to read the message
161
- await new Promise((resolve) => setTimeout(resolve, 2000))
163
+ await new Promise(resolve => setTimeout(resolve, 2000))
162
164
 
163
165
  const result = await addJumpBox()
164
166
 
@@ -236,9 +238,9 @@ export function cloud(buddy: CLI) {
236
238
  console.log(` ${italic('Backups are scheduled to delete themselves in 30 days.')}`)
237
239
 
238
240
  // sleep for 2 seconds to get the user to read the message
239
- await new Promise((resolve) => setTimeout(resolve, 2000))
241
+ await new Promise(resolve => setTimeout(resolve, 2000))
240
242
 
241
- const result = await runCommand(`npx cdk destroy`, {
243
+ const result = await runCommand(`bunx --bun cdk destroy`, {
242
244
  ...options,
243
245
  cwd: p.frameworkCloudPath(),
244
246
  stdin: 'inherit',
@@ -280,7 +282,8 @@ export function cloud(buddy: CLI) {
280
282
  useSeconds: true,
281
283
  })
282
284
  process.exit(ExitCode.Success)
283
- } catch (error) {
285
+ }
286
+ catch (error) {
284
287
  await outro('While cleaning up the cloud, there was an issue', { startTime, useSeconds: true }, error as Error)
285
288
  process.exit(ExitCode.FatalError)
286
289
  }
@@ -337,7 +340,7 @@ export function cloud(buddy: CLI) {
337
340
  log.info(`Cleaning up your cloud resources will take a while to complete. Please be patient.`)
338
341
 
339
342
  // sleep for 2 seconds to get the user to read the message
340
- await new Promise((resolve) => setTimeout(resolve, 2000))
343
+ await new Promise(resolve => setTimeout(resolve, 2000))
341
344
 
342
345
  log.info('Removing any jump-boxes...')
343
346
  const result = await deleteJumpBox()
@@ -365,12 +368,13 @@ export function cloud(buddy: CLI) {
365
368
  const result3 = await deleteStacksFunctions()
366
369
 
367
370
  if (result3.isErr()) {
368
- if (result3.error !== 'No stacks functions found')
371
+ if (result3.error !== 'No stacks functions found') {
369
372
  await outro(
370
373
  'While deleting the Origin Request Lambda function, there was an issue',
371
374
  { startTime, useSeconds: true },
372
375
  result3.error,
373
376
  )
377
+ }
374
378
 
375
379
  process.exit(ExitCode.FatalError)
376
380
  }
@@ -410,6 +414,21 @@ export function cloud(buddy: CLI) {
410
414
  process.exit(ExitCode.FatalError)
411
415
  }
412
416
 
417
+ // delete all vpcs & subnets & internet gateways
418
+ const result9 = await deleteVpcs()
419
+
420
+ if (result9.isErr()) {
421
+ await outro('While deleting the VPCs, there was an issue', { startTime, useSeconds: true }, result9.error)
422
+ process.exit(ExitCode.FatalError)
423
+ }
424
+
425
+ const result10 = await deleteSubnets()
426
+
427
+ if (result10.isErr()) {
428
+ await outro('While deleting the Subnets, there was an issue', { startTime, useSeconds: true }, result10.error)
429
+ process.exit(ExitCode.FatalError)
430
+ }
431
+
413
432
  log.info('Removing any CDK remnants...')
414
433
  const result6 = await deleteCdkRemnants()
415
434
 
@@ -508,7 +527,7 @@ export function cloud(buddy: CLI) {
508
527
 
509
528
  const startTime = await intro('buddy cloud:diff')
510
529
 
511
- const result = await runCommand('npx cdk diff', {
530
+ const result = await runCommand('bunx --bun cdk diff', {
512
531
  cwd: p.frameworkCloudPath(),
513
532
  stdin: 'pipe',
514
533
  })
@@ -1,9 +1,9 @@
1
+ import type { CLI, FreshOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runCommit } from '@stacksjs/actions'
3
4
  import { log } from '@stacksjs/logging'
4
- import type { CLI, FreshOptions } from '@stacksjs/types'
5
5
 
6
- export function commit(buddy: CLI) {
6
+ export function commit(buddy: CLI): void {
7
7
  const descriptions = {
8
8
  commit: 'Commit your stashed changes',
9
9
  project: 'Target a specific project',
@@ -1,10 +1,10 @@
1
+ import type { CLI, ConfigureOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { log, outro, runCommand } from '@stacksjs/cli'
3
4
  import { path as p } from '@stacksjs/path'
4
- import type { CLI, ConfigureOptions } from '@stacksjs/types'
5
5
  import { ExitCode } from '@stacksjs/types'
6
6
 
7
- export function configure(buddy: CLI) {
7
+ export function configure(buddy: CLI): void {
8
8
  const descriptions = {
9
9
  configure: 'Configure options',
10
10
  aws: 'Configure the AWS connection',
@@ -77,7 +77,8 @@ async function configureAws(options?: ConfigureOptions) {
77
77
  process.exit(ExitCode.FatalError)
78
78
  }
79
79
 
80
- if (options?.quiet) return
80
+ if (options?.quiet)
81
+ return
81
82
 
82
83
  await outro('Exited', { startTime, useSeconds: true })
83
84
  }
@@ -1,3 +1,4 @@
1
+ import type { CLI, CreateOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
4
  import { bold, cyan, dim, intro, log, runCommand } from '@stacksjs/cli'
@@ -5,10 +6,9 @@ import { Action } from '@stacksjs/enums'
5
6
  import { resolve } from '@stacksjs/path'
6
7
  import { isFolder } from '@stacksjs/storage'
7
8
  import { ExitCode } from '@stacksjs/types'
8
- import type { CLI, CreateOptions } from '@stacksjs/types'
9
9
  import { useOnline } from '@stacksjs/utils'
10
10
 
11
- export function create(buddy: CLI) {
11
+ export function create(buddy: CLI): void {
12
12
  const descriptions = {
13
13
  name: 'The name of the project',
14
14
  command: 'Create a new Stacks project',
@@ -101,7 +101,7 @@ function onlineCheck() {
101
101
 
102
102
  async function download(name: string, path: string, options: CreateOptions) {
103
103
  log.info('Setting up your stack.')
104
- const result = await runCommand(`bunx giget stacks ${name}`, options)
104
+ const result = await runCommand(`bunx --bun giget stacks ${name}`, options)
105
105
  log.success(`Successfully scaffolded your project at ${cyan(path)}`)
106
106
 
107
107
  return result
@@ -1,21 +1,22 @@
1
+ import type { CLI, DeployOptions } from '@stacksjs/types'
1
2
  import process from 'node:process'
2
3
  import { runAction } from '@stacksjs/actions'
3
- import { intro, italic, log, outro, runCommand } from '@stacksjs/cli'
4
+ import { intro, italic, log, outro, prompts, runCommand } from '@stacksjs/cli'
4
5
  import { app } from '@stacksjs/config'
5
6
  import { addDomain, hasUserDomainBeenAddedToCloud } from '@stacksjs/dns'
6
7
  import { Action } from '@stacksjs/enums'
7
8
  import { path as p } from '@stacksjs/path'
8
9
  import { ExitCode } from '@stacksjs/types'
9
- import type { CLI, DeployOptions } from '@stacksjs/types'
10
10
  import { $ } from 'bun'
11
11
 
12
- export function deploy(buddy: CLI) {
12
+ export function deploy(buddy: CLI): void {
13
13
  const descriptions = {
14
14
  deploy: 'Deploy your project',
15
15
  project: 'Target a specific project',
16
16
  production: 'Deploy to production',
17
17
  development: 'Deploy to development',
18
18
  staging: 'Deploy to staging',
19
+ yes: 'Confirm all prompts by default',
19
20
  domain: 'Specify a domain to deploy to',
20
21
  verbose: 'Enable verbose output',
21
22
  }
@@ -26,6 +27,7 @@ export function deploy(buddy: CLI) {
26
27
  .option('-p, --project [project]', descriptions.project, { default: false })
27
28
  .option('--prod', descriptions.production, { default: true })
28
29
  .option('--dev', descriptions.development, { default: false })
30
+ .option('--yes', descriptions.yes, { default: false })
29
31
  .option('--staging', descriptions.staging, { default: false })
30
32
  .option('--verbose', descriptions.verbose, { default: false })
31
33
  .action(async (env: string | undefined, options: DeployOptions) => {
@@ -34,7 +36,8 @@ export function deploy(buddy: CLI) {
34
36
  const startTime = await intro('buddy deploy')
35
37
  const domain = options.domain || app.url
36
38
 
37
- if (options.prod || env === 'production' || env === 'prod') await confirmProductionDeployment()
39
+ if ((options.prod || env === 'production' || env === 'prod') && !options.yes)
40
+ await confirmProductionDeployment()
38
41
 
39
42
  if (!domain) {
40
43
  log.info('No domain found in your .env or ./config/app.ts')
@@ -71,15 +74,20 @@ export function deploy(buddy: CLI) {
71
74
  }
72
75
 
73
76
  async function confirmProductionDeployment() {
74
- const answer = await log.prompt.require().confirm('Are you sure you want to deploy to production?')
77
+ const { confirmed } = await prompts({
78
+ type: 'confirm',
79
+ name: 'confirmed',
80
+ message: 'Are you sure you want to deploy to production?',
81
+ })
75
82
 
76
- if (!answer) {
83
+ if (!confirmed) {
77
84
  log.info('Aborting deployment...')
78
85
  process.exit(ExitCode.InvalidArgument)
79
86
  }
80
87
  }
81
88
 
82
89
  async function configureDomain(domain: string, options: DeployOptions, startTime: number) {
90
+ log.debug('Configuring domain...', domain)
83
91
  if (!domain) {
84
92
  log.info('We could not identify a domain to deploy to.')
85
93
  log.warn('Please set your .env or ./config/app.ts properly.')
@@ -144,9 +152,10 @@ async function checkIfAwsIsConfigured() {
144
152
  })
145
153
 
146
154
  if (result.isErr()) {
147
- log.error('AWS is not configured properly.')
155
+ log.error('AWS is not configured properly.', {
156
+ shouldExit: false,
157
+ })
148
158
  log.error('Please run `buddy configure:aws` to set up your AWS credentials.')
149
- process.exit(ExitCode.FatalError)
150
159
  }
151
160
 
152
161
  log.success('AWS is configured')
@@ -161,7 +170,8 @@ async function checkIfAwsIsBootstrapped() {
161
170
  log.success('AWS is bootstrapped')
162
171
 
163
172
  return true
164
- } catch (err: any) {
173
+ }
174
+ catch (err: any) {
165
175
  log.debug(`Not yet bootstrapped. Failed with code ${err.exitCode}`)
166
176
  log.debug(err.stdout.toString())
167
177
  log.debug(err.stderr.toString())
@@ -174,7 +184,8 @@ async function checkIfAwsIsBootstrapped() {
174
184
  const result = await $`bun run bootstrap`
175
185
  console.log(result)
176
186
  return true
177
- } catch (error) {
187
+ }
188
+ catch (error) {
178
189
  log.error('Failed to bootstrap AWS')
179
190
  console.error(error)
180
191
  process.exit(ExitCode.FatalError)