@antora/playbook-builder 3.0.0-beta.6 → 3.0.0-rc.4
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/lib/build-playbook.js +5 -9
- package/lib/config/schema.js +2 -6
- package/lib/solitary-convict.js +4 -3
- package/package.json +2 -2
package/lib/build-playbook.js
CHANGED
|
@@ -19,8 +19,8 @@ const ospath = require('path')
|
|
|
19
19
|
*
|
|
20
20
|
* @param {Array} [args=[]] - An array of arguments in the form of command line
|
|
21
21
|
* option flags and switches. Should begin with the first flag or switch.
|
|
22
|
-
* @param {Object} [env=
|
|
23
|
-
* @param {Object} [schema=
|
|
22
|
+
* @param {Object} [env=process.env] - A map of environment variables.
|
|
23
|
+
* @param {Object} [schema=require('./config/schema').defaultSchema] - A convict configuration schema.
|
|
24
24
|
* @param {Function} [beforeValidate=undefined] - A function to invoke on the
|
|
25
25
|
* config before validating it.
|
|
26
26
|
*
|
|
@@ -28,9 +28,9 @@ const ospath = require('path')
|
|
|
28
28
|
* mirrors the configuration schema. With the exception of keys and descendants
|
|
29
29
|
* marked in the schema as preserve, all keys in the playbook are camelCased.
|
|
30
30
|
*/
|
|
31
|
-
function buildPlaybook (args = [], env =
|
|
32
|
-
const config =
|
|
33
|
-
const playbook = config.get('playbook')
|
|
31
|
+
function buildPlaybook (args = [], env = process.env, schema = defaultSchema, beforeValidate = undefined) {
|
|
32
|
+
const config = Object.assign(convict(schema, { args, env }), { getModel })
|
|
33
|
+
const playbook = config.has('playbook') && config.get('playbook')
|
|
34
34
|
let absPlaybookPath
|
|
35
35
|
if (playbook) {
|
|
36
36
|
if (ospath.extname((absPlaybookPath = ospath.resolve(playbook)))) {
|
|
@@ -68,10 +68,6 @@ function buildPlaybook (args = [], env = {}, schema = undefined, beforeValidate
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function loadConvictConfig (args, env, customSchema) {
|
|
72
|
-
return Object.assign(convict(customSchema || defaultSchema, { args, env }), { getModel })
|
|
73
|
-
}
|
|
74
|
-
|
|
75
71
|
function getModel (name = '') {
|
|
76
72
|
let config = this
|
|
77
73
|
const data = config.get(name)
|
package/lib/config/schema.js
CHANGED
|
@@ -55,15 +55,11 @@ module.exports = {
|
|
|
55
55
|
default: {},
|
|
56
56
|
arg: 'key',
|
|
57
57
|
},
|
|
58
|
-
// NOTE used to map
|
|
58
|
+
// NOTE used to map env var for site.keys.google_analytics key
|
|
59
59
|
__private__google_analytics_key: {
|
|
60
|
-
doc:
|
|
61
|
-
'The Google Analytics account key.',
|
|
62
|
-
'(Deprecated; will be removed in Antora 4; define using --key google-analytics=<key> instead)',
|
|
63
|
-
].join('\n'),
|
|
60
|
+
doc: 'The environment variable mapping for the Google Analytics account key.',
|
|
64
61
|
format: String,
|
|
65
62
|
default: undefined,
|
|
66
|
-
arg: 'google-analytics-key',
|
|
67
63
|
env: 'GOOGLE_ANALYTICS_KEY',
|
|
68
64
|
},
|
|
69
65
|
},
|
package/lib/solitary-convict.js
CHANGED
|
@@ -7,6 +7,7 @@ const yaml = require('js-yaml')
|
|
|
7
7
|
|
|
8
8
|
const ARGS_SCANNER_RX = /(?:([^=,]+)|(?==))(?:,|$|=(|("|').*?\3|[^,]+)(?:,|$))/g
|
|
9
9
|
const PRIMITIVE_TYPES = [Boolean, Number, String]
|
|
10
|
+
const YAML_SCHEMA = yaml.CORE_SCHEMA.extend({ implicit: [yaml.types.merge] })
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A convict function wrapper that registers custom formats and parsers and
|
|
@@ -22,8 +23,8 @@ function registerParsers (convict) {
|
|
|
22
23
|
convict.addParser([
|
|
23
24
|
{ extension: 'json', parse: json.parse },
|
|
24
25
|
{ extension: 'toml', parse: toml.parse },
|
|
25
|
-
{ extension: 'yaml', parse: (source) => yaml.load(source, { schema:
|
|
26
|
-
{ extension: 'yml', parse: (source) => yaml.load(source, { schema:
|
|
26
|
+
{ extension: 'yaml', parse: (source) => yaml.load(source, { schema: YAML_SCHEMA }) },
|
|
27
|
+
{ extension: 'yml', parse: (source) => yaml.load(source, { schema: YAML_SCHEMA }) },
|
|
27
28
|
{
|
|
28
29
|
extension: '*',
|
|
29
30
|
parse: () => {
|
|
@@ -74,7 +75,7 @@ function registerFormats (convict) {
|
|
|
74
75
|
if (k) {
|
|
75
76
|
let parsed
|
|
76
77
|
if (v && v !== '-') {
|
|
77
|
-
parsed = yaml.load(v)
|
|
78
|
+
parsed = yaml.load(v, { schema: yaml.CORE_SCHEMA })
|
|
78
79
|
if (parsed && PRIMITIVE_TYPES.indexOf(parsed.constructor) < 0) parsed = v
|
|
79
80
|
} else {
|
|
80
81
|
parsed = v || ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/playbook-builder",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.4",
|
|
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)",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"static site",
|
|
40
40
|
"web publishing"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "5e29b434cf6e83e0e8e02c0793425bdf4d25bed2"
|
|
43
43
|
}
|