Skip to content

Commit 2b7a121

Browse files
committed
chore: wip
1 parent cf9a08f commit 2b7a121

File tree

5 files changed

+63
-41
lines changed

5 files changed

+63
-41
lines changed

storage/framework/core/actions/src/find-projects.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os from 'node:os'
2+
import process from 'node:process'
23
import { findStacksProjects } from '@stacksjs/utils'
34
import { log } from '@stacksjs/logging'
45

@@ -12,12 +13,11 @@ try {
1213
log.info('Found Projects:')
1314
// eslint-disable-next-line no-console
1415
projects.forEach(project => console.log(` - ${project}`))
16+
process.exit()
1517
}
16-
else {
17-
// eslint-disable-next-line no-console
18-
console.log('No Stacks Projects found.')
19-
}
18+
19+
log.info('No Stacks Projects found.')
2020
}
2121
catch (error: any) {
22-
console.error('Error searching for Stacks projects:', error)
22+
log.error('Error searching for Stacks projects:', error)
2323
}

storage/framework/core/buddy/src/commands/find-projects.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

storage/framework/core/buddy/src/commands/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export * from './deploy'
99
export * from './dev'
1010
export * from './domains'
1111
export * from './dns'
12-
export * from './find-projects'
1312
export * from './fresh'
1413
export * from './generate'
1514
export * from './http'
@@ -20,6 +19,7 @@ export * from './key'
2019
export * from './make'
2120
export * from './migrate'
2221
export * from './prepublish'
22+
export * from './projects'
2323
export * from './release'
2424
export * from './seed'
2525
export * from './setup'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import process from 'node:process'
2+
import { ExitCode } from '@stacksjs/types'
3+
import type { CLI, ProjectsOptions } from '@stacksjs/types'
4+
import { runAction } from '@stacksjs/actions'
5+
import { intro, log, outro } from '@stacksjs/cli'
6+
import { Action } from '@stacksjs/enums'
7+
8+
export function findProjects(buddy: CLI) {
9+
const descriptions = {
10+
projects: 'Find all Stacks projects on your system',
11+
verbose: 'Enable verbose output',
12+
}
13+
14+
buddy
15+
.command('projects', descriptions.projects)
16+
.option('-l, --list', 'List all local Stacks projects', { default: false })
17+
.option('--verbose', descriptions.verbose, { default: false })
18+
.action(async (options: ProjectsOptions) => {
19+
log.debug('Running `buddy projects` ...', options)
20+
21+
const perf = await intro('buddy projects')
22+
const result = await runAction(Action.FindProjects, options)
23+
24+
if (result.isErr()) {
25+
await outro('While running the projects command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
26+
process.exit(ExitCode.FatalError)
27+
}
28+
29+
process.exit(ExitCode.Success)
30+
})
31+
32+
buddy
33+
.command('projects:list', descriptions.projects)
34+
.option('-l, --list', 'List all local Stacks projects', { default: true })
35+
.option('--verbose', descriptions.verbose, { default: false })
36+
.action(async (options: ProjectsOptions) => {
37+
log.debug('Running `buddy projects` ...', options)
38+
39+
const perf = await intro('buddy projects:list')
40+
const result = await runAction(Action.FindProjects, options)
41+
42+
if (result.isErr()) {
43+
await outro('While running the projects:list command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
44+
process.exit(ExitCode.FatalError)
45+
}
46+
47+
process.exit(ExitCode.Success)
48+
})
49+
50+
buddy.on('projects:*', () => {
51+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
52+
process.exit(1)
53+
})
54+
}

storage/framework/core/types/src/cli.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ export interface InstallOptions extends CliOptions { }
305305
export interface ReleaseOptions extends CliOptions {
306306
dryRun?: boolean
307307
}
308+
export interface ProjectsOptions extends CliOptions {
309+
list?: boolean
310+
}
308311
export interface PreinstallOptions extends CliOptions { }
309312
export interface PrepublishOptions extends CliOptions { }
310313
export interface TinkerOptions extends CliOptions { }

0 commit comments

Comments
 (0)