@stacksjs/buddy 0.58.72 → 0.58.73
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-1a569f35f66ae151.js +10945 -0
- package/dist/{chunk-59a9de11428ba763.js → chunk-bf054cfbc9cf2201.js} +4 -4
- package/dist/cli.js +27 -610
- package/dist/index.js +8 -2
- package/dist/stacks +0 -0
- package/package.json +3 -3
- package/src/cli.ts +20 -20
- package/src/commands/check.ts +45 -0
- package/src/commands/create.ts +6 -0
- package/src/commands/generate.ts +10 -0
- package/src/commands/index.ts +3 -0
- package/src/commands/ports.ts +73 -0
- package/src/commands/projects.ts +59 -0
- package/src/commands/setup.ts +8 -54
- package/src/commands/upgrade.ts +51 -4
- package/dist/chunk-94f0ae38d2d27d78.js +0 -1932
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
build,
|
|
4
4
|
changelog,
|
|
5
|
+
check,
|
|
5
6
|
clean,
|
|
6
7
|
cloud,
|
|
7
8
|
commit,
|
|
@@ -22,7 +23,9 @@ list,
|
|
|
22
23
|
make,
|
|
23
24
|
migrate,
|
|
24
25
|
optimizePkgxDeps,
|
|
26
|
+
ports,
|
|
25
27
|
prepublish,
|
|
28
|
+
projects,
|
|
26
29
|
release,
|
|
27
30
|
seed,
|
|
28
31
|
setup,
|
|
@@ -32,9 +35,9 @@ tinker,
|
|
|
32
35
|
types,
|
|
33
36
|
upgrade,
|
|
34
37
|
version
|
|
35
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-1a569f35f66ae151.js";
|
|
36
39
|
import"./chunk-0455e53fab4244b1.js";
|
|
37
|
-
import"./chunk-
|
|
40
|
+
import"./chunk-bf054cfbc9cf2201.js";
|
|
38
41
|
export {
|
|
39
42
|
version,
|
|
40
43
|
upgrade,
|
|
@@ -45,7 +48,9 @@ export {
|
|
|
45
48
|
setup,
|
|
46
49
|
seed,
|
|
47
50
|
release,
|
|
51
|
+
projects,
|
|
48
52
|
prepublish,
|
|
53
|
+
ports,
|
|
49
54
|
optimizePkgxDeps,
|
|
50
55
|
migrate,
|
|
51
56
|
make,
|
|
@@ -66,6 +71,7 @@ export {
|
|
|
66
71
|
commit,
|
|
67
72
|
cloud,
|
|
68
73
|
clean,
|
|
74
|
+
check,
|
|
69
75
|
changelog,
|
|
70
76
|
build
|
|
71
77
|
};
|
package/dist/stacks
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/buddy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.58.
|
|
4
|
+
"version": "0.58.73",
|
|
5
5
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
],
|
|
67
67
|
"scripts": {
|
|
68
68
|
"buddy": "bunx ./src/cli.ts",
|
|
69
|
-
"build": "bun --bun build.ts",
|
|
70
|
-
"compile": "bun
|
|
69
|
+
"build": "bun --bun build.ts && bun run compile",
|
|
70
|
+
"compile": "bun compile.ts",
|
|
71
71
|
"typecheck": "bun --bun tsc --noEmit",
|
|
72
72
|
"prepublishOnly": "bun --bun run build"
|
|
73
73
|
},
|
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
|
-
import {
|
|
2
|
+
import { log } from '@stacksjs/logging'
|
|
3
3
|
import { CAC } from 'cac'
|
|
4
4
|
import { ensureProjectIsInitialized } from '@stacksjs/utils'
|
|
5
5
|
import { path as p } from '@stacksjs/path'
|
|
@@ -8,25 +8,17 @@ import * as cmd from './commands'
|
|
|
8
8
|
|
|
9
9
|
// setup global error handlers
|
|
10
10
|
process.on('uncaughtException', (error: Error) => {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
log.debug('uncaughtException')
|
|
12
|
+
log.error(error)
|
|
13
13
|
process.exit(1)
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
process.on('
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
process.on('unhandledRejection', (error: Error) => {
|
|
17
|
+
log.debug('unhandledRejection')
|
|
18
|
+
log.error(error)
|
|
19
19
|
process.exit(1)
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
// process.on('unhandledRejection', errorHandler)
|
|
23
|
-
|
|
24
|
-
// function errorHandler(error: Error) {
|
|
25
|
-
// console.error('An error occurred:', error.message)
|
|
26
|
-
// log.error(error.message)
|
|
27
|
-
// process.exit(1)
|
|
28
|
-
// }
|
|
29
|
-
|
|
30
22
|
async function main() {
|
|
31
23
|
// const buddy = cli('buddy')
|
|
32
24
|
const buddy = new CAC('buddy')
|
|
@@ -40,6 +32,7 @@ async function main() {
|
|
|
40
32
|
|
|
41
33
|
cmd.build(buddy)
|
|
42
34
|
cmd.changelog(buddy)
|
|
35
|
+
cmd.check(buddy)
|
|
43
36
|
cmd.clean(buddy)
|
|
44
37
|
cmd.cloud(buddy)
|
|
45
38
|
// cmd.commit(buddy)
|
|
@@ -48,6 +41,8 @@ async function main() {
|
|
|
48
41
|
cmd.domains(buddy)
|
|
49
42
|
cmd.deploy(buddy)
|
|
50
43
|
cmd.dns(buddy)
|
|
44
|
+
cmd.ports(buddy)
|
|
45
|
+
cmd.projects(buddy)
|
|
51
46
|
cmd.fresh(buddy)
|
|
52
47
|
cmd.generate(buddy)
|
|
53
48
|
cmd.http(buddy)
|
|
@@ -61,10 +56,20 @@ async function main() {
|
|
|
61
56
|
cmd.setup(buddy)
|
|
62
57
|
// cmd.example(buddy)
|
|
63
58
|
// cmd.test(buddy)
|
|
64
|
-
|
|
59
|
+
cmd.version(buddy)
|
|
65
60
|
// cmd.prepublish(buddy)
|
|
66
61
|
cmd.upgrade(buddy)
|
|
67
62
|
|
|
63
|
+
// dynamic imports
|
|
64
|
+
await dynamicImports(buddy)
|
|
65
|
+
|
|
66
|
+
buddy.help()
|
|
67
|
+
buddy.parse()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await main()
|
|
71
|
+
|
|
72
|
+
async function dynamicImports(buddy: CAC) {
|
|
68
73
|
// dynamically import and register commands from ./app/Commands/*
|
|
69
74
|
const commandsDir = p.appPath('Commands')
|
|
70
75
|
const commandFiles = fs.readdirSync(commandsDir).filter(file => file.endsWith('.ts'))
|
|
@@ -83,9 +88,4 @@ async function main() {
|
|
|
83
88
|
const listenerImport = await import(p.listenersPath('Console.ts'))
|
|
84
89
|
if (typeof listenerImport.default === 'function')
|
|
85
90
|
listenerImport.default(buddy)
|
|
86
|
-
|
|
87
|
-
buddy.help()
|
|
88
|
-
buddy.parse()
|
|
89
91
|
}
|
|
90
|
-
|
|
91
|
-
await main()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, CheckOptions } from '@stacksjs/types'
|
|
3
|
+
import { ExitCode } from '@stacksjs/types'
|
|
4
|
+
import { Action } from '@stacksjs/enums'
|
|
5
|
+
import { runAction } from '@stacksjs/actions'
|
|
6
|
+
import { log } from 'stacks/logging'
|
|
7
|
+
import { intro, outro } from 'stacks/cli'
|
|
8
|
+
|
|
9
|
+
export function check(buddy: CLI) {
|
|
10
|
+
const descriptions = {
|
|
11
|
+
command: 'Let buddy check your project for potential issues and misconfigurations',
|
|
12
|
+
ports: 'Check if the ports are available',
|
|
13
|
+
project: 'Target a specific project',
|
|
14
|
+
verbose: 'Enable verbose output',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buddy
|
|
18
|
+
.command('check [type]', descriptions.command)
|
|
19
|
+
.option('--ports', descriptions.ports)
|
|
20
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
21
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
22
|
+
.action(async (type: string | undefined, options: CheckOptions) => {
|
|
23
|
+
log.debug('Running `buddy check [type]` ...', options)
|
|
24
|
+
|
|
25
|
+
const perf = await intro('buddy check [type]')
|
|
26
|
+
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'ports':
|
|
29
|
+
await runAction(Action.CheckPorts)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (options.ports)
|
|
34
|
+
await runAction(Action.CheckPorts, options)
|
|
35
|
+
|
|
36
|
+
// await runAction(Action.Prepublish, options)
|
|
37
|
+
await outro('Exited', { startTime: perf, useSeconds: true })
|
|
38
|
+
process.exit(ExitCode.Success)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
buddy.on('check:*', () => {
|
|
42
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
43
|
+
process.exit(1)
|
|
44
|
+
})
|
|
45
|
+
}
|
package/src/commands/create.ts
CHANGED
|
@@ -19,12 +19,16 @@ export function create(buddy: CLI) {
|
|
|
19
19
|
functions: 'Are you developing functions/composables?',
|
|
20
20
|
api: 'Are you building an API?',
|
|
21
21
|
database: 'Do you need a database?',
|
|
22
|
+
notifications: 'Do you need notifications? e.g. email, SMS, push or chat notifications',
|
|
23
|
+
cache: 'Do you need caching?',
|
|
24
|
+
email: 'Do you need email?',
|
|
22
25
|
project: 'Target a specific project',
|
|
23
26
|
verbose: 'Enable verbose output',
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
buddy
|
|
27
30
|
.command('new <name>', descriptions.command)
|
|
31
|
+
.alias('create <name>')
|
|
28
32
|
.option('-u, --ui', descriptions.ui, { default: true }) // if no, disregard remainder of questions wrt UI
|
|
29
33
|
.option('-c, --components', descriptions.components, { default: true }) // if no, -v and -w would be false
|
|
30
34
|
.option('-w, --web-components', descriptions.webComponents, { default: true })
|
|
@@ -33,6 +37,8 @@ export function create(buddy: CLI) {
|
|
|
33
37
|
.option('-f, --functions', descriptions.functions, { default: true }) // if no, API would be false
|
|
34
38
|
.option('-a, --api', descriptions.api, { default: true }) // APIs need an HTTP server & assumes functions is true
|
|
35
39
|
.option('-d, --database', descriptions.database, { default: true })
|
|
40
|
+
.option('-ca, --cache', descriptions.cache, { default: false })
|
|
41
|
+
.option('-e, --email', descriptions.email, { default: false })
|
|
36
42
|
.option('-p, --project', descriptions.project, { default: false })
|
|
37
43
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
38
44
|
// .option('--auth', 'Scaffold an authentication?', { default: true })
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import {
|
|
3
3
|
generateComponentMeta,
|
|
4
|
+
generateCoreSymlink,
|
|
4
5
|
generateIdeHelpers,
|
|
5
6
|
generateLibEntries,
|
|
6
7
|
generateMigrations,
|
|
@@ -22,6 +23,7 @@ export function generate(buddy: CLI) {
|
|
|
22
23
|
customData: 'Generate VS Code custom data (custom-elements.json) for IDEs',
|
|
23
24
|
ideHelpers: 'Generate IDE helpers',
|
|
24
25
|
componentMeta: 'Generate component meta information',
|
|
26
|
+
coreSymlink: 'Generate symlink of the core framework to the project root',
|
|
25
27
|
pkgx: 'Generate the pkgx configuration file',
|
|
26
28
|
select: 'What are you trying to generate?',
|
|
27
29
|
project: 'Target a specific project',
|
|
@@ -38,6 +40,7 @@ export function generate(buddy: CLI) {
|
|
|
38
40
|
.option('-c, --component-meta', descriptions.componentMeta)
|
|
39
41
|
.option('-p, --pkgx', descriptions.pkgx)
|
|
40
42
|
.option('-p, --project', descriptions.project, { default: false })
|
|
43
|
+
.option('--core-symlink', descriptions.coreSymlink)
|
|
41
44
|
.option('--verbose', descriptions.verbose, { default: false })
|
|
42
45
|
.action(async (options: GeneratorOptions) => {
|
|
43
46
|
log.debug('Running `buddy generate` ...', options)
|
|
@@ -139,6 +142,13 @@ export function generate(buddy: CLI) {
|
|
|
139
142
|
generateMigrations()
|
|
140
143
|
})
|
|
141
144
|
|
|
145
|
+
buddy
|
|
146
|
+
.command('generate:core-symlink', 'Generate core symlink. A shortcut for core developers.')
|
|
147
|
+
.action(async (options: GeneratorOptions) => {
|
|
148
|
+
log.debug('Running `buddy core-symlink` ...', options)
|
|
149
|
+
await generateCoreSymlink()
|
|
150
|
+
})
|
|
151
|
+
|
|
142
152
|
buddy.on('generate:*', () => {
|
|
143
153
|
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
144
154
|
process.exit(1)
|
package/src/commands/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './build'
|
|
2
2
|
export * from './changelog'
|
|
3
|
+
export * from './check'
|
|
3
4
|
export * from './clean'
|
|
4
5
|
export * from './cloud'
|
|
5
6
|
export * from './commit'
|
|
@@ -18,7 +19,9 @@ export * from './install'
|
|
|
18
19
|
export * from './key'
|
|
19
20
|
export * from './make'
|
|
20
21
|
export * from './migrate'
|
|
22
|
+
export * from './ports'
|
|
21
23
|
export * from './prepublish'
|
|
24
|
+
export * from './projects'
|
|
22
25
|
export * from './release'
|
|
23
26
|
export * from './seed'
|
|
24
27
|
export * from './setup'
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, CheckOptions } 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 { $ } from 'bun'
|
|
7
|
+
import { intro, italic, outro } from 'stacks/cli'
|
|
8
|
+
|
|
9
|
+
export function ports(buddy: CLI) {
|
|
10
|
+
const descriptions = {
|
|
11
|
+
command: 'Let buddy check your project for potential issues and misconfigurations',
|
|
12
|
+
ports: 'Check if the ports are available',
|
|
13
|
+
project: 'Target a specific project',
|
|
14
|
+
verbose: 'Enable verbose output',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buddy
|
|
18
|
+
.command('ports', descriptions.command)
|
|
19
|
+
.option('-p, --project [name]', descriptions.project, { default: '' })
|
|
20
|
+
.option('-q, --quiet', 'Use minimal output', { default: false })
|
|
21
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
22
|
+
.action(async (options: CheckOptions) => {
|
|
23
|
+
log.debug('Running `buddy ports` ...', options)
|
|
24
|
+
|
|
25
|
+
let perf
|
|
26
|
+
if (!options.quiet)
|
|
27
|
+
perf = await intro('buddy ports')
|
|
28
|
+
|
|
29
|
+
if (options.project) {
|
|
30
|
+
if (!options.quiet)
|
|
31
|
+
log.info(`Checking ports for project: ${italic(options.project)}`)
|
|
32
|
+
|
|
33
|
+
const projectList = await $`./buddy projects:list --quiet`.text()
|
|
34
|
+
log.debug('projectList', projectList)
|
|
35
|
+
|
|
36
|
+
const projects = projectList.split('\n').filter(line => line.startsWith(' - ')).map(line => line.trim().substring(4))
|
|
37
|
+
log.debug('projects', projects)
|
|
38
|
+
|
|
39
|
+
const projectPath = projects.find(project => project.includes(options.project as string)) || ''
|
|
40
|
+
log.debug('projectPath', projectPath)
|
|
41
|
+
|
|
42
|
+
$.cwd(projectPath.startsWith('/') ? projectPath : `/${projectPath}`)
|
|
43
|
+
|
|
44
|
+
const res = (await $`./buddy ports --quiet`.text()).trim()
|
|
45
|
+
log.debug(`./buddy ports --quiet response for ${projectPath}`, res)
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log('')
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log(res)
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
|
+
console.log('')
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log('')
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.log(projectPorts)
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.log('')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!options.quiet)
|
|
64
|
+
await outro('Exited', { startTime: perf, useSeconds: true })
|
|
65
|
+
|
|
66
|
+
process.exit(ExitCode.Success)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
buddy.on('ports:*', () => {
|
|
70
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
71
|
+
process.exit(1)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
await intro('buddy projects:list')
|
|
42
|
+
|
|
43
|
+
if (!options.quiet)
|
|
44
|
+
await intro('buddy projects')
|
|
45
|
+
|
|
46
|
+
const projects = await findStacksProjects(undefined, options)
|
|
47
|
+
|
|
48
|
+
for (const project of projects)
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log(' - ', project)
|
|
51
|
+
|
|
52
|
+
process.exit(ExitCode.Success)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
buddy.on('projects:*', () => {
|
|
56
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
57
|
+
process.exit(1)
|
|
58
|
+
})
|
|
59
|
+
}
|
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/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
|
}
|