@antora/cli 3.0.0-beta.2 → 3.0.0-beta.6

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.
Files changed (3) hide show
  1. package/README.md +6 -4
  2. package/lib/cli.js +16 -30
  3. package/package.json +9 -5
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Antora CLI
2
2
 
3
3
  The command line interface (CLI) for Antora.
4
+ This package provides the `antora` command (i.e., bin script) to run Antora.
5
+ It does not include the site generator, which must be installed separately.
4
6
 
5
7
  [Antora](https://antora.org) is a modular static site generator designed for creating documentation sites from AsciiDoc documents.
6
8
  Its site generator aggregates documents from versioned content repositories and processes them using [Asciidoctor](https://asciidoctor.org).
@@ -13,7 +15,7 @@ Once these packages are installed, you can use the `antora` command to generate
13
15
  Let's start by installing the CLI.
14
16
 
15
17
  ```sh
16
- npm install -g @antora/cli
18
+ npm i -g @antora/cli
17
19
  ```
18
20
 
19
21
  This package adds the `antora` command to your PATH.
@@ -24,10 +26,10 @@ antora -v
24
26
  ```
25
27
 
26
28
  Next, install a site generator.
27
- The default site generator will be sufficient for most users.
29
+ The site generator provided by Antora will be sufficient for most users.
28
30
 
29
31
  ```sh
30
- npm install -g @antora/site-generator-default
32
+ npm i -g @antora/site-generator
31
33
  ```
32
34
 
33
35
  The `antora` command (specifically the implicit `generate` subcommand) will look for this package by default.
@@ -37,7 +39,7 @@ The `antora` command (specifically the implicit `generate` subcommand) will look
37
39
  To run Antora, you'll need a playbook file and at least one content (source) repository.
38
40
  Consult the [quickstart](https://docs.antora.org/antora/latest/install-and-run-quickstart/) to find an example.
39
41
 
40
- Once you have your content sources set up, just point the `antora` command at your playbook file:
42
+ Once you have your content sources set up, point the `antora` command at your playbook file:
41
43
 
42
44
  ```sh
43
45
  antora antora-playbook.yml
package/lib/cli.js CHANGED
@@ -9,38 +9,25 @@ const userRequire = require('@antora/user-require-helper')
9
9
  const { version: VERSION } = require('../package.json')
10
10
 
11
11
  async function run (argv = process.argv) {
12
- const args = argv.slice(2)
13
- return cli.parseAsync(args.length ? args : ['help'], { from: 'user' })
12
+ return cli.parseAsync((argv = argv.slice(2)).length ? argv : ['help'], { from: 'user' })
14
13
  }
15
14
 
16
15
  function exitWithError (err, opts, msg = undefined) {
17
16
  const { getLogger, configureLogger } = requireLogger()
18
- if (!msg) msg = err.message || err
19
- const name = msg.startsWith('asciidoctor: FAILED: ') ? (msg = msg.slice(21)) && 'asciidoctor' : cli.name()
17
+ let errMessage = String(
18
+ err instanceof Error ? err.message : Object.assign((err = new Error(String(err))), { stack: undefined }).message
19
+ )
20
+ const name = errMessage.startsWith('asciidoctor: FAILED: ')
21
+ ? (errMessage = errMessage.slice(21)) && 'asciidoctor'
22
+ : cli.name()
23
+ if (!msg) msg = errMessage
20
24
  if (!getLogger(null)) {
21
25
  configureLogger({ format: 'pretty', level: opts.silent ? 'silent' : 'fatal', failureLevel: 'fatal' })
22
26
  }
23
- const logger = getLogger(name)
24
27
  if (opts.stacktrace) {
25
- let loc, stack
26
- if ((stack = err.backtrace)) {
27
- err = Object.assign(new Error(msg), { stack: ['Error', ...stack.slice(1)].join('\n') })
28
- } else if ((stack = err.stack)) {
29
- if (err instanceof SyntaxError && stack.includes('\nSyntaxError: ')) {
30
- ;[loc, stack] = stack.split(/\n+SyntaxError: [^\n]+/)
31
- err = Object.assign(new SyntaxError(msg), { stack: stack.replace('\n', `SyntaxError\n at ${loc}\n`) })
32
- } else if (stack.startsWith(`${err.name}: ${msg}`)) {
33
- stack = stack.replace(`${err.name}: ${msg}`, '').replace(/^\n/, '')
34
- err = Object.assign(new err.constructor(msg), { stack: stack ? `${err.name}\n${stack}` : undefined })
35
- }
36
- } else {
37
- err = Object.assign(new Error(msg), { stack: undefined })
38
- }
39
- if ({}.propertyIsEnumerable.call(err, 'name')) Object.defineProperty(err, 'name', { enumerable: false })
40
- err.stack = `Cause: ${err.stack || '(no stacktrace)'}`
41
- logger.fatal(err, msg)
28
+ getLogger(name).fatal(err, msg)
42
29
  } else {
43
- logger.fatal(msg + '\nAdd the --stacktrace option to see the cause of the error.')
30
+ getLogger(name).fatal({ hint: 'Add the --stacktrace option to see the cause of the error.' }, msg)
44
31
  }
45
32
  return exit()
46
33
  }
@@ -48,7 +35,7 @@ function exitWithError (err, opts, msg = undefined) {
48
35
  function exit () {
49
36
  return requireLogger()
50
37
  .finalizeLogger()
51
- .then((failOnExit) => process.exit(failOnExit ? 1 : process.exitCode))
38
+ .then((failOnExit) => process.exit(process.exitCode || (failOnExit ? 1 : 0)))
52
39
  }
53
40
 
54
41
  function getTTYColumns () {
@@ -64,9 +51,10 @@ function requireLogger (fromPath = undefined, moduleName = '@antora/logger') {
64
51
  return (
65
52
  requireLogger.cache ||
66
53
  (requireLogger.cache = fromPath ? userRequire(moduleName, { paths: [fromPath] }) : require(moduleName))
67
- )
68
- } catch {}
69
- return fromPath && (requireLogger.cache = require(moduleName))
54
+ ) // require('@antora/logger')
55
+ } catch {
56
+ return fromPath && (requireLogger.cache = require(moduleName))
57
+ }
70
58
  }
71
59
 
72
60
  cli
@@ -153,9 +141,7 @@ cli
153
141
  if (generator && generator.charAt() !== '.') msg += ` Try installing the '${generator}' package.`
154
142
  return exitWithError(err, errorOpts, msg)
155
143
  }
