@jigging/jig 0.1.0-alpha.14 → 0.1.0-alpha.15
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 +1 -1
- package/libexec/installed-cli.js +4565 -4119
- package/libexec/preparation/bun-native-preparation-worker.js +44 -4
- package/package.json +1 -1
|
@@ -5,6 +5,12 @@ import { copyFile, lstat, mkdir, opendir, readFile, rm, writeFile } from "fs/pro
|
|
|
5
5
|
import { dirname, join } from "path";
|
|
6
6
|
|
|
7
7
|
// src/internal/bun-native-lock-policy.ts
|
|
8
|
+
function requirePrivateBunResolutionManifest(value) {
|
|
9
|
+
const manifest = ordinaryRecord(value);
|
|
10
|
+
if (manifest === undefined || ["workspaces", "patchedDependencies", "overrides", "resolutions"].some((field) => manifest[field] !== undefined))
|
|
11
|
+
throw new TypeError("unsupported Bun resolution input");
|
|
12
|
+
requireRegistryDependencyMaps(manifest);
|
|
13
|
+
}
|
|
8
14
|
function requirePrivateBunLockPolicy(value) {
|
|
9
15
|
const lock = ordinaryRecord(value);
|
|
10
16
|
const workspaces = ordinaryRecord(lock?.workspaces);
|
|
@@ -141,6 +147,7 @@ class WorkerFailure extends Error {
|
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
var outputQueue = Promise.resolve();
|
|
150
|
+
var allowResolutionNetwork = process.argv.length === 3 && process.argv[2] === "--allow-resolution-network";
|
|
144
151
|
try {
|
|
145
152
|
const iterator = jsonLines(process.stdin, PRIVATE_BUN_SOURCE_MESSAGE_BYTES)[Symbol.asyncIterator]();
|
|
146
153
|
const first = await iterator.next();
|
|
@@ -150,9 +157,14 @@ try {
|
|
|
150
157
|
if (!(await iterator.next()).done) {
|
|
151
158
|
throw new WorkerFailure("PACKAGE_BUN_PROTOCOL", "preparation source has trailing data");
|
|
152
159
|
}
|
|
153
|
-
|
|
154
|
-
await
|
|
160
|
+
const inputs = source.files.filter(({ path }) => path === "package.json" || path === "bun.lock");
|
|
161
|
+
await materializeSource(inputs);
|
|
162
|
+
const resolving = !inputs.some(({ path }) => path === "bun.lock");
|
|
163
|
+
if (resolving)
|
|
164
|
+
await resolveMissingLock();
|
|
165
|
+
await requireSupportedLock(resolving);
|
|
155
166
|
await install();
|
|
167
|
+
await materializeSource(source.files.filter(({ path }) => path !== "package.json" && path !== "bun.lock"));
|
|
156
168
|
await verifySource(source.files);
|
|
157
169
|
const prepared = await capturePrepared();
|
|
158
170
|
await sendPrepared(prepared);
|
|
@@ -185,7 +197,7 @@ async function verifySource(files) {
|
|
|
185
197
|
}
|
|
186
198
|
}
|
|
187
199
|
}
|
|
188
|
-
async function requireSupportedLock() {
|
|
200
|
+
async function requireSupportedLock(resolved) {
|
|
189
201
|
const lockCopy = "/work/bun-lock.jsonc";
|
|
190
202
|
await copyFile(join(PACKAGE_ROOT, "bun.lock"), lockCopy);
|
|
191
203
|
let value;
|
|
@@ -210,9 +222,37 @@ async function requireSupportedLock() {
|
|
|
210
222
|
try {
|
|
211
223
|
requirePrivateBunLockPolicy(value);
|
|
212
224
|
} catch {
|
|
225
|
+
if (resolved) {
|
|
226
|
+
throw new WorkerFailure("PACKAGE_BUN_RESOLVED_SOURCE_UNSUPPORTED", "resolved dependencies are unsupported; resolution requests may already have occurred");
|
|
227
|
+
}
|
|
213
228
|
unsupportedSource();
|
|
214
229
|
}
|
|
215
230
|
}
|
|
231
|
+
async function resolveMissingLock() {
|
|
232
|
+
if (!allowResolutionNetwork)
|
|
233
|
+
throw new WorkerFailure("PACKAGE_BUN_PROTOCOL", "resolution permission is missing");
|
|
234
|
+
try {
|
|
235
|
+
requirePrivateBunResolutionManifest(JSON.parse(await readFile(join(PACKAGE_ROOT, "package.json"), "utf8")));
|
|
236
|
+
} catch {
|
|
237
|
+
throw new WorkerFailure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "package.json contains unsupported resolution inputs");
|
|
238
|
+
}
|
|
239
|
+
const result = await runChild([
|
|
240
|
+
"--no-env-file",
|
|
241
|
+
"--config=/dev/null",
|
|
242
|
+
"install",
|
|
243
|
+
"--lockfile-only",
|
|
244
|
+
"--production",
|
|
245
|
+
"--ignore-scripts",
|
|
246
|
+
"--backend=copyfile",
|
|
247
|
+
"--linker=hoisted",
|
|
248
|
+
`--cache-dir=${CACHE_ROOT}`,
|
|
249
|
+
"--registry=https://registry.npmjs.org",
|
|
250
|
+
"--no-progress",
|
|
251
|
+
"--no-summary"
|
|
252
|
+
], { cwd: PACKAGE_ROOT, env: { LD_LIBRARY_PATH: "/jig-runtime/lib" } }, 64 * 1024, 64 * 1024);
|
|
253
|
+
if (result.exit !== 0)
|
|
254
|
+
throw new WorkerFailure("PACKAGE_BUN_RESOLUTION_FAILED", "dependency resolution failed; network requests may already have occurred");
|
|
255
|
+
}
|
|
216
256
|
function unsupportedSource() {
|
|
217
257
|
throw new WorkerFailure("PACKAGE_BUN_SOURCE_UNSUPPORTED", "bun.lock contains a dependency source unsupported by this Jig alpha; only the default npm registry is supported");
|
|
218
258
|
}
|
|
@@ -307,7 +347,7 @@ function requireSource(value) {
|
|
|
307
347
|
}
|
|
308
348
|
files.push(Object.freeze({ path: file.path, content: file.content }));
|
|
309
349
|
}
|
|
310
|
-
if (!files.some(({ path }) => path === "package.json") || !files.some(({ path }) => path === "bun.lock")) {
|
|
350
|
+
if (!files.some(({ path }) => path === "package.json") || !files.some(({ path }) => path === "bun.lock") && !allowResolutionNetwork) {
|
|
311
351
|
throw new WorkerFailure("PACKAGE_BUN_PROTOCOL", "locked Bun source is incomplete");
|
|
312
352
|
}
|
|
313
353
|
return Object.freeze({ files: Object.freeze(files) });
|