@antora/content-classifier 3.1.9 → 3.1.10

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.
@@ -141,7 +141,7 @@ function getNavInfo (filepath, nav) {
141
141
  }
142
142
 
143
143
  function resolveAsciiDocConfig (siteAsciiDocConfig, { asciidoc, origins = [] }) {
144
- const scopedAttributes = (asciidoc || {}).attributes
144
+ const scopedAttributes = asciidoc?.attributes
145
145
  if (scopedAttributes) {
146
146
  const initial = siteAsciiDocConfig.attributes
147
147
  const mdc = { file: { path: 'antora.yml', origin: origins[origins.length - 1] } }
@@ -84,10 +84,10 @@ class ContentCatalog {
84
84
  let lastVerdict
85
85
  const insertIdx = version
86
86
  ? componentVersions.findIndex(({ version: candidateVersion, prerelease: candidatePrerelease }) => {
87
- return (lastVerdict = versionCompare(candidateVersion, version)) > 1
88
- ? !!prerelease === !!candidatePrerelease
89
- : lastVerdict > 0 || (lastVerdict < -1 && prerelease && !candidatePrerelease)
90
- })
87
+ return (lastVerdict = versionCompare(candidateVersion, version)) > 1
88
+ ? !!prerelease === !!candidatePrerelease
89
+ : lastVerdict > 0 || (lastVerdict < -1 && prerelease && !candidatePrerelease)
90
+ })
91
91
  : prerelease
92
92
  ? -1
93
93
  : ~(~componentVersions.findIndex(({ prerelease: candidatePrerelease }) => !candidatePrerelease) || -1)
@@ -143,16 +143,14 @@ class ContentCatalog {
143
143
  if (filesForFamily.has(key)) {
144
144
  if (family === 'alias') {
145
145
  throw new Error(`Duplicate alias: ${generateResourceSpec(src)}`)
146
- } else {
147
- const details = [filesForFamily.get(key), file]
148
- .map((it, idx) => `${idx + 1}: ${summarizeFileLocation(it)}`)
149
- .join(LOG_WRAP)
150
- if (family === 'nav') {
151
- throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}${LOG_WRAP}${details}`)
152
- } else {
153
- throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`)
154
- }
155
146
  }
147
+ const details = [filesForFamily.get(key), file]
148
+ .map((it, idx) => `${idx + 1}: ${summarizeFileLocation(it)}`)
149
+ .join(LOG_WRAP)
150
+ if (family === 'nav') {
151
+ throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}${LOG_WRAP}${details}`)
152
+ }
153
+ throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`)
156
154
  }
157
155
  // NOTE: if the path property is not set, assume the src likely needs to be prepared
158
156
  // another option is to assume that if the file is not a vinyl object, the src likely needs to be prepared
@@ -234,7 +232,7 @@ class ContentCatalog {
234
232
  }
235
233
 
236
234
  getComponentVersion (component, version) {
237
- return (component.versions || (this.getComponent(component) || {}).versions || []).find(
235
+ return (component.versions || this.getComponent(component)?.versions || []).find(
238
236
  ({ version: candidate }) => candidate === version
239
237
  )
240
238
  }
@@ -262,14 +260,13 @@ class ContentCatalog {
262
260
  const accum = []
263
261
  for (const candidate of candidates.values()) filter(candidate) && accum.push(candidate)
264
262
  return accum
265
- } else {
266
- return [...candidates.values()]
267
263
  }
264
+ return [...candidates.values()]
268
265
  }
269
266
 
270
267
  // TODO add `follow` argument to control whether alias is followed
271
268
  getSiteStartPage () {
272
- return this.getById(ROOT_INDEX_PAGE_ID) || (this.getById(ROOT_INDEX_ALIAS_ID) || {}).rel
269
+ return this.getById(ROOT_INDEX_PAGE_ID) || this.getById(ROOT_INDEX_ALIAS_ID)?.rel
273
270
  }
274
271
 