156
- return generateSite()
157
- .then(exit)
158
- .catch((err) => exitWithError(err, errorOpts))
144
+ return generateSite().then(exit, (err) => exitWithError(err, errorOpts))
159
145
  })
160
146
  .options.sort((a, b) => a.long.localeCompare(b.long))
161
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/cli",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "The command line interface for Antora.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -17,14 +17,18 @@
17
17
  "bin": {
18
18
  "antora": "bin/antora"
19
19
  },
20
+ "scripts": {
21
+ "test": "_mocha"
22
+ },
20
23
  "dependencies": {
21
- "@antora/logger": "3.0.0-beta.2",
22
- "@antora/playbook-builder": "3.0.0-beta.2",
24
+ "@antora/logger": "3.0.0-beta.6",
25
+ "@antora/playbook-builder": "3.0.0-beta.6",
23
26
  "@antora/user-require-helper": "~2.0",
24
27
  "commander": "~8.3"
25
28
  },
26
29
  "devDependencies": {
27
- "@antora/site-publisher": "3.0.0-beta.2",
30
+ "@antora/site-publisher": "3.0.0-beta.6",
31
+ "@asciidoctor/core": "~2.2",
28
32
  "convict": "~6.2",
29
33
  "kapok-js": "~0.10"
30
34
  },
@@ -43,5 +47,5 @@
43
47
  "static site",
44
48
  "web publishing"
45
49
  ],
46
- "gitHead": "5cd3f9cc70622e465cb44daf1aa2035ed5a35f54"
50
+ "gitHead": "f9f747965f599442562f59206d870b7e38864806"
47
51
  }