@antora/content-aggregator
Advanced tools
Comparing version 3.0.0-rc.2 to 3.0.0-rc.3
@@ -5,3 +5,3 @@ 'use strict' | ||
const { createHash } = require('crypto') | ||
const createHttpPlugin = require('./git-plugin-http') | ||
const createGitHttpPlugin = require('./git-plugin-http') | ||
const decodeUint8Array = require('./decode-uint8-array') | ||
@@ -421,5 +421,4 @@ const EventEmitter = require('events') | ||
function collectFilesFromStartPath (startPath, repo, authStatus, ref, worktreePath, originUrl, editUrl, version) { | ||
return (worktreePath | ||
? readFilesFromWorktree(worktreePath, startPath) | ||
: readFilesFromGitTree(repo, ref.oid, startPath) | ||
return ( | ||
worktreePath ? readFilesFromWorktree(worktreePath, startPath) : readFilesFromGitTree(repo, ref.oid, startPath) | ||
) | ||
@@ -780,2 +779,3 @@ .then((files) => { | ||
let maxUrlLength = 0 | ||
const width = term.columns | ||
for (const url of urls) { | ||
@@ -787,6 +787,7 @@ if (~url.indexOf(':') && GIT_URI_DETECTOR_RX.test(url)) { | ||
} | ||
const progress = new MultiProgress(term) | ||
// NOTE remove the width of the operation, then partition the difference between the url and bar | ||
progress.maxLabelWidth = Math.min(Math.ceil((term.columns - GIT_OPERATION_LABEL_LENGTH) / 2), maxUrlLength) | ||
return progress | ||
return Object.assign(new MultiProgress(term), { | ||
// NOTE remove the operation width, then partition the difference between the url and bar | ||
maxLabelWidth: Math.min(Math.ceil((width - GIT_OPERATION_LABEL_LENGTH) / 2), maxUrlLength), | ||
width, | ||
}) | ||
} | ||
@@ -796,2 +797,3 @@ } | ||
function createProgressListener (progress, progressLabel, operation) { | ||
const width = progress.width | ||
const progressBar = progress.newBar(formatProgressBar(progressLabel, progress.maxLabelWidth, operation), { | ||
@@ -802,4 +804,5 @@ complete: '#', | ||
total: 100, | ||
width, | ||
}) | ||
const ticks = progressBar.stream.columns - progressBar.fmt.replace(':bar', '').length | ||
const ticks = width - progressBar.fmt.replace(':bar', '').length | ||
// NOTE leave room for indeterminate progress at end of bar; this isn't strictly needed for a bare clone | ||
@@ -945,3 +948,3 @@ progressBar.scaleFactor = Math.max(0, (ticks - 1) / ticks) | ||
if (gitConfig.ensureGitSuffix) urlRouter = { ensureGitSuffix: (url) => (url.endsWith('.git') ? url : url + '.git') } | ||
const http = plugins.get('http') || createHttpPlugin(networkConfig, 'git/isomorphic-git@' + git.version()) | ||
const http = plugins.get('http') || createGitHttpPlugin(networkConfig) | ||
return { credentialManager, http, urlRouter } | ||
@@ -1023,24 +1026,25 @@ } | ||
const patternCache = repo.cache[REF_PATTERN_CACHE_KEY] | ||
return (patterns.length | ||
? fsp | ||
.readdir((worktreesDir = ospath.join(repo.dir, '.git', 'worktrees'))) | ||
.then((worktreeNames) => filterRefs(worktreeNames, patterns, patternCache), invariably.emptyArray) | ||
.then((worktreeNames) => | ||
worktreeNames.length | ||
? Promise.all( | ||
worktreeNames.map((worktreeName) => { | ||
const gitdir = ospath.resolve(worktreesDir, worktreeName) | ||
// NOTE uses name of worktree as branch name if HEAD is detached | ||
return git | ||
.currentBranch(Object.assign({}, repo, { gitdir })) | ||
.then((branch = worktreeName) => | ||
fsp | ||
.readFile(ospath.join(gitdir, 'gitdir'), 'utf8') | ||
.then((contents) => ({ branch, dir: ospath.dirname(contents.trimRight()) })) | ||
) | ||
}) | ||
).then((entries) => entries.reduce((accum, it) => accum.set(it.branch, it.dir), new Map())) | ||
: new Map() | ||
) | ||
: Promise.resolve(new Map()) | ||
return ( | ||
patterns.length | ||
? fsp | ||
.readdir((worktreesDir = ospath.join(repo.dir, '.git', 'worktrees'))) | ||
.then((worktreeNames) => filterRefs(worktreeNames, patterns, patternCache), invariably.emptyArray) | ||
.then((worktreeNames) => | ||
worktreeNames.length | ||
? Promise.all( | ||
worktreeNames.map((worktreeName) => { | ||
const gitdir = ospath.resolve(worktreesDir, worktreeName) | ||
// NOTE uses name of worktree as branch name if HEAD is detached | ||
return git | ||
.currentBranch(Object.assign({}, repo, { gitdir })) | ||
.then((branch = worktreeName) => | ||
fsp | ||
.readFile(ospath.join(gitdir, 'gitdir'), 'utf8') | ||
.then((contents) => ({ branch, dir: ospath.dirname(contents.trimRight()) })) | ||
) | ||
}) | ||
).then((entries) => entries.reduce((accum, it) => accum.set(it.branch, it.dir), new Map())) | ||
: new Map() | ||
) | ||
: Promise.resolve(new Map()) | ||
).then((worktrees) => | ||
@@ -1047,0 +1051,0 @@ linkedOnly |
@@ -5,5 +5,3 @@ 'use strict' | ||
const len = array.length | ||
for (let i = 0, it; i < len; i++) { | ||
Array.isArray((it = array[i])) ? flattenDeep(it, accum) : accum.push(it) | ||
} | ||
for (let i = 0, it; i < len; i++) Array.isArray((it = array[i])) ? flattenDeep(it, accum) : accum.push(it) | ||
return accum | ||
@@ -10,0 +8,0 @@ } |
'use strict' | ||
const get = require('simple-get') | ||
const defaultUserAgent = 'git/isomorphic-git@' + require('./git').version() | ||
@@ -28,3 +29,11 @@ function distillResponse (res) { | ||
module.exports = ({ httpProxy, httpsProxy, noProxy }, userAgent) => { | ||
function mergeHeaders (headers, extraHeaders) { | ||
const mergedHeaders = { 'user-agent': defaultUserAgent } | ||
if (extraHeaders == null) return Object.assign(headers, mergedHeaders) | ||
for (const name in extraHeaders) mergedHeaders[name.toLowerCase()] = extraHeaders[name] | ||
for (const name in headers) mergedHeaders[name.toLowerCase()] = headers[name] | ||
return mergedHeaders | ||
} | ||
module.exports = ({ headers: extraHeaders, httpProxy, httpsProxy, noProxy } = {}) => { | ||
if ((httpsProxy || httpProxy) && noProxy !== '*') { | ||
@@ -35,3 +44,3 @@ const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent') | ||
async request ({ url, method, headers, body }) { | ||
headers['user-agent'] = userAgent | ||
headers = mergeHeaders(headers, extraHeaders) | ||
body = await mergeBuffers(body) | ||
@@ -51,3 +60,3 @@ const proxy = url.startsWith('https:') | ||
async request ({ url, method, headers, body }) { | ||
headers['user-agent'] = userAgent | ||
headers = mergeHeaders(headers, extraHeaders) | ||
body = await mergeBuffers(body) | ||
@@ -54,0 +63,0 @@ return new Promise((resolve, reject) => |
@@ -132,6 +132,3 @@ 'use strict' | ||
(pattern.charAt() === '.' ? '' : '(?!\\.)') + | ||
pattern | ||
.replace(NON_GLOB_SPECIAL_CHARS_RX, '\\$&') | ||
.replace('\\\\*', '\\x2a') | ||
.replace('*', '.*?') | ||
pattern.replace(NON_GLOB_SPECIAL_CHARS_RX, '\\$&').replace('\\\\*', '\\x2a').replace('*', '.*?') | ||
) | ||
@@ -138,0 +135,0 @@ } |
{ | ||
"name": "@antora/content-aggregator", | ||
"version": "3.0.0-rc.2", | ||
"version": "3.0.0-rc.3", | ||
"description": "Fetches and aggregates content from distributed sources for use in an Antora documentation pipeline.", | ||
@@ -55,3 +55,3 @@ "license": "MPL-2.0", | ||
], | ||
"gitHead": "b64861391b7e55ea31fcecce4490b9cc02fec1c7" | ||
"gitHead": "f3b3cbb4a08640bbcf55e685929409e20b186634" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79287
1425
3