@stacksjs/buddy 0.58.72 → 0.59.1
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-94f0ae38d2d27d78.js → chunk-32440b2561f1e29c.js} +568 -485
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +44 -613
- 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 +6 -3
- package/dist/stacks +0 -0
- package/package.json +3 -5
- package/src/cli.ts +36 -31
- package/src/commands/add.ts +1 -1
- package/src/commands/commit.ts +1 -1
- package/src/commands/create.ts +6 -0
- package/src/commands/deploy.ts +1 -1
- package/src/commands/dev.ts +1 -3
- package/src/commands/generate.ts +10 -0
- package/src/commands/index.ts +2 -0
- 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 +180 -0
- package/src/commands/prepublish.ts +1 -1
- package/src/commands/projects.ts +58 -0
- package/src/commands/setup.ts +8 -54
- package/src/commands/types.ts +1 -1
- package/src/commands/upgrade.ts +51 -4
- package/dist/chunk-59a9de11428ba763.js +0 -993
- /package/dist/{chunk-0455e53fab4244b1.js → chunk-970e033f764e29fc.js} +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, Ports, PortsOptions } from '@stacksjs/types'
|
|
3
|
+
import { ExitCode } from '@stacksjs/types'
|
|
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 { $ } from 'bun'
|
|
8
|
+
import { intro, italic, outro } from '@stacksjs/cli'
|
|
9
|
+
import { findStacksProjects } from '@stacksjs/utils'
|
|
10
|
+
|
|
11
|
+
export function ports(buddy: CLI) {
|
|
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', { default: false })
|
|
23
|
+
.option('-p, --project [name]', descriptions.project, { default: undefined })
|
|
24
|
+
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
25
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
26
|
+
.action(async (options: PortsOptions) => {
|
|
27
|
+
log.debug('Running `buddy ports` ...', options)
|
|
28
|
+
|
|
29
|
+
let perf
|
|
30
|
+
if (!options.quiet)
|
|
31
|
+
perf = await intro('buddy ports')
|
|
32
|
+
|
|
33
|
+
if (options.project) {
|
|
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)
|
|
39
|
+
|
|
40
|
+
outputPorts(ports, options)
|
|
41
|
+
}
|
|
42
|
+
|
|
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 })
|
|
50
|
+
|
|
51
|
+
process.exit(ExitCode.Success)
|
|
52
|
+
})
|
|
53
|
+
|
|
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)
|
|
61
|
+
|
|
62
|
+
let perf
|
|
63
|
+
if (!options.quiet)
|
|
64
|
+
perf = await intro('buddy ports:list')
|
|
65
|
+
|
|
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)
|
|
78
|
+
}
|
|
79
|
+
// return the used ports for all projects
|
|
80
|
+
else {
|
|
81
|
+
outputPorts(projectPorts, options)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!options.quiet)
|
|
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 })
|
|
117
|
+
|
|
118
|
+
process.exit(ExitCode.Success)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
buddy.on('ports:*', () => {
|
|
122
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
123
|
+
process.exit(1)
|
|
124
|
+
})
|
|
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 = {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import type { CLI, ProjectsOptions } from '@stacksjs/types'
|
|
4
|
+
import { intro, log } from '@stacksjs/cli'
|
|
5
|
+
import { findStacksProjects } from '@stacksjs/utils'
|
|
6
|
+
|
|
7
|
+
export function projects(buddy: CLI) {
|
|
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)
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log(' - ', project)
|
|
29
|
+
|
|
30
|
+
process.exit(ExitCode.Success)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
buddy
|
|
34
|
+
.command('projects:list', descriptions.projects)
|
|
35
|
+
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
36
|
+
.option('-l, --list', 'List all local Stacks projects', { default: true })
|
|
37
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
38
|
+
.action(async (options: ProjectsOptions) => {
|
|
39
|
+
log.debug('Running `buddy projects` ...', options)
|
|
40
|
+
|
|
41
|
+
if (!options.quiet)
|
|
42
|
+
await intro('buddy projects:list')
|
|
43
|
+
|
|
44
|
+
// uses os.homedir() as the default path
|
|
45
|
+
const projects = await findStacksProjects(undefined, options)
|
|
46
|
+
|
|
47
|
+
for (const project of projects)
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.log(' - ', project)
|
|
50
|
+
|
|
51
|
+
process.exit(ExitCode.Success)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
buddy.on('projects:*', () => {
|
|
55
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
56
|
+
process.exit(1)
|
|
57
|
+
})
|
|
58
|
+
}
|
package/src/commands/setup.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import { path as p } from '@stacksjs/path'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
3
4
|
import { handleError } from '@stacksjs/error-handling'
|
|
4
|
-
import { writeFile } from '@stacksjs/storage'
|
|
5
5
|
import { log, runCommand } from '@stacksjs/cli'
|
|
6
6
|
import { ExitCode } from '@stacksjs/types'
|
|
7
7
|
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
8
|
-
import { $ } from 'bun'
|
|
9
8
|
|
|
10
9
|
export function setup(buddy: CLI) {
|
|
11
10
|
const descriptions = {
|
|
@@ -30,6 +29,9 @@ export function setup(buddy: CLI) {
|
|
|
30
29
|
// ensure the minimal amount of deps are written to ./pkgx.yaml
|
|
31
30
|
await optimizePkgxDeps()
|
|
32
31
|
|
|
32
|
+
// TODO: optimizeConfigDir()
|
|
33
|
+
// TODO: optimizeAddDir()
|
|
34
|
+
|
|
33
35
|
await initializeProject(options)
|
|
34
36
|
})
|
|
35
37
|
|
|
@@ -39,60 +41,12 @@ export function setup(buddy: CLI) {
|
|
|
39
41
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
40
42
|
.action(async (_options?: CliOptions) => {
|
|
41
43
|
log.debug('Running `buddy setup:oh-my-zsh` ...', _options)
|
|
44
|
+
const result = await runAction(Action.UpgradeShell)
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const customPath = p.join(homePath, '.oh-my-zsh/custom/plugins/buddy/')
|
|
47
|
-
|
|
48
|
-
log.info(`Setting up Oh My Zsh via ${zshrcPath}...`)
|
|
49
|
-
$.cwd(p.dirname(zshrcPath))
|
|
50
|
-
let data = await $`cat ${p.basename(zshrcPath)}`.text()
|
|
51
|
-
|
|
52
|
-
// Manipulate the data
|
|
53
|
-
const pluginLineRegex = /^(?!#).*plugins=\(([^)]+)\)/m // ensure it's not a comment
|
|
54
|
-
const match = data.match(pluginLineRegex)
|
|
55
|
-
|
|
56
|
-
if (match) {
|
|
57
|
-
// 1. Find the plugins line
|
|
58
|
-
const plugins = match[1]?.split(' ')
|
|
59
|
-
if (!plugins) {
|
|
60
|
-
log.error('Maybe the plugins line in your .zshrc file could not be found? If this continues being an issue, please reach out to us on Discord.')
|
|
61
|
-
process.exit(ExitCode.FatalError)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 2. Add buddy to the list of plugins if it's not already there
|
|
65
|
-
if (!plugins.includes('buddy')) {
|
|
66
|
-
plugins.push('buddy')
|
|
67
|
-
const newPluginLine = `plugins=(${plugins.join(' ')})`
|
|
68
|
-
// 3. Replace the old plugin line with the new one
|
|
69
|
-
data = data.replace(pluginLineRegex, newPluginLine)
|
|
70
|
-
// 4. Write the data back to the file
|
|
71
|
-
await writeFile(zshrcPath, data)
|
|
72
|
-
|
|
73
|
-
// need to copy plugin to ~/.oh-my-zsh/custom/plugins
|
|
74
|
-
log.info(`Copying buddy zsh plugin ${pluginPath} to ${customPath}...`)
|
|
75
|
-
|
|
76
|
-
// create customPath if it doesn't exist
|
|
77
|
-
await runCommand(`mkdir -p ${customPath}`)
|
|
78
|
-
await runCommand(`cp -rf ${pluginPath} ${customPath}`)
|
|
79
|
-
// await runCommand(`source ${customPath}/buddy.plugin.zsh`)
|
|
80
|
-
|
|
81
|
-
log.success('Copied buddy zsh plugin')
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
log.info('Buddy is already integrated in your shell, ensuring it is updated...')
|
|
85
|
-
await runCommand(`cp -rf ${pluginPath} ${customPath}`)
|
|
86
|
-
// await runCommand(`source ${customPath}/buddy.plugin.zsh`)
|
|
87
|
-
log.success('Updated buddy zsh plugin to latest version')
|
|
88
|
-
}
|
|
46
|
+
if (result.isErr()) {
|
|
47
|
+
log.error(result.error)
|
|
48
|
+
process.exit(ExitCode.FatalError)
|
|
89
49
|
}
|
|
90
|
-
|
|
91
|
-
log.success('Oh My Zsh Setup Complete')
|
|
92
|
-
log.info('To see changes reflect, you may need to open a new terminal window')
|
|
93
|
-
// if using the vscode terminal, show the message
|
|
94
|
-
if (process.env.TERM_PROGRAM === 'vscode')
|
|
95
|
-
log.info('⌘⇧P terminal.create.new.terminal')
|
|
96
50
|
})
|
|
97
51
|
|
|
98
52
|
buddy.on('setup:*', () => {
|
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 = {
|
package/src/commands/upgrade.ts
CHANGED
|
@@ -11,6 +11,8 @@ export function upgrade(buddy: CLI) {
|
|
|
11
11
|
framework: 'Upgrade the Stacks framework',
|
|
12
12
|
dependencies: 'Upgrade your dependencies (pkgx.yaml & package.json)',
|
|
13
13
|
bun: 'Upgrade Bun to the latest version',
|
|
14
|
+
shell: 'Upgrade the to the latest shell integration (currently only supports Oh My Zsh)',
|
|
15
|
+
binary: 'Upgrade the `stacks` binary to the latest version. Please note, the binary is moved to the `~/.stacks/bin` directory',
|
|
14
16
|
all: 'Upgrade Node, package manager, project dependencies, and framework',
|
|
15
17
|
force: 'Overwrite possible local updates with remote framework updates',
|
|
16
18
|
select: 'What are you trying to upgrade?',
|
|
@@ -20,12 +22,15 @@ export function upgrade(buddy: CLI) {
|
|
|
20
22
|
|
|
21
23
|
buddy
|
|
22
24
|
.command('upgrade', descriptions.command)
|
|
23
|
-
.option('-c, --framework', descriptions.framework, { default: false })
|
|
24
25
|
.option('-d, --dependencies', descriptions.dependencies, { default: false })
|
|
25
26
|
.option('-b, --bun', descriptions.bun, { default: false })
|
|
26
27
|
.option('-a, --all', descriptions.all, { default: false })
|
|
27
28
|
.option('-f, --force', descriptions.force, { default: false })
|
|
29
|
+
.option('--framework', descriptions.framework, { default: false })
|
|
28
30
|
.option('-p, --project', descriptions.project, { default: false })
|
|
31
|
+
.option('-s, --shell', descriptions.shell, { default: false })
|
|
32
|
+
.option('-b, --binary', descriptions.binary, { default: false })
|
|
33
|
+
// .option('--canary', descriptions.canary, { default: false })
|
|
29
34
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
30
35
|
.alias('update')
|
|
31
36
|
.example('buddy upgrade -a --verbose')
|
|
@@ -40,8 +45,9 @@ export function upgrade(buddy: CLI) {
|
|
|
40
45
|
options: [
|
|
41
46
|
{ value: 'dependencies', label: 'Dependencies' },
|
|
42
47
|
{ value: 'framework', label: 'Framework' },
|
|
43
|
-
{ value: '
|
|
44
|
-
{ value: '
|
|
48
|
+
{ value: 'bun', label: 'Bun' },
|
|
49
|
+
{ value: 'shell', label: 'Shell' },
|
|
50
|
+
{ value: 'binary', label: 'Binary' },
|
|
45
51
|
],
|
|
46
52
|
})
|
|
47
53
|
|
|
@@ -115,6 +121,47 @@ export function upgrade(buddy: CLI) {
|
|
|
115
121
|
await runAction(Action.Upgrade, options)
|
|
116
122
|
})
|
|
117
123
|
|
|
124
|
+
buddy
|
|
125
|
+
.command('upgrade:shell', descriptions.shell)
|
|
126
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
127
|
+
.example('buddy upgrade:shell')
|
|
128
|
+
.action(async (options: UpgradeOptions) => {
|
|
129
|
+
log.debug('Running `buddy upgrade:shell` ...', options)
|
|
130
|
+
|
|
131
|
+
const perf = await intro('buddy upgrade:shell')
|
|
132
|
+
const result = await runAction(Action.UpgradeShell, options)
|
|
133
|
+
|
|
134
|
+
if (result.isErr()) {
|
|
135
|
+
await outro('While running the buddy upgrade:shell command, there was an issue', { startTime: perf, useSeconds: true }, result.error) // FIXME: should not have to cast
|
|
136
|
+
process.exit()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
process.exit(ExitCode.Success)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
buddy
|
|
143
|
+
.command('upgrade:binary', descriptions.binary)
|
|
144
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
145
|
+
.example('buddy upgrade:binary')
|
|
146
|
+
.action(async (options: UpgradeOptions) => {
|
|
147
|
+
if (process.getuid && process.getuid() !== 0) {
|
|
148
|
+
log.warn('To upgrade the binary, you need to run this command with sudo, or as root.')
|
|
149
|
+
process.exit(0) // Exit with an error code
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
log.debug('Running `buddy upgrade:binary` ...', options)
|
|
153
|
+
|
|
154
|
+
const perf = await intro('buddy upgrade:binary')
|
|
155
|
+
const result = await runAction(Action.UpgradeBinary, options)
|
|
156
|
+
|
|
157
|
+
if (result.isErr()) {
|
|
158
|
+
await outro('While running the buddy upgrade:binary command, there was an issue', { startTime: perf, useSeconds: true }, result.error) // FIXME: should not have to cast
|
|
159
|
+
process.exit()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
process.exit(ExitCode.Success)
|
|
163
|
+
})
|
|
164
|
+
|
|
118
165
|
buddy.on('upgrade:*', () => {
|
|
119
166
|
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
120
167
|
process.exit(1)
|
|
@@ -122,5 +169,5 @@ export function upgrade(buddy: CLI) {
|
|
|
122
169
|
}
|
|
123
170
|
|
|
124
171
|
function hasNoOptions(options: UpgradeOptions) {
|
|
125
|
-
return !options.framework && !options.dependencies && !options.
|
|
172
|
+
return !options.framework && !options.dependencies && !options.bun && !options.shell && !options.binary && !options.all
|
|
126
173
|
}
|