@antora/content-classifier 3.2.0-alpha.3 → 3.2.0-alpha.5

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.
@@ -2,6 +2,8 @@
2
2
 
3
3
  const ContentCatalog = require('./content-catalog')
4
4
  const collateAsciiDocAttributes = require('@antora/asciidoc-loader/config/collate-asciidoc-attributes')
5
+ const logger = require('./logger')
6
+ const summarizeFileLocation = require('./util/summarize-file-location')
5
7
 
6
8
  /**
7
9
  * Organizes the raw aggregate of virtual files into a {ContentCatalog}.
@@ -42,10 +44,18 @@ function addFilesAndRegisterStartPages (contentCatalog, siteStartPage) {
42
44
  for (const { versions: componentVersions } of contentCatalog.getComponents()) {
43
45
  for (const componentVersion of componentVersions) {
44
46
  const { name: component, version, files = [], nav, startPage } = componentVersion
47
+ const navResolved = nav && (nav.resolved = new Set())
45
48
  for (let file, i = 0, len = files.length; i < len; i++) {
46
49
  allocateSrc((file = files[i]), component, version, nav) && contentCatalog.addFile(file, componentVersion)
47
50
  files[i] = undefined // free memory
48
51
  }
52
+ if (navResolved && nav.length > navResolved.size && new Set(nav).size > navResolved.size) {
53
+ const loc = summarizeFileLocation({ path: 'antora.yml', src: { origin: nav.origin } })
54
+ for (const filepath of nav) {
55
+ if (navResolved.has(filepath)) continue
56
+ logger.warn('Could not resolve nav entry for %s@%s defined in %s: %s', version, component, loc, filepath)
57
+ }
58
+ }
49
59
  contentCatalog.registerComponentVersionStartPage(component, componentVersion, startPage)
50
60
  }
51
61
  }
@@ -61,9 +71,9 @@ function allocateSrc (file, component, version, nav) {
61
71
  return true
62
72
  }
63
73
  const filepath = file.path
64
- const navInfo = nav && getNavInfo(filepath, nav)
65
74
  const pathSegments = filepath.split('/')
66
- if (navInfo) {
75
+ let navInfo
76
+ if (nav && (navInfo = getNavInfo(filepath, nav))) {
67
77
  if (extname !== '.adoc') return // ignore file
68
78
  file.nav = navInfo
69
79
  file.src.family = 'nav'
@@ -73,14 +83,14 @@ function allocateSrc (file, component, version, nav) {
73
83
  file.src.relative = pathSegments.slice(2).join('/')
74
84
  file.src.moduleRootPath = calculateRootPath(pathSegments.length - 3)
75
85
  } else {
76
- // relative to root
86
+ // relative to content source root
77
87
  file.src.relative = filepath
78
88
  }
79
89
  } else if (pathSegments[0] === 'modules') {
80
90
  let familyFolder = pathSegments[2]
81
91
  switch (familyFolder) {
82
92
  case 'pages':
83
- // pages/_partials location for partials is @deprecated; special designation scheduled to be removed in Antora 4
93
+ // pages/_partials location for partials is @deprecated; special designation scheduled for removal in Antora 4
84
94
  if (pathSegments[3] === '_partials') {
85
95
  file.src.family = 'partial'
86
96
  // relative to modules/<module>/pages/_partials
@@ -143,7 +153,7 @@ function allocateSrc (file, component, version, nav) {
143
153
  */
144
154
  function getNavInfo (filepath, nav) {
145
155
  const index = nav.findIndex((candidate) => candidate === filepath)
146
- if (~index) return { index }
156
+ if (~index) return nav.resolved.add(filepath) && { index }
147
157
  }
148
158
 
149
159
  function resolveAsciiDocConfig (siteAsciiDocConfig, { asciidoc, origins = [] }) {
@@ -5,8 +5,9 @@ const invariably = { void: () => undefined }
5
5
  const logger = require('./logger')
6
6
  const { lookup: resolveMimeType } = require('./mime-types-with-asciidoc')
7
7
  const parseResourceId = require('./util/parse-resource-id')
8
- const { posix: path } = require('path')
8
+ const { posix: path } = require('node:path')
9
9
  const resolveResource = require('./util/resolve-resource')
10
+ const summarizeFileLocation = require('./util/summarize-file-location')
10
11
  const versionCompare = require('./util/version-compare-desc')
11
12
 
12
13
  const { ROOT_INDEX_ALIAS_ID, ROOT_INDEX_PAGE_ID } = require('./constants')
@@ -75,6 +76,7 @@ class ContentCatalog {
75
76
  }
76
77
  }
77
78
  }
79
+ // NOTE if no AsciiDoc attributes are defined in the component descriptor, asciidoc is the siteAsciiDocConfig object
78
80
  if (asciidoc) componentVersion.asciidoc = asciidoc
79
81
  const component = this[$components].get(name)
