@antora/playbook-builder
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -59,14 +59,23 @@ 'use strict' | ||
function exportModel (config) { | ||
const properties = config.getProperties() | ||
const schema = config.getSchema() | ||
const data = config.getProperties() | ||
if ('git' in schema.properties && 'ensureGitSuffix' in schema.properties.git.properties) { | ||
const git = data.git | ||
if (git.ensureGitSuffix != null) git.ensure_git_suffix = git.ensureGitSuffix | ||
delete git.ensureGitSuffix | ||
} | ||
if ('runtime' in schema.properties && 'pull' in schema.properties.runtime.properties) { | ||
const runtime = data.runtime | ||
if (runtime.pull != null) runtime.fetch = runtime.pull | ||
delete runtime.pull | ||
} | ||
// FIXME would be nice if camelCaseKeys could exclude a subtree (e.g., asciidoc) | ||
// see https://github.com/sindresorhus/camelcase-keys/issues/23 | ||
const asciidocProperty = properties.asciidoc | ||
delete properties.asciidoc | ||
const playbook = camelCaseKeys(properties, { deep: true }) | ||
if (asciidocProperty) playbook.asciidoc = asciidocProperty | ||
const runtime = playbook.runtime | ||
if (runtime && runtime.pull != null) { | ||
runtime.fetch = runtime.pull | ||
delete runtime.pull | ||
let asciidocData | ||
if ('asciidoc' in schema.properties) { | ||
asciidocData = data.asciidoc | ||
delete data.asciidoc | ||
} | ||
const playbook = camelCaseKeys(data, { deep: true }) | ||
if (asciidocData) playbook.asciidoc = asciidocData | ||
playbook.dir = playbook.playbook ? ospath.dirname((playbook.file = playbook.playbook)) : process.cwd() | ||
@@ -73,0 +82,0 @@ delete playbook.playbook |
@@ -24,4 +24,4 @@ 'use strict' | ||
url: { | ||
doc: 'The base URL of the published site. Should not include trailing slash.', | ||
format: String, | ||
doc: 'The base URL (absolute URL or pathname) of the published site. Should not include a trailing slash.', | ||
format: 'url-or-pathname', | ||
default: undefined, | ||
@@ -144,3 +144,3 @@ arg: 'url', | ||
}, | ||
ensureGitSuffix: { | ||
ensure_git_suffix: { | ||
doc: 'Instructs the git client to automatically append .git to the repository URL if absent.', | ||
@@ -150,2 +150,7 @@ format: Boolean, | ||
}, | ||
ensureGitSuffix: { | ||
doc: '(Deprecated; to be removed in Antora 3) Instructs the git client to automatically append .git to the repository URL if absent.', | ||
format: Boolean, | ||
default: undefined, | ||
}, | ||
}, | ||
@@ -167,3 +172,3 @@ runtime: { | ||
pull: { | ||
doc: '(Deprecated) Download updates from remote resources. Use --fetch instead.', | ||
doc: '(Deprecated; to be removed in Antora 3) Download updates from remote resources. Use --fetch instead.', | ||
format: Boolean, | ||
@@ -170,0 +175,0 @@ default: undefined, |
@@ -7,2 +7,3 @@ 'use strict' | ||
const yaml = require('js-yaml') | ||
const { URL } = require('url') | ||
@@ -61,4 +62,16 @@ const ARGS_SCANNER_RX = /(?:([^=,]+)|(?==))(?:,|$|=(|("|').*?\3|[^,]+)(?:,|$))/g | ||
}) | ||
convict.addFormat({ | ||
name: 'url-or-pathname', | ||
validate: (val) => { | ||
if (!(val && (typeof val === 'string' || val instanceof String) && val.charAt() === '/')) { | ||
try { | ||
new URL(val) // eslint-disable-line no-new | ||
} catch (e) { | ||
throw new Error('must be an absolute URL or a pathname (i.e., root-relative path)') | ||
} | ||
} | ||
}, | ||
}) | ||
} | ||
module.exports = solitaryConvict |
{ | ||
"name": "@antora/playbook-builder", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"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", |
13873
375