@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/ports.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import
|
|
3
|
-
import { ExitCode } from '@stacksjs/types'
|
|
2
|
+
import { intro, italic, outro } from '@stacksjs/cli'
|
|
4
3
|
import { ports as projectPorts } from '@stacksjs/config'
|
|
5
4
|
import { log } from '@stacksjs/logging'
|
|
6
5
|
import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
|
|
7
|
+
import { ExitCode } from '@stacksjs/types'
|
|
9
8
|
import { findStacksProjects } from '@stacksjs/utils'
|
|
9
|
+
import { $ } from 'bun'
|
|
10
10
|
|
|
11
11
|
export function ports(buddy: CLI) {
|
|
12
12
|
const descriptions = {
|
|
@@ -19,16 +19,19 @@ export function ports(buddy: CLI) {
|
|
|
19
19
|
buddy
|
|
20
20
|
.command('ports', descriptions.command)
|
|
21
21
|
.option('-l, --list', 'List the used ports', { default: true })
|
|
22
|
-
.option('-c, --check', 'Check if the ports are available', {
|
|
23
|
-
|
|
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
|
+
})
|
|
24
28
|
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
25
29
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
26
30
|
.action(async (options: PortsOptions) => {
|
|
27
31
|
log.debug('Running `buddy ports` ...', options)
|
|
28
32
|
|
|
29
33
|
let perf
|
|
30
|
-
if (!options.quiet)
|
|
31
|
-
perf = await intro('buddy ports')
|
|
34
|
+
if (!options.quiet) perf = await intro('buddy ports')
|
|
32
35
|
|
|
33
36
|
if (options.project) {
|
|
34
37
|
const path = await findProjectPath(options.project)
|
|
@@ -45,28 +48,27 @@ export function ports(buddy: CLI) {
|
|
|
45
48
|
outputPorts(projectPorts, options)
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
if (!options.quiet)
|
|
49
|
-
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
51
|
+
if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
|
|
50
52
|
|
|
51
53
|
process.exit(ExitCode.Success)
|
|
52
54
|
})
|
|
53
55
|
|
|
54
56
|
buddy
|
|
55
57
|
.command('ports:list', descriptions.ports)
|
|
56
|
-
.option('-p, --project [name]', descriptions.project, {
|
|
58
|
+
.option('-p, --project [name]', descriptions.project, {
|
|
59
|
+
default: undefined,
|
|
60
|
+
})
|
|
57
61
|
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
58
62
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
59
63
|
.action(async (options: PortsOptions) => {
|
|
60
64
|
log.debug('Running `buddy ports:list` ...', options)
|
|
61
65
|
|
|
62
66
|
let perf
|
|
63
|
-
if (!options.quiet)
|
|
64
|
-
perf = await intro('buddy ports:list')
|
|
67
|
+
if (!options.quiet) perf = await intro('buddy ports:list')
|
|
65
68
|
|
|
66
69
|
// return the ports for the project
|
|
67
70
|
if (options.project) {
|
|
68
|
-
if (!options.quiet)
|
|
69
|
-
log.info(`Listing ports for project: ${italic(options.project)}`)
|
|
71
|
+
if (!options.quiet) log.info(`Listing ports for project: ${italic(options.project)}`)
|
|
70
72
|
|
|
71
73
|
const path = await findProjectPath(options.project)
|
|
72
74
|
|
|
@@ -81,23 +83,23 @@ export function ports(buddy: CLI) {
|
|
|
81
83
|
outputPorts(projectPorts, options)
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
if (!options.quiet)
|
|
85
|
-
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
86
|
+
if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
|
|
86
87
|
|
|
87
88
|
process.exit(ExitCode.Success)
|
|
88
89
|
})
|
|
89
90
|
|
|
90
91
|
buddy
|
|
91
92
|
.command('ports:check', descriptions.ports)
|
|
92
|
-
.option('-p, --project [name]', descriptions.project, {
|
|
93
|
+
.option('-p, --project [name]', descriptions.project, {
|
|
94
|
+
default: projectPath(),
|
|
95
|
+
})
|
|
93
96
|
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
94
97
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
95
98
|
.action(async (options: PortsOptions) => {
|
|
96
99
|
log.debug('Running `buddy ports:check` ...', options)
|
|
97
100
|
|
|
98
101
|
let perf
|
|
99
|
-
if (!options.quiet)
|
|
100
|
-
perf = await intro('buddy ports:check')
|
|
102
|
+
if (!options.quiet) perf = await intro('buddy ports:check')
|
|
101
103
|
|
|
102
104
|
const projects = await findStacksProjects(undefined, { quiet: true })
|
|
103
105
|
|
|
@@ -107,13 +109,11 @@ export function ports(buddy: CLI) {
|
|
|
107
109
|
|
|
108
110
|
// need to loop over the projects and then trigger `buddy ports` for each project (which returns a list of ports)
|
|
109
111
|
const projectsPorts: { [project: string]: Ports } = {}
|
|
110
|
-
for (const project of projects)
|
|
111
|
-
projectsPorts[project] = await getPortsForProjectPath(project, options)
|
|
112
|
+
for (const project of projects) projectsPorts[project] = await getPortsForProjectPath(project, options)
|
|
112
113
|
|
|
113
114
|
log.info('ProjectsPorts:', projectsPorts)
|
|
114
115
|
|
|
115
|
-
if (!options.quiet)
|
|
116
|
-
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
116
|
+
if (!options.quiet) await outro('Exited', { startTime: perf, useSeconds: false })
|
|
117
117
|
|
|
118
118
|
process.exit(ExitCode.Success)
|
|
119
119
|
})
|
|
@@ -125,8 +125,7 @@ export function ports(buddy: CLI) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
async function getPortsForProjectPath(path: string, options: PortsOptions) {
|
|
128
|
-
if (!options.quiet)
|
|
129
|
-
log.info(`Checking ports for project: ${italic(path)}`)
|
|
128
|
+
if (!options.quiet) log.info(`Checking ports for project: ${italic(path)}`)
|
|
130
129
|
|
|
131
130
|
$.cwd(path)
|
|
132
131
|
// load the .env file for the project
|
|
@@ -136,19 +135,23 @@ async function getPortsForProjectPath(path: string, options: PortsOptions) {
|
|
|
136
135
|
log.debug('ProjectListResponse', projectList)
|
|
137
136
|
|
|
138
137
|
// get the list of all Stacks project paths (on the system)
|
|
139
|
-
const projects = projectList
|
|
138
|
+
const projects = projectList
|
|
139
|
+
.split('\n')
|
|
140
|
+
.filter((line) => line.startsWith(' - '))
|
|
141
|
+
.map((line) => line.trim().substring(4))
|
|
140
142
|
log.debug('Projects:', projects)
|
|
141
143
|
|
|
142
144
|
// since we are targeting a specific project, find its path
|
|
143
145
|
const ppath = options.project ?? p.projectPath()
|
|
144
|
-
let projectPath = projects.find(project => project.includes(ppath))
|
|
146
|
+
let projectPath = projects.find((project) => project.includes(ppath))
|
|
145
147
|
|
|
146
148
|
log.debug(`Checking ports for project: ${projectPath}`)
|
|
147
|
-
if (projectPath === '' || !projectPath)
|
|
149
|
+
if (projectPath === '' || !projectPath)
|
|
150
|
+
// default to the current project
|
|
148
151
|
projectPath = p.projectPath()
|
|
149
152
|
|
|
150
153
|
log.debug(`$ Running: ./buddy ports:list --quiet via ${projectPath}`)
|
|
151
|
-
const response =
|
|
154
|
+
const response = await $`./buddy ports:list --quiet`.json()
|
|
152
155
|
|
|
153
156
|
log.debug(`Response for ./buddy ports:list --quiet via ${projectPath}`, response)
|
|
154
157
|
|
|
@@ -167,14 +170,9 @@ async function getPortsForProjectPath(path: string, options: PortsOptions) {
|
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
function outputPorts(ports: Ports, options: PortsOptions) {
|
|
170
|
-
if (!options.quiet)
|
|
171
|
-
// eslint-disable-next-line no-console
|
|
172
|
-
console.log('')
|
|
173
|
+
if (!options.quiet) console.log('')
|
|
173
174
|
|
|
174
|
-
// eslint-disable-next-line no-console
|
|
175
175
|
console.log(ports)
|
|
176
176
|
|
|
177
|
-
if (!options.quiet)
|
|
178
|
-
// eslint-disable-next-line no-console
|
|
179
|
-
console.log('')
|
|
177
|
+
if (!options.quiet) console.log('')
|
|
180
178
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI, PrepublishOptions } from '@stacksjs/types'
|
|
3
|
-
import { Action } from '@stacksjs/enums'
|
|
4
2
|
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
5
4
|
import { log } from '@stacksjs/logging'
|
|
5
|
+
import type { CLI, PrepublishOptions } from '@stacksjs/types'
|
|
6
6
|
|
|
7
7
|
export function prepublish(buddy: CLI) {
|
|
8
8
|
const descriptions = {
|
|
@@ -13,7 +13,7 @@ export function prepublish(buddy: CLI) {
|
|
|
13
13
|
|
|
14
14
|
buddy
|
|
15
15
|
.command('prepublish', descriptions.command)
|
|
16
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
16
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
17
17
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
18
18
|
.action(async (options: PrepublishOptions) => {
|
|
19
19
|
log.debug('Running `buddy prepublish` ...', options)
|
package/src/commands/projects.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { intro, log } from '@stacksjs/cli'
|
|
2
3
|
import { ExitCode } from '@stacksjs/types'
|
|
3
4
|
import type { CLI, ProjectsOptions } from '@stacksjs/types'
|
|
4
|
-
import { intro, log } from '@stacksjs/cli'
|
|
5
5
|
import { findStacksProjects } from '@stacksjs/utils'
|
|
6
6
|
|
|
7
7
|
export function projects(buddy: CLI) {
|
|
@@ -18,14 +18,11 @@ export function projects(buddy: CLI) {
|
|
|
18
18
|
.action(async (options: ProjectsOptions) => {
|
|
19
19
|
log.debug('Running `buddy projects` ...', options)
|
|
20
20
|
|
|
21
|
-
if (!options.quiet)
|
|
22
|
-
await intro('buddy projects')
|
|
21
|
+
if (!options.quiet) await intro('buddy projects')
|
|
23
22
|
|
|
24
23
|
const projects = await findStacksProjects(undefined, options)
|
|
25
24
|
|
|
26
|
-
for (const project of projects)
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.log(' - ', project)
|
|
25
|
+
for (const project of projects) console.log(' - ', project)
|
|
29
26
|
|
|
30
27
|
process.exit(ExitCode.Success)
|
|
31
28
|
})
|
|
@@ -38,15 +35,12 @@ export function projects(buddy: CLI) {
|
|
|
38
35
|
.action(async (options: ProjectsOptions) => {
|
|
39
36
|
log.debug('Running `buddy projects` ...', options)
|
|
40
37
|
|
|
41
|
-
if (!options.quiet)
|
|
42
|
-
await intro('buddy projects:list')
|
|
38
|
+
if (!options.quiet) await intro('buddy projects:list')
|
|
43
39
|
|
|
44
40
|
// uses os.homedir() as the default path
|
|
45
41
|
const projects = await findStacksProjects(undefined, options)
|
|
46
42
|
|
|
47
|
-
for (const project of projects)
|
|
48
|
-
// eslint-disable-next-line no-console
|
|
49
|
-
console.log(' - ', project)
|
|
43
|
+
for (const project of projects) console.log(' - ', project)
|
|
50
44
|
|
|
51
45
|
process.exit(ExitCode.Success)
|
|
52
46
|
})
|
package/src/commands/release.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { intro, log, outro } from '@stacksjs/cli'
|
|
2
4
|
import { Action } from '@stacksjs/enums'
|
|
3
5
|
import { ExitCode } from '@stacksjs/types'
|
|
4
6
|
import type { CLI, ReleaseOptions } from '@stacksjs/types'
|
|
5
|
-
import { intro, log, outro } from '@stacksjs/cli'
|
|
6
|
-
import { runAction } from '@stacksjs/actions'
|
|
7
7
|
|
|
8
8
|
const descriptions = {
|
|
9
9
|
release: 'Release a new version of your libraries/packages',
|
|
@@ -16,13 +16,12 @@ export function release(buddy: CLI) {
|
|
|
16
16
|
buddy
|
|
17
17
|
.command('release', descriptions.release)
|
|
18
18
|
.option('--dry-run', descriptions.dryRun, { 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: ReleaseOptions) => {
|
|
22
22
|
log.debug('Running `buddy release` ...', options)
|
|
23
23
|
|
|
24
|
-
if (options.dryRun)
|
|
25
|
-
log.warn('Dry run enabled. No changes will be made or committed.')
|
|
24
|
+
if (options.dryRun) log.warn('Dry run enabled. No changes will be made or committed.')
|
|
26
25
|
|
|
27
26
|
const startTime = await intro('buddy release')
|
|
28
27
|
const result = await runAction(Action.Release, {
|
|
@@ -35,7 +34,10 @@ export function release(buddy: CLI) {
|
|
|
35
34
|
process.exit(ExitCode.FatalError)
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
await outro('Triggered CI/CD Release Workflow', {
|
|
37
|
+
await outro('Triggered CI/CD Release Workflow', {
|
|
38
|
+
startTime,
|
|
39
|
+
useSeconds: true,
|
|
40
|
+
})
|
|
39
41
|
})
|
|
40
42
|
|
|
41
43
|
buddy.on('release:*', () => {
|
package/src/commands/seed.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import { ExitCode } from '@stacksjs/types'
|
|
3
|
-
import type { CLI, SeedOptions } from '@stacksjs/types'
|
|
4
2
|
import { runAction } from '@stacksjs/actions'
|
|
5
3
|
import { intro, log, outro } from '@stacksjs/cli'
|
|
6
4
|
import { Action } from '@stacksjs/enums'
|
|
5
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
|
+
import type { CLI, SeedOptions } from '@stacksjs/types'
|
|
7
7
|
|
|
8
8
|
export function seed(buddy: CLI) {
|
|
9
9
|
const descriptions = {
|
|
@@ -14,7 +14,7 @@ export function seed(buddy: CLI) {
|
|
|
14
14
|
|
|
15
15
|
buddy
|
|
16
16
|
.command('seed', descriptions.seed)
|
|
17
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
17
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
18
18
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
19
|
.action(async (options: SeedOptions) => {
|
|
20
20
|
log.debug('Running `buddy seed` ...', options)
|
|
@@ -23,13 +23,20 @@ export function seed(buddy: CLI) {
|
|
|
23
23
|
const result = await runAction(Action.Seed, options)
|
|
24
24
|
|
|
25
25
|
if (result.isErr()) {
|
|
26
|
-
await outro(
|
|
26
|
+
await outro(
|
|
27
|
+
'While running the seed command, there was an issue',
|
|
28
|
+
{ startTime: perf, useSeconds: true },
|
|
29
|
+
result.error,
|
|
30
|
+
)
|
|
27
31
|
process.exit(ExitCode.FatalError)
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
const APP_ENV = process.env.APP_ENV || 'local'
|
|
31
35
|
|
|
32
|
-
await outro(`Seeded your ${APP_ENV} database.`, {
|
|
36
|
+
await outro(`Seeded your ${APP_ENV} database.`, {
|
|
37
|
+
startTime: perf,
|
|
38
|
+
useSeconds: true,
|
|
39
|
+
})
|
|
33
40
|
process.exit(ExitCode.Success)
|
|
34
41
|
})
|
|
35
42
|
|
package/src/commands/setup.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import {
|
|
2
|
+
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { log, runCommand } from '@stacksjs/cli'
|
|
3
4
|
import { Action } from '@stacksjs/enums'
|
|
4
5
|
import { handleError } from '@stacksjs/error-handling'
|
|
6
|
+
import { path as p } from '@stacksjs/path'
|
|
5
7
|
import { storage } from '@stacksjs/storage'
|
|
6
|
-
import { log, runCommand } from '@stacksjs/cli'
|
|
7
8
|
import { ExitCode } from '@stacksjs/types'
|
|
8
9
|
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
9
10
|
|
|
@@ -19,13 +20,12 @@ export function setup(buddy: CLI) {
|
|
|
19
20
|
buddy
|
|
20
21
|
.command('setup', descriptions.setup)
|
|
21
22
|
.alias('ensure')
|
|
22
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
23
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
23
24
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
24
25
|
.action(async (options: CliOptions) => {
|
|
25
26
|
log.debug('Running `buddy setup` ...', options)
|
|
26
27
|
|
|
27
|
-
if (!await isPkgxInstalled())
|
|
28
|
-
await installPkgx()
|
|
28
|
+
if (!(await isPkgxInstalled())) await installPkgx()
|
|
29
29
|
|
|
30
30
|
// ensure the minimal amount of deps are written to ./pkgx.yaml
|
|
31
31
|
await optimizePkgxDeps()
|
|
@@ -59,8 +59,7 @@ export function setup(buddy: CLI) {
|
|
|
59
59
|
async function isPkgxInstalled(): Promise<boolean> {
|
|
60
60
|
const result = await runCommand('pkgx --version', { silent: true })
|
|
61
61
|
|
|
62
|
-
if (result.isOk())
|
|
63
|
-
return true
|
|
62
|
+
if (result.isOk()) return true
|
|
64
63
|
|
|
65
64
|
return false
|
|
66
65
|
}
|
|
@@ -68,8 +67,7 @@ async function isPkgxInstalled(): Promise<boolean> {
|
|
|
68
67
|
async function installPkgx(): Promise<void> {
|
|
69
68
|
const result = await runCommand(p.frameworkPath('scripts/pkgx-install'))
|
|
70
69
|
|
|
71
|
-
if (result.isOk())
|
|
72
|
-
return
|
|
70
|
+
if (result.isOk()) return
|
|
73
71
|
|
|
74
72
|
handleError(result.error)
|
|
75
73
|
process.exit(ExitCode.FatalError)
|
|
@@ -120,7 +118,7 @@ async function initializeProject(options: CliOptions): Promise<void> {
|
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
export async function optimizePkgxDeps(): Promise<void> {
|
|
123
|
-
return new Promise(resolve => setTimeout(resolve, 300))
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, 300))
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
|
|
@@ -137,6 +135,7 @@ export async function ensureEnvIsSet(options: CliOptions): Promise<void> {
|
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
log.success('.env created')
|
|
138
|
+
} else {
|
|
139
|
+
log.success('.env existed')
|
|
140
140
|
}
|
|
141
|
-
else { log.success('.env existed') }
|
|
142
141
|
}
|
package/src/commands/test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI, TestOptions } from '@stacksjs/types'
|
|
3
2
|
import { runAction } from '@stacksjs/actions'
|
|
4
3
|
import { intro, outro } from '@stacksjs/cli'
|
|
5
|
-
import { projectPath } from '@stacksjs/path'
|
|
6
4
|
import { Action } from '@stacksjs/enums'
|
|
5
|
+
import { projectPath } from '@stacksjs/path'
|
|
6
|
+
import type { CLI, TestOptions } from '@stacksjs/types'
|
|
7
7
|
|
|
8
8
|
export function test(buddy: CLI) {
|
|
9
9
|
const descriptions = {
|
|
@@ -21,18 +21,28 @@ export function test(buddy: CLI) {
|
|
|
21
21
|
buddy
|
|
22
22
|
.command('test', descriptions.command)
|
|
23
23
|
.option('--ui', descriptions.ui, { default: false })
|
|
24
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
24
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
25
25
|
.option('--verbose', descriptions.verbose, { default: true })
|
|
26
26
|
.action(async (options: TestOptions) => {
|
|
27
27
|
const perf = await intro('buddy test')
|
|
28
|
-
const result = await runAction(Action.Test, {
|
|
28
|
+
const result = await runAction(Action.Test, {
|
|
29
|
+
...options,
|
|
30
|
+
cwd: projectPath(),
|
|
31
|
+
})
|
|
29
32
|
|
|
30
33
|
if (result.isErr()) {
|
|
31
|
-
await outro(
|
|
34
|
+
await outro(
|
|
35
|
+
'While running `buddy test`, there was an issue',
|
|
36
|
+
{ startTime: perf, useSeconds: true },
|
|
37
|
+
result.error,
|
|
38
|
+
)
|
|
32
39
|
process.exit()
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
await outro('Finished running tests', {
|
|
42
|
+
await outro('Finished running tests', {
|
|
43
|
+
startTime: perf,
|
|
44
|
+
useSeconds: true,
|
|
45
|
+
})
|
|
36
46
|
})
|
|
37
47
|
|
|
38
48
|
buddy
|
|
@@ -40,14 +50,25 @@ export function test(buddy: CLI) {
|
|
|
40
50
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
41
51
|
.action(async (options: TestOptions) => {
|
|
42
52
|
const perf = await intro('buddy test:unit')
|
|
43
|
-
const result = await runAction(Action.TestUnit, {
|
|
53
|
+
const result = await runAction(Action.TestUnit, {
|
|
54
|
+
...options,
|
|
55
|
+
verbose: true,
|
|
56
|
+
cwd: projectPath(),
|
|
57
|
+
})
|
|
44
58
|
|
|
45
59
|
if (result.isErr()) {
|
|
46
|
-
await outro(
|
|
60
|
+
await outro(
|
|
61
|
+
'While running `buddy test:unit`, there was an issue',
|
|
62
|
+
{ startTime: perf, useSeconds: true },
|
|
63
|
+
result.error,
|
|
64
|
+
)
|
|
47
65
|
process.exit()
|
|
48
66
|
}
|
|
49
67
|
|
|
50
|
-
await outro('Finished running unit tests', {
|
|
68
|
+
await outro('Finished running unit tests', {
|
|
69
|
+
startTime: perf,
|
|
70
|
+
useSeconds: true,
|
|
71
|
+
})
|
|
51
72
|
})
|
|
52
73
|
|
|
53
74
|
buddy
|
|
@@ -59,16 +80,31 @@ export function test(buddy: CLI) {
|
|
|
59
80
|
let result
|
|
60
81
|
|
|
61
82
|
if (options.showReport)
|
|
62
|
-
result = await runAction(Action.ShowFeatureTestReport, {
|
|
83
|
+
result = await runAction(Action.ShowFeatureTestReport, {
|
|
84
|
+
...options,
|
|
85
|
+
verbose: true,
|
|
86
|
+
cwd: projectPath(),
|
|
87
|
+
})
|
|
63
88
|
else
|
|
64
|
-
result = await runAction(Action.TestFeature, {
|
|
89
|
+
result = await runAction(Action.TestFeature, {
|
|
90
|
+
...options,
|
|
91
|
+
verbose: true,
|
|
92
|
+
cwd: projectPath(),
|
|
93
|
+
})
|
|
65
94
|
|
|
66
95
|
if (result.isErr()) {
|
|
67
|
-
await outro(
|
|
96
|
+
await outro(
|
|
97
|
+
'While running `buddy test:feature`, there was an issue',
|
|
98
|
+
{ startTime: perf, useSeconds: true },
|
|
99
|
+
result.error,
|
|
100
|
+
)
|
|
68
101
|
process.exit()
|
|
69
102
|
}
|
|
70
103
|
|
|
71
|
-
await outro('Finished running feature tests', {
|
|
104
|
+
await outro('Finished running feature tests', {
|
|
105
|
+
startTime: perf,
|
|
106
|
+
useSeconds: true,
|
|
107
|
+
})
|
|
72
108
|
})
|
|
73
109
|
|
|
74
110
|
buddy
|
|
@@ -76,14 +112,25 @@ export function test(buddy: CLI) {
|
|
|
76
112
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
77
113
|
.action(async (options: TestOptions) => {
|
|
78
114
|
const perf = await intro('buddy test:ui')
|
|
79
|
-
const result = await runAction(Action.TestUi, {
|
|
115
|
+
const result = await runAction(Action.TestUi, {
|
|
116
|
+
...options,
|
|
117
|
+
verbose: true,
|
|
118
|
+
cwd: projectPath(),
|
|
119
|
+
})
|
|
80
120
|
|
|
81
121
|
if (result.isErr()) {
|
|
82
|
-
await outro(
|
|
122
|
+
await outro(
|
|
123
|
+
'While running `buddy test:ui`, there was an issue',
|
|
124
|
+
{ startTime: perf, useSeconds: true },
|
|
125
|
+
result.error,
|
|
126
|
+
)
|
|
83
127
|
process.exit()
|
|
84
128
|
}
|
|
85
129
|
|
|
86
|
-
await outro('Finished running tests in the browser', {
|
|
130
|
+
await outro('Finished running tests in the browser', {
|
|
131
|
+
startTime: perf,
|
|
132
|
+
useSeconds: true,
|
|
133
|
+
})
|
|
87
134
|
})
|
|
88
135
|
|
|
89
136
|
buddy
|
|
@@ -92,30 +139,50 @@ export function test(buddy: CLI) {
|
|
|
92
139
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
93
140
|
.action(async (options: TestOptions) => {
|
|
94
141
|
const perf = await intro('buddy test:types')
|
|
95
|
-
const result = await runAction(Action.Typecheck, {
|
|
142
|
+
const result = await runAction(Action.Typecheck, {
|
|
143
|
+
...options,
|
|
144
|
+
verbose: true,
|
|
145
|
+
cwd: projectPath(),
|
|
146
|
+
})
|
|
96
147
|
|
|
97
148
|
if (result.isErr()) {
|
|
98
|
-
await outro(
|
|
149
|
+
await outro(
|
|
150
|
+
'While running `buddy test:types`, there was an issue',
|
|
151
|
+
{ startTime: perf, useSeconds: true },
|
|
152
|
+
result.error,
|
|
153
|
+
)
|
|
99
154
|
process.exit()
|
|
100
155
|
}
|
|
101
156
|
|
|
102
|
-
await outro('Finished running typecheck', {
|
|
157
|
+
await outro('Finished running typecheck', {
|
|
158
|
+
startTime: perf,
|
|
159
|
+
useSeconds: true,
|
|
160
|
+
})
|
|
103
161
|
})
|
|
104
162
|
|
|
105
|
-
buddy
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
await outro('While running `buddy test:coverage`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
113
|
-
process.exit()
|
|
114
|
-
}
|
|
163
|
+
buddy.command('test:coverage', descriptions.coverage).action(async (options: TestOptions) => {
|
|
164
|
+
const perf = await intro('buddy test:coverage')
|
|
165
|
+
const result = await runAction(Action.TestCoverage, {
|
|
166
|
+
...options,
|
|
167
|
+
cwd: projectPath(),
|
|
168
|
+
verbose: true,
|
|
169
|
+
})
|
|
115
170
|
|
|
116
|
-
|
|
171
|
+
if (result.isErr()) {
|
|
172
|
+
await outro(
|
|
173
|
+
'While running `buddy test:coverage`, there was an issue',
|
|
174
|
+
{ startTime: perf, useSeconds: true },
|
|
175
|
+
result.error,
|
|
176
|
+
)
|
|
117
177
|
process.exit()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await outro('Generated the test coverage report', {
|
|
181
|
+
startTime: perf,
|
|
182
|
+
useSeconds: true,
|
|
118
183
|
})
|
|
184
|
+
process.exit()
|
|
185
|
+
})
|
|
119
186
|
|
|
120
187
|
buddy.on('test:*', () => {
|
|
121
188
|
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
package/src/commands/tinker.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
+
import { intro, log, outro, runCommand } from '@stacksjs/cli'
|
|
2
3
|
import { ExitCode } from '@stacksjs/types'
|
|
3
4
|
import type { CLI, TinkerOptions } from '@stacksjs/types'
|
|
4
|
-
import { runAction } from '@stacksjs/actions'
|
|
5
|
-
import { intro, log, outro } from '@stacksjs/cli'
|
|
6
|
-
import { Action } from '@stacksjs/enums'
|
|
7
5
|
|
|
8
6
|
export function tinker(buddy: CLI) {
|
|
9
7
|
const descriptions = {
|
|
@@ -14,16 +12,22 @@ export function tinker(buddy: CLI) {
|
|
|
14
12
|
|
|
15
13
|
buddy
|
|
16
14
|
.command('tinker', descriptions.tinker)
|
|
17
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
15
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
18
16
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
17
|
.action(async (options: TinkerOptions) => {
|
|
20
18
|
log.debug('Running `buddy tinker` ...', options)
|
|
21
19
|
|
|
22
20
|
const perf = await intro('buddy tinker')
|
|
23
|
-
const result = await
|
|
21
|
+
const result = await runCommand('bun repl', {
|
|
22
|
+
stdin: 'inherit',
|
|
23
|
+
})
|
|
24
24
|
|
|
25
25
|
if (result.isErr()) {
|
|
26
|
-
await outro(
|
|
26
|
+
await outro(
|
|
27
|
+
'While running the tinker command, there was an issue',
|
|
28
|
+
{ startTime: perf, useSeconds: true },
|
|
29
|
+
result.error || undefined,
|
|
30
|
+
)
|
|
27
31
|
process.exit()
|
|
28
32
|
}
|
|
29
33
|
|
package/src/commands/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
3
2
|
import { generateTypes } from '@stacksjs/actions'
|
|
4
3
|
import { log } from '@stacksjs/logging'
|
|
4
|
+
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
5
5
|
|
|
6
6
|
export function types(buddy: CLI) {
|
|
7
7
|
const descriptions = {
|
|
@@ -13,7 +13,7 @@ export function types(buddy: CLI) {
|
|
|
13
13
|
|
|
14
14
|
buddy
|
|
15
15
|
.command('types:generate', descriptions.generate)
|
|
16
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
16
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
17
17
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
18
18
|
.action(async (options: CliOptions) => {
|
|
19
19
|
log.debug('Running `buddy types:generate` ...', options)
|
|
@@ -22,7 +22,7 @@ export function types(buddy: CLI) {
|
|
|
22
22
|
|
|
23
23
|
buddy
|
|
24
24
|
.command('types:fix', descriptions.fix)
|
|
25
|
-
.option('-p, --project', descriptions.project, { default: false })
|
|
25
|
+
.option('-p, --project [project]', descriptions.project, { default: false })
|
|
26
26
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
27
27
|
.action(async () => {
|
|
28
28
|
// await fixTypes()
|