stacks 0.66.0 → 0.68.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 (45) hide show
  1. package/package.json +54 -49
  2. package/buddy/README.md +0 -396
  3. package/buddy/art/social.jpg +0 -0
  4. package/buddy/bin/cli.ts +0 -85
  5. package/buddy/build.ts +0 -43
  6. package/buddy/package.json +0 -129
  7. package/buddy/src/cli.ts +0 -105
  8. package/buddy/src/commands/add.ts +0 -71
  9. package/buddy/src/commands/build.ts +0 -299
  10. package/buddy/src/commands/changelog.ts +0 -52
  11. package/buddy/src/commands/clean.ts +0 -46
  12. package/buddy/src/commands/cloud.ts +0 -553
  13. package/buddy/src/commands/commit.ts +0 -26
  14. package/buddy/src/commands/configure.ts +0 -84
  15. package/buddy/src/commands/create.ts +0 -143
  16. package/buddy/src/commands/deploy.ts +0 -194
  17. package/buddy/src/commands/dev.ts +0 -292
  18. package/buddy/src/commands/dns.ts +0 -86
  19. package/buddy/src/commands/domains.ts +0 -255
  20. package/buddy/src/commands/fresh.ts +0 -48
  21. package/buddy/src/commands/generate.ts +0 -202
  22. package/buddy/src/commands/http.ts +0 -57
  23. package/buddy/src/commands/index.ts +0 -33
  24. package/buddy/src/commands/install.ts +0 -30
  25. package/buddy/src/commands/key.ts +0 -36
  26. package/buddy/src/commands/lint.ts +0 -54
  27. package/buddy/src/commands/list.ts +0 -42
  28. package/buddy/src/commands/make.ts +0 -352
  29. package/buddy/src/commands/migrate.ts +0 -105
  30. package/buddy/src/commands/outdated.ts +0 -31
  31. package/buddy/src/commands/ports.ts +0 -188
  32. package/buddy/src/commands/prepublish.ts +0 -28
  33. package/buddy/src/commands/projects.ts +0 -54
  34. package/buddy/src/commands/release.ts +0 -47
  35. package/buddy/src/commands/route.ts +0 -39
  36. package/buddy/src/commands/seed.ts +0 -47
  37. package/buddy/src/commands/setup.ts +0 -145
  38. package/buddy/src/commands/test.ts +0 -214
  39. package/buddy/src/commands/tinker.ts +0 -42
  40. package/buddy/src/commands/types.ts +0 -35
  41. package/buddy/src/commands/upgrade.ts +0 -200
  42. package/buddy/src/commands/version.ts +0 -29
  43. package/buddy/src/custom-cli.ts +0 -35
  44. package/buddy/src/index.ts +0 -1
  45. package/buddy/tsconfig.json +0 -3
