@antora/playbook-builder 3.2.0-alpha.11 → 3.2.0-alpha.12

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.
@@ -4,7 +4,6 @@ const convict = require('./solitary-convict')
4
4
  const defaultSchema = require('./config/schema')
5
5
  const fs = require('node:fs')
6
6
  const ospath = require('node:path')
7
- const parseArgs = require('yargs-parser')
8
7
  const yaml = require('js-yaml')
9
8
 
10
9
  /**
@@ -30,7 +29,7 @@ const yaml = require('js-yaml')
30
29
  * marked in the schema as preserve, all keys in the playbook are camelCased.
31
30
  */
32
31
  function buildPlaybook (args = [], env = process.env, schema = defaultSchema, beforeValidate = undefined) {
33
- const parsedArgs = parseArgs(args, { configuration: { 'dot-notation': false } })
32
+ const parsedArgs = args.length ? parseArgs(args) : {}
34
33
  const opts = { args: [], env: {} }
35
34
  const config = Object.assign(convict(schema, opts), { getModel, getSchema })
36
35
  Object.assign(opts, { args, env })
@@ -151,4 +150,28 @@ function getDetails (playbook, absPlaybookPath) {
151
150
  return ` (${ospath.isAbsolute(playbook) ? '' : 'cwd: ' + process.cwd() + ', '}playbook: ${playbook})`
152
151
  }
153
152
 
153
+ function parseArgs (args) {
154
+ let currentOptionName
155
+ return Object.assign(
156
+ args.reduce((accum, it) => {
157
+ if (it.startsWith('--') && it !== '--') {
158
+ if (currentOptionName) accum[currentOptionName] = true
159
+ currentOptionName = it.slice(2)
160
+ } else if (currentOptionName) {
161
+ const currentOptionValue = accum[currentOptionName]
162
+ if (currentOptionValue == null || currentOptionValue === true) {
163
+ accum[currentOptionName] = it
164
+ } else if (currentOptionValue.constructor === Array) {
165
+ currentOptionValue.push(it)
166
+ } else {
167
+ accum[currentOptionName] = [currentOptionValue, it]
168
+ }
169
+ currentOptionName = undefined
170
+ }
171
+ return accum
172
+ }, {}),
173
+ currentOptionName ? { [currentOptionName]: true } : undefined
174
+ )
175
+ }
176
+
154
177
  module.exports = Object.assign(buildPlaybook, { defaultSchema })
@@ -250,7 +250,7 @@ module.exports = {
250
250
  log: {
251
251
  level: {
252
252
  doc: 'Set the minimum log level of messages that get logged.',
253
- format: ['all', 'debug', 'info', 'warn', 'error', 'fatal', 'silent'],
253
+ format: ['all', 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'silent'],
254
254
  default: 'warn',
255
255
  arg: 'log-level',
256
256
  env: 'ANTORA_LOG_LEVEL',
@@ -147,8 +147,9 @@ function registerFormats (convict) {
147
147
  if ((match.enabled ?? true) !== enable) match.enabled = enable
148
148
  } else {
149
149
  accum.push((match = byRequire[request] = { require: request }))
150
+ if (!enable) match.enabled = false
150
151
  }
151
- order.set(match, orderIdx++)
152
+ if ((match.order ?? 'auto') === 'auto') order.set(match, orderIdx++)
152
153
  }
153
154
  return accum
154
155
  .sort((a, b) => order.get(a) - order.get(b))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/playbook-builder",
3
- "version": "3.2.0-alpha.11",
3
+ "version": "3.2.0-alpha.12",
4
4
  "description": "Builds a playbook object from user input for configuring successive documentation components in an Antora pipeline.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -30,8 +30,7 @@
30
30
  "@iarna/toml": "~2.2",
31
31
  "convict": "~6.2",
32
32
  "js-yaml": "~4.1",
33
- "json5": "~2.2",
34
- "yargs-parser": "~20.2"
33
+ "json5": "~2.2"
35
34
  },
36
35
  "engines": {
37
36
  "node": ">=18.0.0"
@@ -48,7 +47,7 @@
48
47
  "web publishing"
49
48
  ],
50
49
  "scripts": {
51
- "test": "_mocha",
50
+ "test": "node --test",
52
51
  "prepublishOnly": "npx -y downdoc@latest --prepublish",
53
52
  "postpublish": "npx -y downdoc@latest --postpublish"
54
53
  }