@antora/content-aggregator 3.2.0-alpha.1 → 3.2.0-alpha.11

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,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { posix: path } = require('path')
3
+ const { posix: path } = require('node:path')
4
4
  const posixify = require('./posixify')
5
5
  const removeGitSuffix = require('./remove-git-suffix')
6
6
 
@@ -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 && url.match(HOSTED_GIT_REPO_RX)
27
+ const match = url?.match(HOSTED_GIT_REPO_RX)
28
28
  if (match) {
29
29
  const host = match[1]
30
30
  let action = 'blob'
@@ -33,15 +33,16 @@ 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 if (reftype === 'branch') {
37
- action = 'edit'
36
+ } else {
37
+ if (reftype === 'branch') action = 'edit'
38
+ if (host.startsWith('gitlab.')) action = '-/' + action
38
39
  }
39
40
  origin.editUrlPattern = 'https://' + path.join(match[1], match[2], action, refname, category, startPath, '%s')
40
41
  }
41
42
  } else if (editUrl) {
42
43
  const vars = {
43
44
  path: () => (startPath ? path.join(startPath, '%s') : '%s'),
44
- ref: () => 'refs/' + (reftype === 'branch' ? 'heads' : reftype) + '/' + refname,
45
+ ref: () => 'refs/' + (reftype === 'branch' ? 'head' : reftype) + 's/' + refname,
45
46
  refhash: () => refhash,
46
47
  reftype: () => reftype,
47
48
  refname: () => refname,
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,
@@ -3,4 +3,4 @@
3
3
  module.exports = (({ StringDecoder }) => {
4
4
  const decoder = new StringDecoder()
5
5
  return decoder.write.bind(decoder)
6
- })(require('string_decoder'))
6
+ })(require('node:string_decoder'))
@@ -11,10 +11,9 @@ function compileRx (pattern, opts) {
11
11
  return Object.defineProperty(rx, 'pattern', { value: pattern })
12
12
  }
13
13
 
14
- function createMatcher (patterns, cache, opts) {
14
+ function createMatcher (patterns, cache = Object.assign(new Map(), { braces: new Map() })) {
15
15
  const rxs = patterns.map(
16
- (pattern) =>
17
- cache.get(pattern) || cache.set(pattern, compileRx(pattern, opts || (opts = getMatcherOpts(cache)))).get(pattern)
16
+ (pattern) => cache.get(pattern) || cache.set(pattern, compileRx(pattern, getMatcherOpts(cache))).get(pattern)
18
17
  )
19
18
  if (rxs[0].negated) rxs.unshift(MATCH_ALL_RX)
20
19
  return (candidate, onMatch) => {
@@ -39,7 +38,8 @@ function createMatcher (patterns, cache, opts) {
39
38
  }
40
39
  }
41
40
 
42
- function filterRefs (candidates, patterns, cache = Object.assign(new Map(), { braces: new Map() }), onMatch) {
41
+ function filterRefs (candidates, patterns, cache, onMatch) {
42
+ if (!(patterns = patterns.filter(compact)).length) return []
43
43
  const match = createMatcher(patterns, cache)
44
44
  return candidates.reduce((accum, candidate) => {
45
45
  if ((candidate = match(candidate, onMatch))) accum.push(candidate)
@@ -47,4 +47,8 @@ function filterRefs (candidates, patterns, cache = Object.assign(new Map(), { br
47
47
  }, [])
48
48
  }
49
49
 
50
+ function compact (str) {
51
+ return str !== ''
52
+ }
53
+
50
54
  module.exports = filterRefs
@@ -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 }) {
@@ -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
- get({ url, method, headers, body }, (err, res) => (err ? reject(err) : resolve(distillResponse(res))))
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
- module.exports = require('isomorphic-git')
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,3 +1,3 @@
1
1
  'use strict'
2
2
 
3
- module.exports = require('path').sep === '\\' ? (p) => p.replace(/\\/g, '/') : undefined
3
+ module.exports = require('node: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('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')
@@ -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
- } else if (RX_MAGIC_DETECTOR.test(pattern)) {
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
- oid: dirent.oid,
66
- path: joinPath(path, dirent.name),
67
- globbed: true,
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
- } else {
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
- } else if ((patternSegment += '/' + patternSegments.join('/')).indexOf('{')) {
86
- return expandBraces(patternSegment).map((it) => joinPath(path, it))
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.2.0-alpha.1",
3
+ "version": "3.2.0-alpha.11",
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,11 @@
11
11
  "Balachandran Sivakumar <balachandran@balachandran.org>"
12
12
  ],
13
13
  "homepage": "https://antora.org",
14
- "repository": "gitlab:antora/antora",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://gitlab.com/antora/antora.git",
17
+ "directory": "packages/content-aggregator"
18
+ },
15
19
  "bugs": {
16
20
  "url": "https://gitlab.com/antora/antora/issues"
17
21
  },
@@ -28,24 +32,24 @@
28
32
  "#constants": "./lib/constants.js"
29
33
  },
30
34
  "dependencies": {
31
- "@antora/expand-path-helper": "~2.0",
32
- "@antora/logger": "3.2.0-alpha.1",
33
- "@antora/user-require-helper": "~2.0",
35
+ "@antora/expand-path-helper": "~3.0",
36
+ "@antora/logger": "3.2.0-alpha.11",
37
+ "@antora/user-require-helper": "~3.0",
34
38
  "braces": "~3.0",
35
39
  "cache-directory": "~2.0",
36
- "glob-stream": "~7.0",
37
- "hpagent": "~1.1",
38
- "isomorphic-git": "~1.21",
40
+ "fast-glob": "~3.3",
41
+ "hpagent": "~1.2",
42
+ "isomorphic-git": "~1.25",
39
43
  "js-yaml": "~4.1",
40
44
  "multi-progress": "~4.0",
41
- "picomatch": "~2.3",
45
+ "picomatch": "~4.0",
42
46
  "progress": "~2.0",
43
47
  "should-proxy": "~1.0",
44
48
  "simple-get": "~4.0",
45
- "vinyl": "~2.2"
49
+ "vinyl": "~3.0"
46
50
  },
47
51
  "engines": {
48
- "node": ">=16.0.0"
52
+ "node": ">=18.0.0"
49
53
  },
50
54
  "files": [
51
55
  "lib/"
@@ -62,7 +66,7 @@
62
66
  ],
63
67
  "scripts": {
64
68
  "test": "_mocha",
65
- "prepublishOnly": "node $npm_config_local_prefix/npm/prepublishOnly.js",
66
- "postpublish": "node $npm_config_local_prefix/npm/postpublish.js"
69
+ "prepublishOnly": "npx -y downdoc@latest --prepublish",
70
+ "postpublish": "npx -y downdoc@latest --postpublish"
67
71
  }
68
72
  }