Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/package-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Authentication (token storage, refresh, the login flow) lives in this repository

`@prisma/cli` and `prisma` ship the same shell. `packages/prisma/src/bin.ts` imports `@prisma/cli/src/bin`, and its build bundles `@prisma/cli`, `@repo/cli-telemetry`, and `@prisma/credentials-store` into `dist/prisma.js`, so a command cannot behave differently depending on which package a user installed. The wrapper also exports `prisma/config`, which re-exports `definePrismaConfig` from the engine so a user's `prisma.config.ts` never depends on `@prisma/cli-engine` directly, and it ships the `prisma-platform-core-concepts` agent skill in its `skills/` directory, staged from the repository root `skills/` tree at `prepack` by `scripts/stage-skills.mjs`.

The wrapper's `package.json` carries its own copy of the runtime dependencies, including the product version pins on `@prisma/composer-cli` and `@prisma/orm-toolchain` and the `workspace:` pin on the engine. A user's `npm install prisma` resolves from the wrapper's copy, so the two manifests must declare the same dependencies at the same versions. Three checks keep them equal to `packages/cli`'s: `packages/cli/tests/manifest-pins.test.ts` asserts the wrapper's `dependencies` deep-equal the shell's; the conformance tarball check (`packages/cli-conformance/src/checks/tarball.ts`) fails on any dependency two packed manifests pin differently and on any engine pin that differs from the engine version packed beside it, then installs each packed bin into its own sandbox and starts it; and `scripts/update-product-versions.mjs` and `scripts/bump-cli-engine-version.ts` rewrite both manifests in one step so a pin cannot move in one without the other.
The wrapper's `package.json` carries its own copy of the runtime dependencies, including the product version pins on `@prisma/composer-cli`, `@prisma/orm-toolchain` and `@prisma/orm-framework` (listed at the toolchain's version so the shell does not rely on the toolchain bringing it) and the `workspace:` pin on the engine. A user's `npm install prisma` resolves from the wrapper's copy, so the two manifests must declare the same dependencies at the same versions. Three checks keep them equal to `packages/cli`'s: `packages/cli/tests/manifest-pins.test.ts` asserts the wrapper's `dependencies` deep-equal the shell's; the conformance tarball check (`packages/cli-conformance/src/checks/tarball.ts`) fails on any dependency two packed manifests pin differently and on any engine pin that differs from the engine version packed beside it, then installs each packed bin into its own sandbox and starts it; and `scripts/update-product-versions.mjs` and `scripts/bump-cli-engine-version.ts` rewrite both manifests in one step so a pin cannot move in one without the other.

## Agent skills

Expand Down
4 changes: 2 additions & 2 deletions docs/oss/release-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The unified CLI is assembled from three repositories. This page explains how a n
| --- | --- | --- |
| `prisma/prisma-cli` (this one) | `@prisma/cli-engine`, `@prisma/cli`, `prisma` | — |
| `prisma/composer` | `@prisma/composer-cli` (and the `@prisma/composer` library) | a dependency of the shell |
| `prisma/prisma` | `@prisma/orm-toolchain` | a dependency of the shell |
| `prisma/prisma` | `@prisma/orm-toolchain` (and `@prisma/orm-framework`, listed so the shell does not rely on the toolchain bringing it; the toolchain names it as a peer from the ORM release after 8.0.0-rc.25) | dependencies of the shell, always at the same version |

