@antora/ui-loader 3.2.0-alpha.6 → 3.2.0-alpha.9
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/load-ui.js +36 -39
- package/package.json +7 -3
package/lib/load-ui.js
CHANGED
|
@@ -84,9 +84,9 @@ async function loadUi (playbook) {
|
|
|
84
84
|
return fetch && bundle.snapshot
|
|
85
85
|
? downloadBundle(bundleUrl, cachePath, createAgent(bundleUrl, playbook.network || {}))
|
|
86
86
|
: fsp.stat(cachePath).then(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
(stat) => new File({ path: cachePath, stat }),
|
|
88
|
+
() => downloadBundle(bundleUrl, cachePath, createAgent(bundleUrl, playbook.network || {}))
|
|
89
|
+
)
|
|
90
90
|
})
|
|
91
91
|
} else {
|
|
92
92
|
const localPath = expandPath(bundleUrl, { dot: startDir })
|
|
@@ -106,9 +106,9 @@ async function loadUi (playbook) {
|
|
|
106
106
|
bundleFile.isDirectory()
|
|
107
107
|
? srcFs(ospath.join(bundleFile.path, bundle.startPath || '', '.')).then(resolve, reject)
|
|
108
108
|
: srcZip(bundleFile.path, { startPath: bundle.startPath })
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
.on('error', (err) => reject(Object.assign(err, { message: `not a valid zip file; ${err.message}` })))
|
|
110
|
+
.pipe(bufferizeContentsAndCollectFiles(resolve))
|
|
111
|
+
.on('error', reject)
|
|
112
112
|
).catch((err) => {
|
|
113
113
|
const msg =
|
|
114
114
|
`Failed to read UI ${bundleFile.isDirectory() ? 'directory' : 'bundle'}: ` +
|
|
@@ -203,36 +203,34 @@ function srcSupplementalFiles (filesSpec, startDir) {
|
|
|
203
203
|
return (
|
|
204
204
|
Array.isArray(filesSpec)
|
|
205
205
|
? Promise.all(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
filesSpec.reduce((accum, { path: path_, contents: contents_ }) => {
|
|
207
|
+
if (!path_) return accum
|
|
208
|
+
if (contents_) {
|
|
209
|
+
if (~contents_.indexOf('\n') || !EXT_RX.test(contents_)) {
|
|
210
|
+
accum.push(new MemoryFile({ path: path_, contents: Buffer.from(contents_) }))
|
|
211
|
+
} else {
|
|
212
|
+
contents_ = expandPath(contents_, { dot: startDir })
|
|
213
|
+
accum.push(
|
|
214
|
+
fsp
|
|
215
|
+
.stat(contents_)
|
|
216
|
+
.then((stat) =>
|
|
217
|
+
fsp.readFile(contents_).then((contents) => new File({ path: path_, contents, stat }))
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
}
|
|
212
221
|
} else {
|
|
213
|
-
|
|
214
|
-
accum.push(
|
|
215
|
-
fsp
|
|
216
|
-
.stat(contents_)
|
|
217
|
-
.then((stat) =>
|
|
218
|
-
fsp.readFile(contents_).then((contents) => new File({ path: path_, contents, stat }))
|
|
219
|
-
)
|
|
220
|
-
)
|
|
222
|
+
accum.push(new MemoryFile({ path: path_ }))
|
|
221
223
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return accum
|
|
226
|
-
}, [])
|
|
227
|
-
).then((files) => files.reduce((accum, file) => accum.set(file.path, file) && accum, new Map()))
|
|
224
|
+
return accum
|
|
225
|
+
}, [])
|
|
226
|
+
).then((files) => files.reduce((accum, file) => accum.set(file.path, file) && accum, new Map()))
|
|
228
227
|
: fsp.access((cwd = expandPath(filesSpec, { dot: startDir }))).then(() => srcFs(cwd))
|
|
229
228
|
).catch((err) => {
|
|
230
229
|
const dir = cwd ? filesSpec + (filesSpec === cwd ? '' : ` (resolved to ${cwd})`) : undefined
|
|
231
230
|
if (err.code === 'ENOENT' && err.path === cwd) {
|
|
232
231
|
throw new Error(`Specified ui.supplemental_files directory does not exist: ${dir}`)
|
|
233
|
-
} else {
|
|
234
|
-
throw transformError(err, `Failed to read ui.supplemental_files ${cwd ? `directory: ${dir}` : 'entry'}`)
|
|
235
232
|
}
|
|
233
|
+
throw transformError(err, `Failed to read ui.supplemental_files ${cwd ? `directory: ${dir}` : 'entry'}`)
|
|
236
234
|
})
|
|
237
235
|
}
|
|
238
236
|
|
|
@@ -247,12 +245,11 @@ function loadConfig (files, outputDir) {
|
|
|
247
245
|
files.delete(UI_DESC_FILENAME)
|
|
248
246
|
const config = camelCaseKeys(yaml.load(configFile.contents.toString()))
|
|
249
247
|
const staticFiles = config.staticFiles
|
|
250
|
-
if (staticFiles
|
|
248
|
+
if (staticFiles?.length) config.isStaticFile = picomatch(staticFiles, STATIC_FILE_MATCHER_OPTS)
|
|
251
249
|
if (outputDir !== undefined) config.outputDir = outputDir
|
|
252
250
|
return config
|
|
253
|
-
} else {
|
|
254
|
-
return { outputDir }
|
|
255
251
|
}
|
|
252
|
+
return { outputDir }
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
function camelCaseKeys (o) {
|
|
@@ -266,7 +263,7 @@ function camelCaseKeys (o) {
|
|
|
266
263
|
}
|
|
267
264
|
|
|
268
265
|
function classifyFile (file, config) {
|
|
269
|
-
if (config.isStaticFile && config.isStaticFile(file.path)) {
|
|
266
|
+
if (typeof config.isStaticFile === 'function' && config.isStaticFile(file.path)) {
|
|
270
267
|
file.type = 'static'
|
|
271
268
|
file.out = resolveOut(file, '')
|
|
272
269
|
} else if (file.isDot()) {
|
|
@@ -315,14 +312,14 @@ function srcFs (cwd) {
|
|
|
315
312
|
(statErr) =>
|
|
316
313
|
dirent.isSymbolicLink()
|
|
317
314
|
? fsp
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
315
|
+
.readlink(abspath)
|
|
316
|
+
.then(
|
|
317
|
+
(symlink) =>
|
|
318
|
+
(statErr.code === 'ELOOP' ? 'ELOOP: symbolic link cycle, ' : 'ENOENT: broken symbolic link, ') +
|
|
322
319
|
`${relpath} -> ${symlink}`,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
320
|
+
() => statErr.message.replace(`'${abspath}'`, relpath)
|
|
321
|
+
)
|
|
322
|
+
.then((message) => done(Object.assign(statErr, { message })))
|
|
326
323
|
: done(Object.assign(statErr, { message: statErr.message.replace(`'${abspath}'`, relpath) }))
|
|
327
324
|
)
|
|
328
325
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/ui-loader",
|
|
3
|
-
"version": "3.2.0-alpha.
|
|
3
|
+
"version": "3.2.0-alpha.9",
|
|
4
4
|
"description": "Downloads a UI bundle, if necessary, and loads the files into a UI catalog for use in an Antora documentation pipeline.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"Guillaume Grossetie <g.grossetie@gmail.com>"
|
|
12
12
|
],
|
|
13
13
|
"homepage": "https://antora.org",
|
|
14
|
-
"repository":
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://gitlab.com/antora/antora.git",
|
|
17
|
+
"directory": "packages/ui-loader"
|
|
18
|
+
},
|
|
15
19
|
"bugs": {
|
|
16
20
|
"url": "https://gitlab.com/antora/antora/issues"
|
|
17
21
|
},
|
|
@@ -25,7 +29,7 @@
|
|
|
25
29
|
"#constants": "./lib/constants.js"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@antora/expand-path-helper": "~
|
|
32
|
+
"@antora/expand-path-helper": "~3.0",
|
|
29
33
|
"braces": "~3.0",
|
|
30
34
|
"cache-directory": "~2.0",
|
|
31
35
|
"fast-glob": "~3.3",
|