@vltpkg/git 0.0.0-0.1730239248325 → 0.0.0-0.1730724342581
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.
- package/README.md +13 -3
- package/dist/esm/clone.d.ts +1 -1
- package/dist/esm/clone.d.ts.map +1 -1
- package/dist/esm/clone.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lines-to-revs.d.ts +1 -1
- package/dist/esm/lines-to-revs.d.ts.map +1 -1
- package/dist/esm/lines-to-revs.js.map +1 -1
- package/dist/esm/make-error.d.ts +1 -1
- package/dist/esm/make-error.d.ts.map +1 -1
- package/dist/esm/make-error.js.map +1 -1
- package/dist/esm/opts.d.ts +2 -2
- package/dist/esm/opts.d.ts.map +1 -1
- package/dist/esm/opts.js.map +1 -1
- package/dist/esm/resolve.d.ts +1 -1
- package/dist/esm/resolve.d.ts.map +1 -1
- package/dist/esm/resolve.js.map +1 -1
- package/dist/esm/revs.d.ts +2 -2
- package/dist/esm/revs.d.ts.map +1 -1
- package/dist/esm/revs.js.map +1 -1
- package/dist/esm/spawn.d.ts +2 -2
- package/dist/esm/spawn.d.ts.map +1 -1
- package/dist/esm/spawn.js.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# @vltpkg/git
|
|
2
4
|
|
|
3
5
|
A utility for spawning git from npm CLI contexts.
|
|
4
6
|
|
|
7
|
+
**[Usage](#usage)**
|
|
8
|
+
·
|
|
9
|
+
**[API](#api)**
|
|
10
|
+
·
|
|
11
|
+
**[Options](#options)**
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
5
15
|
This is _not_ an implementation of git itself, it's just a thing that
|
|
6
16
|
spawns child processes to tell the system git CLI implementation to do
|
|
7
17
|
stuff.
|
|
8
18
|
|
|
9
19
|
Fork of `@npmcli/git`.
|
|
10
20
|
|
|
11
|
-
##
|
|
21
|
+
## Usage
|
|
12
22
|
|
|
13
23
|
```js
|
|
14
24
|
import { clone, spawn } from '@vltpkg/git'
|
|
@@ -141,7 +151,7 @@ This will resolve `true` if the git working dir is clean, or
|
|
|
141
151
|
`false` if not, and reject if the path is not within a git
|
|
142
152
|
directory or some other error occurs.
|
|
143
153
|
|
|
144
|
-
##
|
|
154
|
+
## Options
|
|
145
155
|
|
|
146
156
|
- `retry` An object to configure retry behavior for transient network
|
|
147
157
|
errors with exponential backoff.
|
package/dist/esm/clone.d.ts
CHANGED
package/dist/esm/clone.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/clone.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/clone.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAM5C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,aAMvB,CAAA;AAEF,eAAO,MAAM,KAAK,SACV,MAAM,yBAEJ,MAAM,GAAG,SAAS,SACpB,UAAU,wCAajB,CAAA"}
|
package/dist/esm/clone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/clone.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mDAAmD;AACnD,EAAE;AACF,wDAAwD;AACxD,uDAAuD;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,a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C,EACtD,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CACzB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,KAAK,EACtB,IAAY,EACZ,GAAW,EACX,MAAc,EACd,IAAgB,EAChB,EAAE;IACF,gEAAgE;IAChE,gEAAgE;IAChE,MAAM,EAAE,GACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5D,MAAM,SAAS,GAAG;QAChB,OAAO;QACP,UAAU;QACV,IAAI;QACJ,IAAI;QACJ,MAAM,GAAG,OAAO;KACjB,CAAA;IACD,MAAM,GAAG,GAAG,CAAC,IAAc,EAAE,EAAE,CAC7B,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IACvC,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,MAAM,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACnB,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;IAC5B,MAAM,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAA;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// The goal here is to minimize both git workload and\n// the number of refs we download over the network.\n//\n// Every method ends up with the checked out working dir\n// at the specified ref, and resolves with the git sha.\n\nimport { RevDoc, RevDocEntry } from '@vltpkg/types'\nimport { gitScpURL } from '@vltpkg/git-scp-url'\nimport { mkdir, stat } from 'fs/promises'\nimport { basename, resolve } from 'path'\nimport { fileURLToPath } from 'url'\nimport { GitOptions } from './index.js'\nimport { isWindows } from './is-windows.js'\nimport { resolveRef } from './resolve.js'\nimport { revs as getRevs } from './revs.js'\nimport { spawn } from './spawn.js'\n\n/**\n * Only these whitelisted hosts get shallow cloning. Many hosts (including GHE)\n * don't always support it. A failed shallow fetch takes a LOT longer than a\n * full fetch in most cases, so we skip it entirely. Set opts.gitShallow =\n * true/false to force this behavior one way or the other.\n *\n * If other hosts are added to this set, then they will be shallowly cloned\n * as well.\n */\nexport const shallowHosts = new Set([\n 'github.com',\n 'gist.github.com',\n 'gitlab.com',\n 'bitbucket.com',\n 'bitbucket.org',\n])\n\nexport const clone = async (\n repo: string,\n ref = 'HEAD',\n target: string | undefined = undefined,\n opts: GitOptions = {},\n) => {\n repo = String(gitScpURL(repo) ?? repo).replace(/^git\\+/, '')\n if (repo.startsWith('file://')) repo = fileURLToPath(repo)\n const revs = await getRevs(repo, opts)\n return await clone_(\n repo,\n revs,\n ref,\n revs && resolveRef(revs, ref, opts),\n target || defaultTarget(repo, opts.cwd),\n opts,\n )\n}\n\nconst maybeShallow = (repo: string, opts: GitOptions) => {\n if (opts['git-shallow'] === false || opts['git-shallow']) {\n return opts['git-shallow']\n }\n const host = gitScpURL(repo)?.host ?? ''\n return shallowHosts.has(host)\n}\n\nconst defaultTarget = (\n repo: string,\n /* c8 ignore next */ cwd = process.cwd(),\n) => resolve(cwd, basename(repo.replace(/[/\\\\]?\\.git$/, '')))\n\nconst clone_ = (\n repo: string,\n revs: RevDoc | undefined,\n ref: string,\n revDoc: RevDocEntry | undefined,\n target: string,\n opts: GitOptions,\n) => {\n if (!revDoc || !revs) {\n return unresolved(repo, ref, target, opts)\n }\n if (revDoc.sha === revs.refs.HEAD?.sha) {\n return plain(repo, revDoc, target, opts)\n }\n if (revDoc.type === 'tag' || revDoc.type === 'branch') {\n return branch(repo, revDoc, target, opts)\n }\n return other(repo, revDoc, target, opts)\n}\n\n// pull request or some other kind of advertised ref\nconst other = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const shallow = maybeShallow(repo, opts)\n\n const fetchOrigin = ['fetch', 'origin', revDoc.rawRef].concat(\n shallow ? ['--depth=1'] : [],\n )\n\n const git = (args: string[]) =>\n spawn(args, { ...opts, cwd: target })\n await mkdir(target, { recursive: true })\n await git(['init'])\n if (isWindows(opts)) {\n await git([\n 'config',\n '--local',\n '--add',\n 'core.longpaths',\n 'true',\n ])\n }\n await git(['remote', 'add', 'origin', repo])\n await git(fetchOrigin)\n await git(['checkout', revDoc.sha])\n await updateSubmodules(target, opts)\n return revDoc.sha\n}\n\n// tag or branches. use -b\nconst branch = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const args = [\n 'clone',\n '-b',\n revDoc.ref,\n repo,\n target,\n '--recurse-submodules',\n ]\n if (maybeShallow(repo, opts)) {\n args.push('--depth=1')\n }\n if (isWindows(opts)) {\n args.push('--config', 'core.longpaths=true')\n }\n await spawn(args, opts)\n return revDoc.sha\n}\n\n// just the head. clone it\nconst plain = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const args = ['clone', repo, target, '--recurse-submodules']\n if (maybeShallow(repo, opts)) {\n args.push('--depth=1')\n }\n if (isWindows(opts)) {\n args.push('--config', 'core.longpaths=true')\n }\n await spawn(args, opts)\n return revDoc.sha\n}\n\nconst updateSubmodules = async (target: string, opts: GitOptions) => {\n const hasSubmodules = await stat(`${target}/.gitmodules`)\n .then(() => true)\n .catch(() => false)\n if (!hasSubmodules) {\n return\n }\n await spawn(\n ['submodule', 'update', '-q', '--init', '--recursive'],\n { ...opts, cwd: target },\n )\n}\n\nconst unresolved = async (\n repo: string,\n ref: string,\n target: string,\n opts: GitOptions,\n) => {\n // can't do this one shallowly, because the ref isn't advertised\n // but we can avoid checking out the working dir twice, at least\n const lp =\n isWindows(opts) ? ['--config', 'core.longpaths=true'] : []\n const cloneArgs = [\n 'clone',\n '--mirror',\n '-q',\n repo,\n target + '/.git',\n ]\n const git = (args: string[]) =>\n spawn(args, { ...opts, cwd: target })\n await mkdir(target, { recursive: true })\n await git(cloneArgs.concat(lp))\n await git(['init'])\n await git(['checkout', ref])\n await updateSubmodules(target, opts)\n const result = await git(['rev-parse', '--revs-only', 'HEAD'])\n return result.stdout\n}\n"]}
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/clone.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mDAAmD;AACnD,EAAE;AACF,wDAAwD;AACxD,uDAAuD;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAClC,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,eAAe;IACf,eAAe;CAChB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAY,EACZ,GAAG,GAAG,MAAM,EACZ,SAA6B,SAAS,EACtC,OAAmB,EAAE,EACrB,EAAE;IACF,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,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AAI,EAAE,CAAC,CAAA;IACxC,MAAM,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACnB,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;IAC5B,MAAM,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAA;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// The goal here is to minimize both git workload and\n// the number of refs we download over the network.\n//\n// Every method ends up with the checked out working dir\n// at the specified ref, and resolves with the git sha.\n\nimport { type RevDoc, type RevDocEntry } from '@vltpkg/types'\nimport { gitScpURL } from '@vltpkg/git-scp-url'\nimport { mkdir, stat } from 'fs/promises'\nimport { basename, resolve } from 'path'\nimport { fileURLToPath } from 'url'\nimport { type GitOptions } from './index.js'\nimport { isWindows } from './is-windows.js'\nimport { resolveRef } from './resolve.js'\nimport { revs as getRevs } from './revs.js'\nimport { spawn } from './spawn.js'\n\n/**\n * Only these whitelisted hosts get shallow cloning. Many hosts (including GHE)\n * don't always support it. A failed shallow fetch takes a LOT longer than a\n * full fetch in most cases, so we skip it entirely. Set opts.gitShallow =\n * true/false to force this behavior one way or the other.\n *\n * If other hosts are added to this set, then they will be shallowly cloned\n * as well.\n */\nexport const shallowHosts = new Set([\n 'github.com',\n 'gist.github.com',\n 'gitlab.com',\n 'bitbucket.com',\n 'bitbucket.org',\n])\n\nexport const clone = async (\n repo: string,\n ref = 'HEAD',\n target: string | undefined = undefined,\n opts: GitOptions = {},\n) => {\n repo = String(gitScpURL(repo) ?? repo).replace(/^git\\+/, '')\n if (repo.startsWith('file://')) repo = fileURLToPath(repo)\n const revs = await getRevs(repo, opts)\n return await clone_(\n repo,\n revs,\n ref,\n revs && resolveRef(revs, ref, opts),\n target || defaultTarget(repo, opts.cwd),\n opts,\n )\n}\n\nconst maybeShallow = (repo: string, opts: GitOptions) => {\n if (opts['git-shallow'] === false || opts['git-shallow']) {\n return opts['git-shallow']\n }\n const host = gitScpURL(repo)?.host ?? ''\n return shallowHosts.has(host)\n}\n\nconst defaultTarget = (\n repo: string,\n /* c8 ignore next */ cwd = process.cwd(),\n) => resolve(cwd, basename(repo.replace(/[/\\\\]?\\.git$/, '')))\n\nconst clone_ = (\n repo: string,\n revs: RevDoc | undefined,\n ref: string,\n revDoc: RevDocEntry | undefined,\n target: string,\n opts: GitOptions,\n) => {\n if (!revDoc || !revs) {\n return unresolved(repo, ref, target, opts)\n }\n if (revDoc.sha === revs.refs.HEAD?.sha) {\n return plain(repo, revDoc, target, opts)\n }\n if (revDoc.type === 'tag' || revDoc.type === 'branch') {\n return branch(repo, revDoc, target, opts)\n }\n return other(repo, revDoc, target, opts)\n}\n\n// pull request or some other kind of advertised ref\nconst other = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const shallow = maybeShallow(repo, opts)\n\n const fetchOrigin = ['fetch', 'origin', revDoc.rawRef].concat(\n shallow ? ['--depth=1'] : [],\n )\n\n const git = (args: string[]) =>\n spawn(args, { ...opts, cwd: target })\n await mkdir(target, { recursive: true })\n await git(['init'])\n if (isWindows(opts)) {\n await git([\n 'config',\n '--local',\n '--add',\n 'core.longpaths',\n 'true',\n ])\n }\n await git(['remote', 'add', 'origin', repo])\n await git(fetchOrigin)\n await git(['checkout', revDoc.sha])\n await updateSubmodules(target, opts)\n return revDoc.sha\n}\n\n// tag or branches. use -b\nconst branch = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const args = [\n 'clone',\n '-b',\n revDoc.ref,\n repo,\n target,\n '--recurse-submodules',\n ]\n if (maybeShallow(repo, opts)) {\n args.push('--depth=1')\n }\n if (isWindows(opts)) {\n args.push('--config', 'core.longpaths=true')\n }\n await spawn(args, opts)\n return revDoc.sha\n}\n\n// just the head. clone it\nconst plain = async (\n repo: string,\n revDoc: RevDocEntry,\n target: string,\n opts: GitOptions,\n) => {\n const args = ['clone', repo, target, '--recurse-submodules']\n if (maybeShallow(repo, opts)) {\n args.push('--depth=1')\n }\n if (isWindows(opts)) {\n args.push('--config', 'core.longpaths=true')\n }\n await spawn(args, opts)\n return revDoc.sha\n}\n\nconst updateSubmodules = async (target: string, opts: GitOptions) => {\n const hasSubmodules = await stat(`${target}/.gitmodules`)\n .then(() => true)\n .catch(() => false)\n if (!hasSubmodules) {\n return\n }\n await spawn(\n ['submodule', 'update', '-q', '--init', '--recursive'],\n { ...opts, cwd: target },\n )\n}\n\nconst unresolved = async (\n repo: string,\n ref: string,\n target: string,\n opts: GitOptions,\n) => {\n // can't do this one shallowly, because the ref isn't advertised\n // but we can avoid checking out the working dir twice, at least\n const lp =\n isWindows(opts) ? ['--config', 'core.longpaths=true'] : []\n const cloneArgs = [\n 'clone',\n '--mirror',\n '-q',\n repo,\n target + '/.git',\n ]\n const git = (args: string[]) =>\n spawn(args, { ...opts, cwd: target })\n await mkdir(target, { recursive: true })\n await git(cloneArgs.concat(lp))\n await git(['init'])\n await git(['checkout', ref])\n await updateSubmodules(target, opts)\n const result = await git(['rev-parse', '--revs-only', 'HEAD'])\n return result.stdout\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
1
|
+
import { type PickManifestOptions } from '@vltpkg/pick-manifest';
|
|
2
|
+
import { type Spec } from '@vltpkg/spec';
|
|
3
|
+
import { type SpawnOptions } from 'child_process';
|
|
4
|
+
import { type WrapOptions } from 'retry';
|
|
5
5
|
export * from './clone.js';
|
|
6
6
|
export * from './find.js';
|
|
7
7
|
export * from './is-clean.js';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAA;AAExC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAE1B;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAC1C,YAAY,GAAG;IACb,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACpB,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IACxC,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IAC5C;;;OAGG;IACH,wBAAwB,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACpD;;;OAGG;IACH,wBAAwB,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACpD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAA;IAC9B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA"}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA","sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA","sourcesContent":["import { type PickManifestOptions } from '@vltpkg/pick-manifest'\nimport { type Spec } from '@vltpkg/spec'\nimport { type SpawnOptions } from 'child_process'\nimport { type WrapOptions } from 'retry'\n\nexport * from './clone.js'\nexport * from './find.js'\nexport * from './is-clean.js'\nexport * from './is.js'\nexport * from './resolve.js'\nexport * from './revs.js'\nexport * from './spawn.js'\n\n/**\n * This extends all options that can be passed to spawn() or pickManifest.\n */\nexport type GitOptions = PickManifestOptions &\n SpawnOptions & {\n /** the path to git binary, or 'false' to prevent all git operations */\n git?: string | false\n /** the current working directory to perform git operations in */\n cwd?: string\n /** Parsed git specifier to be cloned, if we have one */\n spec?: Spec\n /**\n * Set to a boolean to force cloning with/without `--depth=1`. If left\n * undefined, then shallow cloning will only be performed on hosts known to\n * support it.\n */\n 'git-shallow'?: boolean\n /** Only relevant if `retry` is unset. Value for retry.retries, default 2 */\n 'fetch-retries'?: WrapOptions['retries']\n /** Only relevant if `retry` is unset. Value for retry.factor, default 10 */\n 'fetch-retry-factor'?: WrapOptions['factor']\n /**\n * Only relevant if `retry` is unset. Value for retry.maxTimeout, default\n * 60_000\n */\n 'fetch-retry-maxtimeout'?: WrapOptions['maxTimeout']\n /**\n * Only relevant if `retry` is unset. Value for retry.minTimeout, default\n * 1_000\n */\n 'fetch-retry-mintimeout'?: WrapOptions['minTimeout']\n /**\n * Used to test platform-specific behavior.\n * @internal\n */\n fakePlatform?: NodeJS.Platform\n /**\n * Just to test rev lookup without continually clearing the cache\n */\n noGitRevCache?: boolean\n }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lines-to-revs.d.ts","sourceRoot":"","sources":["../../src/lines-to-revs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lines-to-revs.d.ts","sourceRoot":"","sources":["../../src/lines-to-revs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAGZ,MAAM,eAAe,CAAA;AAItB;;;GAGG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,EAAE,KAAG,MAS3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lines-to-revs.js","sourceRoot":"","sources":["../../src/lines-to-revs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAe,EAAU,EAAE,CACrD,MAAM,CACJ,KAAK,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAC/B,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,EAAE;IACf,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;CACT,CAAC,CACH,CAAA;AAEH,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE,CACtC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CA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IAAI,KAAK,KAAK,EAAE,CAAC;QACvB,+DAA+D;QAC/D,oCAAoC;QACpC,MAAM,KAAK,GACT,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACvB,IAAI;YACN,CAAC,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACjD,IAAI,KAAK,EAAE,CAAC;YACV,qBAAqB;YACrB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;YACvD,oBAAoB;YACpB,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YACzB,IAAI,CAAC;gBAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { RevDoc, RevDocEntry, RefType } from '@vltpkg/types'\nimport { parse } from '@vltpkg/semver'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * turn an array of lines from `git ls-remote` into a thing\n * vaguely resembling a packument, where docs are a resolved ref\n */\nexport const linesToRevs = (lines: string[]): RevDoc =>\n finish(\n lines.reduce(linesToRevsReducer, {\n name: '',\n versions: {},\n 'dist-tags': {},\n refs: {},\n shas: {},\n }),\n )\n\nconst finish = (revs: RevDoc): RevDoc =>\n distTags(versions(shaList(peelTags(revs))))\n\nconst versions = (revs: RevDoc): RevDoc => {\n for (const [version, entry] of Object.entries(revs.versions)) {\n entry.version = version\n }\n return revs\n}\n\n// We can check out shallow clones on specific SHAs if we have a ref\nconst shaList = (revs: RevDoc): RevDoc => {\n Object.entries(revs.refs).forEach(([ref, doc]) => {\n const shas = revs.shas[doc.sha]\n if (!shas) {\n revs.shas[doc.sha] = [ref]\n } else {\n shas.push(ref)\n }\n })\n return revs\n}\n\n// Replace any tags with their ^{} counterparts, if those exist\nconst peelTags = (revs: RevDoc) => {\n Object.entries(revs.refs)\n .filter(([ref]) => ref.endsWith('^{}'))\n .forEach(([ref, peeled]) => {\n const unpeeled = revs.refs[ref.replace(/\\^\\{\\}$/, '')]\n if (unpeeled) {\n unpeeled.sha = peeled.sha\n delete revs.refs[ref]\n }\n })\n return revs\n}\n\nconst distTags = (revs: RevDoc) => {\n // not entirely sure what situations would result in an\n // ichabod repo, but best to be careful in Sleepy Hollow anyway\n /* c8 ignore start */\n const HEAD = revs.refs.HEAD ?? {\n sha: undefined,\n }\n /* c8 ignore stop */\n for (const [v, ver] of Object.entries(revs.versions)) {\n // simulate a dist-tags with latest pointing at the\n // 'latest' branch if one exists and is a version,\n // or HEAD if not.\n if (revs.refs.latest && ver.sha === revs.refs.latest.sha) {\n revs['dist-tags'].latest = v\n } else if (ver.sha === HEAD.sha) {\n revs['dist-tags'].HEAD = v\n if (!revs.refs.latest) {\n revs['dist-tags'].latest = v\n }\n }\n }\n return revs\n}\n\nconst refType = (ref: string): RefType => {\n if (ref.startsWith('refs/tags/')) {\n return 'tag'\n }\n if (ref.startsWith('refs/heads/')) {\n return 'branch'\n }\n if (ref.startsWith('refs/pull/')) {\n return 'pull'\n }\n if (ref === 'HEAD') {\n return 'head'\n }\n // Could be anything, ignore for now\n /* c8 ignore next */\n return 'other'\n}\n\n// return the doc, or null if we should ignore it.\nconst lineToRevDoc = (line: string): RevDocEntry | undefined => {\n let [sha, rawRef] = line.trim().split(/\\s+/, 2)\n if (sha === undefined || rawRef === undefined) return undefined\n sha = sha.trim()\n rawRef = rawRef.trim()\n\n const type = refType(rawRef)\n\n switch (type) {\n case 'tag': {\n // refs/tags/foo^{} is the 'peeled tag', ie the commit\n // that is tagged by refs/tags/foo they resolve to the same\n // content, just different objects in git's data structure.\n // But, we care about the thing the tag POINTS to, not the tag\n // object itself, so we only look at the peeled tag refs, and\n // ignore the pointer.\n // For now, though, we have to save both, because some tags\n // don't have peels, if they were not annotated.\n const ref = rawRef.slice('refs/tags/'.length)\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'branch': {\n const ref = rawRef.slice('refs/heads/'.length)\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'pull': {\n // NB: merged pull requests installable with #pull/123/merge\n // for the merged pr, or #pull/123 for the PR head\n const ref = rawRef.slice('refs/'.length).replace(/\\/head$/, '')\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'head': {\n const ref = 'HEAD'\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n default:\n // at this point, all we can do is leave the ref un-munged\n return { name: '', version: '', sha, ref: rawRef, rawRef, type }\n }\n}\n\nconst linesToRevsReducer = (revs: RevDoc, line: string) => {\n const doc = lineToRevDoc(line)\n\n if (!doc) {\n return revs\n }\n\n revs.refs[doc.ref] = doc\n revs.refs[doc.rawRef] = doc\n\n if (doc.type === 'tag') {\n // try to pull a semver value out of tags like `release-v1.2.3`\n // which is a pretty common pattern.\n const match =\n doc.ref.endsWith('^{}') ?\n null\n : /v?(\\d+\\.\\d+\\.\\d+(?:[-+].+)?)$/.exec(doc.ref)\n if (match) {\n /* c8 ignore start */\n if (!match[1])\n throw error(`invalid semver tag`, { found: doc.ref })\n /* c8 ignore stop */\n const v = parse(match[1])\n if (v) revs.versions[String(v)] = doc\n }\n }\n\n return revs\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lines-to-revs.js","sourceRoot":"","sources":["../../src/lines-to-revs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAe,EAAU,EAAE,CACrD,MAAM,CACJ,KAAK,CAAC,MAAM,CAAC,kBAAkB,EAAE;IAC/B,IAAI,EAAE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AAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;IACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAA;IAE3B,IAAI,GAAG,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACvB,+DAA+D;QAC/D,oCAAoC;QACpC,MAAM,KAAK,GACT,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACvB,IAAI;YACN,CAAC,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACjD,IAAI,KAAK,EAAE,CAAC;YACV,qBAAqB;YACrB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;YACvD,oBAAoB;YACpB,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YACzB,IAAI,CAAC;gBAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import {\n type RevDoc,\n type RevDocEntry,\n type RefType,\n} from '@vltpkg/types'\nimport { parse } from '@vltpkg/semver'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * turn an array of lines from `git ls-remote` into a thing\n * vaguely resembling a packument, where docs are a resolved ref\n */\nexport const linesToRevs = (lines: string[]): RevDoc =>\n finish(\n lines.reduce(linesToRevsReducer, {\n name: '',\n versions: {},\n 'dist-tags': {},\n refs: {},\n shas: {},\n }),\n )\n\nconst finish = (revs: RevDoc): RevDoc =>\n distTags(versions(shaList(peelTags(revs))))\n\nconst versions = (revs: RevDoc): RevDoc => {\n for (const [version, entry] of Object.entries(revs.versions)) {\n entry.version = version\n }\n return revs\n}\n\n// We can check out shallow clones on specific SHAs if we have a ref\nconst shaList = (revs: RevDoc): RevDoc => {\n Object.entries(revs.refs).forEach(([ref, doc]) => {\n const shas = revs.shas[doc.sha]\n if (!shas) {\n revs.shas[doc.sha] = [ref]\n } else {\n shas.push(ref)\n }\n })\n return revs\n}\n\n// Replace any tags with their ^{} counterparts, if those exist\nconst peelTags = (revs: RevDoc) => {\n Object.entries(revs.refs)\n .filter(([ref]) => ref.endsWith('^{}'))\n .forEach(([ref, peeled]) => {\n const unpeeled = revs.refs[ref.replace(/\\^\\{\\}$/, '')]\n if (unpeeled) {\n unpeeled.sha = peeled.sha\n delete revs.refs[ref]\n }\n })\n return revs\n}\n\nconst distTags = (revs: RevDoc) => {\n // not entirely sure what situations would result in an\n // ichabod repo, but best to be careful in Sleepy Hollow anyway\n /* c8 ignore start */\n const HEAD = revs.refs.HEAD ?? {\n sha: undefined,\n }\n /* c8 ignore stop */\n for (const [v, ver] of Object.entries(revs.versions)) {\n // simulate a dist-tags with latest pointing at the\n // 'latest' branch if one exists and is a version,\n // or HEAD if not.\n if (revs.refs.latest && ver.sha === revs.refs.latest.sha) {\n revs['dist-tags'].latest = v\n } else if (ver.sha === HEAD.sha) {\n revs['dist-tags'].HEAD = v\n if (!revs.refs.latest) {\n revs['dist-tags'].latest = v\n }\n }\n }\n return revs\n}\n\nconst refType = (ref: string): RefType => {\n if (ref.startsWith('refs/tags/')) {\n return 'tag'\n }\n if (ref.startsWith('refs/heads/')) {\n return 'branch'\n }\n if (ref.startsWith('refs/pull/')) {\n return 'pull'\n }\n if (ref === 'HEAD') {\n return 'head'\n }\n // Could be anything, ignore for now\n /* c8 ignore next */\n return 'other'\n}\n\n// return the doc, or null if we should ignore it.\nconst lineToRevDoc = (line: string): RevDocEntry | undefined => {\n let [sha, rawRef] = line.trim().split(/\\s+/, 2)\n if (sha === undefined || rawRef === undefined) return undefined\n sha = sha.trim()\n rawRef = rawRef.trim()\n\n const type = refType(rawRef)\n\n switch (type) {\n case 'tag': {\n // refs/tags/foo^{} is the 'peeled tag', ie the commit\n // that is tagged by refs/tags/foo they resolve to the same\n // content, just different objects in git's data structure.\n // But, we care about the thing the tag POINTS to, not the tag\n // object itself, so we only look at the peeled tag refs, and\n // ignore the pointer.\n // For now, though, we have to save both, because some tags\n // don't have peels, if they were not annotated.\n const ref = rawRef.slice('refs/tags/'.length)\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'branch': {\n const ref = rawRef.slice('refs/heads/'.length)\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'pull': {\n // NB: merged pull requests installable with #pull/123/merge\n // for the merged pr, or #pull/123 for the PR head\n const ref = rawRef.slice('refs/'.length).replace(/\\/head$/, '')\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n case 'head': {\n const ref = 'HEAD'\n return { name: '', version: '', sha, ref, rawRef, type }\n }\n\n default:\n // at this point, all we can do is leave the ref un-munged\n return { name: '', version: '', sha, ref: rawRef, rawRef, type }\n }\n}\n\nconst linesToRevsReducer = (revs: RevDoc, line: string) => {\n const doc = lineToRevDoc(line)\n\n if (!doc) {\n return revs\n }\n\n revs.refs[doc.ref] = doc\n revs.refs[doc.rawRef] = doc\n\n if (doc.type === 'tag') {\n // try to pull a semver value out of tags like `release-v1.2.3`\n // which is a pretty common pattern.\n const match =\n doc.ref.endsWith('^{}') ?\n null\n : /v?(\\d+\\.\\d+\\.\\d+(?:[-+].+)?)$/.exec(doc.ref)\n if (match) {\n /* c8 ignore start */\n if (!match[1])\n throw error(`invalid semver tag`, { found: doc.ref })\n /* c8 ignore stop */\n const v = parse(match[1])\n if (v) revs.versions[String(v)] = doc\n }\n }\n\n return revs\n}\n"]}
|
package/dist/esm/make-error.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpawnResultStderr, SpawnResultString } from '@vltpkg/promise-spawn';
|
|
1
|
+
import { type SpawnResultStderr, type SpawnResultString } from '@vltpkg/promise-spawn';
|
|
2
2
|
export declare const makeError: (result: SpawnResultStderr & SpawnResultString) => Error & {
|
|
3
3
|
shouldRetry: (n: number) => boolean;
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-error.d.ts","sourceRoot":"","sources":["../../src/make-error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"make-error.d.ts","sourceRoot":"","sources":["../../src/make-error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAA;AAoB9B,eAAO,MAAM,SAAS,WACZ,iBAAiB,GAAG,iBAAiB,KAC5C,KAAK,GAAG;IAAE,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAY3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-error.js","sourceRoot":"","sources":["../../src/make-error.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC;IACE,qCAAqC;IACrC,qCAAqC;IACrC,sBAAsB;IACtB,qBAAqB;IACrB,mCAAmC;IACnC,0BAA0B;IAC1B,mBAAmB;IACnB,uCAAuC;CACxC,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAA;AAED,MAAM,iBAAiB,GACrB,sDAAsD,CAAA;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAA6C,EACI,EAAE,CACnD,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,MAAM,CAAC,EAAE;QAC9D,WAAW,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;KAClC,CAAC;IACJ,CAAC,CAAC,MAAM,CAAC,MAAM,CACX,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACrC,KAAK,CAAC,sCAAsC,EAAE,MAAM,CAAC;QACvD,CAAC,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,EAChD;QACE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;KACzB,CACF,CAAA","sourcesContent":["import {\n SpawnResultStderr,\n SpawnResultString,\n} from '@vltpkg/promise-spawn'\n\nimport { error } from '@vltpkg/error-cause'\n\nconst connectionErrorRe = new RegExp(\n [\n 'remote error: Internal Server Error',\n 'The remote end hung up unexpectedly',\n 'Connection timed out',\n 'Operation timed out',\n 'Failed to connect to .* Timed out',\n 'Connection reset by peer',\n 'SSL_ERROR_SYSCALL',\n 'The requested URL returned error: 503',\n ].join('|'),\n)\n\nconst missingPathspecRe =\n /pathspec .* did not match any file\\(s\\) known to git/\n\nexport const makeError = (\n result: SpawnResultStderr & SpawnResultString,\n): Error & { shouldRetry: (n: number) => boolean } =>\n connectionErrorRe.test(result.stderr) ?\n Object.assign(error('A git connection error occurred', result), {\n shouldRetry: (n: number) => n < 3,\n })\n : Object.assign(\n missingPathspecRe.test(result.stderr) ?\n error('The git reference could not be found', result)\n : error('An unknown git error occurred', result),\n {\n shouldRetry: () => false,\n },\n )\n"]}
|
|
1
|
+
{"version":3,"file":"make-error.js","sourceRoot":"","sources":["../../src/make-error.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC;IACE,qCAAqC;IACrC,qCAAqC;IACrC,sBAAsB;IACtB,qBAAqB;IACrB,mCAAmC;IACnC,0BAA0B;IAC1B,mBAAmB;IACnB,uCAAuC;CACxC,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAA;AAED,MAAM,iBAAiB,GACrB,sDAAsD,CAAA;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAA6C,EACI,EAAE,CACnD,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,MAAM,CAAC,EAAE;QAC9D,WAAW,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;KAClC,CAAC;IACJ,CAAC,CAAC,MAAM,CAAC,MAAM,CACX,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACrC,KAAK,CAAC,sCAAsC,EAAE,MAAM,CAAC;QACvD,CAAC,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,EAChD;QACE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;KACzB,CACF,CAAA","sourcesContent":["import {\n type SpawnResultStderr,\n type SpawnResultString,\n} from '@vltpkg/promise-spawn'\n\nimport { error } from '@vltpkg/error-cause'\n\nconst connectionErrorRe = new RegExp(\n [\n 'remote error: Internal Server Error',\n 'The remote end hung up unexpectedly',\n 'Connection timed out',\n 'Operation timed out',\n 'Failed to connect to .* Timed out',\n 'Connection reset by peer',\n 'SSL_ERROR_SYSCALL',\n 'The requested URL returned error: 503',\n ].join('|'),\n)\n\nconst missingPathspecRe =\n /pathspec .* did not match any file\\(s\\) known to git/\n\nexport const makeError = (\n result: SpawnResultStderr & SpawnResultString,\n): Error & { shouldRetry: (n: number) => boolean } =>\n connectionErrorRe.test(result.stderr) ?\n Object.assign(error('A git connection error occurred', result), {\n shouldRetry: (n: number) => n < 3,\n })\n : Object.assign(\n missingPathspecRe.test(result.stderr) ?\n error('The git reference could not be found', result)\n : error('An unknown git error occurred', result),\n {\n shouldRetry: () => false,\n },\n )\n"]}
|
package/dist/esm/opts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PromiseSpawnOptionsStderrString, PromiseSpawnOptionsStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
-
import { SpawnOptions } from 'child_process';
|
|
1
|
+
import { type PromiseSpawnOptionsStderrString, type PromiseSpawnOptionsStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
+
import { type SpawnOptions } from 'child_process';
|
|
3
3
|
export declare const opts: (opts?: SpawnOptions) => PromiseSpawnOptionsStderrString & PromiseSpawnOptionsStdoutString;
|
|
4
4
|
//# sourceMappingURL=opts.d.ts.map
|
package/dist/esm/opts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opts.d.ts","sourceRoot":"","sources":["../../src/opts.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,+BAA+B,
|
|
1
|
+
{"version":3,"file":"opts.d.ts","sourceRoot":"","sources":["../../src/opts.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACrC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAQjD,eAAO,MAAM,IAAI,UACT,YAAY,KACjB,+BAA+B,GAChC,+BAOA,CAAA"}
|
package/dist/esm/opts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opts.js","sourceRoot":"","sources":["../../src/opts.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAQvE,2DAA2D;AAC3D,MAAM,MAAM,GAAG;IACb,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,wCAAwC;CAC1D,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,OAAqB,EAAE,EAES,EAAE,CAAC,CAAC;IACpC,UAAU,EAAE,IAAI;IAChB,GAAG,IAAI;IACP,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;IAC9C,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,KAAK;CACb,CAAC,CAAA","sourcesContent":["// Values we want to set if they're not already defined by the end user\n\nimport {\n PromiseSpawnOptionsStderrString,\n PromiseSpawnOptionsStdoutString,\n} from '@vltpkg/promise-spawn'\nimport { SpawnOptions } from 'child_process'\n\n// This defaults to accepting new ssh host key fingerprints\nconst gitEnv = {\n GIT_ASKPASS: 'echo',\n GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',\n}\n\nexport const opts = (\n opts: SpawnOptions = {},\n): PromiseSpawnOptionsStderrString &\n PromiseSpawnOptionsStdoutString => ({\n acceptFail: true,\n ...opts,\n env: opts.env ?? { ...gitEnv, ...process.env },\n stdio: 'pipe',\n stdioString: true,\n shell: false,\n})\n"]}
|
|
1
|
+
{"version":3,"file":"opts.js","sourceRoot":"","sources":["../../src/opts.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAQvE,2DAA2D;AAC3D,MAAM,MAAM,GAAG;IACb,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,wCAAwC;CAC1D,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,OAAqB,EAAE,EAES,EAAE,CAAC,CAAC;IACpC,UAAU,EAAE,IAAI;IAChB,GAAG,IAAI;IACP,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;IAC9C,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,KAAK;CACb,CAAC,CAAA","sourcesContent":["// Values we want to set if they're not already defined by the end user\n\nimport {\n type PromiseSpawnOptionsStderrString,\n type PromiseSpawnOptionsStdoutString,\n} from '@vltpkg/promise-spawn'\nimport { type SpawnOptions } from 'child_process'\n\n// This defaults to accepting new ssh host key fingerprints\nconst gitEnv = {\n GIT_ASKPASS: 'echo',\n GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',\n}\n\nexport const opts = (\n opts: SpawnOptions = {},\n): PromiseSpawnOptionsStderrString &\n PromiseSpawnOptionsStdoutString => ({\n acceptFail: true,\n ...opts,\n env: opts.env ?? { ...gitEnv, ...process.env },\n stdio: 'pipe',\n stdioString: true,\n shell: false,\n})\n"]}
|
package/dist/esm/resolve.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,SACZ,MAAM,uBAEN,UAAU,6DAMjB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,uBAER,UAAU,oDAoBjB,CAAA"}
|
package/dist/esm/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,IAAY,EACZ,GAAG,GAAG,MAAM,EACZ,OAAmB,EAAE,EACrB,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACrC,sDAAsD;IACtD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AACtC,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,GAAG,GAAG,MAAM,EACZ,OAAmB,EAAE,EACrB,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACrB,GAAG,GAAG,IAAI,EAAE,aAAa,IAAI,GAAG,CAAA;IAChC,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;QAChB,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAA;IACzB,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,+DAA+D;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,oBAAoB;IACpB,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { RevDoc } from '@vltpkg/types'\nimport { pickManifest } from '@vltpkg/pick-manifest'\nimport { type GitOptions } from './index.js'\nimport { revs } from './revs.js'\n\n/**\n * Given a repo and either a ref or a git specifier Spec object, resolve the\n * appropriate ref that we should clone, ideally witout actually cloning the\n * repository.\n *\n *\n */\nexport const resolve = async (\n repo: string,\n ref = 'HEAD',\n opts: GitOptions = {},\n) => {\n const revDoc = await revs(repo, opts)\n /* no resolution possible if we can't read the repo */\n if (!revDoc) return undefined\n return resolveRef(revDoc, ref, opts)\n}\n\n/**\n * Given a repo's RevDoc object and either a ref or a git specifier Spec\n * object, resolve the appropriate ref that we should clone, witout actually\n * cloning the repository.\n */\nexport const resolveRef = (\n revDoc: RevDoc,\n ref = 'HEAD',\n opts: GitOptions = {},\n) => {\n const { spec } = opts\n ref = spec?.gitCommittish || ref\n if (spec?.range) {\n return pickManifest(revDoc, spec.range, opts)\n }\n if (!ref) {\n return revDoc.refs.HEAD\n }\n if (revDoc.refs[ref]) {\n return revDoc.refs[ref]\n }\n /* c8 ignore start - typically found above, but just in case */\n const sha = revDoc.shas[ref]?.[0]\n if (sha) {\n return revDoc.refs[sha]\n }\n /* c8 ignore stop */\n return undefined\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,IAAY,EACZ,GAAG,GAAG,MAAM,EACZ,OAAmB,EAAE,EACrB,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACrC,sDAAsD;IACtD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AACtC,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,GAAG,GAAG,MAAM,EACZ,OAAmB,EAAE,EACrB,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACrB,GAAG,GAAG,IAAI,EAAE,aAAa,IAAI,GAAG,CAAA;IAChC,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;QAChB,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAA;IACzB,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,+DAA+D;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjC,IAAI,GAAG,EAAE,CAAC;QACR,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IACD,oBAAoB;IACpB,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { type RevDoc } from '@vltpkg/types'\nimport { pickManifest } from '@vltpkg/pick-manifest'\nimport { type GitOptions } from './index.js'\nimport { revs } from './revs.js'\n\n/**\n * Given a repo and either a ref or a git specifier Spec object, resolve the\n * appropriate ref that we should clone, ideally witout actually cloning the\n * repository.\n *\n *\n */\nexport const resolve = async (\n repo: string,\n ref = 'HEAD',\n opts: GitOptions = {},\n) => {\n const revDoc = await revs(repo, opts)\n /* no resolution possible if we can't read the repo */\n if (!revDoc) return undefined\n return resolveRef(revDoc, ref, opts)\n}\n\n/**\n * Given a repo's RevDoc object and either a ref or a git specifier Spec\n * object, resolve the appropriate ref that we should clone, witout actually\n * cloning the repository.\n */\nexport const resolveRef = (\n revDoc: RevDoc,\n ref = 'HEAD',\n opts: GitOptions = {},\n) => {\n const { spec } = opts\n ref = spec?.gitCommittish || ref\n if (spec?.range) {\n return pickManifest(revDoc, spec.range, opts)\n }\n if (!ref) {\n return revDoc.refs.HEAD\n }\n if (revDoc.refs[ref]) {\n return revDoc.refs[ref]\n }\n /* c8 ignore start - typically found above, but just in case */\n const sha = revDoc.shas[ref]?.[0]\n if (sha) {\n return revDoc.refs[sha]\n }\n /* c8 ignore stop */\n return undefined\n}\n"]}
|
package/dist/esm/revs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitOptions } from './index.js';
|
|
2
|
-
import { RevDoc } from '@vltpkg/types';
|
|
1
|
+
import { type GitOptions } from './index.js';
|
|
2
|
+
import { type RevDoc } from '@vltpkg/types';
|
|
3
3
|
export declare const revs: (repo: string, opts?: GitOptions) => Promise<RevDoc | undefined>;
|
|
4
4
|
//# sourceMappingURL=revs.d.ts.map
|
package/dist/esm/revs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revs.d.ts","sourceRoot":"","sources":["../../src/revs.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"revs.d.ts","sourceRoot":"","sources":["../../src/revs.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAsB3C,eAAO,MAAM,IAAI,SAAgB,MAAM,SAAQ,UAAU,gCAWxD,CAAA"}
|
package/dist/esm/revs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revs.js","sourceRoot":"","sources":["../../src/revs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAK/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,WAAW,GAAG,KAAK,EACvB,IAAY,EACZ,CAAM,EACN,OAA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Cache } from 'lru-cache'\nimport { fileURLToPath } from 'url'\nimport { GitOptions } from './index.js'\nimport { linesToRevs } from './lines-to-revs.js'\nimport { RevDoc } from '@vltpkg/types'\nimport { spawn } from './spawn.js'\n\nconst fetchMethod = async (\n repo: string,\n _: any,\n options: { context: GitOptions },\n) => {\n const result: SpawnResultStderrString & SpawnResultStdoutString =\n await spawn(['ls-remote', repo], options.context)\n const revsDoc = linesToRevs(result.stdout.split('\\n'))\n return revsDoc\n}\n\nconst revsCache = new LRUCache<string, RevDoc, GitOptions>({\n max: 100,\n ttl: 5 * 60 * 1000,\n allowStaleOnFetchAbort: true,\n allowStaleOnFetchRejection: true,\n fetchMethod,\n})\n\nexport const revs = async (repo: string, opts: GitOptions = {}) => {\n repo = String(gitScpURL(repo) ?? repo).replace(/^git\\+/, '')\n if (repo.startsWith('file://')) repo = fileURLToPath(repo)\n if (opts.noGitRevCache) {\n const result = await fetchMethod(repo, undefined, {\n context: opts,\n })\n revsCache.set(repo, result)\n return result\n }\n return await revsCache.fetch(repo, { context: opts })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"revs.js","sourceRoot":"","sources":["../../src/revs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAK/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,WAAW,GAAG,KAAK,EACvB,IAAY,EACZ,CAAM,EACN,OAAgC,EAChC,EAAE;IACF,MAAM,MAAM,GACV,MAAM,KAAK,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACtD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,IAAI,QAAQ,CAA6B;IACzD,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;IAClB,sBAAsB,EAAE,IAAI;IAC5B,0BAA0B,EAAE,IAAI;IAChC,WAAW;CACZ,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,IAAY,EAAE,OAAmB,EAAE,EAAE,EAAE;IAChE,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IAC5D,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IAC1D,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE;YAChD,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QACF,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC3B,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA","sourcesContent":["import { gitScpURL } from '@vltpkg/git-scp-url'\nimport {\n type SpawnResultStderrString,\n type SpawnResultStdoutString,\n} from '@vltpkg/promise-spawn'\nimport { LRUCache } from 'lru-cache'\nimport { fileURLToPath } from 'url'\nimport { type GitOptions } from './index.js'\nimport { linesToRevs } from './lines-to-revs.js'\nimport { type RevDoc } from '@vltpkg/types'\nimport { spawn } from './spawn.js'\n\nconst fetchMethod = async (\n repo: string,\n _: any,\n options: { context: GitOptions },\n) => {\n const result: SpawnResultStderrString & SpawnResultStdoutString =\n await spawn(['ls-remote', repo], options.context)\n const revsDoc = linesToRevs(result.stdout.split('\\n'))\n return revsDoc\n}\n\nconst revsCache = new LRUCache<string, RevDoc, GitOptions>({\n max: 100,\n ttl: 5 * 60 * 1000,\n allowStaleOnFetchAbort: true,\n allowStaleOnFetchRejection: true,\n fetchMethod,\n})\n\nexport const revs = async (repo: string, opts: GitOptions = {}) => {\n repo = String(gitScpURL(repo) ?? repo).replace(/^git\\+/, '')\n if (repo.startsWith('file://')) repo = fileURLToPath(repo)\n if (opts.noGitRevCache) {\n const result = await fetchMethod(repo, undefined, {\n context: opts,\n })\n revsCache.set(repo, result)\n return result\n }\n return await revsCache.fetch(repo, { context: opts })\n}\n"]}
|
package/dist/esm/spawn.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpawnResultStderrString, SpawnResultStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
-
import { GitOptions } from './index.js';
|
|
1
|
+
import { type SpawnResultStderrString, type SpawnResultStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
+
import { type GitOptions } from './index.js';
|
|
3
3
|
export declare const spawn: (gitArgs: string[], opts?: GitOptions) => Promise<SpawnResultStderrString & SpawnResultStdoutString>;
|
|
4
4
|
//# sourceMappingURL=spawn.d.ts.map
|
package/dist/esm/spawn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAK5C,eAAO,MAAM,KA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MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAChE,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;YAClC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,QAAQ,CAAA;YAChB,CAAC;YACD,OAAO,CAAC,QAAQ,CAAC,CAAA;QACnB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,SAAS,CAAC,CAAA;AACf,CAAC,CAAA","sourcesContent":["import {\n promiseSpawn,\n SpawnResultStderrString,\n SpawnResultStdoutString,\n} from '@vltpkg/promise-spawn'\nimport promiseRetry from 'promise-retry'\nimport { WrapOptions } from 'retry'\nimport { GitOptions } from './index.js'\nimport { makeError } from './make-error.js'\nimport { opts as makeOpts } from './opts.js'\nimport { which } from './which.js'\n\nexport const spawn = async (\n gitArgs: string[],\n opts: GitOptions = {},\n): Promise<SpawnResultStderrString & SpawnResultStdoutString> => {\n const gitPath = which(opts)\n\n if (gitPath instanceof Error) {\n throw gitPath\n }\n\n /* c8 ignore start - undocumented option, only here for tests */\n const args =\n (\n (opts as { allowReplace?: boolean }).allowReplace ||\n gitArgs[0] === '--no-replace-objects'\n ) ?\n gitArgs\n : ['--no-replace-objects', ...gitArgs]\n /* c8 ignore stop */\n\n const retryOpts: WrapOptions = {\n retries: opts['fetch-retries'] || 3,\n factor: opts['fetch-retry-factor'] || 2,\n maxTimeout: opts['fetch-retry-maxtimeout'] || 60000,\n minTimeout: opts['fetch-retry-mintimeout'] || 1000,\n }\n return promiseRetry(async (retryFn, num) => {\n const result = await promiseSpawn(gitPath, args, makeOpts(opts))\n if (result.status || result.signal) {\n const gitError = makeError(result)\n if (!gitError.shouldRetry(num)) {\n throw gitError\n }\n retryFn(gitError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MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;YAClC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,QAAQ,CAAA;YAChB,CAAC;YACD,OAAO,CAAC,QAAQ,CAAC,CAAA;QACnB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,SAAS,CAAC,CAAA;AACf,CAAC,CAAA","sourcesContent":["import {\n promiseSpawn,\n type SpawnResultStderrString,\n type SpawnResultStdoutString,\n} from '@vltpkg/promise-spawn'\nimport promiseRetry from 'promise-retry'\nimport { type WrapOptions } from 'retry'\nimport { type GitOptions } from './index.js'\nimport { makeError } from './make-error.js'\nimport { opts as makeOpts } from './opts.js'\nimport { which } from './which.js'\n\nexport const spawn = async (\n gitArgs: string[],\n opts: GitOptions = {},\n): Promise<SpawnResultStderrString & SpawnResultStdoutString> => {\n const gitPath = which(opts)\n\n if (gitPath instanceof Error) {\n throw gitPath\n }\n\n /* c8 ignore start - undocumented option, only here for tests */\n const args =\n (\n (opts as { allowReplace?: boolean }).allowReplace ||\n gitArgs[0] === '--no-replace-objects'\n ) ?\n gitArgs\n : ['--no-replace-objects', ...gitArgs]\n /* c8 ignore stop */\n\n const retryOpts: WrapOptions = {\n retries: opts['fetch-retries'] || 3,\n factor: opts['fetch-retry-factor'] || 2,\n maxTimeout: opts['fetch-retry-maxtimeout'] || 60000,\n minTimeout: opts['fetch-retry-mintimeout'] || 1000,\n }\n return promiseRetry(async (retryFn, num) => {\n const result = await promiseSpawn(gitPath, args, makeOpts(opts))\n if (result.status || result.signal) {\n const gitError = makeError(result)\n if (!gitError.shouldRetry(num)) {\n throw gitError\n }\n retryFn(gitError)\n }\n return result\n }, retryOpts)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/git",
|
|
3
3
|
"description": "a util for spawning git from npm CLI contexts",
|
|
4
|
-
"version": "0.0.0-0.
|
|
4
|
+
"version": "0.0.0-0.1730724342581",
|
|
5
5
|
"tshy": {
|
|
6
6
|
"selfLink": false,
|
|
7
7
|
"dialects": [
|
|
@@ -14,15 +14,16 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@types/promise-retry": "^1.1.6",
|
|
17
|
-
"lru-cache": "^11.0.
|
|
17
|
+
"lru-cache": "^11.0.2",
|
|
18
18
|
"promise-retry": "^2.0.1",
|
|
19
|
-
"
|
|
20
|
-
"@vltpkg/git-scp-url": "0.0.0-0.
|
|
21
|
-
"@vltpkg/
|
|
22
|
-
"@vltpkg/
|
|
23
|
-
"@vltpkg/semver": "0.0.0-0.
|
|
24
|
-
"@vltpkg/
|
|
25
|
-
"@vltpkg/
|
|
19
|
+
"retry": "^0.13.1",
|
|
20
|
+
"@vltpkg/git-scp-url": "0.0.0-0.1730724342581",
|
|
21
|
+
"@vltpkg/error-cause": "0.0.0-0.1730724342581",
|
|
22
|
+
"@vltpkg/pick-manifest": "0.0.0-0.1730724342581",
|
|
23
|
+
"@vltpkg/semver": "0.0.0-0.1730724342581",
|
|
24
|
+
"@vltpkg/promise-spawn": "0.0.0-0.1730724342581",
|
|
25
|
+
"@vltpkg/spec": "0.0.0-0.1730724342581",
|
|
26
|
+
"@vltpkg/which": "0.0.0-0.1730724342581"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@eslint/js": "^9.8.0",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"tshy": "^3.0.2",
|
|
36
37
|
"typescript": "^5.5.4",
|
|
37
38
|
"typescript-eslint": "^8.0.1",
|
|
38
|
-
"@vltpkg/types": "0.0.0-0.
|
|
39
|
+
"@vltpkg/types": "0.0.0-0.1730724342581"
|
|
39
40
|
},
|
|
40
41
|
"license": "ISC",
|
|
41
42
|
"engines": {
|