@stacksjs/buddy 0.65.0 → 0.67.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 (106) hide show
  1. package/dist/{chunk-agapayce.js → chunk-3whxjf1k.js} +1 -4
  2. package/dist/chunk-42swmjjw.js +2 -0
  3. package/dist/chunk-564c63vr.js +2 -0
  4. package/dist/chunk-5wxk7vka.js +1 -0
  5. package/dist/chunk-6cscdnf5.js +2 -0
  6. package/dist/chunk-898dh3kh.js +8 -0
  7. package/dist/chunk-9g2p5d3j.js +2 -0
  8. package/dist/chunk-bpa4071y.js +2 -0
  9. package/dist/chunk-cbtnhpqk.js +2 -0
  10. package/dist/chunk-f18wwa85.js +827 -0
  11. package/dist/chunk-g767h9jq.js +3 -0
  12. package/dist/chunk-hgzxtrgw.js +9 -0
  13. package/dist/chunk-hqv9y9k2.js +6 -0
  14. package/dist/chunk-jfs19hhz.js +2 -0
  15. package/dist/chunk-ncwfzcsm.js +2 -0
  16. package/dist/chunk-pfb4369d.js +2 -0
  17. package/dist/chunk-sgm5999j.js +12 -0
  18. package/dist/chunk-we57sm1m.js +2 -0
  19. package/dist/chunk-wps8bq6b.js +2 -0
  20. package/dist/chunk-y2g00ayp.js +2 -0
  21. package/dist/chunk-ycyg22fp.js +2 -0
  22. package/dist/cli.js +1 -4
  23. package/dist/index.js +1 -4
  24. package/dist/stacks +0 -0
  25. package/package.json +48 -49
  26. package/dist/chunk-1bcxd9nx.js +0 -5
  27. package/dist/chunk-1bcxd9nx.js.map +0 -17
  28. package/dist/chunk-3gvx3tap.js +0 -5
  29. package/dist/chunk-3gvx3tap.js.map +0 -9
  30. package/dist/chunk-5mkzknp4.js +0 -5
  31. package/dist/chunk-5mkzknp4.js.map +0 -32
  32. package/dist/chunk-a3d48jzd.js +0 -15
  33. package/dist/chunk-a3d48jzd.js.map +0 -164
  34. package/dist/chunk-a6ba4vgs.js +0 -5
  35. package/dist/chunk-a6ba4vgs.js.map +0 -11
  36. package/dist/chunk-agapayce.js.map +0 -15
  37. package/dist/chunk-b9d377d9.js +0 -5
  38. package/dist/chunk-b9d377d9.js.map +0 -26
  39. package/dist/chunk-bh61bx6h.js +0 -4
  40. package/dist/chunk-bh61bx6h.js.map +0 -23
  41. package/dist/chunk-fqrjh7j8.js +0 -5
  42. package/dist/chunk-fqrjh7j8.js.map +0 -10
  43. package/dist/chunk-jkt9jxar.js +0 -9
  44. package/dist/chunk-jkt9jxar.js.map +0 -13
  45. package/dist/chunk-k1q2z202.js +0 -4
  46. package/dist/chunk-k1q2z202.js.map +0 -16
  47. package/dist/chunk-mmjggjd5.js +0 -849
  48. package/dist/chunk-mmjggjd5.js.map +0 -240
  49. package/dist/chunk-mxwvrbdh.js +0 -6
  50. package/dist/chunk-mxwvrbdh.js.map +0 -59
  51. package/dist/chunk-n55kahn5.js +0 -5
  52. package/dist/chunk-n55kahn5.js.map +0 -12
  53. package/dist/chunk-pbpgcz3v.js +0 -5
  54. package/dist/chunk-pbpgcz3v.js.map +0 -46
  55. package/dist/chunk-sadghty0.js +0 -5
  56. package/dist/chunk-sadghty0.js.map +0 -20
  57. package/dist/chunk-smzpmhmp.js +0 -11
  58. package/dist/chunk-smzpmhmp.js.map +0 -10
  59. package/dist/chunk-w4zypt02.js +0 -5
  60. package/dist/chunk-w4zypt02.js.map +0 -23
  61. package/dist/chunk-ywfsnx7v.js +0 -5
  62. package/dist/chunk-ywfsnx7v.js.map +0 -22
  63. package/dist/chunk-yxs8vtg9.js +0 -5
  64. package/dist/chunk-yxs8vtg9.js.map +0 -10
  65. package/dist/chunk-z7609s4h.js +0 -12
  66. package/dist/chunk-z7609s4h.js.map +0 -11
  67. package/dist/cli.js.map +0 -10
  68. package/dist/index.js.map +0 -9
  69. package/src/cli.ts +0 -105
  70. package/src/commands/add.ts +0 -71
  71. package/src/commands/build.ts +0 -299
  72. package/src/commands/changelog.ts +0 -52
  73. package/src/commands/clean.ts +0 -46
  74. package/src/commands/cloud.ts +0 -553
  75. package/src/commands/commit.ts +0 -26
  76. package/src/commands/configure.ts +0 -84
  77. package/src/commands/create.ts +0 -143
  78. package/src/commands/deploy.ts +0 -194
  79. package/src/commands/dev.ts +0 -292
  80. package/src/commands/dns.ts +0 -86
  81. package/src/commands/domains.ts +0 -255
  82. package/src/commands/fresh.ts +0 -48
  83. package/src/commands/generate.ts +0 -202
  84. package/src/commands/http.ts +0 -57
  85. package/src/commands/index.ts +0 -33
  86. package/src/commands/install.ts +0 -30
  87. package/src/commands/key.ts +0 -36
  88. package/src/commands/lint.ts +0 -54
  89. package/src/commands/list.ts +0 -42
  90. package/src/commands/make.ts +0 -352
  91. package/src/commands/migrate.ts +0 -105
  92. package/src/commands/outdated.ts +0 -31
  93. package/src/commands/ports.ts +0 -188
  94. package/src/commands/prepublish.ts +0 -28
  95. package/src/commands/projects.ts +0 -54
  96. package/src/commands/release.ts +0 -50
  97. package/src/commands/route.ts +0 -39
  98. package/src/commands/seed.ts +0 -47
  99. package/src/commands/setup.ts +0 -145
  100. package/src/commands/test.ts +0 -214
  101. package/src/commands/tinker.ts +0 -42
  102. package/src/commands/types.ts +0 -35
  103. package/src/commands/upgrade.ts +0 -200
  104. package/src/commands/version.ts +0 -29
  105. package/src/custom-cli.ts +0 -35
  106. package/src/index.ts +0 -1