80
82
  if (component) {
@@ -147,10 +149,10 @@ class ContentCatalog {
147
149
  throw new Error(`Duplicate alias: ${generateResourceSpec(src)}`)
148
150
  } else {
149
151
  const details = [filesForFamily.get(key), file]
150
- .map((it, idx) => `${idx + 1}: ${getFileLocation(it)}`)
152
+ .map((it, idx) => `${idx + 1}: ${summarizeFileLocation(it)}`)
151
153
  .join(LOG_WRAP)
152
154
  if (family === 'nav') {
153
- throw new Error(`Duplicate nav in ${version}@${component}: ${file.path}${LOG_WRAP}${details}`)
155
+ throw new Error(`Duplicate nav file: ${file.path} in ${version}@${component}${LOG_WRAP}${details}`)
154
156
  } else {
155
157
  throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`)
156
158
  }
@@ -398,10 +400,10 @@ class ContentCatalog {
398
400
  throw new Error(
399
401
  existingPage === target
400
402
  ? `Page cannot define alias that references itself: ${generateResourceSpec(src)}` +
401
- ` (specified as: ${spec})${LOG_WRAP}source: ${getFileLocation(existingPage)}`
403
+ ` (specified as: ${spec})${LOG_WRAP}source: ${summarizeFileLocation(existingPage)}`
402
404
  : `Page alias cannot reference an existing page: ${generateResourceSpec(src)} (specified as: ${spec})` +
403
- `${LOG_WRAP}source: ${getFileLocation(target)}` +
404
- `${LOG_WRAP}existing page: ${getFileLocation(existingPage)}`
405
+ `${LOG_WRAP}source: ${summarizeFileLocation(target)}` +
406
+ `${LOG_WRAP}existing page: ${summarizeFileLocation(existingPage)}`
405
407
  )
406
408
  }
407
409
  } else if (src.version == null) {
@@ -413,7 +415,7 @@ class ContentCatalog {
413
415
  if (existingAlias) {
414
416
  throw new Error(
415
417
  `Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})` +
416
- `${LOG_WRAP}source: ${getFileLocation(target)}`
418
+ `${LOG_WRAP}source: ${summarizeFileLocation(target)}`
417
419
  )
418
420
  }
419
421
  // NOTE the redirect producer will populate contents when the redirect facility is 'static'
@@ -631,15 +633,6 @@ function computeVersionSegment (componentVersion, mode) {
631
633
  return versionSegment
632
634
  }
633
635
 
634
- function getFileLocation ({ path: path_, src: { abspath, origin } }) {
635
- if (!origin) return abspath || path_
636
- const { url, gitdir, worktree, refname, tag, reftype = tag ? 'tag' : 'branch', remote, startPath } = origin
637
- let details = `${reftype}: ${refname}`
638
- if ('worktree' in origin) details += worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : ''
639
- if (startPath) details += ` | start path: ${startPath}`
640
- return `${abspath || path.join(startPath, path_)} in ${'worktree' in origin ? worktree || gitdir : url} (${details})`
641
- }
642
-
643
636
  function getComponentVersionFiles (componentVersionId) {
644
637
  return this.findBy(componentVersionId)
645
638
  }
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ const { posix: path } = require('node:path')
4
+
5
+ function summarizeFileLocation ({ path: path_, src: { abspath, origin } }) {
6
+ if (!origin) return abspath || path_
7
+ const { url, gitdir, worktree, refname, tag, reftype = tag ? 'tag' : 'branch', remote, startPath } = origin
8
+ let details = `${reftype}: ${refname}`
9
+ if ('worktree' in origin) details += worktree ? ' <worktree>' : remote ? ` <remotes/${remote}>` : ''
10
+ if (startPath) details += ` | start path: ${startPath}`
11
+ return `${abspath || path.join(startPath, path_)} in ${'worktree' in origin ? worktree || gitdir : url} (${details})`
12
+ }
13
+
14
+ module.exports = summarizeFileLocation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/content-classifier",
3
- "version": "3.2.0-alpha.3",
3
+ "version": "3.2.0-alpha.5",
4
4
  "description": "Organizes aggregated content into a virtual file catalog for use in an Antora documentation pipeline.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -27,13 +27,13 @@
27
27
  "#constants": "./lib/constants.js"
28
28
  },
29
29
  "dependencies": {
30
- "@antora/asciidoc-loader": "3.2.0-alpha.3",
31
- "@antora/logger": "3.2.0-alpha.3",
30
+ "@antora/asciidoc-loader": "3.2.0-alpha.5",
31
+ "@antora/logger": "3.2.0-alpha.5",
32
32
  "mime-types": "~2.1",
33
- "vinyl": "~2.2"
33
+ "vinyl": "~3.0"
34
34
  },
35
35
  "engines": {
36
- "node": ">=16.0.0"
36
+ "node": ">=18.0.0"
37
37
  },
38
38
  "files": [
39
39
  "lib/"