@antora/cli 3.0.3 → 3.1.1
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/lib/cli.js +11 -4
- package/lib/commander/options-from-convict.js +4 -2
- package/package.json +13 -6
package/lib/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const buildPlaybook = require('@antora/playbook-builder')
|
|
4
4
|
const cli = require('./commander')
|
|
5
|
-
const convict = require('@antora/playbook-builder/lib/solitary-convict')
|
|
5
|
+
const convict = require('@antora/playbook-builder/lib/solitary-convict') // drop lib segment in Antora 4
|
|
6
6
|
const ospath = require('path')
|
|
7
7
|
const userRequire = require('@antora/user-require-helper')
|
|
8
8
|
|
|
@@ -13,7 +13,6 @@ async function run (argv = process.argv) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function exitWithError (err, opts, msg = undefined) {
|
|
16
|
-
const { getLogger, configureLogger } = requireLogger()
|
|
17
16
|
let errMessage = String(
|
|
18
17
|
err instanceof Error ? err.message : Object.assign((err = new Error(String(err))), { stack: undefined }).message
|
|
19
18
|
)
|
|
@@ -21,6 +20,8 @@ function exitWithError (err, opts, msg = undefined) {
|
|
|
21
20
|
? (errMessage = errMessage.slice(21)) && 'asciidoctor'
|
|
22
21
|
: cli.name()
|
|
23
22
|
if (!msg) msg = errMessage
|
|
23
|
+
const { configureLogger, getLogger } = requireLogger()
|
|
24
|
+
if (!getLogger) return lastDitchExit(err, msg)
|
|
24
25
|
if (!getLogger(null)) {
|
|
25
26
|
configureLogger({ format: 'pretty', level: opts.silent ? 'silent' : 'fatal', failureLevel: 'fatal' })
|
|
26
27
|
}
|
|
@@ -38,6 +39,12 @@ function exit () {
|
|
|
38
39
|
.then((failOnExit) => process.exitCode || (process.exitCode = failOnExit ? 1 : 0))
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
function lastDitchExit (err, msg) {
|
|
43
|
+
if (msg !== err.message) console.error(msg)
|
|
44
|
+
console.error(err)
|
|
45
|
+
process.exitCode = process.exitCode || 1
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
function getTTYColumns () {
|
|
42
49
|
return +process.env.COLUMNS || process.stdout.columns || 80
|
|
43
50
|
}
|
|
@@ -53,7 +60,7 @@ function requireLogger (fromPath = undefined, moduleName = '@antora/logger') {
|
|
|
53
60
|
(requireLogger.cache = fromPath ? userRequire(moduleName, { paths: [fromPath] }) : require(moduleName))
|
|
54
61
|
) // dynamic require('@antora/logger')
|
|
55
62
|
} catch {
|
|
56
|
-
return fromPath
|
|
63
|
+
return fromPath ? (requireLogger.cache = require(moduleName)) : {}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -152,7 +159,7 @@ cli.command('help [command]', { hidden: true }).action((name, options, command)
|
|
|
152
159
|
helpCommand.help()
|
|
153
160
|
} else {
|
|
154
161
|
const message = `error: unknown command '${name}'. See '${cli.name()} --help' for a list of commands.`
|
|
155
|
-
cli.
|
|
162
|
+
cli.error(message, { code: 'commander.unknownCommand', exitCode: 1 })
|
|
156
163
|
}
|
|
157
164
|
} else {
|
|
158
165
|
cli.help()
|
|
@@ -27,10 +27,12 @@ function collectOptions (props, context = undefined) {
|
|
|
27
27
|
accum.push(...collectOptions(value._cvtProperties, context ? `${context}.${key}` : key))
|
|
28
28
|
} else if ('arg' in value) {
|
|
29
29
|
const { arg, format, default: default_ } = value
|
|
30
|
-
const option = { name: arg, form: `--${arg}`, description: value.doc, format
|
|
30
|
+
const option = { name: arg, form: `--${arg}`, description: value.doc, format }
|
|
31
31
|
if (Array.isArray(format)) {
|
|
32
32
|
option.form += ' <choice>'
|
|
33
|
-
|
|
33
|
+
const choices = format.slice()
|
|
34
|
+
const value = () => choices
|
|
35
|
+
Object.defineProperties((option.choices = choices), { map: { value }, slice: { value } })
|
|
34
36
|
} else if (format !== 'boolean') {
|
|
35
37
|
option.form += ` <${arg.substr(arg.lastIndexOf('-') + 1, arg.length)}>`
|
|
36
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "The command line interface for Antora.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -14,23 +14,30 @@
|
|
|
14
14
|
"url": "https://gitlab.com/antora/antora/issues"
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./lib/index.js",
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"imports": {
|
|
22
|
+
"#commander": "./lib/commander.js"
|
|
23
|
+
},
|
|
17
24
|
"bin": {
|
|
18
25
|
"antora": "bin/antora"
|
|
19
26
|
},
|
|
20
27
|
"dependencies": {
|
|
21
|
-
"@antora/logger": "3.
|
|
22
|
-
"@antora/playbook-builder": "3.
|
|
28
|
+
"@antora/logger": "3.1.1",
|
|
29
|
+
"@antora/playbook-builder": "3.1.1",
|
|
23
30
|
"@antora/user-require-helper": "~2.0",
|
|
24
|
-
"commander": "~
|
|
31
|
+
"commander": "~9.4"
|
|
25
32
|
},
|
|
26
33
|
"devDependencies": {
|
|
27
|
-
"@antora/site-publisher": "3.
|
|
34
|
+
"@antora/site-publisher": "3.1.1",
|
|
28
35
|
"@asciidoctor/core": "~2.2",
|
|
29
36
|
"convict": "~6.2",
|
|
30
37
|
"kapok-js": "~0.10"
|
|
31
38
|
},
|
|
32
39
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
40
|
+
"node": ">=16.0.0"
|
|
34
41
|
},
|
|
35
42
|
"files": [
|
|
36
43
|
"bin/",
|