@@ -1,553 +0,0 @@
1
- import type { CLI, CloudCliOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront'
4
- import { intro, italic, log, outro, prompts, runCommand, underline } from '@stacksjs/cli'
5
- import {
6
- addJumpBox,
7
- deleteCdkRemnants,
8
- deleteIamUsers,
9
- deleteJumpBox,
10
- deleteLogGroups,
11
- deleteParameterStore,
12
- deleteStacksBuckets,
13
- deleteStacksFunctions,
14
- deleteSubnets,
15
- deleteVpcs,
16
- getCloudFrontDistributionId,
17
- getJumpBoxInstanceId,
18
- } from '@stacksjs/cloud'
19
- import { path as p } from '@stacksjs/path'
20
- import { ExitCode } from '@stacksjs/types'
21
- import { loop } from '@stacksjs/utils'
22
-
23
- export function cloud(buddy: CLI): void {
24
- const descriptions = {
25
- cloud: 'Interact with the Stacks Cloud',
26
- ssh: 'SSH into the Stacks Cloud',
27
- add: 'Add a resource to the Stacks Cloud',
28
- remove: 'Remove the Stacks Cloud. In case it fails, try again',
29
- optimizeCost: 'Remove certain resources that may be re-applied at a later time',
30
- cleanUp: 'Remove all resources that were retained during the cloud deletion',
31
- invalidateCache: 'Invalidate the CloudFront cache',
32
- diff: 'Show the diff of the current, undeployed cloud changes ',
33
- paths: 'The paths to invalidate',
34
- project: 'Target a specific project',
35
- verbose: 'Enable verbose output',
36
- }
37
-
38
- buddy
39
- .command('cloud', descriptions.cloud)
40
- .option('--ssh', descriptions.ssh, { default: false })
41
- .option('--connect', descriptions.ssh, { default: false })
42
- .option('--invalidate-cache', descriptions.invalidateCache, { default: false })
43
- .option('--paths [paths]', descriptions.paths)
44
- .option('--diff', descriptions.diff, { default: false })
45
- .option('-p, --project [project]', descriptions.project, { default: false })
46
- .option('--verbose', descriptions.verbose, { default: false })
47
- .action(async (options: CloudCliOptions) => {
48
- log.debug('Running `buddy cloud` ...', options)
49
- const startTime = performance.now()
50
-
51
- if (options.ssh || options.connect) {
52
- const jumpBoxId = await getJumpBoxInstanceId()
53
- const result = await runCommand(`aws ssm start-session --target ${jumpBoxId}`, {
54
- ...options,
55
- cwd: p.projectPath(),
56
- stdin: 'pipe',
57
- })
58
-
59
- if (result.isErr()) {
60
- await outro(
61
- 'While running the cloud command, there was an issue',
62
- { startTime, useSeconds: true },
63
- result.error,
64
- )
65
- process.exit(ExitCode.FatalError)
66
- }
67
-
68
- await outro('Exited', { startTime, useSeconds: true })
69
- process.exit(ExitCode.Success)
70
- }
71
-
72
- if (options.invalidateCache) {
73
- const { confirm } = await prompts({
74
- name: 'confirm',
75
- type: 'confirm',
76
- message: 'Would you like to invalidate the CDN (CloudFront) cache?',
77
- })
78
-
79
- if (!confirm) {
80
- await outro('Exited', { startTime, useSeconds: true })
81
- process.exit(ExitCode.Success)
82
- }
83
-
84
- log.info('Invalidating the CloudFront cache...')
85
-
86
- const cloudfront = new CloudFrontClient()
87
- const distributionId = await getCloudFrontDistributionId()
88
-
89
- const params = {
90
- DistributionId: distributionId,
91
- InvalidationBatch: {
92
- CallerReference: `${Date.now()}`,
93
- Paths: {
94
- Quantity: 1,
95
- Items: [
96
- '/*',
97
- /* more items */
98
- ],
99
- },
100
- },
101
- }
102
-
103
- const command = new CreateInvalidationCommand(params)
104
-
105
- cloudfront.send(command).then(
106
- data => console.log(data),
107
- err => console.log(err, err.stack),
108
- )
109
-
110
- await outro('Exited', { startTime, useSeconds: true })
111
- process.exit(ExitCode.Success)
112
- }
113
-
114
- if (options.diff) {
115
- const result = await runCommand('bunx --bun cdk diff', {
116
- cwd: p.frameworkCloudPath(),
117
- stdin: 'pipe',
118
- })
119
-
120
- if (result.isErr()) {
121
- await outro(
122
- 'While running the cloud diff command, there was an issue',
123
- { startTime, useSeconds: true },
124
- result.error,
125
- )
126
- process.exit(ExitCode.FatalError)
127
- }
128
-
129
- await outro('Showing diff of the current, undeployed cloud changes', { startTime, useSeconds: true })
130
- console.log(result.value)
131
- process.exit(ExitCode.Success)
132
- }
133
-
134
- log.info('Not implemented yet. Read more about `buddy cloud` here: https://stacksjs.org/docs/cloud')
135
- process.exit(ExitCode.Success)
136
- })
137
-
138
- buddy
139
- .command('cloud:add', descriptions.add)
140
- .option('--jump-box', 'Remove the jump-box', { default: false })
141
- .option('-p, --project [project]', descriptions.project, { default: false })
142
- .option('--verbose', descriptions.verbose, { default: false })
143
- .action(async (options: CloudCliOptions) => {
144
- log.debug('Running `buddy cloud:add` ...', options)
145
-
146
- const startTime = await intro('buddy cloud:add')
147
-
148
- if (options.jumpBox) {
149
- const { confirm } = await prompts({
150
- name: 'confirm',
151
- type: 'confirm',
152
- message: 'Would you like to add a jump-box to your cloud?',
153
- })
154
-
155
- if (!confirm) {
156
- await outro('Exited', { startTime, useSeconds: true })
157
- process.exit(ExitCode.Success)
158
- }
159
-
160
- log.info('The jump-box is getting added to your cloud resources...')
161
- log.info('This takes a few moments, please be patient.')
162
- // sleep for 2 seconds to get the user to read the message
163
- await new Promise(resolve => setTimeout(resolve, 2000))
164
-
165
- const result = await addJumpBox()
166
-
167
- if (result.isErr()) {
168
- await outro(
169
- 'While running the cloud:add command, there was an issue',
170
- { startTime, useSeconds: true },
171
- result.error,
172
- )
173
- process.exit(ExitCode.FatalError)
174
- }
175
-
176
- log.info(italic('View the jump-box in the AWS console:'))
177
- log.info(
178
- underline(
179
- 'https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#Instances:instanceState=running',
180
- ),
181
- )
182
- log.info(italic('Once it finished initializing, you may SSH into it:'))
183
- log.info(underline('buddy cloud --ssh'))
184
-
185
- await outro('Your jump-box was added.', {
186
- startTime,
187
- useSeconds: true,
188
- })
189
- process.exit(ExitCode.Success)
190
- }
191
-
192
- log.info('This functionality is not yet implemented.')
193
- process.exit(ExitCode.Success)
194
- })
195
-
196
- buddy
197
- .command('cloud:remove', descriptions.remove)
198
- .alias('cloud:destroy')
199
- .alias('cloud:rm')
200
- .alias('undeploy')
201
- .option('--jump-box', 'Remove the jump-box', { default: false })
202
- // .option('--realtime-cdn-logs', 'Remove the CDN Realtime Log Stream', { default: false }) // TODO: implement this
203
- .option('-p, --project [project]', descriptions.project, { default: false })
204
- .option('--verbose', descriptions.verbose, { default: false })
205
- .action(async (options: CloudCliOptions) => {
206
- log.debug('Running `buddy cloud:remove` ...', options)
207
-
208
- const startTime = await intro('buddy cloud:remove')
209
-
210
- if (options.jumpBox) {
211
- const { confirm } = await prompts({
212
- name: 'confirm',
213
- type: 'confirm',
214
- message: 'Would you like to remove your jump-box for now?',
215
- })
216
-
217
- if (!confirm) {
218
- await outro('Exited', { startTime, useSeconds: true })
219
- process.exit(ExitCode.Success)
220
- }
221
-
222
- const result = await deleteJumpBox()
223
-
224
- if (result.isErr()) {
225
- await outro('While removing your jump-box, there was an issue', { startTime, useSeconds: true }, result.error)
226
- process.exit(ExitCode.FatalError)
227
- }
228
-
229
- await outro('Your jump-box was removed.', {
230
- startTime,
231
- useSeconds: true,
232
- })
233
- process.exit(ExitCode.Success)
234
- }
235
-
236
- console.log(` ${italic('ℹ️ Removing your cloud resources takes a while to complete.')}`)
237
- console.log(` ${italic('Please note, your backups will not yet be deleted. Though,')}`)
238
- console.log(` ${italic('Backups are scheduled to delete themselves in 30 days.')}`)
239
-
240
- // sleep for 2 seconds to get the user to read the message
241
- await new Promise(resolve => setTimeout(resolve, 2000))
242
-
243
- const result = await runCommand(`bunx --bun cdk destroy`, {
244
- ...options,
245
- cwd: p.frameworkCloudPath(),
246
- stdin: 'inherit',
247
- })
248
-
249
- if (result.isErr()) {
250
- await outro(
251
- 'While running the cloud:remove ("undeploy") command, there was an issue',
252
- { startTime, useSeconds: true },
253
- result.error,
254
- )
255
- process.exit(ExitCode.FatalError)
256
- }
257
-
258
- await runCommand('buddy cloud:cleanup', {
259
- ...options,
260
- cwd: p.projectPath(),
261
- stdin: 'inherit',
262
- })
263
-
264
- // TODO: this should not be necessary but for some reason some buckets with versions aren't properly getting deleted
265
- // and because of that, we simply run the command several times, because eventually the versions will be deleted
266
- // and consequently the buckets will be deleted
267
- // the reason we are using 7 as the number of times to run the command is because it’s the most amount of times I have had to run it to get it to delete everything
268
- try {
269
- log.info('Finalizing the removal of your cloud resources.')
270
- log.info('This will take a few moments...')
271
- // sometimes, this fails, so we need to retry it until all resources are deleted -> weird workaround, and would love a more stable alternative
272
- await loop(7, async () => {
273
- await runCommand('buddy cloud:cleanup', {
274
- ...options,
275
- cwd: p.projectPath(),
276
- stdout: 'ignore',
277
- })
278
- })
279
-
280
- await outro('Your cloud has been removed', {
281
- startTime,
282
- useSeconds: true,
283
- })
284
- process.exit(ExitCode.Success)
285
- }
286
- catch (error) {
287
- await outro('While cleaning up the cloud, there was an issue', { startTime, useSeconds: true }, error as Error)
288
- process.exit(ExitCode.FatalError)
289
- }
290
- })
291
-
292
- buddy
293
- .command('cloud:optimize-cost', descriptions.optimizeCost)
294
- .option('--jump-box', 'Remove the jump-box', { default: true }) // removes the ec2 instance
295
- // .option('--realtime-cdn-logs', 'Remove the CDN Realtime Log Stream', { default: true }) // TODO: implement this - removes the Kinesis Data Stream
296
- .option('-p, --project [project]', descriptions.project, { default: false })
297
- .option('--verbose', descriptions.verbose, { default: false })
298
- .action(async (options: CloudCliOptions) => {
299
- log.debug('Running `buddy cloud:optimize-cost` ...', options)
300
-
301
- const startTime = await intro('buddy cloud:optimize-cost')
302
-
303
- if (options.jumpBox) {
304
- const { confirm } = await prompts({
305
- name: 'confirm',
306
- type: 'confirm',
307
- message: 'Would you like to remove your jump-box to optimize your costs?',
308
- })
309
-
310
- if (!confirm) {
311
- await outro('Exited', { startTime, useSeconds: true })
312
- process.exit(ExitCode.Success)
313
- }
314
-
315
- // at the moment, the jump-box is the only resource that is removed to optimize costs
316
- // because it can be re-applied at any later time
317
- await deleteJumpBox()
318
-
319
- await outro('Your jump-box was removed & cost optimizations are applied.', { startTime, useSeconds: true })
320
- process.exit(ExitCode.Success)
321
- }
322
-
323
- await outro('No cost optimization was applied', {
324
- startTime,
325
- useSeconds: true,
326
- })
327
- process.exit(ExitCode.Success)
328
- })
329
-
330
- buddy
331
- .command('cloud:cleanup', descriptions.cleanUp)
332
- .alias('cloud:clean-up')
333
- .option('-p, --project [project]', descriptions.project, { default: false })
334
- .option('--verbose', descriptions.verbose, { default: false })
335
- .action(async (options: CloudCliOptions) => {
336
- log.debug('Running `buddy cloud:cleanup` ...', options)
337
-
338
- const startTime = await intro('buddy cloud:cleanup')
339
-
340
- log.info(`Cleaning up your cloud resources will take a while to complete. Please be patient.`)
341
-
342
- // sleep for 2 seconds to get the user to read the message
343
- await new Promise(resolve => setTimeout(resolve, 2000))
344
-
345
- log.info('Removing any jump-boxes...')
346
- const result = await deleteJumpBox()
347
-
348
- if (result.isErr()) {
349
- if (result.error !== 'Jump-box not found') {
350
- await outro('While removing your jump-box, there was an issue', { startTime, useSeconds: true }, result.error)
351
- process.exit(ExitCode.FatalError)
352
- }
353
- }
354
-
355
- log.info('Removing any retained S3 buckets...')
356
- const result2 = await deleteStacksBuckets()
357
-
358
- if (result2.isErr()) {
359
- await outro(
360
- 'While deleting the retained S3 buckets, there was an issue',
361
- { startTime, useSeconds: true },
362
- result2.error,
363
- )
364
- process.exit(ExitCode.FatalError)
365
- }
366
-
367
- log.info('Removing any retained Lambda functions...')
368
- const result3 = await deleteStacksFunctions()
369
-
370
- if (result3.isErr()) {
371
- if (result3.error !== 'No stacks functions found') {
372
- await outro(
373
- 'While deleting the Origin Request Lambda function, there was an issue',
374
- { startTime, useSeconds: true },
375
- result3.error,
376
- )
377
- }
378
-
379
- process.exit(ExitCode.FatalError)
380
- }
381
-
382
- log.info(result3.value)
383
-
384
- log.info('Removing any remaining Stacks logs...')
385
- const result4 = await deleteLogGroups()
386
- // TODO: investigate other regions for edge (cloudfront) logs
387
-
388
- if (result4.isErr()) {
389
- await outro(
390
- 'While deleting the Stacks log groups, there was an issue',
391
- { startTime, useSeconds: true },
392
- result4.error,
393
- )
394
- process.exit(ExitCode.FatalError)
395
- }
396
-
397
- // log.info('Removing any Backup Vaults...')
398
- // const result5 = await deleteBackupVaults()
399
-
400
- // if (result5.isErr()) {
401
- // await outro('While deleting the Backup Vaults, there was an issue', { startTime, useSeconds: true }, result5.error)
402
- // process.exit(ExitCode.FatalError)
403
- // }
404
-
405
- log.info('Removing any stored parameters...')
406
- const result7 = await deleteParameterStore()
407
-
408
- if (result7.isErr()) {
409
- await outro(
410
- 'While deleting the Stacks log groups, there was an issue',
411
- { startTime, useSeconds: true },
412
- result7.error,
413
- )
414
- process.exit(ExitCode.FatalError)
415
- }
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
-
432
- log.info('Removing any CDK remnants...')
433
- const result6 = await deleteCdkRemnants()
434
-
435
- if (result6.isErr()) {
436
- await outro(
437
- 'While deleting the Stacks log groups, there was an issue',
438
- { startTime, useSeconds: true },
439
- result6.error,
440
- )
441
- process.exit(ExitCode.FatalError)
442
- }
443
-
444
- log.info('Removing any IAM users...')
445
- const result8 = await deleteIamUsers()
446
-
447
- if (result8.isErr()) {
448
- await outro(
449
- 'While deleting the Stacks log groups, there was an issue',
450
- { startTime, useSeconds: true },
451
- result8.error,
452
- )
453
- process.exit(ExitCode.FatalError)
454
- }
455
-
456
- // TODO: needs to delete all Backup Vaults
457
- // TODO: needs to delete all KMS keys
458
-
459
- await outro('AWS resources have been removed', {
460
- startTime,
461
- useSeconds: true,
462
- })
463
- process.exit(ExitCode.Success)
464
- })
465
-
466
- buddy
467
- .command('cloud:invalidate-cache', descriptions.invalidateCache)
468
- .option('--paths [paths]', descriptions.paths, { default: false })
469
- .option('-p, --project [project]', descriptions.project, { default: false })
470
- .option('--verbose', descriptions.verbose, { default: false })
471
- .action(async (options: CloudCliOptions) => {
472
- log.debug('Running `buddy cloud:invalidate-cache` ...', options)
473
-
474
- const startTime = await intro('buddy cloud:invalidate-cache')
475
-
476
- const { confirm } = await prompts({
477
- name: 'confirm',
478
- type: 'confirm',
479
- message: 'Would you like to invalidate the CloudFront cache?',
480
- })
481
-
482
- if (!confirm) {
483
- await outro('Exited', { startTime, useSeconds: true })
484
- process.exit(ExitCode.Success)
485
- }
486
-
487
- log.info('Invalidating the CloudFront cache...')
488
- // const result = await runCommand('aws cloudfront create-invalidation --distribution-id E1U4Z2E9NJW9J --paths "/*"', {
489
- // ...options,
490
- // cwd: p.projectPath(),
491
- // stdin: 'pipe',
492
- // })
493
-
494
- if (options.paths) {
495
- const result = await runCommand(
496
- `aws cloudfront create-invalidation --distribution-id E1U4Z2E9NJW9J --paths ${options.paths}`,
497
- {
498
- ...options,
499
- cwd: p.projectPath(), // TODO: this should be the cloud path
500
- stdin: 'pipe',
501
- },
502
- ) // TODO: this should be the cloud path
503
-
504
- if (result.isErr()) {
505
- await outro(
506
- 'While running the cloud command, there was an issue',
507
- { startTime, useSeconds: true },
508
- result.error,
509
- )
510
- process.exit(ExitCode.FatalError)
511
- }
512
-
513
- await outro('Exited', { startTime, useSeconds: true })
514
- process.exit(ExitCode.Success)
515
- }
516
-
517
- log.info('Not implemented yet. Read more about `buddy cloud` here: https://stacksjs.org/docs/cloud')
518
- process.exit(ExitCode.Success)
519
- })
520
-
521
- buddy
522
- .command('cloud:diff', descriptions.diff)
523
- .option('-p, --project [project]', descriptions.project, { default: false })
524
- .option('--verbose', descriptions.verbose, { default: false })
525
- .action(async (options: CloudCliOptions) => {
526
- log.debug('Running `buddy cloud:diff` ...', options)
527
-
528
- const startTime = await intro('buddy cloud:diff')
529
-
530
- const result = await runCommand('bunx --bun cdk diff', {
531
- cwd: p.frameworkCloudPath(),
532
- stdin: 'pipe',
533
- })
534
-
535
- if (result.isErr()) {
536
- await outro(
537
- 'While running the cloud diff command, there was an issue',
538
- { startTime, useSeconds: true },
539
- result.error,
540
- )
541
- process.exit(ExitCode.FatalError)
542
- }
543
-
544
- await outro('Showing diff of the current, undeployed cloud changes', { startTime, useSeconds: true })
545
- console.log(result.value)
546
- process.exit(ExitCode.Success)
547
- })
548
-
549
- buddy.on('cloud:*', () => {
550
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
551
- process.exit(1)
552
- })
553
- }
@@ -1,26 +0,0 @@
1
- import type { CLI, FreshOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runCommit } from '@stacksjs/actions'
4
- import { log } from '@stacksjs/logging'
5
-
6
- export function commit(buddy: CLI): void {
7
- const descriptions = {
8
- commit: 'Commit your stashed changes',
9
- project: 'Target a specific project',
10
- verbose: 'Enable verbose output',
11
- }
12
-
13
- buddy
14
- .command('commit', descriptions.commit)
15
- .option('-p, --project [project]', descriptions.project, { default: false })
16
- .option('--verbose', descriptions.verbose, { default: false })
17
- .action(async (options: FreshOptions) => {
18
- log.debug('Running `buddy commit` ...', options)
19
- await runCommit(options)
20
- })
21
-
22
- buddy.on('commit:*', () => {
23
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
24
- process.exit(1)
25
- })
26
- }
@@ -1,84 +0,0 @@
1
- import type { CLI, ConfigureOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { log, outro, runCommand } from '@stacksjs/cli'
4
- import { path as p } from '@stacksjs/path'
5
- import { ExitCode } from '@stacksjs/types'
6
-
7
- export function configure(buddy: CLI): void {
8
- const descriptions = {
9
- configure: 'Configure options',
10
- aws: 'Configure the AWS connection',
11
- project: 'Target a specific project',
12
- profile: 'The AWS profile to use',
13
- verbose: 'Enable verbose output',
14
- }
15
-
16
- buddy
17
- .command('configure', descriptions.configure)
18
- .option('--aws', descriptions.aws, { default: false })
19
- .option('-p, --project [project]', descriptions.project, { default: false })
20
- .option('--verbose', descriptions.verbose, { default: false })
21
- .action(async (options?: ConfigureOptions) => {
22
- log.debug('Running `buddy configure` ...', options)
23
-
24
- if (options?.aws) {
25
- await configureAws(options)
26
- process.exit(ExitCode.Success)
27
- }
28
-
29
- log.info('Not implemented yet. Please use the --aws flag to configure AWS.')
30
- process.exit(ExitCode.Success)
31
- })
32
-
33
- buddy
34
- .command('configure:aws', descriptions.aws)
35
- .option('-p, --project [project]', descriptions.project, { default: false })
36
- .option('--profile', descriptions.profile, {
37
- default: process.env.AWS_PROFILE,
38
- })
39
- .option('--verbose', descriptions.verbose, { default: false })
40
- .option('--access-key-id', 'The AWS access key')
41
- .option('--secret-access-key', 'The AWS secret access key')
42
- .option('--region', 'The AWS region')
43
- .option('--output', 'The AWS output format')
44
- .option('--quiet', 'Suppress output')
45
- .action(async (options?: ConfigureOptions) => {
46
- log.debug('Running `buddy configure:aws` ...', options)
47
- await configureAws(options)
48
- process.exit(ExitCode.Success)
49
- })
50
-
51
- buddy.on('configure:*', () => {
52
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
53
- process.exit(ExitCode.FatalError)
54
- })
55
- }
56
-
57
- async function configureAws(options?: ConfigureOptions) {
58
- const startTime = performance.now()
59
-
60
- const awsAccessKeyId = options?.accessKeyId ?? process.env.AWS_ACCESS_KEY_ID
61
- const awsSecretAccessKey = options?.secretAccessKey ?? process.env.AWS_SECRET_ACCESS_KEY
62
- const defaultRegion = 'us-east-1' // we only support `us-east-1` for now
63
- const defaultOutputFormat = options?.output ?? 'json'
64
-
65
- const profile = process.env.AWS_PROFILE ?? options?.profile
66
- const command = profile ? `aws configure --profile ${profile}` : `aws configure`
67
- const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`
68
-
69
- const result = await runCommand(command, {
70
- cwd: p.projectPath(),
71
- stdin: 'pipe', // set stdin mode to 'pipe' to write to it
72
- input, // the actual input to write
73
- })
74
-
75
- if (result.isErr()) {
76
- await outro('While running the cloud command, there was an issue', { startTime, useSeconds: true }, result.error)
77
- process.exit(ExitCode.FatalError)
78
- }
79
-
80
- if (options?.quiet)
81
- return
82
-
83
- await outro('Exited', { startTime, useSeconds: true })
84
- }