@prisma/cli-engine 0.2.2 → 0.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.
@@ -350,7 +350,7 @@ function camelCase(typed) {
350
350
  /**
351
351
  * ci-info's provider table. Its `isCI` export is unusable — it reads
352
352
  * the real `process.env` at import; the engine reads only host-injected
353
- * env. The table is inlined into the build (tsdown `noExternal`): the
353
+ * env. The table is inlined into the build (tsdown `deps.alwaysBundle`): the
354
354
  * file is CJS-owned by ci-info, and loading it as ESM at runtime breaks
355
355
  * hosts that also require ci-info (Bun's dual registry; composer#234).
356
356
  * Pinned by tests/no-esm-json-import-in-dist.test.ts.
@@ -1605,6 +1605,44 @@ function missingNamedFileDiagnostic(path) {
1605
1605
  where: { path }
1606
1606
  };
1607
1607
  }
1608
+ /** jiti reports an unresolvable import as "Cannot find module", Node's
1609
+ * own resolver as "Cannot find package"; either can appear in the
1610
+ * evaluation error chain depending on how the file is loaded. Node's
1611
+ * ESM resolver names only the package, not the subpath — a missing
1612
+ * `import "prisma/config"` reads "Cannot find package 'prisma'" — and
1613
+ * the closing quote keeps a package like 'prisma-x' from matching. */
1614
+ const MISSING_PRISMA_CONFIG_MESSAGES = [
1615
+ "Cannot find module 'prisma/config'",
1616
+ "Cannot find package 'prisma/config'",
1617
+ "Cannot find package 'prisma'"
1618
+ ];
1619
+ /** The walk is depth-limited so a cyclic `cause` chain terminates. */
1620
+ const CAUSE_CHAIN_LIMIT = 10;
1621
+ function importsMissingPrismaPackage(cause) {
1622
+ let error = cause;
1623
+ for (let depth = 0; depth < CAUSE_CHAIN_LIMIT && error instanceof Error; depth += 1, error = error.cause) {
1624
+ const message = error.message;
1625
+ if (MISSING_PRISMA_CONFIG_MESSAGES.some((text) => message.includes(text))) return true;
1626
+ }
1627
+ return false;
1628
+ }
1629
+ /** A plain `npm install prisma` would fetch `latest`, which can be the
1630
+ * too-old version the `why` warns about — the example names the exact
1631
+ * version, or is dropped when the host supplied none. */
1632
+ function prismaConfigUnresolvedDiagnostic(path, cliVersion) {
1633
+ const example = cliVersion === void 0 ? "" : ` (for example: npm install --save-dev prisma@${cliVersion})`;
1634
+ return {
1635
+ code: "CLI.CONFIG_UNREADABLE",
1636
+ severity: "error",
1637
+ summary: `${path} could not be evaluated: the 'prisma/config' entry point could not be resolved from this project.`,
1638
+ why: "The config file imports definePrismaConfig from the prisma npm package's 'prisma/config' entry point, which resolves from the project's node_modules. The package may be missing there — running the CLI through npx installs nothing into the project — or an installed version may be too old to provide the entry point.",
1639
+ nextActions: [{
1640
+ kind: "user-choice",
1641
+ label: `Install the prisma package matching this CLI's version as a dev dependency${example}, then run the command again.`
1642
+ }],
1643
+ where: { path }
1644
+ };
1645
+ }
1608
1646
  function unreadableDiagnostic(path, cause) {
1609
1647
  return {
1610
1648
  code: "CLI.CONFIG_UNREADABLE",
@@ -1684,9 +1722,13 @@ function fileToRead(cwd, configPath) {
1684
1722
  }
1685
1723
  /**
1686
1724
  * The real-disk loader behind Runtime.loadConfig. The bin binds it to
1687
- * the process cwd; tests hand in fixtures.
1725
+ * the process cwd and its own version; tests hand in fixtures.
1726
+ * `cliVersion` names the exact prisma version in the install guidance
1727
+ * when the 'prisma/config' entry point cannot be resolved; absent, the
1728
+ * guidance names no version rather than an example that installs the
1729
+ * wrong one.
1688
1730
  */
1689
- async function loadConfig(cwd, configPath) {
1731
+ async function loadConfig(cwd, configPath, cliVersion) {
1690
1732
  const path = fileToRead(cwd, configPath);
1691
1733
  if (!existsSync(path)) return configPath === void 0 ? {
1692
1734
  path,
@@ -1697,7 +1739,7 @@ async function loadConfig(cwd, configPath) {
1697
1739
  try {
1698
1740
  exported = await evaluateConfigFile(path);
1699
1741
  } catch (cause) {
1700
- return fileLevelConfig(path, unreadableDiagnostic(path, cause));
1742
+ return fileLevelConfig(path, importsMissingPrismaPackage(cause) ? prismaConfigUnresolvedDiagnostic(path, cliVersion) : unreadableDiagnostic(path, cause));
1701
1743
  }
1702
1744
  if (!hasVersionMarker(exported)) return fileLevelConfig(path, missingMarkerDiagnostic(path));
1703
1745
  const version = exported[MARKER_KEY];
package/dist/index.d.ts CHANGED
@@ -84,9 +84,13 @@ declare function definePrismaConfig<T extends Record<string, unknown>>(config: T
84
84
  declare const defineConfig: typeof definePrismaConfig;
85
85
  /**
86
86
  * The real-disk loader behind Runtime.loadConfig. The bin binds it to
87
- * the process cwd; tests hand in fixtures.
87
+ * the process cwd and its own version; tests hand in fixtures.
88
+ * `cliVersion` names the exact prisma version in the install guidance
89
+ * when the 'prisma/config' entry point cannot be resolved; absent, the
90
+ * guidance names no version rather than an example that installs the
91
+ * wrong one.
88
92
  */
89
- declare function loadConfig(cwd: string, configPath?: string): Promise<LoadedConfig>;
93
+ declare function loadConfig(cwd: string, configPath?: string, cliVersion?: string): Promise<LoadedConfig>;
90
94
  //#endregion
91
95
  //#region src/credential-errors.d.ts
92
96
  type CredentialsRequiredReason = "unauthenticated" | "expired" | "expiring-soon" | "session-ended" | "sessions-held-none-selected";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
2
- import { C as credentialRejectedError, D as noSessionForWorkspaceError, E as emptyServiceTokenError, S as authServiceError, T as credentialsRequiredError, _ as positional, a as loadConfig, b as claimedIdentity, c as WORKSPACE_ID_ENV_VAR, d as userConfigPath, f as writeUserConfig, g as flag, h as detectCI, i as definePrismaConfig, l as PRESENTED, m as exitWithChildStatus, o as PRISMA_CONFIG_VERSION, p as resolveGating, r as defineConfig, s as SERVICE_TOKEN_ENV_VAR, t as buildEngine, u as readUserConfig, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-Di08Z6xm.js";
2
+ import { C as credentialRejectedError, D as noSessionForWorkspaceError, E as emptyServiceTokenError, S as authServiceError, T as credentialsRequiredError, _ as positional, a as loadConfig, b as claimedIdentity, c as WORKSPACE_ID_ENV_VAR, d as userConfigPath, f as writeUserConfig, g as flag, h as detectCI, i as definePrismaConfig, l as PRESENTED, m as exitWithChildStatus, o as PRISMA_CONFIG_VERSION, p as resolveGating, r as defineConfig, s as SERVICE_TOKEN_ENV_VAR, t as buildEngine, u as readUserConfig, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-CPLGpHh5.js";
3
3
  //#region src/cli.ts
4
4
  /**
5
5
  * Shell-side construction. Group help is declared with the mount.
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as noSessionForWorkspaceError, T as credentialsRequiredError, b as claimedIdentity, t as buildEngine, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-Di08Z6xm.js";
1
+ import { D as noSessionForWorkspaceError, T as credentialsRequiredError, b as claimedIdentity, t as buildEngine, v as readActiveAccessToken, w as credentialWorkspaceMismatchError, x as credentialWorkspaceId, y as claimedExpiresAt } from "./engine-CPLGpHh5.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  //#region src/in-memory-credential-manager.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-engine",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "The execution engine of the unified Prisma CLI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -41,16 +41,19 @@
41
41
  "license": "Apache-2.0",
42
42
  "dependencies": {
43
43
  "@clack/prompts": "1.5.0",
44
- "@prisma/management-api-sdk": "1.55.0",
45
44
  "@stricli/core": "1.3.0",
46
45
  "c12": "3.3.4",
47
46
  "colorette": "^2.0.20",
48
47
  "package-manager-detector": "1.8.0",
49
48
  "string-width": "^8.2.1"
50
49
  },
50
+ "peerDependencies": {
51
+ "@prisma/management-api-sdk": "^1.55.0"
52
+ },
51
53
  "devDependencies": {
52
- "@repo/cli-conformance": "8.0.0-rc.9-dev.75",
53
- "@repo/tsconfig": "8.0.0-rc.9-dev.75",
54
+ "@prisma/management-api-sdk": "1.69.0",
55
+ "@repo/cli-conformance": "8.0.0-rc.10-dev.85",
56
+ "@repo/tsconfig": "8.0.0-rc.10-dev.85",
54
57
  "@types/node": "^22.19.19",
55
58
  "ci-info": "^4.3.1",
56
59
  "tsdown": "^0.21.10",