Skip to content

Commit

Permalink
refactor: add help description and assetsArgs CLI flag
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 17, 2023
1 parent f3d995e commit 867c0bf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
21 changes: 20 additions & 1 deletion commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ export default class Build extends BaseCommand {
static description =
'Build application for production by compiling frontend assets and TypeScript source to JavaScript'

static help = [
'Create the production build using the following command.',
'```',
'{{ binaryName }} build',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
'You may pass vite CLI args using the --assets-args command line flag.',
'```',
'{{ binaryName }} build --assets-args="--debug --base=/public"',
'```',
]

@flags.boolean({ description: 'Watch filesystem and restart the HTTP server on file change' })
declare watch?: boolean

Expand All @@ -38,6 +51,11 @@ export default class Build extends BaseCommand {
})
declare assets?: boolean

@flags.array({
description: 'Define CLI arguments to pass to the assets bundler',
})
declare assetsArgs?: string[]

/**
* Log a development dependency is missing
*/
Expand All @@ -46,7 +64,7 @@ export default class Build extends BaseCommand {
[
`Cannot find package "${dependency}"`,
'',
`The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
`The "${dependency}" package is a development dependency and therefore you should use the build command with development dependencies installed.`,
'',
'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
].join('\n')
Expand Down Expand Up @@ -78,6 +96,7 @@ export default class Build extends BaseCommand {
serve: this.assets === false ? false : true,
driver: assetsBundler.name,
cmd: assetsBundler.buildCommand,
args: this.assetsArgs || [],
}
: {
serve: false,
Expand Down
19 changes: 19 additions & 0 deletions commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ export default class Serve extends BaseCommand {
static description =
'Start the development HTTP server along with the file watcher to perform restarts on file change'

static help = [
'Start the development server with file watcher using the following command.',
'```',
'{{ binaryName }} serve --watch',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
'You may pass vite CLI args using the --assets-args command line flag.',
'```',
'{{ binaryName }} serve --assets-args="--debug --base=/public"',
'```',
]

static options: CommandOptions = {
staysAlive: true,
}
Expand All @@ -45,6 +58,11 @@ export default class Serve extends BaseCommand {
})
declare assets?: boolean

@flags.array({
description: 'Define CLI arguments to pass to the assets bundler',
})
declare assetsArgs?: string[]

/**
* Log a development dependency is missing
*/
Expand Down Expand Up @@ -81,6 +99,7 @@ export default class Serve extends BaseCommand {
serve: this.assets === false ? false : true,
driver: assetsBundler.name,
cmd: assetsBundler.devServerCommand,
args: this.assetsArgs || [],
}
: {
serve: false,
Expand Down

0 comments on commit 867c0bf

Please sign in to comment.