@antora/content-aggregator 3.1.11 → 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.
@@ -1,32 +1,32 @@
1
1
  'use strict'
2
2
 
3
3
  const computeOrigin = require('./compute-origin')
4
- const { createHash } = require('node:crypto')
4
+ const { createHash } = require('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('node:events')
8
+ const EventEmitter = require('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('node:fs')
12
+ const fs = require('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
18
  const { globStream } = require('fast-glob')
19
- const { inspect } = require('node:util')
19
+ const { inspect } = require('util')
20
20
  const invariably = require('./invariably')
21
21
  const logger = require('./logger')
22
22
  const { makeMatcherRx, versionMatcherOpts: VERSION_MATCHER_OPTS } = require('./matcher')
23
23
  const MultiProgress = require('multi-progress') // calls require('progress') as a peer dependencies
24
- const ospath = require('node:path')
24
+ const ospath = require('path')
25
25
  const { posix: path } = ospath
26
26
  const posixify = require('./posixify')
27
27
  const removeGitSuffix = require('./remove-git-suffix')
28
28
  const { fs: resolvePathGlobsFs, git: resolvePathGlobsGit } = require('./resolve-path-globs')
29
- const { pipeline, Writable } = require('node:stream')
29
+ const { pipeline, Writable } = require('stream')
30
30
  const forEach = (write) => new Writable({ objectMode: true, write })
31
31
  const userRequire = require('@antora/user-require-helper')
32
32
  const yaml = require('js-yaml')
@@ -102,8 +102,7 @@ function aggregateContent (playbook) {
102
102
  }, new Map())
103
103
  const progress = quiet ? undefined : createProgress(sourcesByUrl.keys(), process.stdout)
104
104
  const refPatternCache = Object.assign(new Map(), { braces: new Map() })
105
- const fetchConfig = { always: fetch, depth: Math.max(0, gitConfig.fetchDepth ?? 1) }
106
- const loadOpts = { cacheDir, fetch: fetchConfig, gitPlugins, progress, startDir, refPatternCache }
105
+ const loadOpts = { cacheDir, fetch, gitPlugins, progress, startDir, refPatternCache }
107
106
  return collectFiles(sourcesByUrl, loadOpts, concurrency).then(buildAggregate, (err) => {
108
107
  progress?.terminate()
109
108
  throw err
@@ -111,11 +110,11 @@ function aggregateContent (playbook) {
111
110
  })
112
111
  }
113
112
 
114
- async function collectFiles (sourcesByUrl, loadOpts, concurrency, fetchedUrls = []) {
113
+ async function collectFiles (sourcesByUrl, loadOpts, concurrency, fetchedUrls) {
115
114
  const loadTasks = [...sourcesByUrl.entries()].map(([url, sources]) => {
116
115
  const loadOptsForUrl = Object.assign({}, loadOpts)
117
- if (loadOpts.fetch.always && fetchedUrls.length && fetchedUrls.includes(url)) loadOptsForUrl.fetch.always = false
118
- if (tagsSpecified(sources)) loadOptsForUrl.fetch.tags = true
116
+ if (loadOpts.fetch && fetchedUrls && fetchedUrls.length && fetchedUrls.includes(url)) loadOptsForUrl.fetch = false
117
+ if (tagsSpecified(sources)) loadOptsForUrl.fetchTags = true
119
118
  return loadRepository.bind(null, url, loadOptsForUrl, { url, sources })
120
119
  })
121
120
  return gracefulPromiseAllWithLimit(loadTasks, concurrency.fetch).then(([results, rejections]) => {
@@ -164,7 +163,7 @@ async function loadRepository (url, opts, result = {}) {
164
163
  if (~url.indexOf(':') && GIT_URI_DETECTOR_RX.test(url)) {
165
164
  let credentials, displayUrl
166
165
  ;({ displayUrl, url, credentials } = extractCredentials(url))
167
- const { cacheDir, fetch, gitPlugins, progress } = opts
166
+ const { cacheDir, fetch, fetchTags, gitPlugins, progress } = opts
168
167
  dir = ospath.join(cacheDir, generateCloneFolderName(displayUrl))
169
168
  // NOTE the presence of the url property on the repo object implies the repository is remote
170
169
  repo = { cache, dir, fs, gitdir: dir, noCheckout: true, url }
@@ -172,9 +171,9 @@ async function loadRepository (url, opts, result = {}) {
172
171
  const validStateFile = ospath.join(dir, VALID_STATE_FILENAME)
173
172
  try {
174
173
  await fsp.access(validStateFile)
175
- if (fetch.always) {
174
+ if (fetch) {
176
175
  await fsp.unlink(validStateFile)
177
- const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetch, 'fetch')
176
+ const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetchTags, 'fetch')
178
177
  await git
179
178
  .fetch(fetchOpts)
180
179
  .then(() => {
@@ -194,7 +193,7 @@ async function loadRepository (url, opts, result = {}) {
194
193
  } catch (gitErr) {
195
194
  await fsp['rm' in fsp ? 'rm' : 'rmdir'](dir, { recursive: true, force: true })
196
195
  if (gitErr.rethrow) throw transformGitCloneError(gitErr, displayUrl)
197
- const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetch, 'clone')
196
+ const fetchOpts = buildFetchOptions(repo, progress, displayUrl, credentials, gitPlugins, fetchTags, 'clone')
198
197
  await git
199
198
  .clone(fetchOpts)
200
199
  .then(() => git.resolveRef(Object.assign({ ref: 'HEAD', depth: 1 }, repo)))
@@ -211,15 +210,8 @@ async function loadRepository (url, opts, result = {}) {
211
210
  .then(() => fetchOpts.onProgress?.finish())
212
211
  }
213
212
  } else if (await isDirectory((dir = expandPath(url, { dot: opts.startDir })))) {
214
- const dotgit = ospath.join(dir, '.git')
215
- const dotgitStat = await fsp.stat(dotgit).catch(() => ({ isFile: invariably.false, isDirectory: invariably.false }))
216
- if (dotgitStat.isDirectory()) {
217
- repo = { cache, dir, fs, gitdir: dotgit }
218
- } else if (dotgitStat.isFile()) {
219
- repo = await resolveRepositoryFromWorktree({ cache, dir, fs, gitdir: dotgit })
220
- } else {
221
- repo = { cache, dir, fs, gitdir: dir, noCheckout: true }
222
- }
213
+ const gitdir = ospath.join(dir, '.git')
214
+ repo = (await isDirectory(gitdir)) ? { cache, dir, fs, gitdir } : { cache, dir, fs, gitdir: dir, noCheckout: true }
223
215
  try {
224
216
  await git.resolveRef(Object.assign({ ref: 'HEAD', depth: 1 }, repo))
225
217
  } catch {
@@ -293,7 +285,7 @@ async function selectStartPathsForRepository (repo, authStatus, sources) {
293
285
 
294
286
  // QUESTION should we resolve HEAD to a ref eagerly to avoid having to do a match on it?
295
287
  async function selectReferences (source, repo, remote) {
296
- let { branches: branchPatterns, tags: tagPatterns, worktrees: worktreePatterns } = source
288
+ let { branches: branchPatterns, tags: tagPatterns, worktrees: worktreePatterns = '.' } = source
297
289
  const managed = 'url' in repo
298
290
  const isBare = managed || repo.noCheckout
299
291
  const patternCache = repo.cache[REF_PATTERN_CACHE_KEY]
@@ -313,16 +305,7 @@ async function selectReferences (source, repo, remote) {
313
305
  }
314
306
  }
315
307
  }
316
- if (
317
- !branchPatterns ||
318
- !(branchPatterns = Array.isArray(branchPatterns)
319
- ? branchPatterns.map((pattern) => String(pattern))
320
- : splitRefPatterns(String(branchPatterns))).length
321
- ) {
322
- return [...refs.values()]
323
- }
324
- const worktreeName = repo.worktreeName // possibly switch to worktree property ({ name, dir}) in future
325
- if (worktreeName) branchPatterns = branchPatterns.map((it) => (it === 'HEAD' ? 'HEAD@' + worktreeName : it))
308
+ if (!branchPatterns) return [...refs.values()]
326
309
  if (worktreePatterns) {
327
310
  if (worktreePatterns === '.') {
328
311
  worktreePatterns = ['.']
@@ -332,14 +315,14 @@ async function selectReferences (source, repo, remote) {
332
315
  worktreePatterns = Array.isArray(worktreePatterns)
333
316
  ? worktreePatterns.map((pattern) => String(pattern))
334
317
  : splitRefPatterns(String(worktreePatterns))
335
- if (worktreeName) worktreePatterns = worktreePatterns.map((it) => (it === '@' ? worktreeName : it))
336
318
  }
337
319
  } else {
338
- worktreePatterns = worktreePatterns === undefined ? [worktreeName || '.'] : []
320
+ worktreePatterns = []
339
321
  }
340
- let currentBranch
341
- if (branchPatterns.length === 1 && (branchPatterns[0] === 'HEAD' || branchPatterns[0] === '.')) {
342
- if ((currentBranch = await getCurrentBranchName(repo, remote).then((branch) => branch ?? false))) {
322
+ const branchPatternsString = String(branchPatterns)
323
+ if (branchPatternsString === 'HEAD' || branchPatternsString === '.') {
324
+ const currentBranch = await getCurrentBranchName(repo, remote)
325
+ if (currentBranch) {
343
326
  branchPatterns = [currentBranch]
344
327
  } else if (isBare) {
345
328
  return [...refs.values()]
@@ -349,11 +332,17 @@ async function selectReferences (source, repo, remote) {
349
332
  refs.set('HEAD', { shortname: 'HEAD', fullname: 'HEAD', type: 'branch', detached: true, head })
350
333
  return [...refs.values()]
351
334
  }
352
- } else {
335
+ } else if (
336
+ (branchPatterns = Array.isArray(branchPatterns)
337
+ ? branchPatterns.map((pattern) => String(pattern))
338
+ : splitRefPatterns(branchPatternsString)).length
339
+ ) {
353
340
  let headBranchIdx
354
341
  // NOTE we can assume at least two entries if HEAD or . are present
355
342
  if (~(headBranchIdx = branchPatterns.indexOf('HEAD')) || ~(headBranchIdx = branchPatterns.indexOf('.'))) {
356
- if ((currentBranch = await getCurrentBranchName(repo, remote).then((branch) => branch ?? false))) {
343
+ const currentBranch = await getCurrentBranchName(repo, remote)
344
+ if (currentBranch) {
345
+ // NOTE ignore if current branch is already in list
357
346
  if (~branchPatterns.indexOf(currentBranch)) {
358
347
  branchPatterns.splice(headBranchIdx, 1)
359
348
  } else {
@@ -372,6 +361,8 @@ async function selectReferences (source, repo, remote) {
372
361
  branchPatterns.splice(headBranchIdx, 1)
373
362
  }
374
363
  }
364
+ } else {
365
+ return [...refs.values()]
375
366
  }
376
367
  // NOTE isomorphic-git includes HEAD in list of remote branches (see https://isomorphic-git.org/docs/listBranches)
377
368
  const remoteBranches = remote
@@ -385,27 +376,11 @@ async function selectReferences (source, repo, remote) {
385
376
  }
386
377
  // NOTE only consider local branches if repo has a worktree or there are no remote tracking branches
387
378
  if (!isBare) {
388
- const localBranches = await git.listBranches(repo).then((branches) => {
389
- if (branches.length) return branches
390
- if (currentBranch == null) return getCurrentBranchName(repo).then((branch) => (branch ? [branch] : []))
391
- return currentBranch ? [currentBranch] : []
392
- })
379
+ const localBranches = await git.listBranches(repo)
393
380
  if (localBranches.length) {
394
381
  const worktrees = await findWorktrees(repo, worktreePatterns)
395
- let onMatch
396
- if ((worktreePatterns.join('') || '.') !== '.') {
397
- const symbolicNames = new Map()
398
- worktrees.forEach(({ name, symbolicName = 'HEAD@' + name }, shortname) => {
399
- localBranches.push(symbolicName)
400
- symbolicNames.set(symbolicName, shortname)
401
- })
402
- onMatch = (candidate, { pattern }) => {
403
- const shortname = symbolicNames.get(candidate)
404
- return shortname ? (pattern.startsWith('HEAD@') ? shortname : undefined) : candidate
405
- }
406
- }
407
- for (const shortname of filterRefs(localBranches, branchPatterns, patternCache, onMatch)) {
408
- const head = (worktrees.get(shortname) || { head: noWorktree }).head
382
+ for (const shortname of filterRefs(localBranches, branchPatterns, patternCache)) {
383
+ const head = worktrees.get(shortname) || noWorktree
409
384
  refs.set(shortname, { shortname, fullname: 'heads/' + shortname, type: 'branch', head })
410
385
  }
411
386
  }
@@ -425,13 +400,15 @@ async function selectReferences (source, repo, remote) {
425
400
  * Returns the current branch name or undefined if the HEAD is detached.
426
401
  */
427
402
  function getCurrentBranchName (repo, remote) {
428
- return (
429
- remote && repo.noCheckout
430
- ? git
431
- .resolveRef(Object.assign({ ref: 'refs/remotes/' + remote + '/HEAD', depth: 2 }, repo))
432
- .catch(() => git.resolveRef(Object.assign({ ref: 'HEAD', depth: 2 }, repo)))
433
- : git.resolveRef(Object.assign({ ref: 'HEAD', depth: 2 }, repo))
434
- ).then((ref) => (ref.startsWith('refs/') ? ref.replace(SHORTEN_REF_RX, '') : undefined))
403
+ let refPromise
404
+ if (repo.noCheckout) {
405
+ refPromise = git
406
+ .resolveRef(Object.assign({ ref: 'refs/remotes/' + remote + '/HEAD', depth: 2 }, repo))
407
+ .catch(() => git.resolveRef(Object.assign({ ref: 'HEAD', depth: 2 }, repo)))
408
+ } else {
409
+ refPromise = git.resolveRef(Object.assign({ ref: 'HEAD', depth: 2 }, repo))
410
+ }
411
+ return refPromise.then((ref) => (ref.startsWith('refs/') ? ref.replace(SHORTEN_REF_RX, '') : undefined))
435
412
  }
436
413
 
437
414
  async function selectStartPaths (source, repo, ref) {
@@ -775,7 +752,7 @@ function loadComponentDescriptor (files, ref, version) {
775
752
  throw new Error(`version in ${COMPONENT_DESC_FILENAME} cannot have path segments: ${version}`)
776
753
  }
777
754
  data.version = version
778
- return camelCaseKeys(data, ['asciidoc', 'ext'])
755
+ return camelCaseKeys(data, ['asciidoc'])
779
756
  }
780
757
 
781
758
  function assignFileProperties (file, origin) {
@@ -792,20 +769,18 @@ function assignFileProperties (file, origin) {
792
769
  return file
793
770
  }
794
771
 
795
- function buildFetchOptions (repo, progress, displayUrl, credentialsFromUrl, gitPlugins, fetch, operation) {
772
+ function buildFetchOptions (repo, progress, displayUrl, credentialsFromUrl, gitPlugins, fetchTags, operation) {
796
773
  const { credentialManager, http, urlRouter } = gitPlugins
797
- const corsProxy = false
798
- const depth = fetch.depth || undefined
799
774
  const onAuth = resolveCredentials.bind(credentialManager, new Map().set(undefined, credentialsFromUrl))
800
775
  const onAuthFailure = onAuth
801
776
  const onAuthSuccess = (url) => credentialManager.approved({ url })
802
- const opts = Object.assign({ corsProxy, depth, http, onAuth, onAuthFailure, onAuthSuccess }, repo)
777
+ const opts = Object.assign({ corsProxy: false, depth: 1, http, onAuth, onAuthFailure, onAuthSuccess }, repo)
803
778
  if (urlRouter) opts.url = urlRouter.ensureGitSuffix(opts.url)
804
779
  if (progress) opts.onProgress = createProgressListener(progress, displayUrl, operation)
805
780
  if (operation === 'fetch') {
806
781
  opts.prune = true
807
- if (fetch.tags) opts.tags = opts.pruneTags = true
808
- } else if (!fetch.tags) {
782
+ if (fetchTags) opts.tags = opts.pruneTags = true
783
+ } else if (!fetchTags) {
809
784
  opts.noTags = true
810
785
  }
811
786
  return opts
@@ -900,11 +875,7 @@ function resolveCredentials (credentialsFromUrlHolder, url, auth) {
900
875
  }
901
876
 
902
877
  function identifyAuthStatus (credentialManager, credentials, url) {
903
- const status = credentialManager.status({ url })
904
- if (credentials) {
905
- return typeof status === 'string' && status.startsWith('requested,') ? 'auth-required' : 'auth-embedded'
906
- }
907
- if (status != null) return 'auth-required'
878
+ return credentials ? 'auth-embedded' : credentialManager.status({ url }) ? 'auth-required' : undefined
908
879
  }
909
880
 
910
881
  /**
@@ -1058,50 +1029,39 @@ function coerceToString (value) {
1058
1029
  return value == null ? '' : String(value)
1059
1030
  }
1060
1031
 
1061
- function resolveRepositoryFromWorktree (repo) {
1062
- return fsp
1063
- .readFile(repo.gitdir, 'utf8')
1064
- .then((contents) => contents.substr(8).trimEnd())
1065
- .then((worktreeGitdir) =>
1066
- fsp.readFile(ospath.join(worktreeGitdir, 'commondir'), 'utf8').then(
1067
- (contents) => {
1068
- const gitdir = ospath.join(worktreeGitdir, contents.trimEnd())
1069
- const dir = ospath.basename(gitdir) === '.git' ? ospath.dirname(gitdir) : gitdir
1070
- return Object.assign(repo, { dir, gitdir, worktreeName: ospath.basename(worktreeGitdir) })
1071
- },
1072
- () => repo
1073
- )
1074
- )
1075
- }
1076
-
1077
1032
  function findWorktrees (repo, patterns) {
1078
1033
  if (!patterns.length) return new Map()
1079
- const mainWorktree =
1080
- patterns[0] === '.' && (patterns = patterns.slice(1))
1081
- ? getCurrentBranchName(repo).then((branch) => branch && [branch, { head: repo.dir, name: '.' }])
1082
- : Promise.resolve()
1083
- const worktreesDir = patterns.length ? ospath.join(repo.dir, '.git', 'worktrees') : undefined
1034
+ const linkedOnly = patterns[0] === '.' ? !(patterns = patterns.slice(1)) : true
1035
+ let worktreesDir
1084
1036
  const patternCache = repo.cache[REF_PATTERN_CACHE_KEY]
1085
1037
  return (
1086
- worktreesDir
1038
+ patterns.length
1087
1039
  ? fsp
1088
- .readdir(worktreesDir)
1040
+ .readdir((worktreesDir = ospath.join(repo.dir, '.git', 'worktrees')))
1089
1041
  .then((worktreeNames) => filterRefs(worktreeNames, patterns, patternCache), invariably.emptyArray)
1090
1042
  .then((worktreeNames) =>
1091
- Promise.all(
1092
- worktreeNames.map((worktreeName) => {
1093
- const gitdir = ospath.resolve(worktreesDir, worktreeName)
1094
- // NOTE branch name defaults to worktree name if HEAD is detached
1095
- return getCurrentBranchName(Object.assign({}, repo, { gitdir })).then((branch = worktreeName) =>
1096
- fsp
1097
- .readFile(ospath.join(gitdir, 'gitdir'), 'utf8')
1098
- .then((contents) => [branch, { head: ospath.dirname(contents.trimEnd()), name: worktreeName }])
1099
- )
1100
- })
1101
- )
1043
+ worktreeNames.length
1044
+ ? Promise.all(
1045
+ worktreeNames.map((worktreeName) => {
1046
+ const gitdir = ospath.resolve(worktreesDir, worktreeName)
1047
+ // NOTE uses name of worktree as branch name if HEAD is detached
1048
+ return git
1049
+ .currentBranch(Object.assign({}, repo, { gitdir }))
1050
+ .then((branch = worktreeName) =>
1051
+ fsp
1052
+ .readFile(ospath.join(gitdir, 'gitdir'), 'utf8')
1053
+ .then((contents) => ({ branch, dir: ospath.dirname(contents.trimEnd()) }))
1054
+ )
1055
+ })
1056
+ ).then((entries) => entries.reduce((accum, it) => accum.set(it.branch, it.dir), new Map()))
1057
+ : new Map()
1102
1058
  )
1103
- : Promise.resolve()
1104
- ).then((entries = []) => mainWorktree.then((entry) => new Map(entry ? entries.push(entry) && entries : entries)))
1059
+ : Promise.resolve(new Map())
1060
+ ).then((worktrees) =>
1061
+ linkedOnly
1062
+ ? worktrees
1063
+ : git.currentBranch(repo).then((branch) => (branch ? worktrees.set(branch, repo.dir) : worktrees))
1064
+ )
1105
1065
  }
1106
1066
 
1107
1067
  async function gracefulPromiseAllWithLimit (tasks, limit = Infinity) {
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
- const { posix: path } = require('node:path')
3
+ const { posix: path } = require('path')
4
4
  const posixify = require('./posixify')
5
5
  const removeGitSuffix = require('./remove-git-suffix')
6
6
 
7
- const EDIT_URL_TEMPLATE_VAR_RX = /\{(web_url|ref(?:hash|name|type)?|path)\}/g
7
+ const EDIT_URL_TEMPLATE_VAR_RX = /\{(web_url|ref(?:hash|name|type)|path)\}/g
8
8
  const HOSTED_GIT_REPO_RX = /^(?:https?:\/\/|.+@)(git(?:hub|lab)\.com|bitbucket\.org|pagure\.io)[/:](.+?)(?:\.git)?$/
9
9
 
10
10
  function computeOrigin (url, authStatus, gitdir, ref, startPath, worktreePath = undefined, editUrl = true) {
@@ -33,16 +33,14 @@ function computeOrigin (url, authStatus, gitdir, ref, startPath, worktreePath =
33
33
  category = 'f'
34
34
  } else if (host === 'bitbucket.org') {
35
35
  action = 'src'
36
- } else {
37
- if (reftype === 'branch') action = 'edit'
38
- if (host.startsWith('gitlab.')) action = '-/' + action
36
+ } else if (reftype === 'branch') {
37
+ action = 'edit'
39
38
  }
40
39
  origin.editUrlPattern = 'https://' + path.join(match[1], match[2], action, refname, category, startPath, '%s')
41
40
  }
42
41
  } else if (editUrl) {
43
42
  const vars = {
44
43
  path: () => (startPath ? path.join(startPath, '%s') : '%s'),
45
- ref: () => 'refs/' + (reftype === 'branch' ? 'heads' : reftype) + '/' + refname,
46
44
  refhash: () => refhash,
47
45
  reftype: () => reftype,
48
46
  refname: () => refname,
@@ -3,4 +3,4 @@
3
3
  module.exports = (({ StringDecoder }) => {
4
4
  const decoder = new StringDecoder()
5
5
  return decoder.write.bind(decoder)
6
- })(require('node:string_decoder'))
6
+ })(require('string_decoder'))
@@ -4,11 +4,9 @@ const { makeMatcherRx, refMatcherOpts: getMatcherOpts, MATCH_ALL_RX } = require(
4
4
 
5
5
  function compileRx (pattern, opts) {
6
6
  if (pattern === '*' || pattern === '**') return MATCH_ALL_RX
7
- const rx =
8
- pattern.charAt() === '!' // we handle negate ourselves
9
- ? Object.defineProperty(makeMatcherRx((pattern = pattern.substr(1)), opts), 'negated', { value: true })
10
- : makeMatcherRx(pattern, opts)
11
- return Object.defineProperty(rx, 'pattern', { value: pattern })
7
+ return pattern.charAt() === '!' // do our own negate
8
+ ? Object.defineProperty(makeMatcherRx(pattern.substr(1), opts), 'negated', { value: true })
9
+ : makeMatcherRx(pattern, opts)
12
10
  }
13
11
 
14
12
  function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new Map() })) {
@@ -16,8 +14,8 @@ function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new
16
14
  (pattern) => cache.get(pattern) || cache.set(pattern, compileRx(pattern, getMatcherOpts(cache))).get(pattern)
17
15
  )
18
16
  if (rxs[0].negated) rxs.unshift(MATCH_ALL_RX)
19
- return (candidate, onMatch) => {
20
- let matched, symbolic
17
+ return (candidate) => {
18
+ let matched
21
19
  for (const rx of rxs) {
22
20
  let voteIfMatched = true
23
21
  if (matched) {
@@ -26,22 +24,16 @@ function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new
26
24
  } else if (rx.negated) {
27
25
  continue
28
26
  }
29
- if (rx.test(candidate) || (symbolic && rx.test(symbolic) && (candidate = symbolic))) {
30
- if (onMatch) {
31
- if (!(matched = onMatch(candidate, rx))) continue
32
- ;[symbolic, candidate] = [candidate, matched]
33
- }
34
- matched = voteIfMatched && candidate
35
- }
27
+ if (rx.test(candidate)) matched = voteIfMatched
36
28
  }
37
29
  return matched
38
30
  }
39
31
  }
40
32
 
41
- function filterRefs (candidates, patterns, cache, onMatch) {
42
- const match = createMatcher(patterns, cache)
33
+ function filterRefs (candidates, patterns, cache) {
34
+ const isMatch = createMatcher(patterns, cache)
43
35
  return candidates.reduce((accum, candidate) => {
44
- if ((candidate = match(candidate, onMatch))) accum.push(candidate)
36
+ if (isMatch(candidate)) accum.push(candidate)
45
37
  return accum
46
38
  }, [])
47
39
  }
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
- const { homedir } = require('node:os')
3
+ const { homedir } = require('os')
4
4
  const expandPath = require('@antora/expand-path-helper')
5
- const { promises: fsp } = require('node:fs')
5
+ const { promises: fsp } = require('fs')
6
6
  const invariably = require('./invariably')
7
- const ospath = require('node:path')
7
+ const ospath = require('path')
8
8
 
9
9
  class GitCredentialManagerStore {
10
10
  configure ({ config, startDir }) {
@@ -86,11 +86,11 @@ class GitCredentialManagerStore {
86
86
  }
87
87
 
88
88
  async approved ({ url }) {
89
- this.urls[url] = (url in this.urls ? this.urls[url] + ',' : '') + 'approved'
89
+ this.urls[url] = 'approved'
90
90
  }
91
91
 
92
92
  async rejected ({ url, auth }) {
93
- this.urls[url] = (url in this.urls ? this.urls[url] + ',' : '') + 'rejected'
93
+ this.urls[url] = 'rejected'
94
94
  const statusCode = 401
95
95
  const statusMessage = 'HTTP Basic: Access Denied'
96
96
  const err = new Error(`HTTP Error: ${statusCode} ${statusMessage}`)
package/lib/git.js CHANGED
@@ -1,10 +1,3 @@
1
1
  'use strict'
2
2
 
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')
3
+ module.exports = require('isomorphic-git')
package/lib/matcher.js CHANGED
@@ -17,7 +17,7 @@ const BASE_OPTS = {
17
17
  }
18
18
 
19
19
  module.exports = {
20
- MATCH_ALL_RX: Object.defineProperty({ test: () => true }, 'pattern', { value: '*' }),
20
+ MATCH_ALL_RX: { test: () => true },
21
21
  expandBraces,
22
22
  makeMatcherRx: makeRe,
23
23
  pathMatcherOpts: Object.assign({}, BASE_OPTS, { dot: false }),
package/lib/posixify.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict'
2
2
 
3
- module.exports = require('node:path').sep === '\\' ? (p) => p.replace(/\\/g, '/') : undefined
3
+ module.exports = require('path').sep === '\\' ? (p) => p.replace(/\\/g, '/') : undefined
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const deepFlatten = require('./deep-flatten')
4
- const { promises: fsp } = require('node:fs')
4
+ const { promises: fsp } = require('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.1.11",
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)",
@@ -13,8 +13,7 @@
13
13
  "homepage": "https://antora.org",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+https://gitlab.com/antora/antora.git",
17
- "directory": "packages/content-aggregator"
16
+ "url": "git+https://gitlab.com/antora/antora.git"
18
17
  },
19
18
  "bugs": {
20
19
  "url": "https://gitlab.com/antora/antora/issues"
@@ -33,7 +32,7 @@
33
32
  },
34
33
  "dependencies": {
35
34
  "@antora/expand-path-helper": "~3.0",
36
- "@antora/logger": "3.1.11",
35
+ "@antora/logger": "3.1.12",
37
36
  "@antora/user-require-helper": "~3.0",
38
37
  "braces": "~3.0",
39
38
  "cache-directory": "~2.0",
@@ -49,7 +48,7 @@
49
48
  "vinyl": "~3.0"
50
49
  },
51
50
  "engines": {
52
- "node": ">=18.0.0"
51
+ "node": ">=16.0.0"
53
52
  },
54
53
  "files": [
55
54
  "lib/"
@@ -66,7 +65,7 @@
66
65
  ],
67
66
  "scripts": {
68
67
  "test": "_mocha",
69
- "prepublishOnly": "npx -y downdoc@latest --prepublish",
70
- "postpublish": "npx -y downdoc@latest --postpublish"
68
+ "prepublishOnly": "npx -y downdoc --prepublish",
69
+ "postpublish": "npx -y downdoc --postpublish"
71
70
  }
72
71
  }