@stacksjs/buddy 0.59.11 → 0.61.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.
- package/README.md +0 -1
- package/dist/chunk-b0df37cbea681adc.js +2223 -0
- package/dist/{chunk-d2428b387d843985.js → chunk-eb51d49adb5b5f07.js} +478 -247
- package/dist/cli.js +13 -4
- package/dist/index.js +1 -1
- package/dist/stacks +0 -0
- package/package.json +1 -1
- package/src/cli.ts +17 -13
- package/src/commands/add.ts +5 -6
- package/src/commands/build.ts +55 -34
- package/src/commands/changelog.ts +13 -6
- package/src/commands/clean.ts +13 -5
- package/src/commands/cloud.ts +91 -30
- package/src/commands/commit.ts +2 -2
- package/src/commands/configure.ts +7 -7
- package/src/commands/create.ts +14 -10
- package/src/commands/deploy.ts +15 -10
- package/src/commands/dev.ts +53 -53
- package/src/commands/dns.ts +5 -5
- package/src/commands/domains.ts +132 -41
- package/src/commands/fresh.ts +16 -6
- package/src/commands/generate.ts +14 -16
- package/src/commands/http.ts +2 -2
- package/src/commands/install.ts +2 -2
- package/src/commands/key.ts +3 -3
- package/src/commands/lint.ts +4 -4
- package/src/commands/list.ts +3 -4
- package/src/commands/make.ts +101 -65
- package/src/commands/migrate.ts +52 -9
- package/src/commands/ports.ts +35 -37
- package/src/commands/prepublish.ts +3 -3
- package/src/commands/projects.ts +5 -11
- package/src/commands/release.ts +8 -6
- package/src/commands/seed.ts +12 -5
- package/src/commands/setup.ts +10 -11
- package/src/commands/test.ts +97 -30
- package/src/commands/tinker.ts +10 -6
- package/src/commands/types.ts +3 -3
- package/src/commands/upgrade.ts +49 -29
- package/src/commands/version.ts +11 -13
- package/src/custom-cli.ts +5 -7
- package/dist/cli.d.ts +0 -1
- package/dist/commands/build.d.ts +0 -2
- package/dist/commands/changelog.d.ts +0 -2
- package/dist/commands/clean.d.ts +0 -2
- package/dist/commands/cloud.d.ts +0 -2
- package/dist/commands/commit.d.ts +0 -2
- package/dist/commands/configure.d.ts +0 -2
- package/dist/commands/create.d.ts +0 -2
- package/dist/commands/deploy.d.ts +0 -2
- package/dist/commands/dev.d.ts +0 -3
- package/dist/commands/dns.d.ts +0 -2
- package/dist/commands/domains.d.ts +0 -2
- package/dist/commands/fresh.d.ts +0 -2
- package/dist/commands/generate.d.ts +0 -2
- package/dist/commands/http.d.ts +0 -2
- package/dist/commands/index.d.ts +0 -31
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/key.d.ts +0 -2
- package/dist/commands/lint.d.ts +0 -2
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/make.d.ts +0 -2
- package/dist/commands/migrate.d.ts +0 -2
- package/dist/commands/ports.d.ts +0 -2
- package/dist/commands/prepublish.d.ts +0 -2
- package/dist/commands/projects.d.ts +0 -2
- package/dist/commands/release.d.ts +0 -2
- package/dist/commands/seed.d.ts +0 -2
- package/dist/commands/setup.d.ts +0 -4
- package/dist/commands/test.d.ts +0 -2
- package/dist/commands/tinker.d.ts +0 -2
- package/dist/commands/types.d.ts +0 -2
- package/dist/commands/upgrade.d.ts +0 -2
- package/dist/commands/version.d.ts +0 -2
- package/dist/index.d.ts +0 -1
package/src/commands/cloud.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import { intro, italic, log, outro, prompts, runCommand, runCommandSync, underline } from '@stacksjs/cli'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
addJumpBox,
|
|
5
|
+
deleteCdkRemnants,
|
|
6
|
+
deleteIamUsers,
|
|
7
|
+
deleteJumpBox,
|
|
8
|
+
deleteLogGroups,
|
|
9
|
+
deleteParameterStore,
|
|
10
|
+
deleteStacksBuckets,
|
|
11
|
+
deleteStacksFunctions,
|
|
12
|
+
getJumpBoxInstanceId,
|
|
13
|
+
} from '@stacksjs/cloud'
|
|
4
14
|
import { path as p } from '@stacksjs/path'
|
|
5
15
|
import type { CLI, CloudCliOptions } from '@stacksjs/types'
|
|
6
16
|
import { ExitCode } from '@stacksjs/types'
|
|
@@ -22,7 +32,7 @@ export function cloud(buddy: CLI) {
|
|
|
22
32
|
.command('cloud', descriptions.cloud)
|
|
23
33
|
.option('--ssh', descriptions.ssh, { default: false })
|
|
24
34
|
.option('--connect', descriptions.ssh, { default: false })
|
|
25
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
35
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
26
36
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
27
37
|
.action(async (options: CloudCliOptions) => {
|
|
28
38
|
log.debug('Running `buddy cloud` ...', options)
|
|
@@ -37,7 +47,11 @@ export function cloud(buddy: CLI) {
|
|
|
37
47
|
})
|
|
38
48
|
|
|
39
49
|
if (result.isErr()) {
|
|
40
|
-
await outro(
|
|
50
|
+
await outro(
|
|
51
|
+
'While running the cloud command, there was an issue',
|
|
52
|
+
{ startTime, useSeconds: true },
|
|
53
|
+
result.error,
|
|
54
|
+
)
|
|
41
55
|
process.exit(ExitCode.FatalError)
|
|
42
56
|
}
|
|
43
57
|
|
|
@@ -52,7 +66,7 @@ export function cloud(buddy: CLI) {
|
|
|
52
66
|
buddy
|
|
53
67
|
.command('cloud:add', descriptions.add)
|
|
54
68
|
.option('--jump-box', 'Remove the jump-box', { default: false })
|
|
55
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
69
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
56
70
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
57
71
|
.action(async (options: CloudCliOptions) => {
|
|
58
72
|
log.debug('Running `buddy cloud:add` ...', options)
|
|
@@ -74,21 +88,32 @@ export function cloud(buddy: CLI) {
|
|
|
74
88
|
log.info('The jump-box is getting added to your cloud resources...')
|
|
75
89
|
log.info('This takes a few moments, please be patient.')
|
|
76
90
|
// sleep for 2 seconds to get the user to read the message
|
|
77
|
-
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
91
|
+
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
78
92
|
|
|
79
93
|
const result = await addJumpBox()
|
|
80
94
|
|
|
81
95
|
if (result.isErr()) {
|
|
82
|
-
await outro(
|
|
96
|
+
await outro(
|
|
97
|
+
'While running the cloud:add command, there was an issue',
|
|
98
|
+
{ startTime, useSeconds: true },
|
|
99
|
+
result.error,
|
|
100
|
+
)
|
|
83
101
|
process.exit(ExitCode.FatalError)
|
|
84
102
|
}
|
|
85
103
|
|
|
86
104
|
log.info(italic('View the jump-box in the AWS console:'))
|
|
87
|
-
log.info(
|
|
105
|
+
log.info(
|
|
106
|
+
underline(
|
|
107
|
+
'https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#Instances:instanceState=running',
|
|
108
|
+
),
|
|
109
|
+
)
|
|
88
110
|
log.info(italic('Once it finished initializing, you may SSH into it:'))
|
|
89
|
-
log.info(underline(
|
|
111
|
+
log.info(underline('buddy cloud --ssh'))
|
|
90
112
|
|
|
91
|
-
await outro('Your jump-box was added.', {
|
|
113
|
+
await outro('Your jump-box was added.', {
|
|
114
|
+
startTime,
|
|
115
|
+
useSeconds: true,
|
|
116
|
+
})
|
|
92
117
|
process.exit(ExitCode.Success)
|
|
93
118
|
}
|
|
94
119
|
|
|
@@ -103,7 +128,7 @@ export function cloud(buddy: CLI) {
|
|
|
103
128
|
.alias('undeploy')
|
|
104
129
|
.option('--jump-box', 'Remove the jump-box', { default: false })
|
|
105
130
|
// .option('--realtime-cdn-logs', 'Remove the CDN Realtime Log Stream', { default: false }) // TODO: implement this
|
|
106
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
131
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
107
132
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
108
133
|
.action(async (options: CloudCliOptions) => {
|
|
109
134
|
log.debug('Running `buddy cloud:remove` ...', options)
|
|
@@ -129,19 +154,19 @@ export function cloud(buddy: CLI) {
|
|
|
129
154
|
process.exit(ExitCode.FatalError)
|
|
130
155
|
}
|
|
131
156
|
|
|
132
|
-
await outro('Your jump-box was removed.', {
|
|
157
|
+
await outro('Your jump-box was removed.', {
|
|
158
|
+
startTime,
|
|
159
|
+
useSeconds: true,
|
|
160
|
+
})
|
|
133
161
|
process.exit(ExitCode.Success)
|
|
134
162
|
}
|
|
135
163
|
|
|
136
|
-
// eslint-disable-next-line no-console
|
|
137
164
|
console.log(` ${italic('ℹ️ Removing your cloud resources takes a while to complete.')}`)
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
165
|
console.log(` ${italic('Please note, your backups will not yet be deleted. Though,')}`)
|
|
140
|
-
// eslint-disable-next-line no-console
|
|
141
166
|
console.log(` ${italic('Backups are scheduled to delete themselves in 30 days.')}`)
|
|
142
167
|
|
|
143
168
|
// sleep for 2 seconds to get the user to read the message
|
|
144
|
-
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
169
|
+
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
145
170
|
|
|
146
171
|
const result = await runCommand(`bunx cdk destroy`, {
|
|
147
172
|
...options,
|
|
@@ -150,7 +175,11 @@ export function cloud(buddy: CLI) {
|
|
|
150
175
|
})
|
|
151
176
|
|
|
152
177
|
if (result.isErr()) {
|
|
153
|
-
await outro(
|
|
178
|
+
await outro(
|
|
179
|
+
'While running the cloud:remove ("undeploy") command, there was an issue',
|
|
180
|
+
{ startTime, useSeconds: true },
|
|
181
|
+
result.error,
|
|
182
|
+
)
|
|
154
183
|
process.exit(ExitCode.FatalError)
|
|
155
184
|
}
|
|
156
185
|
|
|
@@ -175,10 +204,12 @@ export function cloud(buddy: CLI) {
|
|
|
175
204
|
})
|
|
176
205
|
})
|
|
177
206
|
|
|
178
|
-
await outro('Your cloud has been removed', {
|
|
207
|
+
await outro('Your cloud has been removed', {
|
|
208
|
+
startTime,
|
|
209
|
+
useSeconds: true,
|
|
210
|
+
})
|
|
179
211
|
process.exit(ExitCode.Success)
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
212
|
+
} catch (error) {
|
|
182
213
|
await outro('While cleaning up the cloud, there was an issue', { startTime, useSeconds: true }, error as Error)
|
|
183
214
|
process.exit(ExitCode.FatalError)
|
|
184
215
|
}
|
|
@@ -188,7 +219,7 @@ export function cloud(buddy: CLI) {
|
|
|
188
219
|
.command('cloud:optimize-cost', descriptions.optimizeCost)
|
|
189
220
|
.option('--jump-box', 'Remove the jump-box', { default: true }) // removes the ec2 instance
|
|
190
221
|
// .option('--realtime-cdn-logs', 'Remove the CDN Realtime Log Stream', { default: true }) // TODO: implement this - removes the Kinesis Data Stream
|
|
191
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
222
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
192
223
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
193
224
|
.action(async (options: CloudCliOptions) => {
|
|
194
225
|
log.debug('Running `buddy cloud:optimize-cost` ...', options)
|
|
@@ -215,14 +246,17 @@ export function cloud(buddy: CLI) {
|
|
|
215
246
|
process.exit(ExitCode.Success)
|
|
216
247
|
}
|
|
217
248
|
|
|
218
|
-
await outro('No cost optimization was applied', {
|
|
249
|
+
await outro('No cost optimization was applied', {
|
|
250
|
+
startTime,
|
|
251
|
+
useSeconds: true,
|
|
252
|
+
})
|
|
219
253
|
process.exit(ExitCode.Success)
|
|
220
254
|
})
|
|
221
255
|
|
|
222
256
|
buddy
|
|
223
257
|
.command('cloud:cleanup', descriptions.cleanUp)
|
|
224
258
|
.alias('cloud:clean-up')
|
|
225
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
259
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
226
260
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
227
261
|
.action(async (options: CloudCliOptions) => {
|
|
228
262
|
log.debug('Running `buddy cloud:cleanup` ...', options)
|
|
@@ -232,7 +266,7 @@ export function cloud(buddy: CLI) {
|
|
|
232
266
|
log.info(`Cleaning up your cloud resources will take a while to complete. Please be patient.`)
|
|
233
267
|
|
|
234
268
|
// sleep for 2 seconds to get the user to read the message
|
|
235
|
-
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
269
|
+
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
236
270
|
|
|
237
271
|
log.info('Removing any jump-boxes...')
|
|
238
272
|
const result = await deleteJumpBox()
|
|
@@ -248,7 +282,11 @@ export function cloud(buddy: CLI) {
|
|
|
248
282
|
const result2 = await deleteStacksBuckets()
|
|
249
283
|
|
|
250
284
|
if (result2.isErr()) {
|
|
251
|
-
await outro(
|
|
285
|
+
await outro(
|
|
286
|
+
'While deleting the retained S3 buckets, there was an issue',
|
|
287
|
+
{ startTime, useSeconds: true },
|
|
288
|
+
result2.error,
|
|
289
|
+
)
|
|
252
290
|
process.exit(ExitCode.FatalError)
|
|
253
291
|
}
|
|
254
292
|
|
|
@@ -257,7 +295,11 @@ export function cloud(buddy: CLI) {
|
|
|
257
295
|
|
|
258
296
|
if (result3.isErr()) {
|
|
259
297
|
if (result3.error !== 'No stacks functions found')
|
|
260
|
-
await outro(
|
|
298
|
+
await outro(
|
|
299
|
+
'While deleting the Origin Request Lambda function, there was an issue',
|
|
300
|
+
{ startTime, useSeconds: true },
|
|
301
|
+
result3.error,
|
|
302
|
+
)
|
|
261
303
|
|
|
262
304
|
process.exit(ExitCode.FatalError)
|
|
263
305
|
}
|
|
@@ -269,7 +311,11 @@ export function cloud(buddy: CLI) {
|
|
|
269
311
|
// TODO: investigate other regions for edge (cloudfront) logs
|
|
270
312
|
|
|
271
313
|
if (result4.isErr()) {
|
|
272
|
-
await outro(
|
|
314
|
+
await outro(
|
|
315
|
+
'While deleting the Stacks log groups, there was an issue',
|
|
316
|
+
{ startTime, useSeconds: true },
|
|
317
|
+
result4.error,
|
|
318
|
+
)
|
|
273
319
|
process.exit(ExitCode.FatalError)
|
|
274
320
|
}
|
|
275
321
|
|
|
@@ -285,7 +331,11 @@ export function cloud(buddy: CLI) {
|
|
|
285
331
|
const result7 = await deleteParameterStore()
|
|
286
332
|
|
|
287
333
|
if (result7.isErr()) {
|
|
288
|
-
await outro(
|
|
334
|
+
await outro(
|
|
335
|
+
'While deleting the Stacks log groups, there was an issue',
|
|
336
|
+
{ startTime, useSeconds: true },
|
|
337
|
+
result7.error,
|
|
338
|
+
)
|
|
289
339
|
process.exit(ExitCode.FatalError)
|
|
290
340
|
}
|
|
291
341
|
|
|
@@ -293,7 +343,11 @@ export function cloud(buddy: CLI) {
|
|
|
293
343
|
const result6 = await deleteCdkRemnants()
|
|
294
344
|
|
|
295
345
|
if (result6.isErr()) {
|
|
296
|
-
await outro(
|
|
346
|
+
await outro(
|
|
347
|
+
'While deleting the Stacks log groups, there was an issue',
|
|
348
|
+
{ startTime, useSeconds: true },
|
|
349
|
+
result6.error,
|
|
350
|
+
)
|
|
297
351
|
process.exit(ExitCode.FatalError)
|
|
298
352
|
}
|
|
299
353
|
|
|
@@ -301,14 +355,21 @@ export function cloud(buddy: CLI) {
|
|
|
301
355
|
const result8 = await deleteIamUsers()
|
|
302
356
|
|
|
303
357
|
if (result8.isErr()) {
|
|
304
|
-
await outro(
|
|
358
|
+
await outro(
|
|
359
|
+
'While deleting the Stacks log groups, there was an issue',
|
|
360
|
+
{ startTime, useSeconds: true },
|
|
361
|
+
result8.error,
|
|
362
|
+
)
|
|
305
363
|
process.exit(ExitCode.FatalError)
|
|
306
364
|
}
|
|
307
365
|
|
|
308
366
|
// TODO: needs to delete all Backup Vaults
|
|
309
367
|
// TODO: needs to delete all KMS keys
|
|
310
368
|
|
|
311
|
-
await outro('AWS resources have been removed', {
|
|
369
|
+
await outro('AWS resources have been removed', {
|
|
370
|
+
startTime,
|
|
371
|
+
useSeconds: true,
|
|
372
|
+
})
|
|
312
373
|
process.exit(ExitCode.Success)
|
|
313
374
|
})
|
|
314
375
|
|
package/src/commands/commit.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI, FreshOptions } from '@stacksjs/types'
|
|
3
2
|
import { runCommit } from '@stacksjs/actions'
|
|
4
3
|
import { log } from '@stacksjs/logging'
|
|
4
|
+
import type { CLI, FreshOptions } from '@stacksjs/types'
|
|
5
5
|
|
|
6
6
|
export function commit(buddy: CLI) {
|
|
7
7
|
const descriptions = {
|
|
@@ -12,7 +12,7 @@ export function commit(buddy: CLI) {
|
|
|
12
12
|
|
|
13
13
|
buddy
|
|
14
14
|
.command('commit', descriptions.commit)
|
|
15
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
15
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
16
16
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
17
17
|
.action(async (options: FreshOptions) => {
|
|
18
18
|
log.debug('Running `buddy commit` ...', options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI, ConfigureOptions } from '@stacksjs/types'
|
|
3
2
|
import { log, outro, runCommand } from '@stacksjs/cli'
|
|
4
3
|
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
7
|
export function configure(buddy: CLI) {
|
|
@@ -16,7 +16,7 @@ export function configure(buddy: CLI) {
|
|
|
16
16
|
buddy
|
|
17
17
|
.command('configure', descriptions.configure)
|
|
18
18
|
.option('--aws', descriptions.aws, { default: false })
|
|
19
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
19
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
20
20
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
21
21
|
.action(async (options?: ConfigureOptions) => {
|
|
22
22
|
log.debug('Running `buddy configure` ...', options)
|
|
@@ -32,8 +32,10 @@ export function configure(buddy: CLI) {
|
|
|
32
32
|
|
|
33
33
|
buddy
|
|
34
34
|
.command('configure:aws', descriptions.aws)
|
|
35
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
36
|
-
.option('--profile', descriptions.profile, {
|
|
35
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
36
|
+
.option('--profile', descriptions.profile, {
|
|
37
|
+
default: process.env.AWS_PROFILE,
|
|
38
|
+
})
|
|
37
39
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
38
40
|
.option('--access-key-id', 'The AWS access key')
|
|
39
41
|
.option('--secret-access-key', 'The AWS secret access key')
|
|
@@ -64,7 +66,6 @@ async function configureAws(options?: ConfigureOptions) {
|
|
|
64
66
|
const input = `${awsAccessKeyId}\n${awsSecretAccessKey}\n${defaultRegion}\n${defaultOutputFormat}\n`
|
|
65
67
|
|
|
66
68
|
const result = await runCommand(command, {
|
|
67
|
-
...options,
|
|
68
69
|
cwd: p.projectPath(),
|
|
69
70
|
stdin: 'pipe', // set stdin mode to 'pipe' to write to it
|
|
70
71
|
input, // the actual input to write
|
|
@@ -75,8 +76,7 @@ async function configureAws(options?: ConfigureOptions) {
|
|
|
75
76
|
process.exit(ExitCode.FatalError)
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
if (options?.quiet)
|
|
79
|
-
return
|
|
79
|
+
if (options?.quiet) return
|
|
80
80
|
|
|
81
81
|
await outro('Exited', { startTime, useSeconds: true })
|
|
82
82
|
}
|
package/src/commands/create.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { bold, cyan, dim, intro, log, runCommand } from '@stacksjs/cli'
|
|
4
|
+
import { Action } from '@stacksjs/enums'
|
|
5
|
+
import { resolve } from '@stacksjs/path'
|
|
6
|
+
import { isFolder } from '@stacksjs/storage'
|
|
2
7
|
import { ExitCode } from '@stacksjs/types'
|
|
3
8
|
import type { CLI, CreateOptions } from '@stacksjs/types'
|
|
4
|
-
import { bold, cyan, dim, intro, log, runCommand } from '@stacksjs/cli'
|
|
5
9
|
import { useOnline } from '@stacksjs/utils'
|
|
6
|
-
import { isFolder } from '@stacksjs/storage'
|
|
7
|
-
import { resolve } from '@stacksjs/path'
|
|
8
|
-
import { Action } from '@stacksjs/enums'
|
|
9
|
-
import { runAction } from '@stacksjs/actions'
|
|
10
10
|
|
|
11
11
|
export function create(buddy: CLI) {
|
|
12
12
|
const descriptions = {
|
|
13
|
+
name: 'The name of the project',
|
|
13
14
|
command: 'Create a new Stacks project',
|
|
14
15
|
ui: 'Are you building a UI?',
|
|
15
16
|
components: 'Are you building UI components?',
|
|
@@ -27,8 +28,9 @@ export function create(buddy: CLI) {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
buddy
|
|
30
|
-
.command('new
|
|
31
|
-
.alias('create
|
|
31
|
+
.command('new [name]', descriptions.command)
|
|
32
|
+
.alias('create [name]')
|
|
33
|
+
.option('-n, --name [name]', descriptions.name, { default: false })
|
|
32
34
|
.option('-u, --ui', descriptions.ui, { default: true }) // if no, disregard remainder of questions wrt UI
|
|
33
35
|
.option('-c, --components', descriptions.components, { default: true }) // if no, -v and -w would be false
|
|
34
36
|
.option('-w, --web-components', descriptions.webComponents, { default: true })
|
|
@@ -39,18 +41,20 @@ export function create(buddy: CLI) {
|
|
|
39
41
|
.option('-d, --database', descriptions.database, { default: true })
|
|
40
42
|
.option('-ca, --cache', descriptions.cache, { default: false })
|
|
41
43
|
.option('-e, --email', descriptions.email, { default: false })
|
|
42
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
44
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
43
45
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
44
46
|
// .option('--auth', 'Scaffold an authentication?', { default: true })
|
|
45
|
-
.action(async (options: CreateOptions) => {
|
|
47
|
+
.action(async (name, options: CreateOptions) => {
|
|
46
48
|
log.debug('Running `buddy new <name>` ...', options)
|
|
47
49
|
|
|
48
50
|
const startTime = await intro('stacks new')
|
|
49
|
-
|
|
51
|
+
|
|
52
|
+
name = name ?? options.name
|
|
50
53
|
const path = resolve(process.cwd(), name)
|
|
51
54
|
|
|
52
55
|
isFolderCheck(path)
|
|
53
56
|
onlineCheck()
|
|
57
|
+
|
|
54
58
|
const result = await download(name, path, options)
|
|
55
59
|
|
|
56
60
|
if (result.isErr()) {
|
package/src/commands/deploy.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import process from 'node:process'
|
|
3
|
-
import { ExitCode } from '@stacksjs/types'
|
|
4
|
-
import type { CLI, DeployOptions } from '@stacksjs/types'
|
|
5
2
|
import { runAction } from '@stacksjs/actions'
|
|
6
3
|
import { intro, italic, log, outro, runCommand } from '@stacksjs/cli'
|
|
7
|
-
import { Action } from '@stacksjs/enums'
|
|
8
4
|
import { app } from '@stacksjs/config'
|
|
9
5
|
import { addDomain, hasUserDomainBeenAddedToCloud } from '@stacksjs/dns'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
import { ExitCode } from '@stacksjs/types'
|
|
8
|
+
import type { CLI, DeployOptions } from '@stacksjs/types'
|
|
10
9
|
|
|
11
10
|
export function deploy(buddy: CLI) {
|
|
12
11
|
const descriptions = {
|
|
@@ -18,7 +17,7 @@ export function deploy(buddy: CLI) {
|
|
|
18
17
|
buddy
|
|
19
18
|
.command('deploy', descriptions.deploy)
|
|
20
19
|
.option('--domain', 'Specify a domain to deploy to', { default: undefined })
|
|
21
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
20
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
22
21
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
23
22
|
.action(async (options: DeployOptions) => {
|
|
24
23
|
log.debug('Running `buddy deploy` ...', options)
|
|
@@ -33,6 +32,8 @@ export function deploy(buddy: CLI) {
|
|
|
33
32
|
process.exit(ExitCode.FatalError)
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
log.info(`Deploying to ${italic(domain)}`)
|
|
36
|
+
|
|
36
37
|
await checkIfAwsIsConfigured()
|
|
37
38
|
|
|
38
39
|
options.domain = await configureDomain(domain, options, startTime)
|
|
@@ -40,7 +41,11 @@ export function deploy(buddy: CLI) {
|
|
|
40
41
|
const result = await runAction(Action.Deploy, options)
|
|
41
42
|
|
|
42
43
|
if (result.isErr()) {
|
|
43
|
-
await outro(
|
|
44
|
+
await outro(
|
|
45
|
+
'While running the `buddy deploy`, there was an issue',
|
|
46
|
+
{ startTime, useSeconds: true },
|
|
47
|
+
result.error,
|
|
48
|
+
)
|
|
44
49
|
process.exit(ExitCode.FatalError)
|
|
45
50
|
}
|
|
46
51
|
|
|
@@ -56,8 +61,7 @@ export function deploy(buddy: CLI) {
|
|
|
56
61
|
async function configureDomain(domain: string, options: DeployOptions, startTime: number) {
|
|
57
62
|
if (!domain) {
|
|
58
63
|
log.info('We could not identify a domain to deploy to.')
|
|
59
|
-
log.
|
|
60
|
-
console.log('')
|
|
64
|
+
log.warn('Please set your .env or ./config/app.ts properly.')
|
|
61
65
|
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
62
66
|
console.log('')
|
|
63
67
|
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|
|
@@ -69,8 +73,9 @@ async function configureDomain(domain: string, options: DeployOptions, startTime
|
|
|
69
73
|
// TODO: add check for whether the local APP_ENV is getting deployed, if so, ask if the user meant to deploy `dev`
|
|
70
74
|
if (domain.includes('localhost')) {
|
|
71
75
|
log.info('You are deploying to a local environment.')
|
|
72
|
-
log.
|
|
73
|
-
|
|
76
|
+
log.warn(
|
|
77
|
+
'Please set your .env or ./config/app.ts properly. The domain we are deploying cannot be a `localhost` domain.',
|
|
78
|
+
)
|
|
74
79
|
log.info('Alternatively, specify a domain to deploy via the `--domain` flag.')
|
|
75
80
|
console.log('')
|
|
76
81
|
log.info(' ➡️ Example: `buddy deploy --domain example.com`')
|