@thegetty/quire-cli 1.0.0-rc.45 → 1.0.0-rc.47
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 +10 -27
- 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/man/quire.1 +0 -341
- package/man/quire.1.md +0 -232
- 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,106 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import chalk from 'chalk'
|
|
3
|
-
import {
|
|
4
|
-
getKeyDescription,
|
|
5
|
-
formatSettings,
|
|
6
|
-
} from './format.js'
|
|
7
|
-
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// getKeyDescription
|
|
10
|
-
// =============================================================================
|
|
11
|
-
|
|
12
|
-
test('getKeyDescription returns description for known key', (t) => {
|
|
13
|
-
const desc = getKeyDescription('logLevel')
|
|
14
|
-
t.is(typeof desc, 'string')
|
|
15
|
-
t.true(desc.length > 0)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('getKeyDescription returns undefined for unknown key', (t) => {
|
|
19
|
-
t.is(getKeyDescription('unknownKey'), undefined)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
// =============================================================================
|
|
23
|
-
// formatSettings (plain, useColor=false)
|
|
24
|
-
// =============================================================================
|
|
25
|
-
|
|
26
|
-
test('formatSettings includes header with config path', (t) => {
|
|
27
|
-
const output = formatSettings({}, { configPath: '/mock/path' })
|
|
28
|
-
t.true(output.includes('quire-cli configuration /mock/path'))
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('formatSettings includes header without config path', (t) => {
|
|
32
|
-
const output = formatSettings({})
|
|
33
|
-
t.true(output.includes('quire-cli configuration'))
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('formatSettings includes key-value pairs', (t) => {
|
|
37
|
-
const store = { logLevel: 'info', logShowLevel: false }
|
|
38
|
-
const output = formatSettings(store)
|
|
39
|
-
t.true(output.includes('logLevel: "info"'))
|
|
40
|
-
t.true(output.includes('logShowLevel: false'))
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('formatSettings includes schema descriptions', (t) => {
|
|
44
|
-
const store = { logLevel: 'info' }
|
|
45
|
-
const output = formatSettings(store)
|
|
46
|
-
const desc = getKeyDescription('logLevel')
|
|
47
|
-
t.true(output.includes(desc))
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('formatSettings hides __internal__ keys by default', (t) => {
|
|
51
|
-
const store = { logLevel: 'info', __internal__secret: 'hidden' }
|
|
52
|
-
const output = formatSettings(store)
|
|
53
|
-
t.false(output.includes('__internal__secret'))
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
test('formatSettings shows __internal__ keys with showInternal', (t) => {
|
|
57
|
-
const store = { logLevel: 'info', __internal__secret: 'hidden' }
|
|
58
|
-
const output = formatSettings(store, { showInternal: true })
|
|
59
|
-
t.true(output.includes('__internal__secret'))
|
|
60
|
-
t.true(output.includes('"hidden"'))
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('formatSettings includes help hint', (t) => {
|
|
64
|
-
const output = formatSettings({})
|
|
65
|
-
t.true(output.includes('Use "quire settings set <key> <value>" to change a setting'))
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
// =============================================================================
|
|
69
|
-
// formatSettings (useColor=true)
|
|
70
|
-
// =============================================================================
|
|
71
|
-
|
|
72
|
-
test('formatSettings with useColor applies bold to header', (t) => {
|
|
73
|
-
const output = formatSettings({}, { useColor: true })
|
|
74
|
-
t.true(output.includes(chalk.bold('quire-cli configuration')))
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('formatSettings with useColor applies bold to header with path', (t) => {
|
|
78
|
-
const output = formatSettings({}, { useColor: true, configPath: '/mock/path' })
|
|
79
|
-
t.true(output.includes(chalk.bold('quire-cli configuration /mock/path')))
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
test('formatSettings with useColor applies cyan to key names', (t) => {
|
|
83
|
-
const store = { logLevel: 'info' }
|
|
84
|
-
const output = formatSettings(store, { useColor: true })
|
|
85
|
-
t.true(output.includes(chalk.cyan('logLevel')))
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('formatSettings with useColor applies dim to descriptions', (t) => {
|
|
89
|
-
const store = { logLevel: 'info' }
|
|
90
|
-
const output = formatSettings(store, { useColor: true })
|
|
91
|
-
const desc = getKeyDescription('logLevel')
|
|
92
|
-
t.true(output.includes(chalk.dim(desc)))
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test('formatSettings with useColor applies dim to help hint', (t) => {
|
|
96
|
-
const output = formatSettings({}, { useColor: true })
|
|
97
|
-
t.true(output.includes(chalk.dim('Use "quire settings set <key> <value>" to change a setting')))
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
test('formatSettings without useColor does not apply ANSI codes', (t) => {
|
|
101
|
-
const store = { logLevel: 'info' }
|
|
102
|
-
const output = formatSettings(store)
|
|
103
|
-
// Plain output should not contain ANSI escape sequences
|
|
104
|
-
// eslint-disable-next-line no-control-regex
|
|
105
|
-
t.false(/\u001b\[/.test(output))
|
|
106
|
-
})
|
package/src/lib/conf/helpers.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper functions for Quire configuration
|
|
3
|
-
*
|
|
4
|
-
* Provides schema-aware validation and coercion
|
|
5
|
-
* without side effects or dependencies on the Conf instance.
|
|
6
|
-
*
|
|
7
|
-
* Nota bene: these functions import only schema and defaults (pure data),
|
|
8
|
-
* avoiding circular dependencies with the logger module.
|
|
9
|
-
*
|
|
10
|
-
* @see ./format.js for display formatting functions
|
|
11
|
-
*/
|
|
12
|
-
import schema from './schema.js'
|
|
13
|
-
import defaults from './defaults.js'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Check whether a key is a valid configuration key
|
|
17
|
-
*
|
|
18
|
-
* @param {string} key - Configuration key to check
|
|
19
|
-
* @returns {boolean} True if the key exists in the schema
|
|
20
|
-
*/
|
|
21
|
-
export function isValidKey(key) {
|
|
22
|
-
return Object.hasOwn(schema, key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get all valid configuration keys
|
|
27
|
-
*
|
|
28
|
-
* @returns {string[]} Sorted array of valid configuration keys
|
|
29
|
-
*/
|
|
30
|
-
export function getValidKeys() {
|
|
31
|
-
return Object.keys(schema).sort()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Coerce a CLI string value to the appropriate type based on schema
|
|
36
|
-
*
|
|
37
|
-
* @param {string} key - Configuration key
|
|
38
|
-
* @param {string} value - String value from CLI input
|
|
39
|
-
* @returns {*} Coerced value matching the schema type
|
|
40
|
-
*/
|
|
41
|
-
export function coerceValue(key, value) {
|
|
42
|
-
const keySchema = schema[key]
|
|
43
|
-
if (!keySchema) return value
|
|
44
|
-
|
|
45
|
-
switch (keySchema.type) {
|
|
46
|
-
case 'boolean':
|
|
47
|
-
if (value === 'true' || value === '1') return true
|
|
48
|
-
if (value === 'false' || value === '0') return false
|
|
49
|
-
return value
|
|
50
|
-
case 'number': {
|
|
51
|
-
const num = Number(value)
|
|
52
|
-
return isNaN(num) ? value : num
|
|
53
|
-
}
|
|
54
|
-
default:
|
|
55
|
-
return value
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Format a validation error with helpful information from the schema
|
|
61
|
-
*
|
|
62
|
-
* @param {string} key - Configuration key
|
|
63
|
-
* @param {*} value - The invalid value
|
|
64
|
-
* @returns {string} Formatted multiline error message
|
|
65
|
-
*/
|
|
66
|
-
export function formatValidationError(key, value) {
|
|
67
|
-
const keySchema = schema[key]
|
|
68
|
-
const lines = [`Invalid value for '${key}': ${JSON.stringify(value)}`]
|
|
69
|
-
|
|
70
|
-
if (keySchema) {
|
|
71
|
-
if (keySchema.enum) {
|
|
72
|
-
lines.push(`Valid values: ${keySchema.enum.join(', ')}`)
|
|
73
|
-
}
|
|
74
|
-
if (keySchema.description) {
|
|
75
|
-
lines.push(`Description: ${keySchema.description}`)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return lines.join('\n')
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get the default value for a configuration key
|
|
84
|
-
*
|
|
85
|
-
* @param {string} key - Configuration key
|
|
86
|
-
* @returns {*} Default value, or undefined if key has no default
|
|
87
|
-
*/
|
|
88
|
-
export function getDefault(key) {
|
|
89
|
-
return defaults[key]
|
|
90
|
-
}
|
|
91
|
-
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import {
|
|
3
|
-
isValidKey,
|
|
4
|
-
getValidKeys,
|
|
5
|
-
coerceValue,
|
|
6
|
-
formatValidationError,
|
|
7
|
-
getDefault,
|
|
8
|
-
} from './helpers.js'
|
|
9
|
-
|
|
10
|
-
// =============================================================================
|
|
11
|
-
// isValidKey
|
|
12
|
-
// =============================================================================
|
|
13
|
-
|
|
14
|
-
test('isValidKey returns true for a known schema key', (t) => {
|
|
15
|
-
t.true(isValidKey('logLevel'))
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('isValidKey returns true for all schema keys', (t) => {
|
|
19
|
-
const keys = getValidKeys()
|
|
20
|
-
for (const key of keys) {
|
|
21
|
-
t.true(isValidKey(key), `${key} should be valid`)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('isValidKey returns false for an unknown key', (t) => {
|
|
26
|
-
t.false(isValidKey('nonExistentKey'))
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test('isValidKey returns false for __internal__ prefixed keys', (t) => {
|
|
30
|
-
t.false(isValidKey('__internal__secretKey'))
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// =============================================================================
|
|
34
|
-
// getValidKeys
|
|
35
|
-
// =============================================================================
|
|
36
|
-
|
|
37
|
-
test('getValidKeys returns an array', (t) => {
|
|
38
|
-
const keys = getValidKeys()
|
|
39
|
-
t.true(Array.isArray(keys))
|
|
40
|
-
t.true(keys.length > 0)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('getValidKeys returns sorted keys', (t) => {
|
|
44
|
-
const keys = getValidKeys()
|
|
45
|
-
const sorted = [...keys].sort()
|
|
46
|
-
t.deepEqual(keys, sorted)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('getValidKeys includes expected keys', (t) => {
|
|
50
|
-
const keys = getValidKeys()
|
|
51
|
-
t.true(keys.includes('logLevel'))
|
|
52
|
-
t.true(keys.includes('quireVersion'))
|
|
53
|
-
t.true(keys.includes('projectTemplate'))
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
// =============================================================================
|
|
57
|
-
// coerceValue
|
|
58
|
-
// =============================================================================
|
|
59
|
-
|
|
60
|
-
test('coerceValue coerces "true" to boolean true', (t) => {
|
|
61
|
-
t.is(coerceValue('logShowLevel', 'true'), true)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
test('coerceValue coerces "false" to boolean false', (t) => {
|
|
65
|
-
t.is(coerceValue('logShowLevel', 'false'), false)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('coerceValue coerces "1" to boolean true for boolean schema', (t) => {
|
|
69
|
-
t.is(coerceValue('logShowLevel', '1'), true)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('coerceValue coerces "0" to boolean false for boolean schema', (t) => {
|
|
73
|
-
t.is(coerceValue('logShowLevel', '0'), false)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
test('coerceValue passes through non-boolean string for boolean schema', (t) => {
|
|
77
|
-
t.is(coerceValue('logShowLevel', 'maybe'), 'maybe')
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('coerceValue passes through string values for string schema', (t) => {
|
|
81
|
-
t.is(coerceValue('logLevel', 'debug'), 'debug')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('coerceValue passes through value for unknown key', (t) => {
|
|
85
|
-
t.is(coerceValue('unknownKey', 'someValue'), 'someValue')
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
// =============================================================================
|
|
89
|
-
// formatValidationError
|
|
90
|
-
// =============================================================================
|
|
91
|
-
|
|
92
|
-
test('formatValidationError includes invalid value', (t) => {
|
|
93
|
-
const error = formatValidationError('logLevel', 'invalid')
|
|
94
|
-
t.true(error.includes("Invalid value for 'logLevel'"))
|
|
95
|
-
t.true(error.includes('"invalid"'))
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test('formatValidationError includes valid enum values', (t) => {
|
|
99
|
-
const error = formatValidationError('logLevel', 'invalid')
|
|
100
|
-
t.true(error.includes('Valid values:'))
|
|
101
|
-
t.true(error.includes('info'))
|
|
102
|
-
t.true(error.includes('debug'))
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test('formatValidationError includes description', (t) => {
|
|
106
|
-
const error = formatValidationError('logLevel', 'invalid')
|
|
107
|
-
t.true(error.includes('Description:'))
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('formatValidationError handles key without enum', (t) => {
|
|
111
|
-
const error = formatValidationError('logPrefix', 123)
|
|
112
|
-
t.true(error.includes("Invalid value for 'logPrefix'"))
|
|
113
|
-
t.false(error.includes('Valid values:'))
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test('formatValidationError handles unknown key', (t) => {
|
|
117
|
-
const error = formatValidationError('unknownKey', 'value')
|
|
118
|
-
t.true(error.includes("Invalid value for 'unknownKey'"))
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
// =============================================================================
|
|
122
|
-
// getDefault
|
|
123
|
-
// =============================================================================
|
|
124
|
-
|
|
125
|
-
test('getDefault returns default value for known key', (t) => {
|
|
126
|
-
t.is(getDefault('logLevel'), 'info')
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test('getDefault returns default for boolean key', (t) => {
|
|
130
|
-
t.is(getDefault('logShowLevel'), false)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test('getDefault returns undefined for unknown key', (t) => {
|
|
134
|
-
t.is(getDefault('unknownKey'), undefined)
|
|
135
|
-
})
|
|
136
|
-
|
package/src/lib/conf/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Quire configuration module
|
|
3
|
-
*
|
|
4
|
-
* Exports the singleton Conf instance as the default export
|
|
5
|
-
* and named helper functions for schema-aware operations.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* import config from '#lib/conf/index.js'
|
|
9
|
-
* import { isValidKey, coerceValue } from '#lib/conf/index.js'
|
|
10
|
-
*/
|
|
11
|
-
export { default as default } from './config.js'
|
|
12
|
-
export {
|
|
13
|
-
isValidKey,
|
|
14
|
-
getValidKeys,
|
|
15
|
-
coerceValue,
|
|
16
|
-
formatValidationError,
|
|
17
|
-
getDefault,
|
|
18
|
-
} from './helpers.js'
|
|
19
|
-
export {
|
|
20
|
-
getKeyDescription,
|
|
21
|
-
formatSettings,
|
|
22
|
-
} from './format.js'
|
package/src/lib/constants.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared CLI constants
|
|
3
|
-
*
|
|
4
|
-
* Centralized constants used across the CLI to avoid duplication
|
|
5
|
-
* and ensure consistency.
|
|
6
|
-
*
|
|
7
|
-
* @module lib/constants
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Base URL for Quire documentation (without trailing slash)
|
|
12
|
-
*
|
|
13
|
-
* Use with URL constructor for path joining:
|
|
14
|
-
* @example
|
|
15
|
-
* new URL('install-uninstall/', DOCS_BASE_URL).href
|
|
16
|
-
* // => 'https://quire.getty.edu/docs-v1/install-uninstall/'
|
|
17
|
-
*/
|
|
18
|
-
export const DOCS_BASE_URL = 'https://quire.getty.edu/docs-v1'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Package name for quire-11ty
|
|
22
|
-
*/
|
|
23
|
-
export const QUIRE_11TY_PACKAGE = '@thegetty/quire-11ty'
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Minimum required Node.js major version
|
|
27
|
-
*/
|
|
28
|
-
export const REQUIRED_NODE_VERSION = 22
|