@antora/playbook-builder
Advanced tools
Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8
@@ -7,3 +7,2 @@ 'use strict' | ||
const fs = require('fs') | ||
const { hasOwnProperty } = Object.prototype | ||
const ospath = require('path') | ||
@@ -33,3 +32,2 @@ | ||
const config = loadConvictConfig(args, env, schema) | ||
const relSpecFilePath = config.get('playbook') | ||
@@ -62,5 +60,3 @@ if (relSpecFilePath) { | ||
} | ||
config.validate({ allowed: 'strict' }) | ||
return exportModel(config) | ||
@@ -73,5 +69,4 @@ } | ||
function freeze (o) { | ||
let v | ||
for (const k in o) hasOwnProperty.call(o, k) && (Object.isFrozen((v = o[k])) || freeze(v)) | ||
function deepFreeze (o) { | ||
for (const v of Object.values(o)) Object.isFrozen(v) || deepFreeze(v) | ||
return Object.freeze(o) | ||
@@ -92,4 +87,5 @@ } | ||
} | ||
const playbook = camelCaseKeys(data, { deep: true, stopPaths: ['asciidoc'] }) | ||
const playbook = camelCaseKeys(data, { deep: true, stopPaths: getStopPaths(schemaProperties) }) | ||
playbook.dir = playbook.playbook ? ospath.dirname((playbook.file = playbook.playbook)) : process.cwd() | ||
Object.defineProperty(playbook, 'env', { value: config.getEnv() }) | ||
const runtime = (playbook.runtime || false).constructor === Object && playbook.runtime | ||
@@ -105,5 +101,18 @@ if (runtime) { | ||
delete playbook.playbook | ||
return freeze(playbook) | ||
return deepFreeze(playbook) | ||
} | ||
function getStopPaths (schemaProperties, schemaPath = []) { | ||
const stopPaths = [] | ||
for (const [key, { preserve, _cvtProperties }] of Object.entries(schemaProperties)) { | ||
if (preserve) { | ||
return Array.isArray(preserve) | ||
? preserve.reduce((accum, it) => accum.concat(schemaPath.concat(key, it).join('.')), stopPaths) | ||
: stopPaths.concat(schemaPath.concat(key).join('.')) | ||
} | ||
if (_cvtProperties) stopPaths.push(...getStopPaths(_cvtProperties, schemaPath.concat(key))) | ||
} | ||
return stopPaths | ||
} | ||
module.exports = buildPlaybook |
@@ -10,2 +10,13 @@ 'use strict' | ||
}, | ||
pipeline: { | ||
extensions: { | ||
doc: | ||
'A list of extensions that listen for pipeline events. ' + | ||
'Each extension is specified as a require request string or an object with a require key.', | ||
format: 'require-array', | ||
default: [], | ||
arg: 'extension', | ||
preserve: ['data'], | ||
}, | ||
}, | ||
site: { | ||
@@ -66,3 +77,3 @@ start_page: { | ||
sources: { | ||
doc: 'The list of git repositories + branch patterns to use.', | ||
doc: 'The list of git repository urls, references, and start paths to use as content sources.', | ||
format: Array, | ||
@@ -118,5 +129,8 @@ default: [], | ||
arg: 'attribute', | ||
preserve: true, | ||
}, | ||
extensions: { | ||
doc: 'A list of require paths for registering extensions per instance of the AsciiDoc processor.', | ||
doc: | ||
'A list of extensions to register either globally or per instance of the AsciiDoc processor. ' + | ||
'Each extension is specified as a require request string.', | ||
format: Array, | ||
@@ -153,2 +167,14 @@ default: [], | ||
}, | ||
plugins: { | ||
credential_manager: { | ||
doc: 'A require request for a plugin to replace the built-in credential manager used by the git client.', | ||
format: String, | ||
default: undefined, | ||
}, | ||
http: { | ||
doc: 'A require request for a plugin to replace the built-in HTTP client used by the git client.', | ||
format: String, | ||
default: undefined, | ||
}, | ||
}, | ||
}, | ||
@@ -155,0 +181,0 @@ network: { |
@@ -89,2 +89,21 @@ 'use strict' | ||
convict.addFormat({ | ||
name: 'require-array', | ||
validate: (val) => { | ||
if (!Array.isArray(val)) throw new Error('must be of type Array') | ||
}, | ||
coerce: (val, config, name) => { | ||
const accum = config && config.has(name) ? config.get(name) : [] | ||
val.split(',').forEach((v) => { | ||
if (~accum.indexOf(v)) return | ||
const match = accum.find((it) => it.constructor === Object && it.id === v) | ||
if (match) { | ||
if (match.enabled === false) match.enabled = true | ||
} else { | ||
accum.push(v) | ||
} | ||
}) | ||
return accum | ||
}, | ||
}) | ||
convict.addFormat({ | ||
name: 'boolean-or-string', | ||
@@ -91,0 +110,0 @@ validate: (val) => { |
{ | ||
"name": "@antora/playbook-builder", | ||
"version": "3.0.0-alpha.7", | ||
"version": "3.0.0-alpha.8", | ||
"description": "Builds a playbook object from user input for configuring successive documentation components in an Antora pipeline.", | ||
@@ -19,3 +19,3 @@ "license": "MPL-2.0", | ||
"dependencies": { | ||
"@antora/logger": "3.0.0-alpha.7", | ||
"@antora/logger": "3.0.0-alpha.8", | ||
"@iarna/toml": "~2.2", | ||
@@ -41,3 +41,3 @@ "camelcase-keys": "~6.2", | ||
], | ||
"gitHead": "fbd597b3680474f2083cda8a7facf1e2848c08e0" | ||
"gitHead": "2e5695bea11fb5719989c329c97e66d36e29659f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38766
601
+ Added@antora/expand-path-helper@2.0.0(transitive)
+ Added@antora/logger@3.0.0-alpha.8(transitive)
- Removed@antora/expand-path-helper@1.0.0(transitive)
- Removed@antora/logger@3.0.0-alpha.7(transitive)
Updated@antora/logger@3.0.0-alpha.8