@antora/content-classifier 3.2.0-rc.1 → 3.2.0-rc.2
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.
- package/lib/content-catalog.js +6 -8
- package/package.json +3 -3
package/lib/content-catalog.js
CHANGED
|
@@ -143,11 +143,11 @@ class ContentCatalog {
|
|
|
143
143
|
return componentVersion
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
addFile (file) {
|
|
146
|
+
addFile (file, create = true) {
|
|
147
147
|
const src = file.src
|
|
148
148
|
const family = src.family
|
|
149
149
|
let filesForFamily
|
|
150
|
-
if ((filesForFamily = this[$files].get(family))
|
|
150
|
+
if (!(filesForFamily = this[$files].get(family))) this[$files].set(family, (filesForFamily = new Map()))
|
|
151
151
|
const key = generateKey(src)
|
|
152
152
|
if (filesForFamily.has(key)) {
|
|
153
153
|
if (family === 'alias') {
|
|
@@ -161,8 +161,7 @@ class ContentCatalog {
|
|
|
161
161
|
}
|
|
162
162
|
throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`)
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
filesForFamily.set(key, file)
|
|
164
|
+
filesForFamily.set(key, create ? (file = this.createFile(file)) : file)
|
|
166
165
|
return file
|
|
167
166
|
}
|
|
168
167
|
|
|
@@ -170,10 +169,10 @@ class ContentCatalog {
|
|
|
170
169
|
const src = file.src
|
|
171
170
|
let { componentVersion, family } = src
|
|
172
171
|
if (componentVersion) delete src.componentVersion
|
|
173
|
-
// NOTE: assume that if the file is not a vinyl object, the src likely needs to be
|
|
172
|
+
// NOTE: assume that if the file is not a vinyl object, the src likely needs to be inflated
|
|
174
173
|
// a vinyl object is one indication the file was created and prepared by the content aggregator
|
|
175
|
-
// an alternate approach would be to call inflateSrc if the path property is not set
|
|
176
174
|
if (!File.isVinyl(file)) {
|
|
175
|
+
if (typeof file.contents === 'string') file.contents = Buffer.from(file.contents)
|
|
177
176
|
inflateSrc(src)
|
|
178
177
|
file = new File(file)
|
|
179
178
|
}
|
|
@@ -228,8 +227,7 @@ class ContentCatalog {
|
|
|
228
227
|
|
|
229
228
|
removeFile (file) {
|
|
230
229
|
const src = file.src
|
|
231
|
-
|
|
232
|
-
return filesForFamily ? filesForFamily.delete(generateKey(src)) : false
|
|
230
|
+
return this[$files].get(src.family)?.delete(generateKey(src)) || false
|
|
233
231
|
}
|
|
234
232
|
|
|
235
233
|
findBy (criteria) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-classifier",
|
|
3
|
-
"version": "3.2.0-rc.
|
|
3
|
+
"version": "3.2.0-rc.2",
|
|
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)",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"#constants": "./lib/constants.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@antora/asciidoc-loader": "3.2.0-rc.
|
|
35
|
-
"@antora/logger": "3.2.0-rc.
|
|
34
|
+
"@antora/asciidoc-loader": "3.2.0-rc.2",
|
|
35
|
+
"@antora/logger": "3.2.0-rc.2",
|
|
36
36
|
"mime-types": "~3.0",
|
|
37
37
|
"vinyl": "~3.0"
|
|
38
38
|
},
|