@jigging/jig 0.1.0-alpha.13 → 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.
@@ -246,8 +246,12 @@ async function enterMain(arguments_) {
246
246
  writeSync(3, `${process.pid}
247
247
  `);
248
248
  closeSync(3);
249
- const output = bubblewrapArguments_.includes("--sync-fd");
250
- const inputDescriptors = bubblewrapArguments_.flatMap((arg, index) => arg === "--ro-bind-data" ? [Number(bubblewrapArguments_[index + 1])] : []);
249
+ const separator = bubblewrapArguments_.indexOf("--");
250
+ if (separator < 0)
251
+ throw new Error("missing rootless command boundary");
252
+ const envelopeArguments = bubblewrapArguments_.slice(0, separator);
253
+ const output = envelopeArguments.includes("--sync-fd");
254
+ const inputDescriptors = envelopeArguments.flatMap((arg, index) => arg === "--file" ? [Number(envelopeArguments[index + 1])] : []);
251
255
  if (inputDescriptors.some((fd, index) => fd !== 6 + index))
252
256
  throw new Error("invalid captured input descriptor order");
253
257
  const child = spawn(bubblewrap, bubblewrapArguments_, {
@@ -337,11 +341,11 @@ function bubblewrapArguments(configuration) {
337
341
  for (const mount of configuration.readOnlyMounts)
338
342
  result.push("--ro-bind", mount.source, mount.destination);
339
343
  if (configuration.inputDirectories.length > 0)
340
- result.push("--size", "1048576", "--tmpfs", "/jig-input");
344
+ result.push("--size", String(16 * 1024 * 1024), "--tmpfs", "/jig-input");
341
345
  for (const path of configuration.inputDirectories)
342
346
  result.push("--dir", path);
343
347
  for (const file of configuration.capturedInputs)
344
- result.push("--ro-bind-data", String(file.fd), file.destination);
348
+ result.push("--perms", "0444", "--file", String(file.fd), file.destination);
345
349
  if (configuration.inputDirectories.length > 0)
346
350
  result.push("--remount-ro", "/jig-input");
347
351
  if (configuration.output)
@@ -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
- await materializeSource(source.files);
154
- await requireSupportedLock();
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) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jigging/jig",
3
- "version": "0.1.0-alpha.13",
3
+ "version": "0.1.0-alpha.15",
4
4
  "description": "A local, secure host for admitted FLOW packages",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {
@@ -42,6 +42,7 @@
42
42
  "dist/index.js",
43
43
  "dist/index.d.ts",
44
44
  "dist/project/author.d.ts",
45
+ "dist/project/commands.d.ts",
45
46
  "dist/json.d.ts",
46
47
  "libexec/installed-cli.js",
47
48
  "libexec/linux-rootless-supervisor.js",