@stacksjs/buddy 0.58.73 → 0.59.2
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-d2428b387d843985.js +2016 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +23 -9
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/changelog.d.ts +2 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/cloud.d.ts +2 -0
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/configure.d.ts +2 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/deploy.d.ts +2 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dns.d.ts +2 -0
- package/dist/commands/domains.d.ts +2 -0
- package/dist/commands/fresh.d.ts +2 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/http.d.ts +2 -0
- package/dist/commands/index.d.ts +31 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/key.d.ts +2 -0
- package/dist/commands/lint.d.ts +2 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/make.d.ts +2 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/ports.d.ts +2 -0
- package/dist/commands/prepublish.d.ts +2 -0
- package/dist/commands/projects.d.ts +2 -0
- package/dist/commands/release.d.ts +2 -0
- package/dist/commands/seed.d.ts +2 -0
- package/dist/commands/setup.d.ts +4 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/tinker.d.ts +2 -0
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/version.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -5
- package/dist/stacks +0 -0
- package/package.json +1 -3
- package/src/cli.ts +18 -13
- package/src/commands/add.ts +1 -1
- package/src/commands/commit.ts +1 -1
- package/src/commands/deploy.ts +1 -1
- package/src/commands/dev.ts +1 -3
- package/src/commands/index.ts +0 -1
- package/src/commands/key.ts +1 -1
- package/src/commands/list.ts +1 -1
- package/src/commands/make.ts +28 -2
- package/src/commands/ports.ts +135 -28
- package/src/commands/prepublish.ts +1 -1
- package/src/commands/projects.ts +2 -3
- package/src/commands/setup.ts +1 -0
- package/src/commands/types.ts +1 -1
- package/dist/chunk-1a569f35f66ae151.js +0 -10945
- package/dist/chunk-bf054cfbc9cf2201.js +0 -993
- package/src/commands/check.ts +0 -45
- /package/dist/{chunk-0455e53fab4244b1.js → chunk-970e033f764e29fc.js} +0 -0
package/src/commands/ports.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import type { CLI,
|
|
2
|
+
import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
|
|
3
3
|
import { ExitCode } from '@stacksjs/types'
|
|
4
4
|
import { ports as projectPorts } from '@stacksjs/config'
|
|
5
5
|
import { log } from '@stacksjs/logging'
|
|
6
|
+
import { findProjectPath, path as p, projectPath } from '@stacksjs/path'
|
|
6
7
|
import { $ } from 'bun'
|
|
7
|
-
import { intro, italic, outro } from '
|
|
8
|
+
import { intro, italic, outro } from '@stacksjs/cli'
|
|
9
|
+
import { findStacksProjects } from '@stacksjs/utils'
|
|
8
10
|
|
|
9
11
|
export function ports(buddy: CLI) {
|
|
10
12
|
const descriptions = {
|
|
@@ -16,10 +18,12 @@ export function ports(buddy: CLI) {
|
|
|
16
18
|
|
|
17
19
|
buddy
|
|
18
20
|
.command('ports', descriptions.command)
|
|
19
|
-
.option('-
|
|
21
|
+
.option('-l, --list', 'List the used ports', { default: true })
|
|
22
|
+
.option('-c, --check', 'Check if the ports are available', { default: false })
|
|
23
|
+
.option('-p, --project [name]', descriptions.project, { default: undefined })
|
|
20
24
|
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
21
25
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
22
|
-
.action(async (options:
|
|
26
|
+
.action(async (options: PortsOptions) => {
|
|
23
27
|
log.debug('Running `buddy ports` ...', options)
|
|
24
28
|
|
|
25
29
|
let perf
|
|
@@ -27,41 +31,89 @@ export function ports(buddy: CLI) {
|
|
|
27
31
|
perf = await intro('buddy ports')
|
|
28
32
|
|
|
29
33
|
if (options.project) {
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
const path = await findProjectPath(options.project)
|
|
35
|
+
log.debug(`Path: ${path}`)
|
|
36
|
+
|
|
37
|
+
const ports = await getPortsForProjectPath(path, options)
|
|
38
|
+
log.debug(`./buddy ports --quiet response for ${projectPath}`, ports)
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
outputPorts(ports, options)
|
|
41
|
+
}
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
// use the user config ports
|
|
44
|
+
else {
|
|
45
|
+
outputPorts(projectPorts, options)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!options.quiet)
|
|
49
|
+
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
38
50
|
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
process.exit(ExitCode.Success)
|
|
52
|
+
})
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
buddy
|
|
55
|
+
.command('ports:list', descriptions.ports)
|
|
56
|
+
.option('-p, --project [name]', descriptions.project, { default: undefined })
|
|
57
|
+
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
58
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
59
|
+
.action(async (options: PortsOptions) => {
|
|
60
|
+
log.debug('Running `buddy ports:list` ...', options)
|
|
43
61
|
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
let perf
|
|
63
|
+
if (!options.quiet)
|
|
64
|
+
perf = await intro('buddy ports:list')
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
// return the ports for the project
|
|
67
|
+
if (options.project) {
|
|
68
|
+
if (!options.quiet)
|
|
69
|
+
log.info(`Listing ports for project: ${italic(options.project)}`)
|
|
70
|
+
|
|
71
|
+
const path = await findProjectPath(options.project)
|
|
72
|
+
|
|
73
|
+
log.debug(`Path: ${path}`)
|
|
74
|
+
|
|
75
|
+
const ports = await getPortsForProjectPath(path, options)
|
|
76
|
+
|
|
77
|
+
outputPorts(ports, options)
|
|
53
78
|
}
|
|
79
|
+
// return the used ports for all projects
|
|
54
80
|
else {
|
|
55
|
-
|
|
56
|
-
console.log('')
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
console.log(projectPorts)
|
|
59
|
-
// eslint-disable-next-line no-console
|
|
60
|
-
console.log('')
|
|
81
|
+
outputPorts(projectPorts, options)
|
|
61
82
|
}
|
|
62
83
|
|
|
63
84
|
if (!options.quiet)
|
|
64
|
-
await outro('Exited', { startTime: perf, useSeconds:
|
|
85
|
+
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
86
|
+
|
|
87
|
+
process.exit(ExitCode.Success)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
buddy
|
|
91
|
+
.command('ports:check', descriptions.ports)
|
|
92
|
+
.option('-p, --project [name]', descriptions.project, { default: projectPath() })
|
|
93
|
+
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
94
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
95
|
+
.action(async (options: PortsOptions) => {
|
|
96
|
+
log.debug('Running `buddy ports:check` ...', options)
|
|
97
|
+
|
|
98
|
+
let perf
|
|
99
|
+
if (!options.quiet)
|
|
100
|
+
perf = await intro('buddy ports:check')
|
|
101
|
+
|
|
102
|
+
const projects = await findStacksProjects(undefined, { quiet: true })
|
|
103
|
+
|
|
104
|
+
log.debug('Running `buddy ports`')
|
|
105
|
+
log.debug(`Found ${projects.length} projects`)
|
|
106
|
+
log.debug('Projects:', projects)
|
|
107
|
+
|
|
108
|
+
// need to loop over the projects and then trigger `buddy ports` for each project (which returns a list of ports)
|
|
109
|
+
const projectsPorts: { [project: string]: Ports } = {}
|
|
110
|
+
for (const project of projects)
|
|
111
|
+
projectsPorts[project] = await getPortsForProjectPath(project, options)
|
|
112
|
+
|
|
113
|
+
log.info('ProjectsPorts:', projectsPorts)
|
|
114
|
+
|
|
115
|
+
if (!options.quiet)
|
|
116
|
+
await outro('Exited', { startTime: perf, useSeconds: false })
|
|
65
117
|
|
|
66
118
|
process.exit(ExitCode.Success)
|
|
67
119
|
})
|
|
@@ -71,3 +123,58 @@ export function ports(buddy: CLI) {
|
|
|
71
123
|
process.exit(1)
|
|
72
124
|
})
|
|
73
125
|
}
|
|
126
|
+
|
|
127
|
+
async function getPortsForProjectPath(path: string, options: PortsOptions) {
|
|
128
|
+
if (!options.quiet)
|
|
129
|
+
log.info(`Checking ports for project: ${italic(path)}`)
|
|
130
|
+
|
|
131
|
+
$.cwd(path)
|
|
132
|
+
// load the .env file for the project
|
|
133
|
+
$.env(await import(`${path}/.env`))
|
|
134
|
+
|
|
135
|
+
const projectList = await $`./buddy projects:list --quiet`.text()
|
|
136
|
+
log.debug('ProjectListResponse', projectList)
|
|
137
|
+
|
|
138
|
+
// get the list of all Stacks project paths (on the system)
|
|
139
|
+
const projects = projectList.split('\n').filter(line => line.startsWith(' - ')).map(line => line.trim().substring(4))
|
|
140
|
+
log.debug('Projects:', projects)
|
|
141
|
+
|
|
142
|
+
// since we are targeting a specific project, find its path
|
|
143
|
+
const ppath = options.project ?? p.projectPath()
|
|
144
|
+
let projectPath = projects.find(project => project.includes(ppath))
|
|
145
|
+
|
|
146
|
+
log.debug(`Checking ports for project: ${projectPath}`)
|
|
147
|
+
if (projectPath === '' || !projectPath) // default to the current project
|
|
148
|
+
projectPath = p.projectPath()
|
|
149
|
+
|
|
150
|
+
log.debug(`$ Running: ./buddy ports:list --quiet via ${projectPath}`)
|
|
151
|
+
const response = (await $`./buddy ports:list --quiet`.json())
|
|
152
|
+
|
|
153
|
+
log.debug(`Response for ./buddy ports:list --quiet via ${projectPath}`, response)
|
|
154
|
+
|
|
155
|
+
// Step 1: Add double quotes around keys
|
|
156
|
+
let validJsonString = response.replace(/(\w+)(?=\s*:)/g, '"$1"')
|
|
157
|
+
|
|
158
|
+
// Step 2: Remove potential trailing commas before closing braces
|
|
159
|
+
validJsonString = validJsonString.replace(/,(\s*})/g, '$1')
|
|
160
|
+
|
|
161
|
+
// Now we can parse it into an object
|
|
162
|
+
const ports = JSON.parse(validJsonString) as Ports
|
|
163
|
+
|
|
164
|
+
log.debug(`Ports for ${projectPath}`, ports)
|
|
165
|
+
|
|
166
|
+
return ports
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function outputPorts(ports: Ports, options: PortsOptions) {
|
|
170
|
+
if (!options.quiet)
|
|
171
|
+
// eslint-disable-next-line no-console
|
|
172
|
+
console.log('')
|
|
173
|
+
|
|
174
|
+
// eslint-disable-next-line no-console
|
|
175
|
+
console.log(ports)
|
|
176
|
+
|
|
177
|
+
if (!options.quiet)
|
|
178
|
+
// eslint-disable-next-line no-console
|
|
179
|
+
console.log('')
|
|
180
|
+
}
|
|
@@ -2,7 +2,7 @@ import process from 'node:process'
|
|
|
2
2
|
import type { CLI, PrepublishOptions } from '@stacksjs/types'
|
|
3
3
|
import { Action } from '@stacksjs/enums'
|
|
4
4
|
import { runAction } from '@stacksjs/actions'
|
|
5
|
-
import { log } from '
|
|
5
|
+
import { log } from '@stacksjs/logging'
|
|
6
6
|
|
|
7
7
|
export function prepublish(buddy: CLI) {
|
|
8
8
|
const descriptions = {
|
package/src/commands/projects.ts
CHANGED
|
@@ -38,11 +38,10 @@ export function projects(buddy: CLI) {
|
|
|
38
38
|
.action(async (options: ProjectsOptions) => {
|
|
39
39
|
log.debug('Running `buddy projects` ...', options)
|
|
40
40
|
|
|
41
|
-
await intro('buddy projects:list')
|
|
42
|
-
|
|
43
41
|
if (!options.quiet)
|
|
44
|
-
await intro('buddy projects')
|
|
42
|
+
await intro('buddy projects:list')
|
|
45
43
|
|
|
44
|
+
// uses os.homedir() as the default path
|
|
46
45
|
const projects = await findStacksProjects(undefined, options)
|
|
47
46
|
|
|
48
47
|
for (const project of projects)
|
package/src/commands/setup.ts
CHANGED
|
@@ -2,6 +2,7 @@ import process from 'node:process'
|
|
|
2
2
|
import { path as p } from '@stacksjs/path'
|
|
3
3
|
import { Action } from '@stacksjs/enums'
|
|
4
4
|
import { handleError } from '@stacksjs/error-handling'
|
|
5
|
+
import { storage } from '@stacksjs/storage'
|
|
5
6
|
import { log, runCommand } from '@stacksjs/cli'
|
|
6
7
|
import { ExitCode } from '@stacksjs/types'
|
|
7
8
|
import type { CLI, CliOptions } from '@stacksjs/types'
|
package/src/commands/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
3
3
|
import { generateTypes } from '@stacksjs/actions'
|
|
4
|
-
import { log } from '
|
|
4
|
+
import { log } from '@stacksjs/logging'
|
|
5
5
|
|
|
6
6
|
export function types(buddy: CLI) {
|
|
7
7
|
const descriptions = {
|