@antora/ui-loader
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
@@ -28,9 +28,9 @@ 'use strict' | ||
* | ||
* Looks for UI bundle at the path specified in the ui.bundle property of the | ||
* playbook. If the path is a URI, it downloads the file and caches it at | ||
* a unique path to avoid this step in future calls. It then reads all the | ||
* files from the bundle into memory, skipping any files that fall outside | ||
* of the start path specified in the ui.startPath property of the playbook. | ||
* Finally, it classifies the files and adds them to a UiCatalog, which is | ||
* then returned. | ||
* Looks for UI bundle at the path specified in the ui.bundle.url property of | ||
* the playbook. If the path is a URI, it downloads the file and caches it at a | ||
* unique path to avoid this step in future calls. It then reads all the files | ||
* from the bundle into memory, skipping any files that fall outside of the | ||
* start path specified in the ui.startPath property of the playbook. Finally, | ||
* it classifies the files and adds them to a UiCatalog, which is then | ||
* returned. | ||
* | ||
@@ -43,5 +43,6 @@ * @memberof ui-loader | ||
* @param {Object} playbook.ui - The UI configuration object for Antora. | ||
* @param {String} playbook.ui.bundle - The path (relative or absolute) or URI | ||
* @param {String} playbook.ui.bundle - The UI bundle configuration. | ||
* @param {String} playbook.ui.bundle.url - The path (relative or absolute) or URI | ||
* of the UI bundle to use. | ||
* @param {String} [playbook.ui.startPath=''] - The path inside the bundle from | ||
* @param {String} [playbook.ui.bundle.startPath=''] - The path inside the bundle from | ||
* which to start reading files. | ||
@@ -55,16 +56,15 @@ * @param {String} [playbook.ui.outputDir='_'] - The path relative to the site root | ||
const startDir = playbook.dir || '.' | ||
const { bundle: bundleUri, startPath, supplementalFiles: supplementalFilesSpec, outputDir } = playbook.ui | ||
const { bundle, supplementalFiles: supplementalFilesSpec, outputDir } = playbook.ui | ||
const bundleUrl = bundle.url | ||
let resolveBundle | ||
if (isUrl(bundleUri)) { | ||
resolveBundle = ensureCacheDir((playbook.runtime || {}).cacheDir, startDir).then((cacheDir) => { | ||
const cachePath = ospath.join(cacheDir, sha1(bundleUri) + '.zip') | ||
return fs.pathExists(cachePath).then((exists) => { | ||
if (exists) return cachePath | ||
return get(bundleUri, { encoding: null }).then(({ body }) => | ||
fs.outputFile(cachePath, body).then(() => cachePath) | ||
) | ||
}) | ||
if (isUrl(bundleUrl)) { | ||
const { cacheDir, pull } = playbook.runtime || {} | ||
resolveBundle = ensureCacheDir(cacheDir, startDir).then((cacheAbsDir) => { | ||
const cachePath = ospath.join(cacheAbsDir, `${sha1(bundleUrl)}.zip`) | ||
return pull && bundle.snapshot | ||
? downloadBundle(bundleUrl, cachePath) | ||
: fs.pathExists(cachePath).then((cached) => (cached ? cachePath : downloadBundle(bundleUrl, cachePath))) | ||
}) | ||
} else { | ||
const localPath = expandPath(bundleUri, '~+', startDir) | ||
const localPath = expandPath(bundleUrl, '~+', startDir) | ||
resolveBundle = fs.pathExists(localPath).then((exists) => { | ||
@@ -74,3 +74,3 @@ if (exists) { | ||
} else { | ||
throw new Error('Specified UI bundle does not exist: ' + bundleUri) | ||
throw new Error('Specified UI bundle does not exist: ' + bundleUrl) | ||
} | ||
@@ -87,3 +87,3 @@ }) | ||
.on('error', reject) | ||
.pipe(selectFilesStartingFrom(startPath)) | ||
.pipe(selectFilesStartingFrom(bundle.startPath)) | ||
.pipe(bufferizeContents()) | ||
@@ -133,2 +133,6 @@ .on('error', reject) | ||
function downloadBundle (url, to) { | ||
return get(url, { encoding: null }).then(({ body }) => fs.outputFile(to, body).then(() => to)) | ||
} | ||
function selectFilesStartingFrom (startPath) { | ||
@@ -135,0 +139,0 @@ if (!startPath || (startPath = path.join('/', startPath + '/')) === '/') { |
{ | ||
"name": "@antora/ui-loader", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "Downloads a UI bundle, if necessary, and loads the files into a UI catalog for use in an Antora documentation pipeline.", | ||
@@ -23,5 +23,5 @@ "license": "MPL-2.0", | ||
"fs-extra": "^5.0.0", | ||
"got": "^8.2.0", | ||
"got": "^8.3.0", | ||
"gulp-vinyl-zip": "^2.1.0", | ||
"js-yaml": "^3.10.0", | ||
"js-yaml": "^3.11.0", | ||
"lodash": "^4.17.5", | ||
@@ -28,0 +28,0 @@ "minimatch-all": "^1.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13747
345
Updatedgot@^8.3.0
Updatedjs-yaml@^3.11.0