@prisma/orm-toolchain 8.0.0-rc.21 → 8.0.0-rc.21-dev.2
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/cli-telemetry.mjs +3 -275
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.d.mts +11 -1
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +336 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/{exports-CnTIYbnR.mjs → exports-DET_AbNt.mjs} +8 -3
- package/dist/exports-DET_AbNt.mjs.map +1 -0
- package/dist/exports-DwuO4y2c.mjs +278 -0
- package/dist/exports-DwuO4y2c.mjs.map +1 -0
- package/dist/{import-roots-TXcwr_U0.mjs → import-roots-A66iGb4c.mjs} +2 -2
- package/dist/{import-roots-TXcwr_U0.mjs.map → import-roots-A66iGb4c.mjs.map} +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/{ref-D-HCqZAl-DZcqYpTO.mjs → ref-D-HCqZAl-Bbop38S7.mjs} +2 -2
- package/dist/{ref-D-HCqZAl-DZcqYpTO.mjs.map → ref-D-HCqZAl-Bbop38S7.mjs.map} +1 -1
- package/dist/{shells-BQdc-Ixy.mjs → shells-BfiPyJDF.mjs} +6 -5
- package/dist/shells-BfiPyJDF.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/exports-CnTIYbnR.mjs.map +0 -1
- package/dist/shells-BQdc-Ixy.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -9,10 +9,11 @@ import { r as getEmittedArtifactPaths } from "./exports-BCIlMjIW-DkUBVDzl.mjs";
|
|
|
9
9
|
import { r as isInSpaceHistory } from "./graph-membership-DxpNgxfZ-BfqA-H7V.mjs";
|
|
10
10
|
import { d as writeRef, r as readRef } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
|
|
11
11
|
import { a as contractHashAtMarker } from "./aggregate-CNSeEdzt.mjs";
|
|
12
|
-
import { i as createScaffoldSpecifierResolver } from "./import-roots-
|
|
12
|
+
import { i as createScaffoldSpecifierResolver } from "./import-roots-A66iGb4c.mjs";
|
|
13
13
|
import { o as isLiveMarkerRef } from "./ref-resolution-Eo0QHp4f.mjs";
|
|
14
|
-
import { $ as refuseContractSpaceIntegrity, A as executeRefDeleteCommand, B as loadAggregateIntegrityViolations, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as looksLikePath, H as loadContractSource, I as isStatementVerb, J as matchConsents, K as mapContractAtError, L as labelsText, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as readMigrationRefs, R as listRefsByContractHash, St as withWarningFindings, U as loadContractSourceWithStack, V as loadContractRawSafely, W as loadContractSpaceAggregateForCli, X as planEverySpace, Y as migrationSpaceListEntriesFromAggregate, Z as preflightRefAdvancement, _ as deriveStatusEdgeAnnotations, _t as snapshotVerifierFor, a as advanceRefSafely, at as requireDatabaseForLiveMarkerUse, b as enumerateCheckSpaces, bt as toDeclaredExtensionsFromRaw, ct as resolveContractRefToSnapshot, d as buildRefAdvancementFields, f as checkSingleTarget, g as createControlClient, gt as runMigrationList, h as convertAndDelete, ht as runMigrationCheck, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as renamedAndDeleted, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refusePackageCorruptionOnAggregate, ot as resolveAppTargetPath, p as computeRefAdvancementName, pt as retryCommandFor, r as RECORDED_CONTRACT_REF_FORMS, rt as refuseUnknownInvariants, s as appliedHashesFromLedger, st as resolveContractRef$1, t as ALL_CONTRACT_REF_FORMS, tt as refuseMissingInvariantPath, u as buildReadAggregate, ut as resolveMigrationRef, vt as sourceWarningDiagnostic, x as executeContractEmit, xt as validateLoadedContract, yt as statusForMigrationHash, z as liveMarkerUse } from "./ref-D-HCqZAl-
|
|
14
|
+
import { $ as refuseContractSpaceIntegrity, A as executeRefDeleteCommand, B as loadAggregateIntegrityViolations, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as looksLikePath, H as loadContractSource, I as isStatementVerb, J as matchConsents, K as mapContractAtError, L as labelsText, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as readMigrationRefs, R as listRefsByContractHash, St as withWarningFindings, U as loadContractSourceWithStack, V as loadContractRawSafely, W as loadContractSpaceAggregateForCli, X as planEverySpace, Y as migrationSpaceListEntriesFromAggregate, Z as preflightRefAdvancement, _ as deriveStatusEdgeAnnotations, _t as snapshotVerifierFor, a as advanceRefSafely, at as requireDatabaseForLiveMarkerUse, b as enumerateCheckSpaces, bt as toDeclaredExtensionsFromRaw, ct as resolveContractRefToSnapshot, d as buildRefAdvancementFields, f as checkSingleTarget, g as createControlClient, gt as runMigrationList, h as convertAndDelete, ht as runMigrationCheck, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as renamedAndDeleted, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, n as NO_REF_ADVANCEMENT, nt as refusePackageCorruptionOnAggregate, ot as resolveAppTargetPath, p as computeRefAdvancementName, pt as retryCommandFor, r as RECORDED_CONTRACT_REF_FORMS, rt as refuseUnknownInvariants, s as appliedHashesFromLedger, st as resolveContractRef$1, t as ALL_CONTRACT_REF_FORMS, tt as refuseMissingInvariantPath, u as buildReadAggregate, ut as resolveMigrationRef, vt as sourceWarningDiagnostic, x as executeContractEmit, xt as validateLoadedContract, yt as statusForMigrationHash, z as liveMarkerUse } from "./ref-D-HCqZAl-Bbop38S7.mjs";
|
|
15
15
|
import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
|
|
16
|
+
import { a as resolveGating, i as readUserConfig, r as ensureInstallationId, s as runTelemetry, u as userConfigPath } from "./exports-DwuO4y2c.mjs";
|
|
16
17
|
import { createRequire } from "node:module";
|
|
17
18
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
18
19
|
import { CliStructuredError } from "@prisma/orm-framework/errors/control";
|
|
@@ -23,11 +24,12 @@ import { basename, dirname, extname, isAbsolute, join, normalize, relative, reso
|
|
|
23
24
|
import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
24
25
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
25
26
|
import { type } from "arktype";
|
|
26
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
27
|
+
import { existsSync, fstatSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
27
28
|
import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
|
|
28
29
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
29
|
-
import { pathToFileURL } from "node:url";
|
|
30
|
-
import { defineCommand, defineCommandFamily, defineServerCommand, flag, noDataLines, positional } from "@prisma/cli-engine";
|
|
30
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
31
|
+
import { createCli, defineCommand, defineCommandFamily, defineServerCommand, flag, noDataLines, positional, telemetryCommandGroup } from "@prisma/cli-engine";
|
|
32
|
+
import process$1 from "node:process";
|
|
31
33
|
import { CliStructuredError as CliStructuredError$1, notOk as notOk$1, ok as ok$1 } from "@prisma/cli-engine/protocol";
|
|
32
34
|
import { printPsl } from "@prisma/orm-framework/psl-printer";
|
|
33
35
|
import { DEFAULT_CONTRACT_SOURCE_DIR, defaultContractOutputPath } from "@prisma/orm-framework/config/config-types";
|
|
@@ -39,8 +41,10 @@ import { detect } from "package-manager-detector/detect";
|
|
|
39
41
|
import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
40
42
|
import stringWidth from "string-width";
|
|
41
43
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
44
|
+
import { isCI } from "ci-info";
|
|
42
45
|
import { build } from "esbuild";
|
|
43
|
-
//#region ../../../1-framework/3-tooling/cli/dist/
|
|
46
|
+
//#region ../../../1-framework/3-tooling/cli/dist/cli-Bmb-VQKh.mjs
|
|
47
|
+
var version = "8.0.0-rc.21-dev.2";
|
|
44
48
|
const ESCAPES = {
|
|
45
49
|
"\\": "\\\\",
|
|
46
50
|
" ": "\\t",
|
|
@@ -7087,7 +7091,7 @@ const lspCommand = defineServerCommand({
|
|
|
7087
7091
|
} },
|
|
7088
7092
|
handler: async (args, io) => {
|
|
7089
7093
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
7090
|
-
const { startServer } = await import("./exports-
|
|
7094
|
+
const { startServer } = await import("./exports-DET_AbNt.mjs");
|
|
7091
7095
|
return startServer({
|
|
7092
7096
|
stdin: io.stdin,
|
|
7093
7097
|
stdout: io.stdout,
|
|
@@ -11814,6 +11818,312 @@ async function loadOrmConfig(options) {
|
|
|
11814
11818
|
diagnostics: []
|
|
11815
11819
|
};
|
|
11816
11820
|
}
|
|
11821
|
+
/** A manager that could not be launched at all reports the same as one that failed. */
|
|
11822
|
+
const LAUNCH_FAILURE_EXIT_CODE = 1;
|
|
11823
|
+
/**
|
|
11824
|
+
* Runs the package-manager invocation the engine composed. This is the bin's
|
|
11825
|
+
* half of the capability: the engine chooses the manager and spells the argv,
|
|
11826
|
+
* and never imports a child-process module of its own.
|
|
11827
|
+
*/
|
|
11828
|
+
const runPackageManager = (request) => new Promise((resolve) => {
|
|
11829
|
+
const child = spawn(request.file, [...request.args], {
|
|
11830
|
+
cwd: request.cwd,
|
|
11831
|
+
signal: request.signal,
|
|
11832
|
+
stdio: [
|
|
11833
|
+
"ignore",
|
|
11834
|
+
"pipe",
|
|
11835
|
+
"pipe"
|
|
11836
|
+
]
|
|
11837
|
+
});
|
|
11838
|
+
let stderr = "";
|
|
11839
|
+
const keepTail = (chunk) => {
|
|
11840
|
+
stderr = (stderr + chunk).slice(-65536);
|
|
11841
|
+
};
|
|
11842
|
+
const settle = (exitCode) => {
|
|
11843
|
+
resolve({
|
|
11844
|
+
exitCode,
|
|
11845
|
+
stderr
|
|
11846
|
+
});
|
|
11847
|
+
};
|
|
11848
|
+
child.stdout?.setEncoding("utf-8");
|
|
11849
|
+
child.stdout?.on("data", (chunk) => request.onOutput("data", chunk));
|
|
11850
|
+
child.stderr?.setEncoding("utf-8");
|
|
11851
|
+
child.stderr?.on("data", (chunk) => {
|
|
11852
|
+
keepTail(chunk);
|
|
11853
|
+
request.onOutput("diagnostic", chunk);
|
|
11854
|
+
});
|
|
11855
|
+
child.on("error", (error) => {
|
|
11856
|
+
keepTail(error.message);
|
|
11857
|
+
settle(LAUNCH_FAILURE_EXIT_CODE);
|
|
11858
|
+
});
|
|
11859
|
+
child.on("close", (code) => settle(code ?? LAUNCH_FAILURE_EXIT_CODE));
|
|
11860
|
+
});
|
|
11861
|
+
/**
|
|
11862
|
+
* Returns true when the process is running in any CI environment recognised
|
|
11863
|
+
* by the `ci-info` package. The single source of truth for CI detection
|
|
11864
|
+
* across this CLI — colour-output suppression and telemetry-skip both call
|
|
11865
|
+
* this helper, so neither path drifts from the other when a new CI provider
|
|
11866
|
+
* is added upstream.
|
|
11867
|
+
*
|
|
11868
|
+
* `ci-info` checks the standard `CI=true` marker plus dozens of
|
|
11869
|
+
* provider-specific environment variables (Buildkite, Jenkins, Drone,
|
|
11870
|
+
* Bitbucket Pipelines, Azure Pipelines, AWS CodeBuild, …) that the raw
|
|
11871
|
+
* `process.env.CI` read misses.
|
|
11872
|
+
*
|
|
11873
|
+
*/
|
|
11874
|
+
function isCI$1() {
|
|
11875
|
+
return isCI;
|
|
11876
|
+
}
|
|
11877
|
+
function senderPath() {
|
|
11878
|
+
return fileURLToPath(new URL(import.meta.resolve("@internal/cli-telemetry/sender")));
|
|
11879
|
+
}
|
|
11880
|
+
function firstRunNotice(configPath) {
|
|
11881
|
+
return [
|
|
11882
|
+
"Prisma ORM collects anonymous CLI usage data, enabled by default.",
|
|
11883
|
+
"What's collected and why: https://www.prisma.io/docs/cli/telemetry.",
|
|
11884
|
+
"Opt out: run \"prisma telemetry disable\", set DO_NOT_TRACK=1 or",
|
|
11885
|
+
`PRISMA_DISABLE_TELEMETRY=1, or set "enableTelemetry": false in ${configPath}.`
|
|
11886
|
+
].join(" ");
|
|
11887
|
+
}
|
|
11888
|
+
/**
|
|
11889
|
+
* The engine's value-free snapshot, in the shape the existing sanitiser reads.
|
|
11890
|
+
* It drops the leading segment, so the binary name goes back on the front;
|
|
11891
|
+
* positional values are never reported, and the field exists only to make that
|
|
11892
|
+
* exclusion legible.
|
|
11893
|
+
*/
|
|
11894
|
+
function senderCommandShape(snapshot) {
|
|
11895
|
+
return {
|
|
11896
|
+
commandPath: ["prisma", ...snapshot.commandPath],
|
|
11897
|
+
positionalArgs: [],
|
|
11898
|
+
options: snapshot.flags.map((entry) => ({
|
|
11899
|
+
attributeName: entry.name,
|
|
11900
|
+
longName: `--${entry.name}`,
|
|
11901
|
+
source: entry.source
|
|
11902
|
+
}))
|
|
11903
|
+
};
|
|
11904
|
+
}
|
|
11905
|
+
/**
|
|
11906
|
+
* Resolves the telemetry decision once per process and returns the hook to
|
|
11907
|
+
* attach, or nothing at all when telemetry is off — a disabled run carries no
|
|
11908
|
+
* hook. The first-run disclosure prints here, before the command runs, so the
|
|
11909
|
+
* user learns what telemetry records before any output.
|
|
11910
|
+
*
|
|
11911
|
+
* The event fires from `onSettled`, after settlement, so it carries the exit
|
|
11912
|
+
* code. A run killed before settlement, and a run that never reaches a mounted
|
|
11913
|
+
* command, emit nothing.
|
|
11914
|
+
*/
|
|
11915
|
+
function resolveTelemetryHooks(proc, options) {
|
|
11916
|
+
const inCI = options?.inCI ?? isCI$1();
|
|
11917
|
+
if (inCI) return;
|
|
11918
|
+
const userConfig = readUserConfig();
|
|
11919
|
+
if (!resolveGating({
|
|
11920
|
+
env: proc.env,
|
|
11921
|
+
config: userConfig
|
|
11922
|
+
}).enabled) return;
|
|
11923
|
+
const storedId = userConfig.installationId;
|
|
11924
|
+
const hasStoredId = typeof storedId === "string" && storedId.length > 0;
|
|
11925
|
+
if (!hasStoredId) try {
|
|
11926
|
+
proc.stderr.write(`${firstRunNotice(userConfigPath())}\n`);
|
|
11927
|
+
} catch {}
|
|
11928
|
+
const fire = options?.fire ?? runTelemetry;
|
|
11929
|
+
return { onSettled: (summary) => {
|
|
11930
|
+
try {
|
|
11931
|
+
let config = userConfig;
|
|
11932
|
+
if (!hasStoredId) try {
|
|
11933
|
+
config = {
|
|
11934
|
+
...config,
|
|
11935
|
+
installationId: ensureInstallationId()
|
|
11936
|
+
};
|
|
11937
|
+
} catch {}
|
|
11938
|
+
fire({
|
|
11939
|
+
command: senderCommandShape(summary.snapshot),
|
|
11940
|
+
version,
|
|
11941
|
+
exitCode: summary.exitCode,
|
|
11942
|
+
projectRoot: proc.cwd(),
|
|
11943
|
+
senderPath: options?.senderPath ?? senderPath(),
|
|
11944
|
+
isCI: inCI,
|
|
11945
|
+
env: proc.env,
|
|
11946
|
+
userConfig: config
|
|
11947
|
+
});
|
|
11948
|
+
} catch {}
|
|
11949
|
+
} };
|
|
11950
|
+
}
|
|
11951
|
+
/**
|
|
11952
|
+
* This repo's stand-in for the unified Prisma CLI: it mounts the ORM command
|
|
11953
|
+
* family exactly the way the real host does — every command at its family
|
|
11954
|
+
* key, which spells the unified CLI's mount path (`contract format`,
|
|
11955
|
+
* `db migrate`, `migration ref …`, `orm init`) — same command paths, same
|
|
11956
|
+
* `prisma.config.ts`, so examples and e2e tests exercise the commands as
|
|
11957
|
+
* users run them. The real host lives in the prisma-cli repo and consumes
|
|
11958
|
+
* {@link ormCommandFamily} from this package's exports.
|
|
11959
|
+
*/
|
|
11960
|
+
const BIN_NAME = "prisma";
|
|
11961
|
+
/**
|
|
11962
|
+
* The engine's consent surface — `telemetry status|enable|disable` and the
|
|
11963
|
+
* group help that belongs to them. Mounted whole, mirroring the unified
|
|
11964
|
+
* `prisma` bin's mount points.
|
|
11965
|
+
*/
|
|
11966
|
+
const telemetry = telemetryCommandGroup({ docsUrl: "https://www.prisma.io/docs/cli/telemetry" });
|
|
11967
|
+
const BIN_GROUPS = {
|
|
11968
|
+
orm: {
|
|
11969
|
+
brief: "Initialize a Prisma ORM project",
|
|
11970
|
+
description: "Project initialization for the ORM. The other ORM commands mount under\ntheir workflow groups (contract, db, migration); only init lives here."
|
|
11971
|
+
},
|
|
11972
|
+
contract: {
|
|
11973
|
+
brief: "Contract management commands",
|
|
11974
|
+
description: "Define and emit your application data contract. The contract describes your\nschema as a declarative data structure that can be signed and verified\nagainst your database."
|
|
11975
|
+
},
|
|
11976
|
+
db: {
|
|
11977
|
+
brief: "Live database commands",
|
|
11978
|
+
description: "Inspect, bootstrap, verify and sign the live database against the\nemitted contract. Every command in this group needs a database connection."
|
|
11979
|
+
},
|
|
11980
|
+
migration: {
|
|
11981
|
+
brief: "On-disk migration management commands",
|
|
11982
|
+
description: "Plan, apply, and scaffold on-disk migration packages. Migrations are\ncontract-to-contract edges stored as versioned directories under migrations/."
|
|
11983
|
+
},
|
|
11984
|
+
"migration ref": {
|
|
11985
|
+
brief: "Named pointers at contracts",
|
|
11986
|
+
description: "Manage the named refs under migrations/app/refs/. A ref maps a logical\nenvironment name — staging, production — to a contract hash, so a command\ncan name the environment instead of the hash."
|
|
11987
|
+
},
|
|
11988
|
+
...telemetry.groups
|
|
11989
|
+
};
|
|
11990
|
+
/**
|
|
11991
|
+
* The command tree with its client factory injected, so tests can mount the
|
|
11992
|
+
* same tree over a control-client double instead of mocking modules.
|
|
11993
|
+
*/
|
|
11994
|
+
function createBinCommands(createClient) {
|
|
11995
|
+
return {
|
|
11996
|
+
"contract print": contractPrintCommand,
|
|
11997
|
+
"contract emit": contractEmitCommand,
|
|
11998
|
+
"contract format": formatCommand,
|
|
11999
|
+
"contract infer": contractInferCommand,
|
|
12000
|
+
"db init": createDbInitCommand(createClient),
|
|
12001
|
+
"db migrate": createMigrateCommand(createClient),
|
|
12002
|
+
"db schema": createDbSchemaCommand(createClient),
|
|
12003
|
+
"db sign": createDbSignCommand(createClient),
|
|
12004
|
+
"db update": createDbUpdateCommand(createClient),
|
|
12005
|
+
"db verify": createDbVerifyCommand(createClient),
|
|
12006
|
+
lsp: lspCommand,
|
|
12007
|
+
"migration check": migrationCheckCommand,
|
|
12008
|
+
"migration graph": migrationGraphCommand,
|
|
12009
|
+
"migration list": migrationListCommand,
|
|
12010
|
+
"migration log": migrationLogCommand,
|
|
12011
|
+
"migration new": createMigrationNewCommand(createClient),
|
|
12012
|
+
"migration plan": createMigrationPlanCommand(createClient),
|
|
12013
|
+
"migration ref delete": refDeleteCommand,
|
|
12014
|
+
"migration ref list": refListCommand,
|
|
12015
|
+
"migration ref set": refSetCommand,
|
|
12016
|
+
"migration show": migrationShowCommand,
|
|
12017
|
+
"migration status": migrationStatusCommand,
|
|
12018
|
+
"orm init": initCommand,
|
|
12019
|
+
...telemetry.commands
|
|
12020
|
+
};
|
|
12021
|
+
}
|
|
12022
|
+
const BIN_COMMANDS = createBinCommands(createControlClient);
|
|
12023
|
+
function createOrmCli() {
|
|
12024
|
+
return createCli({
|
|
12025
|
+
name: BIN_NAME,
|
|
12026
|
+
version,
|
|
12027
|
+
commandFamilies: [ormCommandFamily],
|
|
12028
|
+
groups: BIN_GROUPS,
|
|
12029
|
+
commands: BIN_COMMANDS
|
|
12030
|
+
});
|
|
12031
|
+
}
|
|
12032
|
+
/**
|
|
12033
|
+
* The file identity behind a stream's fd, or undefined where the host exposes
|
|
12034
|
+
* no fd (a harness stream) or the fd cannot be stat-ed.
|
|
12035
|
+
*/
|
|
12036
|
+
function streamFileIdentity(stream) {
|
|
12037
|
+
if (!("fd" in stream) || typeof stream.fd !== "number") return;
|
|
12038
|
+
try {
|
|
12039
|
+
const stat = fstatSync(stream.fd);
|
|
12040
|
+
return `${stat.dev}:${stat.ino}`;
|
|
12041
|
+
} catch {
|
|
12042
|
+
return;
|
|
12043
|
+
}
|
|
12044
|
+
}
|
|
12045
|
+
/**
|
|
12046
|
+
* Everything environmental the engine is given, adapted from the host process
|
|
12047
|
+
* once. The engine owns signal policy; the bin is dumb wiring.
|
|
12048
|
+
*/
|
|
12049
|
+
function runtimeFromProcess(proc) {
|
|
12050
|
+
const stdoutFile = streamFileIdentity(proc.stdout);
|
|
12051
|
+
const stderrFile = streamFileIdentity(proc.stderr);
|
|
12052
|
+
const outputStreamsShareDevice = stdoutFile !== void 0 && stderrFile !== void 0 ? stdoutFile === stderrFile : void 0;
|
|
12053
|
+
return {
|
|
12054
|
+
stdout: { write: (text) => void proc.stdout.write(text) },
|
|
12055
|
+
stderr: {
|
|
12056
|
+
write: (text) => void proc.stderr.write(text),
|
|
12057
|
+
...ifDefined("columns", proc.stderr.columns)
|
|
12058
|
+
},
|
|
12059
|
+
stdin: proc.stdin,
|
|
12060
|
+
cwd: proc.cwd(),
|
|
12061
|
+
env: proc.env,
|
|
12062
|
+
isTty: {
|
|
12063
|
+
stdin: proc.stdin.isTTY === true,
|
|
12064
|
+
stdout: proc.stdout.isTTY === true,
|
|
12065
|
+
stderr: proc.stderr.isTTY === true
|
|
12066
|
+
},
|
|
12067
|
+
...ifDefined("outputStreamsShareDevice", outputStreamsShareDevice),
|
|
12068
|
+
host: {
|
|
12069
|
+
runtime: {
|
|
12070
|
+
name: "node",
|
|
12071
|
+
version: proc.version
|
|
12072
|
+
},
|
|
12073
|
+
platform: proc.platform,
|
|
12074
|
+
arch: proc.arch
|
|
12075
|
+
},
|
|
12076
|
+
exit: (code) => proc.exit(code),
|
|
12077
|
+
onSignal: (callback) => {
|
|
12078
|
+
const onInterrupt = () => callback("SIGINT");
|
|
12079
|
+
const onTerminate = () => callback("SIGTERM");
|
|
12080
|
+
proc.on("SIGINT", onInterrupt);
|
|
12081
|
+
proc.on("SIGTERM", onTerminate);
|
|
12082
|
+
return () => {
|
|
12083
|
+
proc.off("SIGINT", onInterrupt);
|
|
12084
|
+
proc.off("SIGTERM", onTerminate);
|
|
12085
|
+
};
|
|
12086
|
+
},
|
|
12087
|
+
loadConfig: (configPath) => loadOrmConfig({
|
|
12088
|
+
cwd: proc.cwd(),
|
|
12089
|
+
...ifDefined("configPath", configPath)
|
|
12090
|
+
}),
|
|
12091
|
+
managementApi: { baseUrl: "https://api.prisma.io" },
|
|
12092
|
+
runPackageManager
|
|
12093
|
+
};
|
|
12094
|
+
}
|
|
12095
|
+
/** What the engine itself exits with for a failure it cannot attribute to a command. */
|
|
12096
|
+
const STARTUP_FAILURE_EXIT_CODE = 1;
|
|
12097
|
+
/**
|
|
12098
|
+
* The engine settles everything that happens inside a run. What happens before one exists —
|
|
12099
|
+
* reading the config, resolving telemetry, building the CLI — has no invocation to attach a
|
|
12100
|
+
* diagnostic to, so a throw there would reach the user as a raw stack trace. This writes the
|
|
12101
|
+
* same single line the engine writes in that position instead.
|
|
12102
|
+
*/
|
|
12103
|
+
function reportStartupFailure(proc, error) {
|
|
12104
|
+
const normalized = normalizeError(error);
|
|
12105
|
+
proc.stderr.write(`✘ [${normalized.code}] ${normalized.message}\n`);
|
|
12106
|
+
return STARTUP_FAILURE_EXIT_CODE;
|
|
12107
|
+
}
|
|
12108
|
+
/** Parses, executes and settles one invocation; returns the exit code. */
|
|
12109
|
+
async function runOrmCli(proc) {
|
|
12110
|
+
try {
|
|
12111
|
+
const hooks = resolveTelemetryHooks(proc);
|
|
12112
|
+
return await createOrmCli().run(proc.argv.slice(2), runtimeFromProcess(proc), hooks);
|
|
12113
|
+
} catch (error) {
|
|
12114
|
+
return reportStartupFailure(proc, error);
|
|
12115
|
+
}
|
|
12116
|
+
}
|
|
12117
|
+
/**
|
|
12118
|
+
* Runs the CLI as this process's `prisma` command: the exit code becomes `process.exitCode`, and
|
|
12119
|
+
* stdin is released so the process exits once the run settles. A command that read stdin leaves it
|
|
12120
|
+
* referenced — `lsp` reads it for its whole run — and with fd 0 closed Node substitutes a stream
|
|
12121
|
+
* that has no `unref`.
|
|
12122
|
+
*/
|
|
12123
|
+
async function runOrmBin() {
|
|
12124
|
+
process$1.exitCode = await runOrmCli(process$1);
|
|
12125
|
+
process$1.stdin.unref?.();
|
|
12126
|
+
}
|
|
11817
12127
|
//#endregion
|
|
11818
12128
|
//#region ../../../1-framework/3-tooling/cli/dist/exports/index.mjs
|
|
11819
12129
|
function contractSourceError(code, message, options) {
|
|
@@ -11882,6 +12192,21 @@ function validatePurity(value, entryPath) {
|
|
|
11882
12192
|
} });
|
|
11883
12193
|
}
|
|
11884
12194
|
}
|
|
12195
|
+
const FRAMEWORK_PACKAGES = ["@internal/*", "@prisma/orm-*"];
|
|
12196
|
+
const SKIP_IN_PLACE = Symbol("resolving in place");
|
|
12197
|
+
/** Leaves `args.path` external, imported by the file URL it resolves to from the importer. */
|
|
12198
|
+
async function importedInPlace(build, args) {
|
|
12199
|
+
const resolved = await build.resolve(args.path, {
|
|
12200
|
+
kind: args.kind,
|
|
12201
|
+
resolveDir: args.resolveDir,
|
|
12202
|
+
pluginData: SKIP_IN_PLACE
|
|
12203
|
+
});
|
|
12204
|
+
if (resolved.errors.length > 0 || resolved.path === "") return;
|
|
12205
|
+
return {
|
|
12206
|
+
path: pathToFileURL(resolved.path).href,
|
|
12207
|
+
external: true
|
|
12208
|
+
};
|
|
12209
|
+
}
|
|
11885
12210
|
function createImportAllowlistPlugin(allowlist, entryPath, collected) {
|
|
11886
12211
|
const entryAbs = resolve(entryPath);
|
|
11887
12212
|
function isFromEntry(importer) {
|
|
@@ -11890,8 +12215,8 @@ function createImportAllowlistPlugin(allowlist, entryPath, collected) {
|
|
|
11890
12215
|
return {
|
|
11891
12216
|
name: "import-allowlist",
|
|
11892
12217
|
setup(build) {
|
|
11893
|
-
build.onResolve({ filter: /.*/ }, (args) => {
|
|
11894
|
-
if (args.kind === "entry-point") return;
|
|
12218
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
12219
|
+
if (args.kind === "entry-point" || args.pluginData === SKIP_IN_PLACE) return;
|
|
11895
12220
|
if (args.path.startsWith(".") || args.path.startsWith("/")) return;
|
|
11896
12221
|
if (isFromEntry(args.importer) && !isAllowedImport(args.path, allowlist)) {
|
|
11897
12222
|
collected.add(args.path);
|
|
@@ -11900,6 +12225,7 @@ function createImportAllowlistPlugin(allowlist, entryPath, collected) {
|
|
|
11900
12225
|
external: true
|
|
11901
12226
|
};
|
|
11902
12227
|
}
|
|
12228
|
+
if (isAllowedImport(args.path, FRAMEWORK_PACKAGES)) return await importedInPlace(build, args);
|
|
11903
12229
|
});
|
|
11904
12230
|
}
|
|
11905
12231
|
};
|
|
@@ -11980,6 +12306,6 @@ async function loadContractFromTs(entryPath, options) {
|
|
|
11980
12306
|
}
|
|
11981
12307
|
}
|
|
11982
12308
|
//#endregion
|
|
11983
|
-
export { loadContractFromTs, loadOrmConfig, ormCommandFamily, ormConfigSection };
|
|
12309
|
+
export { loadContractFromTs, loadOrmConfig, ormCommandFamily, ormConfigSection, runOrmBin };
|
|
11984
12310
|
|
|
11985
12311
|
//# sourceMappingURL=cli.mjs.map
|