@antora/content-aggregator 3.1.10 → 3.1.12
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 +34 -22
- package/package.json +2 -2
package/lib/aggregate-content.js
CHANGED
|
@@ -246,14 +246,27 @@ async function selectStartPathsForRepository (repo, authStatus, sources) {
|
|
|
246
246
|
const originUrls = {}
|
|
247
247
|
for (const source of sources) {
|
|
248
248
|
const { version, editUrl } = source
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
let remoteName, originUrl
|
|
250
|
+
if (repo.url) {
|
|
251
|
+
remoteName = 'origin' // NOTE if repository is managed (has url property), we can assume remote name is origin
|
|
252
|
+
originUrl = repo.url
|
|
253
|
+
} else {
|
|
254
|
+
remoteName = source.remote || 'origin'
|
|
255
|
+
originUrl =
|
|
256
|
+
remoteName in originUrls
|
|
257
|
+
? originUrls[remoteName]
|
|
258
|
+
: (originUrls[remoteName] = await resolveRemoteUrl(repo, remoteName))
|
|
259
|
+
if (!originUrl) {
|
|
260
|
+
remoteName = undefined
|
|
261
|
+
if ((originUrl = posixify ? 'file:///' + posixify(repo.dir) : 'file://' + repo.dir).indexOf(' ')) {
|
|
262
|
+
originUrl = originUrl.replace(SPACE_RX, '%20')
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
253
266
|
const refs = await selectReferences(source, repo, remoteName)
|
|
254
267
|
if (refs.length) {
|
|
255
268
|
for (const ref of refs) {
|
|
256
|
-
for (const startPath of await selectStartPaths(source, repo,
|
|
269
|
+
for (const startPath of await selectStartPaths(source, repo, ref)) {
|
|
257
270
|
startPaths.push({ startPath, ref, originUrl, editUrl, version })
|
|
258
271
|
}
|
|
259
272
|
}
|
|
@@ -352,7 +365,9 @@ async function selectReferences (source, repo, remote) {
|
|
|
352
365
|
return [...refs.values()]
|
|
353
366
|
}
|
|
354
367
|
// NOTE isomorphic-git includes HEAD in list of remote branches (see https://isomorphic-git.org/docs/listBranches)
|
|
355
|
-
const remoteBranches =
|
|
368
|
+
const remoteBranches = remote
|
|
369
|
+
? (await git.listBranches(Object.assign({ remote }, repo))).filter((it) => it !== 'HEAD')
|
|
370
|
+
: []
|
|
356
371
|
if (remoteBranches.length) {
|
|
357
372
|
for (const shortname of filterRefs(remoteBranches, branchPatterns, patternCache)) {
|
|
358
373
|
const fullname = 'remotes/' + remote + '/' + shortname
|
|
@@ -396,7 +411,7 @@ function getCurrentBranchName (repo, remote) {
|
|
|
396
411
|
return refPromise.then((ref) => (ref.startsWith('refs/') ? ref.replace(SHORTEN_REF_RX, '') : undefined))
|
|
397
412
|
}
|
|
398
413
|
|
|
399
|
-
async function selectStartPaths (source, repo,
|
|
414
|
+
async function selectStartPaths (source, repo, ref) {
|
|
400
415
|
const url = repo.url
|
|
401
416
|
const displayUrl = url || repo.dir
|
|
402
417
|
const worktreePath = ref.head
|
|
@@ -711,18 +726,18 @@ function loadComponentDescriptor (files, ref, version) {
|
|
|
711
726
|
if (!version) {
|
|
712
727
|
if (version === undefined) throw new Error(`${COMPONENT_DESC_FILENAME} is missing a version`)
|
|
713
728
|
if (version === false) throw new Error(`${COMPONENT_DESC_FILENAME} has an invalid version`)
|
|
714
|
-
version =
|
|
729
|
+
version = typeof version === 'number' ? '' + version : ''
|
|
715
730
|
} else if (version === true) {
|
|
716
731
|
version = ref.shortname.replace(PATH_SEPARATOR_RX, '-')
|
|
717
732
|
} else if (version.constructor === Object) {
|
|
718
733
|
const refname = ref.shortname
|
|
719
734
|
let matched
|
|
720
735
|
if (refname in version) {
|
|
721
|
-
matched = version[refname]
|
|
736
|
+
matched = '' + (version[refname] ?? '')
|
|
722
737
|
} else if (
|
|
723
738
|
!Object.entries(version).some(([pattern, replacement]) => {
|
|
724
|
-
const result = refname.replace(makeMatcherRx(pattern, VERSION_MATCHER_OPTS), '\0' + replacement)
|
|
725
|
-
if (result === refname) return false
|
|
739
|
+
const result = refname.replace(makeMatcherRx(pattern, VERSION_MATCHER_OPTS), '\0' + (replacement ?? ''))
|
|
740
|
+
if (result === refname) return false // no match
|
|
726
741
|
matched = result.substr(1)
|
|
727
742
|
return true
|
|
728
743
|
})
|
|
@@ -885,21 +900,18 @@ function generateCloneFolderName (url) {
|
|
|
885
900
|
*
|
|
886
901
|
* @param {Repository} repo - The repository on which to operate.
|
|
887
902
|
* @param {String} remoteName - The name of the remote to resolve.
|
|
888
|
-
* @returns {String} The URL of the specified remote, if defined
|
|
903
|
+
* @returns {String} The URL of the specified remote, if defined
|
|
889
904
|
*/
|
|
890
905
|
function resolveRemoteUrl (repo, remoteName) {
|
|
891
906
|
return git.getConfig(Object.assign({ path: 'remote.' + remoteName + '.url' }, repo)).then((url) => {
|
|
892
|
-
if (url)
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
907
|
+
if (!url) return
|
|
908
|
+
if (url.startsWith('https://') || url.startsWith('http://')) {
|
|
909
|
+
return ~url.indexOf('@') ? url.replace(URL_AUTH_CLEANER_RX, '$1') : url
|
|
910
|
+
}
|
|
911
|
+
if (url.startsWith('git@')) return 'https://' + url.substr(4).replace(':', '/')
|
|
912
|
+
if (url.startsWith('ssh://')) {
|
|
913
|
+
return 'https://' + url.substr(url.indexOf('@') + 1 || 6).replace(URL_PORT_CLEANER_RX, '$1')
|
|
900
914
|
}
|
|
901
|
-
url = posixify ? 'file:///' + posixify(repo.dir) : 'file://' + repo.dir
|
|
902
|
-
return ~url.indexOf(' ') ? url.replace(SPACE_RX, '%20') : url
|
|
903
915
|
})
|
|
904
916
|
}
|
|
905
917
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-aggregator",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.12",
|
|
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)",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@antora/expand-path-helper": "~3.0",
|
|
35
|
-
"@antora/logger": "3.1.
|
|
35
|
+
"@antora/logger": "3.1.12",
|
|
36
36
|
"@antora/user-require-helper": "~3.0",
|
|
37
37
|
"braces": "~3.0",
|
|
38
38
|
"cache-directory": "~2.0",
|