@stacksjs/buddy 0.58.48 → 0.58.49
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/package.json +3 -2
- package/src/cli.ts +50 -0
- package/src/commands/add.ts +69 -0
- package/src/commands/build.ts +228 -0
- package/src/commands/changelog.ts +38 -0
- package/src/commands/clean.ts +36 -0
- package/src/commands/cloud.ts +305 -0
- package/src/commands/commit.ts +24 -0
- package/src/commands/configure.ts +68 -0
- package/src/commands/create.ts +131 -0
- package/src/commands/deploy.ts +100 -0
- package/src/commands/dev.ts +268 -0
- package/src/commands/dns.ts +80 -0
- package/src/commands/domains.ts +158 -0
- package/src/commands/example.ts +66 -0
- package/src/commands/fresh.ts +36 -0
- package/src/commands/generate.ts +140 -0
- package/src/commands/http.ts +55 -0
- package/src/commands/index.ts +30 -0
- package/src/commands/inspire.ts +24 -0
- package/src/commands/install.ts +28 -0
- package/src/commands/key.ts +34 -0
- package/src/commands/lint.ts +53 -0
- package/src/commands/make.ts +269 -0
- package/src/commands/migrate.ts +58 -0
- package/src/commands/prepublish.ts +25 -0
- package/src/commands/release.ts +35 -0
- package/src/commands/seed.ts +38 -0
- package/src/commands/setup.ts +115 -0
- package/src/commands/test.ts +124 -0
- package/src/commands/tinker.ts +36 -0
- package/src/commands/types.ts +33 -0
- package/src/commands/upgrade.ts +115 -0
- package/src/commands/version.ts +24 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import type { CLI, MigrateOptions } from '@stacksjs/types'
|
|
4
|
+
import { runAction } from '@stacksjs/actions'
|
|
5
|
+
import { intro, outro } from '@stacksjs/cli'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
|
|
8
|
+
export function migrate(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
migrate: 'Migrates your database',
|
|
11
|
+
dns: 'Writes the DNS records for a domain to ./config/dns.ts',
|
|
12
|
+
project: 'Target a specific project',
|
|
13
|
+
verbose: 'Enable verbose output',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
buddy
|
|
17
|
+
.command('migrate', descriptions.migrate)
|
|
18
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
19
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
20
|
+
.action(async (options: MigrateOptions) => {
|
|
21
|
+
const perf = await intro('buddy migrate')
|
|
22
|
+
const result = await runAction(Action.Migrate, { ...options })
|
|
23
|
+
|
|
24
|
+
if (result.isErr()) {
|
|
25
|
+
await outro('While running the migrate command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
26
|
+
process.exit()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const APP_ENV = process.env.APP_ENV || 'local'
|
|
30
|
+
|
|
31
|
+
await outro(`Migrated your ${APP_ENV} database.`, { startTime: perf, useSeconds: true })
|
|
32
|
+
process.exit(ExitCode.Success)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
buddy
|
|
36
|
+
.command('migrate:dns', descriptions.migrate)
|
|
37
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
38
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
39
|
+
.action(async (options: MigrateOptions) => {
|
|
40
|
+
const perf = await intro('buddy migrate')
|
|
41
|
+
const result = await runAction(Action.MigrateDns, { ...options })
|
|
42
|
+
|
|
43
|
+
if (result.isErr()) {
|
|
44
|
+
await outro('While running the migrate:dns command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
45
|
+
process.exit()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const APP_URL = process.env.APP_URL || 'undefined'
|
|
49
|
+
|
|
50
|
+
await outro(`Migrated your ${APP_URL} DNS.`, { startTime: perf, useSeconds: true })
|
|
51
|
+
process.exit(ExitCode.Success)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
buddy.on('migrate:*', () => {
|
|
55
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
56
|
+
process.exit(1)
|
|
57
|
+
})
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, PrepublishOptions } from '@stacksjs/types'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
4
|
+
import { runAction } from '@stacksjs/actions'
|
|
5
|
+
|
|
6
|
+
export function prepublish(buddy: CLI) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
command: 'Run your prepublish script',
|
|
9
|
+
project: 'Target a specific project',
|
|
10
|
+
verbose: 'Enable verbose output',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
buddy
|
|
14
|
+
.command('prepublish', descriptions.command)
|
|
15
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
16
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
17
|
+
.action(async (options: PrepublishOptions) => {
|
|
18
|
+
await runAction(Action.Prepublish, options)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
buddy.on('prepublish:*', () => {
|
|
22
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
23
|
+
process.exit(1)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { Action } from '@stacksjs/enums'
|
|
3
|
+
import { ExitCode } from '@stacksjs/types'
|
|
4
|
+
import type { CLI, ReleaseOptions } from '@stacksjs/types'
|
|
5
|
+
import { intro, log, outro } from '@stacksjs/cli'
|
|
6
|
+
import { runAction } from '@stacksjs/actions'
|
|
7
|
+
|
|
8
|
+
const descriptions = {
|
|
9
|
+
release: 'Release a new version of your libraries/packages',
|
|
10
|
+
project: 'Target a specific project',
|
|
11
|
+
verbose: 'Enable verbose output',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function release(buddy: CLI) {
|
|
15
|
+
buddy
|
|
16
|
+
.command('release', descriptions.release)
|
|
17
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
18
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
|
+
.action(async (options: ReleaseOptions) => {
|
|
20
|
+
const startTime = await intro('buddy release')
|
|
21
|
+
const result = await runAction(Action.Release, { ...options, stdin: 'inherit' })
|
|
22
|
+
|
|
23
|
+
if (result.isErr()) {
|
|
24
|
+
log.error('Failed to release', result.error)
|
|
25
|
+
process.exit(ExitCode.FatalError)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await outro('Triggered your CI/CD release workflow', { startTime, useSeconds: true })
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
buddy.on('release:*', () => {
|
|
32
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
33
|
+
process.exit(1)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import type { CLI, SeedOptions } from '@stacksjs/types'
|
|
4
|
+
import { runAction } from '@stacksjs/actions'
|
|
5
|
+
import { intro, outro } from '@stacksjs/cli'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
|
|
8
|
+
export function seed(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
seed: 'Seed your database',
|
|
11
|
+
project: 'Target a specific project',
|
|
12
|
+
verbose: 'Enable verbose output',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
buddy
|
|
16
|
+
.command('seed', descriptions.seed)
|
|
17
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
18
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
|
+
.action(async (options: SeedOptions) => {
|
|
20
|
+
const perf = await intro('buddy seed')
|
|
21
|
+
const result = await runAction(Action.Seed, options)
|
|
22
|
+
|
|
23
|
+
if (result.isErr()) {
|
|
24
|
+
await outro('While running the seed command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
25
|
+
process.exit(ExitCode.FatalError)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const APP_ENV = process.env.APP_ENV || 'local'
|
|
29
|
+
|
|
30
|
+
await outro(`Seeded your ${APP_ENV} database.`, { startTime: perf, useSeconds: true })
|
|
31
|
+
process.exit(ExitCode.Success)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
buddy.on('seed:*', () => {
|
|
35
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
36
|
+
process.exit(1)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { path as p } from '@stacksjs/path'
|
|
3
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
4
|
+
import { storage } from '@stacksjs/storage'
|
|
5
|
+
import { log, runCommand } from '@stacksjs/cli'
|
|
6
|
+
import { ExitCode } from '@stacksjs/types'
|
|
7
|
+
import type { CLI, CliOptions } from '@stacksjs/types'
|
|
8
|
+
|
|
9
|
+
export function setup(buddy: CLI) {
|
|
10
|
+
const descriptions = {
|
|
11
|
+
setup: 'This command ensures your project is setup correctly',
|
|
12
|
+
project: 'Target a specific project',
|
|
13
|
+
verbose: 'Enable verbose output',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
buddy
|
|
17
|
+
.command('setup', descriptions.setup)
|
|
18
|
+
.alias('ensure')
|
|
19
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
20
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
21
|
+
.action(async (options: CliOptions) => {
|
|
22
|
+
if (!await isPkgxInstalled())
|
|
23
|
+
await installPkgx()
|
|
24
|
+
|
|
25
|
+
// ensure the minimal amount of deps are written to ./pkgx.yaml
|
|
26
|
+
await optimizePkgxDeps()
|
|
27
|
+
|
|
28
|
+
await initializeProject(options)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
buddy.on('setup:*', () => {
|
|
32
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
33
|
+
process.exit(ExitCode.FatalError)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function isPkgxInstalled(): Promise<boolean> {
|
|
38
|
+
const result = await runCommand('pkgx --version', { silent: true })
|
|
39
|
+
|
|
40
|
+
if (result.isOk())
|
|
41
|
+
return true
|
|
42
|
+
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function installPkgx(): Promise<void> {
|
|
47
|
+
const result = await runCommand(p.frameworkPath('scripts/pkgx-install'))
|
|
48
|
+
|
|
49
|
+
if (result.isOk())
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
handleError(result.error)
|
|
53
|
+
process.exit(ExitCode.FatalError)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function initializeProject(options: CliOptions): Promise<void> {
|
|
57
|
+
log.info('Installing dependencies...')
|
|
58
|
+
|
|
59
|
+
const result = await runCommand('bun install', {
|
|
60
|
+
cwd: options.cwd || p.projectPath(),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
if (result.isErr()) {
|
|
64
|
+
handleError(result.error)
|
|
65
|
+
process.exit(ExitCode.FatalError)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
log.success('Installed node_modules')
|
|
69
|
+
log.info('Ensuring .env exists...')
|
|
70
|
+
|
|
71
|
+
if (storage.doesNotExist(p.projectPath('.env'))) {
|
|
72
|
+
const envResult = await runCommand('cp .env.example .env', {
|
|
73
|
+
cwd: options.cwd || p.projectPath(),
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (envResult.isErr()) {
|
|
77
|
+
handleError(envResult.error)
|
|
78
|
+
process.exit(ExitCode.FatalError)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
log.success('.env created')
|
|
82
|
+
}
|
|
83
|
+
else { log.success('.env existed') }
|
|
84
|
+
|
|
85
|
+
const keyResult = await runCommand('buddy key:generate', {
|
|
86
|
+
cwd: options.cwd || p.projectPath(),
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
if (keyResult.isErr()) {
|
|
90
|
+
handleError(keyResult.error)
|
|
91
|
+
process.exit(ExitCode.FatalError)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
log.info('Ensuring AWS is connected...')
|
|
95
|
+
|
|
96
|
+
// const awsResult = await runCommand('buddy configure:aws', {
|
|
97
|
+
// cwd: options.cwd || p.projectPath(),
|
|
98
|
+
// })
|
|
99
|
+
|
|
100
|
+
// if (awsResult.isErr()) {
|
|
101
|
+
// handleError(awsResult.error)
|
|
102
|
+
// process.exit(ExitCode.FatalError)
|
|
103
|
+
// }
|
|
104
|
+
|
|
105
|
+
log.success('Configured AWS')
|
|
106
|
+
|
|
107
|
+
// TODO: ensure the IDE is setup by making sure .vscode etc exists, and if not, copy them over
|
|
108
|
+
|
|
109
|
+
log.success('Project is setup')
|
|
110
|
+
log.info('Happy coding! 💙')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function optimizePkgxDeps(): Promise<void> {
|
|
114
|
+
return new Promise(resolve => setTimeout(resolve, 300))
|
|
115
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, TestOptions } from '@stacksjs/types'
|
|
3
|
+
import { runAction } from '@stacksjs/actions'
|
|
4
|
+
import { intro, outro } from '@stacksjs/cli'
|
|
5
|
+
import { projectPath } from '@stacksjs/path'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
|
|
8
|
+
export function test(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
command: 'Runs your test suite',
|
|
11
|
+
types: 'Typechecks your codebase',
|
|
12
|
+
coverage: 'Generates a test coverage report',
|
|
13
|
+
ui: 'Runs your test suite in the browser',
|
|
14
|
+
unit: 'Runs your unit tests',
|
|
15
|
+
feature: 'Runs your feature tests',
|
|
16
|
+
showReport: 'Show the test report',
|
|
17
|
+
project: 'Target a specific project',
|
|
18
|
+
verbose: 'Enable verbose output',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
buddy
|
|
22
|
+
.command('test', descriptions.command)
|
|
23
|
+
.option('--ui', descriptions.ui, { default: false })
|
|
24
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
25
|
+
.option('--verbose', descriptions.verbose, { default: true })
|
|
26
|
+
.action(async (options: TestOptions) => {
|
|
27
|
+
const perf = await intro('buddy test')
|
|
28
|
+
const result = await runAction(Action.Test, { ...options, cwd: projectPath() })
|
|
29
|
+
|
|
30
|
+
if (result.isErr()) {
|
|
31
|
+
await outro('While running `buddy test`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
32
|
+
process.exit()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await outro('Finished running tests', { startTime: perf, useSeconds: true })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
buddy
|
|
39
|
+
.command('test:unit', descriptions.unit)
|
|
40
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
41
|
+
.action(async (options: TestOptions) => {
|
|
42
|
+
const perf = await intro('buddy test:unit')
|
|
43
|
+
const result = await runAction(Action.TestUnit, { ...options, verbose: true, cwd: projectPath() })
|
|
44
|
+
|
|
45
|
+
if (result.isErr()) {
|
|
46
|
+
await outro('While running `buddy test:unit`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
47
|
+
process.exit()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await outro('Finished running unit tests', { startTime: perf, useSeconds: true })
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
buddy
|
|
54
|
+
.command('test:feature', descriptions.feature)
|
|
55
|
+
.option('--show-report', descriptions.showReport, { default: false })
|
|
56
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
57
|
+
.action(async (options: TestOptions) => {
|
|
58
|
+
const perf = await intro('buddy test:feature')
|
|
59
|
+
let result
|
|
60
|
+
|
|
61
|
+
if (options.showReport)
|
|
62
|
+
result = await runAction(Action.ShowFeatureTestReport, { ...options, verbose: true, cwd: projectPath() })
|
|
63
|
+
else
|
|
64
|
+
result = await runAction(Action.TestFeature, { ...options, verbose: true, cwd: projectPath() })
|
|
65
|
+
|
|
66
|
+
if (result.isErr()) {
|
|
67
|
+
await outro('While running `buddy test:feature`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
68
|
+
process.exit()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
await outro('Finished running feature tests', { startTime: perf, useSeconds: true })
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
buddy
|
|
75
|
+
.command('test:ui', descriptions.command)
|
|
76
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
77
|
+
.action(async (options: TestOptions) => {
|
|
78
|
+
const perf = await intro('buddy test:ui')
|
|
79
|
+
const result = await runAction(Action.TestUi, { ...options, verbose: true, cwd: projectPath() })
|
|
80
|
+
|
|
81
|
+
if (result.isErr()) {
|
|
82
|
+
await outro('While running `buddy test:ui`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
83
|
+
process.exit()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
await outro('Finished running tests in the browser', { startTime: perf, useSeconds: true })
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
buddy
|
|
90
|
+
.command('test:types', descriptions.types)
|
|
91
|
+
.alias('typecheck')
|
|
92
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
93
|
+
.action(async (options: TestOptions) => {
|
|
94
|
+
const perf = await intro('buddy test:types')
|
|
95
|
+
const result = await runAction(Action.Typecheck, { ...options, verbose: true, cwd: projectPath() })
|
|
96
|
+
|
|
97
|
+
if (result.isErr()) {
|
|
98
|
+
await outro('While running `buddy test:types`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
99
|
+
process.exit()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await outro('Finished running typecheck', { startTime: perf, useSeconds: true })
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
buddy
|
|
106
|
+
.command('test:coverage', descriptions.coverage)
|
|
107
|
+
.action(async (options: TestOptions) => {
|
|
108
|
+
const perf = await intro('buddy test:coverage')
|
|
109
|
+
const result = await runAction(Action.TestCoverage, { ...options, cwd: projectPath(), verbose: true })
|
|
110
|
+
|
|
111
|
+
if (result.isErr()) {
|
|
112
|
+
await outro('While running `buddy test:coverage`, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
113
|
+
process.exit()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await outro('Generated the test coverage report', { startTime: perf, useSeconds: true })
|
|
117
|
+
process.exit()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
buddy.on('test:*', () => {
|
|
121
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
122
|
+
process.exit(1)
|
|
123
|
+
})
|
|
124
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import type { CLI, TinkerOptions } from '@stacksjs/types'
|
|
4
|
+
import { runAction } from '@stacksjs/actions'
|
|
5
|
+
import { intro, outro } from '@stacksjs/cli'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
|
|
8
|
+
export function tinker(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
tinker: 'Tinker with your code',
|
|
11
|
+
project: 'Target a specific project',
|
|
12
|
+
verbose: 'Enable verbose output',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
buddy
|
|
16
|
+
.command('tinker', descriptions.tinker)
|
|
17
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
18
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
|
+
.action(async (options: TinkerOptions) => {
|
|
20
|
+
const perf = await intro('buddy tinker')
|
|
21
|
+
const result = await runAction(Action.Tinker, options)
|
|
22
|
+
|
|
23
|
+
if (result.isErr()) {
|
|
24
|
+
await outro('While running the tinker command, there was an issue', { startTime: perf, useSeconds: true }, result.error || undefined)
|
|
25
|
+
process.exit()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await outro('Tinker mode exited.', { startTime: perf, useSeconds: true })
|
|
29
|
+
process.exit(ExitCode.Success)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
buddy.on('tinker:*', () => {
|
|
33
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
34
|
+
process.exit(1)
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI } from '@stacksjs/types'
|
|
3
|
+
import { generateTypes } from '@stacksjs/actions'
|
|
4
|
+
|
|
5
|
+
export function types(buddy: CLI) {
|
|
6
|
+
const descriptions = {
|
|
7
|
+
generate: 'Generate the types of & for your library/libraries',
|
|
8
|
+
fix: 'wip',
|
|
9
|
+
project: 'Target a specific project',
|
|
10
|
+
verbose: 'Enable verbose output',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
buddy
|
|
14
|
+
.command('types:generate', descriptions.generate)
|
|
15
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
16
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
17
|
+
.action(async () => {
|
|
18
|
+
await generateTypes()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
buddy
|
|
22
|
+
.command('types:fix', descriptions.fix)
|
|
23
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
24
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
25
|
+
.action(async () => {
|
|
26
|
+
// await fixTypes()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
buddy.on('types:*', () => {
|
|
30
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
31
|
+
process.exit(1)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { intro, outro, prompt } from '@stacksjs/cli'
|
|
4
|
+
import { ExitCode } from '@stacksjs/types'
|
|
5
|
+
import type { CLI, UpgradeOptions } from '@stacksjs/types'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
import { isString } from '@stacksjs/validation'
|
|
8
|
+
|
|
9
|
+
export function upgrade(buddy: CLI) {
|
|
10
|
+
const descriptions = {
|
|
11
|
+
command: 'Upgrade dependencies, framework, package manager, JS/TS runtime',
|
|
12
|
+
framework: 'Upgrade the Stacks framework',
|
|
13
|
+
dependencies: 'Upgrade your dependencies (pkgx.yaml & package.json)',
|
|
14
|
+
bun: 'Upgrade Bun to the latest version',
|
|
15
|
+
all: 'Upgrade Node, package manager, project dependencies, and framework',
|
|
16
|
+
force: 'Overwrite possible local updates with remote framework updates',
|
|
17
|
+
select: 'What are you trying to upgrade?',
|
|
18
|
+
project: 'Target a specific project',
|
|
19
|
+
verbose: 'Enable verbose output',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
buddy
|
|
23
|
+
.command('upgrade', descriptions.command)
|
|
24
|
+
.option('-c, --framework', descriptions.framework, { default: false })
|
|
25
|
+
.option('-d, --dependencies', descriptions.dependencies, { default: false })
|
|
26
|
+
.option('-b, --bun', descriptions.bun, { default: false })
|
|
27
|
+
.option('-a, --all', descriptions.all, { default: false })
|
|
28
|
+
.option('-f, --force', descriptions.force, { default: false })
|
|
29
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
30
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
31
|
+
.alias('update')
|
|
32
|
+
.example('buddy upgrade -a --verbose')
|
|
33
|
+
.action(async (options: UpgradeOptions) => {
|
|
34
|
+
const perf = await intro('buddy upgrade')
|
|
35
|
+
|
|
36
|
+
if (hasNoOptions(options)) {
|
|
37
|
+
let answers = await prompt.require()
|
|
38
|
+
.multiselect(descriptions.select, {
|
|
39
|
+
options: [
|
|
40
|
+
{ value: 'dependencies', label: 'Dependencies' },
|
|
41
|
+
{ value: 'framework', label: 'Framework' },
|
|
42
|
+
{ value: 'node', label: 'Node.js' },
|
|
43
|
+
{ value: 'package-manager', label: 'Package Manager' },
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
if (answers !== null)
|
|
48
|
+
process.exit(ExitCode.InvalidArgument)
|
|
49
|
+
|
|
50
|
+
if (isString(answers))
|
|
51
|
+
answers = [answers]
|
|
52
|
+
|
|
53
|
+
// creates an object out of array and sets answers to true
|
|
54
|
+
options = answers.reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const result = await runAction(Action.Upgrade, options)
|
|
58
|
+
|
|
59
|
+
if (result.isErr()) {
|
|
60
|
+
await outro('While running the buddy:upgrade command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
61
|
+
process.exit()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
await outro('Upgrade complete.', { startTime: perf, useSeconds: true })
|
|
65
|
+
process.exit()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
buddy
|
|
69
|
+
.command('upgrade:framework', descriptions.framework)
|
|
70
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
71
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
72
|
+
.example('buddy upgrade:framework --verbose')
|
|
73
|
+
.action(async (options: UpgradeOptions) => {
|
|
74
|
+
// const perf = await intro('buddy update:framework')
|
|
75
|
+
await runAction(Action.Upgrade, options)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
buddy
|
|
79
|
+
.command('upgrade:dependencies', descriptions.dependencies)
|
|
80
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
81
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
82
|
+
.alias('upgrade:deps')
|
|
83
|
+
.example('buddy upgrade:dependencies --verbose')
|
|
84
|
+
.action(async (options: UpgradeOptions) => {
|
|
85
|
+
await runAction(Action.Upgrade, options)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
buddy
|
|
89
|
+
.command('upgrade:bun', descriptions.bun)
|
|
90
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
91
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
92
|
+
.action(async (options: UpgradeOptions) => {
|
|
93
|
+
const perf = await intro('buddy upgrade:bun')
|
|
94
|
+
const result = await runAction(Action.UpgradeBun, options)
|
|
95
|
+
|
|
96
|
+
if (result.isErr()) {
|
|
97
|
+
await outro('While running the buddy upgrade:bun command, there was an issue', { startTime: perf, useSeconds: true }, result.error) // FIXME: should not have to cast
|
|
98
|
+
process.exit()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
process.exit(ExitCode.Success)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
buddy
|
|
105
|
+
.command('upgrade:all', descriptions.all)
|
|
106
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
107
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
108
|
+
.action(async (options: UpgradeOptions) => {
|
|
109
|
+
await runAction(Action.Upgrade, options)
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function hasNoOptions(options: UpgradeOptions) {
|
|
114
|
+
return !options.framework && !options.dependencies && !options.packageManager && !options.node && !options.all
|
|
115
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CLI } from '@stacksjs/types'
|
|
2
|
+
import { bold, dim, green, intro, log } from '@stacksjs/cli'
|
|
3
|
+
import { storage } from '@stacksjs/storage'
|
|
4
|
+
|
|
5
|
+
export function version(buddy: CLI) {
|
|
6
|
+
const descriptions = {
|
|
7
|
+
version: 'Retrieving Stacks build version',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
buddy
|
|
11
|
+
.command('version', descriptions.version)
|
|
12
|
+
.action(async () => {
|
|
13
|
+
await intro('buddy version')
|
|
14
|
+
|
|
15
|
+
const pkg = await storage.readPackageJson('./package.json')
|
|
16
|
+
const bunVersion = 'wip'
|
|
17
|
+
const stacksVersion = pkg.version
|
|
18
|
+
|
|
19
|
+
log.info(green(bold('@stacksjs/ ')) + dim(` ${stacksVersion}`))
|
|
20
|
+
log.info(green(bold('Bun: ')) + dim(` ${bunVersion}`))
|
|
21
|
+
|
|
22
|
+
// redis (or other cache/s), mysql (or other database/s),
|
|
23
|
+
})
|
|
24
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './commands'
|