@antora/content-aggregator 3.1.8 → 3.1.10
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 +44 -45
- package/lib/compute-origin.js +1 -1
- package/lib/filter-refs.js +3 -4
- package/lib/resolve-path-globs.js +24 -23
- package/package.json +8 -5
package/lib/aggregate-content.js
CHANGED
|
@@ -100,11 +100,11 @@ function aggregateContent (playbook) {
|
|
|
100
100
|
const sourcesByUrl = sources.reduce((accum, source) => {
|
|
101
101
|
return accum.set(source.url, [...(accum.get(source.url) || []), Object.assign({}, sourceDefaults, source)])
|
|
102
102
|
}, new Map())
|
|
103
|
-
const progress =
|
|
103
|
+
const progress = quiet ? undefined : createProgress(sourcesByUrl.keys(), process.stdout)
|
|
104
104
|
const refPatternCache = Object.assign(new Map(), { braces: new Map() })
|
|
105
105
|
const loadOpts = { cacheDir, fetch, gitPlugins, progress, startDir, refPatternCache }
|
|
106
106
|
return collectFiles(sourcesByUrl, loadOpts, concurrency).then(buildAggregate, (err) => {
|
|
107
|
-
progress
|
|
107
|
+
progress?.terminate()
|
|
108
108
|
throw err
|
|
109
109
|
})
|
|
110
110
|
})
|
|
@@ -124,7 +124,7 @@ async function collectFiles (sourcesByUrl, loadOpts, concurrency, fetchedUrls) {
|
|
|
124
124
|
const msg0 = 'An unexpected error occurred while fetching content sources concurrently.'
|
|
125
125
|
const msg1 = 'Retrying with git.fetch_concurrency value of 1.'
|
|
126
126
|
logger.warn(rejections[0], msg0 + ' ' + msg1)
|
|
127
|
-
const fulfilledUrls = results.
|
|
127
|
+
const fulfilledUrls = results.filter((it) => it?.repo.url).map((it) => it.url)
|
|
128
128
|
return collectFiles(sourcesByUrl, loadOpts, Object.assign(concurrency, { fetch: 1 }), fulfilledUrls)
|
|
129
129
|
}
|
|
130
130
|
throw rejections[0]
|
|
@@ -181,12 +181,12 @@ async function loadRepository (url, opts, result = {}) {
|
|
|
181
181
|
return git.setConfig(Object.assign({ path: 'remote.origin.private', value: authStatus }, repo))
|
|
182
182
|
})
|
|
183
183
|
.catch((fetchErr) => {
|
|
184
|
-
|
|
184
|
+
fetchOpts.onProgress?.finish(fetchErr)
|
|
185
185
|
if (HTTP_ERROR_CODE_RX.test(fetchErr.code) && fetchErr.data.statusCode === 401) fetchErr.rethrow = true
|
|
186
186
|
throw fetchErr
|
|
187
187
|
})
|
|
188
188
|
.then(() => fsp.writeFile(validStateFile, '').catch(invariably.void))
|
|
189
|
-
.then(() => fetchOpts.onProgress
|
|
189
|
+
.then(() => fetchOpts.onProgress?.finish())
|
|
190
190
|
} else {
|
|
191
191
|
authStatus = await git.getConfig(Object.assign({ path: 'remote.origin.private' }, repo))
|
|
192
192
|
}
|
|
@@ -202,12 +202,12 @@ async function loadRepository (url, opts, result = {}) {
|
|
|
202
202
|
return git.setConfig(Object.assign({ path: 'remote.origin.private', value: authStatus }, repo))
|
|
203
203
|
})
|
|
204
204
|
.catch((cloneErr) => {
|
|
205
|
-
|
|
205
|
+
fetchOpts.onProgress?.finish(cloneErr)
|
|
206
206
|
const authRequested = credentialManager.status({ url }) === 'requested'
|
|
207
207
|
throw transformGitCloneError(cloneErr, displayUrl, authRequested)
|
|
208
208
|
})
|
|
209
209
|
.then(() => fsp.writeFile(validStateFile, '').catch(invariably.void))
|
|
210
|
-
.then(() => fetchOpts.onProgress
|
|
210
|
+
.then(() => fetchOpts.onProgress?.finish())
|
|
211
211
|
}
|
|
212
212
|
} else if (await isDirectory((dir = expandPath(url, { dot: opts.startDir })))) {
|
|
213
213
|
const gitdir = ospath.join(dir, '.git')
|
|
@@ -236,11 +236,9 @@ function extractCredentials (url) {
|
|
|
236
236
|
// NOTE if only username is present, assume it's an oauth token and set password to empty string
|
|
237
237
|
const credentials = username ? { username, password: password || '' } : {}
|
|
238
238
|
return { displayUrl, url, credentials }
|
|
239
|
-
} else if (url.startsWith('git@')) {
|
|
240
|
-
return { displayUrl: url, url: 'https://' + url.substr(4).replace(':', '/') }
|
|
241
|
-
} else {
|
|
242
|
-
return { displayUrl: url, url }
|
|
243
239
|
}
|
|
240
|
+
if (url.startsWith('git@')) return { displayUrl: url, url: 'https://' + url.substr(4).replace(':', '/') }
|
|
241
|
+
return { displayUrl: url, url }
|
|
244
242
|
}
|
|
245
243
|
|
|
246
244
|
async function selectStartPathsForRepository (repo, authStatus, sources) {
|
|
@@ -440,7 +438,7 @@ function collectFilesFromStartPath (startPath, repo, authStatus, ref, originUrl,
|
|
|
440
438
|
return (worktreePath ? readFilesFromWorktree(origin) : readFilesFromGitTree(repo, ref.oid, startPath))
|
|
441
439
|
.then((files) => {
|
|
442
440
|
const batch = deepClone((origin.descriptor = loadComponentDescriptor(files, ref, version)))
|
|
443
|
-
if ('nav' in batch) batch.nav.origin = origin
|
|
441
|
+
if ('nav' in batch && Array.isArray(batch.nav)) batch.nav.origin = origin
|
|
444
442
|
batch.files = files.map((file) => assignFileProperties(file, origin))
|
|
445
443
|
batch.origins = [origin]
|
|
446
444
|
return batch
|
|
@@ -525,9 +523,9 @@ function readFilesFromGitTree (repo, oid, startPath) {
|
|
|
525
523
|
Object.assign(root, { dirname: '' })
|
|
526
524
|
return startPath
|
|
527
525
|
? getGitTreeAtStartPath(repo, oid, startPath).then((start) => {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
526
|
+
Object.assign(start, { dirname: startPath })
|
|
527
|
+
return srcGitTree(repo, root, start)
|
|
528
|
+
})
|
|
531
529
|
: srcGitTree(repo, root)
|
|
532
530
|
})
|
|
533
531
|
}
|
|
@@ -582,7 +580,8 @@ function visitGitTree (emitter, repo, root, filter, convert, parent, dirname = '
|
|
|
582
580
|
(target) => {
|
|
583
581
|
if (target.type === 'tree') {
|
|
584
582
|
return visitGitTree(emitter, repo, root, filter, convert, target, vfilePath, target.following)
|
|
585
|
-
}
|
|
583
|
+
}
|
|
584
|
+
if (target.type === 'blob' && filterVerdict === true && (mode = FILE_MODES[target.mode])) {
|
|
586
585
|
return convert(Object.assign({ mode, oid: target.oid, path: vfilePath }, repo)).then((result) =>
|
|
587
586
|
emitter.emit('entry', result)
|
|
588
587
|
)
|
|
@@ -654,11 +653,11 @@ function readGitObjectAtPath (repo, root, parent, pathSegments, following) {
|
|
|
654
653
|
if (entry.path === firstPathSegment) {
|
|
655
654
|
return entry.type === 'tree'
|
|
656
655
|
? git.readTree(Object.assign({ oid: entry.oid }, repo)).then((subtree) => {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
656
|
+
Object.assign(subtree, { dirname: path.join(parent.dirname, entry.path) })
|
|
657
|
+
return (pathSegments = pathSegments.slice(1)).length
|
|
658
|
+
? readGitObjectAtPath(repo, root, subtree, pathSegments, following)
|
|
659
|
+
: Object.assign(subtree, { type: 'tree', following }) // Q: should this create copy?
|
|
660
|
+
})
|
|
662
661
|
: entry.mode === SYMLINK_FILE_MODE
|
|
663
662
|
? readGitSymlink(repo, root, parent, entry, following)
|
|
664
663
|
: Promise.resolve(entry)
|
|
@@ -870,7 +869,7 @@ function identifyAuthStatus (credentialManager, credentials, url) {
|
|
|
870
869
|
* The purpose of this function is generate a safe, unique folder name for the cloned
|
|
871
870
|
* repository that gets stored in the cache directory.
|
|
872
871
|
*
|
|
873
|
-
* The generated folder name follows the pattern: <basename>-<sha1
|
|
872
|
+
* The generated folder name follows the pattern: <basename>-<sha1-of-normalized-url>.git
|
|
874
873
|
*
|
|
875
874
|
* @param {String} url - The repository URL to convert.
|
|
876
875
|
* @returns {String} The generated folder name.
|
|
@@ -893,9 +892,9 @@ function resolveRemoteUrl (repo, remoteName) {
|
|
|
893
892
|
if (url) {
|
|
894
893
|
if (url.startsWith('https://') || url.startsWith('http://')) {
|
|
895
894
|
return ~url.indexOf('@') ? url.replace(URL_AUTH_CLEANER_RX, '$1') : url
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
|
|
895
|
+
}
|
|
896
|
+
if (url.startsWith('git@')) return 'https://' + url.substr(4).replace(':', '/')
|
|
897
|
+
if (url.startsWith('ssh://')) {
|
|
899
898
|
return 'https://' + url.substr(url.indexOf('@') + 1 || 6).replace(URL_PORT_CLEANER_RX, '$1')
|
|
900
899
|
}
|
|
901
900
|
}
|
|
@@ -928,7 +927,7 @@ function loadGitPlugins (gitConfig, networkConfig, startDir) {
|
|
|
928
927
|
if (typeof credentialManager.configure === 'function') {
|
|
929
928
|
credentialManager.configure({ config: gitConfig.credentials, startDir })
|
|
930
929
|
}
|
|
931
|
-
if (typeof credentialManager.status !== 'function') Object.assign(credentialManager, { status
|
|
930
|
+
if (typeof credentialManager.status !== 'function') Object.assign(credentialManager, { status: invariably.void })
|
|
932
931
|
} else {
|
|
933
932
|
credentialManager = new GitCredentialManagerStore().configure({ config: gitConfig.credentials, startDir })
|
|
934
933
|
}
|
|
@@ -1026,25 +1025,25 @@ function findWorktrees (repo, patterns) {
|
|
|
1026
1025
|
return (
|
|
1027
1026
|
patterns.length
|
|
1028
1027
|
? fsp
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1028
|
+
.readdir((worktreesDir = ospath.join(repo.dir, '.git', 'worktrees')))
|
|
1029
|
+
.then((worktreeNames) => filterRefs(worktreeNames, patterns, patternCache), invariably.emptyArray)
|
|
1030
|
+
.then((worktreeNames) =>
|
|
1031
|
+
worktreeNames.length
|
|
1032
|
+
? Promise.all(
|
|
1033
|
+
worktreeNames.map((worktreeName) => {
|
|
1034
|
+
const gitdir = ospath.resolve(worktreesDir, worktreeName)
|
|
1035
|
+
// NOTE uses name of worktree as branch name if HEAD is detached
|
|
1036
|
+
return git
|
|
1037
|
+
.currentBranch(Object.assign({}, repo, { gitdir }))
|
|
1038
|
+
.then((branch = worktreeName) =>
|
|
1039
|
+
fsp
|
|
1040
|
+
.readFile(ospath.join(gitdir, 'gitdir'), 'utf8')
|
|
1041
|
+
.then((contents) => ({ branch, dir: ospath.dirname(contents.trimEnd()) }))
|
|
1042
|
+
)
|
|
1043
|
+
})
|
|
1044
|
+
).then((entries) => entries.reduce((accum, it) => accum.set(it.branch, it.dir), new Map()))
|
|
1045
|
+
: new Map()
|
|
1046
|
+
)
|
|
1048
1047
|
: Promise.resolve(new Map())
|
|
1049
1048
|
).then((worktrees) =>
|
|
1050
1049
|
linkedOnly
|
package/lib/compute-origin.js
CHANGED
|
@@ -24,7 +24,7 @@ function computeOrigin (url, authStatus, gitdir, ref, startPath, worktreePath =
|
|
|
24
24
|
if (authStatus) origin.private = authStatus
|
|
25
25
|
if (url) origin.webUrl = removeGitSuffix(url)
|
|
26
26
|
if (editUrl === true) {
|
|
27
|
-
const match = url
|
|
27
|
+
const match = url?.match(HOSTED_GIT_REPO_RX)
|
|
28
28
|
if (match) {
|
|
29
29
|
const host = match[1]
|
|
30
30
|
let action = 'blob'
|
package/lib/filter-refs.js
CHANGED
|
@@ -9,10 +9,9 @@ function compileRx (pattern, opts) {
|
|
|
9
9
|
: makeMatcherRx(pattern, opts)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function createMatcher (patterns, cache,
|
|
12
|
+
function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new Map() })) {
|
|
13
13
|
const rxs = patterns.map(
|
|
14
|
-
(pattern) =>
|
|
15
|
-
cache.get(pattern) || cache.set(pattern, compileRx(pattern, opts || (opts = getMatcherOpts(cache)))).get(pattern)
|
|
14
|
+
(pattern) => cache.get(pattern) || cache.set(pattern, compileRx(pattern, getMatcherOpts(cache))).get(pattern)
|
|
16
15
|
)
|
|
17
16
|
if (rxs[0].negated) rxs.unshift(MATCH_ALL_RX)
|
|
18
17
|
return (candidate) => {
|
|
@@ -31,7 +30,7 @@ function createMatcher (patterns, cache, opts) {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function filterRefs (candidates, patterns, cache
|
|
33
|
+
function filterRefs (candidates, patterns, cache) {
|
|
35
34
|
const isMatch = createMatcher(patterns, cache)
|
|
36
35
|
return candidates.reduce((accum, candidate) => {
|
|
37
36
|
if (isMatch(candidate)) accum.push(candidate)
|
|
@@ -16,11 +16,11 @@ function resolvePathGlobs (base, patterns, listDirents, retrievePath, tree = { p
|
|
|
16
16
|
if (resolvedPaths.length) {
|
|
17
17
|
const rx = makeMatcherRx(pattern.substr(1), MATCHER_OPTS)
|
|
18
18
|
return resolvedPaths.filter((it) => !rx.test(it))
|
|
19
|
-
} else {
|
|
20
|
-
return resolvedPaths
|
|
21
19
|
}
|
|
20
|
+
return resolvedPaths
|
|
22
21
|
})
|
|
23
|
-
}
|
|
22
|
+
}
|
|
23
|
+
if (RX_MAGIC_DETECTOR.test(pattern)) {
|
|
24
24
|
return glob(base, pattern.split('/'), listDirents, retrievePath, tree).then((nestedPaths) =>
|
|
25
25
|
paths.then((resolvedPaths) => [...resolvedPaths, ...nestedPaths])
|
|
26
26
|
)
|
|
@@ -62,35 +62,36 @@ async function glob (base, patternSegments, listDirents, retrievePath, { oid, pa
|
|
|
62
62
|
dirent.isDirectory() && isMatch(dirent.name)
|
|
63
63
|
? patternSegments.length
|
|
64
64
|
? glob(base, patternSegments, listDirents, retrievePath, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
oid: dirent.oid,
|
|
66
|
+
path: joinPath(path, dirent.name),
|
|
67
|
+
globbed: true,
|
|
68
|
+
})
|
|
69
69
|
: joinPath(path, dirent.name)
|
|
70
70
|
: []
|
|
71
71
|
)
|
|
72
72
|
)
|
|
73
73
|
)
|
|
74
74
|
return explicit ? [...[...explicit].map((it) => joinPath(path, it)), ...discovered] : discovered
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return [joinPath(path, patternSegment)]
|
|
89
|
-
} else if (globbed) {
|
|
90
|
-
return (await retrievePath(base, { oid, path }, patternSegment)) ? [joinPath(path, patternSegment)] : []
|
|
75
|
+
}
|
|
76
|
+
const [magicBase, nextSegment] = extractMagicBase(patternSegments, patternSegment)
|
|
77
|
+
patternSegment = magicBase
|
|
78
|
+
if (nextSegment) {
|
|
79
|
+
const obj = await retrievePath(base, { oid, path }, patternSegment)
|
|
80
|
+
if (obj) {
|
|
81
|
+
return glob(base, patternSegments, listDirents, retrievePath, {
|
|
82
|
+
oid: obj.oid,
|
|
83
|
+
path: joinPath(path, patternSegment),
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
if ((patternSegment += '/' + patternSegments.join('/')).indexOf('{')) {
|
|
87
|
+
return expandBraces(patternSegment).map((it) => joinPath(path, it))
|
|
91
88
|
}
|
|
92
89
|
return [joinPath(path, patternSegment)]
|
|
93
90
|
}
|
|
91
|
+
if (globbed) {
|
|
92
|
+
return (await retrievePath(base, { oid, path }, patternSegment)) ? [joinPath(path, patternSegment)] : []
|
|
93
|
+
}
|
|
94
|
+
return [joinPath(path, patternSegment)]
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
function extractMagicBase (patternSegments, base) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-aggregator",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.10",
|
|
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)",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"Balachandran Sivakumar <balachandran@balachandran.org>"
|
|
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
|
+
},
|
|
15
18
|
"bugs": {
|
|
16
19
|
"url": "https://gitlab.com/antora/antora/issues"
|
|
17
20
|
},
|
|
@@ -28,9 +31,9 @@
|
|
|
28
31
|
"#constants": "./lib/constants.js"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@antora/expand-path-helper": "~
|
|
32
|
-
"@antora/logger": "3.1.
|
|
33
|
-
"@antora/user-require-helper": "~
|
|
34
|
+
"@antora/expand-path-helper": "~3.0",
|
|
35
|
+
"@antora/logger": "3.1.10",
|
|
36
|
+
"@antora/user-require-helper": "~3.0",
|
|
34
37
|
"braces": "~3.0",
|
|
35
38
|
"cache-directory": "~2.0",
|
|
36
39
|
"fast-glob": "~3.3",
|