@antora/ui-loader 3.2.0-alpha.2 → 3.2.0-alpha.4

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/README.md CHANGED
@@ -10,4 +10,4 @@ Its site generator aggregates documents from versioned content repositories and
10
10
 
11
11
  Copyright (C) 2017-present [OpenDevise Inc.](https://opendevise.com) and the [Antora Project](https://antora.org).
12
12
 
13
- Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
13
+ Use of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).
package/lib/load-ui.js CHANGED
@@ -8,6 +8,7 @@ const { promises: fsp } = require('fs')
8
8
  const { concat: get } = require('simple-get')
9
9
  const getCacheDir = require('cache-directory')
10
10
  const globStream = require('glob-stream')
11
+ const { inspect } = require('util')
11
12
  const ospath = require('path')
12
13
  const { posix: path } = ospath
13
14
  const picomatch = require('picomatch')
@@ -17,7 +18,7 @@ const forEach = (write, final) => new Writable({ objectMode: true, write, final
17
18
  const map = (transform) => new Transform({ objectMode: true, transform })
18
19
  const UiCatalog = require('./ui-catalog')
19
20
  const yaml = require('js-yaml')
20
- const vzip = require('gulp-vinyl-zip')
21
+ const vzip = require('@vscode/gulp-vinyl-zip')
21
22
 
22
23
  const STATIC_FILE_MATCHER_OPTS = {
23
24
  expandRange: (begin, end, step, opts) => bracesToGroup(opts ? `{${begin}..${end}..${step}}` : `{${begin}..${end}}`),
@@ -111,12 +112,10 @@ async function loadUi (playbook) {
111
112
  .on('error', reject)
112
113
  .pipe(collectFiles(resolve))
113
114
  ).catch((err) => {
114
- const errWrapper = new Error(
115
+ const msg =
115
116
  `Failed to read UI ${bundleFile.isDirectory() ? 'directory' : 'bundle'}: ` +
116
- (bundleUrl === bundleFile.path ? bundleUrl : `${bundleFile.path} (resolved from url: ${bundleUrl})`)
117
- )
118
- errWrapper.stack += `\nCaused by: ${err.stack || 'unknown'}`
119
- throw errWrapper
117
+ (bundleUrl === bundleFile.path ? bundleUrl : `${bundleFile.path} (resolved from url: ${bundleUrl})`)
118
+ throw transformError(err, msg)
120
119
  })
121
120
  ),
122
121
  srcSupplementalFiles(supplementalFilesSpec, startDir),
@@ -175,7 +174,7 @@ function createAgent (url, { httpProxy, httpsProxy, noProxy }) {
175
174
  function downloadBundle (url, to, agent) {
176
175
  return new Promise((resolve, reject) => {
177
176
  get({ url, agent }, (err, response, contents) => {
178
- if (err) reject(err)
177
+ if (err) return reject(err)
179
178
  if (response.statusCode !== 200) {
180
179
  const message = `Response code ${response.statusCode} (${response.statusMessage})`
181
180
  return reject(Object.assign(new Error(message), { name: 'HTTPError' }))
@@ -193,8 +192,10 @@ function downloadBundle (url, to, agent) {
193
192
  )
194
193
  })
195
194
  }).catch((err) => {
196
- const errWrapper = new Error(`${err.summary || 'Failed to download UI bundle'}: ${url}`)
197
- errWrapper.stack += `\nCaused by: ${err.stack || 'unknown'}`
195
+ const errWrapper = transformError(err, `${err.summary || 'Failed to download UI bundle'}: ${url}`)
196
+ if (err.code === 'ECONNRESET' || (err.message || '').toLowerCase() === 'request timed out') {
197
+ Object.defineProperty(errWrapper, 'recoverable', { value: true })
198
+ }
198
199
  throw errWrapper
199
200
  })
200
201
  }
@@ -289,9 +290,7 @@ function srcSupplementalFiles (filesSpec, startDir) {
289
290
  if (err.code === 'ENOENT' && err.path === cwd) {
290
291
  throw new Error(`Specified ui.supplemental_files directory does not exist: ${dir}`)
291
292
  } else {
292
- const errWrapper = new Error(`Failed to read ui.supplemental_files ${cwd ? `directory: ${dir}` : 'entry'}`)
293
- errWrapper.stack += `\nCaused by: ${err.stack || 'unknown'}`
294
- throw errWrapper
293
+ throw transformError(err, `Failed to read ui.supplemental_files ${cwd ? `directory: ${dir}` : 'entry'}`)
295
294
  }
296
295
  })
297
296
  }
@@ -405,4 +404,10 @@ function symlinkAwareStat (path_) {
405
404
  })
406
405
  }
407
406
 
407
+ function transformError (err, msg) {
408
+ const errWrapper = new Error(msg)
409
+ errWrapper.stack += `\nCaused by: ${err.stack ? inspect(err).replace(/^Error \[(.+)\](?=: )/, '$1') : err}`
410
+ return errWrapper
411
+ }
412
+
408
413
  module.exports = loadUi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/ui-loader",
3
- "version": "3.2.0-alpha.2",
3
+ "version": "3.2.0-alpha.4",
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)",
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@antora/expand-path-helper": "~2.0",
29
+ "@vscode/gulp-vinyl-zip": "~2.5",
29
30
  "braces": "~3.0",
30
31
  "cache-directory": "~2.0",
31
32
  "glob-stream": "~7.0",
32
- "gulp-vinyl-zip": "~2.5",
33
33
  "hpagent": "~1.2",
34
34
  "js-yaml": "~4.1",
35
35
  "picomatch": "~2.3",
@@ -54,7 +54,7 @@
54
54
  ],
55
55
  "scripts": {
56
56
  "test": "_mocha",
57
- "prepublishOnly": "node $npm_config_local_prefix/npm/prepublishOnly.js",
58
- "postpublish": "node $npm_config_local_prefix/npm/postpublish.js"
57
+ "prepublishOnly": "npx -y downdoc@latest --prepublish",
58
+ "postpublish": "npx -y downdoc@latest --postpublish"
59
59
  }
60
60
  }