@antora/content-aggregator 3.2.0-alpha.3 → 3.2.0-alpha.5
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 +88 -88
- package/lib/compute-origin.js +1 -1
- package/lib/constants.js +2 -2
- package/lib/decode-uint8-array.js +1 -1
- package/lib/git-credential-manager-store.js +3 -3
- package/lib/git-plugin-http.js +5 -4
- package/lib/git.js +8 -1
- package/lib/matcher.js +1 -6
- package/lib/posixify.js +1 -1
- package/lib/resolve-path-globs.js +1 -1
- package/package.json +7 -7
package/lib/aggregate-content.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const computeOrigin = require('./compute-origin')
|
|
4
|
-
const { createHash } = require('crypto')
|
|
4
|
+
const { createHash } = require('node:crypto')
|
|
5
5
|
const createGitHttpPlugin = require('./git-plugin-http')
|
|
6
6
|
const decodeUint8Array = require('./decode-uint8-array')
|
|
7
7
|
const deepClone = require('./deep-clone')
|
|
8
|
-
const EventEmitter = require('events')
|
|
8
|
+
const EventEmitter = require('node:events')
|
|
9
9
|
const expandPath = require('@antora/expand-path-helper')
|
|
10
10
|
const File = require('./file')
|
|
11
11
|
const filterRefs = require('./filter-refs')
|
|
12
|
-
const fs = require('fs')
|
|
12
|
+
const fs = require('node:fs')
|
|
13
13
|
const { promises: fsp } = fs
|
|
14
14
|
const getCacheDir = require('cache-directory')
|
|
15
15
|
const GitCredentialManagerStore = require('./git-credential-manager-store')
|
|
16
16
|
const git = require('./git')
|
|
17
17
|
const { NotFoundError, ObjectTypeError, UnknownTransportError, UrlParseError } = git.Errors
|
|
18
|
-
const globStream = require('glob
|
|
18
|
+
const { globStream } = require('fast-glob')
|
|
19
|
+
const { inspect } = require('node:util')
|
|
19
20
|
const invariably = require('./invariably')
|
|
20
21
|
const logger = require('./logger')
|
|
21
22
|
const { makeMatcherRx, versionMatcherOpts: VERSION_MATCHER_OPTS } = require('./matcher')
|
|
22
23
|
const MultiProgress = require('multi-progress') // calls require('progress') as a peer dependencies
|
|
23
|
-
const ospath = require('path')
|
|
24
|
+
const ospath = require('node:path')
|
|
24
25
|
const { posix: path } = ospath
|
|
25
26
|
const posixify = require('./posixify')
|
|
26
27
|
const removeGitSuffix = require('./remove-git-suffix')
|
|
27
28
|
const { fs: resolvePathGlobsFs, git: resolvePathGlobsGit } = require('./resolve-path-globs')
|
|
28
|
-
const { pipeline, Writable } = require('stream')
|
|
29
|
+
const { pipeline, Writable } = require('node:stream')
|
|
29
30
|
const forEach = (write) => new Writable({ objectMode: true, write })
|
|
30
31
|
const userRequire = require('@antora/user-require-helper')
|
|
31
32
|
const yaml = require('js-yaml')
|
|
@@ -101,7 +102,8 @@ function aggregateContent (playbook) {
|
|
|
101
102
|
}, new Map())
|
|
102
103
|
const progress = !quiet && createProgress(sourcesByUrl.keys(), process.stdout)
|
|
103
104
|
const refPatternCache = Object.assign(new Map(), { braces: new Map() })
|
|
104
|
-
const
|
|
105
|
+
const fetchConfig = { always: fetch, depth: Math.max(0, gitConfig.fetchDepth ?? 1) }
|
|
106
|
+
const loadOpts = { cacheDir, fetch: fetchConfig, gitPlugins, progress, startDir, refPatternCache }
|
|
105
107
|
return collectFiles(sourcesByUrl, loadOpts, concurrency).then(buildAggregate, (err) => {
|
|
106
108
|
progress && progress.terminate()
|
|
107
109
|
throw err
|
|
@@ -109,20 +111,20 @@ function aggregateContent (playbook) {
|
|
|
109
111
|
})
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
async function collectFiles (sourcesByUrl, loadOpts, concurrency, fetchedUrls) {
|
|
114
|
+
async function collectFiles (sourcesByUrl, loadOpts, concurrency, fetchedUrls = []) {
|
|
113
115
|
const loadTasks = [...sourcesByUrl.entries()].map(([url, sources]) => {
|
|
114
116
|
const loadOptsForUrl = Object.assign({}, loadOpts)
|
|
115
|
-
if (loadOpts.fetch && fetchedUrls
|
|
116
|
-
if (tagsSpecified(sources)) loadOptsForUrl.
|
|
117
|
+
if (loadOpts.fetch.always && fetchedUrls.length && fetchedUrls.includes(url)) loadOptsForUrl.fetch.always = false
|
|
118
|
+
if (tagsSpecified(sources)) loadOptsForUrl.fetch.tags = true
|
|
117
119
|
return loadRepository.bind(null, url, loadOptsForUrl, { url, sources })
|
|
118
120
|
})
|
|
119
121
|
return gracefulPromiseAllWithLimit(loadTasks, concurrency.fetch).then(([results, rejections]) => {
|
|
120
122
|
if (rejections.length) {
|
|
121
|
-
if (concurrency.fetch > 1 && rejections.every(({ recoverable }) => recoverable)) {
|
|
123
|
+
if (concurrency.fetch > 1 && results.length > 1 && rejections.every(({ recoverable }) => recoverable)) {
|
|
122
124
|
if (loadOpts.progress) loadOpts.progress.terminate() // reset cursor position and allow it be reused
|
|
123
|
-
const msg0 = 'An unexpected error occurred while
|
|
125
|
+
const msg0 = 'An unexpected error occurred while fetching content sources concurrently.'
|
|
124
126
|
const msg1 = 'Retrying with git.fetch_concurrency value of 1.'
|
|
125
|
-
logger.warn(msg0 + ' ' + msg1)
|
|
127
|
+
logger.warn(rejections[0], msg0 + ' ' + msg1)
|
|
126
128
|
const fulfilledUrls = results.map((it) => it && it.repo.url && it.url).filter((it) => it)
|
|
127
129
|
return collectFiles(sourcesByUrl, loadOpts, Object.assign(concurrency, { fetch: 1 }), fulfilledUrls)
|
|
128
130
|
}
|
|
@@ -162,7 +164,7 @@ async function loadRepository (url, opts, result = {}) {
|
|
|
162
164
|
if (~url.indexOf(':') && GIT_URI_DETECTOR_RX.test(url)) {
|
|
163
165
|
let credentials, displayUrl
|
|
164
166
|
;({ displayUrl, url, credentials } = extractCredentials(url))
|
|
165
|
-
const { cacheDir, fetch,
|
|
167
|
+
const { cacheDir, fetch, gitPlugins, progress } = opts
|
|
166
168
|
dir = ospath.join(cacheDir, generateCloneFolderName(displayUrl))
|
|
167
169
|
// NOTE the presence of the url property on the repo object implies the repository is remote
|
|
168
170
|
repo = { cache, dir, fs, gitdir: dir, noCheckout: true, url }
|
|
@@ -170,9 +172,9 @@ async function loadRepository (url, opts, result = {}) {
|
|
|
170
172
|
const validStateFile = ospath.join(dir, VALID_STATE_FILENAME)
|
|
171
173
|
try {
|
|
172
174
|
await fsp.access(validStateFile)
|
|
173
|
-
if (fetch) {
|
|
175
|
+
if (fetch.always) {
|
|
174
176
|
await fsp.unlink(validStateFile)
|
|
175
|
-
const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins,
|
|
177
|
+
const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetch, 'fetch')
|
|
176
178
|
await git
|
|
177
179
|
.fetch(fetchOpts)
|
|
178
180
|
.then(() => {
|
|
@@ -192,7 +194,7 @@ async function loadRepository (url, opts, result = {}) {
|
|
|
192
194
|
} catch (gitErr) {
|
|
193
195
|
await fsp['rm' in fsp ? 'rm' : 'rmdir'](dir, { recursive: true, force: true })
|
|
194
196
|
if (gitErr.rethrow) throw transformGitCloneError(gitErr, displayUrl)
|
|
195
|
-
const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins,
|
|
197
|
+
const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetch, 'clone')
|
|
196
198
|
await git
|
|
197
199
|
.clone(fetchOpts)
|
|
198
200
|
.then(() => git.resolveRef(Object.assign({ ref: 'HEAD', depth: 1 }, repo)))
|
|
@@ -324,9 +326,9 @@ async function selectReferences (source, repo, remote) {
|
|
|
324
326
|
} else {
|
|
325
327
|
worktreePatterns = worktreePatterns === undefined ? [worktreeName || '.'] : []
|
|
326
328
|
}
|
|
329
|
+
let currentBranch
|
|
327
330
|
if (branchPatterns.length === 1 && (branchPatterns[0] === 'HEAD' || branchPatterns[0] === '.')) {
|
|
328
|
-
|
|
329
|
-
if (currentBranch) {
|
|
331
|
+
if ((currentBranch = await getCurrentBranchName(repo, remote).then((branch) => branch ?? false))) {
|
|
330
332
|
branchPatterns = [currentBranch]
|
|
331
333
|
} else if (isBare) {
|
|
332
334
|
return [...refs.values()]
|
|
@@ -340,9 +342,7 @@ async function selectReferences (source, repo, remote) {
|
|
|
340
342
|
let headBranchIdx
|
|
341
343
|
// NOTE we can assume at least two entries if HEAD or . are present
|
|
342
344
|
if (~(headBranchIdx = branchPatterns.indexOf('HEAD')) || ~(headBranchIdx = branchPatterns.indexOf('.'))) {
|
|
343
|
-
|
|
344
|
-
if (currentBranch) {
|
|
345
|
-
// NOTE ignore if current branch is already in list
|
|
345
|
+
if ((currentBranch = await getCurrentBranchName(repo, remote).then((branch) => branch ?? false))) {
|
|
346
346
|
if (~branchPatterns.indexOf(currentBranch)) {
|
|
347
347
|
branchPatterns.splice(headBranchIdx, 1)
|
|
348
348
|
} else {
|
|
@@ -372,7 +372,11 @@ async function selectReferences (source, repo, remote) {
|
|
|
372
372
|
}
|
|
373
373
|
// NOTE only consider local branches if repo has a worktree or there are no remote tracking branches
|
|
374
374
|
if (!isBare) {
|
|
375
|
-
const localBranches = await git.listBranches(repo)
|
|
375
|
+
const localBranches = await git.listBranches(repo).then((branches) => {
|
|
376
|
+
if (branches.length) return branches
|
|
377
|
+
if (currentBranch == null) return getCurrentBranchName(repo).then((branch) => (branch ? [branch] : []))
|
|
378
|
+
return currentBranch ? [currentBranch] : []
|
|
379
|
+
})
|
|
376
380
|
if (localBranches.length) {
|
|
377
381
|
const worktrees = await findWorktrees(repo, worktreePatterns)
|
|
378
382
|
let onMatch
|
|
@@ -405,11 +409,11 @@ async function selectReferences (source, repo, remote) {
|
|
|
405
409
|
}
|
|
406
410
|
|
|
407
411
|
/**
|
|
408
|
-
* Returns the current branch name
|
|
412
|
+
* Returns the current branch name or undefined if the HEAD is detached.
|
|
409
413
|
*/
|
|
410
414
|
function getCurrentBranchName (repo, remote) {
|
|
411
415
|
return (
|
|
412
|
-
repo.noCheckout
|
|
416
|
+
remote && repo.noCheckout
|
|
413
417
|
? git
|
|
414
418
|
.resolveRef(Object.assign({ ref: 'refs/remotes/' + remote + '/HEAD', depth: 2 }, repo))
|
|
415
419
|
.catch(() => git.resolveRef(Object.assign({ ref: 'HEAD', depth: 2 }, repo)))
|
|
@@ -457,12 +461,13 @@ function collectFilesFromStartPath (startPath, repo, authStatus, ref, originUrl,
|
|
|
457
461
|
const worktreePath = ref.head
|
|
458
462
|
const origin = computeOrigin(originUrl, authStatus, repo.gitdir, ref, startPath, worktreePath, editUrl)
|
|
459
463
|
return (worktreePath ? readFilesFromWorktree(origin) : readFilesFromGitTree(repo, ref.oid, startPath))
|
|
460
|
-
.then((files) =>
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
.then((files) => {
|
|
465
|
+
const batch = deepClone((origin.descriptor = loadComponentDescriptor(files, ref, version)))
|
|
466
|
+
if ('nav' in batch) batch.nav.origin = origin
|
|
467
|
+
batch.files = files.map((file) => assignFileProperties(file, origin))
|
|
468
|
+
batch.origins = [origin]
|
|
469
|
+
return batch
|
|
470
|
+
})
|
|
466
471
|
.catch((err) => {
|
|
467
472
|
const where = worktreePath || (worktreePath === false ? repo.gitdir : repo.url || repo.dir)
|
|
468
473
|
const flag = worktreePath ? ' <worktree>' : ref.remote && worktreePath === false ? ` <remotes/${ref.remote}>` : ''
|
|
@@ -487,19 +492,18 @@ function readFilesFromWorktree (origin) {
|
|
|
487
492
|
}
|
|
488
493
|
|
|
489
494
|
function srcFs (cwd, origin) {
|
|
490
|
-
return new Promise((resolve, reject,
|
|
495
|
+
return new Promise((resolve, reject, files = []) =>
|
|
491
496
|
pipeline(
|
|
492
|
-
globStream(CONTENT_SRC_GLOB, Object.assign({
|
|
493
|
-
forEach(({ path:
|
|
494
|
-
if ((
|
|
495
|
-
const
|
|
496
|
-
const relpath =
|
|
497
|
-
|
|
498
|
-
(stat) =>
|
|
499
|
-
if (stat.isDirectory()) return done() // detects directories that slipped through cache check
|
|
497
|
+
globStream(CONTENT_SRC_GLOB, Object.assign({ cwd }, CONTENT_SRC_OPTS)),
|
|
498
|
+
forEach(({ path: relpath, dirent }, _, done) => {
|
|
499
|
+
if (dirent.isDirectory()) return done()
|
|
500
|
+
const relpathPosix = relpath
|
|
501
|
+
const abspath = posixify ? ospath.join(cwd, (relpath = ospath.normalize(relpath))) : cwd + '/' + relpath
|
|
502
|
+
fsp.stat(abspath).then(
|
|
503
|
+
(stat) =>
|
|
500
504
|
fsp.readFile(abspath).then(
|
|
501
505
|
(contents) => {
|
|
502
|
-
files.push(new File({ path:
|
|
506
|
+
files.push(new File({ path: relpathPosix, contents, stat, src: { abspath } }))
|
|
503
507
|
done()
|
|
504
508
|
},
|
|
505
509
|
(readErr) => {
|
|
@@ -509,22 +513,28 @@ function srcFs (cwd, origin) {
|
|
|
509
513
|
: logger.error(logObject, readErr.message.replace(`'${abspath}'`, relpath))
|
|
510
514
|
done()
|
|
511
515
|
}
|
|
512
|
-
)
|
|
513
|
-
},
|
|
516
|
+
),
|
|
514
517
|
(statErr) => {
|
|
515
518
|
const logObject = { file: { abspath, origin } }
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
519
|
+
if (dirent.isSymbolicLink()) {
|
|
520
|
+
fsp
|
|
521
|
+
.readlink(abspath)
|
|
522
|
+
.then(
|
|
523
|
+
(symlink) =>
|
|
524
|
+
(statErr.code === 'ELOOP' ? 'ELOOP: symbolic link cycle, ' : 'ENOENT: broken symbolic link, ') +
|
|
525
|
+
`${relpath} -> ${symlink}`,
|
|
526
|
+
() => statErr.message.replace(`'${abspath}'`, relpath)
|
|
527
|
+
)
|
|
528
|
+
.then((message) => {
|
|
529
|
+
logger.error(logObject, message)
|
|
530
|
+
done()
|
|
531
|
+
})
|
|
524
532
|
} else {
|
|
525
|
-
|
|
533
|
+
statErr.code === 'ENOENT'
|
|
534
|
+
? logger.warn(logObject, `ENOENT: file or directory disappeared, ${statErr.syscall} ${relpath}`)
|
|
535
|
+
: logger.error(logObject, statErr.message.replace(`'${abspath}'`, relpath))
|
|
536
|
+
done()
|
|
526
537
|
}
|
|
527
|
-
done()
|
|
528
538
|
}
|
|
529
539
|
)
|
|
530
540
|
}),
|
|
@@ -694,8 +704,13 @@ function filterGitEntry (entry) {
|
|
|
694
704
|
|
|
695
705
|
function gitEntryToFile (entry) {
|
|
696
706
|
return git.readBlob(entry).then(({ blob: contents }) => {
|
|
697
|
-
|
|
698
|
-
|
|
707
|
+
const stat = {
|
|
708
|
+
mode: entry.mode,
|
|
709
|
+
size: (contents = Buffer.from(contents.buffer)).byteLength,
|
|
710
|
+
isDirectory: invariably.false,
|
|
711
|
+
isFile: invariably.true,
|
|
712
|
+
isSymbolicLink: invariably.false,
|
|
713
|
+
}
|
|
699
714
|
return new File({ path: entry.path, contents, stat })
|
|
700
715
|
})
|
|
701
716
|
}
|
|
@@ -707,7 +722,7 @@ function loadComponentDescriptor (files, ref, version) {
|
|
|
707
722
|
files.splice(descriptorFileIdx, 1)
|
|
708
723
|
let data
|
|
709
724
|
try {
|
|
710
|
-
data = yaml.load(descriptorFile.contents.toString(), { schema: yaml.CORE_SCHEMA })
|
|
725
|
+
data = Object(yaml.load(descriptorFile.contents.toString(), { schema: yaml.CORE_SCHEMA }))
|
|
711
726
|
} catch (err) {
|
|
712
727
|
throw Object.assign(err, { message: `${COMPONENT_DESC_FILENAME} has invalid syntax; ${err.message}` })
|
|
713
728
|
}
|
|
@@ -763,18 +778,20 @@ function assignFileProperties (file, origin) {
|
|
|
763
778
|
return file
|
|
764
779
|
}
|
|
765
780
|
|
|
766
|
-
function buildFetchOptions (repo, progress, displayUrl, credentialsFromUrl, gitPlugins,
|
|
781
|
+
function buildFetchOptions (repo, progress, displayUrl, credentialsFromUrl, gitPlugins, fetch, operation) {
|
|
767
782
|
const { credentialManager, http, urlRouter } = gitPlugins
|
|
783
|
+
const corsProxy = false
|
|
784
|
+
const depth = fetch.depth || undefined
|
|
768
785
|
const onAuth = resolveCredentials.bind(credentialManager, new Map().set(undefined, credentialsFromUrl))
|
|
769
786
|
const onAuthFailure = onAuth
|
|
770
787
|
const onAuthSuccess = (url) => credentialManager.approved({ url })
|
|
771
|
-
const opts = Object.assign({ corsProxy
|
|
788
|
+
const opts = Object.assign({ corsProxy, depth, http, onAuth, onAuthFailure, onAuthSuccess }, repo)
|
|
772
789
|
if (urlRouter) opts.url = urlRouter.ensureGitSuffix(opts.url)
|
|
773
790
|
if (progress) opts.onProgress = createProgressListener(progress, displayUrl, operation)
|
|
774
791
|
if (operation === 'fetch') {
|
|
775
792
|
opts.prune = true
|
|
776
|
-
if (
|
|
777
|
-
} else if (!
|
|
793
|
+
if (fetch.tags) opts.tags = opts.pruneTags = true
|
|
794
|
+
} else if (!fetch.tags) {
|
|
778
795
|
opts.noTags = true
|
|
779
796
|
}
|
|
780
797
|
return opts
|
|
@@ -927,20 +944,6 @@ function isDirectory (url) {
|
|
|
927
944
|
return fsp.stat(url).then((stat) => stat.isDirectory(), invariably.false)
|
|
928
945
|
}
|
|
929
946
|
|
|
930
|
-
function symlinkAwareStat (path_) {
|
|
931
|
-
return fsp.lstat(path_).then((lstat) => {
|
|
932
|
-
if (!lstat.isSymbolicLink()) return lstat
|
|
933
|
-
return fsp.stat(path_).catch((statErr) =>
|
|
934
|
-
fsp
|
|
935
|
-
.readlink(path_)
|
|
936
|
-
.catch(invariably.void)
|
|
937
|
-
.then((symlink) => {
|
|
938
|
-
throw Object.assign(statErr, { symlink })
|
|
939
|
-
})
|
|
940
|
-
)
|
|
941
|
-
})
|
|
942
|
-
}
|
|
943
|
-
|
|
944
947
|
function tagsSpecified (sources) {
|
|
945
948
|
return sources.some(({ tags }) => tags && (Array.isArray(tags) ? tags.length : true))
|
|
946
949
|
}
|
|
@@ -1011,15 +1014,14 @@ function transformGitCloneError (err, displayUrl, authRequested) {
|
|
|
1011
1014
|
} else if (err.code === 'ENOTFOUND') {
|
|
1012
1015
|
wrappedMsg = `Content repository host could not be resolved: ${err.hostname}`
|
|
1013
1016
|
} else {
|
|
1014
|
-
wrappedMsg =
|
|
1017
|
+
wrappedMsg = err.message || String(err)
|
|
1015
1018
|
recoverable = trimMessage = true
|
|
1016
1019
|
}
|
|
1017
|
-
if (trimMessage)
|
|
1018
|
-
wrappedMsg = ~(wrappedMsg = wrappedMsg.trimEnd()).indexOf('. ') ? wrappedMsg : wrappedMsg.replace(/\.$/, '')
|
|
1019
|
-
}
|
|
1020
|
+
if (trimMessage && !~(wrappedMsg = wrappedMsg.trimEnd()).indexOf('. ')) wrappedMsg = wrappedMsg.replace(/\.$/, '')
|
|
1020
1021
|
const errWrapper = new Error(`${wrappedMsg} (url: ${displayUrl})`)
|
|
1021
|
-
errWrapper.stack += `\nCaused by: ${err.stack
|
|
1022
|
-
|
|
1022
|
+
errWrapper.stack += `\nCaused by: ${err.stack ? inspect(err).replace(/^Error \[(.+?)\](?=: )/, '$1') : err}`
|
|
1023
|
+
if (recoverable) Object.defineProperty(errWrapper, 'recoverable', { value: true })
|
|
1024
|
+
return errWrapper
|
|
1023
1025
|
}
|
|
1024
1026
|
|
|
1025
1027
|
function splitRefPatterns (str) {
|
|
@@ -1066,7 +1068,7 @@ function findWorktrees (repo, patterns) {
|
|
|
1066
1068
|
if (!patterns.length) return new Map()
|
|
1067
1069
|
const mainWorktree =
|
|
1068
1070
|
patterns[0] === '.' && (patterns = patterns.slice(1))
|
|
1069
|
-
? getCurrentBranchName(repo).then((branch) =>
|
|
1071
|
+
? getCurrentBranchName(repo).then((branch) => branch && [branch, { head: repo.dir, name: '.' }])
|
|
1070
1072
|
: Promise.resolve()
|
|
1071
1073
|
const worktreesDir = patterns.length ? ospath.join(repo.dir, '.git', 'worktrees') : undefined
|
|
1072
1074
|
const patternCache = repo.cache[REF_PATTERN_CACHE_KEY]
|
|
@@ -1080,13 +1082,11 @@ function findWorktrees (repo, patterns) {
|
|
|
1080
1082
|
worktreeNames.map((worktreeName) => {
|
|
1081
1083
|
const gitdir = ospath.resolve(worktreesDir, worktreeName)
|
|
1082
1084
|
// NOTE branch name defaults to worktree name if HEAD is detached
|
|
1083
|
-
return
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
.then((contents) => [branch, { head: ospath.dirname(contents.trimEnd()), name: worktreeName }])
|
|
1089
|
-
)
|
|
1085
|
+
return getCurrentBranchName(Object.assign({}, repo, { gitdir })).then((branch = worktreeName) =>
|
|
1086
|
+
fsp
|
|
1087
|
+
.readFile(ospath.join(gitdir, 'gitdir'), 'utf8')
|
|
1088
|
+
.then((contents) => [branch, { head: ospath.dirname(contents.trimEnd()), name: worktreeName }])
|
|
1089
|
+
)
|
|
1090
1090
|
})
|
|
1091
1091
|
)
|
|
1092
1092
|
)
|
package/lib/compute-origin.js
CHANGED
package/lib/constants.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module.exports = Object.freeze({
|
|
4
4
|
COMPONENT_DESC_FILENAME: 'antora.yml',
|
|
5
5
|
CONTENT_CACHE_FOLDER: 'content',
|
|
6
|
-
CONTENT_SRC_GLOB: '
|
|
7
|
-
CONTENT_SRC_OPTS: {
|
|
6
|
+
CONTENT_SRC_GLOB: '**/!(*~)',
|
|
7
|
+
CONTENT_SRC_OPTS: { dot: true, ignore: ['**/.*{,/**}'], objectMode: true, onlyFiles: false, unique: false },
|
|
8
8
|
FILE_MODES: { 100644: 0o100666 & ~process.umask(), 100755: 0o100777 & ~process.umask() },
|
|
9
9
|
GIT_CORE: 'antora',
|
|
10
10
|
GIT_OPERATION_LABEL_LENGTH: 8,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { homedir } = require('os')
|
|
3
|
+
const { homedir } = require('node:os')
|
|
4
4
|
const expandPath = require('@antora/expand-path-helper')
|
|
5
|
-
const { promises: fsp } = require('fs')
|
|
5
|
+
const { promises: fsp } = require('node:fs')
|
|
6
6
|
const invariably = require('./invariably')
|
|
7
|
-
const ospath = require('path')
|
|
7
|
+
const ospath = require('node:path')
|
|
8
8
|
|
|
9
9
|
class GitCredentialManagerStore {
|
|
10
10
|
configure ({ config, startDir }) {
|
package/lib/git-plugin-http.js
CHANGED
|
@@ -49,11 +49,12 @@ module.exports = ({ headers: extraHeaders, httpProxy, httpsProxy, noProxy } = {}
|
|
|
49
49
|
}
|
|
50
50
|
return {
|
|
51
51
|
async request ({ url, method, headers, body }) {
|
|
52
|
-
headers = mergeHeaders(headers, extraHeaders)
|
|
52
|
+
headers = Object.assign(mergeHeaders(headers, extraHeaders), { connection: 'close' })
|
|
53
53
|
body = await mergeBuffers(body)
|
|
54
|
-
return new Promise((resolve, reject) =>
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const opts = { url, method, headers, body, timeout: 0, keepAlive: false }
|
|
56
|
+
return get(opts, (err, res) => (err ? reject(err) : resolve(distillResponse(res))))
|
|
57
|
+
})
|
|
57
58
|
},
|
|
58
59
|
}
|
|
59
60
|
}
|
package/lib/git.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const zlib = require('node:zlib')
|
|
4
|
+
const { promisify } = require('node:util')
|
|
5
|
+
|
|
6
|
+
module.exports = ((pakoModuleId) => {
|
|
7
|
+
const git = require('isomorphic-git')
|
|
8
|
+
require(pakoModuleId).inflate = promisify(zlib.inflate)
|
|
9
|
+
return git
|
|
10
|
+
})('pako')
|
package/lib/matcher.js
CHANGED
|
@@ -16,15 +16,10 @@ const BASE_OPTS = {
|
|
|
16
16
|
strictSlashes: true,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function makeMatcherRx (input, opts) {
|
|
20
|
-
if (input && ~input.indexOf('{')) input = input.replace(/^([^({]+)\./, '$1(?:.)')
|
|
21
|
-
return makeRe(input, opts)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
19
|
module.exports = {
|
|
25
20
|
MATCH_ALL_RX: Object.defineProperty({ test: () => true }, 'pattern', { value: '*' }),
|
|
26
21
|
expandBraces,
|
|
27
|
-
makeMatcherRx,
|
|
22
|
+
makeMatcherRx: makeRe,
|
|
28
23
|
pathMatcherOpts: Object.assign({}, BASE_OPTS, { dot: false }),
|
|
29
24
|
refMatcherOpts: (cache) =>
|
|
30
25
|
Object.assign({}, BASE_OPTS, {
|
package/lib/posixify.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const deepFlatten = require('./deep-flatten')
|
|
4
|
-
const { promises: fsp } = require('fs')
|
|
4
|
+
const { promises: fsp } = require('node:fs')
|
|
5
5
|
const git = require('./git')
|
|
6
6
|
const invariably = require('./invariably')
|
|
7
7
|
const { expandBraces, makeMatcherRx, pathMatcherOpts: MATCHER_OPTS } = require('./matcher')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-aggregator",
|
|
3
|
-
"version": "3.2.0-alpha.
|
|
3
|
+
"version": "3.2.0-alpha.5",
|
|
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)",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@antora/expand-path-helper": "~2.0",
|
|
32
|
-
"@antora/logger": "3.2.0-alpha.
|
|
32
|
+
"@antora/logger": "3.2.0-alpha.5",
|
|
33
33
|
"@antora/user-require-helper": "~2.0",
|
|
34
34
|
"braces": "~3.0",
|
|
35
35
|
"cache-directory": "~2.0",
|
|
36
|
-
"glob
|
|
36
|
+
"fast-glob": "~3.3",
|
|
37
37
|
"hpagent": "~1.2",
|
|
38
|
-
"isomorphic-git": "~1.
|
|
38
|
+
"isomorphic-git": "~1.25",
|
|
39
39
|
"js-yaml": "~4.1",
|
|
40
40
|
"multi-progress": "~4.0",
|
|
41
|
-
"picomatch": "~
|
|
41
|
+
"picomatch": "~4.0",
|
|
42
42
|
"progress": "~2.0",
|
|
43
43
|
"should-proxy": "~1.0",
|
|
44
44
|
"simple-get": "~4.0",
|
|
45
|
-
"vinyl": "~
|
|
45
|
+
"vinyl": "~3.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"lib/"
|