@antora/cli 3.2.0-alpha.9 → 3.2.0-rc.2

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 CHANGED
@@ -17,7 +17,7 @@ function exitWithError (err, opts, msg = undefined) {
17
17
  err instanceof Error ? err.message : Object.assign((err = new Error(String(err))), { stack: undefined }).message
18
18
  )
19
19
  const name = errMessage.startsWith('asciidoctor: FAILED: ')
20
- ? (errMessage = errMessage.slice(21)) && 'asciidoctor'
20
+ ? (errMessage = errMessage.substring(21)) && 'asciidoctor'
21
21
  : cli.name()
22
22
  if (!msg) msg = errMessage
23
23
  const { configureLogger, getLogger } = requireLogger()
@@ -30,19 +30,19 @@ function exitWithError (err, opts, msg = undefined) {
30
30
  } else {
31
31
  getLogger(name).fatal({ hint: 'Add the --stacktrace option to see the cause of the error.' }, msg)
32
32
  }
33
- return exit()
33
+ return exit(1)
34
34
  }
35
35
 
36
- function exit () {
36
+ function exit (failureExitCode = 2) {
37
37
  return requireLogger()
38
38
  .finalizeLogger()
39
- .then((failOnExit) => process.exitCode || (process.exitCode = failOnExit ? 1 : 0))
39
+ .then((failOnExit) => process.exitCode || (process.exitCode = failOnExit ? failureExitCode : 0))
40
40
  }
41
41
 
42
42
  function lastDitchExit (err, msg) {
43
43
  if (msg !== err.message) console.error(msg)
44
44
  console.error(err)
45
- process.exitCode = process.exitCode || 1
45
+ process.exitCode ||= 3
46
46
  }
47
47
 
48
48
  function getTTYColumns () {
@@ -67,7 +67,6 @@ function requireLogger (fromPath = undefined, moduleName = '@antora/logger') {
67
67
  cli
68
68
  .allowExcessArguments(false)
69
69
  .configureOutput({ getOutHelpWidth: getTTYColumns, getErrHelpWidth: getTTYColumns, outputError })
70
- .storeOptionsAsProperties()
71
70
  .name('antora')
72
71
  .version(
73
72
  {
@@ -97,14 +96,16 @@ cli
97
96
  const name = cli.name()
98
97
  return cli
99
98
  .createHelp()
100
- .wrap(
99
+ .boxWrap(
101
100
  ` \nRun '${name} <command> --help' to see options and examples for a command (e.g., ${name} generate --help).`,
102
101
  getTTYColumns(),
103
102
  0
104
103
  )
105
104
  })
106
105
  .option('-r, --require <library>', 'Require library (aka node module) or script path before executing command.')
107
- .on('option:require', (requireRequest) => (cli.requireRequests = cli.requireRequests || []).push(requireRequest))
106
+ .on('option:require', (requireRequest) => {
107
+ cli.setOptionValueWithSource('requires', (cli.getOptionValue('requires') || []).concat(requireRequest), 'cli')
108
+ })
108
109
  .option('--stacktrace', 'Print the stacktrace to the console if the application fails.')
109
110
 
110
111
  cli
@@ -113,12 +114,13 @@ cli
113
114
  .optionsFromConvict(convict(buildPlaybook.defaultSchema), { exclude: 'playbook' })
114
115
  .trackOptions()
115
116
  .action(async (playbookFile, _options, command) => {
116
- const errorOpts = { stacktrace: cli.stacktrace, silent: command.silent }
117
+ const errorOpts = { stacktrace: cli.getOptionValue('stacktrace'), silent: command.getOptionValue('silent') }
117
118
  const playbookDir = ospath.resolve(playbookFile, '..')
118
119
  const userRequireContext = { dot: playbookDir, paths: [playbookDir, __dirname] }
119
- if (cli.requireRequests) {
120
+ const requires = cli.getOptionValue('requires') || []
121
+ if (requires.length) {
120
122
  try {
121
- cli.requireRequests.forEach((requireRequest) => userRequire(requireRequest, userRequireContext))
123
+ requires.forEach((requireRequest) => userRequire(requireRequest, userRequireContext))
122
124
  } catch (err) {
123
125
  return exitWithError(err, errorOpts)
124
126
  }
@@ -148,7 +150,10 @@ cli
148
150
  if (generator && generator.charAt() !== '.') msg += ` Try installing the '${generator}' package.`
149
151
  return exitWithError(err, errorOpts, msg)
150
152
  }
151
- return generateSite().then(exit, (err) => exitWithError(err, errorOpts))
153
+ return generateSite().then(
154
+ () => exit(),
155
+ (err) => exitWithError(err, errorOpts)
156
+ )
152
157
  })
153
158
  .options.sort((a, b) => a.long.localeCompare(b.long))
154
159
 
@@ -34,7 +34,7 @@ function collectOptions (props, context = undefined) {
34
34
  const value = () => choices
35
35
  Object.defineProperties((option.choices = choices), { map: { value }, slice: { value } })
36
36
  } else if (format !== 'boolean') {
37
- option.form += ` <${arg.substr(arg.lastIndexOf('-') + 1, arg.length)}>`
37
+ option.form += ` <${arg.substring(arg.lastIndexOf('-') + 1)}>`
38
38
  }
39
39
  if (default_ === null) {
40
40
  //option.mandatory = true
@@ -5,9 +5,8 @@ const { Command } = require('commander')
5
5
  Command.prototype.trackOptions = function () {
6
6
  const optionArgs = (this.optionArgs = [])
7
7
  for (const eventName of this.eventNames().filter((name) => name.startsWith('option:'))) {
8
- // biome-ignore lint/complexity/useArrowFunction: needed to access arguments
9
8
  this.on(eventName, function () {
10
- optionArgs.push(`--${eventName.slice(7)}`)
9
+ optionArgs.push(`--${eventName.substring(7)}`)
11
10
  if (arguments.length) optionArgs.push(arguments[0])
12
11
  })
13
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/cli",
3
- "version": "3.2.0-alpha.9",
3
+ "version": "3.2.0-rc.2",
4
4
  "description": "The command line interface for Antora.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -29,20 +29,19 @@
29
29
  "antora": "bin/antora"
30
30
  },
31
31
  "dependencies": {
32
- "@antora/logger": "3.2.0-alpha.9",
33
- "@antora/playbook-builder": "3.2.0-alpha.9",
32
+ "@antora/logger": "3.2.0-rc.2",
33
+ "@antora/playbook-builder": "3.2.0-rc.2",
34
34
  "@antora/user-require-helper": "~3.0",
35
- "commander": "~12.1"
35
+ "commander": "~14.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@antora/site-generator": "3.2.0-alpha.9",
39
- "@antora/site-publisher": "3.2.0-alpha.9",
38
+ "@antora/site-generator": "3.2.0-rc.2",
39
+ "@antora/site-publisher": "3.2.0-rc.2",
40
40
  "@asciidoctor/core": "~2.2",
41
- "convict": "~6.2",
42
- "kapok-js": "~0.10"
41
+ "convict": "~6.2"
43
42
  },
44
43
  "engines": {
45
- "node": ">=18.0.0"
44
+ "node": ">=20.0.0"
46
45
  },
47
46
  "files": [
48
47
  "bin/",
@@ -57,7 +56,7 @@
57
56
  "web publishing"
58
57
  ],
59
58
  "scripts": {
60
- "test": "_mocha",
59
+ "test": "node --test",
61
60
  "prepublishOnly": "npx -y downdoc@latest --prepublish",
62
61
  "postpublish": "npx -y downdoc@latest --postpublish"
63
62
  }