harnesstap 1.1.0 → 1.3.0
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 +33 -16
- package/dist/apply-QSS4242W.js +67 -0
- package/dist/apply-QSS4242W.js.map +1 -0
- package/dist/approve-CNYQY6DC.js +181 -0
- package/dist/approve-CNYQY6DC.js.map +1 -0
- package/dist/audit-V4SUV7KA.js +434 -0
- package/dist/audit-V4SUV7KA.js.map +1 -0
- package/dist/auth-63FOHIQ3.js +220 -0
- package/dist/auth-63FOHIQ3.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-2NE3QYMP.js +103 -0
- package/dist/chunk-2NE3QYMP.js.map +1 -0
- package/dist/chunk-2P2EOYEW.js +1140 -0
- package/dist/chunk-2P2EOYEW.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-37LQQWMF.js +496 -0
- package/dist/chunk-37LQQWMF.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3PGC6OA3.js +540 -0
- package/dist/chunk-3PGC6OA3.js.map +1 -0
- package/dist/chunk-4IHKBIY3.js +118 -0
- package/dist/chunk-4IHKBIY3.js.map +1 -0
- package/dist/chunk-4ZUBRLSP.js +17 -0
- package/dist/chunk-4ZUBRLSP.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-5TXI6BI2.js +1359 -0
- package/dist/chunk-5TXI6BI2.js.map +1 -0
- package/dist/chunk-6P5IO4BX.js +235 -0
- package/dist/chunk-6P5IO4BX.js.map +1 -0
- package/dist/chunk-ABXUKHAU.js +571 -0
- package/dist/chunk-ABXUKHAU.js.map +1 -0
- package/dist/chunk-AOUDSNRK.js +1357 -0
- package/dist/chunk-AOUDSNRK.js.map +1 -0
- package/dist/chunk-BNDJJAEI.js +311 -0
- package/dist/chunk-BNDJJAEI.js.map +1 -0
- package/dist/chunk-C2IWSFF5.js +818 -0
- package/dist/chunk-C2IWSFF5.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DEJLP7QJ.js +681 -0
- package/dist/chunk-DEJLP7QJ.js.map +1 -0
- package/dist/chunk-DJ6FN6EW.js +532 -0
- package/dist/chunk-DJ6FN6EW.js.map +1 -0
- package/dist/chunk-E4WRTRMH.js +1173 -0
- package/dist/chunk-E4WRTRMH.js.map +1 -0
- package/dist/chunk-E5QXNU3K.js +238 -0
- package/dist/chunk-E5QXNU3K.js.map +1 -0
- package/dist/chunk-EMTBGOR3.js +2959 -0
- package/dist/chunk-EMTBGOR3.js.map +1 -0
- package/dist/chunk-FFWYIGQ4.js +18 -0
- package/dist/chunk-FFWYIGQ4.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IHWAOIAU.js +172 -0
- package/dist/chunk-IHWAOIAU.js.map +1 -0
- package/dist/chunk-IHZUYG66.js +583 -0
- package/dist/chunk-IHZUYG66.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-KCBI6JQC.js +115 -0
- package/dist/chunk-KCBI6JQC.js.map +1 -0
- package/dist/chunk-KDUQMINL.js +60 -0
- package/dist/chunk-KDUQMINL.js.map +1 -0
- package/dist/chunk-KLR2DURP.js +656 -0
- package/dist/chunk-KLR2DURP.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LYQMK6SV.js +87 -0
- package/dist/chunk-LYQMK6SV.js.map +1 -0
- package/dist/chunk-MK3Q37ZN.js +183 -0
- package/dist/chunk-MK3Q37ZN.js.map +1 -0
- package/dist/chunk-MSGAGV7B.js +346 -0
- package/dist/chunk-MSGAGV7B.js.map +1 -0
- package/dist/chunk-MZQRSERO.js +430 -0
- package/dist/chunk-MZQRSERO.js.map +1 -0
- package/dist/chunk-N3WIJXXM.js +691 -0
- package/dist/chunk-N3WIJXXM.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NFYPBTKO.js +302 -0
- package/dist/chunk-NFYPBTKO.js.map +1 -0
- package/dist/chunk-NPO2IG6G.js +491 -0
- package/dist/chunk-NPO2IG6G.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PFUK3HJ4.js +296 -0
- package/dist/chunk-PFUK3HJ4.js.map +1 -0
- package/dist/chunk-PMQ55GDB.js +115 -0
- package/dist/chunk-PMQ55GDB.js.map +1 -0
- package/dist/chunk-QIVE2YFJ.js +514 -0
- package/dist/chunk-QIVE2YFJ.js.map +1 -0
- package/dist/chunk-QKXD3EUF.js +691 -0
- package/dist/chunk-QKXD3EUF.js.map +1 -0
- package/dist/chunk-RNQYUWF6.js +32 -0
- package/dist/chunk-RNQYUWF6.js.map +1 -0
- package/dist/chunk-S2E4SSQV.js +41 -0
- package/dist/chunk-S2E4SSQV.js.map +1 -0
- package/dist/chunk-SN4BXX3B.js +186 -0
- package/dist/chunk-SN4BXX3B.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-T5VRREN4.js +696 -0
- package/dist/chunk-T5VRREN4.js.map +1 -0
- package/dist/chunk-TKBMHZTS.js +10945 -0
- package/dist/chunk-TKBMHZTS.js.map +1 -0
- package/dist/chunk-TNJPTUE4.js +35 -0
- package/dist/chunk-TNJPTUE4.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TXXDMDPN.js +998 -0
- package/dist/chunk-TXXDMDPN.js.map +1 -0
- package/dist/chunk-UWXUBU7V.js +184 -0
- package/dist/chunk-UWXUBU7V.js.map +1 -0
- package/dist/chunk-UYRK2H24.js +141 -0
- package/dist/chunk-UYRK2H24.js.map +1 -0
- package/dist/chunk-V4IXIM3C.js +806 -0
- package/dist/chunk-V4IXIM3C.js.map +1 -0
- package/dist/chunk-VFHVXXP4.js +6438 -0
- package/dist/chunk-VFHVXXP4.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-W7HQ5X3S.js +610 -0
- package/dist/chunk-W7HQ5X3S.js.map +1 -0
- package/dist/chunk-WMSQAFK5.js +65 -0
- package/dist/chunk-WMSQAFK5.js.map +1 -0
- package/dist/chunk-WMYTBJPB.js +364 -0
- package/dist/chunk-WMYTBJPB.js.map +1 -0
- package/dist/chunk-WNLFNCOH.js +7795 -0
- package/dist/chunk-WNLFNCOH.js.map +1 -0
- package/dist/chunk-WRX7CB2M.js +6448 -0
- package/dist/chunk-WRX7CB2M.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-YSXRBUR4.js +682 -0
- package/dist/chunk-YSXRBUR4.js.map +1 -0
- package/dist/chunk-YTC2EG64.js +1759 -0
- package/dist/chunk-YTC2EG64.js.map +1 -0
- package/dist/compile-J3UGQSS3.js +161 -0
- package/dist/compile-J3UGQSS3.js.map +1 -0
- package/dist/config-5BPSZND3.js +438 -0
- package/dist/config-5BPSZND3.js.map +1 -0
- package/dist/doctor-BVFKLJVO.js +111 -0
- package/dist/doctor-BVFKLJVO.js.map +1 -0
- package/dist/environment-3RI5H32O.js +2745 -0
- package/dist/environment-3RI5H32O.js.map +1 -0
- package/dist/github-YFJQVH5K.js +114 -0
- package/dist/github-YFJQVH5K.js.map +1 -0
- package/dist/harness-ECGHPEKA.js +746 -0
- package/dist/harness-ECGHPEKA.js.map +1 -0
- package/dist/help-ELPNPPEM.js +2079 -0
- package/dist/help-ELPNPPEM.js.map +1 -0
- package/dist/help-UL5XLY3I.js +1892 -0
- package/dist/help-UL5XLY3I.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -54362
- package/dist/index.js.map +1 -1
- package/dist/init-UJQTDHW7.js +873 -0
- package/dist/init-UJQTDHW7.js.map +1 -0
- package/dist/lock-XUMJ63NZ.js +455 -0
- package/dist/lock-XUMJ63NZ.js.map +1 -0
- package/dist/marketplace-ZUMOLVXE.js +495 -0
- package/dist/marketplace-ZUMOLVXE.js.map +1 -0
- package/dist/mcp-RZA5O2ND.js +202 -0
- package/dist/mcp-RZA5O2ND.js.map +1 -0
- package/dist/migrate-CYQI2FH6.js +1043 -0
- package/dist/migrate-CYQI2FH6.js.map +1 -0
- package/dist/open-AWOAWLKO.js +32 -0
- package/dist/open-AWOAWLKO.js.map +1 -0
- package/dist/pack-2QD5ZUIO.js +99 -0
- package/dist/pack-2QD5ZUIO.js.map +1 -0
- package/dist/plugin-GQSSSFX4.js +64 -0
- package/dist/plugin-GQSSSFX4.js.map +1 -0
- package/dist/plugin-from-project-SIQUFYIO.js +16 -0
- package/dist/plugin-from-project-SIQUFYIO.js.map +1 -0
- package/dist/policy-CT4JRCJI.js +105 -0
- package/dist/policy-CT4JRCJI.js.map +1 -0
- package/dist/profile-4JQ6LECP.js +1886 -0
- package/dist/profile-4JQ6LECP.js.map +1 -0
- package/dist/project-JG7QWXRG.js +1392 -0
- package/dist/project-JG7QWXRG.js.map +1 -0
- package/dist/resource-QRMR6CSD.js +555 -0
- package/dist/resource-QRMR6CSD.js.map +1 -0
- package/dist/version-LZ5POOXY.js +17 -0
- package/dist/version-LZ5POOXY.js.map +1 -0
- package/package.json +25 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BundleSymlinkError,
|
|
3
|
+
apmGitLegacyPackagePaths,
|
|
4
|
+
apmGitPackageDir,
|
|
5
|
+
apmGitPackageRelativePath,
|
|
6
|
+
assertContainedPath,
|
|
7
|
+
hasParentTraversalSegment,
|
|
8
|
+
upsertPackageCacheEntry
|
|
9
|
+
} from "./chunk-TKBMHZTS.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_GIT_CLONE_TIMEOUT_MS,
|
|
12
|
+
runCommandWithTimeout
|
|
13
|
+
} from "./chunk-TXXDMDPN.js";
|
|
14
|
+
import {
|
|
15
|
+
ensureGithubGitConfigArgs,
|
|
16
|
+
githubHttpsRemoteForAuth,
|
|
17
|
+
resolveGithubAccessToken
|
|
18
|
+
} from "./chunk-C2IWSFF5.js";
|
|
19
|
+
|
|
20
|
+
// src/services/apm-dependencies.ts
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
function splitHashRef(value) {
|
|
25
|
+
const hash = value.lastIndexOf("#");
|
|
26
|
+
if (hash <= 0) {
|
|
27
|
+
return { body: value };
|
|
28
|
+
}
|
|
29
|
+
const body = value.slice(0, hash);
|
|
30
|
+
const ref = value.slice(hash + 1);
|
|
31
|
+
if (!body || !ref) {
|
|
32
|
+
return { body: value };
|
|
33
|
+
}
|
|
34
|
+
return { body, ref };
|
|
35
|
+
}
|
|
36
|
+
function repoNameFromGitRef(value) {
|
|
37
|
+
const withoutGit = value.replace(/\.git$/, "");
|
|
38
|
+
const tail = withoutGit.split("/").filter(Boolean).pop() ?? withoutGit;
|
|
39
|
+
return tail.split(":").pop() ?? tail;
|
|
40
|
+
}
|
|
41
|
+
function looksLikeHost(segment) {
|
|
42
|
+
return segment.includes(".") || segment === "localhost";
|
|
43
|
+
}
|
|
44
|
+
function githubCloneUrl(ownerRepo) {
|
|
45
|
+
const trimmed = ownerRepo.replace(/\.git$/, "");
|
|
46
|
+
return `https://github.com/${trimmed}.git`;
|
|
47
|
+
}
|
|
48
|
+
function cloneUrlFromOrigin(originRef) {
|
|
49
|
+
return originRef.startsWith("git+") ? originRef.slice(4) : originRef;
|
|
50
|
+
}
|
|
51
|
+
function parseGitShorthand(body, raw, ref) {
|
|
52
|
+
const name = repoNameFromGitRef(body);
|
|
53
|
+
const originRef = looksLikeHost(body.split("/")[0] ?? "") ? body : githubCloneUrl(body);
|
|
54
|
+
return {
|
|
55
|
+
raw,
|
|
56
|
+
sourceKind: "git",
|
|
57
|
+
name,
|
|
58
|
+
originRef,
|
|
59
|
+
applySelector: name,
|
|
60
|
+
...ref ? { ref, versionConstraint: ref } : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function parseApmDependencyString(entry) {
|
|
64
|
+
const trimmed = entry.trim();
|
|
65
|
+
const { body, ref } = splitHashRef(trimmed);
|
|
66
|
+
if (body.startsWith("./") || body.startsWith("../") || body.startsWith("~/") || body.startsWith("/") || body.startsWith(".\\") || body.startsWith("..\\") || body.startsWith("~\\")) {
|
|
67
|
+
const name = body.split(/[/\\]/).filter(Boolean).pop() ?? body;
|
|
68
|
+
return {
|
|
69
|
+
raw: trimmed,
|
|
70
|
+
sourceKind: "local",
|
|
71
|
+
name,
|
|
72
|
+
originRef: body,
|
|
73
|
+
applySelector: name
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (body.startsWith("https://") || body.startsWith("http://") || body.startsWith("file://") || body.startsWith("git://") || body.startsWith("git@") || body.startsWith("ssh://git@") || body.startsWith("git+")) {
|
|
77
|
+
const name = repoNameFromGitRef(body);
|
|
78
|
+
return {
|
|
79
|
+
raw: trimmed,
|
|
80
|
+
sourceKind: "git",
|
|
81
|
+
name,
|
|
82
|
+
originRef: cloneUrlFromOrigin(body),
|
|
83
|
+
applySelector: name,
|
|
84
|
+
...ref ? { ref, versionConstraint: ref } : {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const slashParts = body.split("/").filter(Boolean);
|
|
88
|
+
const at = body.lastIndexOf("@");
|
|
89
|
+
if (slashParts.length === 3) {
|
|
90
|
+
const namePart = slashParts[2] ?? body;
|
|
91
|
+
const name = namePart.includes("@") ? namePart.split("@")[0] ?? namePart : namePart;
|
|
92
|
+
return {
|
|
93
|
+
raw: trimmed,
|
|
94
|
+
sourceKind: "catalog",
|
|
95
|
+
name,
|
|
96
|
+
originRef: body,
|
|
97
|
+
applySelector: body,
|
|
98
|
+
...ref ? { ref, versionConstraint: ref } : {}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (at > 0 && !body.slice(0, at).includes("/")) {
|
|
102
|
+
const name = body.slice(0, at);
|
|
103
|
+
return {
|
|
104
|
+
raw: trimmed,
|
|
105
|
+
sourceKind: "marketplace",
|
|
106
|
+
name,
|
|
107
|
+
originRef: body,
|
|
108
|
+
applySelector: body
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (slashParts.length === 2) {
|
|
112
|
+
return parseGitShorthand(body, trimmed, ref);
|
|
113
|
+
}
|
|
114
|
+
if (slashParts.length > 2 && looksLikeHost(slashParts[0] ?? "")) {
|
|
115
|
+
return parseGitShorthand(body, trimmed, ref);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
raw: trimmed,
|
|
119
|
+
sourceKind: "local",
|
|
120
|
+
name: body,
|
|
121
|
+
originRef: body,
|
|
122
|
+
applySelector: body,
|
|
123
|
+
...ref ? { ref, versionConstraint: ref } : {}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function stringMap(value) {
|
|
127
|
+
if (!isRecord(value)) {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const result = {};
|
|
131
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
132
|
+
result[key] = String(entry);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
function parseApmDependencyEntry(entry) {
|
|
137
|
+
if (typeof entry === "string") {
|
|
138
|
+
return parseApmDependencyString(entry);
|
|
139
|
+
}
|
|
140
|
+
if (!isRecord(entry)) {
|
|
141
|
+
throw new Error("dependencies.apm entries must be strings or mappings");
|
|
142
|
+
}
|
|
143
|
+
if (typeof entry.git === "string" && typeof entry.id === "string") {
|
|
144
|
+
throw new Error("dependencies.apm object cannot set both git and id");
|
|
145
|
+
}
|
|
146
|
+
if (typeof entry.marketplace === "string" && typeof entry.name === "string") {
|
|
147
|
+
const version = typeof entry.version === "string" ? entry.version : void 0;
|
|
148
|
+
const originRef = `${entry.name}@${entry.marketplace}`;
|
|
149
|
+
return {
|
|
150
|
+
raw: JSON.stringify(entry),
|
|
151
|
+
sourceKind: "marketplace",
|
|
152
|
+
name: entry.name,
|
|
153
|
+
originRef,
|
|
154
|
+
applySelector: originRef,
|
|
155
|
+
...version ? { versionConstraint: version } : {}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (typeof entry.id === "string") {
|
|
159
|
+
const version = typeof entry.version === "string" ? entry.version : void 0;
|
|
160
|
+
const parsed = parseApmDependencyString(entry.id);
|
|
161
|
+
const selector = version && parsed.sourceKind === "catalog" ? `${entry.id}@${version}` : parsed.applySelector;
|
|
162
|
+
return {
|
|
163
|
+
...parsed,
|
|
164
|
+
raw: JSON.stringify(entry),
|
|
165
|
+
applySelector: selector,
|
|
166
|
+
originRef: parsed.sourceKind === "catalog" ? selector : parsed.originRef,
|
|
167
|
+
...version ? { versionConstraint: version, ref: parsed.ref ?? version } : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (typeof entry.git === "string") {
|
|
171
|
+
const ref = typeof entry.ref === "string" ? entry.ref : void 0;
|
|
172
|
+
const parsed = parseApmDependencyString(ref ? `${entry.git}#${ref}` : entry.git);
|
|
173
|
+
const path = typeof entry.path === "string" && entry.path.length > 0 ? entry.path : void 0;
|
|
174
|
+
return {
|
|
175
|
+
...parsed,
|
|
176
|
+
raw: JSON.stringify(entry),
|
|
177
|
+
originRef: cloneUrlFromOrigin(parsed.originRef),
|
|
178
|
+
...ref ? { ref, versionConstraint: ref } : {},
|
|
179
|
+
...path ? { path } : {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (typeof entry.path === "string") {
|
|
183
|
+
return parseApmDependencyString(entry.path);
|
|
184
|
+
}
|
|
185
|
+
throw new Error("dependencies.apm object must include git, id, path, or marketplace");
|
|
186
|
+
}
|
|
187
|
+
function parseApmDependencyList(value) {
|
|
188
|
+
if (value === void 0) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
if (!Array.isArray(value)) {
|
|
192
|
+
throw new Error("dependencies.apm must be a list");
|
|
193
|
+
}
|
|
194
|
+
return value.map(parseApmDependencyEntry);
|
|
195
|
+
}
|
|
196
|
+
function mcpTransport(value) {
|
|
197
|
+
if (value === "stdio") {
|
|
198
|
+
return "stdio";
|
|
199
|
+
}
|
|
200
|
+
if (value === "http" || value === "sse" || value === "streamable-http") {
|
|
201
|
+
return "http";
|
|
202
|
+
}
|
|
203
|
+
return void 0;
|
|
204
|
+
}
|
|
205
|
+
function parseMcpDependencyEntry(entry) {
|
|
206
|
+
if (typeof entry === "string") {
|
|
207
|
+
const trimmed = entry.trim();
|
|
208
|
+
const name2 = trimmed.split("/").filter(Boolean).pop() ?? trimmed;
|
|
209
|
+
return {
|
|
210
|
+
raw: trimmed,
|
|
211
|
+
name: name2,
|
|
212
|
+
registryId: trimmed,
|
|
213
|
+
selfDefined: false
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (!isRecord(entry)) {
|
|
217
|
+
throw new Error("dependencies.mcp entries must be strings or mappings");
|
|
218
|
+
}
|
|
219
|
+
const name = typeof entry.name === "string" && entry.name.length > 0 ? entry.name : void 0;
|
|
220
|
+
if (!name) {
|
|
221
|
+
throw new Error("dependencies.mcp object must include a name");
|
|
222
|
+
}
|
|
223
|
+
const registry = entry.registry;
|
|
224
|
+
const selfDefined = registry === false;
|
|
225
|
+
const argsRaw = entry.args;
|
|
226
|
+
const args = Array.isArray(argsRaw) ? argsRaw.map((value) => String(value)) : void 0;
|
|
227
|
+
return {
|
|
228
|
+
raw: JSON.stringify(entry),
|
|
229
|
+
name,
|
|
230
|
+
...typeof registry === "string" ? { registryId: registry } : {},
|
|
231
|
+
...!selfDefined && typeof name === "string" && !registry ? { registryId: name } : {},
|
|
232
|
+
transport: mcpTransport(entry.transport),
|
|
233
|
+
...typeof entry.command === "string" ? { command: entry.command } : {},
|
|
234
|
+
...args ? { args } : {},
|
|
235
|
+
...typeof entry.url === "string" ? { url: entry.url } : {},
|
|
236
|
+
...stringMap(entry.env) ? { env: stringMap(entry.env) } : {},
|
|
237
|
+
...stringMap(entry.headers) ? { headers: stringMap(entry.headers) } : {},
|
|
238
|
+
selfDefined
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function parseMcpDependencyList(value) {
|
|
242
|
+
if (value === void 0) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
if (!Array.isArray(value)) {
|
|
246
|
+
throw new Error("dependencies.mcp must be a list");
|
|
247
|
+
}
|
|
248
|
+
return value.map(parseMcpDependencyEntry);
|
|
249
|
+
}
|
|
250
|
+
function collectRuntimeApmDependencies(document) {
|
|
251
|
+
const dependencies = isRecord(document.dependencies) ? document.dependencies : {};
|
|
252
|
+
return parseApmDependencyList(dependencies.apm);
|
|
253
|
+
}
|
|
254
|
+
function collectApmAndDevDependencies(document) {
|
|
255
|
+
const dependencies = isRecord(document.dependencies) ? document.dependencies : {};
|
|
256
|
+
const devDependencies = isRecord(document.devDependencies) ? document.devDependencies : {};
|
|
257
|
+
return {
|
|
258
|
+
apm: [
|
|
259
|
+
...parseApmDependencyList(dependencies.apm),
|
|
260
|
+
...parseApmDependencyList(devDependencies.apm)
|
|
261
|
+
],
|
|
262
|
+
mcp: [
|
|
263
|
+
...parseMcpDependencyList(dependencies.mcp),
|
|
264
|
+
...parseMcpDependencyList(devDependencies.mcp)
|
|
265
|
+
]
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function isFilesystemApmDependency(dependency) {
|
|
269
|
+
if (dependency.sourceKind !== "local") {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
const origin = dependency.originRef;
|
|
273
|
+
return origin.startsWith("./") || origin.startsWith("../") || origin.startsWith("~/") || origin.startsWith("/") || origin.startsWith(".\\") || origin.startsWith("..\\") || origin.startsWith("~\\");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/services/apm-git-resolve.ts
|
|
277
|
+
import { existsSync, lstatSync, mkdirSync, rmSync } from "fs";
|
|
278
|
+
import { join } from "path";
|
|
279
|
+
import semver from "semver";
|
|
280
|
+
var ApmGitResolveError = class extends Error {
|
|
281
|
+
constructor(message) {
|
|
282
|
+
super(message);
|
|
283
|
+
this.name = "ApmGitResolveError";
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
var FULL_SHA = /^[0-9a-f]{40}$/i;
|
|
287
|
+
var LITERAL_SEMVER_TAG = /^v?\d+\.\d+\.\d+$/;
|
|
288
|
+
var RANGE_OPERATOR = /[\^~><*=xX]| \|\|| - /;
|
|
289
|
+
function classifyApmGitRef(ref) {
|
|
290
|
+
if (!ref || ref.trim().length === 0) {
|
|
291
|
+
return "none";
|
|
292
|
+
}
|
|
293
|
+
const trimmed = ref.trim();
|
|
294
|
+
if (FULL_SHA.test(trimmed) || LITERAL_SEMVER_TAG.test(trimmed)) {
|
|
295
|
+
return "literal";
|
|
296
|
+
}
|
|
297
|
+
if (semver.validRange(trimmed) && RANGE_OPERATOR.test(trimmed)) {
|
|
298
|
+
return "semver";
|
|
299
|
+
}
|
|
300
|
+
return "literal";
|
|
301
|
+
}
|
|
302
|
+
function canonicalApmRepoUrl(originRef) {
|
|
303
|
+
const cloneUrl = cloneUrlFromOrigin(originRef.trim());
|
|
304
|
+
if (cloneUrl.startsWith("git@")) {
|
|
305
|
+
const match = cloneUrl.match(/^git@([^:]+):(.+)$/);
|
|
306
|
+
if (match?.[1] && match[2]) {
|
|
307
|
+
return `${match[1].toLowerCase()}/${stripGitSuffix(match[2])}`;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const ssh = cloneUrl.match(/^ssh:\/\/git@([^/]+)\/(.+)$/);
|
|
311
|
+
if (ssh?.[1] && ssh[2]) {
|
|
312
|
+
return `${hostWithoutDefaultPort(ssh[1])}/${stripGitSuffix(ssh[2])}`;
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const parsed = new URL(cloneUrl);
|
|
316
|
+
const host = hostWithoutDefaultPort(parsed.host);
|
|
317
|
+
const path = stripGitSuffix(parsed.pathname.replace(/^\/+/, ""));
|
|
318
|
+
if (parsed.protocol === "file:") {
|
|
319
|
+
return `file:///${path}`;
|
|
320
|
+
}
|
|
321
|
+
return host ? `${host}/${path}` : path;
|
|
322
|
+
} catch {
|
|
323
|
+
return stripGitSuffix(cloneUrl.replace(/^https?:\/\//, ""));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function hostWithoutDefaultPort(host) {
|
|
327
|
+
const lowered = host.toLowerCase();
|
|
328
|
+
return lowered.replace(/:443$/, "").replace(/:22$/, "").replace(/:80$/, "").replace(/:9418$/, "");
|
|
329
|
+
}
|
|
330
|
+
function stripGitSuffix(value) {
|
|
331
|
+
const trimmed = value.replace(/\/+$/, "");
|
|
332
|
+
return trimmed.replace(/\.git$/i, "");
|
|
333
|
+
}
|
|
334
|
+
function apmGitCacheDir(harnesstapDir, repoUrl, commit) {
|
|
335
|
+
const modern = apmGitPackageDir(harnesstapDir, repoUrl, commit);
|
|
336
|
+
if (existsSync(modern)) {
|
|
337
|
+
return modern;
|
|
338
|
+
}
|
|
339
|
+
for (const legacy of apmGitLegacyPackagePaths(harnesstapDir, repoUrl, commit)) {
|
|
340
|
+
if (existsSync(legacy)) {
|
|
341
|
+
return legacy;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return modern;
|
|
345
|
+
}
|
|
346
|
+
function recordApmGitPackageCacheEntry(input) {
|
|
347
|
+
upsertPackageCacheEntry({
|
|
348
|
+
kind: "apm_git",
|
|
349
|
+
origin_ref: input.originRef,
|
|
350
|
+
resolved_key: input.commit.toLowerCase(),
|
|
351
|
+
relative_path: apmGitPackageRelativePath(input.repoUrl, input.commit)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function assertSafeApmVirtualPath(path) {
|
|
355
|
+
const normalized = path.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
356
|
+
if (!normalized || normalized === ".") {
|
|
357
|
+
throw new ApmGitResolveError("dependencies.apm path must be a non-empty repository subpath");
|
|
358
|
+
}
|
|
359
|
+
if (normalized.startsWith("/") || hasParentTraversalSegment(normalized)) {
|
|
360
|
+
throw new ApmGitResolveError(
|
|
361
|
+
`Unsafe dependencies.apm path ${path}: apply aborted closed`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
assertContainedPath(".", normalized);
|
|
365
|
+
}
|
|
366
|
+
var VIRTUAL_FILE_SUFFIXES = [".prompt.md", ".instructions.md", ".agent.md"];
|
|
367
|
+
function isApmVirtualFilePath(path) {
|
|
368
|
+
const lowered = path.replaceAll("\\", "/").toLowerCase();
|
|
369
|
+
return VIRTUAL_FILE_SUFFIXES.some((suffix) => lowered.endsWith(suffix));
|
|
370
|
+
}
|
|
371
|
+
function assertCheckoutPathSafe(checkoutRoot, relativePath) {
|
|
372
|
+
assertSafeApmVirtualPath(relativePath);
|
|
373
|
+
const absolute = join(checkoutRoot, relativePath);
|
|
374
|
+
if (lstatSync(absolute).isSymbolicLink()) {
|
|
375
|
+
throw new BundleSymlinkError(relativePath);
|
|
376
|
+
}
|
|
377
|
+
assertContainedPath(checkoutRoot, relativePath);
|
|
378
|
+
return absolute;
|
|
379
|
+
}
|
|
380
|
+
function runGit(run, args, cwd) {
|
|
381
|
+
return run("git", ensureGithubGitConfigArgs(args), {
|
|
382
|
+
timeoutMs: DEFAULT_GIT_CLONE_TIMEOUT_MS,
|
|
383
|
+
...cwd ? { cwd } : {}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function parseLsRemote(stdout) {
|
|
387
|
+
const refs = [];
|
|
388
|
+
for (const line of stdout.split("\n")) {
|
|
389
|
+
const tab = line.indexOf(" ");
|
|
390
|
+
if (tab <= 0) continue;
|
|
391
|
+
const sha = line.slice(0, tab).trim().toLowerCase();
|
|
392
|
+
const rawName = line.slice(tab + 1).trim();
|
|
393
|
+
if (!FULL_SHA.test(sha) || !rawName) continue;
|
|
394
|
+
const peeled = rawName.endsWith("^{}");
|
|
395
|
+
const name = peeled ? rawName.slice(0, -3) : rawName;
|
|
396
|
+
refs.push({ sha, name, peeled });
|
|
397
|
+
}
|
|
398
|
+
return refs;
|
|
399
|
+
}
|
|
400
|
+
function shaForRefName(refs, name) {
|
|
401
|
+
const matches = refs.filter((entry) => entry.name === name || entry.name.endsWith(`/${name}`));
|
|
402
|
+
const peeled = matches.find((entry) => entry.peeled);
|
|
403
|
+
return peeled?.sha ?? matches[0]?.sha;
|
|
404
|
+
}
|
|
405
|
+
function tagSemver(tagName) {
|
|
406
|
+
const name = tagName.replace(/^refs\/tags\//, "");
|
|
407
|
+
const withoutV = name.startsWith("v") ? name.slice(1) : name;
|
|
408
|
+
if (!semver.valid(withoutV)) {
|
|
409
|
+
return void 0;
|
|
410
|
+
}
|
|
411
|
+
return { tag: name, version: withoutV };
|
|
412
|
+
}
|
|
413
|
+
function selectSemverTag(range, tagNames) {
|
|
414
|
+
const candidates = [];
|
|
415
|
+
for (const tagName of tagNames) {
|
|
416
|
+
const parsed = tagSemver(tagName);
|
|
417
|
+
if (!parsed) continue;
|
|
418
|
+
if (!semver.satisfies(parsed.version, range, { includePrerelease: false })) {
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
candidates.push(parsed);
|
|
422
|
+
}
|
|
423
|
+
if (candidates.length === 0) {
|
|
424
|
+
return void 0;
|
|
425
|
+
}
|
|
426
|
+
candidates.sort((left, right) => {
|
|
427
|
+
const byVersion = semver.rcompare(left.version, right.version);
|
|
428
|
+
if (byVersion !== 0) return byVersion;
|
|
429
|
+
return right.tag < left.tag ? -1 : right.tag > left.tag ? 1 : 0;
|
|
430
|
+
});
|
|
431
|
+
return candidates[0];
|
|
432
|
+
}
|
|
433
|
+
function authorizedGitRemote(url) {
|
|
434
|
+
return githubHttpsRemoteForAuth(url, resolveGithubAccessToken().token);
|
|
435
|
+
}
|
|
436
|
+
function listRemoteTags(run, cloneUrl) {
|
|
437
|
+
const remote = authorizedGitRemote(cloneUrl);
|
|
438
|
+
const result = runGit(run, ["ls-remote", "--tags", remote]);
|
|
439
|
+
if (result.exitCode !== 0) {
|
|
440
|
+
throw new ApmGitResolveError(
|
|
441
|
+
`Failed to list tags for ${cloneUrl}: ${result.stderr.trim() || "git ls-remote failed"}`
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
return parseLsRemote(result.stdout);
|
|
445
|
+
}
|
|
446
|
+
function resolveLiteralRef(run, cloneUrl, ref) {
|
|
447
|
+
if (FULL_SHA.test(ref)) {
|
|
448
|
+
const probe = runGit(run, ["ls-remote", authorizedGitRemote(cloneUrl), ref]);
|
|
449
|
+
if (probe.exitCode === 0) {
|
|
450
|
+
const parsed = parseLsRemote(probe.stdout);
|
|
451
|
+
const sha2 = parsed[0]?.sha ?? ref.toLowerCase();
|
|
452
|
+
if (FULL_SHA.test(sha2)) {
|
|
453
|
+
return sha2;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return ref.toLowerCase();
|
|
457
|
+
}
|
|
458
|
+
const listed = runGit(run, ["ls-remote", authorizedGitRemote(cloneUrl), ref, `refs/heads/${ref}`, `refs/tags/${ref}`]);
|
|
459
|
+
if (listed.exitCode !== 0) {
|
|
460
|
+
throw new ApmGitResolveError(
|
|
461
|
+
`Failed to resolve ${ref} for ${cloneUrl}: ${listed.stderr.trim() || "git ls-remote failed"}`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
const refs = parseLsRemote(listed.stdout);
|
|
465
|
+
const sha = shaForRefName(refs, `refs/tags/${ref}`) ?? shaForRefName(refs, `refs/heads/${ref}`) ?? shaForRefName(refs, ref) ?? refs[0]?.sha;
|
|
466
|
+
if (!sha) {
|
|
467
|
+
throw new ApmGitResolveError(
|
|
468
|
+
`Could not resolve git ref ${ref} for ${cloneUrl}: apply aborted closed`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
return sha;
|
|
472
|
+
}
|
|
473
|
+
function resolveHead(run, cloneUrl) {
|
|
474
|
+
const result = runGit(run, ["ls-remote", authorizedGitRemote(cloneUrl), "HEAD"]);
|
|
475
|
+
if (result.exitCode !== 0) {
|
|
476
|
+
throw new ApmGitResolveError(
|
|
477
|
+
`Failed to resolve HEAD for ${cloneUrl}: ${result.stderr.trim() || "git ls-remote failed"}`
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const sha = parseLsRemote(result.stdout)[0]?.sha;
|
|
481
|
+
if (!sha) {
|
|
482
|
+
throw new ApmGitResolveError(
|
|
483
|
+
`Could not resolve HEAD for ${cloneUrl}: apply aborted closed`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
return sha;
|
|
487
|
+
}
|
|
488
|
+
function lockMatchesDependency(entry, dependency) {
|
|
489
|
+
const repoUrl = canonicalApmRepoUrl(dependency.originRef);
|
|
490
|
+
if (entry.repo_url && entry.repo_url !== repoUrl) {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
if (!entry.repo_url && entry.name !== dependency.name) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
const lockedPath = entry.virtual_path ?? "";
|
|
497
|
+
const declaredPath = dependency.path ?? "";
|
|
498
|
+
return lockedPath === declaredPath;
|
|
499
|
+
}
|
|
500
|
+
function findLockedGit(lock, dependency) {
|
|
501
|
+
if (!lock) return void 0;
|
|
502
|
+
return lock.plugins.find((entry) => lockMatchesDependency(entry, dependency));
|
|
503
|
+
}
|
|
504
|
+
function canReplayLock(entry, dependency, kind) {
|
|
505
|
+
if (!entry.resolved_commit || !FULL_SHA.test(entry.resolved_commit)) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
if (kind === "none") {
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
if (kind === "semver") {
|
|
512
|
+
const constraint = dependency.versionConstraint ?? dependency.ref ?? "";
|
|
513
|
+
return Boolean(entry.constraint && entry.constraint === constraint);
|
|
514
|
+
}
|
|
515
|
+
const declared = dependency.ref ?? dependency.versionConstraint ?? "";
|
|
516
|
+
const locked = entry.resolved_ref ?? "";
|
|
517
|
+
if (!declared && !locked) {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
return declared === locked;
|
|
521
|
+
}
|
|
522
|
+
function resolveApmGitDependency(dependency, options = {}) {
|
|
523
|
+
if (dependency.sourceKind !== "git") {
|
|
524
|
+
throw new ApmGitResolveError(`Expected a git dependency, got ${dependency.sourceKind}`);
|
|
525
|
+
}
|
|
526
|
+
if (dependency.path) {
|
|
527
|
+
assertSafeApmVirtualPath(dependency.path);
|
|
528
|
+
}
|
|
529
|
+
const cloneUrl = cloneUrlFromOrigin(dependency.originRef);
|
|
530
|
+
const repoUrl = canonicalApmRepoUrl(cloneUrl);
|
|
531
|
+
const kind = classifyApmGitRef(dependency.ref ?? dependency.versionConstraint);
|
|
532
|
+
const locked = options.update ? void 0 : findLockedGit(options.lock, dependency);
|
|
533
|
+
if (locked && canReplayLock(locked, dependency, kind)) {
|
|
534
|
+
const lockedCommit = locked.resolved_commit;
|
|
535
|
+
if (!lockedCommit || !FULL_SHA.test(lockedCommit)) {
|
|
536
|
+
throw new ApmGitResolveError(
|
|
537
|
+
`Lock entry for ${dependency.originRef} is missing a resolved commit: apply aborted closed`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
name: dependency.name,
|
|
542
|
+
cloneUrl,
|
|
543
|
+
repoUrl,
|
|
544
|
+
commit: lockedCommit.toLowerCase(),
|
|
545
|
+
...locked.resolved_ref ? { resolvedRef: locked.resolved_ref } : {},
|
|
546
|
+
...locked.constraint ? { constraint: locked.constraint } : {},
|
|
547
|
+
...locked.resolved_tag ? { resolvedTag: locked.resolved_tag } : {},
|
|
548
|
+
...dependency.path ? { virtualPath: dependency.path } : {},
|
|
549
|
+
replayed: true
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
const run = options.runCommand ?? runCommandWithTimeout;
|
|
553
|
+
if (kind === "semver") {
|
|
554
|
+
const constraint = dependency.ref ?? dependency.versionConstraint ?? "";
|
|
555
|
+
const tags = listRemoteTags(run, cloneUrl);
|
|
556
|
+
const tagNames = [...new Set(tags.map((entry) => entry.name.replace(/^refs\/tags\//, "")))];
|
|
557
|
+
const selected = selectSemverTag(constraint, tagNames);
|
|
558
|
+
if (!selected) {
|
|
559
|
+
throw new ApmGitResolveError(
|
|
560
|
+
`No git tag satisfies ${constraint} for ${cloneUrl}: apply aborted closed`
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
const sha = shaForRefName(tags, `refs/tags/${selected.tag}`) ?? resolveLiteralRef(run, cloneUrl, selected.tag);
|
|
564
|
+
return {
|
|
565
|
+
name: dependency.name,
|
|
566
|
+
cloneUrl,
|
|
567
|
+
repoUrl,
|
|
568
|
+
commit: sha,
|
|
569
|
+
resolvedRef: constraint,
|
|
570
|
+
constraint,
|
|
571
|
+
resolvedTag: selected.tag,
|
|
572
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
573
|
+
...dependency.path ? { virtualPath: dependency.path } : {},
|
|
574
|
+
replayed: false
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (kind === "none") {
|
|
578
|
+
const commit2 = resolveHead(run, cloneUrl);
|
|
579
|
+
return {
|
|
580
|
+
name: dependency.name,
|
|
581
|
+
cloneUrl,
|
|
582
|
+
repoUrl,
|
|
583
|
+
commit: commit2,
|
|
584
|
+
...dependency.path ? { virtualPath: dependency.path } : {},
|
|
585
|
+
replayed: false
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
const ref = dependency.ref ?? dependency.versionConstraint ?? "";
|
|
589
|
+
const commit = resolveLiteralRef(run, cloneUrl, ref);
|
|
590
|
+
return {
|
|
591
|
+
name: dependency.name,
|
|
592
|
+
cloneUrl,
|
|
593
|
+
repoUrl,
|
|
594
|
+
commit,
|
|
595
|
+
resolvedRef: ref,
|
|
596
|
+
...dependency.path ? { virtualPath: dependency.path } : {},
|
|
597
|
+
replayed: false
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function checkoutApmGitCommit(resolution, targetDir, runCommand = runCommandWithTimeout) {
|
|
601
|
+
if (existsSync(join(targetDir, ".git"))) {
|
|
602
|
+
const current = runGit(runCommand, ["-C", targetDir, "rev-parse", "HEAD"]);
|
|
603
|
+
if (current.exitCode === 0 && current.stdout.trim().toLowerCase() === resolution.commit) {
|
|
604
|
+
return targetDir;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (existsSync(targetDir)) {
|
|
608
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
609
|
+
}
|
|
610
|
+
mkdirSync(targetDir, { recursive: true });
|
|
611
|
+
const init = runGit(runCommand, ["init", "--quiet", targetDir]);
|
|
612
|
+
if (init.exitCode !== 0) {
|
|
613
|
+
throw new ApmGitResolveError(
|
|
614
|
+
`Failed to initialize checkout for ${resolution.cloneUrl}: ${init.stderr.trim()}`
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
const remote = runGit(runCommand, ["-C", targetDir, "remote", "add", "origin", authorizedGitRemote(resolution.cloneUrl)]);
|
|
618
|
+
if (remote.exitCode !== 0) {
|
|
619
|
+
throw new ApmGitResolveError(
|
|
620
|
+
`Failed to add origin ${resolution.cloneUrl}: ${remote.stderr.trim()}`
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
let fetch = runGit(runCommand, [
|
|
624
|
+
"-C",
|
|
625
|
+
targetDir,
|
|
626
|
+
"fetch",
|
|
627
|
+
"--depth",
|
|
628
|
+
"1",
|
|
629
|
+
"origin",
|
|
630
|
+
resolution.commit
|
|
631
|
+
]);
|
|
632
|
+
if (fetch.exitCode !== 0) {
|
|
633
|
+
fetch = runGit(runCommand, ["-C", targetDir, "fetch", "origin", resolution.commit]);
|
|
634
|
+
}
|
|
635
|
+
if (fetch.exitCode !== 0) {
|
|
636
|
+
throw new ApmGitResolveError(
|
|
637
|
+
`Failed to fetch ${resolution.commit} from ${resolution.cloneUrl}: ${fetch.stderr.trim() || "git fetch failed"}`
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
const checkout = runGit(runCommand, ["-C", targetDir, "checkout", "--quiet", "FETCH_HEAD"]);
|
|
641
|
+
if (checkout.exitCode !== 0) {
|
|
642
|
+
throw new ApmGitResolveError(
|
|
643
|
+
`Failed to checkout ${resolution.commit}: ${checkout.stderr.trim() || "git checkout failed"}`
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
const head = runGit(runCommand, ["-C", targetDir, "rev-parse", "HEAD"]);
|
|
647
|
+
const sha = head.stdout.trim().toLowerCase();
|
|
648
|
+
if (head.exitCode !== 0 || sha !== resolution.commit) {
|
|
649
|
+
throw new ApmGitResolveError(
|
|
650
|
+
`Checkout HEAD ${sha || "(unknown)"} does not match resolved commit ${resolution.commit}: apply aborted closed`
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
return targetDir;
|
|
654
|
+
}
|
|
655
|
+
function resolveAndFetchApmGitDependency(dependency, harnesstapDir, options = {}) {
|
|
656
|
+
const resolution = resolveApmGitDependency(dependency, options);
|
|
657
|
+
const checkoutRoot = checkoutApmGitCommit(
|
|
658
|
+
resolution,
|
|
659
|
+
apmGitCacheDir(harnesstapDir, resolution.repoUrl, resolution.commit),
|
|
660
|
+
options.runCommand
|
|
661
|
+
);
|
|
662
|
+
recordApmGitPackageCacheEntry({
|
|
663
|
+
harnesstapDir,
|
|
664
|
+
repoUrl: resolution.repoUrl,
|
|
665
|
+
commit: resolution.commit,
|
|
666
|
+
originRef: dependency.originRef
|
|
667
|
+
});
|
|
668
|
+
return { ...resolution, checkoutRoot };
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
export {
|
|
672
|
+
collectRuntimeApmDependencies,
|
|
673
|
+
collectApmAndDevDependencies,
|
|
674
|
+
isFilesystemApmDependency,
|
|
675
|
+
ApmGitResolveError,
|
|
676
|
+
canonicalApmRepoUrl,
|
|
677
|
+
isApmVirtualFilePath,
|
|
678
|
+
assertCheckoutPathSafe,
|
|
679
|
+
resolveAndFetchApmGitDependency
|
|
680
|
+
};
|
|
681
|
+
//# sourceMappingURL=chunk-DEJLP7QJ.js.map
|