@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.
- package/dist/{chunk-agapayce.js → chunk-3whxjf1k.js} +1 -4
- package/dist/chunk-42swmjjw.js +2 -0
- package/dist/chunk-564c63vr.js +2 -0
- package/dist/chunk-5wxk7vka.js +1 -0
- package/dist/chunk-6cscdnf5.js +2 -0
- package/dist/chunk-898dh3kh.js +8 -0
- package/dist/chunk-9g2p5d3j.js +2 -0
- package/dist/chunk-bpa4071y.js +2 -0
- package/dist/chunk-cbtnhpqk.js +2 -0
- package/dist/chunk-f18wwa85.js +827 -0
- package/dist/chunk-g767h9jq.js +3 -0
- package/dist/chunk-hgzxtrgw.js +9 -0
- package/dist/chunk-hqv9y9k2.js +6 -0
- package/dist/chunk-jfs19hhz.js +2 -0
- package/dist/chunk-ncwfzcsm.js +2 -0
- package/dist/chunk-pfb4369d.js +2 -0
- package/dist/chunk-sgm5999j.js +12 -0
- package/dist/chunk-we57sm1m.js +2 -0
- package/dist/chunk-wps8bq6b.js +2 -0
- package/dist/chunk-y2g00ayp.js +2 -0
- package/dist/chunk-ycyg22fp.js +2 -0
- package/dist/cli.js +1 -4
- package/dist/index.js +1 -4
- package/dist/stacks +0 -0
- package/package.json +48 -49
- package/dist/chunk-1bcxd9nx.js +0 -5
- package/dist/chunk-1bcxd9nx.js.map +0 -17
- package/dist/chunk-3gvx3tap.js +0 -5
- package/dist/chunk-3gvx3tap.js.map +0 -9
- package/dist/chunk-5mkzknp4.js +0 -5
- package/dist/chunk-5mkzknp4.js.map +0 -32
- package/dist/chunk-a3d48jzd.js +0 -15
- package/dist/chunk-a3d48jzd.js.map +0 -164
- package/dist/chunk-a6ba4vgs.js +0 -5
- package/dist/chunk-a6ba4vgs.js.map +0 -11
- package/dist/chunk-agapayce.js.map +0 -15
- package/dist/chunk-b9d377d9.js +0 -5
- package/dist/chunk-b9d377d9.js.map +0 -26
- package/dist/chunk-bh61bx6h.js +0 -4
- package/dist/chunk-bh61bx6h.js.map +0 -23
- package/dist/chunk-fqrjh7j8.js +0 -5
- package/dist/chunk-fqrjh7j8.js.map +0 -10
- package/dist/chunk-jkt9jxar.js +0 -9
- package/dist/chunk-jkt9jxar.js.map +0 -13
- package/dist/chunk-k1q2z202.js +0 -4
- package/dist/chunk-k1q2z202.js.map +0 -16
- package/dist/chunk-mmjggjd5.js +0 -849
- package/dist/chunk-mmjggjd5.js.map +0 -240
- package/dist/chunk-mxwvrbdh.js +0 -6
- package/dist/chunk-mxwvrbdh.js.map +0 -59
- package/dist/chunk-n55kahn5.js +0 -5
- package/dist/chunk-n55kahn5.js.map +0 -12
- package/dist/chunk-pbpgcz3v.js +0 -5
- package/dist/chunk-pbpgcz3v.js.map +0 -46
- package/dist/chunk-sadghty0.js +0 -5
- package/dist/chunk-sadghty0.js.map +0 -20
- package/dist/chunk-smzpmhmp.js +0 -11
- package/dist/chunk-smzpmhmp.js.map +0 -10
- package/dist/chunk-w4zypt02.js +0 -5
- package/dist/chunk-w4zypt02.js.map +0 -23
- package/dist/chunk-ywfsnx7v.js +0 -5
- package/dist/chunk-ywfsnx7v.js.map +0 -22
- package/dist/chunk-yxs8vtg9.js +0 -5
- package/dist/chunk-yxs8vtg9.js.map +0 -10
- package/dist/chunk-z7609s4h.js +0 -12
- package/dist/chunk-z7609s4h.js.map +0 -11
- package/dist/cli.js.map +0 -10
- package/dist/index.js.map +0 -9
- package/src/cli.ts +0 -105
- package/src/commands/add.ts +0 -71
- package/src/commands/build.ts +0 -299
- package/src/commands/changelog.ts +0 -52
- package/src/commands/clean.ts +0 -46
- package/src/commands/cloud.ts +0 -553
- package/src/commands/commit.ts +0 -26
- package/src/commands/configure.ts +0 -84
- package/src/commands/create.ts +0 -143
- package/src/commands/deploy.ts +0 -194
- package/src/commands/dev.ts +0 -292
- package/src/commands/dns.ts +0 -86
- package/src/commands/domains.ts +0 -255
- package/src/commands/fresh.ts +0 -48
- package/src/commands/generate.ts +0 -202
- package/src/commands/http.ts +0 -57
- package/src/commands/index.ts +0 -33
- package/src/commands/install.ts +0 -30
- package/src/commands/key.ts +0 -36
- package/src/commands/lint.ts +0 -54
- package/src/commands/list.ts +0 -42
- package/src/commands/make.ts +0 -352
- package/src/commands/migrate.ts +0 -105
- package/src/commands/outdated.ts +0 -31
- package/src/commands/ports.ts +0 -188
- package/src/commands/prepublish.ts +0 -28
- package/src/commands/projects.ts +0 -54
- package/src/commands/release.ts +0 -50
- package/src/commands/route.ts +0 -39
- package/src/commands/seed.ts +0 -47
- package/src/commands/setup.ts +0 -145
- package/src/commands/test.ts +0 -214
- package/src/commands/tinker.ts +0 -42
- package/src/commands/types.ts +0 -35
- package/src/commands/upgrade.ts +0 -200
- package/src/commands/version.ts +0 -29
- package/src/custom-cli.ts +0 -35
- package/src/index.ts +0 -1
package/src/commands/ports.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { intro, italic, outro } from '@stacksjs/cli'
|
|
4
|
-
import { ports as projectPorts } from '@stacksjs/config'
|
|
5
|
-
import { log } from '@stacksjs/logging'
|
|
6
|
-
import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
|
|
7
|
-
import { ExitCode } from '@stacksjs/types'
|
|
8
|
-
import { findStacksProjects } from '@stacksjs/utils'
|
|
9
|
-
import { $ } from 'bun'
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { CLI, PrepublishOptions } from '@stacksjs/types'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { runAction } from '@stacksjs/actions'
|
|
4
|
-
import { Action } from '@stacksjs/enums'
|
|
5
|
-
import { log } from '@stacksjs/logging'
|
|
6
|
-
|
|
7
|
-
export function prepublish(buddy: CLI): void {
|
|
8
|
-
const descriptions = {
|
|
9
|
-
command: 'Run your prepublish script',
|
|
10
|
-
project: 'Target a specific project',
|
|
11
|
-
verbose: 'Enable verbose output',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
buddy
|
|
15
|
-
.command('prepublish', descriptions.command)
|
|
16
|
-
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
17
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
18
|
-
.action(async (options: PrepublishOptions) => {
|
|
19
|
-
log.debug('Running `buddy prepublish` ...', options)
|
|
20
|
-
|
|
21
|
-
await runAction(Action.Prepublish, options)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
buddy.on('prepublish:*', () => {
|
|
25
|
-
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
26
|
-
process.exit(1)
|
|
27
|
-
})
|
|
28
|
-
}
|
package/src/commands/projects.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CLI, ProjectsOptions } from '@stacksjs/types'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { intro, log } from '@stacksjs/cli'
|
|
4
|
-
import { ExitCode } from '@stacksjs/types'
|
|
5
|
-
import { findStacksProjects } from '@stacksjs/utils'
|
|
6
|
-
|
|
7
|
-
export function projects(buddy: CLI): void {
|
|
8
|
-
const descriptions = {
|
|
9
|
-
projects: 'Find all Stacks projects on your system',
|
|
10
|
-
verbose: 'Enable verbose output',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
buddy
|
|
14
|
-
.command('projects', descriptions.projects)
|
|
15
|
-
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
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
|
-
if (!options.quiet)
|
|
22
|
-
await intro('buddy projects')
|
|
23
|
-
|
|
24
|
-
const projects = await findStacksProjects(undefined, options)
|
|
25
|
-
|
|
26
|
-
for (const project of projects) console.log(' - ', project)
|
|
27
|
-
|
|
28
|
-
process.exit(ExitCode.Success)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
buddy
|
|
32
|
-
.command('projects:list', descriptions.projects)
|
|
33
|
-
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
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
|
-
if (!options.quiet)
|
|
40
|
-
await intro('buddy projects:list')
|
|
41
|
-
|
|
42
|
-
// uses os.homedir() as the default path
|
|
43
|
-
const projects = await findStacksProjects(undefined, options)
|
|
44
|
-
|
|
45
|
-
for (const project of projects) console.log(' - ', project)
|
|
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
|
-
}
|
package/src/commands/release.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { CLI, ReleaseOptions } from '@stacksjs/types'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { runAction } from '@stacksjs/actions'
|
|
4
|
-
import { intro, italic, log, outro } from '@stacksjs/cli'
|
|
5
|
-
import { Action } from '@stacksjs/enums'
|
|
6
|
-
import { ExitCode } from '@stacksjs/types'
|
|
7
|
-
|
|
8
|
-
const descriptions = {
|
|
9
|
-
release: 'Release a new version of your libraries/packages',
|
|
10
|
-
project: 'Target a specific project',
|
|
11
|
-
dryRun: 'Run the release without actually releasing',
|
|
12
|
-
verbose: 'Enable verbose output',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function release(buddy: CLI): void {
|
|
16
|
-
buddy
|
|
17
|
-
.command('release', descriptions.release)
|
|
18
|
-
.option('--dry-run', descriptions.dryRun, { default: false })
|
|
19
|
-
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
20
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
21
|
-
.action(async (options: ReleaseOptions) => {
|
|
22
|
-
log.debug('Running `buddy release` ...', options)
|
|
23
|
-
|
|
24
|
-
if (options.dryRun)
|
|
25
|
-
log.warn('Dry run enabled. No changes will be made or committed.')
|
|
26
|
-
|
|
27
|
-
const startTime = await intro('buddy release')
|
|
28
|
-
const result = await runAction(Action.Release, {
|
|
29
|
-
stdin: 'inherit',
|
|
30
|
-
...options,
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
if (result.isErr()) {
|
|
34
|
-
log.error('Failed to release', result.error)
|
|
35
|
-
process.exit(ExitCode.FatalError)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await outro('Triggered CI/CD Release via GitHub Actions', {
|
|
39
|
-
startTime,
|
|
40
|
-
useSeconds: true,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
log.info(`Follow along: ${italic('https://github.com/stacksjs/stacks/actions')}`)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
buddy.on('release:*', () => {
|
|
47
|
-
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
48
|
-
process.exit(1)
|
|
49
|
-
})
|
|
50
|
-
}
|
package/src/commands/route.ts
DELETED
|
@@ -1,39 +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, outro } from '@stacksjs/cli'
|
|
5
|
-
import { Action } from '@stacksjs/enums'
|
|
6
|
-
import { ExitCode } from '@stacksjs/types'
|
|
7
|
-
|
|
8
|
-
export function route(buddy: CLI): void {
|
|
9
|
-
const descriptions = {
|
|
10
|
-
route: 'Lists your routes',
|
|
11
|
-
verbose: 'Enable verbose output',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
buddy
|
|
15
|
-
.command('route:list', descriptions.route)
|
|
16
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
17
|
-
.action(async (options: MigrateOptions) => {
|
|
18
|
-
const perf = await intro('buddy route:list')
|
|
19
|
-
const result = await runAction(Action.RouteList, options)
|
|
20
|
-
|
|
21
|
-
if (result.isErr()) {
|
|
22
|
-
await outro(
|
|
23
|
-
'While running the migrate command, there was an issue',
|
|
24
|
-
{ startTime: perf, useSeconds: true },
|
|
25
|
-
result.error,
|
|
26
|
-
)
|
|
27
|
-
process.exit()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
await outro(`Successfully listed routes`)
|
|
31
|
-
|
|
32
|
-
process.exit(ExitCode.Success)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
buddy.on('route:*', () => {
|
|
36
|
-
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
37
|
-
process.exit(1)
|
|
38
|
-
})
|
|
39
|
-
}
|
package/src/commands/seed.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { CLI, SeedOptions } 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 seed(buddy: CLI): void {
|
|
9
|
-
const descriptions = {
|
|
10
|
-
seed: 'Seed your database',
|
|
11
|
-
project: 'Target a specific project',
|
|
12
|
-
verbose: 'Enable verbose output',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
buddy
|
|
16
|
-
.command('seed', descriptions.seed)
|
|
17
|
-
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
18
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
|
-
.action(async (options: SeedOptions) => {
|
|
20
|
-
log.debug('Running `buddy seed` ...', options)
|
|
21
|
-
|
|
22
|
-
const perf = await intro('buddy seed')
|
|
23
|
-
const result = await runAction(Action.Seed, options)
|
|
24
|
-
|
|
25
|
-
if (result.isErr()) {
|
|
26
|
-
await outro(
|
|
27
|
-
'While running the seed command, there was an issue',
|
|
28
|
-
{ startTime: perf, useSeconds: true },
|
|
29
|
-
result.error,
|
|
30
|
-
)
|
|
31
|
-
process.exit(ExitCode.FatalError)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const APP_ENV = process.env.APP_ENV || 'local'
|
|
35
|
-
|
|
36
|
-
await outro(`Seeded your ${APP_ENV} database.`, {
|
|
37
|
-
startTime: perf,
|
|
38
|
-
useSeconds: true,
|
|
39
|
-
})
|
|
40
|
-
process.exit(ExitCode.Success)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
buddy.on('seed:*', () => {
|
|
44
|
-
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
45
|
-
process.exit(1)
|
|
46
|
-
})
|
|
47
|
-
}
|
package/src/commands/setup.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { runAction } from '@stacksjs/actions'
|
|
4
|
-
import { log, runCommand } from '@stacksjs/cli'
|
|
5
|
-
import { Action } from '@stacksjs/enums'
|
|
6
|
-
import { handleError } from '@stacksjs/error-handling'
|
|
7
|
-
import { path as p } from '@stacksjs/path'
|
|
8
|
-
import { storage } from '@stacksjs/storage'
|
|
9
|
-
import { ExitCode } from '@stacksjs/types'
|
|
10
|
-
|
|
11
|
-
export function setup(buddy: CLI): void {
|
|
12
|
-
const descriptions = {
|
|
13
|
-
setup: 'This command ensures your project is setup correctly',
|
|
14
|
-
ohMyZsh: 'Enable Oh My Zsh',
|
|
15
|
-
aws: 'Ensures AWS is connected to the project',
|
|
16
|
-
project: 'Target a specific project',
|
|
17
|
-
verbose: 'Enable verbose output',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
buddy
|
|
21
|
-
.command('setup', descriptions.setup)
|
|
22
|
-
.alias('ensure')
|
|
23
|
-
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
24
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
25
|
-
.action(async (options: CliOptions) => {
|
|
26
|
-
log.debug('Running `buddy setup` ...', options)
|
|
27
|
-
|
|
28
|
-
if (!(await isPkgxInstalled()))
|
|
29
|
-
await installPkgx()
|
|
30
|
-
|
|
31
|
-
// ensure the minimal amount of deps are written to ./pkgx.yaml
|
|
32
|
-
await optimizePkgxDeps()
|
|
33
|
-
|
|
34
|
-
// TODO: optimizeConfigDir()
|
|
35
|
-
// TODO: optimizeAddDir()
|
|
36
|
-
|
|
37
|
-
await initializeProject(options)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
buddy
|
|
41
|
-
.command('setup:oh-my-zsh', descriptions.ohMyZsh) // if triggered multiple times, it will update the plugin
|
|
42
|
-
.alias('upgrade:oh-my-zsh')
|
|
43
|
-
.option('--verbose', descriptions.verbose, { default: false })
|
|
44
|
-
.action(async (_options?: CliOptions) => {
|
|
45
|
-
log.debug('Running `buddy setup:oh-my-zsh` ...', _options)
|
|
46
|
-
const result = await runAction(Action.UpgradeShell)
|
|
47
|
-
|
|
48
|
-
if (result.isErr()) {
|
|
49
|
-
log.error(result.error)
|
|
50
|
-
process.exit(ExitCode.FatalError)
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
buddy.on('setup:*', () => {
|
|
55
|
-
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
56
|
-
process.exit(ExitCode.FatalError)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function isPkgxInstalled(): Promise<boolean> {
|
|
61
|
-
const result = await runCommand('pkgx --version', { silent: true })
|
|
62
|
-
|
|
63
|
-
if (result.isOk())
|
|
64
|
-
return true
|
|
65
|
-
|
|
66
|
-
return false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function installPkgx(): Promise<void> {
|
|
70
|
-
const result = await runCommand(p.frameworkPath('scripts/pkgx-install'))
|
|
71
|
-
|
|
72
|
-
if (result.isOk())
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
handleError(result.error)
|
|
76
|
-
process.exit(ExitCode.FatalError)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function initializeProject(options: CliOptions): Promise<void> {
|
|
80
|
-
log.info('Installing dependencies...')
|
|
81
|
-
|
|
82
|
-
const result = await runCommand('bun install', {
|
|
83
|
-
cwd: options.cwd || p.projectPath(),
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (result.isErr()) {
|
|
87
|
-
handleError(result.error)
|
|
88
|
-
process.exit(ExitCode.FatalError)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
log.success('Installed node_modules')
|
|
92
|
-
|
|
93
|
-
ensureEnvIsSet(options)
|
|
94
|
-
|
|
95
|
-
const keyResult = await runCommand('buddy key:generate', {
|
|
96
|
-
cwd: options.cwd || p.projectPath(),
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
if (keyResult.isErr()) {
|
|
100
|
-
handleError(keyResult.error)
|
|
101
|
-
process.exit(ExitCode.FatalError)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
log.info('Ensuring AWS is connected...')
|
|
105
|
-
|
|
106
|
-
const awsResult = await runCommand('buddy configure:aws', {
|
|
107
|
-
cwd: options.cwd || p.projectPath(),
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
if (awsResult.isErr()) {
|
|
111
|
-
handleError(awsResult.error)
|
|
112
|
-
process.exit(ExitCode.FatalError)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
log.success('Configured AWS')
|
|
116
|
-
|
|
117
|
-
// TODO: ensure the IDE is setup by making sure .vscode etc exists, and if not, copy them over
|
|
118
|
-
|
|
119
|
-
log.success('Project is setup')
|
|
120
|
-
log.info('Happy coding! 💙')
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function optimizePkgxDeps(): Promise<void> {
|
|
124
|
-
return new Promise(resolve => setTimeout(resolve, 300))
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
|
|
128
|
-
log.info('Ensuring .env exists...')
|
|
129
|
-
|
|
130
|
-
if (storage.doesNotExist(p.projectPath('.env'))) {
|
|
131
|
-
const envResult = await runCommand('cp .env.example .env', {
|
|
132
|
-
cwd: options.cwd || p.projectPath(),
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
if (envResult.isErr()) {
|
|
136
|
-
handleError(envResult.error)
|
|
137
|
-
process.exit(ExitCode.FatalError)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
log.success('.env created')
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
log.success('.env existed')
|
|
144
|
-
}
|
|
145
|
-
}
|