@antora/playbook-builder
Advanced tools
Comparing version 3.2.0-alpha.1 to 3.2.0-alpha.2
@@ -69,3 +69,3 @@ 'use strict' | ||
doc: 'The default branch pattern to use when no specific pattern is provided.', | ||
format: Array, | ||
format: 'array-or-string', | ||
default: ['HEAD', 'v{0..9}*'], | ||
@@ -86,3 +86,3 @@ }, | ||
doc: 'The default tag pattern to use when no specific pattern is provided.', | ||
format: Array, | ||
format: 'array-or-string', | ||
default: undefined, | ||
@@ -258,19 +258,9 @@ }, | ||
}, | ||
format: new Proxy( | ||
{ | ||
doc: 'Set the format of log messages. Defaults to pretty if CI=true or stdout is a TTY, json otherwise.', | ||
format: ['json', 'pretty'], | ||
default: undefined, | ||
arg: 'log-format', | ||
env: 'ANTORA_LOG_FORMAT', | ||
}, | ||
{ | ||
get (target, property) { | ||
if (property !== 'default') return target[property] | ||
return process.env.CI === 'true' || (process.env.IS_TTY || String(process.stdout.isTTY)) === 'true' | ||
? 'pretty' | ||
: 'json' | ||
}, | ||
} | ||
), | ||
format: { | ||
doc: 'Set the format of log messages. Defaults to pretty if CI=true or stdout is a TTY, json otherwise.', | ||
format: ['json', 'pretty'], | ||
default: 'auto', | ||
arg: 'log-format', | ||
env: 'ANTORA_LOG_FORMAT', | ||
}, | ||
destination: { | ||
@@ -350,4 +340,9 @@ file: { | ||
}, | ||
[Symbol.for('convict.beforeValidate')]: ({ _schema: schema, _instance: data }) => { | ||
[Symbol.for('convict.beforeValidate')]: ({ getEnv, _instance: data, _schema: schema }) => { | ||
const runtime = data.runtime | ||
const log = runtime.log | ||
if (log.format === 'auto') { | ||
const env = getEnv() | ||
log.format = env.CI === 'true' || (env.IS_TTY || String(process.stdout.isTTY)) === 'true' ? 'pretty' : 'json' | ||
} | ||
if (runtime.silent) { | ||
@@ -354,0 +349,0 @@ if (runtime.quiet === false) runtime.quiet = true |
@@ -39,2 +39,10 @@ 'use strict' | ||
convict.addFormat({ | ||
name: 'array-or-string', | ||
validate: (val) => { | ||
if (!(val == null || val.constructor === String || Array.isArray(val))) { | ||
throw new Error('must be an array, string, or null') | ||
} | ||
}, | ||
}) | ||
convict.addFormat({ | ||
name: 'map', | ||
@@ -48,4 +56,4 @@ validate: (val) => { | ||
let match | ||
ARGS_SCANNER_RX.lastIndex = 0 | ||
while ((match = ARGS_SCANNER_RX.exec(val))) { | ||
const scanner = new RegExp(ARGS_SCANNER_RX) | ||
while ((match = scanner.exec(val))) { | ||
const [, k, v] = match | ||
@@ -74,4 +82,4 @@ if (k) accum[k] = v ? (v === '-' ? '-' : yaml.load(v, { schema: yaml.CORE_SCHEMA })) : '' | ||
let match | ||
ARGS_SCANNER_RX.lastIndex = 0 | ||
while ((match = ARGS_SCANNER_RX.exec(val))) { | ||
const scanner = new RegExp(ARGS_SCANNER_RX) | ||
while ((match = scanner.exec(val))) { | ||
const [, k, v] = match | ||
@@ -95,3 +103,3 @@ if (k) { | ||
validate: (val) => { | ||
if (!Array.isArray(val)) throw new Error('must be of type Array') | ||
if (!Array.isArray(val)) throw new Error('must be an array') | ||
}, | ||
@@ -116,3 +124,3 @@ coerce: (val, config, name) => { | ||
if (!(val == null || val.constructor === String || val.constructor === Boolean)) { | ||
throw new Error('must be a boolean or string') | ||
throw new Error('must be a boolean, string, or null') | ||
} | ||
@@ -119,0 +127,0 @@ }, |
{ | ||
"name": "@antora/playbook-builder", | ||
"version": "3.2.0-alpha.1", | ||
"version": "3.2.0-alpha.2", | ||
"description": "Builds a playbook object from user input for configuring successive documentation components in an Antora pipeline.", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
@@ -13,2 +13,2 @@ # Antora Playbook Builder | ||
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). | ||
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). |
24094
633
13