@stacksjs/buddy 0.58.57 → 0.58.59

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.
@@ -12,7 +12,7 @@ import {
12
12
  } from '@stacksjs/actions'
13
13
  import { ExitCode } from '@stacksjs/types'
14
14
  import type { CLI, DevOptions } from '@stacksjs/types'
15
- import { intro, log, outro, prompt, runCommand } from '@stacksjs/cli'
15
+ import { intro, log, outro, runCommand } from '@stacksjs/cli'
16
16
  import { libsPath } from '@stacksjs/path'
17
17
 
18
18
  export function dev(buddy: CLI) {
@@ -48,6 +48,8 @@ export function dev(buddy: CLI) {
48
48
  .option('-p, --project', descriptions.project, { default: false })
49
49
  .option('--verbose', descriptions.verbose, { default: false })
50
50
  .action(async (server: string | undefined, options: DevOptions) => {
51
+ log.debug('Running `buddy dev [server]` ...', options)
52
+
51
53
  const perf = await intro('buddy dev')
52
54
 
53
55
  // log.info('Ensuring web server/s running...') // in other words, ensure caddy is running
@@ -89,39 +91,40 @@ export function dev(buddy: CLI) {
89
91
  }
90
92
 
91
93
  if (wantsInteractive(options)) {
92
- const answer = await prompt.require()
93
- .select(descriptions.select, {
94
- options: [
95
- { value: 'all', label: 'All' },
96
- { value: 'frontend', label: 'Frontend' },
97
- { value: 'api', label: 'Backend' },
98
- { value: 'dashboard', label: 'Dashboard' },
99
- { value: 'desktop', label: 'Desktop' },
100
- { value: 'email', label: 'Email' },
101
- { value: 'components', label: 'Components' },
102
- { value: 'docs', label: 'Documentation' },
103
- ],
104
- })
105
-
106
- if (answer === 'components') {
107
- await runComponentsDevServer(options)
108
- }
109
- else if (answer === 'api') {
110
- await runApiDevServer(options)
111
- }
112
- else if (answer === 'dashboard') {
113
- await runDashboardDevServer(options)
114
- }
115
- // else if (answer === 'email')
116
- // await runEmailDevServer(options)
117
- else if (answer === 'docs') {
118
- await runDocsDevServer(options)
119
- }
120
-
121
- else {
122
- log.error('Invalid option during interactive mode')
123
- process.exit(ExitCode.InvalidArgument)
124
- }
94
+ // TODO: uncomment this when prompt is available
95
+ // const answer = await prompt.require()
96
+ // .select(descriptions.select, {
97
+ // options: [
98
+ // { value: 'all', label: 'All' },
99
+ // { value: 'frontend', label: 'Frontend' },
100
+ // { value: 'api', label: 'Backend' },
101
+ // { value: 'dashboard', label: 'Dashboard' },
102
+ // { value: 'desktop', label: 'Desktop' },
103
+ // { value: 'email', label: 'Email' },
104
+ // { value: 'components', label: 'Components' },
105
+ // { value: 'docs', label: 'Documentation' },
106
+ // ],
107
+ // })
108
+ //
109
+ // if (answer === 'components') {
110
+ // await runComponentsDevServer(options)
111
+ // }
112
+ // else if (answer === 'api') {
113
+ // await runApiDevServer(options)
114
+ // }
115
+ // else if (answer === 'dashboard') {
116
+ // await runDashboardDevServer(options)
117
+ // }
118
+ // // else if (answer === 'email')
119
+ // // await runEmailDevServer(options)
120
+ // else if (answer === 'docs') {
121
+ // await runDocsDevServer(options)
122
+ // }
123
+ //
124
+ // else {
125
+ // log.error('Invalid option during interactive mode')
126
+ // process.exit(ExitCode.InvalidArgument)
127
+ // }
125
128
  }
126
129
 
127
130
  else {
@@ -146,6 +149,8 @@ export function dev(buddy: CLI) {
146
149
  .option('-p, --project', descriptions.project, { default: false })
147
150
  .option('--verbose', descriptions.verbose, { default: false })
148
151
  .action(async (options: DevOptions) => {
152
+ log.debug('Running `buddy dev:components` ...', options)
153
+
149
154
  const perf = await intro('buddy dev:components')
150
155
  const result = await runCommand('bun run dev', {
151
156
  cwd: libsPath('components/vue'),
@@ -171,6 +176,8 @@ export function dev(buddy: CLI) {
171
176
  .option('-p, --project', descriptions.project, { default: false })
172
177
  .option('--verbose', descriptions.verbose, { default: false })
173
178
  .action(async (options: DevOptions) => {
179
+ log.debug('Running `buddy dev:docs` ...', options)
180
+
174
181
  const perf = await intro('buddy dev:docs')
175
182
  const result = await runAction(Action.DevDocs, options)
176
183
 
@@ -190,6 +197,8 @@ export function dev(buddy: CLI) {
190
197
  .option('-p, --project', descriptions.project, { default: false })
191
198
  .option('--verbose', descriptions.verbose, { default: false })
192
199
  .action(async (options: DevOptions) => {
200
+ log.debug('Running `buddy dev:desktop` ...', options)
201
+
193
202
  const perf = await intro('buddy dev:desktop')
194
203
  const result = await runAction(Action.DevDesktop, options)
195
204
 
@@ -209,13 +218,15 @@ export function dev(buddy: CLI) {
209
218
  .option('-p, --project', descriptions.project, { default: false })
210
219
  .option('--verbose', descriptions.verbose, { default: false })
211
220
  .action(async (options: DevOptions) => {
221
+ log.debug('Running `buddy dev:api` ...', options)
222
+
212
223
  await runApiDevServer(options)
213
224
  })
214
225
 
215
226
  // buddy
216
227
  // .command('dev:functions', descriptions.api)
217
- .option('-p, --project', descriptions.project, { default: false })//
218
- .option('--verbose', descriptions.verbose, { default: false })
228
+ // .option('-p, --project', descriptions.project, { default: false })//
229
+ // .option('--verbose', descriptions.verbose, { default: false })
219
230
  // .action(async (options: DevOptions) => {
220
231
  // await runFunctionsDevServer(options)
221
232
  // })
@@ -227,6 +238,7 @@ export function dev(buddy: CLI) {
227
238
  .option('-p, --project', descriptions.project, { default: false })
228
239
  .option('--verbose', descriptions.verbose, { default: false })
229
240
  .action(async (options: DevOptions) => {
241
+ log.debug('Running `buddy dev:frontend` ...', options)
230
242
  await runFrontendDevServer(options)
231
243
  })
232
244
 
@@ -236,6 +248,7 @@ export function dev(buddy: CLI) {
236
248
  .option('-p, --project', descriptions.project, { default: false })
237
249
  .option('--verbose', descriptions.verbose, { default: false })
238
250
  .action(async (options: DevOptions) => {
251
+ log.debug('Running `buddy dev:dashboard` ...', options)
239
252
  await runDashboardDevServer(options)
240
253
  })
241
254
 
@@ -245,6 +258,7 @@ export function dev(buddy: CLI) {
245
258
  .option('-p, --project', descriptions.project, { default: false })
246
259
  .option('--verbose', descriptions.verbose, { default: false })
247
260
  .action(async (options: DevOptions) => {
261
+ log.debug('Running `buddy dev:system-tray` ...', options)
248
262
  await runSystemTrayDevServer(options)
249
263
  })
250
264
 
@@ -2,7 +2,7 @@ import process from 'node:process'
2
2
  import { ExitCode } from '@stacksjs/types'
3
3
  import type { CLI } from '@stacksjs/types'
4
4
  import { config } from '@stacksjs/config'
5
- import { runCommand } from '@stacksjs/cli'
5
+ import { log, runCommand } from '@stacksjs/cli'
6
6
 
7
7
  // import { Action } from '@stacksjs/enums'
8
8
  // import { runAction } from '@stacksjs/actions'
@@ -59,6 +59,7 @@ export function dns(buddy: CLI) {
59
59
  .option('-p, --project', descriptions.project, { default: false })
60
60
  .option('--verbose', descriptions.verbose, { default: false })
61
61
  .action(async (domain: string | undefined, options: DnsOptions) => {
62
+ log.debug('Running `buddy dns [domain]` ...', options)
62
63
  // let prettyOutput = false
63
64
 
64
65
  // if (options.json && options.pretty)
@@ -77,4 +78,9 @@ export function dns(buddy: CLI) {
77
78
 
78
79
  process.exit(ExitCode.Success)
79
80
  })
81
+
82
+ buddy.on('dns:*', () => {
83
+ console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
84
+ process.exit(1)
85
+ })
80
86
  }
@@ -1,6 +1,6 @@
1
1
  import process from 'node:process'
2
2
  import { runAction } from '@stacksjs/actions'
3
- import { bgCyan, bold, intro, italic, outro, prompts } from '@stacksjs/cli'
3
+ import { bgCyan, bold, intro, italic, log, outro, prompts } from '@stacksjs/cli'
4
4
  import { config } from '@stacksjs/config'
5
5
  import { addDomain } from '@stacksjs/dns'
6
6
  import { ExitCode } from '@stacksjs/types'
@@ -64,6 +64,8 @@ export function domains(buddy: CLI) {
64
64
  .option('-p, --project', descriptions.project, { default: false })
65
65
  .option('--verbose', descriptions.verbose, { default: false })
66
66
  .action(async (domain: string, options: DomainsOptions) => {
67
+ log.debug('Running `buddy domains:purchase <domain>` ...', options)
68
+
67
69
  options.domain = domain
68
70
  const startTime = await intro('buddy domains:purchase')
69
71
  const result = await runAction(Action.DomainsPurchase, options)
@@ -103,6 +105,8 @@ export function domains(buddy: CLI) {
103
105
  .command('domains:add <domain>', descriptions.add)
104
106
  .option('--verbose', descriptions.verbose, { default: false })
105
107
  .action(async (options: DomainsOptions) => {
108
+ log.debug('Running `buddy domains:add <domain>` ...', options)
109
+
106
110
  const startTime = await intro('buddy domains:add')
107
111
  const result = await addDomain({
108
112
  ...options,
@@ -123,6 +127,8 @@ export function domains(buddy: CLI) {
123
127
  .option('--yes', descriptions.skip, { default: false })
124
128
  .option('--verbose', descriptions.verbose, { default: false })
125
129
  .action(async (options: DomainsOptions) => {
130
+ log.debug('Running `buddy domains:remove <domain>` ...', options)
131
+
126
132
  const domain = options.domain || config.app.url
127
133
  const opts = { ...options, domain }
128
134
  const startTime = await intro('buddy domains:remove')
@@ -2,12 +2,12 @@ import process from 'node:process'
2
2
  import { ExitCode } from '@stacksjs/types'
3
3
  import type { CLI, FreshOptions } from '@stacksjs/types'
4
4
  import { runAction } from '@stacksjs/actions'
5
- import { intro, outro } from '@stacksjs/cli'
5
+ import { intro, log, outro } from '@stacksjs/cli'
6
6
  import { Action } from '@stacksjs/enums'
7
7
 
8
8
  export function fresh(buddy: CLI) {
9
9
  const descriptions = {
10
- fresh: 'Reinstalls your npm dependencies',
10
+ fresh: 'Re-installs your npm dependencies',
11
11
  project: 'Target a specific project',
12
12
  verbose: 'Enable verbose output',
13
13
  }
@@ -17,6 +17,8 @@ export function fresh(buddy: CLI) {
17
17
  .option('-p, --project', descriptions.project, { default: false })
18
18
  .option('--verbose', descriptions.verbose, { default: false })
19
19
  .action(async (options: FreshOptions) => {
20
+ log.debug('Running `buddy fresh` ...', options)
21
+
20
22
  const perf = await intro('buddy fresh')
21
23
  const result = await runAction(Action.Fresh, { ...options, stdout: 'inherit' })
22
24
 
@@ -10,9 +10,8 @@ import {
10
10
  generateWebTypes,
11
11
  invoke as startGenerationProcess,
12
12
  } from '@stacksjs/actions'
13
- import { prompt } from '@stacksjs/cli'
13
+ import { log } from '@stacksjs/cli'
14
14
  import { type CLI, ExitCode, type GeneratorOptions } from '@stacksjs/types'
15
- import { isString } from '@stacksjs/validation'
16
15
 
17
16
  export function generate(buddy: CLI) {
18
17
  const descriptions = {
@@ -41,25 +40,28 @@ export function generate(buddy: CLI) {
41
40
  .option('-p, --project', descriptions.project, { default: false })
42
41
  .option('--verbose', descriptions.verbose, { default: false })
43
42
  .action(async (options: GeneratorOptions) => {
44
- if (hasNoOptions(options)) {
45
- let answers = await prompt.require()
46
- .multiselect(descriptions.select, {
47
- options: [
48
- { label: '1.) TypeScript Types', value: 'types' },
49
- { label: '2.) Library Entry Points', value: 'entries' },
50
- { label: '3.) Web Types', value: 'web-types' },
51
- { label: '4.) VS Code Custom Data', value: 'custom-data' },
52
- { label: '5.) IDE Helpers', value: 'ide-helpers' },
53
- { label: '6.) Component Meta', value: 'component-meta' },
54
- ],
55
- })
56
-
57
- if (isString(answers))
58
- answers = [answers]
59
-
60
- // creates an object out of array and sets answers to true
61
- options = (answers as Array<any>).reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
62
- }
43
+ log.debug('Running `buddy generate` ...', options)
44
+
45
+ // TODO: uncomment this
46
+ // if (hasNoOptions(options)) {
47
+ // let answers = await prompt.require()
48
+ // .multiselect(descriptions.select, {
49
+ // options: [
50
+ // { label: '1.) TypeScript Types', value: 'types' },
51
+ // { label: '2.) Library Entry Points', value: 'entries' },
52
+ // { label: '3.) Web Types', value: 'web-types' },
53
+ // { label: '4.) VS Code Custom Data', value: 'custom-data' },
54
+ // { label: '5.) IDE Helpers', value: 'ide-helpers' },
55
+ // { label: '6.) Component Meta', value: 'component-meta' },
56
+ // ],
57
+ // })
58
+ //
59
+ // if (isString(answers))
60
+ // answers = [answers]
61
+ //
62
+ // // creates an object out of array and sets answers to true
63
+ // options = (answers as Array<any>).reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
64
+ // }
63
65
 
64
66
  await startGenerationProcess(options)
65
67
 
@@ -72,6 +74,7 @@ export function generate(buddy: CLI) {
72
74
  .option('--verbose', descriptions.verbose, { default: false })
73
75
  .alias('types:generate')
74
76
  .action(async (options: GeneratorOptions) => {
77
+ log.debug('Running `buddy generate:types` ...', options)
75
78
  await generateTypes(options)
76
79
  })
77
80
 
@@ -80,6 +83,7 @@ export function generate(buddy: CLI) {
80
83
  .option('-p, --project', descriptions.project, { default: false })
81
84
  .option('--verbose', descriptions.verbose, { default: false })
82
85
  .action(async (options: GeneratorOptions) => {
86
+ log.debug('Running `buddy generate:entries` ...', options)
83
87
  await generateLibEntries(options)
84
88
  })
85
89
 
@@ -88,6 +92,7 @@ export function generate(buddy: CLI) {
88
92
  .option('-p, --project', descriptions.project, { default: false })
89
93
  .option('--verbose', descriptions.verbose, { default: false })
90
94
  .action(async (options: GeneratorOptions) => {
95
+ log.debug('Running `buddy generate:web-types` ...', options)
91
96
  await generateWebTypes(options)
92
97
  })
93
98
 
@@ -96,6 +101,7 @@ export function generate(buddy: CLI) {
96
101
  .option('-p, --project', descriptions.project, { default: false })
97
102
  .option('--verbose', descriptions.verbose, { default: false })
98
103
  .action(async (options: GeneratorOptions) => {
104
+ log.debug('Running `buddy generate:vscode-custom-data` ...', options)
99
105
  await generateVsCodeCustomData(options)
100
106
  })
101
107
 
@@ -104,6 +110,7 @@ export function generate(buddy: CLI) {
104
110
  .option('-p, --project', descriptions.project, { default: false })
105
111
  .option('--verbose', descriptions.verbose, { default: false })
106
112
  .action(async (options: GeneratorOptions) => {
113
+ log.debug('Running `buddy generate:ide-helpers` ...', options)
107
114
  await generateIdeHelpers(options)
108
115
  })
109
116
 
@@ -112,6 +119,7 @@ export function generate(buddy: CLI) {
112
119
  .option('-p, --project', descriptions.project, { default: false })
113
120
  .option('--verbose', descriptions.verbose, { default: false })
114
121
  .action(async (options: GeneratorOptions) => {
122
+ log.debug('Running `buddy generate:component-meta` ...', options)
115
123
  await generateComponentMeta(options)
116
124
  })
117
125
 
@@ -119,13 +127,15 @@ export function generate(buddy: CLI) {
119
127
  .command('generate:pkgx-config', descriptions.pkgx)
120
128
  .option('-p, --project', descriptions.project, { default: false })
121
129
  .option('--verbose', descriptions.verbose, { default: false })
122
- .action(() => {
130
+ .action((options: GeneratorOptions) => {
131
+ log.debug('Running `buddy generate:pkgx-config` ...', options)
123
132
  generatePkgxConfig()
124
133
  })
125
134
 
126
135
  buddy
127
136
  .command('generate:migrations', 'Generate Migrations')
128
- .action(() => {
137
+ .action((options: GeneratorOptions) => {
138
+ log.debug('Running `buddy generate:migrations` ...', options)
129
139
  generateMigrations()
130
140
  })
131
141
 
@@ -135,6 +145,6 @@ export function generate(buddy: CLI) {
135
145
  })
136
146
  }
137
147
 
138
- function hasNoOptions(options: GeneratorOptions) {
139
- return !options.types && !options.entries && !options.webTypes && !options.customData && !options.ideHelpers && !options.componentMeta
140
- }
148
+ // function hasNoOptions(options: GeneratorOptions) {
149
+ // return !options.types && !options.entries && !options.webTypes && !options.customData && !options.ideHelpers && !options.componentMeta
150
+ // }
@@ -4,7 +4,7 @@ import type { CLI } from '@stacksjs/types'
4
4
  import { config } from '@stacksjs/config'
5
5
 
6
6
  // import { path } from '@stacksjs/path'
7
- import { runCommandSync } from '@stacksjs/cli'
7
+ import { log, runCommandSync } from '@stacksjs/cli'
8
8
 
9
9
  // function runCommand(command: string): Promise<string> {
10
10
  // return new Promise((resolve, reject) => {
@@ -39,6 +39,8 @@ export function http(buddy: CLI) {
39
39
  .option('-p, --project', descriptions.project, { default: false })
40
40
  // .option('--verbose', descriptions.verbose, { default: false })
41
41
  .action(async (domain: string | undefined, options: HttpOptions) => {
42
+ log.debug('Running `buddy http [domain]` ...', options)
43
+
42
44
  // Convert options object to command-line options string
43
45
  const optionsString = Object.entries(options)
44
46
  .filter(([key, value]) => key !== '--' && key.length > 1 && value !== false) // filter out '--' key and short options
@@ -46,9 +48,9 @@ export function http(buddy: CLI) {
46
48
  .join(' ')
47
49
 
48
50
  const command = `http GET ${domain || config.app.url} ${optionsString}`
49
- // eslint-disable-next-line no-console
50
- console.log(`Running command: ${command}`)
51
- runCommandSync(command)
51
+
52
+ log.info(`Running command: ${command}`)
53
+ await runCommandSync(command)
52
54
 
53
55
  process.exit(ExitCode.Success)
54
56
  })
@@ -9,13 +9,11 @@ export * from './deploy'
9
9
  export * from './dev'
10
10
  export * from './domains'
11
11
  export * from './dns'
12
- export * from './example'
13
12
  export * from './fresh'
14
13
  export * from './generate'
15
14
  export * from './http'
16
15
  export * from './lint'
17
16
  export * from './list'
18
- export * from './inspire'
19
17
  export * from './install'
20
18
  export * from './key'
21
19
  export * from './make'
@@ -1,6 +1,6 @@
1
1
  import process from 'node:process'
2
2
  import type { CLI, InstallOptions } from '@stacksjs/types'
3
- import { runCommand } from '@stacksjs/cli'
3
+ import { log, runCommand } from '@stacksjs/cli'
4
4
  import { path as p } from '@stacksjs/path'
5
5
 
6
6
  export function install(buddy: CLI) {
@@ -15,6 +15,8 @@ export function install(buddy: CLI) {
15
15
  .option('-p, --project', descriptions.project, { default: false })
16
16
  .option('-v, --verbose', descriptions.verbose, { default: false })
17
17
  .action(async (options: InstallOptions) => {
18
+ log.debug('Running `buddy install` ...', options)
19
+
18
20
  await runCommand('bun install', {
19
21
  ...options,
20
22
  cwd: p.projectPath(),
@@ -16,6 +16,8 @@ export function key(buddy: CLI) {
16
16
  .option('-p, --project', descriptions.project, { default: false })
17
17
  .option('--verbose', descriptions.verbose, { default: false })
18
18
  .action(async (options: KeyOptions) => {
19
+ log.debug('Running `buddy key:generate` ...', options)
20
+
19
21
  await intro('buddy key:generate')
20
22
  const result = await runAction(Action.KeyGenerate, options)
21
23
 
@@ -18,6 +18,8 @@ export function lint(buddy: CLI) {
18
18
  .option('-p, --project', descriptions.project, { default: false })
19
19
  .option('--verbose', descriptions.verbose, { default: false })
20
20
  .action(async (options: LintOptions) => {
21
+ log.debug('Running `buddy lint` ...', options)
22
+
21
23
  const startTime = await intro('buddy lint')
22
24
  const result = await runAction(Action.Lint, options)
23
25
 
@@ -35,6 +37,8 @@ export function lint(buddy: CLI) {
35
37
  .option('-p, --project', descriptions.project, { default: false })
36
38
  .option('--verbose', descriptions.verbose, { default: false })
37
39
  .action(async (options: LintOptions) => {
40
+ log.debug('Running `buddy lint:fix` ...', options)
41
+
38
42
  log.info('Fixing lint errors...')
39
43
  const result = await runAction(Action.LintFix, { ...options })
40
44
 
@@ -1,7 +1,8 @@
1
1
  import process from 'node:process'
2
- import type { CLI } from '@stacksjs/types'
2
+ import type { CLI, CliOptions } from '@stacksjs/types'
3
3
  import { $ } from 'bun'
4
4
  import { projectPath } from '@stacksjs/path'
5
+ import { log } from 'stacks/logging'
5
6
 
6
7
  export function list(buddy: CLI) {
7
8
  const descriptions = {
@@ -14,8 +15,11 @@ export function list(buddy: CLI) {
14
15
  .command('list', descriptions.list)
15
16
  .option('-p, --project', descriptions.project, { default: false })
16
17
  .option('--verbose', descriptions.verbose, { default: false })
17
- .action(async () => {
18
+ .action(async (options: CliOptions) => {
19
+ log.debug('Running `buddy list` ...', options)
20
+
18
21
  $.cwd(projectPath())
22
+
19
23
  const test = await $`buddy --help`.text()
20
24
  const commandsSection = test.match(/Commands:.*?(?=For more info, run any command with the)/s)?.[0]
21
25