@vltpkg/git 1.0.0-rc.18 → 1.0.0-rc.22
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/package.json +31 -27
- package/dist/clone.d.ts +0 -13
- package/dist/clone.d.ts.map +0 -1
- package/dist/clone.js +0 -140
- package/dist/clone.js.map +0 -1
- package/dist/find.d.ts +0 -6
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -15
- package/dist/find.js.map +0 -1
- package/dist/index.d.ts +0 -53
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/is-clean.d.ts +0 -2
- package/dist/is-clean.d.ts.map +0 -1
- package/dist/is-clean.js +0 -14
- package/dist/is-clean.js.map +0 -1
- package/dist/is-windows.d.ts +0 -3
- package/dist/is-windows.d.ts.map +0 -1
- package/dist/is-windows.js +0 -2
- package/dist/is-windows.js.map +0 -1
- package/dist/is.d.ts +0 -4
- package/dist/is.d.ts.map +0 -1
- package/dist/is.js +0 -4
- package/dist/is.js.map +0 -1
- package/dist/lines-to-revs.d.ts +0 -7
- package/dist/lines-to-revs.d.ts.map +0 -1
- package/dist/lines-to-revs.js +0 -153
- package/dist/lines-to-revs.js.map +0 -1
- package/dist/make-error.d.ts +0 -3
- package/dist/make-error.d.ts.map +0 -1
- package/dist/make-error.js +0 -21
- package/dist/make-error.js.map +0 -1
- package/dist/opts.d.ts +0 -4
- package/dist/opts.d.ts.map +0 -1
- package/dist/opts.js +0 -15
- package/dist/opts.js.map +0 -1
- package/dist/resolve.d.ts +0 -17
- package/dist/resolve.d.ts.map +0 -1
- package/dist/resolve.js +0 -42
- package/dist/resolve.js.map +0 -1
- package/dist/revs.d.ts +0 -4
- package/dist/revs.d.ts.map +0 -1
- package/dist/revs.js +0 -31
- package/dist/revs.js.map +0 -1
- package/dist/spawn.d.ts +0 -4
- package/dist/spawn.d.ts.map +0 -1
- package/dist/spawn.js +0 -35
- package/dist/spawn.js.map +0 -1
- package/dist/user.d.ts +0 -6
- package/dist/user.d.ts.map +0 -1
- package/dist/user.js +0 -39
- package/dist/user.js.map +0 -1
- package/dist/which.d.ts +0 -5
- package/dist/which.d.ts.map +0 -1
- package/dist/which.js +0 -27
- package/dist/which.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/git",
|
|
3
3
|
"description": "a util for spawning git from npm CLI contexts",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.22",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/git"
|
|
9
9
|
},
|
|
10
|
-
"author":
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh"
|
|
13
|
+
},
|
|
11
14
|
"dependencies": {
|
|
12
15
|
"@types/promise-retry": "^1.1.6",
|
|
16
|
+
"@vltpkg/error-cause": "1.0.0-rc.22",
|
|
17
|
+
"@vltpkg/git-scp-url": "1.0.0-rc.22",
|
|
18
|
+
"@vltpkg/pick-manifest": "1.0.0-rc.22",
|
|
19
|
+
"@vltpkg/promise-spawn": "1.0.0-rc.22",
|
|
20
|
+
"@vltpkg/semver": "1.0.0-rc.22",
|
|
21
|
+
"@vltpkg/spec": "1.0.0-rc.22",
|
|
22
|
+
"@vltpkg/which": "1.0.0-rc.22",
|
|
13
23
|
"lru-cache": "^11.2.4",
|
|
14
24
|
"promise-retry": "^2.0.1",
|
|
15
|
-
"retry": "^0.13.1"
|
|
16
|
-
"@vltpkg/error-cause": "1.0.0-rc.18",
|
|
17
|
-
"@vltpkg/git-scp-url": "1.0.0-rc.18",
|
|
18
|
-
"@vltpkg/pick-manifest": "1.0.0-rc.18",
|
|
19
|
-
"@vltpkg/semver": "1.0.0-rc.18",
|
|
20
|
-
"@vltpkg/promise-spawn": "1.0.0-rc.18",
|
|
21
|
-
"@vltpkg/spec": "1.0.0-rc.18",
|
|
22
|
-
"@vltpkg/which": "1.0.0-rc.18"
|
|
25
|
+
"retry": "^0.13.1"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@eslint/js": "^9.39.1",
|
|
26
29
|
"@types/node": "^22.19.2",
|
|
27
30
|
"@types/retry": "^0.12.5",
|
|
31
|
+
"@vltpkg/types": "1.0.0-rc.22",
|
|
28
32
|
"eslint": "^9.39.1",
|
|
29
33
|
"prettier": "^3.7.4",
|
|
30
34
|
"tap": "^21.5.0",
|
|
31
35
|
"typedoc": "~0.27.9",
|
|
32
36
|
"typescript": "5.7.3",
|
|
33
|
-
"typescript-eslint": "^8.49.0"
|
|
34
|
-
"@vltpkg/types": "1.0.0-rc.18"
|
|
37
|
+
"typescript-eslint": "^8.49.0"
|
|
35
38
|
},
|
|
36
39
|
"license": "ISC",
|
|
37
40
|
"engines": {
|
|
38
|
-
"node": ">=22.
|
|
41
|
+
"node": ">=22.22.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
45
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
46
|
+
"lint": "eslint . --fix",
|
|
47
|
+
"lint:check": "eslint .",
|
|
48
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
49
|
+
"snap": "tap",
|
|
50
|
+
"test": "tap",
|
|
51
|
+
"posttest": "tsc --noEmit",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
39
53
|
},
|
|
40
54
|
"tap": {
|
|
41
55
|
"extends": "../../tap-config.yaml"
|
|
42
56
|
},
|
|
43
57
|
"prettier": "../../.prettierrc.js",
|
|
44
|
-
"module": "./
|
|
58
|
+
"module": "./src/index.ts",
|
|
45
59
|
"type": "module",
|
|
46
60
|
"exports": {
|
|
47
61
|
"./package.json": "./package.json",
|
|
48
62
|
".": {
|
|
49
63
|
"import": {
|
|
50
|
-
"default": "./
|
|
64
|
+
"default": "./src/index.ts"
|
|
51
65
|
}
|
|
52
66
|
}
|
|
53
67
|
},
|
|
54
68
|
"files": [
|
|
55
69
|
"dist"
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
59
|
-
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
60
|
-
"lint": "eslint . --fix",
|
|
61
|
-
"lint:check": "eslint .",
|
|
62
|
-
"snap": "tap",
|
|
63
|
-
"test": "tap",
|
|
64
|
-
"posttest": "tsc --noEmit",
|
|
65
|
-
"typecheck": "tsc --noEmit"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
70
|
+
]
|
|
71
|
+
}
|
package/dist/clone.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GitOptions } from './index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Only these whitelisted hosts get shallow cloning. Many hosts (including GHE)
|
|
4
|
-
* don't always support it. A failed shallow fetch takes a LOT longer than a
|
|
5
|
-
* full fetch in most cases, so we skip it entirely. Set opts.gitShallow =
|
|
6
|
-
* true/false to force this behavior one way or the other.
|
|
7
|
-
*
|
|
8
|
-
* If other hosts are added to this set, then they will be shallowly cloned
|
|
9
|
-
* as well.
|
|
10
|
-
*/
|
|
11
|
-
export declare const shallowHosts: Set<string>;
|
|
12
|
-
export declare const clone: (repo: string, ref?: string, target?: string, opts?: GitOptions) => Promise<string>;
|
|
13
|
-
//# sourceMappingURL=clone.d.ts.map
|
package/dist/clone.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../src/clone.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAM5C;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,aAMvB,CAAA;AAEF,eAAO,MAAM,KAAK,SACV,MAAM,yBAEH,MAAM,SACT,UAAU,oBAajB,CAAA"}
|
package/dist/clone.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// The goal here is to minimize both git workload and
|
|
2
|
-
// the number of refs we download over the network.
|
|
3
|
-
//
|
|
4
|
-
// Every method ends up with the checked out working dir
|
|
5
|
-
// at the specified ref, and resolves with the git sha.
|
|
6
|
-
import { gitScpURL } from '@vltpkg/git-scp-url';
|
|
7
|
-
import { mkdir, stat } from 'node:fs/promises';
|
|
8
|
-
import { basename, resolve } from 'node:path';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
-
import { isWindows } from "./is-windows.js";
|
|
11
|
-
import { resolveRef } from "./resolve.js";
|
|
12
|
-
import { revs as getRevs } from "./revs.js";
|
|
13
|
-
import { spawn } from "./spawn.js";
|
|
14
|
-
/**
|
|
15
|
-
* Only these whitelisted hosts get shallow cloning. Many hosts (including GHE)
|
|
16
|
-
* don't always support it. A failed shallow fetch takes a LOT longer than a
|
|
17
|
-
* full fetch in most cases, so we skip it entirely. Set opts.gitShallow =
|
|
18
|
-
* true/false to force this behavior one way or the other.
|
|
19
|
-
*
|
|
20
|
-
* If other hosts are added to this set, then they will be shallowly cloned
|
|
21
|
-
* as well.
|
|
22
|
-
*/
|
|
23
|
-
export const shallowHosts = new Set([
|
|
24
|
-
'github.com',
|
|
25
|
-
'gist.github.com',
|
|
26
|
-
'gitlab.com',
|
|
27
|
-
'bitbucket.com',
|
|
28
|
-
'bitbucket.org',
|
|
29
|
-
]);
|
|
30
|
-
export const clone = async (repo, ref = 'HEAD', target, opts = {}) => {
|
|
31
|
-
repo = String(gitScpURL(repo) ?? repo).replace(/^git\+/, '');
|
|
32
|
-
if (repo.startsWith('file://'))
|
|
33
|
-
repo = fileURLToPath(repo);
|
|
34
|
-
const revs = await getRevs(repo, opts);
|
|
35
|
-
return await clone_(repo, revs, ref, revs && resolveRef(revs, ref, opts), target || defaultTarget(repo, opts.cwd), opts);
|
|
36
|
-
};
|
|
37
|
-
const maybeShallow = (repo, opts) => {
|
|
38
|
-
if (opts['git-shallow'] === false || opts['git-shallow']) {
|
|
39
|
-
return opts['git-shallow'];
|
|
40
|
-
}
|
|
41
|
-
const host = gitScpURL(repo)?.host ?? '';
|
|
42
|
-
return shallowHosts.has(host);
|
|
43
|
-
};
|
|
44
|
-
const defaultTarget = (repo,
|
|
45
|
-
/* c8 ignore next */ cwd = process.cwd()) => resolve(cwd, basename(repo.replace(/[/\\]?\.git$/, '')));
|
|
46
|
-
const clone_ = (repo, revs, ref, revDoc, target, opts) => {
|
|
47
|
-
if (!revDoc || !revs) {
|
|
48
|
-
return unresolved(repo, ref, target, opts);
|
|
49
|
-
}
|
|
50
|
-
if (revDoc.sha === revs.refs.HEAD?.sha) {
|
|
51
|
-
return plain(repo, revDoc, target, opts);
|
|
52
|
-
}
|
|
53
|
-
if (revDoc.type === 'tag' || revDoc.type === 'branch') {
|
|
54
|
-
return branch(repo, revDoc, target, opts);
|
|
55
|
-
}
|
|
56
|
-
return other(repo, revDoc, target, opts);
|
|
57
|
-
};
|
|
58
|
-
// pull request or some other kind of advertised ref
|
|
59
|
-
const other = async (repo, revDoc, target, opts) => {
|
|
60
|
-
const shallow = maybeShallow(repo, opts);
|
|
61
|
-
const fetchOrigin = ['fetch', 'origin', revDoc.rawRef].concat(shallow ? ['--depth=1'] : []);
|
|
62
|
-
const git = (args) => spawn(args, { ...opts, cwd: target });
|
|
63
|
-
await mkdir(target, { recursive: true });
|
|
64
|
-
await git(['init']);
|
|
65
|
-
if (isWindows(opts)) {
|
|
66
|
-
await git([
|
|
67
|
-
'config',
|
|
68
|
-
'--local',
|
|
69
|
-
'--add',
|
|
70
|
-
'core.longpaths',
|
|
71
|
-
'true',
|
|
72
|
-
]);
|
|
73
|
-
}
|
|
74
|
-
await git(['remote', 'add', 'origin', repo]);
|
|
75
|
-
await git(fetchOrigin);
|
|
76
|
-
await git(['checkout', revDoc.sha]);
|
|
77
|
-
await updateSubmodules(target, opts);
|
|
78
|
-
return revDoc.sha;
|
|
79
|
-
};
|
|
80
|
-
// tag or branches. use -b
|
|
81
|
-
const branch = async (repo, revDoc, target, opts) => {
|
|
82
|
-
const args = [
|
|
83
|
-
'clone',
|
|
84
|
-
'-b',
|
|
85
|
-
revDoc.ref,
|
|
86
|
-
repo,
|
|
87
|
-
target,
|
|
88
|
-
'--recurse-submodules',
|
|
89
|
-
];
|
|
90
|
-
if (maybeShallow(repo, opts)) {
|
|
91
|
-
args.push('--depth=1');
|
|
92
|
-
}
|
|
93
|
-
if (isWindows(opts)) {
|
|
94
|
-
args.push('--config', 'core.longpaths=true');
|
|
95
|
-
}
|
|
96
|
-
await spawn(args, opts);
|
|
97
|
-
return revDoc.sha;
|
|
98
|
-
};
|
|
99
|
-
// just the head. clone it
|
|
100
|
-
const plain = async (repo, revDoc, target, opts) => {
|
|
101
|
-
const args = ['clone', repo, target, '--recurse-submodules'];
|
|
102
|
-
if (maybeShallow(repo, opts)) {
|
|
103
|
-
args.push('--depth=1');
|
|
104
|
-
}
|
|
105
|
-
if (isWindows(opts)) {
|
|
106
|
-
args.push('--config', 'core.longpaths=true');
|
|
107
|
-
}
|
|
108
|
-
await spawn(args, opts);
|
|
109
|
-
return revDoc.sha;
|
|
110
|
-
};
|
|
111
|
-
const updateSubmodules = async (target, opts) => {
|
|
112
|
-
const hasSubmodules = await stat(`${target}/.gitmodules`)
|
|
113
|
-
.then(() => true)
|
|
114
|
-
.catch(() => false);
|
|
115
|
-
if (!hasSubmodules) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
await spawn(['submodule', 'update', '-q', '--init', '--recursive'], { ...opts, cwd: target });
|
|
119
|
-
};
|
|
120
|
-
const unresolved = async (repo, ref, target, opts) => {
|
|
121
|
-
// can't do this one shallowly, because the ref isn't advertised
|
|
122
|
-
// but we can avoid checking out the working dir twice, at least
|
|
123
|
-
const lp = isWindows(opts) ? ['--config', 'core.longpaths=true'] : [];
|
|
124
|
-
const cloneArgs = [
|
|
125
|
-
'clone',
|
|
126
|
-
'--mirror',
|
|
127
|
-
'-q',
|
|
128
|
-
repo,
|
|
129
|
-
target + '/.git',
|
|
130
|
-
];
|
|
131
|
-
const git = (args) => spawn(args, { ...opts, cwd: target });
|
|
132
|
-
await mkdir(target, { recursive: true });
|
|
133
|
-
await git(cloneArgs.concat(lp));
|
|
134
|
-
await git(['init']);
|
|
135
|
-
await git(['checkout', ref]);
|
|
136
|
-
await updateSubmodules(target, opts);
|
|
137
|
-
const result = await git(['rev-parse', '--revs-only', 'HEAD']);
|
|
138
|
-
return result.stdout;
|
|
139
|
-
};
|
|
140
|
-
//# sourceMappingURL=clone.js.map
|
package/dist/clone.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,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,YAA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B,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 type { RevDoc, RevDocEntry } from '@vltpkg/types'\nimport { gitScpURL } from '@vltpkg/git-scp-url'\nimport { mkdir, stat } from 'node:fs/promises'\nimport { basename, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { GitOptions } from './index.ts'\nimport { isWindows } from './is-windows.ts'\nimport { resolveRef } from './resolve.ts'\nimport { revs as getRevs } from './revs.ts'\nimport { spawn } from './spawn.ts'\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,\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/find.d.ts
DELETED
package/dist/find.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AACD,eAAO,MAAM,IAAI,oBAGd,QAAQ,gCAWV,CAAA"}
|
package/dist/find.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { dirname } from 'node:path';
|
|
2
|
-
import { is } from "./is.js";
|
|
3
|
-
export const find = async ({ cwd = process.cwd(), root, } = {}) => {
|
|
4
|
-
while (true) {
|
|
5
|
-
if (await is({ cwd })) {
|
|
6
|
-
return cwd;
|
|
7
|
-
}
|
|
8
|
-
const next = dirname(cwd);
|
|
9
|
-
if (cwd === root || cwd === next) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
cwd = next;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAM5B,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,EACzB,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,IAAI,MACQ,EAAE,EAAE,EAAE;IAClB,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACtB,OAAO,GAAG,CAAA;QACZ,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QACzB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,GAAG,GAAG,IAAI,CAAA;IACZ,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { dirname } from 'node:path'\nimport { is } from './is.ts'\n\nexport type FindOpts = {\n cwd?: string\n root?: string\n}\nexport const find = async ({\n cwd = process.cwd(),\n root,\n}: FindOpts = {}) => {\n while (true) {\n if (await is({ cwd })) {\n return cwd\n }\n const next = dirname(cwd)\n if (cwd === root || cwd === next) {\n return undefined\n }\n cwd = next\n }\n}\n"]}
|
package/dist/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { PickManifestOptions } from '@vltpkg/pick-manifest';
|
|
2
|
-
import type { Spec } from '@vltpkg/spec';
|
|
3
|
-
import type { SpawnOptions } from 'node:child_process';
|
|
4
|
-
import type { WrapOptions } from 'retry';
|
|
5
|
-
export * from './clone.ts';
|
|
6
|
-
export * from './find.ts';
|
|
7
|
-
export * from './is-clean.ts';
|
|
8
|
-
export * from './is.ts';
|
|
9
|
-
export * from './resolve.ts';
|
|
10
|
-
export * from './revs.ts';
|
|
11
|
-
export * from './spawn.ts';
|
|
12
|
-
export * from './user.ts';
|
|
13
|
-
/**
|
|
14
|
-
* This extends all options that can be passed to spawn() or pickManifest.
|
|
15
|
-
*/
|
|
16
|
-
export type GitOptions = PickManifestOptions & SpawnOptions & {
|
|
17
|
-
/** the path to git binary, or 'false' to prevent all git operations */
|
|
18
|
-
git?: string | false;
|
|
19
|
-
/** the current working directory to perform git operations in */
|
|
20
|
-
cwd?: string;
|
|
21
|
-
/** Parsed git specifier to be cloned, if we have one */
|
|
22
|
-
spec?: Spec;
|
|
23
|
-
/**
|
|
24
|
-
* Set to a boolean to force cloning with/without `--depth=1`. If left
|
|
25
|
-
* undefined, then shallow cloning will only be performed on hosts known to
|
|
26
|
-
* support it.
|
|
27
|
-
*/
|
|
28
|
-
'git-shallow'?: boolean;
|
|
29
|
-
/** Only relevant if `retry` is unset. Value for retry.retries, default 2 */
|
|
30
|
-
'fetch-retries'?: WrapOptions['retries'];
|
|
31
|
-
/** Only relevant if `retry` is unset. Value for retry.factor, default 10 */
|
|
32
|
-
'fetch-retry-factor'?: WrapOptions['factor'];
|
|
33
|
-
/**
|
|
34
|
-
* Only relevant if `retry` is unset. Value for retry.maxTimeout, default
|
|
35
|
-
* 60_000
|
|
36
|
-
*/
|
|
37
|
-
'fetch-retry-maxtimeout'?: WrapOptions['maxTimeout'];
|
|
38
|
-
/**
|
|
39
|
-
* Only relevant if `retry` is unset. Value for retry.minTimeout, default
|
|
40
|
-
* 1_000
|
|
41
|
-
*/
|
|
42
|
-
'fetch-retry-mintimeout'?: WrapOptions['minTimeout'];
|
|
43
|
-
/**
|
|
44
|
-
* Used to test platform-specific behavior.
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
fakePlatform?: NodeJS.Platform;
|
|
48
|
-
/**
|
|
49
|
-
* Just to test rev lookup without continually clearing the cache
|
|
50
|
-
*/
|
|
51
|
-
noGitRevCache?: boolean;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,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;AAC1B,cAAc,WAAW,CAAA;AAEzB;;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/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./clone.js";
|
|
2
|
-
export * from "./find.js";
|
|
3
|
-
export * from "./is-clean.js";
|
|
4
|
-
export * from "./is.js";
|
|
5
|
-
export * from "./resolve.js";
|
|
6
|
-
export * from "./revs.js";
|
|
7
|
-
export * from "./spawn.js";
|
|
8
|
-
export * from "./user.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAC1B,cAAc,WAAW,CAAA","sourcesContent":["import type { PickManifestOptions } from '@vltpkg/pick-manifest'\nimport type { Spec } from '@vltpkg/spec'\nimport type { SpawnOptions } from 'node:child_process'\nimport type { WrapOptions } from 'retry'\n\nexport * from './clone.ts'\nexport * from './find.ts'\nexport * from './is-clean.ts'\nexport * from './is.ts'\nexport * from './resolve.ts'\nexport * from './revs.ts'\nexport * from './spawn.ts'\nexport * from './user.ts'\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"]}
|
package/dist/is-clean.d.ts
DELETED
package/dist/is-clean.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-clean.d.ts","sourceRoot":"","sources":["../src/is-clean.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,iCAYnB,CAAA"}
|
package/dist/is-clean.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { spawn } from "./spawn.js";
|
|
3
|
-
export const isClean = async (opts = {}) => {
|
|
4
|
-
const result = await spawn(['status', '--porcelain=v1', '-uno'], opts);
|
|
5
|
-
if (result.status || result.signal) {
|
|
6
|
-
throw error('git isClean check failed', result);
|
|
7
|
-
}
|
|
8
|
-
for (const line of result.stdout.split(/\r?\n+/)) {
|
|
9
|
-
if (line.trim())
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=is-clean.js.map
|
package/dist/is-clean.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-clean.js","sourceRoot":"","sources":["../src/is-clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,KAAK,CACxB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,CAAC,EACpC,IAAI,CACL,CAAA;IACD,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,KAAK,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAA;IAC/B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { spawn } from './spawn.ts'\n\nexport const isClean = async (opts = {}) => {\n const result = await spawn(\n ['status', '--porcelain=v1', '-uno'],\n opts,\n )\n if (result.status || result.signal) {\n throw error('git isClean check failed', result)\n }\n for (const line of result.stdout.split(/\\r?\\n+/)) {\n if (line.trim()) return false\n }\n return true\n}\n"]}
|
package/dist/is-windows.d.ts
DELETED
package/dist/is-windows.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-windows.d.ts","sourceRoot":"","sources":["../src/is-windows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,eAAO,MAAM,SAAS,SAAU,UAAU,YACW,CAAA"}
|
package/dist/is-windows.js
DELETED
package/dist/is-windows.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-windows.js","sourceRoot":"","sources":["../src/is-windows.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAgB,EAAE,EAAE,CAC5C,CAAC,IAAI,CAAC,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAA","sourcesContent":["import type { GitOptions } from './index.ts'\nexport const isWindows = (opts: GitOptions) =>\n (opts.fakePlatform || process.platform) === 'win32'\n"]}
|
package/dist/is.d.ts
DELETED
package/dist/is.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,EAAE;;sBAIZ,CAAA"}
|
package/dist/is.js
DELETED
package/dist/is.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is.js","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CACjD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC,IAAI,CACtB,GAAG,EAAE,CAAC,IAAI,EACV,GAAG,EAAE,CAAC,KAAK,CACZ,CAAA","sourcesContent":["// not an airtight indicator, but a good gut-check to even bother trying\nimport { stat } from 'node:fs/promises'\nexport const is = ({ cwd = process.cwd() } = {}) =>\n stat(cwd + '/.git').then(\n () => true,\n () => false,\n )\n"]}
|
package/dist/lines-to-revs.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RevDoc } from '@vltpkg/types';
|
|
2
|
-
/**
|
|
3
|
-
* turn an array of lines from `git ls-remote` into a thing
|
|
4
|
-
* vaguely resembling a packument, where docs are a resolved ref
|
|
5
|
-
*/
|
|
6
|
-
export declare const linesToRevs: (lines: string[]) => RevDoc;
|
|
7
|
-
//# sourceMappingURL=lines-to-revs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lines-to-revs.d.ts","sourceRoot":"","sources":["../src/lines-to-revs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAwB,MAAM,eAAe,CAAA;AAIjE;;;GAGG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,EAAE,KAAG,MAS3C,CAAA"}
|
package/dist/lines-to-revs.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { parse } from '@vltpkg/semver';
|
|
2
|
-
import { error } from '@vltpkg/error-cause';
|
|
3
|
-
/**
|
|
4
|
-
* turn an array of lines from `git ls-remote` into a thing
|
|
5
|
-
* vaguely resembling a packument, where docs are a resolved ref
|
|
6
|
-
*/
|
|
7
|
-
export const linesToRevs = (lines) => finish(lines.reduce(linesToRevsReducer, {
|
|
8
|
-
name: '',
|
|
9
|
-
versions: {},
|
|
10
|
-
'dist-tags': {},
|
|
11
|
-
refs: {},
|
|
12
|
-
shas: {},
|
|
13
|
-
}));
|
|
14
|
-
const finish = (revs) => distTags(versions(shaList(peelTags(revs))));
|
|
15
|
-
const versions = (revs) => {
|
|
16
|
-
for (const [version, entry] of Object.entries(revs.versions)) {
|
|
17
|
-
entry.version = version;
|
|
18
|
-
}
|
|
19
|
-
return revs;
|
|
20
|
-
};
|
|
21
|
-
// We can check out shallow clones on specific SHAs if we have a ref
|
|
22
|
-
const shaList = (revs) => {
|
|
23
|
-
Object.entries(revs.refs).forEach(([ref, doc]) => {
|
|
24
|
-
const shas = revs.shas[doc.sha];
|
|
25
|
-
if (!shas) {
|
|
26
|
-
revs.shas[doc.sha] = [ref];
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
shas.push(ref);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return revs;
|
|
33
|
-
};
|
|
34
|
-
// Replace any tags with their ^{} counterparts, if those exist
|
|
35
|
-
const peelTags = (revs) => {
|
|
36
|
-
Object.entries(revs.refs)
|
|
37
|
-
.filter(([ref]) => ref.endsWith('^{}'))
|
|
38
|
-
.forEach(([ref, peeled]) => {
|
|
39
|
-
const unpeeled = revs.refs[ref.replace(/\^\{\}$/, '')];
|
|
40
|
-
if (unpeeled) {
|
|
41
|
-
unpeeled.sha = peeled.sha;
|
|
42
|
-
delete revs.refs[ref];
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return revs;
|
|
46
|
-
};
|
|
47
|
-
const distTags = (revs) => {
|
|
48
|
-
// not entirely sure what situations would result in an
|
|
49
|
-
// ichabod repo, but best to be careful in Sleepy Hollow anyway
|
|
50
|
-
/* c8 ignore start */
|
|
51
|
-
const HEAD = revs.refs.HEAD ?? {
|
|
52
|
-
sha: undefined,
|
|
53
|
-
};
|
|
54
|
-
/* c8 ignore stop */
|
|
55
|
-
for (const [v, ver] of Object.entries(revs.versions)) {
|
|
56
|
-
// simulate a dist-tags with latest pointing at the
|
|
57
|
-
// 'latest' branch if one exists and is a version,
|
|
58
|
-
// or HEAD if not.
|
|
59
|
-
if (revs.refs.latest && ver.sha === revs.refs.latest.sha) {
|
|
60
|
-
revs['dist-tags'].latest = v;
|
|
61
|
-
}
|
|
62
|
-
else if (ver.sha === HEAD.sha) {
|
|
63
|
-
revs['dist-tags'].HEAD = v;
|
|
64
|
-
if (!revs.refs.latest) {
|
|
65
|
-
revs['dist-tags'].latest = v;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return revs;
|
|
70
|
-
};
|
|
71
|
-
const refType = (ref) => {
|
|
72
|
-
if (ref.startsWith('refs/tags/')) {
|
|
73
|
-
return 'tag';
|
|
74
|
-
}
|
|
75
|
-
if (ref.startsWith('refs/heads/')) {
|
|
76
|
-
return 'branch';
|
|
77
|
-
}
|
|
78
|
-
if (ref.startsWith('refs/pull/')) {
|
|
79
|
-
return 'pull';
|
|
80
|
-
}
|
|
81
|
-
if (ref === 'HEAD') {
|
|
82
|
-
return 'head';
|
|
83
|
-
}
|
|
84
|
-
// Could be anything, ignore for now
|
|
85
|
-
/* c8 ignore next */
|
|
86
|
-
return 'other';
|
|
87
|
-
};
|
|
88
|
-
// return the doc, or null if we should ignore it.
|
|
89
|
-
const lineToRevDoc = (line) => {
|
|
90
|
-
let [sha, rawRef] = line.trim().split(/\s+/, 2);
|
|
91
|
-
if (sha === undefined || rawRef === undefined)
|
|
92
|
-
return undefined;
|
|
93
|
-
sha = sha.trim();
|
|
94
|
-
rawRef = rawRef.trim();
|
|
95
|
-
const type = refType(rawRef);
|
|
96
|
-
switch (type) {
|
|
97
|
-
case 'tag': {
|
|
98
|
-
// refs/tags/foo^{} is the 'peeled tag', ie the commit
|
|
99
|
-
// that is tagged by refs/tags/foo they resolve to the same
|
|
100
|
-
// content, just different objects in git's data structure.
|
|
101
|
-
// But, we care about the thing the tag POINTS to, not the tag
|
|
102
|
-
// object itself, so we only look at the peeled tag refs, and
|
|
103
|
-
// ignore the pointer.
|
|
104
|
-
// For now, though, we have to save both, because some tags
|
|
105
|
-
// don't have peels, if they were not annotated.
|
|
106
|
-
const ref = rawRef.slice('refs/tags/'.length);
|
|
107
|
-
return { name: '', version: '', sha, ref, rawRef, type };
|
|
108
|
-
}
|
|
109
|
-
case 'branch': {
|
|
110
|
-
const ref = rawRef.slice('refs/heads/'.length);
|
|
111
|
-
return { name: '', version: '', sha, ref, rawRef, type };
|
|
112
|
-
}
|
|
113
|
-
case 'pull': {
|
|
114
|
-
// NB: merged pull requests installable with #pull/123/merge
|
|
115
|
-
// for the merged pr, or #pull/123 for the PR head
|
|
116
|
-
const ref = rawRef.slice('refs/'.length).replace(/\/head$/, '');
|
|
117
|
-
return { name: '', version: '', sha, ref, rawRef, type };
|
|
118
|
-
}
|
|
119
|
-
case 'head': {
|
|
120
|
-
const ref = 'HEAD';
|
|
121
|
-
return { name: '', version: '', sha, ref, rawRef, type };
|
|
122
|
-
}
|
|
123
|
-
default:
|
|
124
|
-
// at this point, all we can do is leave the ref un-munged
|
|
125
|
-
return { name: '', version: '', sha, ref: rawRef, rawRef, type };
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const linesToRevsReducer = (revs, line) => {
|
|
129
|
-
const doc = lineToRevDoc(line);
|
|
130
|
-
if (!doc) {
|
|
131
|
-
return revs;
|
|
132
|
-
}
|
|
133
|
-
revs.refs[doc.ref] = doc;
|
|
134
|
-
revs.refs[doc.rawRef] = doc;
|
|
135
|
-
if (doc.type === 'tag') {
|
|
136
|
-
// try to pull a semver value out of tags like `release-v1.2.3`
|
|
137
|
-
// which is a pretty common pattern.
|
|
138
|
-
const match = doc.ref.endsWith('^{}') ?
|
|
139
|
-
null
|
|
140
|
-
: /v?(\d+\.\d+\.\d+(?:[-+].+)?)$/.exec(doc.ref);
|
|
141
|
-
if (match) {
|
|
142
|
-
/* c8 ignore start */
|
|
143
|
-
if (!match[1])
|
|
144
|
-
throw error(`invalid semver tag`, { found: doc.ref });
|
|
145
|
-
/* c8 ignore stop */
|
|
146
|
-
const v = parse(match[1]);
|
|
147
|
-
if (v)
|
|
148
|
-
revs.versions[String(v)] = doc;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return revs;
|
|
152
|
-
};
|
|
153
|
-
//# sourceMappingURL=lines-to-revs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7C,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE;IACxC,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7D,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;IACzB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,oEAAoE;AACpE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE;IACvC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,I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AC;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 type { 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"]}
|
package/dist/make-error.d.ts
DELETED
package/dist/make-error.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"make-error.d.ts","sourceRoot":"","sources":["../src/make-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,uBAAuB,CAAA;AAoB9B,eAAO,MAAM,SAAS,WACZ,iBAAiB,GAAG,iBAAiB,KAC5C,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,EAAE,KAAK,CAQgB,CAAA"}
|
package/dist/make-error.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
const connectionErrorRe = new RegExp([
|
|
3
|
-
'remote error: Internal Server Error',
|
|
4
|
-
'The remote end hung up unexpectedly',
|
|
5
|
-
'Connection timed out',
|
|
6
|
-
'Operation timed out',
|
|
7
|
-
'Failed to connect to .* Timed out',
|
|
8
|
-
'Connection reset by peer',
|
|
9
|
-
'SSL_ERROR_SYSCALL',
|
|
10
|
-
'The requested URL returned error: 503',
|
|
11
|
-
].join('|'));
|
|
12
|
-
const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/;
|
|
13
|
-
export const makeError = (result) => connectionErrorRe.test(result.stderr) ?
|
|
14
|
-
[
|
|
15
|
-
(n) => n < 3,
|
|
16
|
-
error('A git connection error occurred', result),
|
|
17
|
-
]
|
|
18
|
-
: missingPathspecRe.test(result.stderr) ?
|
|
19
|
-
[null, error('The git reference could not be found', result)]
|
|
20
|
-
: [null, error('An unknown git error occurred', result)];
|
|
21
|
-
//# sourceMappingURL=make-error.js.map
|
package/dist/make-error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EACH,EAAE,CAC5C,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC;QACE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;QACpB,KAAK,CAAC,iCAAiC,EAAE,MAAM,CAAC;KACjD;IACH,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACvC,CAAC,IAAI,EAAE,KAAK,CAAC,sCAAsC,EAAE,MAAM,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC,CAAA","sourcesContent":["import type {\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): [null | ((n: number) => boolean), Error] =>\n connectionErrorRe.test(result.stderr) ?\n [\n (n: number) => n < 3,\n error('A git connection error occurred', result),\n ]\n : missingPathspecRe.test(result.stderr) ?\n [null, error('The git reference could not be found', result)]\n : [null, error('An unknown git error occurred', result)]\n"]}
|
package/dist/opts.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PromiseSpawnOptionsStderrString, PromiseSpawnOptionsStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
-
import type { SpawnOptions } from 'node:child_process';
|
|
3
|
-
export declare const opts: (opts?: SpawnOptions) => PromiseSpawnOptionsStderrString & PromiseSpawnOptionsStdoutString;
|
|
4
|
-
//# sourceMappingURL=opts.d.ts.map
|
package/dist/opts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opts.d.ts","sourceRoot":"","sources":["../src/opts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAQtD,eAAO,MAAM,IAAI,UACT,YAAY,KACjB,+BAA+B,GAChC,+BAOA,CAAA"}
|
package/dist/opts.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Values we want to set if they're not already defined by the end user
|
|
2
|
-
// This defaults to accepting new ssh host key fingerprints
|
|
3
|
-
const gitEnv = {
|
|
4
|
-
GIT_ASKPASS: 'echo',
|
|
5
|
-
GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',
|
|
6
|
-
};
|
|
7
|
-
export const opts = (opts = {}) => ({
|
|
8
|
-
acceptFail: true,
|
|
9
|
-
...opts,
|
|
10
|
-
env: opts.env ?? { ...gitEnv, ...process.env },
|
|
11
|
-
stdio: 'pipe',
|
|
12
|
-
stdioString: true,
|
|
13
|
-
shell: false,
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=opts.js.map
|
package/dist/opts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 type {\n PromiseSpawnOptionsStderrString,\n PromiseSpawnOptionsStdoutString,\n} from '@vltpkg/promise-spawn'\nimport type { SpawnOptions } from 'node: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/resolve.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { RevDoc } from '@vltpkg/types';
|
|
2
|
-
import type { GitOptions } from './index.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Given a repo and either a ref or a git specifier Spec object, resolve the
|
|
5
|
-
* appropriate ref that we should clone, ideally witout actually cloning the
|
|
6
|
-
* repository.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare const resolve: (repo: string, ref?: string, opts?: GitOptions) => Promise<import("@vltpkg/types").RevDocEntry | undefined>;
|
|
11
|
-
/**
|
|
12
|
-
* Given a repo's RevDoc object and either a ref or a git specifier Spec
|
|
13
|
-
* object, resolve the appropriate ref that we should clone, witout actually
|
|
14
|
-
* cloning the repository.
|
|
15
|
-
*/
|
|
16
|
-
export declare const resolveRef: (revDoc: RevDoc, ref?: string, opts?: GitOptions) => import("@vltpkg/types").RevDocEntry | undefined;
|
|
17
|
-
//# sourceMappingURL=resolve.d.ts.map
|
package/dist/resolve.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EAAE,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/resolve.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { pickManifest } from '@vltpkg/pick-manifest';
|
|
2
|
-
import { revs } from "./revs.js";
|
|
3
|
-
/**
|
|
4
|
-
* Given a repo and either a ref or a git specifier Spec object, resolve the
|
|
5
|
-
* appropriate ref that we should clone, ideally witout actually cloning the
|
|
6
|
-
* repository.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export const resolve = async (repo, ref = 'HEAD', opts = {}) => {
|
|
11
|
-
const revDoc = await revs(repo, opts);
|
|
12
|
-
/* no resolution possible if we can't read the repo */
|
|
13
|
-
if (!revDoc)
|
|
14
|
-
return undefined;
|
|
15
|
-
return resolveRef(revDoc, ref, opts);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Given a repo's RevDoc object and either a ref or a git specifier Spec
|
|
19
|
-
* object, resolve the appropriate ref that we should clone, witout actually
|
|
20
|
-
* cloning the repository.
|
|
21
|
-
*/
|
|
22
|
-
export const resolveRef = (revDoc, ref = 'HEAD', opts = {}) => {
|
|
23
|
-
const { spec } = opts;
|
|
24
|
-
ref = spec?.gitCommittish || ref;
|
|
25
|
-
if (spec?.range) {
|
|
26
|
-
return pickManifest(revDoc, spec.range, opts);
|
|
27
|
-
}
|
|
28
|
-
if (!ref) {
|
|
29
|
-
return revDoc.refs.HEAD;
|
|
30
|
-
}
|
|
31
|
-
if (revDoc.refs[ref]) {
|
|
32
|
-
return revDoc.refs[ref];
|
|
33
|
-
}
|
|
34
|
-
/* c8 ignore start - typically found above, but just in case */
|
|
35
|
-
const sha = revDoc.shas[ref]?.[0];
|
|
36
|
-
if (sha) {
|
|
37
|
-
return revDoc.refs[sha];
|
|
38
|
-
}
|
|
39
|
-
/* c8 ignore stop */
|
|
40
|
-
return undefined;
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=resolve.js.map
|
package/dist/resolve.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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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ions } from './index.ts'\nimport { revs } from './revs.ts'\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/revs.d.ts
DELETED
package/dist/revs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"revs.d.ts","sourceRoot":"","sources":["../src/revs.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAsB3C,eAAO,MAAM,IAAI,SAAgB,MAAM,SAAQ,UAAU,gCAWxD,CAAA"}
|
package/dist/revs.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { gitScpURL } from '@vltpkg/git-scp-url';
|
|
2
|
-
import { LRUCache } from 'lru-cache';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { linesToRevs } from "./lines-to-revs.js";
|
|
5
|
-
import { spawn } from "./spawn.js";
|
|
6
|
-
const fetchMethod = async (repo, _, options) => {
|
|
7
|
-
const result = await spawn(['ls-remote', repo], options.context);
|
|
8
|
-
const revsDoc = linesToRevs(result.stdout.split('\n'));
|
|
9
|
-
return revsDoc;
|
|
10
|
-
};
|
|
11
|
-
const revsCache = new LRUCache({
|
|
12
|
-
max: 100,
|
|
13
|
-
ttl: 5 * 60 * 1000,
|
|
14
|
-
allowStaleOnFetchAbort: true,
|
|
15
|
-
allowStaleOnFetchRejection: true,
|
|
16
|
-
fetchMethod,
|
|
17
|
-
});
|
|
18
|
-
export const revs = async (repo, opts = {}) => {
|
|
19
|
-
repo = String(gitScpURL(repo) ?? repo).replace(/^git\+/, '');
|
|
20
|
-
if (repo.startsWith('file://'))
|
|
21
|
-
repo = fileURLToPath(repo);
|
|
22
|
-
if (opts.noGitRevCache) {
|
|
23
|
-
const result = await fetchMethod(repo, undefined, {
|
|
24
|
-
context: opts,
|
|
25
|
-
});
|
|
26
|
-
revsCache.set(repo, result);
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
return await revsCache.fetch(repo, { context: opts });
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=revs.js.map
|
package/dist/revs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,UAAU,CAAA;AAExC,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 type {\n SpawnResultStderrString,\n SpawnResultStdoutString,\n} from '@vltpkg/promise-spawn'\nimport { LRUCache } from 'lru-cache'\nimport { fileURLToPath } from 'node:url'\nimport type { GitOptions } from './index.ts'\nimport { linesToRevs } from './lines-to-revs.ts'\nimport type { RevDoc } from '@vltpkg/types'\nimport { spawn } from './spawn.ts'\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/spawn.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SpawnResultStderrString, SpawnResultStdoutString } from '@vltpkg/promise-spawn';
|
|
2
|
-
import type { GitOptions } from './index.ts';
|
|
3
|
-
export declare const spawn: (gitArgs: string[], opts?: GitOptions) => Promise<SpawnResultStderrString & SpawnResultStdoutString>;
|
|
4
|
-
//# sourceMappingURL=spawn.d.ts.map
|
package/dist/spawn.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAK5C,eAAO,MAAM,KAAK,YACP,MAAM,EAAE,SACX,UAAU,KACf,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAkC3D,CAAA"}
|
package/dist/spawn.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { promiseSpawn } from '@vltpkg/promise-spawn';
|
|
2
|
-
import promiseRetry from 'promise-retry';
|
|
3
|
-
import { makeError } from "./make-error.js";
|
|
4
|
-
import { opts as makeOpts } from "./opts.js";
|
|
5
|
-
import { which } from "./which.js";
|
|
6
|
-
export const spawn = async (gitArgs, opts = {}) => {
|
|
7
|
-
const gitPath = which(opts);
|
|
8
|
-
if (gitPath instanceof Error) {
|
|
9
|
-
throw gitPath;
|
|
10
|
-
}
|
|
11
|
-
/* c8 ignore start - undocumented option, only here for tests */
|
|
12
|
-
const args = (opts.allowReplace ||
|
|
13
|
-
gitArgs[0] === '--no-replace-objects') ?
|
|
14
|
-
gitArgs
|
|
15
|
-
: ['--no-replace-objects', ...gitArgs];
|
|
16
|
-
/* c8 ignore stop */
|
|
17
|
-
const retryOpts = {
|
|
18
|
-
retries: opts['fetch-retries'] || 3,
|
|
19
|
-
factor: opts['fetch-retry-factor'] || 2,
|
|
20
|
-
maxTimeout: opts['fetch-retry-maxtimeout'] || 60000,
|
|
21
|
-
minTimeout: opts['fetch-retry-mintimeout'] || 1000,
|
|
22
|
-
};
|
|
23
|
-
return promiseRetry(async (retryFn, num) => {
|
|
24
|
-
const result = await promiseSpawn(gitPath, args, makeOpts(opts));
|
|
25
|
-
if (result.status || result.signal) {
|
|
26
|
-
const [shouldRetry, gitError] = makeError(result);
|
|
27
|
-
if (!shouldRetry?.(num)) {
|
|
28
|
-
throw gitError;
|
|
29
|
-
}
|
|
30
|
-
retryFn(gitError);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}, retryOpts);
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=spawn.js.map
|
package/dist/spawn.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA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YACjD,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,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 { promiseSpawn } from '@vltpkg/promise-spawn'\nimport type {\n SpawnResultStderrString,\n SpawnResultStdoutString,\n} from '@vltpkg/promise-spawn'\nimport promiseRetry from 'promise-retry'\nimport type { WrapOptions } from 'retry'\nimport type { GitOptions } from './index.ts'\nimport { makeError } from './make-error.ts'\nimport { opts as makeOpts } from './opts.ts'\nimport { which } from './which.ts'\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 [shouldRetry, gitError] = makeError(result)\n if (!shouldRetry?.(num)) {\n throw gitError\n }\n retryFn(gitError)\n }\n return result\n }, retryOpts)\n}\n"]}
|
package/dist/user.d.ts
DELETED
package/dist/user.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../src/user.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,OAAO,iBAEjB,OAAO,CAAC,OAAO,GAAG,SAAS,CAsD7B,CAAA"}
|
package/dist/user.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { spawn } from "./spawn.js";
|
|
2
|
-
export const getUser = async (opts = {}) => {
|
|
3
|
-
let name = '';
|
|
4
|
-
let email = '';
|
|
5
|
-
// retrieve user.name
|
|
6
|
-
const oldFlagUserNameResult = await spawn(['config', '--get', 'user.name'], opts);
|
|
7
|
-
if (oldFlagUserNameResult.status || oldFlagUserNameResult.signal) {
|
|
8
|
-
const userNameResult = await spawn(['config', 'get', 'user.name'], opts);
|
|
9
|
-
name =
|
|
10
|
-
userNameResult.status || userNameResult.signal ?
|
|
11
|
-
''
|
|
12
|
-
: userNameResult.stdout.trim();
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
name = oldFlagUserNameResult.stdout.trim();
|
|
16
|
-
}
|
|
17
|
-
// retrieve user.email
|
|
18
|
-
const oldFlagUserEmailResult = await spawn(['config', '--get', 'user.email'], opts);
|
|
19
|
-
if (oldFlagUserEmailResult.status ||
|
|
20
|
-
oldFlagUserEmailResult.signal) {
|
|
21
|
-
const userEmailResult = await spawn(['config', 'get', 'user.email'], opts);
|
|
22
|
-
email =
|
|
23
|
-
userEmailResult.status || userEmailResult.signal ?
|
|
24
|
-
''
|
|
25
|
-
: userEmailResult.stdout.trim();
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
email = oldFlagUserEmailResult.stdout.trim();
|
|
29
|
-
}
|
|
30
|
-
// if fails to find both name & email, then return undefined
|
|
31
|
-
if (!name && !email) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
name,
|
|
36
|
-
email,
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=user.js.map
|
package/dist/user.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAOlC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,IAAI,GAAG,EAAE,EACqB,EAAE;IAChC,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,KAAK,GAAG,EAAE,CAAA;IAEd,qBAAqB;IACrB,MAAM,qBAAqB,GAAG,MAAM,KAAK,CACvC,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,EAChC,IAAI,CACL,CAAA;IACD,IAAI,qBAAqB,CAAC,MAAM,IAAI,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACjE,MAAM,cAAc,GAAG,MAAM,KAAK,CAChC,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,EAC9B,IAAI,CACL,CAAA;QAED,IAAI;YACF,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;gBAC9C,EAAE;gBACJ,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IAClC,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IAC5C,CAAC;IAED,sBAAsB;IACtB,MAAM,sBAAsB,GAAG,MAAM,KAAK,CACxC,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC,EACjC,IAAI,CACL,CAAA;IACD,IACE,sBAAsB,CAAC,MAAM;QAC7B,sBAAsB,CAAC,MAAM,EAC7B,CAAC;QACD,MAAM,eAAe,GAAG,MAAM,KAAK,CACjC,CAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,EAC/B,IAAI,CACL,CAAA;QAED,KAAK;YACH,eAAe,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;gBAChD,EAAE;gBACJ,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IACnC,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IAC9C,CAAC;IAED,4DAA4D;IAC5D,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK;KACN,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { spawn } from './spawn.ts'\n\nexport type GitUser = {\n name?: string\n email?: string\n}\n\nexport const getUser = async (\n opts = {},\n): Promise<GitUser | undefined> => {\n let name = ''\n let email = ''\n\n // retrieve user.name\n const oldFlagUserNameResult = await spawn(\n ['config', '--get', 'user.name'],\n opts,\n )\n if (oldFlagUserNameResult.status || oldFlagUserNameResult.signal) {\n const userNameResult = await spawn(\n ['config', 'get', 'user.name'],\n opts,\n )\n\n name =\n userNameResult.status || userNameResult.signal ?\n ''\n : userNameResult.stdout.trim()\n } else {\n name = oldFlagUserNameResult.stdout.trim()\n }\n\n // retrieve user.email\n const oldFlagUserEmailResult = await spawn(\n ['config', '--get', 'user.email'],\n opts,\n )\n if (\n oldFlagUserEmailResult.status ||\n oldFlagUserEmailResult.signal\n ) {\n const userEmailResult = await spawn(\n ['config', 'get', 'user.email'],\n opts,\n )\n\n email =\n userEmailResult.status || userEmailResult.signal ?\n ''\n : userEmailResult.stdout.trim()\n } else {\n email = oldFlagUserEmailResult.stdout.trim()\n }\n\n // if fails to find both name & email, then return undefined\n if (!name && !email) {\n return undefined\n }\n\n return {\n name,\n email,\n }\n}\n"]}
|
package/dist/which.d.ts
DELETED
package/dist/which.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"which.d.ts","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAI5C,eAAO,MAAM,KAAK,UAAU,UAAU;;EAyBrC,CAAA"}
|
package/dist/which.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { whichSync } from '@vltpkg/which';
|
|
3
|
-
let gitPath = undefined;
|
|
4
|
-
export const which = (opts = {}) => {
|
|
5
|
-
if (opts.git) {
|
|
6
|
-
return opts.git;
|
|
7
|
-
}
|
|
8
|
-
let whichError = undefined;
|
|
9
|
-
if (opts.git !== false) {
|
|
10
|
-
if (!gitPath) {
|
|
11
|
-
try {
|
|
12
|
-
gitPath = whichSync('git');
|
|
13
|
-
}
|
|
14
|
-
catch (er) {
|
|
15
|
-
whichError = er;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!gitPath || opts.git === false) {
|
|
20
|
-
return error('No git binary found in $PATH', {
|
|
21
|
-
code: 'ENOGIT',
|
|
22
|
-
cause: whichError,
|
|
23
|
-
}, which);
|
|
24
|
-
}
|
|
25
|
-
return gitPath;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=which.js.map
|
package/dist/which.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"which.js","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,IAAI,OAAO,GAAuB,SAAS,CAAA;AAE3C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAmB,EAAE,EAAE,EAAE;IAC7C,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IACD,IAAI,UAAU,GAAY,SAAS,CAAA;IACnC,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACZ,UAAU,GAAG,EAAE,CAAA;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;QACnC,OAAO,KAAK,CACV,8BAA8B,EAC9B;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;SAClB,EACD,KAAK,CACN,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { whichSync } from '@vltpkg/which'\nimport type { GitOptions } from './index.ts'\n\nlet gitPath: string | undefined = undefined\n\nexport const which = (opts: GitOptions = {}) => {\n if (opts.git) {\n return opts.git\n }\n let whichError: unknown = undefined\n if (opts.git !== false) {\n if (!gitPath) {\n try {\n gitPath = whichSync('git')\n } catch (er) {\n whichError = er\n }\n }\n }\n if (!gitPath || opts.git === false) {\n return error(\n 'No git binary found in $PATH',\n {\n code: 'ENOGIT',\n cause: whichError,\n },\n which,\n )\n }\n return gitPath\n}\n"]}
|