@antora/playbook-builder 3.2.0-alpha.1 → 3.2.0-alpha.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/README.md CHANGED
@@ -10,4 +10,4 @@ Its site generator aggregates documents from versioned content repositories and
10
10
 
11
11
  Copyright (C) 2017-present [OpenDevise Inc.](https://opendevise.com) and the [Antora Project](https://antora.org).
12
12
 
13
- Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
13
+ Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
@@ -66,7 +66,7 @@ module.exports = {
66
66
  content: {
67
67
  branches: {
68
68
  doc: 'The default branch pattern to use when no specific pattern is provided.',
69
- format: Array,
69
+ format: 'array-or-string',
70
70
  default: ['HEAD', 'v{0..9}*'],
71
71
  },
72
72
  edit_url: {
@@ -82,7 +82,7 @@ module.exports = {
82
82
  },
83
83
  tags: {
84
84
  doc: 'The default tag pattern to use when no specific pattern is provided.',
85
- format: Array,
85
+ format: 'array-or-string',
86
86
  default: undefined,
87
87
  },
88
88
  },
@@ -253,23 +253,13 @@ module.exports = {
253
253
  arg: 'log-failure-level',
254
254
  env: 'ANTORA_LOG_FAILURE_LEVEL',
255
255
  },
256
- format: new Proxy(
257
- {
258
- doc: 'Set the format of log messages. Defaults to pretty if CI=true or stdout is a TTY, json otherwise.',
259
- format: ['json', 'pretty'],
260
- default: undefined,
261
- arg: 'log-format',
262
- env: 'ANTORA_LOG_FORMAT',
263
- },
264
- {
265
- get (target, property) {
266
- if (property !== 'default') return target[property]
267
- return process.env.CI === 'true' || (process.env.IS_TTY || String(process.stdout.isTTY)) === 'true'
268
- ? 'pretty'
269
- : 'json'
270
- },
271
- }
272
- ),
256
+ format: {
257
+ doc: 'Set the format of log messages. Defaults to pretty if CI=true or stdout is a TTY, json otherwise.',
258
+ format: ['json', 'pretty'],
259
+ default: 'auto',
260
+ arg: 'log-format',
261
+ env: 'ANTORA_LOG_FORMAT',
262
+ },
273
263
  destination: {
274
264
  file: {
275
265
  doc: 'Write log messages to this file or stream. Defaults to stderr if format is pretty, stdout otherwise.',
@@ -344,8 +334,13 @@ module.exports = {
344
334
  default: undefined,
345
335
  },
346
336
  },
347
- [Symbol.for('convict.beforeValidate')]: ({ _schema: schema, _instance: data }) => {
337
+ [Symbol.for('convict.beforeValidate')]: ({ getEnv, _instance: data, _schema: schema }) => {
348
338
  const runtime = data.runtime
339
+ const log = runtime.log
340
+ if (log.format === 'auto') {
341
+ const env = getEnv()
342
+ log.format = env.CI === 'true' || (env.IS_TTY || String(process.stdout.isTTY)) === 'true' ? 'pretty' : 'json'
343
+ }
349
344
  if (runtime.silent) {
350
345
  if (runtime.quiet === false) runtime.quiet = true
351
346
  if (runtime.log.level !== 'silent') runtime.log.level = 'silent'
@@ -35,6 +35,14 @@ function registerParsers (convict) {
35
35
  }
36
36
 
37
37
  function registerFormats (convict) {
38
+ convict.addFormat({
39
+ name: 'array-or-string',
40
+ validate: (val) => {
41
+ if (!(val == null || val.constructor === String || Array.isArray(val))) {
42
+ throw new Error('must be an array, string, or null')
43
+ }
44
+ },
45
+ })
38
46
  convict.addFormat({
39
47
  name: 'map',
40
48
  validate: (val) => {
@@ -44,8 +52,8 @@ function registerFormats (convict) {
44
52
  if (config == null) return val
45
53
  const accum = config.has(name) ? config.get(name) : {}
46
54
  let match
47
- ARGS_SCANNER_RX.lastIndex = 0
48
- while ((match = ARGS_SCANNER_RX.exec(val))) {
55
+ const scanner = new RegExp(ARGS_SCANNER_RX)
56
+ while ((match = scanner.exec(val))) {
49
57
  const [, k, v] = match
50
58
  if (k) accum[k] = v ? (v === '-' ? '-' : yaml.load(v, { schema: yaml.CORE_SCHEMA })) : ''
51
59
  }
@@ -69,8 +77,8 @@ function registerFormats (convict) {
69
77
  if (config == null) return val
70
78
  const accum = config.has(name) ? config.get(name) : {}
71
79
  let match
72
- ARGS_SCANNER_RX.lastIndex = 0
73
- while ((match = ARGS_SCANNER_RX.exec(val))) {
80
+ const scanner = new RegExp(ARGS_SCANNER_RX)
81
+ while ((match = scanner.exec(val))) {
74
82
  const [, k, v] = match
75
83
  if (k) {
76
84
  let parsed
@@ -89,7 +97,7 @@ function registerFormats (convict) {
89
97
  convict.addFormat({
90
98
  name: 'require-array',
91
99
  validate: (val) => {
92
- if (!Array.isArray(val)) throw new Error('must be of type Array')
100
+ if (!Array.isArray(val)) throw new Error('must be an array')
93
101
  },
94
102
  coerce: (val, config, name) => {
95
103
  const accum = config && config.has(name) ? config.get(name) : []
@@ -109,7 +117,7 @@ function registerFormats (convict) {
109
117
  name: 'boolean-or-string',
110
118
  validate: (val) => {
111
119
  if (!(val == null || val.constructor === String || val.constructor === Boolean)) {
112
- throw new Error('must be a boolean or string')
120
+ throw new Error('must be a boolean, string, or null')
113
121
  }
114
122
  },
115
123
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/playbook-builder",
3
- "version": "3.2.0-alpha.1",
3
+ "version": "3.2.0-alpha.2",
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)",