diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6f0d299ebe8e5a9323ab308315fa9b6a8b819230..6728b2f05dc58e5bb5e2f207aa2d0ecb9ea7fb4a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -15,6 +15,7 @@ For a detailed view of what's changed, refer to the {url-repo}/commits[commit hi * rename `on_failure` key on run config to `failure`; keep `on_failure` key as alias (#38) * map the `env.PWD` context variable to the resolved value of the `dir` key on the run entry (#31) * cache the result of previous where calls on Windows to avoid redundant lookups (#40) +* load git client from `@antora/content-aggregator` package instead of declaring it as a direct dependency (#39) === Fixed diff --git a/docs/antora.yml b/docs/antora.yml index f4e80f56b3819953c9602268c4a719a0364b7306..ec037815cf422aa54970b0c8dfe33b4e294acd7a 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -4,7 +4,7 @@ version: '1.0' prerelease: '.0-beta.2' asciidoc: attributes: - version-antora-min: '3.1' + version-antora-min: '3.1.2' version-node-min: '16' version-node: '20.16.0' release-version: '1.0.0-beta.2' diff --git a/package-lock.json b/package-lock.json index f4ccd4dc68c57defc72a861c83ff97a85bb5447a..2f7e2e46331e214c9a9480110d3ae45ce9b53e61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -555,7 +555,8 @@ "node_modules/async-lock": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.4.1.tgz", - "integrity": "sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==" + "integrity": "sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==", + "dev": true }, "node_modules/atomic-sleep": { "version": "1.0.0", @@ -748,7 +749,8 @@ "node_modules/clean-git-ref": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/clean-git-ref/-/clean-git-ref-2.0.1.tgz", - "integrity": "sha512-bLSptAy2P0s6hU4PzuIMKmMJJSE6gLXGH1cntDu7bWJUksvuM+7ReOK61mozULErYvP6a15rnYl0zFDef+pyPw==" + "integrity": "sha512-bLSptAy2P0s6hU4PzuIMKmMJJSE6gLXGH1cntDu7bWJUksvuM+7ReOK61mozULErYvP6a15rnYl0zFDef+pyPw==", + "dev": true }, "node_modules/clone": { "version": "2.1.2", @@ -808,6 +810,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "dev": true, "bin": { "crc32": "bin/crc32.njs" }, @@ -913,6 +916,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, "dependencies": { "mimic-response": "^3.1.0" }, @@ -968,7 +972,8 @@ "node_modules/diff3": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/diff3/-/diff3-0.0.3.tgz", - "integrity": "sha512-iSq8ngPOt0K53A6eVr4d5Kn6GNrM2nQZtC740pzIriHtn4pOQ2lyzEXQMBeVcWERN0ye7fhBsk9PbLLQOnUx/g==" + "integrity": "sha512-iSq8ngPOt0K53A6eVr4d5Kn6GNrM2nQZtC740pzIriHtn4pOQ2lyzEXQMBeVcWERN0ye7fhBsk9PbLLQOnUx/g==", + "dev": true }, "node_modules/dir-glob": { "version": "3.0.1", @@ -2066,6 +2071,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, "engines": { "node": ">= 4" } @@ -2118,7 +2124,8 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/internal-slot": { "version": "1.0.7", @@ -2419,6 +2426,7 @@ "version": "1.25.10", "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.25.10.tgz", "integrity": "sha512-IxGiaKBwAdcgBXwIcxJU6rHLk+NrzYaaPKXXQffcA0GW3IUrQXdUPDXDo+hkGVcYruuz/7JlGBiuaeTCgIgivQ==", + "dev": true, "dependencies": { "async-lock": "^1.4.1", "clean-git-ref": "^2.0.1", @@ -2660,6 +2668,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, "engines": { "node": ">=10" }, @@ -2683,6 +2692,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -2691,6 +2701,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/minimisted/-/minimisted-2.0.1.tgz", "integrity": "sha512-1oPjfuLQa2caorJUM8HV8lGgWCc0qqAO1MNv/k05G4qslmsndV/5WdNZrqCiyqiz3wohia2Ij2B7w2Dr7/IyrA==", + "dev": true, "dependencies": { "minimist": "^1.2.5" } @@ -2833,6 +2844,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -2887,7 +2899,8 @@ "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", - "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true }, "node_modules/parent-module": { "version": "1.0.1", @@ -2959,6 +2972,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, "engines": { "node": ">=6" } @@ -3232,6 +3246,7 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -3399,6 +3414,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -3495,6 +3511,7 @@ "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -3553,6 +3570,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "dev": true, "funding": [ { "type": "github", @@ -3572,6 +3590,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "dev": true, "funding": [ { "type": "github", @@ -3637,6 +3656,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -3987,7 +4007,8 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true }, "node_modules/vinyl": { "version": "3.0.0", @@ -4105,7 +4126,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/xdg-basedir": { "version": "3.0.0", @@ -4135,7 +4157,6 @@ "@antora/expand-path-helper": "~2.0", "cache-directory": "~2.0", "fast-glob": "~3.3", - "isomorphic-git": "~1.25", "js-yaml": "~4.1" }, "devDependencies": { diff --git a/packages/collector-extension/lib/index.js b/packages/collector-extension/lib/index.js index db07940c8f3ff33b61a6abd1bbf99c82c7564d3a..40e5c10982d39c09a62739c2fdbdb27830a49da7 100644 --- a/packages/collector-extension/lib/index.js +++ b/packages/collector-extension/lib/index.js @@ -5,7 +5,6 @@ const expandPath = require('@antora/expand-path-helper') const fs = require('node:fs') const { promises: fsp } = fs const getUserCacheDir = require('cache-directory') -const git = require('isomorphic-git') const { globStream } = require('fast-glob') const invariably = { false: () => false, null: () => null, void: () => undefined } const ospath = require('node:path') @@ -28,6 +27,7 @@ module.exports.register = function ({ config: { createWorktrees = 'auto', keepWo const quiet = playbook.runtime?.quiet const cacheDir = ospath.join(getBaseCacheDir(playbook), 'collector') await fsp.mkdir(cacheDir, { recursive: true }) + const git = this.require('@antora/content-aggregator/git') const gitCache = {} const runCache = { where: {} } const managedWorktrees = new Map() @@ -119,7 +119,7 @@ module.exports.register = function ({ config: { createWorktrees = 'auto', keepWo const cache = gitCache[gitdir] || (gitCache[gitdir] = {}) const ref = `refs/${reftype === 'branch' ? 'head' : reftype}s/${refname}` const bare = worktree === undefined - await prepareWorktree({ fs, cache, dir: worktreeDir, gitdir, ref, remote, bare }) + await prepareWorktree(git, { fs, cache, dir: worktreeDir, gitdir, ref, remote, bare }) } else { await fsp.mkdir(worktreeDir, { recursive: true }) } @@ -218,7 +218,7 @@ module.exports.register = function ({ config: { createWorktrees = 'auto', keepWo * a fresh worktree is created. If the gitdir contains an index file, that index file is temporarily overwritten to * prepare the worktree and later restored before the function returns. */ -async function prepareWorktree (repo) { +async function prepareWorktree (git, repo) { const { dir: worktreeDir, gitdir, ref, remote = 'origin', bare, cache } = repo delete repo.remote const currentIndexPath = ospath.join(gitdir, 'index') @@ -230,7 +230,7 @@ async function prepareWorktree (repo) { let force = true try { await mv(worktreeIndexPath, currentIndexPath) // isomorphic-git requires index to be in commondir - await removeUntrackedFiles(repo) + await removeUntrackedFiles(git, repo) } catch { force = false await fsp.unlink(currentIndexPath).catch(invariably.void) // index file not needed in this case @@ -313,7 +313,7 @@ function srcFs (cwd, globs = '**/*', into) { ) } -function removeUntrackedFiles (repo) { +function removeUntrackedFiles (git, repo) { const trees = [git.STAGE({}), git.WORKDIR()] const map = (relpath, [sEntry]) => { if (relpath === '.') return diff --git a/packages/collector-extension/package.json b/packages/collector-extension/package.json index e4c9bf61d7475fbec0d9fefc2ae9bd5d73159816..b98aec9935246726932879175263179ab581d0e1 100644 --- a/packages/collector-extension/package.json +++ b/packages/collector-extension/package.json @@ -35,7 +35,6 @@ "@antora/expand-path-helper": "~2.0", "cache-directory": "~2.0", "fast-glob": "~3.3", - "isomorphic-git": "~1.25", "js-yaml": "~4.1" }, "devDependencies": {