@@ -1,352 +0,0 @@
1
- import type { CLI, MakeOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import {
4
- createModel,
5
- createNotification,
6
- invoke,
7
- makeAction,
8
- makeComponent,
9
- makeDatabase,
10
- makeFunction,
11
- makeLanguage,
12
- makePage,
13
- makeStack,
14
- } from '@stacksjs/actions'
15
- import { intro, italic, outro, runCommand } from '@stacksjs/cli'
16
- import { localUrl } from '@stacksjs/config'
17
- import { log } from '@stacksjs/logging'
18
- import { path as p } from '@stacksjs/path'
19
- import { ExitCode } from '@stacksjs/types'
20
-
21
- export function make(buddy: CLI): void {
22
- const descriptions = {
23
- action: 'Create a new action',
24
- model: 'Create a new model',
25
- component: 'Create a new component',
26
- page: 'Create a new page',
27
- function: 'Create a new function',
28
- language: 'Create a new language',
29
- database: 'Create a new database',
30
- migration: 'Create a new migration',
31
- factory: 'Create a new factory',
32
- notification: 'Create a new notification',
33
- name: 'The name of the action',
34
- stack: 'Create a new stack',
35
- certificate: 'Create a new SSL Certificate',
36
- select: 'What are you trying to make?',
37
- project: 'Target a specific project',
38
- verbose: 'Enable verbose output',
39
- }
40
-
41
- buddy
42
- .command('make', 'The make command')
43
- .option('-a, --action [action]', descriptions.action, { default: false })
44
- .option('-m, --model [model]', descriptions.model, { default: false })
45
- .option('-c, --component [component]', descriptions.component, { default: false })
46
- .option('-p, --page [page]', descriptions.page, { default: false })
47
- .option('-f, --function [function]', descriptions.function, { default: false })
48
- .option('-l, --language [language]', descriptions.language, { default: false })
49
- .option('-d, --database [database]', descriptions.database, { default: false })
50
- .option('-m, --migration [migration]', descriptions.migration, { default: false })
51
- .option('-f, --factory [factory]', descriptions.factory, { default: false })
52
- .option('-n, --notification [notification]', descriptions.notification, { default: false })
53
- .option('-s, --stack [stack]', descriptions.stack, { default: false })
54
- .option('--verbose', descriptions.verbose, { default: false })
55
- .action(async (options: MakeOptions) => {
56
- log.debug('Running `buddy make` ...', options)
57
-
58
- const name = buddy.args[0]
59
-
60
- if (!name) {
61
- log.error('You need to specify a name. Read more about the documentation here.')
62
- process.exit()
63
- }
64
-
65
- // TODO: uncomment this when prompt is ready
66
- // if (hasNoOptions(options)) {
67
- // let answers = await prompt.require()
68
- // .multiselect(descriptions.select, {
69
- // options: [
70
- // { label: 'Page', value: 'page' },
71
- // { label: 'Function', value: 'function' },
72
- // { label: 'Component', value: 'component' },
73
- // { label: 'Notification', value: 'notification' },
74
- // { label: 'Language', value: 'language' },
75
- // { label: 'Database', value: 'database' },
76
- // { label: 'Migration', value: 'migration' },
77
- // { label: 'Factory', value: 'factory' },
78
- // { label: 'Stack', value: 'stack' },
79
- // ],
80
- // })
81
- //
82
- // if (answers !== null)
83
- // process.exit(ExitCode.InvalidArgument)
84
- //
85
- // if (isString(answers))
86
- // answers = [answers]
87
- //
88
- // // creates an object out of array and sets answers to true
89
- // options = answers.reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
90
- // }
91
-
92
- await invoke(options)
93
-
94
- process.exit(ExitCode.Success)
95
- })
96
-
97
- buddy
98
- .command('make:component [name]', descriptions.component)
99
- .option('-n, --name [name]', descriptions.name, { default: false })
100
- .option('-p, --project [project]', descriptions.project, { default: false })
101
- .option('--verbose', descriptions.verbose, { default: false })
102
- .action(async (name: string, options: MakeOptions) => {
103
- log.debug('Running `buddy make:component` ...', options)
104
-
105
- name = name ?? options.name
106
- options.name = name
107
-
108
- if (!name) {
109
- log.error('You need to specify a name. Read more about the documentation here.')
110
- process.exit()
111
- }
112
-
113
- await makeComponent(options)
114
- })
115
-
116
- buddy
117
- .command('make:database [name]', descriptions.database)
118
- .option('-n, --name [name]', descriptions.name, { default: false })
119
- .option('-p, --project [project]', descriptions.project, { default: false })
120
- .option('--verbose', descriptions.verbose, { default: false })
121
- .action((name: string, options: MakeOptions) => {
122
- log.debug('Running `buddy make:database` ...', options)
123
-
124
- name = name ?? options.name
125
- options.name = name
126
-
127
- if (!name) {
128
- log.error('You need to specify a database name via the `--name` option, or as the command’s argument.')
129
- log.info('Example: `buddy make:database my-cool-database`')
130
- log.info('Or: `buddy make:database --name=my-cool-database`')
131
- log.info('Read more about the documentation here: https://stacksjs.org/docs/make/database')
132
- process.exit()
133
- }
134
-
135
- makeDatabase(options)
136
- })
137
-
138
- buddy
139
- .command('make:factory [name]', descriptions.factory)
140
- .option('-n, --name [name]', descriptions.name, { default: false })
141
- .option('-p, --project [project]', descriptions.project, { default: false })
142
- .option('--verbose', descriptions.verbose, { default: false })
143
- .action((name: string, options: MakeOptions) => {
144
- log.debug('Running `buddy make:factory` ...', options)
145
-
146
- name = name ?? options.name
147
- options.name = name
148
-
149
- if (!name) {
150
- log.error('You need to specify a name. Read more about the documentation here.')
151
- process.exit()
152
- }
153
-
154
- // makeFactory(options)
155
- })
156
-
157
- buddy
158
- .command('make:view [name]', descriptions.page)
159
- .alias('make:page [name]')
160
- .option('-n, --name [name]', descriptions.name, { default: false })
161
- .option('-p, --project [project]', descriptions.project, { default: false })
162
- .option('--verbose', descriptions.verbose, { default: false })
163
- .action(async (name: string, options: MakeOptions) => {
164
- log.debug('Running `buddy make:view` ...', options)
165
-
166
- name = name ?? options.name
167
- options.name = name
168
-
169
- if (!name) {
170
- log.error('You need to specify a name. Read more about the documentation here.')
171
- process.exit()
172
- }
173
-
174
- await makePage(options)
175
- })
176
-
177
- buddy
178
- .command('make:function [name]', descriptions.function)
179
- .option('-n, --name [name]', descriptions.name, { default: false })
180
- .option('-p, --project [project]', descriptions.project, { default: false })
181
- .option('--verbose', descriptions.verbose, { default: false })
182
- .action(async (options: MakeOptions) => {
183
- log.debug('Running `buddy make:function` ...', options)
184
-
185
- await makeFunction(options)
186
- })
187
-
188
- buddy
189
- .command('make:lang [name]', descriptions.language)
190
- .option('-n, --name [name]', descriptions.name, { default: false })
191
- .option('-p, --project [project]', descriptions.project, { default: false })
192
- .option('--verbose', descriptions.verbose, { default: false })
193
- .action(async (name: string, options: MakeOptions) => {
194
- log.debug('Running `buddy make:lang` ...', options)
195
-
196
- name = name ?? options.name
197
- options.name = name
198
-
199
- if (!name) {
200
- log.error('You need to specify a name. Read more about the documentation here.')
201
- process.exit()
202
- }
203
-
204
- await makeLanguage(options)
205
- })
206
-
207
- buddy
208
- .command('make:notification [name]', descriptions.notification)
209
- .option('-n, --name [name]', descriptions.name, { default: false })
210
- .option('-e, --email', 'Is it an email notification?', { default: true })
211
- .option('-c, --chat', 'Is it a chat notification?', { default: false })
212
- .option('-s, --sms', 'Is it a SMS notification?', { default: false })
213
- .option('-p, --project [project]', descriptions.project, { default: false })
214
- .option('--verbose', descriptions.verbose, { default: false })
215
- .action(async (name: string, options: MakeOptions) => {
216
- log.debug('Running `buddy make:notification` ...', options)
217
-
218
- const perf = await intro('buddy make:notification')
219
-
220
- name = name ?? options.name
221
- options.name = name
222
-
223
- if (!name) {
224
- log.error('You need to specify a name. Read more about the documentation here.')
225
- process.exit()
226
- }
227
-
228
- const result = await createNotification(options)
229
-
230
- if (!result) {
231
- await outro('While running the make:notification command, there was an issue', {
232
- startTime: perf,
233
- useSeconds: true,
234
- })
235
- process.exit()
236
- }
237
-
238
- await outro(`Created your ${italic(name)} notification.`, {
239
- startTime: perf,
240
- useSeconds: true,
241
- })
242
- process.exit(ExitCode.Success)
243
- })
244
-
245
- buddy
246
- .command('make:stack [name]', descriptions.stack)
247
- .option('-n, --name [name]', descriptions.name, { default: false })
248
- .option('-p, --project [project]', descriptions.project, { default: false })
249
- .option('--verbose', descriptions.verbose, { default: false })
250
- .action((name: string, options: MakeOptions) => {
251
- log.debug('Running `buddy make:stack` ...', options)
252
-
253
- name = name ?? options.name
254
- options.name = name
255
-
256
- if (!name) {
257
- log.error('You need to specify a name. Read more about the documentation here.')
258
- process.exit()
259
- }
260
-
261
- makeStack(options)
262
- })
263
-
264
- buddy
265
- .command('make:action [name]', descriptions.action)
266
- .option('-n, --name [name]', descriptions.name, { default: false })
267
- .option('-p, --project [project]', descriptions.project, { default: false })
268
- .option('--verbose', descriptions.verbose, { default: false })
269
- .action(async (name: string, options: MakeOptions) => {
270
- log.info('Running `buddy make:action` ...')
271
- log.debug('Running `buddy make:action` ...', name, options)
272
-
273
- name = name ?? options.name
274
- options.name = name
275
-
276
- if (!name) {
277
- log.error('You need to specify a name. Read more about the documentation here.')
278
- process.exit()
279
- }
280
-
281
- await makeAction(options)
282
- })
283
-
284
- buddy
285
- .command('make:model [name]', descriptions.model)
286
- .option('-n, --name [name]', descriptions.name, { default: false })
287
- .option('-p, --project [project]', descriptions.project, { default: false })
288
- .option('--verbose', descriptions.verbose, { default: false })
289
- .action(async (name: string, options: MakeOptions) => {
290
- log.debug('Running `buddy make:model` ...', options)
291
-
292
- name = name ?? options.name
293
- options.name = name
294
-
295
- if (!name) {
296
- log.error('You need to specify a model name')
297
- process.exit()
298
- }
299
-
300
- await createModel(options)
301
- })
302
-
303
- buddy
304
- .command('make:migration [name]', descriptions.migration)
305
- .option('-n, --name [name]', descriptions.name, { default: false })
306
- .option('-p, --project [project]', descriptions.project, { default: false })
307
- .option('--verbose', descriptions.verbose, { default: false })
308
- .action((name: string, options: MakeOptions) => {
309
- log.debug('Running `buddy make:migration` ...', options)
310
-
311
- name = name ?? options.name
312
- options.name = name
313
-
314
- if (!name) {
315
- log.error('You need to specify a migration name')
316
- process.exit()
317
- }
318
-
319
- // log.info(path)
320
- })
321
-
322
- buddy
323
- .command('make:certificate', descriptions.certificate)
324
- .alias('make:cert')
325
- .example('buddy make:certificate')
326
- .action(async (options: MakeOptions) => {
327
- log.debug('Running `buddy make:certificate` ...', options)
328
-
329
- const domain = await localUrl()
330
-
331
- log.info(`Creating SSL certificate...`)
332
- await runCommand(`tlsx ${domain}`, {
333
- cwd: p.storagePath('keys'),
334
- })
335
- log.success('Certificate created')
336
-
337
- log.info(`Installing SSL certificate...`)
338
- await runCommand(`tlsx -install`, {
339
- cwd: p.storagePath('keys'),
340
- })
341
- log.success('Certificate installed')
342
- })
343
-
344
- buddy.on('make:*', () => {
345
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
346
- process.exit(1)
347
- })
348
- }
349
-
350
- // function hasNoOptions(options: MakeOptions) {
351
- // return !options.component && !options.page && !options.function && !options.language && !options.database && !options.migration && !options.notification && !options.stack
352
- // }
@@ -1,105 +0,0 @@
1
- import type { CLI, MigrateOptions } from '@stacksjs/types'
2
- import process from 'node:process'
3
- import { runAction } from '@stacksjs/actions'
4
- import { intro, log, outro } from '@stacksjs/cli'
5
- import { Action } from '@stacksjs/enums'
6
- import { ExitCode } from '@stacksjs/types'
7
-
8
- export function migrate(buddy: CLI): void {
9
- const descriptions = {
10
- migrate: 'Migrates your database',
11
- dns: 'Writes the DNS records for a domain to ./config/dns.ts',
12
- project: 'Target a specific project',
13
- verbose: 'Enable verbose output',
14
- }
15
-
16
- buddy
17
- .command('migrate', descriptions.migrate)
18
- .option('-d, --diff', 'Show the SQL that would be run', { default: false })
19
- .option('-p, --project [project]', descriptions.project, { default: false })
20
- .option('--verbose', descriptions.verbose, { default: false })
21
- .action(async (options: MigrateOptions) => {
22
- log.debug('Running `buddy migrate` ...', options)
23
-
24
- const perf = await intro('buddy migrate')
25
- const result = await runAction(Action.Migrate, options)
26
-
27
- if (result.isErr()) {
28
- await outro(
29
- 'While running the migrate command, there was an issue',
30
- { startTime: perf, useSeconds: true },
31
- result.error,
32
- )
33
- process.exit()
34
- }
35
-
36
- const APP_ENV = process.env.APP_ENV || 'local'
37
-
38
- await outro(`Migrated your ${APP_ENV} database.`, {
39
- startTime: perf,
40
- useSeconds: true,
41
- })
42
- process.exit(ExitCode.Success)
43
- })
44
-
45
- buddy
46
- .command('migrate:fresh', descriptions.migrate)
47
- .option('-d, --diff', 'Show the SQL that would be run', { default: false })
48
- .option('-p, --project [project]', descriptions.project, { default: false })
49
- .option('--verbose', descriptions.verbose, { default: false })
50
- .action(async (options: MigrateOptions) => {
51
- log.debug('Running `buddy migrate:fresh` ...', options)
52
-
53
- const perf = await intro('buddy migrate:fresh')
54
- const result = await runAction(Action.MigrateFresh, options)
55
-
56
- if (result.isErr()) {
57
- await outro(
58
- 'While running the migrate:fresh command, there was an issue',
59
- { startTime: perf, useSeconds: true },
60
- result.error,
61
- )
62
- process.exit()
63
- }
64
-
65
- await outro(`All tables dropped successfully & migrated successfully`, {
66
- startTime: perf,
67
- useSeconds: true,
68
- })
69
-
70
- process.exit(ExitCode.Success)
71
- })
72
-
73
- buddy
74
- .command('migrate:dns', descriptions.migrate)
75
- .option('-p, --project [project]', descriptions.project, { default: false })
76
- .option('--verbose', descriptions.verbose, { default: false })
77
- .action(async (options: MigrateOptions) => {
78
- log.debug('Running `buddy migrate:dns` ...', options)
79
-
80
- const perf = await intro('buddy migrate:dns')
81
- const result = await runAction(Action.MigrateDns, { ...options })
82
-
83
- if (result.isErr()) {
84
- await outro(
85
- 'While running the migrate:dns command, there was an issue',
86
- { startTime: perf, useSeconds: true },
87
- result.error,
88
- )
89
- process.exit()
90
- }
91
-
92
- const APP_URL = process.env.APP_URL || 'undefined'
93
-
94
- await outro(`Migrated your ${APP_URL} DNS.`, {
95
- startTime: perf,
96
- useSeconds: true,
97
- })
98
- process.exit(ExitCode.Success)
99
- })
100
-
101
- buddy.on('migrate:*', () => {
102
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
103
- process.exit(1)
104
- })
105
- }
@@ -1,31 +0,0 @@
1
- import type { CLI } from '@stacksjs/types'
2
- import { $ } from 'bun'
3
- import process from 'node:process'
4
- import { log } from '@stacksjs/logging'
5
- import { projectPath } from '@stacksjs/path'
6
-
7
- export function outdated(buddy: CLI): void {
8
- const descriptions = {
9
- outdated: 'List all the outdated project dependencies',
10
- project: 'Target a specific project',
11
- verbose: 'Enable verbose output',
12
- }
13
-
14
- buddy
15
- .command('outdated', descriptions.outdated)
16
- .option('-p, --project [project]', descriptions.project, { default: false })
17
- .option('--verbose', descriptions.verbose, { default: false })
18
- .action(async () => {
19
- log.debug('Running `buddy outdated` ...')
20
-
21
- $.cwd(projectPath())
22
-
23
- const response = await $`bun outdated`.text()
24
- console.log(response)
25
- })
26
-
27
- buddy.on('outdated:*', () => {
28
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
29
- process.exit(1)
30
- })
31
- }
@@ -1,188 +0,0 @@
1
- import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
2
- import { $ } from 'bun'
3
- import process from 'node:process'
4
- import { intro, italic, outro } from '@stacksjs/cli'
5
- import { ports as projectPorts } from '@stacksjs/config'
6
- import { log } from '@stacksjs/logging'
7
- import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
8
- import { ExitCode } from '@stacksjs/types'
9
- import { findStacksProjects } from '@stacksjs/utils'
10
-
11
- export function ports(buddy: CLI): void {
12
- const descriptions = {
13
- command: 'Let buddy check your project for potential issues and misconfigurations',
14
- ports: 'Check if the ports are available',
15
- project: 'Target a specific project',
16
- verbose: 'Enable verbose output',
17
- }
18
-
19
- buddy
20
- .command('ports', descriptions.command)
21
- .option('-l, --list', 'List the used ports', { default: true })
22
- .option('-c, --check', 'Check if the ports are available', {
23
- default: false,
24
- })
25
- .option('-p, --project [name]', descriptions.project, {
26
- default: undefined,
27
- })
28
- .option('-q, --quiet', 'Use minimal output', { default: false })
29
- .option('--verbose', descriptions.verbose, { default: false })
30
- .action(async (options: PortsOptions) => {
31
- log.debug('Running `buddy ports` ...', options)
32
-
33
- let perf
34
- if (!options.quiet)
35
- perf = await intro('buddy ports')
36
-
37
- if (options.project) {
38
- const path = await findProjectPath(options.project)
39
- log.debug(`Path: ${path}`)
40
-
41
- const ports = await getPortsForProjectPath(path, options)
42
- log.debug(`./buddy ports --quiet response for ${projectPath}`, ports)
43
-
44
- outputPorts(ports, options)
45
- }
46
-
47
- // use the user config ports
48
- else {
49
- outputPorts(projectPorts, options)
50
- }
51
-
52
- if (!options.quiet)
53
- await outro('Exited', { startTime: perf, useSeconds: false })
54
-
55
- process.exit(ExitCode.Success)
56
- })
57
-
58
- buddy
59
- .command('ports:list', descriptions.ports)
60
- .option('-p, --project [name]', descriptions.project, {
61
- default: undefined,
62
- })
63
- .option('-q, --quiet', 'Use minimal output', { default: false })
64
- .option('--verbose', descriptions.verbose, { default: false })
65
- .action(async (options: PortsOptions) => {
66
- log.debug('Running `buddy ports:list` ...', options)
67
-
68
- let perf
69
- if (!options.quiet)
70
- perf = await intro('buddy ports:list')
71
-
72
- // return the ports for the project
73
- if (options.project) {
74
- if (!options.quiet)
75
- log.info(`Listing ports for project: ${italic(options.project)}`)
76
-
77
- const path = await findProjectPath(options.project)
78
-
79
- log.debug(`Path: ${path}`)
80
-
81
- const ports = await getPortsForProjectPath(path, options)
82
-
83
- outputPorts(ports, options)
84
- }
85
- // return the used ports for all projects
86
- else {
87
- outputPorts(projectPorts, options)
88
- }
89
-
90
- if (!options.quiet)
91
- await outro('Exited', { startTime: perf, useSeconds: false })
92
-
93
- process.exit(ExitCode.Success)
94
- })
95
-
96
- buddy
97
- .command('ports:check', descriptions.ports)
98
- .option('-p, --project [name]', descriptions.project, {
99
- default: projectPath(),
100
- })
101
- .option('-q, --quiet', 'Use minimal output', { default: false })
102
- .option('--verbose', descriptions.verbose, { default: false })
103
- .action(async (options: PortsOptions) => {
104
- log.debug('Running `buddy ports:check` ...', options)
105
-
106
- let perf
107
- if (!options.quiet)
108
- perf = await intro('buddy ports:check')
109
-
110
- const projects = await findStacksProjects(undefined, { quiet: true })
111
-
112
- log.debug('Running `buddy ports`')
113
- log.debug(`Found ${projects.length} projects`)
114
- log.debug('Projects:', projects)
115
-
116
- // need to loop over the projects and then trigger `buddy ports` for each project (which returns a list of ports)
117
- const projectsPorts: { [project: string]: Ports } = {}
118
- for (const project of projects) projectsPorts[project] = await getPortsForProjectPath(project, options)
119
-
120
- log.info('ProjectsPorts:', projectsPorts)
121
-
122
- if (!options.quiet)
123
- await outro('Exited', { startTime: perf, useSeconds: false })
124
-
125
- process.exit(ExitCode.Success)
126
- })
127
-
128
- buddy.on('ports:*', () => {
129
- console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
130
- process.exit(1)
131
- })
132
- }
133
-
134
- async function getPortsForProjectPath(path: string, options: PortsOptions) {
135
- if (!options.quiet)
136
- log.info(`Checking ports for project: ${italic(path)}`)
137
-
138
- $.cwd(path)
139
- // load the .env file for the project
140
- $.env(await import(`${path}/.env`))
141
-
142
- const projectList = await $`./buddy projects:list --quiet`.text()
143
- log.debug('ProjectListResponse', projectList)
144
-
145
- // get the list of all Stacks project paths (on the system)
146
- const projects = projectList
147
- .split('\n')
148
- .filter(line => line.startsWith(' - '))
149
- .map(line => line.trim().substring(4))
150
- log.debug('Projects:', projects)
151
-
152
- // since we are targeting a specific project, find its path
153
- const ppath = options.project ?? p.projectPath()
154
- let projectPath = projects.find(project => project.includes(ppath))
155
-
156
- log.debug(`Checking ports for project: ${projectPath}`)
157
- if (projectPath === '' || !projectPath)
158
- // default to the current project
159
- projectPath = p.projectPath()
160
-
161
- log.debug(`$ Running: ./buddy ports:list --quiet via ${projectPath}`)
162
- const response = await $`./buddy ports:list --quiet`.json()
163
-
164
- log.debug(`Response for ./buddy ports:list --quiet via ${projectPath}`, response)
165
-
166
- // Step 1: Add double quotes around keys
167
- let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"')
168
-
169
- // Step 2: Remove potential trailing commas before closing braces
170
- validJsonString = validJsonString.replace(/,(\s*\})/g, '$1')
171
-
172
- // Now we can parse it into an object
173
- const ports = JSON.parse(validJsonString) as Ports
174
-
175
- log.debug(`Ports for ${projectPath}`, ports)
176
-
177
- return ports
178
- }
179
-
180
- function outputPorts(ports: Ports, options: PortsOptions) {
181
- if (!options.quiet)
182
- console.log('')
183
-
184
- console.log(ports)
185
-
186
- if (!options.quiet)
187
- console.log('')
188
- }