@antora/content-aggregator 3.1.7 → 3.1.9

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.
@@ -15,7 +15,7 @@ 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-stream')
18
+ const { globStream } = require('fast-glob')
19
19
  const { inspect } = require('util')
20
20
  const invariably = require('./invariably')
21
21
  const logger = require('./logger')
@@ -384,7 +384,7 @@ async function selectReferences (source, repo, remote) {
384
384
  }
385
385
 
386
386
  /**
387
- * Returns the current branch name unless the HEAD is detached.
387
+ * Returns the current branch name or undefined if the HEAD is detached.
388
388
  */
389
389
  function getCurrentBranchName (repo, remote) {
390
390
  let refPromise
@@ -438,12 +438,13 @@ function collectFilesFromStartPath (startPath, repo, authStatus, ref, originUrl,
438
438
  const worktreePath = ref.head
439
439
  const origin = computeOrigin(originUrl, authStatus, repo.gitdir, ref, startPath, worktreePath, editUrl)
440
440
  return (worktreePath ? readFilesFromWorktree(origin) : readFilesFromGitTree(repo, ref.oid, startPath))
441
- .then((files) =>
442
- Object.assign(deepClone((origin.descriptor = loadComponentDescriptor(files, ref, version))), {
443
- files: files.map((file) => assignFileProperties(file, origin)),
444
- origins: [origin],
445
- })
446
- )
441
+ .then((files) => {
442
+ const batch = deepClone((origin.descriptor = loadComponentDescriptor(files, ref, version)))
443
+ if ('nav' in batch) batch.nav.origin = origin
444
+ batch.files = files.map((file) => assignFileProperties(file, origin))
445
+ batch.origins = [origin]
446
+ return batch
447
+ })
447
448
  .catch((err) => {
448
449
  const where = worktreePath || (worktreePath === false ? repo.gitdir : repo.url || repo.dir)
449
450
  const flag = worktreePath ? ' <worktree>' : ref.remote && worktreePath === false ? ` <remotes/${ref.remote}>` : ''
@@ -468,19 +469,18 @@ function readFilesFromWorktree (origin) {
468
469
  }
469
470
 
470
471
  function srcFs (cwd, origin) {
471
- return new Promise((resolve, reject, cache = Object.create(null), files = [], relpathStart = cwd.length + 1) =>
472
+ return new Promise((resolve, reject, files = []) =>
472
473
  pipeline(
473
- globStream(CONTENT_SRC_GLOB, Object.assign({ cache, cwd }, CONTENT_SRC_OPTS)),
474
- forEach(({ path: abspathPosix }, _, done) => {
475
- if ((cache[abspathPosix] || {}).constructor === Array) return done() // detects some directories
476
- const abspath = posixify ? ospath.normalize(abspathPosix) : abspathPosix
477
- const relpath = abspath.substr(relpathStart)
478
- symlinkAwareStat(abspath).then(
479
- (stat) => {
480
- if (stat.isDirectory()) return done() // detects directories that slipped through cache check
474
+ globStream(CONTENT_SRC_GLOB, Object.assign({ cwd }, CONTENT_SRC_OPTS)),
475
+ forEach(({ path: relpath, dirent }, _, done) => {
476
+ if (dirent.isDirectory()) return done()
477
+ const relpathPosix = relpath
478
+ const abspath = posixify ? ospath.join(cwd, (relpath = ospath.normalize(relpath))) : cwd + '/' + relpath
479
+ fsp.stat(abspath).then(
480
+ (stat) =>
481
481
  fsp.readFile(abspath).then(
482
482
  (contents) => {
483
- files.push(new File({ path: posixify ? posixify(relpath) : relpath, contents, stat, src: { abspath } }))
483
+ files.push(new File({ path: relpathPosix, contents, stat, src: { abspath } }))
484
484
  done()
485
485
  },
486
486
  (readErr) => {
@@ -490,22 +490,28 @@ function srcFs (cwd, origin) {
490
490
  : logger.error(logObject, readErr.message.replace(`'${abspath}'`, relpath))
491
491
  done()
492
492
  }
493
- )
494
- },
493
+ ),
495
494
  (statErr) => {
496
495
  const logObject = { file: { abspath, origin } }
497
- if (statErr.symlink) {
498
- logger.error(
499
- logObject,
500
- (statErr.code === 'ELOOP' ? 'ELOOP: symbolic link cycle, ' : 'ENOENT: broken symbolic link, ') +
501
- `${relpath} -> ${statErr.symlink}`
502
- )
503
- } else if (statErr.code === 'ENOENT') {
504
- logger.warn(logObject, `ENOENT: file or directory disappeared, ${statErr.syscall} ${relpath}`)
496
+ if (dirent.isSymbolicLink()) {
497
+ fsp
498
+ .readlink(abspath)
499
+ .then(
500
+ (symlink) =>
501
+ (statErr.code === 'ELOOP' ? 'ELOOP: symbolic link cycle, ' : 'ENOENT: broken symbolic link, ') +
502
+ `${relpath} -> ${symlink}`,
503
+ () => statErr.message.replace(`'${abspath}'`, relpath)
504
+ )
505
+ .then((message) => {
506
+ logger.error(logObject, message)
507
+ done()
508
+ })
505
509
  } else {
506
- logger.error(logObject, statErr.message.replace(`'${abspath}'`, relpath))
510
+ statErr.code === 'ENOENT'
511
+ ? logger.warn(logObject, `ENOENT: file or directory disappeared, ${statErr.syscall} ${relpath}`)
512
+ : logger.error(logObject, statErr.message.replace(`'${abspath}'`, relpath))
513
+ done()
507
514
  }
508
- done()
509
515
  }
510
516
  )
511
517
  }),
@@ -675,8 +681,13 @@ function filterGitEntry (entry) {
675
681
 
676
682
  function gitEntryToFile (entry) {
677
683
  return git.readBlob(entry).then(({ blob: contents }) => {
678
- contents = Buffer.from(contents.buffer)
679
- const stat = Object.assign(new fs.Stats(), { mode: entry.mode, mtime: undefined, size: contents.byteLength })
684
+ const stat = {
685
+ mode: entry.mode,
686
+ size: (contents = Buffer.from(contents.buffer)).byteLength,
687
+ isDirectory: invariably.false,
688
+ isFile: invariably.true,
689
+ isSymbolicLink: invariably.false,
690
+ }
680
691
  return new File({ path: entry.path, contents, stat })
681
692
  })
682
693
  }
@@ -688,7 +699,7 @@ function loadComponentDescriptor (files, ref, version) {
688
699
  files.splice(descriptorFileIdx, 1)
689
700
  let data
690
701
  try {
691
- data = yaml.load(descriptorFile.contents.toString(), { schema: yaml.CORE_SCHEMA })
702
+ data = Object(yaml.load(descriptorFile.contents.toString(), { schema: yaml.CORE_SCHEMA }))
692
703
  } catch (err) {
693
704
  throw Object.assign(err, { message: `${COMPONENT_DESC_FILENAME} has invalid syntax; ${err.message}` })
694
705
  }
@@ -903,20 +914,6 @@ function isDirectory (url) {
903
914
  return fsp.stat(url).then((stat) => stat.isDirectory(), invariably.false)
904
915
  }
905
916
 
906
- function symlinkAwareStat (path_) {
907
- return fsp.lstat(path_).then((lstat) => {
908
- if (!lstat.isSymbolicLink()) return lstat
909
- return fsp.stat(path_).catch((statErr) =>
910
- fsp
911
- .readlink(path_)
912
- .catch(invariably.void)
913
- .then((symlink) => {
914
- throw Object.assign(statErr, { symlink })
915
- })
916
- )
917
- })
918
- }
919
-
920
917
  function tagsSpecified (sources) {
921
918
  return sources.some(({ tags }) => tags && (Array.isArray(tags) ? tags.length : true))
922
919
  }
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: { follow: true, nomount: true, nosort: true, nounique: true, strict: false },
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,
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: { test: () => true },
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/content-aggregator",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
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,20 +29,20 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@antora/expand-path-helper": "~2.0",
32
- "@antora/logger": "3.1.7",
32
+ "@antora/logger": "3.1.9",
33
33
  "@antora/user-require-helper": "~2.0",
34
34
  "braces": "~3.0",
35
35
  "cache-directory": "~2.0",
36
- "glob-stream": "~7.0",
36
+ "fast-glob": "~3.3",
37
37
  "hpagent": "~1.2",
38
38
  "isomorphic-git": "~1.25",
39
39
  "js-yaml": "~4.1",
40
40
  "multi-progress": "~4.0",
41
- "picomatch": "~2.3",
41
+ "picomatch": "~4.0",
42
42
  "progress": "~2.0",
43
43
  "should-proxy": "~1.0",
44
44
  "simple-get": "~4.0",
45
- "vinyl": "~2.2"
45
+ "vinyl": "~3.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=16.0.0"