Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antora/content-classifier

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/content-classifier - npm Package Compare versions

Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8

71

lib/content-catalog.js
'use strict'
const File = require('./file')
const invariably = { void: () => undefined }
const logger = require('./logger')

@@ -123,8 +124,12 @@ const { lookup: resolveMimeType } = require('./mime-types-with-asciidoc')

let family = src.family
let filesForFamily = this[$files].get(family)
if (!filesForFamily) this[$files].set(family, (filesForFamily = new Map()))
const key = generateKey(src)
if (this[$files].has(key)) {
if (filesForFamily.has(key)) {
if (family === 'alias') {
throw new Error(`Duplicate alias: ${generateResourceSpec(src)}`)
} else {
const details = [this.getById(src), file].map((it, idx) => ` ${idx + 1}: ${getFileLocation(it)}`).join('\n')
const details = [filesForFamily.get(key), file]
.map((it, idx) => ` ${idx + 1}: ${getFileLocation(it)}`)
.join('\n')
if (family === 'nav') {

@@ -173,3 +178,3 @@ throw new Error(`Duplicate nav in ${src.version}@${src.component}: ${file.path}\n${details}`)

}
this[$files].set(key, file)
filesForFamily.set(key, file)
return file

@@ -180,6 +185,13 @@ }

const criteriaEntries = Object.entries(criteria)
const family = criteria.family
if (criteriaEntries.length === 1 && family) {
const filesForFamily = this[$files].get(family)
return filesForFamily ? [...filesForFamily.values()] : []
}
const accum = []
for (const candidate of this[$files].values()) {
const candidateSrc = candidate.src
if (criteriaEntries.every(([key, val]) => candidateSrc[key] === val)) accum.push(candidate)
for (const filesForFamily of this[$files].values()) {
for (const candidate of filesForFamily.values()) {
const candidateSrc = candidate.src
if (criteriaEntries.every(([key, val]) => candidateSrc[key] === val)) accum.push(candidate)
}
}

@@ -189,10 +201,10 @@ return accum

getById ({ component, version, module: module_, family, relative }) {
return this[$files].get(generateKey({ component, version, module: module_, family, relative }))
getById (id) {
return (this[$files].get(id.family) || { get: invariably.void }).get(generateKey(id))
}
getByPath ({ component, version, path: path_ }) {
for (const candidate of this[$files].values()) {
if (candidate.path === path_ && candidate.src.component === component && candidate.src.version === version) {
return candidate
for (const filesForFamily of this[$files].values()) {
for (const it of filesForFamily.values()) {
if (it.path === path_ && it.src.component === component && it.src.version === version) return it
}

@@ -221,17 +233,19 @@ }

getFiles () {
return [...this[$files].values()]
const accum = []
for (const filesForFamily of this[$files].values()) {
for (const file of filesForFamily.values()) accum.push(file)
}
return accum
}
getPages (filter) {
const accum = []
const candidates = this[$files].get('page')
if (!candidates) return []
if (filter) {
for (const candidate of this[$files].values()) {
if (candidate.src.family === 'page' && filter(candidate)) accum.push(candidate)
}
const accum = []
for (const candidate of candidates.values()) filter(candidate) && accum.push(candidate)
return accum
} else {
for (const candidate of this[$files].values()) {
if (candidate.src.family === 'page') accum.push(candidate)
}
return [...candidates.values()]
}
return accum
}

@@ -336,9 +350,2 @@

}
const existingAlias = this.getById(Object.assign({}, src, { family: 'alias' }))
if (existingAlias) {
throw new Error(
`Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})\n` +
` source: ${getFileLocation(target)}`
)
}
} else if (src.version == null) {

@@ -349,2 +356,8 @@ // QUESTION should we skip registering alias in this case?

src.family = 'alias'
const existingAlias = this.getById(src)
if (existingAlias) {
throw new Error(
`Duplicate alias: ${generateResourceSpec(src)} (specified as: ${spec})\n source: ${getFileLocation(target)}`
)
}
// NOTE the redirect producer will populate contents when the redirect facility is 'static'

@@ -404,4 +417,4 @@ const alias = this.addFile({ src, rel: target })

function generateKey ({ component, version, module: module_, family, relative }) {
return `${version}@${component}:${module_}:${family}$${relative}`
function generateKey ({ component, version, module: module_, relative }) {
return `${version}@${component}:${module_}:${relative}`
}

@@ -408,0 +421,0 @@

{
"name": "@antora/content-classifier",
"version": "3.0.0-alpha.7",
"version": "3.0.0-alpha.8",
"description": "Organizes aggregated content into a virtual file catalog for use in an Antora documentation pipeline.",

@@ -19,3 +19,3 @@ "license": "MPL-2.0",

"dependencies": {
"@antora/logger": "3.0.0-alpha.7",
"@antora/logger": "3.0.0-alpha.8",
"mime-types": "~2.1",

@@ -38,3 +38,3 @@ "vinyl": "~2.2"

],
"gitHead": "fbd597b3680474f2083cda8a7facf1e2848c08e0"
"gitHead": "2e5695bea11fb5719989c329c97e66d36e29659f"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc