@prisma/cli-engine 0.0.7 → 0.0.9
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/dist/index.d.ts +54 -3
- package/dist/index.js +165 -3
- package/dist/{protocol-C1JQcGl9.js → protocol-D1CRNkhv.js} +25 -4
- package/dist/{protocol-CpZLdxML.d.ts → protocol-YjqPCCOG.d.ts} +23 -3
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +2 -2
- package/dist/{run-summary-DQx6CRvB.d.ts → report-Bh6-ntIa.d.ts} +269 -74
- package/dist/testing.d.ts +31 -2
- package/dist/testing.js +52 -26
- package/dist/{token-claims-DZ3p13Qu.js → token-claims-CGQ-5m9N.js} +1101 -164
- package/package.json +5 -2
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-
|
|
1
|
+
import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-CGQ-5m9N.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
//#region src/in-memory-credential-manager.ts
|
|
4
4
|
/**
|
|
@@ -317,6 +317,21 @@ function recordingSpawn(adapter, spawns) {
|
|
|
317
317
|
};
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
+
function runEnv(environmentCredential, env) {
|
|
321
|
+
if (environmentCredential === void 0) return env ?? {};
|
|
322
|
+
return {
|
|
323
|
+
PRISMA_SERVICE_TOKEN: environmentCredential.token,
|
|
324
|
+
...env
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function relaySignalOnAbort(abort, deliver) {
|
|
328
|
+
if (abort === void 0) return;
|
|
329
|
+
if (abort.aborted) {
|
|
330
|
+
deliver(abort.reason);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
abort.addEventListener("abort", () => deliver(abort.reason), { once: true });
|
|
334
|
+
}
|
|
320
335
|
function inputStreamFromString(text) {
|
|
321
336
|
const bytes = new TextEncoder().encode(text);
|
|
322
337
|
return { async *[Symbol.asyncIterator]() {
|
|
@@ -337,19 +352,31 @@ function createTestCli(spec) {
|
|
|
337
352
|
credential: spec.credential,
|
|
338
353
|
environmentCredential: spec.environmentCredential
|
|
339
354
|
});
|
|
355
|
+
const managementApiBaseUrl = spec.managementApi?.baseUrl ?? "https://test.invalid";
|
|
340
356
|
const managementApiClientConfig = spec.managementApiClientConfig ?? {
|
|
341
357
|
clientId: "test-client-id",
|
|
342
358
|
redirectUri: "https://test.invalid/auth/callback",
|
|
343
|
-
apiBaseUrl:
|
|
359
|
+
apiBaseUrl: managementApiBaseUrl,
|
|
344
360
|
authBaseUrl: "https://auth.test.invalid"
|
|
345
361
|
};
|
|
362
|
+
const loadConfig = spec.loadConfig ?? (async (configPath) => ({
|
|
363
|
+
path: configPath ?? "prisma.config.ts",
|
|
364
|
+
sections: spec.config ?? {},
|
|
365
|
+
diagnostics: []
|
|
366
|
+
}));
|
|
367
|
+
const spawnChild = spec.spawn ?? scriptedSpawn(spec.spawnScript ?? (() => ({
|
|
368
|
+
exitCode: 0,
|
|
369
|
+
signal: null
|
|
370
|
+
})));
|
|
371
|
+
const openUrl = spec.openUrl ?? (() => {});
|
|
346
372
|
const engine = buildEngine(
|
|
347
373
|
{
|
|
348
374
|
name: "prisma-test",
|
|
349
375
|
version: "0.0.0",
|
|
350
376
|
commandFamilies: spec.commandFamilies ?? [],
|
|
351
377
|
groups: spec.groups ?? {},
|
|
352
|
-
commands: spec.commands
|
|
378
|
+
commands: spec.commands,
|
|
379
|
+
telemetry: spec.telemetry
|
|
353
380
|
},
|
|
354
381
|
/** Waiting is instant under test: browserWait's polling is driven
|
|
355
382
|
* by the seeded clock, never by real time. */
|
|
@@ -369,6 +396,7 @@ function createTestCli(spec) {
|
|
|
369
396
|
const events = [];
|
|
370
397
|
let presented;
|
|
371
398
|
const spawns = [];
|
|
399
|
+
const telemetry = [];
|
|
372
400
|
const signalListeners = /* @__PURE__ */ new Set();
|
|
373
401
|
const deliverSignal = (reason) => {
|
|
374
402
|
const signal = reason === "SIGTERM" ? "SIGTERM" : "SIGINT";
|
|
@@ -378,20 +406,21 @@ function createTestCli(spec) {
|
|
|
378
406
|
stdout: { write: (text) => {
|
|
379
407
|
stdoutText += text;
|
|
380
408
|
} },
|
|
381
|
-
stderr: {
|
|
382
|
-
|
|
383
|
-
|
|
409
|
+
stderr: {
|
|
410
|
+
write: (text) => {
|
|
411
|
+
stderrText += text;
|
|
412
|
+
},
|
|
413
|
+
columns: opts?.columns?.stderr
|
|
414
|
+
},
|
|
384
415
|
stdin: inputStreamFromString(opts?.stdin ?? ""),
|
|
385
416
|
cwd: opts?.cwd ?? "/",
|
|
386
|
-
env: spec.environmentCredential
|
|
387
|
-
PRISMA_SERVICE_TOKEN: spec.environmentCredential.token,
|
|
388
|
-
...opts?.env
|
|
389
|
-
},
|
|
417
|
+
env: runEnv(spec.environmentCredential, opts?.env),
|
|
390
418
|
isTty: {
|
|
391
419
|
stdin: opts?.isTty?.stdin ?? false,
|
|
392
420
|
stdout: opts?.isTty?.stdout ?? false,
|
|
393
421
|
stderr: opts?.isTty?.stderr ?? false
|
|
394
422
|
},
|
|
423
|
+
isCI: opts?.isCI ?? spec.isCI ?? false,
|
|
395
424
|
exit: (code) => {
|
|
396
425
|
throw new Error(`@prisma/cli-engine: runtime.exit(${code}) reached the test harness`);
|
|
397
426
|
},
|
|
@@ -401,20 +430,18 @@ function createTestCli(spec) {
|
|
|
401
430
|
signalListeners.delete(cb);
|
|
402
431
|
};
|
|
403
432
|
},
|
|
404
|
-
loadConfig
|
|
405
|
-
path: configPath ?? "prisma.config.ts",
|
|
406
|
-
sections: spec.config ?? {},
|
|
407
|
-
diagnostics: []
|
|
408
|
-
})),
|
|
433
|
+
loadConfig,
|
|
409
434
|
credentialManager,
|
|
410
435
|
managementApiClientConfig,
|
|
411
|
-
spawn: recordingSpawn(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
436
|
+
spawn: recordingSpawn(spawnChild, spawns),
|
|
437
|
+
spawnTelemetry: spec.telemetrySpawner === null ? void 0 : (payload) => {
|
|
438
|
+
telemetry.push(payload);
|
|
439
|
+
spec.telemetrySpawner?.(payload);
|
|
440
|
+
},
|
|
441
|
+
openUrl,
|
|
442
|
+
managementApi: { baseUrl: managementApiBaseUrl },
|
|
443
|
+
packageManager: spec.packageManager,
|
|
444
|
+
runPackageManager: spec.packageManagerRunner
|
|
418
445
|
};
|
|
419
446
|
const running = engine.execute(argv, runtime, {
|
|
420
447
|
onEvent: (event) => {
|
|
@@ -431,9 +458,7 @@ function createTestCli(spec) {
|
|
|
431
458
|
answers: opts?.answers,
|
|
432
459
|
managementApi: spec.managementApi?.client === void 0 ? void 0 : { client: spec.managementApi.client }
|
|
433
460
|
});
|
|
434
|
-
|
|
435
|
-
if (abort !== void 0) if (abort.aborted) deliverSignal(abort.reason);
|
|
436
|
-
else abort.addEventListener("abort", () => deliverSignal(abort.reason), { once: true });
|
|
461
|
+
relaySignalOnAbort(opts?.abort, deliverSignal);
|
|
437
462
|
return {
|
|
438
463
|
exitCode: await running,
|
|
439
464
|
stdout: stdoutText,
|
|
@@ -441,7 +466,8 @@ function createTestCli(spec) {
|
|
|
441
466
|
json: frames,
|
|
442
467
|
events,
|
|
443
468
|
presented,
|
|
444
|
-
spawns
|
|
469
|
+
spawns,
|
|
470
|
+
telemetry
|
|
445
471
|
};
|
|
446
472
|
}
|
|
447
473
|
};
|