275
272
  registerComponentVersionStartPage (name, componentVersion, startPageSpec = undefined) {
@@ -342,7 +339,8 @@ class ContentCatalog {
342
339
  if (rel.pub.url === (this.htmlUrlExtensionStyle === 'default' ? '/index.html' : '/')) return
343
340
  const src = Object.assign({}, ROOT_INDEX_ALIAS_ID)
344
341
  return this.addFile({ src, rel, synthetic: true }, { version: src.version })
345
- } else if (rel === false) {
342
+ }
343
+ if (rel === false) {
346
344
  logger.warn('Start page specified for site has invalid syntax: %s', startPageSpec)
347
345
  } else if (startPageSpec.lastIndexOf(':') > startPageSpec.indexOf(':')) {
348
346
  logger.warn('Start page specified for site not found: %s', startPageSpec)
@@ -367,10 +365,10 @@ class ContentCatalog {
367
365
  throw new Error(
368
366
  existingPage === target
369
367
  ? `Page cannot define alias that references itself: ${generateResourceSpec(src)}` +
370
- ` (specified as: ${spec})${LOG_WRAP}source: ${summarizeFileLocation(existingPage)}`
368
+ ` (specified as: ${spec})${LOG_WRAP}source: ${summarizeFileLocation(existingPage)}`
371
369
  : `Page alias cannot reference an existing page: ${generateResourceSpec(src)} (specified as: ${spec})` +
372
- `${LOG_WRAP}source: ${summarizeFileLocation(target)}` +
373
- `${LOG_WRAP}existing page: ${summarizeFileLocation(existingPage)}`
370
+ `${LOG_WRAP}source: ${summarizeFileLocation(target)}` +
371
+ `${LOG_WRAP}existing page: ${summarizeFileLocation(existingPage)}`
374
372
  )
375
373
  }
376
374
  } else if (src.version == null) {
@@ -26,7 +26,6 @@ const parseResourceId = require('./parse-resource-id')
26
26
  */
27
27
  function resolveResource (spec, catalog, ctx = {}, defaultFamily = undefined, permittedFamilies = undefined) {
28
28
  const id = parseResourceId(spec, ctx, defaultFamily, permittedFamilies)
29
-
30
29
  if (!id || !id.family) return false
31
30
  if (id.version == null) {
32
31
  const component = catalog.getComponent(id.component)
@@ -34,10 +33,9 @@ function resolveResource (spec, catalog, ctx = {}, defaultFamily = undefined, pe
34
33
  id.version = component.latest.version
35
34
  }
36
35
  if (!id.module) id.module = 'ROOT'
37
-
38
36
  return (
39
37
  catalog.getById(id) ||
40
- (id.family === 'page' ? (catalog.getById(Object.assign({}, id, { family: 'alias' })) || {}).rel : undefined)
38
+ (id.family === 'page' ? catalog.getById(Object.assign({}, id, { family: 'alias' }))?.rel : undefined)
41
39
  )
42
40
  }
43
41
 
@@ -24,11 +24,8 @@ function versionCompareDesc (a, b) {
24
24
  if (a && b) {
25
25
  const semverA = resolveSemver(a)
26
26
  const semverB = resolveSemver(b)
27
- if (semverA) {
28
- return semverB ? -semverCompare(semverA, semverB) : 1
29
- } else {
30
- return semverB ? -1 : -2 * a.localeCompare(b, 'en', { numeric: true })
31
- }
27
+ if (semverA) return semverB ? -semverCompare(semverA, semverB) : 1
28
+ return semverB ? -1 : -2 * a.localeCompare(b, 'en', { numeric: true })
32
29
  }
33
30
  return a ? 1 : -1
34
31
  }
@@ -64,23 +61,18 @@ function semverCompare (a, b) {
64
61
  const numsA = a.split('.')
65
62
  const numsB = b.split('.')
66
63
  for (let i = 0; i < 3; i++) {
67
- const numA = Number(numsA[i] || 0)
68
- const numB = Number(numsB[i] || 0)
69
- if (numA > numB) {
70
- return 1
71
- } else if (numB > numA) {
72
- return -1
73
- } else if (isNaN(numA)) {
74
- if (!isNaN(numB)) return -1
75
- } else if (isNaN(numB)) {
64
+ const numA = Number(numsA[i] ?? 0)
65
+ const numB = Number(numsB[i] ?? 0)
66
+ if (numA > numB) return 1
67
+ if (numB > numA) return -1
68
+ if (Number.isNaN(numA)) {
69
+ if (!Number.isNaN(numB)) return -1
70
+ } else if (Number.isNaN(numB)) {
76
71
  return 1
77
72
  }
78
73
  }
79
- if (preA == null) {
80
- return preB == null ? 0 : 1
81
- } else {
82
- return preB == null ? -1 : preA.localeCompare(preB, 'en', { numeric: true })
83
- }
74
+ if (preA == null) return preB == null ? 0 : 1
75
+ return preB == null ? -1 : preA.localeCompare(preB, 'en', { numeric: true })
84
76
  }
85
77
 
86
78
  module.exports = versionCompareDesc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/content-classifier",
3
- "version": "3.1.9",
3
+ "version": "3.1.10",
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)",
@@ -10,7 +10,10 @@
10
10
  "Hubert SABLONNIÈRE <hubert.sablonniere@gmail.com>"
11
11
  ],
12
12
  "homepage": "https://antora.org",
13
- "repository": "gitlab:antora/antora",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://gitlab.com/antora/antora.git"
16
+ },
14
17
  "bugs": {
15
18
  "url": "https://gitlab.com/antora/antora/issues"
16
19
  },
@@ -27,8 +30,8 @@
27
30
  "#constants": "./lib/constants.js"
28
31
  },
29
32
  "dependencies": {
30
- "@antora/asciidoc-loader": "3.1.9",
31
- "@antora/logger": "3.1.9",
33
+ "@antora/asciidoc-loader": "3.1.10",
34
+ "@antora/logger": "3.1.10",
32
35
  "mime-types": "~2.1",
33
36
  "vinyl": "~3.0"
34
37
  },