@antora/content-classifier
Advanced tools
Comparing version 3.0.3 to 3.1.0
'use strict' | ||
const ContentCatalog = require('./content-catalog') | ||
const collateAsciiDocAttributes = require('@antora/asciidoc-loader/config/collate-asciidoc-attributes') | ||
@@ -37,3 +38,3 @@ /** | ||
const { files, nav, startPage } = componentVersionData | ||
delete componentVersionData.files // clean up memory | ||
componentVersionData.files = undefined // clean up memory | ||
files.forEach((file) => allocateSrc(file, name, version, nav) && contentCatalog.addFile(file)) | ||
@@ -134,25 +135,11 @@ contentCatalog.registerComponentVersionStartPage(name, componentVersion, startPage) | ||
function resolveAsciiDocConfig (siteAsciiDocConfig, { asciidoc }) { | ||
function resolveAsciiDocConfig (siteAsciiDocConfig, { asciidoc, origins = [] }) { | ||
const scopedAttributes = (asciidoc || {}).attributes | ||
if (scopedAttributes) { | ||
const siteAttributes = siteAsciiDocConfig.attributes | ||
if (siteAttributes) { | ||
const attributes = Object.keys(scopedAttributes).reduce((accum, name) => { | ||
if (name in siteAttributes) { | ||
const currentVal = siteAttributes[name] | ||
if (currentVal === false || String(currentVal).endsWith('@')) accum[name] = scopedAttributes[name] | ||
} else { | ||
accum[name] = scopedAttributes[name] | ||
} | ||
return accum | ||
}, {}) | ||
return Object.keys(attributes).length | ||
? Object.assign({}, siteAsciiDocConfig, { attributes: Object.assign({}, siteAttributes, attributes) }) | ||
: siteAsciiDocConfig | ||
} else { | ||
return Object.assign({}, siteAsciiDocConfig, { attributes: scopedAttributes }) | ||
} | ||
} else { | ||
return siteAsciiDocConfig | ||
const initial = siteAsciiDocConfig.attributes | ||
const mdc = { file: { path: 'antora.yml', origin: origins[origins.length - 1] } } | ||
const attributes = collateAsciiDocAttributes(scopedAttributes, { initial, mdc, merge: true }) | ||
if (attributes !== initial) siteAsciiDocConfig = Object.assign({}, siteAsciiDocConfig, { attributes }) | ||
} | ||
return siteAsciiDocConfig | ||
} | ||
@@ -159,0 +146,0 @@ |
@@ -14,2 +14,3 @@ 'use strict' | ||
const SPACE_RX = / /g | ||
const LOG_WRAP = '\n ' | ||
@@ -144,8 +145,8 @@ const $components = Symbol('components') | ||
const details = [filesForFamily.get(key), file] | ||
.map((it, idx) => ` ${idx + 1}: ${getFileLocation(it)}`) | ||
.join('\n') | ||
.map((it, idx) => `${idx + 1}: ${getFileLocation(it)}`) | ||
.join(LOG_WRAP) | ||
if (family === 'nav') { | ||
throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}\n${details}`) | ||
throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}${LOG_WRAP}${details}`) | ||
} else { | ||
throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}\n${details}`) | ||
throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`) | ||
} | ||
@@ -194,2 +195,8 @@ } | ||
removeFile (file) { | ||
const src = file.src | ||
const filesForFamily = this[$files].get(src.family) | ||
return filesForFamily ? filesForFamily.delete(generateKey(src)) : false | ||
} | ||
findBy (criteria) { | ||
@@ -360,6 +367,6 @@ const criteriaEntries = Object.entries(criteria) | ||
? `Page cannot define alias that references itself: ${generateResourceSpec(src)}` + | ||
` (specified as: ${spec})\n source: ${getFileLocation(existingPage)}` | ||
: `Page alias cannot reference an existing page: ${generateResourceSpec(src)} (specified as: ${spec})\n` + | ||
` source: ${getFileLocation(target)}\n` + | ||
` existing page: ${getFileLocation(existingPage)}` | ||
` (specified as: ${spec})${LOG_WRAP}source: ${getFileLocation(existingPage)}` | ||
: `Page alias cannot reference an existing page: ${generateResourceSpec(src)} (specified as: ${spec})` + | ||
`${LOG_WRAP}source: ${getFileLocation(target)}` + | ||
`${LOG_WRAP}existing page: ${getFileLocation(existingPage)}` | ||
) | ||
@@ -375,3 +382,4 @@ } | ||
throw new Error( | ||
`Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})\n source: ${getFileLocation(target)}` | ||
`Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})` + | ||
`${LOG_WRAP}source: ${getFileLocation(target)}` | ||
) | ||
@@ -595,8 +603,10 @@ } | ||
function getFileLocation ({ path: path_, src: { abspath, origin } }) { | ||
return ( | ||
abspath || | ||
(origin ? `${path.join(origin.startPath, path_)} in ${origin.url} (ref: ${origin.branch || origin.tag})` : path_) | ||
) | ||
if (!origin) return abspath || path_ | ||
const { url, gitdir, worktree, refname, tag, reftype = tag ? 'tag' : 'branch', remote, startPath } = origin | ||
let details = `${reftype}: ${refname}` | ||
if ('worktree' in origin) details += worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : '' | ||
if (startPath) details += ` | start path: ${startPath}` | ||
return `${abspath || path.join(startPath, path_)} in ${'worktree' in origin ? worktree || gitdir : url} (${details})` | ||
} | ||
module.exports = ContentCatalog |
{ | ||
"name": "@antora/content-classifier", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "Organizes aggregated content into a virtual file catalog for use in an Antora documentation pipeline.", | ||
@@ -18,4 +18,16 @@ "license": "MPL-2.0", | ||
"main": "lib/index.js", | ||
"exports": { | ||
".": "./lib/index.js", | ||
"./content-catalog": "./lib/content-catalog.js", | ||
"./file": "./lib/file.js", | ||
"./util/*": "./lib/util/*.js", | ||
"./lib/util/*": "./lib/util/*.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"imports": { | ||
"#constants": "./lib/constants.js" | ||
}, | ||
"dependencies": { | ||
"@antora/logger": "3.0.3", | ||
"@antora/asciidoc-loader": "3.1.0", | ||
"@antora/logger": "3.1.0", | ||
"mime-types": "~2.1", | ||
@@ -25,3 +37,3 @@ "vinyl": "~2.2" | ||
"engines": { | ||
"node": ">=12.21.0" | ||
"node": ">=16.0.0" | ||
}, | ||
@@ -28,0 +40,0 @@ "files": [ |
41873
4
930
+ Added@antora/asciidoc-loader@3.1.0(transitive)
+ Added@antora/logger@3.1.0(transitive)
+ Added@antora/user-require-helper@2.0.0(transitive)
+ Added@asciidoctor/core@2.2.8(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedasciidoctor-opal-runtime@0.3.3(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@1.1.112.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-copy@2.1.7(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.1.38.1.0(transitive)
+ Addedhelp-me@4.2.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedminimatch@3.1.25.1.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpino@8.4.2(transitive)
+ Addedpino-pretty@9.0.1(transitive)
+ Addedpino-std-serializers@6.2.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@2.3.2(transitive)
+ Addedreadable-stream@4.7.0(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedsonic-boom@3.2.1(transitive)
+ Addedthread-stream@2.7.0(transitive)
+ Addedunxhr@1.0.1(transitive)
- Removed@antora/logger@3.0.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargs@5.0.3(transitive)
- Removedcamelcase@5.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedleven@2.1.0(transitive)
- Removedmri@1.1.4(transitive)
- Removedon-exit-leak-free@0.2.0(transitive)
- Removedpino@7.6.5(transitive)
- Removedpino-pretty@7.3.0(transitive)
- Removedpino-std-serializers@4.0.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedreal-require@0.1.0(transitive)
- Removedrfdc@1.4.1(transitive)
- Removedsonic-boom@2.4.2(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedthread-stream@0.13.2(transitive)
Updated@antora/logger@3.1.0