@antora/content-aggregator 3.0.0-beta.3 → 3.0.0-rc.1
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/aggregate-content.js
CHANGED
|
@@ -18,13 +18,13 @@ const { NotFoundError, ObjectTypeError, UnknownTransportError, UrlParseError } =
|
|
|
18
18
|
const globStream = require('glob-stream')
|
|
19
19
|
const invariably = require('./invariably')
|
|
20
20
|
const { makeMatcherRx, versionMatcherOpts: VERSION_MATCHER_OPTS } = require('./matcher')
|
|
21
|
-
const MultiProgress = require('multi-progress')
|
|
21
|
+
const MultiProgress = require('multi-progress') // calls require('progress') as a peer dependencies
|
|
22
22
|
const ospath = require('path')
|
|
23
23
|
const { posix: path } = ospath
|
|
24
24
|
const posixify = ospath.sep === '\\' ? (p) => p.replace(/\\/g, '/') : undefined
|
|
25
25
|
const { fs: resolvePathGlobsFs, git: resolvePathGlobsGit } = require('./resolve-path-globs')
|
|
26
|
-
const { pipeline,
|
|
27
|
-
const
|
|
26
|
+
const { pipeline, Writable } = require('stream')
|
|
27
|
+
const forEach = (write) => new Writable({ objectMode: true, write })
|
|
28
28
|
const userRequire = require('@antora/user-require-helper')
|
|
29
29
|
const yaml = require('js-yaml')
|
|
30
30
|
|
|
@@ -227,9 +227,8 @@ async function loadRepository (url, opts) {
|
|
|
227
227
|
try {
|
|
228
228
|
await git.resolveRef(Object.assign({ ref: 'HEAD', depth: 1 }, repo))
|
|
229
229
|
} catch {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
)
|
|
230
|
+
const msg = `Local content source must be a git repository: ${dir}${url !== dir ? ' (url: ' + url + ')' : ''}`
|
|
231
|
+
throw new Error(msg)
|
|
233
232
|
}
|
|
234
233
|
} else {
|
|
235
234
|
throw new Error(`Local content source does not exist: ${dir}${url !== dir ? ' (url: ' + url + ')' : ''}`)
|
|
@@ -429,14 +428,15 @@ function collectFilesFromStartPath (startPath, repo, authStatus, ref, worktreePa
|
|
|
429
428
|
return componentVersionBucket
|
|
430
429
|
})
|
|
431
430
|
.catch((err) => {
|
|
431
|
+
const msg = err.message
|
|
432
432
|
const refInfo = `ref: ${ref.fullname.replace(HEADS_DIR_RX, '')}${worktreePath ? ' <worktree>' : ''}`
|
|
433
|
-
const pathInfo = !startPath ||
|
|
434
|
-
throw Object.assign(err, { message:
|
|
433
|
+
const pathInfo = !startPath || msg.startsWith('the start path ') ? '' : ' | path: ' + startPath
|
|
434
|
+
throw Object.assign(err, { message: msg.replace(/$/m, ` in ${repo.url || repo.dir} (${refInfo}${pathInfo})`) })
|
|
435
435
|
})
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
function readFilesFromWorktree (worktreePath, startPath) {
|
|
439
|
-
const cwd = ospath.join(worktreePath, startPath)
|
|
439
|
+
const cwd = ospath.join(worktreePath, startPath, '.') // . shaves off trailing slash
|
|
440
440
|
return fsp.stat(cwd).then(
|
|
441
441
|
(startPathStat) => {
|
|
442
442
|
if (!startPathStat.isDirectory()) throw new Error(`the start path '${startPath}' is not a directory`)
|
|
@@ -449,23 +449,24 @@ function readFilesFromWorktree (worktreePath, startPath) {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
function srcFs (cwd) {
|
|
452
|
-
|
|
452
|
+
const relpathStart = cwd.length + 1
|
|
453
|
+
return new Promise((resolve, reject, cache = Object.create(null), files = []) =>
|
|
453
454
|
pipeline(
|
|
454
455
|
globStream(CONTENT_SRC_GLOB, Object.assign({ cache, cwd }, CONTENT_SRC_OPTS)),
|
|
455
|
-
|
|
456
|
-
if (Array.isArray(cache[abspathPosix])) return
|
|
456
|
+
forEach(({ path: abspathPosix }, _, done) => {
|
|
457
|
+
if (Array.isArray(cache[abspathPosix])) return done() // detects some directories, but not all
|
|
457
458
|
const abspath = posixify ? ospath.normalize(abspathPosix) : abspathPosix
|
|
458
|
-
const relpath = abspath.substr(
|
|
459
|
+
const relpath = abspath.substr(relpathStart)
|
|
459
460
|
symlinkAwareStat(abspath).then(
|
|
460
461
|
(stat) => {
|
|
461
|
-
if (stat.isDirectory()) return
|
|
462
|
+
if (stat.isDirectory()) return done() // detects remaining directories
|
|
462
463
|
fsp.readFile(abspath).then(
|
|
463
464
|
(contents) => {
|
|
464
465
|
files.push(new File({ path: posixify ? posixify(relpath) : relpath, contents, stat, src: { abspath } }))
|
|
465
|
-
|
|
466
|
+
done()
|
|
466
467
|
},
|
|
467
468
|
(readErr) => {
|
|
468
|
-
|
|
469
|
+
done(Object.assign(readErr, { message: readErr.message.replace(`'${abspath}'`, relpath) }))
|
|
469
470
|
}
|
|
470
471
|
)
|
|
471
472
|
},
|
|
@@ -478,7 +479,7 @@ function srcFs (cwd) {
|
|
|
478
479
|
} else {
|
|
479
480
|
statErr.message = statErr.message.replace(`'${abspath}'`, relpath)
|
|
480
481
|
}
|
|
481
|
-
|
|
482
|
+
done(statErr)
|
|
482
483
|
}
|
|
483
484
|
)
|
|
484
485
|
}),
|
|
@@ -652,7 +653,7 @@ function loadComponentDescriptor (files, ref, version) {
|
|
|
652
653
|
files.splice(descriptorFileIdx, 1)
|
|
653
654
|
let data
|
|
654
655
|
try {
|
|
655
|
-
data = yaml.load(descriptorFile.contents.toString())
|
|
656
|
+
data = yaml.load(descriptorFile.contents.toString(), { schema: yaml.CORE_SCHEMA })
|
|
656
657
|
} catch (err) {
|
|
657
658
|
throw Object.assign(err, { message: `${COMPONENT_DESC_FILENAME} has invalid syntax; ${err.message}` })
|
|
658
659
|
}
|
|
@@ -664,7 +665,8 @@ function loadComponentDescriptor (files, ref, version) {
|
|
|
664
665
|
if ('version' in data) version = data.version
|
|
665
666
|
if (!version) {
|
|
666
667
|
if (version === undefined) throw new Error(`${COMPONENT_DESC_FILENAME} is missing a version`)
|
|
667
|
-
version
|
|
668
|
+
if (version === false) throw new Error(`${COMPONENT_DESC_FILENAME} has an invalid version`)
|
|
669
|
+
version = '' + (typeof version === 'number' ? version : '')
|
|
668
670
|
} else if (version === true) {
|
|
669
671
|
version = ref.shortname.replace(PATH_SEPARATOR_RX, '-')
|
|
670
672
|
} else if (version.constructor === Object) {
|
|
@@ -686,7 +688,7 @@ function loadComponentDescriptor (files, ref, version) {
|
|
|
686
688
|
throw new Error(`version in ${COMPONENT_DESC_FILENAME} cannot have path segments: ${matched}`)
|
|
687
689
|
}
|
|
688
690
|
version = matched.replace(PATH_SEPARATOR_RX, '-')
|
|
689
|
-
} else if ((version =
|
|
691
|
+
} else if ((version = '' + version) === '.' || version === '..' || ~version.indexOf('/')) {
|
|
690
692
|
throw new Error(`version in ${COMPONENT_DESC_FILENAME} cannot have path segments: ${version}`)
|
|
691
693
|
}
|
|
692
694
|
data.version = version
|
|
@@ -702,7 +704,8 @@ function computeOrigin (url, authStatus, gitdir, ref, startPath, worktreePath =
|
|
|
702
704
|
} else {
|
|
703
705
|
if (worktreePath) {
|
|
704
706
|
origin.fileUriPattern =
|
|
705
|
-
(posixify ? 'file:///' + posixify(worktreePath) : 'file://' + worktreePath) +
|
|
707
|
+
(posixify ? 'file:///' + posixify(worktreePath) : 'file://' + worktreePath) +
|
|
708
|
+
(startPath ? '/' + startPath + '/%s' : '/%s')
|
|
706
709
|
} else {
|
|
707
710
|
origin.refhash = refhash
|
|
708
711
|
}
|
|
@@ -890,7 +893,8 @@ function resolveRemoteUrl (repo, remoteName) {
|
|
|
890
893
|
return 'https://' + url.substr(url.indexOf('@') + 1 || 6).replace(URL_PORT_CLEANER_RX, '$1')
|
|
891
894
|
}
|
|
892
895
|
}
|
|
893
|
-
|
|
896
|
+
url = posixify ? 'file:///' + posixify(repo.dir) : 'file://' + repo.dir
|
|
897
|
+
return ~url.indexOf(' ') ? url.replace(SPACE_RX, '%20') : url
|
|
894
898
|
})
|
|
895
899
|
}
|
|
896
900
|
|
|
@@ -9,10 +9,9 @@ const ospath = require('path')
|
|
|
9
9
|
class GitCredentialManagerStore {
|
|
10
10
|
configure ({ config, startDir }) {
|
|
11
11
|
this.entries = undefined
|
|
12
|
+
this.path = undefined
|
|
12
13
|
this.urls = {}
|
|
13
|
-
if ((this.contents = (config = config || {}).contents)
|
|
14
|
-
this.path = undefined
|
|
15
|
-
} else {
|
|
14
|
+
if (!(this.contents = (config = config || {}).contents) && config.path) {
|
|
16
15
|
this.path = expandPath(config.path, { dot: startDir })
|
|
17
16
|
}
|
|
18
17
|
return this
|
|
@@ -35,14 +34,13 @@ class GitCredentialManagerStore {
|
|
|
35
34
|
'git',
|
|
36
35
|
'credentials'
|
|
37
36
|
)
|
|
38
|
-
contentsPromise = fsp
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
.catch(() =>
|
|
37
|
+
contentsPromise = fsp.access(homeGitCredentialsPath).then(
|
|
38
|
+
() => fsp.readFile(homeGitCredentialsPath, 'utf8'),
|
|
39
|
+
() =>
|
|
42
40
|
fsp
|
|
43
41
|
.access(xdgConfigGitCredentialsPath)
|
|
44
42
|
.then(() => fsp.readFile(xdgConfigGitCredentialsPath, 'utf8'), invariably.void)
|
|
45
|
-
|
|
43
|
+
)
|
|
46
44
|
}
|
|
47
45
|
contentsPromise.then((contents) => {
|
|
48
46
|
if (contents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-aggregator",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
4
4
|
"description": "Fetches and aggregates content from distributed sources for use in an Antora documentation pipeline.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
"url": "https://gitlab.com/antora/antora/issues"
|
|
17
17
|
},
|
|
18
18
|
"main": "lib/index.js",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "_mocha"
|
|
21
|
+
},
|
|
19
22
|
"dependencies": {
|
|
20
23
|
"@antora/expand-path-helper": "~2.0",
|
|
21
24
|
"@antora/user-require-helper": "~2.0",
|
|
22
25
|
"braces": "~3.0",
|
|
23
26
|
"cache-directory": "~2.0",
|
|
24
27
|
"camelcase-keys": "~7.0",
|
|
28
|
+
"glob-stream": "~7.0",
|
|
25
29
|
"hpagent": "~0.1.0",
|
|
26
30
|
"isomorphic-git": "~1.10",
|
|
27
31
|
"js-yaml": "~4.1",
|
|
@@ -48,5 +52,5 @@
|
|
|
48
52
|
"static site",
|
|
49
53
|
"web publishing"
|
|
50
54
|
],
|
|
51
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "044371a33e2c0fed9724d30945bbb549d64845d5"
|
|
52
56
|
}
|