One more repository depends on this CLI instead of feeding it: `prisma/cloud-deploy-action`, whose test this repository runs (see [Keeping `prisma/cloud-deploy-action` working](#keeping-prismacloud-deploy-action-working)).

Expand All @@ -17,7 +17,7 @@ A **release** of the CLI depends only on **released** versions of the products.
## What happens when a product publishes

1. The product repository's publish workflow finishes and sends a `repository_dispatch` event of type `product-published` to `prisma/prisma-cli`.
2. [`update-product-versions.yml`](../../.github/workflows/update-product-versions.yml) runs [`scripts/update-product-versions.mjs`](../../scripts/update-product-versions.mjs), which asks the registry for each watched package's version at its **release** dist-tag and rewrites `packages/cli/package.json` and `packages/prisma/package.json` where they differ. Every watched package publishes its releases under `latest`, pre-release versions included: they are all new packages with no pre-8 audience to protect. The bare `prisma` name, which this repository publishes, was the one exception: its `latest` served Prisma 7 until the 2026-08-25 cutover, and since then every release of it publishes under `latest` too (see [versioning.md](versioning.md)). Each package carries a list of candidate tags rather than one name, most-preferred first, so a product moving where it publishes does not silently freeze the CLI on an old version — and a package that publishes none of its candidates fails the run instead of looking like "nothing to update".
2. [`update-product-versions.yml`](../../.github/workflows/update-product-versions.yml) runs [`scripts/update-product-versions.mjs`](../../scripts/update-product-versions.mjs), which asks the registry for each watched package's version at its **release** dist-tag and rewrites `packages/cli/package.json` and `packages/prisma/package.json` where they differ. Every watched package publishes its releases under `latest`, pre-release versions included: they are all new packages with no pre-8 audience to protect. The bare `prisma` name, which this repository publishes, was the one exception: its `latest` served Prisma 7 until the 2026-08-25 cutover, and since then every release of it publishes under `latest` too (see [versioning.md](versioning.md)). `@prisma/orm-framework` reads no tag of its own: it takes the version found for `@prisma/orm-toolchain`, because the two must agree (from the ORM release after 8.0.0-rc.25 the toolchain names it as an exact peer) and a run during the ORM's publish must not pin the two apart. Each other package carries a list of candidate tags rather than one name, most-preferred first, so a product moving where it publishes does not silently freeze the CLI on an old version — and a package that publishes none of its candidates fails the run instead of looking like "nothing to update".
3. If any pin changed, or `main` holds pins the last release (its `v<version>` tag) did not ship, the workflow bumps the CLI to its next version with `pnpm bump-version` (which also refreshes `pnpm-lock.yaml`), opens a pull request titled `Release <version>: follow the products' released versions: ...`, and arms auto-merge. Every earlier open pull request from this workflow, and every open `Bump to version` release pull request, is closed first: each bumps the same version, so only one can merge.
4. The pull request runs the full quality and conformance checks. When they pass and CodeRabbit approves it (the `main` ruleset requires one approving review), it merges, and that push to `main` changes the root version, so [`publish.yml`](../../.github/workflows/publish.yml) publishes the release under `latest` with the committed product versions, plus the usual `dev` build.

Expand Down
3 changes: 2 additions & 1 deletion packages/cli-conformance/src/checks/import-purity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export interface ImportPurityInput {
/**
* Declared dependencies reached without a static import, so the
* reverse half must not report them. `import.meta.resolve` is the
* case: it is not an import, by design.
* case: it is not an import, by design. A package listed only so
* that another package's peer dependency is met is the other case.
*/
readonly allowedUnimported?: readonly string[];
/**
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-conformance/src/checks/tarball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ export interface TarballInput {
dir: string;
/**
* Declared dependencies this package reaches without a static
* import (`import.meta.resolve` and friends), handed through to
* check 3a's import purity over the packed files.
* import (`import.meta.resolve` and friends), or never reaches but
* lists so another package's peer is met; handed through to check
* 3a's import purity over the packed files.
*/
allowedUnimported?: readonly string[];
}[];
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@prisma/composer-cli": "0.40.0",
"@prisma/compute-sdk": "0.43.0",
"@prisma/management-api-sdk": "1.101.0",
"@prisma/orm-framework": "8.0.0-rc.25",
"@prisma/orm-toolchain": "8.0.0-rc.25",
"@vercel/detect-agent": "^1.2.3",
"better-result": "^2.9.2",
Expand Down
15 changes: 13 additions & 2 deletions packages/cli/scripts/conformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
ormCommandFamily,
platformCommandFamily,
} from "../src/cli";
import { SHELL_ALLOWED_UNIMPORTED } from "./shell-conformance-inputs";

const CLI_DIR = fileURLToPath(new URL("..", import.meta.url));
const ENGINE_DIR = join(CLI_DIR, "..", "cli-engine");
Expand All @@ -59,12 +60,14 @@ async function importPurity(): Promise<readonly Finding[]> {
label: "@prisma/cli",
output: await sweepBuiltOutput(join(CLI_DIR, "dist")),
manifest: await manifest(CLI_DIR),
allowedUnimported: SHELL_ALLOWED_UNIMPORTED,
requiredSpecifiers: ["@prisma/cli-engine", "@prisma/composer-cli/family"],
});
const unscoped = checkImportPurity({
label: "prisma",
output: await sweepBuiltOutput(join(PRISMA_DIR, "dist")),
manifest: await manifest(PRISMA_DIR),
allowedUnimported: SHELL_ALLOWED_UNIMPORTED,
requiredSpecifiers: ["@prisma/cli-engine", "@prisma/composer-cli/family"],
});
const engine = checkImportPurity({
Expand Down Expand Up @@ -97,8 +100,16 @@ async function tarball(): Promise<readonly Finding[]> {
return checkTarball(
{
packages: [
{ name: "@prisma/cli", dir: CLI_DIR },
{ name: "prisma", dir: PRISMA_DIR },
{
name: "@prisma/cli",
dir: CLI_DIR,
allowedUnimported: SHELL_ALLOWED_UNIMPORTED,
},
{
name: "prisma",
dir: PRISMA_DIR,
allowedUnimported: SHELL_ALLOWED_UNIMPORTED,
},
{
name: "@prisma/cli-engine",
dir: ENGINE_DIR,
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/scripts/shell-conformance-inputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// The shell lists the framework so it does not rely on the toolchain
// bringing it (the toolchain peers on it from the ORM release after
// 8.0.0-rc.25). The shell's own code never imports it.
export const SHELL_ALLOWED_UNIMPORTED: readonly string[] = [
"@prisma/orm-framework",
];
2 changes: 2 additions & 0 deletions packages/cli/tests/v8-conformance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { sweepBuiltOutput } from "@repo/cli-conformance/module-graph";
import { sectionsFrom } from "@repo/cli-conformance/subjects";
import { checkValidatorNoThrow } from "@repo/cli-conformance/validator-no-throw";
import { describe, expect, test } from "vitest";
import { SHELL_ALLOWED_UNIMPORTED } from "../scripts/shell-conformance-inputs";
import {
composerCommandFamily,
mountedCommands,
Expand Down Expand Up @@ -68,6 +69,7 @@ describe("conformance: import purity", () => {
label: "@prisma/cli",
output,
manifest,
allowedUnimported: SHELL_ALLOWED_UNIMPORTED,
// Anti-vacuity, and more: these two are the engine boundary this
// package exists to compose, so a build that stopped importing
// either one is a broken shell rather than a tidy one.
Expand Down
1 change: 1 addition & 0 deletions packages/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@prisma/composer-cli": "0.40.0",
"@prisma/compute-sdk": "0.43.0",
"@prisma/management-api-sdk": "1.101.0",
"@prisma/orm-framework": "8.0.0-rc.25",
"@prisma/orm-toolchain": "8.0.0-rc.25",
"@vercel/detect-agent": "^1.2.3",
"better-result": "^2.9.2",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 30 additions & 6 deletions scripts/update-product-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const WATCHED = /** @type {const} */ ([
// package it ships beside, or the fixture resolves a second copy.
{ name: "@prisma/composer", release: ["latest"] },
{ name: "@prisma/orm-toolchain", release: ["latest"] },
// The shell lists the framework so it does not rely on the toolchain
// bringing it; from the ORM release after 8.0.0-rc.25 the toolchain
// names it as an exact peer. It takes
// the toolchain's version rather than reading its own tag, so a run
// during the ORM's publish cannot pin the two apart.
{ name: "@prisma/orm-framework", sameVersionAs: "@prisma/orm-toolchain" },
]);

const MANIFEST_PATHS = [
Expand Down Expand Up @@ -91,6 +97,29 @@ export function selectTag(distTags, candidates) {
return undefined;
}

/**
* Each watched package's version on the channel. Pure apart from
* `lookup`; exported for tests.
*
* @param {"release" | "dev"} channel
* @param {(name: string, tags: readonly string[]) => string | undefined} lookup
* @returns {Map<string, string | undefined>}
*/
export function publishedVersions(channel, lookup) {
const published = new Map();
for (const entry of WATCHED) {
if ("release" in entry) {
published.set(entry.name, lookup(entry.name, tagsFor(entry, channel)));
}
}
for (const entry of WATCHED) {
if ("sameVersionAs" in entry) {
published.set(entry.name, published.get(entry.sameVersionAs));
}
}
return published;
}

/**
* @param {string} path
* @param {string} field
Expand Down Expand Up @@ -273,12 +302,7 @@ function main() {
path,
manifest: JSON.parse(readFileSync(join(rootDir, path), "utf-8")),
}));
const published = new Map(
WATCHED.map((entry) => [
entry.name,
publishedVersion(entry.name, tagsFor(entry, channel)),
]),
);
const published = publishedVersions(channel, publishedVersion);
const updates = computeUpdates(manifests, published);
applyUpdates(manifests, updates);

Expand Down
49 changes: 49 additions & 0 deletions scripts/update-product-versions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
computeUpdates,
isPackageAbsent,
pinChanges,
publishedVersions,
selectTag,
tagsFor,
} from "./update-product-versions.mjs";
Expand Down Expand Up @@ -228,6 +229,54 @@ describe("computeUpdates", () => {
});
});

describe("publishedVersions", () => {
const registry = {
"@prisma/composer-cli": "0.41.0",
"@prisma/composer": "0.41.0",
"@prisma/orm-toolchain": "8.0.0-rc.26",
"@prisma/orm-framework": "8.0.0-rc.27",
};

/**
* The toolchain names the framework as an exact peer, so the two pins
* must agree. Reading the framework's own tag could catch the ORM
* mid-publish with one moved and not the other.
*/
it("pins the framework at the toolchain's version without asking the registry", () => {
const asked = [];
const published = publishedVersions("release", (name) => {
asked.push(name);
return registry[name];
});
assert.equal(published.get("@prisma/orm-framework"), "8.0.0-rc.26");
assert.equal(asked.includes("@prisma/orm-framework"), false);
});

it("moves the framework in the same run as the toolchain", () => {
const updates = computeUpdates(
[
{
path: PRISMA,
manifest: {
dependencies: {
"@prisma/orm-framework": "8.0.0-rc.25",
"@prisma/orm-toolchain": "8.0.0-rc.25",
},
},
},
],
publishedVersions("release", (name) => registry[name]),
);
assert.deepEqual(
updates.map(({ name, to }) => [name, to]),
[
["@prisma/orm-toolchain", "8.0.0-rc.26"],
["@prisma/orm-framework", "8.0.0-rc.26"],
],
);
});
});

describe("applyUpdates", () => {
it("writes each update into the manifest it names", () => {
const manifests = [
Expand Down
Loading