@thegetty/quire-cli 1.0.0-rc.44 → 1.0.0-rc.46
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/CHANGELOG.md +0 -36
- package/README.md +0 -9
- package/bin/cli.js +1 -46
- package/package.json +9 -25
- package/src/Command.js +6 -26
- package/src/commands/README.md +122 -213
- package/src/commands/build.js +37 -45
- package/src/commands/clean.js +19 -33
- package/src/commands/conf.js +43 -0
- package/src/commands/create.js +14 -42
- package/src/commands/epub.js +31 -67
- package/src/commands/index.js +2 -9
- package/src/commands/info.js +86 -88
- package/src/commands/pdf.js +82 -63
- package/src/commands/preview.js +31 -32
- package/src/commands/validate.js +20 -64
- package/src/commands/version.js +43 -0
- package/src/errors/validation/validation-error.js +11 -20
- package/src/helpers/clean.js +1 -1
- package/src/helpers/is-quire.js +31 -0
- package/src/helpers/test-cwd.js +6 -5
- package/src/helpers/which.js +4 -10
- package/src/lib/11ty/README.md +19 -135
- package/src/lib/11ty/api.js +93 -235
- package/src/lib/11ty/cli.js +37 -112
- package/src/lib/11ty/index.js +5 -64
- package/src/lib/11ty/paths.js +103 -0
- package/src/lib/README.md +0 -330
- package/src/lib/conf/README.md +69 -86
- package/src/lib/conf/config.js +3 -5
- package/src/lib/conf/defaults.js +0 -65
- package/src/lib/conf/schema.js +9 -103
- package/src/lib/epub/README.md +2 -133
- package/src/lib/epub/epub.js +11 -36
- package/src/lib/epub/index.js +21 -111
- package/src/lib/epub/pandoc.js +4 -33
- package/src/lib/git/README.md +2 -151
- package/src/lib/git/index.js +13 -217
- package/src/lib/i18n/README.md +3 -0
- package/src/lib/i18n/config.js +53 -0
- package/src/lib/i18n/index.js +43 -0
- package/src/lib/i18n/localeService.js +58 -0
- package/src/lib/pdf/README.md +0 -131
- package/src/lib/pdf/index.js +21 -124
- package/src/lib/pdf/paged.js +52 -100
- package/src/lib/pdf/prince.js +37 -115
- package/src/lib/pdf/split.js +33 -61
- package/src/lib/quire/README.md +19 -0
- package/src/lib/quire/index.js +353 -0
- package/src/lib/reporter/README.md +2 -211
- package/src/lib/reporter/index.js +0 -607
- package/src/main.js +48 -221
- package/src/packageConfig.js +0 -17
- package/src/validators/utils.js +1 -2
- package/schemas/config.schema.json +0 -194
- package/schemas/figures.schema.json +0 -56
- package/schemas/layout.schema.json +0 -5
- package/schemas/objects.schema.json +0 -62
- package/schemas/publication.schema.json +0 -140
- package/schemas/references.schema.json +0 -29
- package/src/Command.spec.js +0 -99
- package/src/commands/build.spec.js +0 -113
- package/src/commands/build.test.js +0 -397
- package/src/commands/clean.spec.js +0 -118
- package/src/commands/clean.test.js +0 -382
- package/src/commands/config.js +0 -238
- package/src/commands/config.spec.js +0 -107
- package/src/commands/config.test.js +0 -845
- package/src/commands/create.spec.js +0 -112
- package/src/commands/create.test.js +0 -415
- package/src/commands/doctor.js +0 -251
- package/src/commands/doctor.spec.js +0 -115
- package/src/commands/doctor.test.js +0 -1409
- package/src/commands/epub.spec.js +0 -114
- package/src/commands/epub.test.js +0 -503
- package/src/commands/help.js +0 -60
- package/src/commands/help.test.js +0 -132
- package/src/commands/info.spec.js +0 -72
- package/src/commands/info.test.js +0 -512
- package/src/commands/pdf.spec.js +0 -114
- package/src/commands/pdf.test.js +0 -464
- package/src/commands/preview.spec.js +0 -97
- package/src/commands/preview.test.js +0 -250
- package/src/commands/use.js +0 -56
- package/src/commands/use.spec.js +0 -61
- package/src/commands/use.test.js +0 -280
- package/src/commands/validate.spec.js +0 -90
- package/src/commands/validate.test.js +0 -378
- package/src/commands/workflows.js +0 -70
- package/src/errors/build/build-failed-error.js +0 -19
- package/src/errors/build/config-field-missing-error.js +0 -20
- package/src/errors/build/config-file-not-found-error.js +0 -20
- package/src/errors/build/index.js +0 -11
- package/src/errors/help/help-topic-not-found-error.js +0 -30
- package/src/errors/help/index.js +0 -8
- package/src/errors/index.js +0 -58
- package/src/errors/input/index.js +0 -8
- package/src/errors/input/invalid-input-error.js +0 -21
- package/src/errors/install/dependency-install-error.js +0 -19
- package/src/errors/install/directory-not-empty-error.js +0 -25
- package/src/errors/install/index.js +0 -12
- package/src/errors/install/invalid-path-error.js +0 -31
- package/src/errors/install/invalid-starter-error.js +0 -27
- package/src/errors/install/version-not-found-error.js +0 -35
- package/src/errors/output/epub-generation-error.js +0 -19
- package/src/errors/output/index.js +0 -14
- package/src/errors/output/invalid-epub-library-error.js +0 -20
- package/src/errors/output/invalid-pdf-library-error.js +0 -20
- package/src/errors/output/missing-build-output-error.js +0 -21
- package/src/errors/output/pdf-generation-error.js +0 -24
- package/src/errors/output/tool-not-found-error.js +0 -37
- package/src/errors/project/index.js +0 -10
- package/src/errors/project/not-in-project-error.js +0 -20
- package/src/errors/project/project-create-error.js +0 -21
- package/src/errors/quire-error.js +0 -27
- package/src/errors/validation/index.js +0 -3
- package/src/errors/validation/unknown-config-key-error.js +0 -27
- package/src/errors/validation/unknown-config-operation-error.js +0 -24
- package/src/helpers/docs-url.js +0 -32
- package/src/helpers/pager.js +0 -59
- package/src/helpers/pager.test.js +0 -85
- package/src/helpers/suggest-similar.js +0 -124
- package/src/helpers/suggest-similar.test.js +0 -108
- package/src/helpers/test-cwd.test.js +0 -192
- package/src/lib/11ty/index.test.js +0 -655
- package/src/lib/commander/index.js +0 -103
- package/src/lib/commander/index.test.js +0 -86
- package/src/lib/commander/options.js +0 -237
- package/src/lib/commander/options.test.js +0 -205
- package/src/lib/conf/build-status.js +0 -103
- package/src/lib/conf/build-status.test.js +0 -247
- package/src/lib/conf/config.test.js +0 -281
- package/src/lib/conf/format.js +0 -60
- package/src/lib/conf/format.test.js +0 -106
- package/src/lib/conf/helpers.js +0 -91
- package/src/lib/conf/helpers.test.js +0 -136
- package/src/lib/conf/index.js +0 -22
- package/src/lib/constants.js +0 -28
- package/src/lib/doctor/README.md +0 -667
- package/src/lib/doctor/checks/environment/cli-version.js +0 -62
- package/src/lib/doctor/checks/environment/cli-version.test.js +0 -132
- package/src/lib/doctor/checks/environment/git-available.js +0 -77
- package/src/lib/doctor/checks/environment/git-available.test.js +0 -52
- package/src/lib/doctor/checks/environment/index.js +0 -13
- package/src/lib/doctor/checks/environment/node-version.js +0 -66
- package/src/lib/doctor/checks/environment/node-version.test.js +0 -17
- package/src/lib/doctor/checks/environment/npm-available.js +0 -66
- package/src/lib/doctor/checks/environment/npm-available.test.js +0 -52
- package/src/lib/doctor/checks/environment/os-info.js +0 -48
- package/src/lib/doctor/checks/environment/os-info.test.js +0 -81
- package/src/lib/doctor/checks/environment/runtime-info.js +0 -51
- package/src/lib/doctor/checks/environment/runtime-info.test.js +0 -132
- package/src/lib/doctor/checks/outputs/epub-output.js +0 -119
- package/src/lib/doctor/checks/outputs/epub-output.test.js +0 -277
- package/src/lib/doctor/checks/outputs/index.js +0 -10
- package/src/lib/doctor/checks/outputs/pdf-output.js +0 -144
- package/src/lib/doctor/checks/outputs/pdf-output.test.js +0 -377
- package/src/lib/doctor/checks/outputs/stale-build.js +0 -122
- package/src/lib/doctor/checks/outputs/stale-build.test.js +0 -282
- package/src/lib/doctor/checks/project/data-files.js +0 -56
- package/src/lib/doctor/checks/project/data-files.test.js +0 -125
- package/src/lib/doctor/checks/project/dependencies.js +0 -53
- package/src/lib/doctor/checks/project/dependencies.test.js +0 -71
- package/src/lib/doctor/checks/project/index.js +0 -11
- package/src/lib/doctor/checks/project/quire-11ty.js +0 -98
- package/src/lib/doctor/checks/project/quire-11ty.test.js +0 -170
- package/src/lib/doctor/checks/project/quire-project.js +0 -38
- package/src/lib/doctor/checks/project/quire-project.test.js +0 -47
- package/src/lib/doctor/checks/tools/index.js +0 -10
- package/src/lib/doctor/checks/tools/pandoc-available.js +0 -82
- package/src/lib/doctor/checks/tools/pandoc-available.test.js +0 -73
- package/src/lib/doctor/checks/tools/prince-available.js +0 -81
- package/src/lib/doctor/checks/tools/prince-available.test.js +0 -73
- package/src/lib/doctor/constants.js +0 -39
- package/src/lib/doctor/formatDuration.js +0 -108
- package/src/lib/doctor/formatDuration.test.js +0 -76
- package/src/lib/doctor/formatters/human.js +0 -257
- package/src/lib/doctor/formatters/human.test.js +0 -463
- package/src/lib/doctor/formatters/index.js +0 -8
- package/src/lib/doctor/formatters/json.js +0 -78
- package/src/lib/doctor/formatters/json.test.js +0 -174
- package/src/lib/doctor/formatters/shared.js +0 -129
- package/src/lib/doctor/formatters/shared.test.js +0 -194
- package/src/lib/doctor/index.js +0 -271
- package/src/lib/doctor/index.test.js +0 -797
- package/src/lib/epub/engines.js +0 -46
- package/src/lib/epub/index.test.js +0 -518
- package/src/lib/epub/pandoc.test.js +0 -122
- package/src/lib/epub/schema.js +0 -21
- package/src/lib/error/README.md +0 -170
- package/src/lib/error/handler.js +0 -107
- package/src/lib/git/index.spec.js +0 -80
- package/src/lib/git/index.test.js +0 -453
- package/src/lib/help/frontmatter.js +0 -77
- package/src/lib/help/frontmatter.test.js +0 -139
- package/src/lib/help/index.js +0 -146
- package/src/lib/help/index.test.js +0 -188
- package/src/lib/help/topics/configuration.md +0 -77
- package/src/lib/help/topics/debugging.md +0 -69
- package/src/lib/help/topics/epub.md +0 -74
- package/src/lib/help/topics/pdf.md +0 -74
- package/src/lib/help/topics/publishing.md +0 -80
- package/src/lib/help/topics/workflows.md +0 -50
- package/src/lib/installer/index.js +0 -309
- package/src/lib/installer/index.spec.js +0 -83
- package/src/lib/installer/index.test.js +0 -545
- package/src/lib/logger/README.md +0 -424
- package/src/lib/logger/debug.js +0 -132
- package/src/lib/logger/debug.spec.js +0 -130
- package/src/lib/logger/debug.test.js +0 -128
- package/src/lib/logger/index.js +0 -228
- package/src/lib/logger/index.spec.js +0 -131
- package/src/lib/logger/index.test.js +0 -578
- package/src/lib/npm/README.md +0 -127
- package/src/lib/npm/index.js +0 -198
- package/src/lib/npm/index.spec.js +0 -60
- package/src/lib/npm/index.test.js +0 -355
- package/src/lib/pdf/engines.js +0 -46
- package/src/lib/pdf/index.test.js +0 -708
- package/src/lib/pdf/paged.test.js +0 -366
- package/src/lib/pdf/prince.test.js +0 -202
- package/src/lib/pdf/schema.js +0 -21
- package/src/lib/pdf/split.test.js +0 -445
- package/src/lib/platform.js +0 -95
- package/src/lib/process/manager.js +0 -110
- package/src/lib/process/manager.test.js +0 -55
- package/src/lib/project/build.js +0 -162
- package/src/lib/project/build.test.js +0 -275
- package/src/lib/project/config.js +0 -48
- package/src/lib/project/config.test.js +0 -134
- package/src/lib/project/detect.js +0 -47
- package/src/lib/project/detect.test.js +0 -157
- package/src/lib/project/index.js +0 -56
- package/src/lib/project/output-paths.js +0 -87
- package/src/lib/project/output-paths.test.js +0 -66
- package/src/lib/project/paths.js +0 -272
- package/src/lib/project/version.js +0 -110
- package/src/lib/project/version.test.js +0 -350
- package/src/lib/reporter/index.test.js +0 -862
- package/src/main.spec.js +0 -61
- package/src/main.test.js +0 -347
- package/src/validators/validate-data-files.js +0 -154
- package/src/validators/validate-data-files.test.js +0 -217
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commander.js utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides helper functions for converting array-based definitions
|
|
5
|
-
* to Commander.js Argument and Option objects, plus shared option definitions.
|
|
6
|
-
*
|
|
7
|
-
* @module lib/commander
|
|
8
|
-
*/
|
|
9
|
-
import { Argument, Option } from 'commander'
|
|
10
|
-
|
|
11
|
-
// Re-export shared option definitions
|
|
12
|
-
export {
|
|
13
|
-
colorOption,
|
|
14
|
-
noColorOption,
|
|
15
|
-
quietOption,
|
|
16
|
-
verboseOption,
|
|
17
|
-
debugOption,
|
|
18
|
-
reducedMotionOption,
|
|
19
|
-
outputModeOptions,
|
|
20
|
-
outputModeHelpText,
|
|
21
|
-
withOutputModes,
|
|
22
|
-
} from './options.js'
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Convert array argument definition to Argument object
|
|
26
|
-
*
|
|
27
|
-
* @param {Array} entry - Argument definition array [name, description, { choices, default }]
|
|
28
|
-
* @returns {Argument} Commander Argument object
|
|
29
|
-
* @see https://github.com/tj/commander.js#more-configuration-1
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // Required argument
|
|
33
|
-
* arrayToArgument(['<version>', 'quire-11ty version to use'])
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // Optional argument with default
|
|
37
|
-
* arrayToArgument(['[starter]', 'starter template', { default: 'default' }])
|
|
38
|
-
*/
|
|
39
|
-
export function arrayToArgument(entry) {
|
|
40
|
-
const [name, description, config = {}] = entry
|
|
41
|
-
const argument = new Argument(name, description)
|
|
42
|
-
if (config.choices) argument.choices(config.choices)
|
|
43
|
-
if (config.default) argument.default(config.default)
|
|
44
|
-
return argument
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Convert array option definition to Option object
|
|
49
|
-
*
|
|
50
|
-
* Supports two array formats:
|
|
51
|
-
* - Separate flags: ['-s', '--long <value>', 'description', default, { choices, default }]
|
|
52
|
-
* - Combined flags: ['--long <value>', 'description', default, { choices, default }]
|
|
53
|
-
*
|
|
54
|
-
* @param {Array} entry - Option definition array
|
|
55
|
-
* @returns {Option} Commander Option object
|
|
56
|
-
* @see https://github.com/tj/commander.js/#options
|
|
57
|
-
* @see https://github.com/tj/commander.js/#more-configuration
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* // Long-only option
|
|
61
|
-
* arrayToOption(['--debug', 'enable debug output'])
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* // Short and long flags
|
|
65
|
-
* arrayToOption(['-v', '--verbose', 'enable verbose output'])
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // Option with choices
|
|
69
|
-
* arrayToOption(['--lib <module>', 'library to use', { choices: ['a', 'b'], default: 'a' }])
|
|
70
|
-
*/
|
|
71
|
-
export function arrayToOption(entry) {
|
|
72
|
-
const lastElement = entry[entry.length - 1]
|
|
73
|
-
const configObj = typeof lastElement === 'object' && lastElement !== null ? lastElement : null
|
|
74
|
-
|
|
75
|
-
let flags, description, defaultValue
|
|
76
|
-
if (entry[0]?.startsWith('-') && entry[1]?.startsWith('--')) {
|
|
77
|
-
// Array has separate elements for short and long option flags
|
|
78
|
-
// @example ['-s', '--long <value>', 'desc', ...]
|
|
79
|
-
flags = `${entry[0]}, ${entry[1]}`
|
|
80
|
-
description = entry[2]
|
|
81
|
-
defaultValue = entry[3]
|
|
82
|
-
} else {
|
|
83
|
-
// Array has a single element with option flags
|
|
84
|
-
// @example ['--long <value>', 'desc', ...]
|
|
85
|
-
flags = entry[0]
|
|
86
|
-
description = entry[1]
|
|
87
|
-
defaultValue = entry[2]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const option = new Option(flags, description)
|
|
91
|
-
|
|
92
|
-
if (configObj) {
|
|
93
|
-
if (configObj.choices) option.choices(configObj.choices)
|
|
94
|
-
if (configObj.conflicts) option.conflicts(configObj.conflicts)
|
|
95
|
-
if (configObj.default !== undefined) option.default(configObj.default)
|
|
96
|
-
if (configObj.hidden) option.hideHelp()
|
|
97
|
-
if (configObj.implies) option.implies(configObj.implies)
|
|
98
|
-
} else if (defaultValue !== undefined) {
|
|
99
|
-
option.default(defaultValue)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return option
|
|
103
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import { Argument, Option } from 'commander'
|
|
3
|
-
import { arrayToArgument, arrayToOption } from './index.js'
|
|
4
|
-
|
|
5
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
-
// arrayToArgument tests
|
|
7
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
test('arrayToArgument creates Argument from basic array', (t) => {
|
|
10
|
-
const arg = arrayToArgument(['<version>', 'the version to use'])
|
|
11
|
-
|
|
12
|
-
t.true(arg instanceof Argument)
|
|
13
|
-
t.is(arg.name(), 'version')
|
|
14
|
-
t.is(arg.description, 'the version to use')
|
|
15
|
-
t.true(arg.required)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('arrayToArgument creates optional Argument', (t) => {
|
|
19
|
-
const arg = arrayToArgument(['[starter]', 'starter template'])
|
|
20
|
-
|
|
21
|
-
t.true(arg instanceof Argument)
|
|
22
|
-
t.is(arg.name(), 'starter')
|
|
23
|
-
t.false(arg.required)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('arrayToArgument applies choices from config', (t) => {
|
|
27
|
-
const arg = arrayToArgument(['<format>', 'output format', { choices: ['pdf', 'epub'] }])
|
|
28
|
-
|
|
29
|
-
t.true(arg instanceof Argument)
|
|
30
|
-
t.deepEqual(arg.argChoices, ['pdf', 'epub'])
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('arrayToArgument applies default from config', (t) => {
|
|
34
|
-
const arg = arrayToArgument(['[starter]', 'starter template', { default: 'default' }])
|
|
35
|
-
|
|
36
|
-
t.true(arg instanceof Argument)
|
|
37
|
-
t.is(arg.defaultValue, 'default')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
41
|
-
// arrayToOption tests
|
|
42
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
test('arrayToOption creates Option from combined flags', (t) => {
|
|
45
|
-
const opt = arrayToOption(['--debug', 'enable debug output'])
|
|
46
|
-
|
|
47
|
-
t.true(opt instanceof Option)
|
|
48
|
-
t.is(opt.long, '--debug')
|
|
49
|
-
t.is(opt.description, 'enable debug output')
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('arrayToOption creates Option from separate short/long flags', (t) => {
|
|
53
|
-
const opt = arrayToOption(['-v', '--verbose', 'enable verbose output'])
|
|
54
|
-
|
|
55
|
-
t.true(opt instanceof Option)
|
|
56
|
-
t.is(opt.short, '-v')
|
|
57
|
-
t.is(opt.long, '--verbose')
|
|
58
|
-
t.is(opt.description, 'enable verbose output')
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test('arrayToOption applies choices from config object', (t) => {
|
|
62
|
-
const opt = arrayToOption([
|
|
63
|
-
'--lib <module>',
|
|
64
|
-
'library to use',
|
|
65
|
-
{ choices: ['pagedjs', 'prince'], default: 'pagedjs' }
|
|
66
|
-
])
|
|
67
|
-
|
|
68
|
-
t.true(opt instanceof Option)
|
|
69
|
-
t.deepEqual(opt.argChoices, ['pagedjs', 'prince'])
|
|
70
|
-
t.is(opt.defaultValue, 'pagedjs')
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test('arrayToOption applies default from positional argument', (t) => {
|
|
74
|
-
const opt = arrayToOption(['--port <number>', 'port to use', 8080])
|
|
75
|
-
|
|
76
|
-
t.true(opt instanceof Option)
|
|
77
|
-
t.is(opt.defaultValue, 8080)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('arrayToOption handles option with value placeholder', (t) => {
|
|
81
|
-
const opt = arrayToOption(['--output <path>', 'output directory'])
|
|
82
|
-
|
|
83
|
-
t.true(opt instanceof Option)
|
|
84
|
-
t.is(opt.long, '--output')
|
|
85
|
-
t.true(opt.required) // option requires a value
|
|
86
|
-
})
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared option definitions for CLI commands
|
|
3
|
-
*
|
|
4
|
-
* Provides consistent option definitions that can be imported by commands.
|
|
5
|
-
* This ensures uniform help text, flags, and behavior across the CLI.
|
|
6
|
-
*
|
|
7
|
-
* ## Recommended Usage
|
|
8
|
-
*
|
|
9
|
-
* Use `withOutputModes()` to wrap your command definition:
|
|
10
|
-
*
|
|
11
|
-
* ```javascript
|
|
12
|
-
* import { withOutputModes } from '#lib/commander/index.js'
|
|
13
|
-
*
|
|
14
|
-
* export default class MyCommand extends Command {
|
|
15
|
-
* static definition = withOutputModes({
|
|
16
|
-
* name: 'my-command',
|
|
17
|
-
* description: 'Do something useful',
|
|
18
|
-
* helpText: `
|
|
19
|
-
* Examples:
|
|
20
|
-
* quire my-command --verbose
|
|
21
|
-
* `,
|
|
22
|
-
* options: [
|
|
23
|
-
* ['--custom', 'my custom option'],
|
|
24
|
-
* ],
|
|
25
|
-
* })
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* This automatically adds --quiet, --verbose, --debug options and prepends
|
|
30
|
-
* the standard output mode help text.
|
|
31
|
-
*
|
|
32
|
-
* ## Selective Options
|
|
33
|
-
*
|
|
34
|
-
* For commands that need only specific output options:
|
|
35
|
-
*
|
|
36
|
-
* ```javascript
|
|
37
|
-
* import { quietOption, verboseOption } from '#lib/commander/index.js'
|
|
38
|
-
*
|
|
39
|
-
* options: [
|
|
40
|
-
* quietOption,
|
|
41
|
-
* verboseOption,
|
|
42
|
-
* // No --debug for this command
|
|
43
|
-
* ]
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* ## Commander.js Boolean Negation
|
|
47
|
-
*
|
|
48
|
-
* Boolean options automatically support negation via Commander.js.
|
|
49
|
-
* For example, `--verbose` automatically supports `--no-verbose`.
|
|
50
|
-
*
|
|
51
|
-
* This enables the config fallback pattern:
|
|
52
|
-
* - `--verbose` → options.verbose = true
|
|
53
|
-
* - `--no-verbose` → options.verbose = false
|
|
54
|
-
* - (no flag) → options.verbose = undefined (falls back to config)
|
|
55
|
-
*
|
|
56
|
-
* @see https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
57
|
-
* @module lib/commander/options
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Quiet mode option - suppress progress output
|
|
62
|
-
*
|
|
63
|
-
* Use for CI/CD pipelines and automated scripts where spinner
|
|
64
|
-
* output would clutter logs. Exit codes still indicate success/failure.
|
|
65
|
-
*
|
|
66
|
-
* Conflicts with --verbose and --debug since quiet mode suppresses
|
|
67
|
-
* the output those modes would show.
|
|
68
|
-
*
|
|
69
|
-
* @type {Array}
|
|
70
|
-
*/
|
|
71
|
-
export const quietOption = [
|
|
72
|
-
'-q, --quiet', 'suppress progress output',
|
|
73
|
-
{ conflicts: ['verbose', 'debug'] }
|
|
74
|
-
]
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Verbose mode option - show detailed progress
|
|
78
|
-
*
|
|
79
|
-
* Shows additional information like file paths, timing data,
|
|
80
|
-
* and step-by-step progress. Useful when users want more
|
|
81
|
-
* visibility into what the CLI is doing.
|
|
82
|
-
*
|
|
83
|
-
* Respects config default: `quire settings set verbose true`
|
|
84
|
-
* Conflicts with --quiet since quiet mode suppresses output.
|
|
85
|
-
*
|
|
86
|
-
* @type {Array}
|
|
87
|
-
*/
|
|
88
|
-
export const verboseOption = [
|
|
89
|
-
'-v, --verbose', 'show detailed progress output',
|
|
90
|
-
{ conflicts: ['quiet'] }
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Progress option - hidden alias for --verbose
|
|
95
|
-
*
|
|
96
|
-
* Provides a familiar `--progress` flag as an alternative to `--verbose`.
|
|
97
|
-
* Many users expect `--progress` to show detailed output during long-running
|
|
98
|
-
* operations like builds and file deletions.
|
|
99
|
-
*
|
|
100
|
-
* Hidden from help output since --verbose is the canonical flag.
|
|
101
|
-
* Uses `implies` to set verbose=true when --progress is used.
|
|
102
|
-
*
|
|
103
|
-
* @type {Array}
|
|
104
|
-
*/
|
|
105
|
-
const progressOption = [
|
|
106
|
-
'--progress', 'show detailed progress (alias for --verbose)',
|
|
107
|
-
{ hidden: true, implies: { verbose: true } }
|
|
108
|
-
]
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Debug mode option - enable debug output
|
|
112
|
-
*
|
|
113
|
-
* Enables the DEBUG=quire:* namespace for internal logging.
|
|
114
|
-
* Outputs technical debugging information intended for developers
|
|
115
|
-
* and maintainers troubleshooting issues.
|
|
116
|
-
*
|
|
117
|
-
* Respects config default: `quire settings set debug true`
|
|
118
|
-
* Conflicts with --quiet since quiet mode suppresses output.
|
|
119
|
-
*
|
|
120
|
-
* @type {Array}
|
|
121
|
-
*/
|
|
122
|
-
export const debugOption = [
|
|
123
|
-
'--debug', 'enable debug output for troubleshooting',
|
|
124
|
-
{ conflicts: ['quiet'] }
|
|
125
|
-
]
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Reduced motion option - disable spinner animation and line overwriting
|
|
129
|
-
*
|
|
130
|
-
* When enabled, the reporter outputs static text on new lines instead of
|
|
131
|
-
* animated spinners that overwrite the current line. This is useful for:
|
|
132
|
-
* - Screen reader users (animated overwriting disrupts reading flow)
|
|
133
|
-
* - Users who prefer reduced motion
|
|
134
|
-
* - Environments where terminal animation is problematic
|
|
135
|
-
*
|
|
136
|
-
* Respects config default: `quire settings set reducedMotion true`
|
|
137
|
-
* Also respects REDUCED_MOTION environment variable.
|
|
138
|
-
*
|
|
139
|
-
* @type {Array}
|
|
140
|
-
*/
|
|
141
|
-
export const reducedMotionOption = [
|
|
142
|
-
'--reduced-motion', 'disable spinner animation and line overwriting',
|
|
143
|
-
]
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Color options - enable/disable colored output
|
|
147
|
-
*
|
|
148
|
-
* Commander.js requires separate option definitions for --color and --no-color
|
|
149
|
-
* to support both the positive and negative forms. When --color has no default,
|
|
150
|
-
* the three-state semantics are:
|
|
151
|
-
*
|
|
152
|
-
* - `--color` → options.color = true (force color on)
|
|
153
|
-
* - `--no-color` → options.color = false (force color off)
|
|
154
|
-
* - (no flag) → options.color = undefined (falls back to env/config)
|
|
155
|
-
*
|
|
156
|
-
* Respects the NO_COLOR environment variable (https://no-color.org/).
|
|
157
|
-
* Respects config default: `quire settings set logUseColor false`
|
|
158
|
-
*
|
|
159
|
-
* @type {Array[]}
|
|
160
|
-
*/
|
|
161
|
-
export const colorOption = [
|
|
162
|
-
'--color', 'force colored output (overrides NO_COLOR env var)',
|
|
163
|
-
]
|
|
164
|
-
|
|
165
|
-
export const noColorOption = [
|
|
166
|
-
'--no-color', 'disable colored output',
|
|
167
|
-
]
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Standard output mode options (quiet, verbose, debug, progress)
|
|
171
|
-
*
|
|
172
|
-
* Most commands should include all three options for consistent UX.
|
|
173
|
-
* Spread this array into your command's options:
|
|
174
|
-
*
|
|
175
|
-
* ```javascript
|
|
176
|
-
* options: [
|
|
177
|
-
* ...outputModeOptions,
|
|
178
|
-
* ['--my-option', 'custom option'],
|
|
179
|
-
* ]
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @type {string[][]}
|
|
183
|
-
*/
|
|
184
|
-
export const outputModeOptions = [
|
|
185
|
-
quietOption,
|
|
186
|
-
verboseOption,
|
|
187
|
-
progressOption,
|
|
188
|
-
debugOption,
|
|
189
|
-
]
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Standard help text for output modes
|
|
193
|
-
*
|
|
194
|
-
* @type {string}
|
|
195
|
-
*/
|
|
196
|
-
export const outputModeHelpText = `Output Modes:
|
|
197
|
-
-q, --quiet Suppress progress output (for CI/scripts)
|
|
198
|
-
-v, --verbose Show detailed progress (paths, timing)
|
|
199
|
-
--progress Alias for --verbose
|
|
200
|
-
--debug Enable debug output for troubleshooting`
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Add output mode options to a command definition
|
|
204
|
-
*
|
|
205
|
-
* Injects --quiet, --verbose, --debug options and prepends the
|
|
206
|
-
* standard output mode help text to the command's helpText.
|
|
207
|
-
*
|
|
208
|
-
* @param {Object} definition - Command definition object
|
|
209
|
-
* @param {string} [definition.helpText] - Existing help text (output modes prepended)
|
|
210
|
-
* @param {Array} [definition.options] - Existing options (output modes appended)
|
|
211
|
-
* @returns {Object} Modified definition with output mode options
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* static definition = withOutputModes({
|
|
215
|
-
* name: 'build',
|
|
216
|
-
* description: 'Generate publication outputs',
|
|
217
|
-
* helpText: `
|
|
218
|
-
* Examples:
|
|
219
|
-
* quire build --verbose
|
|
220
|
-
* `,
|
|
221
|
-
* options: [
|
|
222
|
-
* ['--custom', 'my option'],
|
|
223
|
-
* ],
|
|
224
|
-
* })
|
|
225
|
-
*/
|
|
226
|
-
export function withOutputModes(definition) {
|
|
227
|
-
return {
|
|
228
|
-
...definition,
|
|
229
|
-
helpText: definition.helpText
|
|
230
|
-
? `\n${outputModeHelpText}\n${definition.helpText}`
|
|
231
|
-
: `\n${outputModeHelpText}`,
|
|
232
|
-
options: [
|
|
233
|
-
...(definition.options || []),
|
|
234
|
-
...outputModeOptions,
|
|
235
|
-
],
|
|
236
|
-
}
|
|
237
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import { Command } from 'commander'
|
|
3
|
-
import { arrayToOption } from './index.js'
|
|
4
|
-
import { colorOption, noColorOption, quietOption, verboseOption, debugOption, reducedMotionOption } from './options.js'
|
|
5
|
-
|
|
6
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
-
// Integration tests for option conflicts
|
|
8
|
-
//
|
|
9
|
-
// These tests verify that Commander.js correctly enforces the option conflicts
|
|
10
|
-
// at parse time.
|
|
11
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Helper to create a test program with the shared options
|
|
15
|
-
*/
|
|
16
|
-
function createTestProgram() {
|
|
17
|
-
const program = new Command()
|
|
18
|
-
program
|
|
19
|
-
.addOption(arrayToOption(colorOption))
|
|
20
|
-
.addOption(arrayToOption(noColorOption))
|
|
21
|
-
.addOption(arrayToOption(quietOption))
|
|
22
|
-
.addOption(arrayToOption(verboseOption))
|
|
23
|
-
.addOption(arrayToOption(debugOption))
|
|
24
|
-
.addOption(arrayToOption(reducedMotionOption))
|
|
25
|
-
.action(() => {})
|
|
26
|
-
.exitOverride() // Throw instead of process.exit
|
|
27
|
-
.configureOutput({
|
|
28
|
-
writeErr: () => {}, // Suppress error output
|
|
29
|
-
})
|
|
30
|
-
return program
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
test('--quiet alone is valid', (t) => {
|
|
34
|
-
const program = createTestProgram()
|
|
35
|
-
|
|
36
|
-
t.notThrows(() => {
|
|
37
|
-
program.parse(['node', 'test', '--quiet'])
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('--verbose alone is valid', (t) => {
|
|
42
|
-
const program = createTestProgram()
|
|
43
|
-
|
|
44
|
-
t.notThrows(() => {
|
|
45
|
-
program.parse(['node', 'test', '--verbose'])
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('--debug alone is valid', (t) => {
|
|
50
|
-
const program = createTestProgram()
|
|
51
|
-
|
|
52
|
-
t.notThrows(() => {
|
|
53
|
-
program.parse(['node', 'test', '--debug'])
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('--verbose --debug together is valid', (t) => {
|
|
58
|
-
const program = createTestProgram()
|
|
59
|
-
|
|
60
|
-
t.notThrows(() => {
|
|
61
|
-
program.parse(['node', 'test', '--verbose', '--debug'])
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('--quiet --verbose throws conflict error', (t) => {
|
|
66
|
-
const program = createTestProgram()
|
|
67
|
-
|
|
68
|
-
const error = t.throws(() => {
|
|
69
|
-
program.parse(['node', 'test', '--quiet', '--verbose'])
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
t.true(error.message.includes('cannot be used with'))
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('--quiet --debug throws conflict error', (t) => {
|
|
76
|
-
const program = createTestProgram()
|
|
77
|
-
|
|
78
|
-
const error = t.throws(() => {
|
|
79
|
-
program.parse(['node', 'test', '--quiet', '--debug'])
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
t.true(error.message.includes('cannot be used with'))
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('--quiet --verbose --debug throws conflict error', (t) => {
|
|
86
|
-
const program = createTestProgram()
|
|
87
|
-
|
|
88
|
-
const error = t.throws(() => {
|
|
89
|
-
program.parse(['node', 'test', '--quiet', '--verbose', '--debug'])
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
t.true(error.message.includes('cannot be used with'))
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test('-q -v (short flags) throws conflict error', (t) => {
|
|
96
|
-
const program = createTestProgram()
|
|
97
|
-
|
|
98
|
-
const error = t.throws(() => {
|
|
99
|
-
program.parse(['node', 'test', '-q', '-v'])
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
t.true(error.message.includes('cannot be used with'))
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test('options order does not affect conflict detection', (t) => {
|
|
106
|
-
const program1 = createTestProgram()
|
|
107
|
-
const program2 = createTestProgram()
|
|
108
|
-
|
|
109
|
-
// Both orders should throw
|
|
110
|
-
t.throws(() => program1.parse(['node', 'test', '--quiet', '--verbose']))
|
|
111
|
-
t.throws(() => program2.parse(['node', 'test', '--verbose', '--quiet']))
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
115
|
-
// Reduced motion option tests
|
|
116
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
117
|
-
|
|
118
|
-
test('--reduced-motion alone is valid', (t) => {
|
|
119
|
-
const program = createTestProgram()
|
|
120
|
-
|
|
121
|
-
t.notThrows(() => {
|
|
122
|
-
program.parse(['node', 'test', '--reduced-motion'])
|
|
123
|
-
})
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test('--reduced-motion sets opts.reducedMotion to true', (t) => {
|
|
127
|
-
const program = createTestProgram()
|
|
128
|
-
program.parse(['node', 'test', '--reduced-motion'])
|
|
129
|
-
|
|
130
|
-
t.is(program.opts().reducedMotion, true)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test('no flag leaves opts.reducedMotion as undefined', (t) => {
|
|
134
|
-
const program = createTestProgram()
|
|
135
|
-
program.parse(['node', 'test'])
|
|
136
|
-
|
|
137
|
-
t.is(program.opts().reducedMotion, undefined)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test('--reduced-motion combines with --verbose without conflict', (t) => {
|
|
141
|
-
const program = createTestProgram()
|
|
142
|
-
|
|
143
|
-
t.notThrows(() => {
|
|
144
|
-
program.parse(['node', 'test', '--reduced-motion', '--verbose'])
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
test('--reduced-motion combines with --quiet without conflict', (t) => {
|
|
149
|
-
const program = createTestProgram()
|
|
150
|
-
|
|
151
|
-
t.notThrows(() => {
|
|
152
|
-
program.parse(['node', 'test', '--reduced-motion', '--quiet'])
|
|
153
|
-
})
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
test('--reduced-motion combines with --debug without conflict', (t) => {
|
|
157
|
-
const program = createTestProgram()
|
|
158
|
-
|
|
159
|
-
t.notThrows(() => {
|
|
160
|
-
program.parse(['node', 'test', '--reduced-motion', '--debug'])
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
165
|
-
// Color option tests
|
|
166
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
167
|
-
|
|
168
|
-
test('--no-color sets color to false', (t) => {
|
|
169
|
-
const program = createTestProgram()
|
|
170
|
-
program.parse(['node', 'test', '--no-color'])
|
|
171
|
-
t.is(program.opts().color, false)
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
test('--color sets color to true', (t) => {
|
|
175
|
-
const program = createTestProgram()
|
|
176
|
-
program.parse(['node', 'test', '--color'])
|
|
177
|
-
t.is(program.opts().color, true)
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
test('no color flag leaves color undefined', (t) => {
|
|
181
|
-
const program = createTestProgram()
|
|
182
|
-
program.parse(['node', 'test'])
|
|
183
|
-
t.is(program.opts().color, undefined)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
test('--no-color can be combined with --verbose', (t) => {
|
|
187
|
-
const program = createTestProgram()
|
|
188
|
-
t.notThrows(() => {
|
|
189
|
-
program.parse(['node', 'test', '--no-color', '--verbose'])
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
test('--no-color can be combined with --quiet', (t) => {
|
|
194
|
-
const program = createTestProgram()
|
|
195
|
-
t.notThrows(() => {
|
|
196
|
-
program.parse(['node', 'test', '--no-color', '--quiet'])
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
test('--no-color can be combined with --debug', (t) => {
|
|
201
|
-
const program = createTestProgram()
|
|
202
|
-
t.notThrows(() => {
|
|
203
|
-
program.parse(['node', 'test', '--no-color', '--debug'])
|
|
204
|
-
})
|
|
205
|
-
})
|