@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
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.49",
|
|
5
5
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
63
|
"README.md",
|
|
64
|
-
"dist"
|
|
64
|
+
"dist",
|
|
65
|
+
"src"
|
|
65
66
|
],
|
|
66
67
|
"scripts": {
|
|
67
68
|
"buddy": "bunx ./src/cli.ts",
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
3
|
+
import { cli } from '@stacksjs/cli'
|
|
4
|
+
import { ensureProjectIsInitialized } from '@stacksjs/utils'
|
|
5
|
+
import * as cmd from './commands'
|
|
6
|
+
|
|
7
|
+
// setup global error handlers
|
|
8
|
+
process.on('uncaughtException', handleError)
|
|
9
|
+
process.on('unhandledRejection', handleError)
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
const buddy = cli('buddy')
|
|
13
|
+
|
|
14
|
+
// the following commands are not dependent on the project being initialized
|
|
15
|
+
cmd.setup(buddy)
|
|
16
|
+
cmd.key(buddy)
|
|
17
|
+
|
|
18
|
+
// before running any commands, ensure the project is already initialized
|
|
19
|
+
await ensureProjectIsInitialized()
|
|
20
|
+
|
|
21
|
+
cmd.build(buddy)
|
|
22
|
+
cmd.changelog(buddy)
|
|
23
|
+
cmd.clean(buddy)
|
|
24
|
+
cmd.cloud(buddy)
|
|
25
|
+
// cmd.commit(buddy)
|
|
26
|
+
cmd.configure(buddy)
|
|
27
|
+
cmd.dev(buddy)
|
|
28
|
+
cmd.domains(buddy)
|
|
29
|
+
cmd.deploy(buddy)
|
|
30
|
+
cmd.dns(buddy)
|
|
31
|
+
cmd.fresh(buddy)
|
|
32
|
+
cmd.generate(buddy)
|
|
33
|
+
cmd.http(buddy)
|
|
34
|
+
cmd.install(buddy)
|
|
35
|
+
cmd.lint(buddy)
|
|
36
|
+
// cmd.make(buddy)
|
|
37
|
+
// cmd.migrate(buddy)
|
|
38
|
+
cmd.release(buddy)
|
|
39
|
+
// cmd.seed(buddy)
|
|
40
|
+
cmd.setup(buddy)
|
|
41
|
+
// cmd.example(buddy)
|
|
42
|
+
// cmd.test(buddy)
|
|
43
|
+
// cmd.version(buddy)
|
|
44
|
+
// cmd.prepublish(buddy)
|
|
45
|
+
cmd.upgrade(buddy)
|
|
46
|
+
|
|
47
|
+
buddy.parse()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await main()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { AddOptions, BuildOptions, CLI } from '@stacksjs/types'
|
|
3
|
+
import { ExitCode } from '@stacksjs/types'
|
|
4
|
+
import { runAdd } from '@stacksjs/actions'
|
|
5
|
+
|
|
6
|
+
export function add(buddy: CLI) {
|
|
7
|
+
const descriptions = {
|
|
8
|
+
add: 'Add a stack to your project (coming soon)',
|
|
9
|
+
table: 'Add the Table Stack to your project',
|
|
10
|
+
calendar: 'Add the Calendar Stack to your project',
|
|
11
|
+
all: 'Add all stacks',
|
|
12
|
+
select: 'Which stack/s are you trying to add?',
|
|
13
|
+
project: 'Target a specific project',
|
|
14
|
+
verbose: 'Enable verbose output',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buddy
|
|
18
|
+
.command('add', descriptions.add)
|
|
19
|
+
.option('-t, --table', descriptions.table, { default: false })
|
|
20
|
+
.option('-c, --calendar', descriptions.calendar, { default: false })
|
|
21
|
+
.option('-a, --all', descriptions.all, { default: false })
|
|
22
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
23
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
24
|
+
.action(async (options: BuildOptions) => {
|
|
25
|
+
if (hasNoOptions(options)) {
|
|
26
|
+
// const answers = await log.prompt(descriptions.select, {
|
|
27
|
+
// type: 'multiselect',
|
|
28
|
+
// options: [
|
|
29
|
+
// { label: 'Calendar', value: 'calendar' },
|
|
30
|
+
// { label: 'Table', value: 'table' },
|
|
31
|
+
// ],
|
|
32
|
+
// })
|
|
33
|
+
|
|
34
|
+
// // creates an object out of array and sets answers to true
|
|
35
|
+
// options = answers.reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await runAdd(options)
|
|
39
|
+
|
|
40
|
+
process.exit(ExitCode.Success)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
buddy
|
|
44
|
+
.command('add:table', descriptions.table)
|
|
45
|
+
.option('-t, --table', descriptions.table, { default: true })
|
|
46
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
47
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
48
|
+
.action(async (options: BuildOptions) => {
|
|
49
|
+
await runAdd(options)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
buddy
|
|
53
|
+
.command('add:calendar', descriptions.calendar)
|
|
54
|
+
.option('-t, --calendar', descriptions.calendar, { default: true })
|
|
55
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
56
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
57
|
+
.action(async (options: BuildOptions) => {
|
|
58
|
+
await runAdd(options)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
buddy.on('add:*', () => {
|
|
62
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
63
|
+
process.exit(1)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function hasNoOptions(options: AddOptions) {
|
|
68
|
+
return !options.all && !options.table && !options.calendar
|
|
69
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { runAction } from '@stacksjs/actions'
|
|
3
|
+
import { intro, log, outro, prompt } from '@stacksjs/cli'
|
|
4
|
+
import type { BuildOptions, CLI } from '@stacksjs/types'
|
|
5
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
|
+
import { Action } from '@stacksjs/enums'
|
|
7
|
+
import { isString } from '@stacksjs/validation'
|
|
8
|
+
|
|
9
|
+
export function build(buddy: CLI) {
|
|
10
|
+
const descriptions = {
|
|
11
|
+
build: 'Build any of your libraries (packages) for production use',
|
|
12
|
+
components: 'Build your component library',
|
|
13
|
+
vueComponents: 'Build your Vue component library',
|
|
14
|
+
webComponents: 'Build your framework agnostic web component library',
|
|
15
|
+
elements: 'An alias to the -w flag',
|
|
16
|
+
buddy: 'Build the Buddy binary',
|
|
17
|
+
functions: 'Build your function library',
|
|
18
|
+
desktop: 'Build the Desktop Application',
|
|
19
|
+
pages: 'Build your frontend',
|
|
20
|
+
docs: 'Build your documentation',
|
|
21
|
+
framework: 'Build Stacks framework',
|
|
22
|
+
select: 'What are you trying to build?',
|
|
23
|
+
project: 'Target a specific project',
|
|
24
|
+
verbose: 'Enable verbose output',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
buddy
|
|
28
|
+
.command('build [type]', descriptions.build)
|
|
29
|
+
.option('-c, --components', descriptions.components)
|
|
30
|
+
.option('-v, --vue-components', descriptions.vueComponents) // these are automatically built with your -c option as well
|
|
31
|
+
.option('-w, --web-components', descriptions.webComponents) // these are automatically built with your -c option as well
|
|
32
|
+
.option('-e, --elements', descriptions.elements)
|
|
33
|
+
.option('-f, --functions', descriptions.functions)
|
|
34
|
+
.option('-p, --views', descriptions.pages)
|
|
35
|
+
.option('-d, --docs', descriptions.docs)
|
|
36
|
+
.option('-b, --buddy', descriptions.buddy, { default: false })
|
|
37
|
+
.option('-s, --stacks', descriptions.framework, { default: false })
|
|
38
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
39
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
40
|
+
.action(async (server: string | undefined, options: BuildOptions) => {
|
|
41
|
+
switch (server) {
|
|
42
|
+
case 'components':
|
|
43
|
+
options.components = true
|
|
44
|
+
break
|
|
45
|
+
case 'vue':
|
|
46
|
+
options.vueComponents = true
|
|
47
|
+
break
|
|
48
|
+
case 'web-components':
|
|
49
|
+
options.webComponents = true
|
|
50
|
+
break
|
|
51
|
+
case 'functions':
|
|
52
|
+
options.functions = true
|
|
53
|
+
break
|
|
54
|
+
case 'views':
|
|
55
|
+
options.views = true
|
|
56
|
+
break
|
|
57
|
+
case 'docs':
|
|
58
|
+
options.docs = true
|
|
59
|
+
break
|
|
60
|
+
case 'buddy':
|
|
61
|
+
options.buddy = true
|
|
62
|
+
break
|
|
63
|
+
case 'cli':
|
|
64
|
+
options.buddy = true
|
|
65
|
+
break
|
|
66
|
+
case 'stacks':
|
|
67
|
+
options.stacks = true
|
|
68
|
+
break
|
|
69
|
+
default:
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (hasNoOptions(options)) {
|
|
74
|
+
let answers = await prompt.require()
|
|
75
|
+
.multiselect(descriptions.select, {
|
|
76
|
+
options: [
|
|
77
|
+
{ label: 'Components', value: 'components' },
|
|
78
|
+
// { label: 'Vue Components', value: 'vue-components' },
|
|
79
|
+
{ label: 'Web Components', value: 'web-components' },
|
|
80
|
+
{ label: 'Functions', value: 'functions' },
|
|
81
|
+
{ label: 'Views', value: 'views' },
|
|
82
|
+
{ label: 'Documentation', value: 'docs' },
|
|
83
|
+
],
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
if (answers !== null)
|
|
87
|
+
process.exit(ExitCode.InvalidArgument)
|
|
88
|
+
|
|
89
|
+
if (isString(answers))
|
|
90
|
+
answers = [answers]
|
|
91
|
+
|
|
92
|
+
// creates an object out of array and sets answers to true
|
|
93
|
+
options = answers.reduce((a: any, v: any) => ({ ...a, [v]: true }), {})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await runAction(Action.BuildStacks, options)
|
|
97
|
+
|
|
98
|
+
process.exit(ExitCode.Success)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
buddy
|
|
102
|
+
.command('build:components', 'Automagically build component libraries for production use & npm/CDN distribution')
|
|
103
|
+
.alias('prod:components')
|
|
104
|
+
.option('-c, --components', descriptions.components, { default: true })
|
|
105
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
106
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
107
|
+
.action(async (options: BuildOptions) => {
|
|
108
|
+
await runAction(Action.BuildComponentLibs, options)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
buddy
|
|
112
|
+
.command('build:cli', 'Automagically build the CLI')
|
|
113
|
+
.alias('prod:cli')
|
|
114
|
+
.option('-b, --buddy', descriptions.buddy, { default: true })
|
|
115
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
116
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
117
|
+
.action(async (options: BuildOptions) => {
|
|
118
|
+
await runAction(Action.BuildCli, options)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
buddy
|
|
122
|
+
.command('build:functions', 'Automagically build function library for npm/CDN distribution')
|
|
123
|
+
.option('-f, --functions', descriptions.functions, { default: true })
|
|
124
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
125
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
126
|
+
.action(async (options: BuildOptions) => {
|
|
127
|
+
await runAction(Action.BuildFunctionLib, options)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
buddy
|
|
131
|
+
.command('build:vue-components', 'Automagically build Vue component library for npm/CDN distribution')
|
|
132
|
+
.alias('build:vue')
|
|
133
|
+
.alias('prod:vue-components')
|
|
134
|
+
.alias('prod:vue')
|
|
135
|
+
.option('-v, --vue-components', descriptions.vueComponents, { default: true })
|
|
136
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
137
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
138
|
+
.alias('build:vue')
|
|
139
|
+
.action(async (options: BuildOptions) => {
|
|
140
|
+
await runAction(Action.BuildVueComponentLib, options)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
buddy
|
|
144
|
+
.command('build:web-components', 'Automagically build Web Component library for npm/CDN distribution')
|
|
145
|
+
.alias('build:wc')
|
|
146
|
+
.alias('prod:web-components')
|
|
147
|
+
.alias('prod:wc')
|
|
148
|
+
.option('-w, --web-components', descriptions.webComponents, { default: true })
|
|
149
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
150
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
151
|
+
.action(async (options: BuildOptions) => {
|
|
152
|
+
await runAction(Action.BuildWebComponentLib, options)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
buddy
|
|
156
|
+
.command('build:docs', 'Automagically build your documentation site.')
|
|
157
|
+
.alias('prod:docs')
|
|
158
|
+
.alias('build:documentation')
|
|
159
|
+
.alias('prod:documentation')
|
|
160
|
+
.option('-d, --docs', descriptions.docs, { default: true })
|
|
161
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
162
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
163
|
+
.action(async (options: BuildOptions) => {
|
|
164
|
+
await runAction(Action.BuildDocs, options)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
buddy
|
|
168
|
+
.command('build:core', 'Automagically build the Stacks core.')
|
|
169
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
170
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
171
|
+
.action(async (options: BuildOptions) => {
|
|
172
|
+
const startTime = await intro('buddy build:core')
|
|
173
|
+
const result = await runAction(Action.BuildCore, options)
|
|
174
|
+
|
|
175
|
+
if (result.isErr()) {
|
|
176
|
+
log.error('Failed to build the Stacks core.', result.error)
|
|
177
|
+
process.exit()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await outro('Core packages built successfully', { startTime, useSeconds: true })
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
buddy
|
|
184
|
+
.command('build:desktop', descriptions.desktop)
|
|
185
|
+
.alias('prod:desktop')
|
|
186
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
187
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
188
|
+
.action(async (options: BuildOptions) => {
|
|
189
|
+
const perf = await intro('buddy build:desktop')
|
|
190
|
+
const result = await runAction(Action.BuildDesktop, options)
|
|
191
|
+
|
|
192
|
+
if (result.isErr()) {
|
|
193
|
+
await outro('While running the build:desktop command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
194
|
+
process.exit()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// eslint-disable-next-line no-console
|
|
198
|
+
console.log('')
|
|
199
|
+
await outro('Exited', { startTime: perf, useSeconds: true })
|
|
200
|
+
process.exit(ExitCode.Success)
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
buddy
|
|
204
|
+
.command('build:stacks', 'Build the Stacks framework.')
|
|
205
|
+
.option('-s, --stacks', descriptions.framework, { default: true })
|
|
206
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
207
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
208
|
+
.action(async (options: BuildOptions) => {
|
|
209
|
+
const startTime = await intro('buddy build:stacks')
|
|
210
|
+
const result = await runAction(Action.BuildStacks, options)
|
|
211
|
+
|
|
212
|
+
if (result.isErr()) {
|
|
213
|
+
log.error('Failed to build Stacks.', result.error)
|
|
214
|
+
process.exit()
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
await outro('Stacks built successfully', { startTime, useSeconds: true })
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
buddy.on('build:*', () => {
|
|
221
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
222
|
+
process.exit(1)
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function hasNoOptions(options: BuildOptions) {
|
|
227
|
+
return !options.components && !options.vueComponents && !options.webComponents && !options.elements && !options.functions && !options.views && !options.docs && !options.stacks && !options.buddy
|
|
228
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { CLI, FreshOptions } from '@stacksjs/types'
|
|
3
|
+
import { ExitCode } 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 changelog(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
changelog: 'Create a CHANGELOG.md file',
|
|
11
|
+
quiet: 'Minimal output',
|
|
12
|
+
project: 'Target a specific project',
|
|
13
|
+
verbose: 'Enable verbose output',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
buddy
|
|
17
|
+
.command('changelog', descriptions.changelog)
|
|
18
|
+
.option('--quiet', descriptions.quiet, { default: false })
|
|
19
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
20
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
21
|
+
.action(async (options: FreshOptions) => {
|
|
22
|
+
const perf = await intro('buddy changelog')
|
|
23
|
+
const result = await runAction(Action.Changelog, options)
|
|
24
|
+
|
|
25
|
+
if (result.isErr()) {
|
|
26
|
+
await outro('While running the changelog command, there was an issue', { ...options, startTime: perf, useSeconds: true }, result.error)
|
|
27
|
+
process.exit()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await outro('Generated the CHANGELOG.md file', { ...options, startTime: perf, useSeconds: true, type: 'info' })
|
|
31
|
+
process.exit(ExitCode.Success)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
buddy.on('changelog:*', () => {
|
|
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,36 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import type { CLI, CleanOptions } 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 clean(buddy: CLI) {
|
|
9
|
+
const descriptions = {
|
|
10
|
+
clean: 'Removes all node_modules & lock files',
|
|
11
|
+
project: 'Target a specific project',
|
|
12
|
+
verbose: 'Enable verbose output',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
buddy
|
|
16
|
+
.command('clean', descriptions.clean)
|
|
17
|
+
.option('-p, --project', descriptions.project, { default: false })
|
|
18
|
+
.option('--verbose', descriptions.verbose, { default: false })
|
|
19
|
+
.action(async (options: CleanOptions) => {
|
|
20
|
+
const perf = await intro('buddy clean')
|
|
21
|
+
const result = await runAction(Action.Clean, options)
|
|
22
|
+
|
|
23
|
+
if (result.isErr()) {
|
|
24
|
+
await outro('While running the clean command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
25
|
+
process.exit(ExitCode.FatalError)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await outro('Cleaned up', { startTime: perf, useSeconds: true, message: 'Cleaned up' })
|
|
29
|
+
process.exit(ExitCode.Success)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
buddy.on('clean:*', () => {
|
|
33
|
+
console.error('Invalid command: %s\nSee --help for a list of available commands.', buddy.args.join(' '))
|
|
34
|
+
process.exit(1)
|
|
35
|
+
})
|
|
36
|
+
}
|