From a8964f79292cc9036671a6a6440b1bd1451a5261 Mon Sep 17 00:00:00 2001 From: willbot Date: Tue, 17 Nov 2026 07:27:04 +1100 Subject: [PATCH 1/6] fix(ci): publish v7 dev builds under prev-dev, versioned from prisma@prev Every push to v7 published all packages under the npm dist-tag `dev` and based the dev version on `prisma@latest`. Both now belong to the Prisma 8 CLI from prisma/prisma-cli, so Prisma 7 code went out as 8.1.0-dev.N and `prisma@dev` switched between Prisma 7 and Prisma 8 builds. Dev builds from v7 now go to `prev-dev`, and dev and integration versions are based on `prisma@prev` (7.10.1 gives 7.11.0-dev.N). The version base must be a stable x.y.z version, so a prerelease on that tag stops the publish instead of producing a wrong version. Tag selection moves to scripts/ci/publish-channel.ts, which has no dependencies. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- AGENTS.md | 1 + scripts/ci/publish-channel.ts | 62 +++++++++++++++++++++++ scripts/ci/publish.ts | 94 +++++++++++++---------------------- 3 files changed, 97 insertions(+), 60 deletions(-) create mode 100644 scripts/ci/publish-channel.ts diff --git a/AGENTS.md b/AGENTS.md index ac5a6034743c..c28aa8267aab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,6 +11,7 @@ - **Key packages**: `packages/cli` (Prisma CLI entry point), `packages/migrate` (migrate/db namespace + fixtures), `packages/client` (client runtime), `packages/client-generator-ts` (new `prisma-client` generator), `packages/client-generator-js` (traditional `prisma-client-js` generator), `packages/client-generator-registry` (generator registry for managing generators), `packages/client-engine-runtime` (the core part of the new Rust binary free client based on Wasm query compiler, used by `ClientEngine` class in `packages/client`), `packages/client-common` (shared client utilities), `packages/client-runtime-utils` (utility types and singletons for Prisma Client), `packages/config` (`PrismaConfigInternal` + loader), `packages/internals` (shared CLI + engine glue), `packages/engines` (Rust binaries download wrapper), `packages/integration-tests` (matrix suites), `packages/query-plan-executor` (standalone query plan executor service for Prisma Accelerate), `packages/credentials-store` (credential storage utilities), sqlcommenter packages under `packages/sqlcommenter*`, and numerous driver adapters under `packages/adapter-*`. - **Driver adapters & runtimes**: `packages/bundled-js-drivers` plus the `adapter-*` packages ship JS driver adapters: `adapter-pg`, `adapter-neon`, `adapter-libsql`, `adapter-planetscale`, `adapter-d1`, `adapter-better-sqlite3`, `adapter-mssql`, `adapter-mariadb`, `adapter-ppg` (Prisma Postgres Serverless). These are built on helpers in `driver-adapter-utils`; migrate/client fixtures exercise them, so adapter changes typically require fixture/test updates. CI tests driver adapters with flavors: `js_pg`, `js_neon`, `js_libsql`, `js_planetscale`, `js_d1`, `js_better_sqlite3`, `js_mssql`, `js_mariadb`, `js_pg_cockroachdb`. - **Build & tooling**: Typescript-first repo with WASM/Rust assets (downloaded by `@prisma/engines`). Multiple `tsconfig.*` drive bundle vs runtime builds. Lint via `pnpm lint`, format via `pnpm format`. Maintenance scripts live in `scripts/` (e.g. `bump-engines.ts`, `bench.ts`, `ci/publish.ts` orchestrates build/test/publish flows). Build configuration uses esbuild via `helpers/compile/build.ts` with configs in `helpers/compile/configs.ts`. Most packages use `bundledConfig` which bundles to both CJS and ESM with type declarations. + - **npm dist-tags on this branch.** `prisma`'s `latest` and `dev` dist-tags belong to the Prisma 8 CLI published from prisma/prisma-cli, so `scripts/ci/publish.ts` must never publish `prisma` under either. Stable releases put `prisma` on `prev` (other packages on `latest`), and every push to `v7` publishes all packages as `-dev.N` under `prev-dev`. The tag selection lives in `scripts/ci/publish-channel.ts`, which has no dependencies so it can be exercised without an install. - Build helpers that copy Wasm artifacts should resolve package assets through `require.resolve(...)` instead of hardcoding `packages/*/node_modules` paths. With pnpm hoisted installs, dependencies can live only at workspace root and package-local `node_modules/@prisma/*` entries may be absent. - **Benchmarking**: Comprehensive performance benchmarks using Benchmark.js with CodSpeed integration. See `docs/benchmarking.md` for full documentation. Key commands: - `pnpm bench` - Run all benchmarks (outputs to `output.txt`) diff --git a/scripts/ci/publish-channel.ts b/scripts/ci/publish-channel.ts new file mode 100644 index 000000000000..56df5460c490 --- /dev/null +++ b/scripts/ci/publish-channel.ts @@ -0,0 +1,62 @@ +/** + * npm dist-tag for dev builds from the `v7` branch. Not `dev`: prisma/prisma-cli publishes the Prisma 8 `prisma` + * package under `dev`, and sharing the tag made `prisma@dev` switch between Prisma 7 and Prisma 8 builds. + */ +export const DEV_DIST_TAG = 'prev-dev' + +/** + * npm dist-tag that holds the newest stable Prisma 7 release of `prisma`. `latest` belongs to prisma/prisma-cli. + */ +export const PRISMA_STABLE_DIST_TAG = 'prev' + +export type PublishChannelInput = { + branch: string | undefined + patchBranch: string | null + releaseVersion: string | undefined + forceIntegrationRelease: boolean +} + +export type PublishChannel = { + version: 'integration' | 'patch-dev' | 'release' | 'dev' + tag: string + tagForEcosystemTestsCheck?: string +} + +export function getPublishChannel({ + branch, + patchBranch, + releaseVersion, + forceIntegrationRelease, +}: PublishChannelInput): PublishChannel { + if (branch && (forceIntegrationRelease || branch.startsWith('integration/'))) { + return { version: 'integration', tag: 'integration' } + } + if (patchBranch) { + return releaseVersion + ? { version: 'release', tag: 'latest', tagForEcosystemTestsCheck: 'patch-dev' } + : { version: 'patch-dev', tag: 'patch-dev' } + } + if (releaseVersion) { + // Names the `dev` branch of prisma/ecosystem-tests, not an npm dist-tag. + return { version: 'release', tag: 'latest', tagForEcosystemTestsCheck: 'dev' } + } + return { version: 'dev', tag: DEV_DIST_TAG } +} + +export function getPackageDistTag(pkgName: string, tag: string): string { + return pkgName === 'prisma' && tag === 'latest' ? PRISMA_STABLE_DIST_TAG : tag +} + +/** + * Returns the next minor version after the newest stable Prisma 7 release, e.g. `7.10.1` -> `7.11.0`. + * Throws for a prerelease, which means the dist-tag no longer points at a Prisma 7 stable release. + */ +export function getNextMinorStable(stableVersion: string): string { + const match = /^(\d+)\.(\d+)\.\d+$/.exec(stableVersion.trim()) + if (!match) { + throw new Error( + `Expected prisma@${PRISMA_STABLE_DIST_TAG} to be a stable x.y.z version, got "${stableVersion}". Dev and integration versions are based on it.`, + ) + } + return `${match[1]}.${Number(match[2]) + 1}.0` +} diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index 583a24c0c258..a6f4e96485f5 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -12,6 +12,8 @@ import { blue, bold, cyan, dim, magenta, red, underline } from 'kleur/colors' import pRetry from 'p-retry' import semver from 'semver' +import { getNextMinorStable, getPackageDistTag, getPublishChannel, PRISMA_STABLE_DIST_TAG } from './publish-channel' + const onlyPackages = process.env.ONLY_PACKAGES ? process.env.ONLY_PACKAGES.split(',') : null const skipPackages = process.env.SKIP_PACKAGES ? process.env.SKIP_PACKAGES.split(',') : null @@ -217,12 +219,6 @@ export function getPublishOrder(packages: Packages): string[][] { return topo(dag) // TODO: this is now done by pnpm (top sort), can we remove? } -function zeroOutPatch(version: string): string { - const parts = version.split('.') - parts[parts.length - 1] = '0' - return parts.join('.') -} - /** * Takes the max dev version + 1 * For now supporting X.Y.Z-dev.# @@ -231,10 +227,7 @@ function zeroOutPatch(version: string): string { async function getNewDevVersion(packages: Packages): Promise { const before = Math.round(performance.now()) console.log('\nCalculating new dev version...') - // Why are we calling zeroOutPatch? - // Because here we're only interested in the 2.5.0 <- the next minor stable version - // If the current version would be 2.4.7, we would end up with 2.5.7 - const nextStable = zeroOutPatch((await getNextMinorStable())!) + const nextStable = await fetchNextMinorStable() console.log(`getNewDevVersion: Next minor stable: ${nextStable}`) @@ -254,10 +247,7 @@ async function getNewDevVersion(packages: Packages): Promise { async function getNewIntegrationVersion(packages: Packages, branch: string): Promise { const before = Math.round(performance.now()) console.log('\nCalculating new integration version...') - // Why are we calling zeroOutPatch? - // Because here we're only interested in the 2.5.0 <- the next minor stable version - // If the current version would be 2.4.7, we would end up with 2.5.7 - const nextStable = zeroOutPatch((await getNextMinorStable())!) + const nextStable = await fetchNextMinorStable() console.log(`getNewIntegrationVersion: Next minor stable: ${nextStable}`) @@ -447,18 +437,14 @@ export async function getAllVersionsPublishedFor(pkgs: Packages, channel: string } /** - * Only used when publishing to the `dev` and `integration` npm channels - * (see `getNewDevVersion()` and `getNewIntegrationVersion()`) - * @returns The next minor version for the `latest` channel - * Example: If latest is `4.9.0` it will return `4.10.0` + * Only used for dev and integration versions (see `getNewDevVersion()` and `getNewIntegrationVersion()`) + * @returns The next minor version after `prisma@prev`, e.g. `7.11.0` when `prev` is `7.10.1` */ -async function getNextMinorStable() { - // We check the Prisma CLI `latest` version - // We retry a few times if it fails - // npm can have some hiccups +async function fetchNextMinorStable(): Promise { + // `prisma@latest` is the Prisma 8 CLI from prisma/prisma-cli, so the newest Prisma 7 release is read from `prev`. const remoteVersionString = await pRetry( async () => { - return await runResult('.', `npm info prisma version`) + return await runResult('.', `npm info prisma@${PRISMA_STABLE_DIST_TAG} version`) }, { retries: 6, @@ -467,7 +453,7 @@ async function getNextMinorStable() { }, }, ) - return increaseMinor(remoteVersionString) + return getNextMinorStable(remoteVersionString) } // TODO: could probably use the semver package @@ -556,10 +542,6 @@ async function publish() { throw new Error(`Oops, there are circular dependencies: ${circles}`) } - let prismaVersion: undefined | string - let tag: undefined | string - let tagForEcosystemTestsCheck: undefined | string - const patchBranch = getPatchBranch() console.log({ patchBranch }) @@ -567,28 +549,29 @@ async function publish() { const branch = await getPrismaBranch() console.log({ branch }) - // For branches that are named "integration/" we publish to the integration npm tag - if (branch && (process.env.FORCE_INTEGRATION_RELEASE === 'true' || branch.startsWith('integration/'))) { - prismaVersion = await getNewIntegrationVersion(packages, branch) - tag = 'integration' - } - // Is it a patch branch? (Like 2.20.x) - else if (patchBranch) { - prismaVersion = await getNewPatchDevVersion(packages, patchBranch) - tag = 'patch-dev' - if (args['--release']) { - tagForEcosystemTestsCheck = 'patch-dev' //? - prismaVersion = args['--release'] - tag = 'latest' - } - } else if (args['--release']) { - // TODO:Where each patch branch goes - prismaVersion = args['--release'] - tag = 'latest' - tagForEcosystemTestsCheck = 'dev' - } else { - prismaVersion = await getNewDevVersion(packages) - tag = 'dev' + const channel = getPublishChannel({ + branch, + patchBranch, + releaseVersion: args['--release'], + forceIntegrationRelease: process.env.FORCE_INTEGRATION_RELEASE === 'true', + }) + const { tagForEcosystemTestsCheck } = channel + let tag = channel.tag + + let prismaVersion: string + switch (channel.version) { + case 'integration': + prismaVersion = await getNewIntegrationVersion(packages, branch!) + break + case 'patch-dev': + prismaVersion = await getNewPatchDevVersion(packages, patchBranch!) + break + case 'release': + prismaVersion = args['--release']! + break + case 'dev': + prismaVersion = await getNewDevVersion(packages) + break } if (args['--custom-dist-tag']) { @@ -708,15 +691,6 @@ function intersection(arr1: T[], arr2: T[]): T[] { const semverRegex = /^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ -function increaseMinor(version: string) { - const match = semverRegex.exec(version) - if (match?.groups) { - return `${match.groups.major}.${Number(match.groups.minor) + 1}.${match.groups.patch}` - } - - return undefined -} - function filterPublishOrder(publishOrder: string[][], packages: string[]): string[][] { return publishOrder.reduce((acc, curr) => { if (Array.isArray(curr)) { @@ -811,7 +785,7 @@ async function publishPackages( const pkgDir = path.dirname(pkg.path) const newVersion = prismaVersion - const packageTag = pkgName === 'prisma' && tag === 'latest' ? 'prev' : tag + const packageTag = getPackageDistTag(pkgName, tag) console.log(`\nPublishing ${magenta(`${pkgName}@${newVersion}`)} ${dim(`on ${packageTag}`)}`) From d3db5291f6f2229efb1f9a1034d99f019f6ac8d3 Mon Sep 17 00:00:00 2001 From: willbot Date: Tue, 17 Nov 2026 07:35:35 +1100 Subject: [PATCH 2/6] fix(ci): base v7 dev versions on the highest stable 7.x, refuse prisma@dev, and test tag selection The dev and integration base came from `prisma@prev`. Releasing an older patch branch (7.9.2 after 7.10.1) moves `prev` back, and the next v7 push would then publish 7.10.0-dev.N under `prev-dev`. The base is now the next minor after the highest stable 7.x.y version of `prisma` on npm, so a moved tag no longer changes it. Today it is still 7.11.0, and the first dev build is 7.11.0-dev.1. `getPackageDistTag` now throws when `prisma` would be published under `dev`, which prisma/prisma-cli owns. Every publish goes through it, including a custom dist tag, and `publish.ts` calls it for `prisma` before any build or publish step. `scripts/ci/publish-channel.test.ts` covers every publish path, the tag mapping and the base version. It runs in the `Workspace types` CI job. Renames: `PublishChannel.version` is now `kind`, `tagForEcosystemTestsCheck` is now `ecosystemTestsBranch` (the GITHUB_OUTPUT key is unchanged), and the `channel` parameter of `getAllVersionsPublishedFor` is now `prereleaseId`. The ecosystem-tests failure message now names the ecosystem-tests branch instead of the npm tag. `AGENTS.md` lists which `prisma` tags each publisher owns. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- .github/workflows/test-template.yml | 3 + AGENTS.md | 2 +- scripts/ci/publish-channel.test.ts | 98 +++++++++++++++++++++++++++++ scripts/ci/publish-channel.ts | 57 ++++++++++------- scripts/ci/publish.ts | 53 +++++++++------- 5 files changed, 169 insertions(+), 44 deletions(-) create mode 100644 scripts/ci/publish-channel.test.ts diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 7c6b8599508a..196cad00710f 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -618,6 +618,9 @@ jobs: - run: pnpm tsc -p tsconfig.utils.typecheck.json + - name: Test publish channel selection + run: pnpm tsx --test scripts/ci/publish-channel.test.ts + # # INTEGRATION-TESTS # diff --git a/AGENTS.md b/AGENTS.md index c28aa8267aab..76fef4d6c257 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ - **Key packages**: `packages/cli` (Prisma CLI entry point), `packages/migrate` (migrate/db namespace + fixtures), `packages/client` (client runtime), `packages/client-generator-ts` (new `prisma-client` generator), `packages/client-generator-js` (traditional `prisma-client-js` generator), `packages/client-generator-registry` (generator registry for managing generators), `packages/client-engine-runtime` (the core part of the new Rust binary free client based on Wasm query compiler, used by `ClientEngine` class in `packages/client`), `packages/client-common` (shared client utilities), `packages/client-runtime-utils` (utility types and singletons for Prisma Client), `packages/config` (`PrismaConfigInternal` + loader), `packages/internals` (shared CLI + engine glue), `packages/engines` (Rust binaries download wrapper), `packages/integration-tests` (matrix suites), `packages/query-plan-executor` (standalone query plan executor service for Prisma Accelerate), `packages/credentials-store` (credential storage utilities), sqlcommenter packages under `packages/sqlcommenter*`, and numerous driver adapters under `packages/adapter-*`. - **Driver adapters & runtimes**: `packages/bundled-js-drivers` plus the `adapter-*` packages ship JS driver adapters: `adapter-pg`, `adapter-neon`, `adapter-libsql`, `adapter-planetscale`, `adapter-d1`, `adapter-better-sqlite3`, `adapter-mssql`, `adapter-mariadb`, `adapter-ppg` (Prisma Postgres Serverless). These are built on helpers in `driver-adapter-utils`; migrate/client fixtures exercise them, so adapter changes typically require fixture/test updates. CI tests driver adapters with flavors: `js_pg`, `js_neon`, `js_libsql`, `js_planetscale`, `js_d1`, `js_better_sqlite3`, `js_mssql`, `js_mariadb`, `js_pg_cockroachdb`. - **Build & tooling**: Typescript-first repo with WASM/Rust assets (downloaded by `@prisma/engines`). Multiple `tsconfig.*` drive bundle vs runtime builds. Lint via `pnpm lint`, format via `pnpm format`. Maintenance scripts live in `scripts/` (e.g. `bump-engines.ts`, `bench.ts`, `ci/publish.ts` orchestrates build/test/publish flows). Build configuration uses esbuild via `helpers/compile/build.ts` with configs in `helpers/compile/configs.ts`. Most packages use `bundledConfig` which bundles to both CJS and ESM with type declarations. - - **npm dist-tags on this branch.** `prisma`'s `latest` and `dev` dist-tags belong to the Prisma 8 CLI published from prisma/prisma-cli, so `scripts/ci/publish.ts` must never publish `prisma` under either. Stable releases put `prisma` on `prev` (other packages on `latest`), and every push to `v7` publishes all packages as `-dev.N` under `prev-dev`. The tag selection lives in `scripts/ci/publish-channel.ts`, which has no dependencies so it can be exercised without an install. + - **npm dist-tags on this branch.** Two publishers share the npm package `prisma`: prisma/prisma-cli (Prisma 8) owns its `latest`, `dev` and `next` tags, and this branch owns `prev`, `prev-dev`, `patch-dev` and `integration`. Stable releases put `prisma` on `prev` and the `@prisma/*` packages on `latest`, so for `@prisma/*` the `prev-dev` tag means "Prisma 7 dev build", not "dev line of `prev`". Every push to `v7` publishes all packages as `-dev.N` under `prev-dev`. Tag and base-version selection live in `scripts/ci/publish-channel.ts`; `getPackageDistTag` there refuses to publish `prisma` under `dev`. Its test runs in the `Workspace types` CI job (`pnpm tsx --test scripts/ci/publish-channel.test.ts`). Revisit these tag names when Prisma 9 ships and 8.x needs `prev`. - Build helpers that copy Wasm artifacts should resolve package assets through `require.resolve(...)` instead of hardcoding `packages/*/node_modules` paths. With pnpm hoisted installs, dependencies can live only at workspace root and package-local `node_modules/@prisma/*` entries may be absent. - **Benchmarking**: Comprehensive performance benchmarks using Benchmark.js with CodSpeed integration. See `docs/benchmarking.md` for full documentation. Key commands: - `pnpm bench` - Run all benchmarks (outputs to `output.txt`) diff --git a/scripts/ci/publish-channel.test.ts b/scripts/ci/publish-channel.test.ts new file mode 100644 index 000000000000..9d5340763956 --- /dev/null +++ b/scripts/ci/publish-channel.test.ts @@ -0,0 +1,98 @@ +/* eslint-disable @typescript-eslint/no-floating-promises -- node:test tracks the promises that describe() and test() return */ + +import assert from 'node:assert/strict' +import { describe, test } from 'node:test' + +import { + getNextMinorStable, + getPackageDistTag, + getPublishChannel, + type PublishChannel, + type PublishChannelInput, +} from './publish-channel' + +const push: PublishChannelInput = { + branch: 'v7', + patchBranch: null, + releaseVersion: undefined, + forceIntegrationRelease: false, +} + +describe('getPublishChannel', () => { + const cases: [string, PublishChannelInput, PublishChannel][] = [ + ['push to v7', push, { kind: 'dev', tag: 'prev-dev' }], + [ + '--release on v7', + { ...push, releaseVersion: '7.11.0' }, + { kind: 'release', tag: 'latest', ecosystemTestsBranch: 'dev' }, + ], + [ + 'push to a patch branch', + { ...push, branch: '7.9.x', patchBranch: '7.9.x' }, + { kind: 'patch-dev', tag: 'patch-dev' }, + ], + [ + '--release on a patch branch', + { ...push, branch: '7.9.x', patchBranch: '7.9.x', releaseVersion: '7.9.2' }, + { kind: 'release', tag: 'latest', ecosystemTestsBranch: 'patch-dev' }, + ], + ['push to integration/*', { ...push, branch: 'integration/foo' }, { kind: 'integration', tag: 'integration' }], + [ + 'forced integration release wins over --release', + { ...push, forceIntegrationRelease: true, releaseVersion: '7.11.0' }, + { kind: 'integration', tag: 'integration' }, + ], + ] + + for (const [name, input, expected] of cases) { + test(name, () => { + assert.deepEqual(getPublishChannel(input), expected) + }) + } +}) + +describe('getPackageDistTag', () => { + const cases: [string, string, string][] = [ + ['prisma', 'prev-dev', 'prev-dev'], + ['@prisma/client', 'prev-dev', 'prev-dev'], + ['prisma', 'latest', 'prev'], + ['@prisma/client', 'latest', 'latest'], + ['prisma', 'patch-dev', 'patch-dev'], + ['prisma', 'integration', 'integration'], + ['prisma', 'my-custom-tag', 'my-custom-tag'], + ['@prisma/client', 'dev', 'dev'], + ] + + for (const [pkgName, tag, expected] of cases) { + test(`${pkgName} on ${tag} publishes under ${expected}`, () => { + assert.equal(getPackageDistTag(pkgName, tag), expected) + }) + } + + test('refuses to publish prisma under dev', () => { + assert.throws(() => getPackageDistTag('prisma', 'dev'), /prisma\/prisma-cli owns it.*"prev-dev"/) + }) +}) + +describe('getNextMinorStable', () => { + test('returns the next minor after the highest stable 7.x version', () => { + assert.equal(getNextMinorStable(['7.9.0', '7.10.0', '7.10.1', '7.10.0-dev.58']), '7.11.0') + }) + + test('uses the highest version, not the newest one in the list', () => { + assert.equal(getNextMinorStable(['7.10.1', '7.9.2']), '7.11.0') + }) + + test('ignores other majors and prereleases', () => { + assert.equal( + getNextMinorStable(['6.19.3', '7.10.1', '7.11.0-dev.1', '7.12.0-integration-foo.1', '8.0.0', '8.0.0-rc.34']), + '7.11.0', + ) + }) + + test('throws when no stable 7.x version exists', () => { + for (const versions of [[], ['6.19.3', '8.0.0', '7.11.0-dev.1', '7.10']]) { + assert.throws(() => getNextMinorStable(versions), /no stable 7\.x\.y version of prisma/) + } + }) +}) diff --git a/scripts/ci/publish-channel.ts b/scripts/ci/publish-channel.ts index 56df5460c490..ed3659365a3f 100644 --- a/scripts/ci/publish-channel.ts +++ b/scripts/ci/publish-channel.ts @@ -1,14 +1,16 @@ /** - * npm dist-tag for dev builds from the `v7` branch. Not `dev`: prisma/prisma-cli publishes the Prisma 8 `prisma` - * package under `dev`, and sharing the tag made `prisma@dev` switch between Prisma 7 and Prisma 8 builds. + * Two publishers share the npm package `prisma`. prisma/prisma-cli (Prisma 8) owns its `latest`, `dev` and `next` + * tags. This branch (Prisma 7) owns `prev`, `prev-dev`, `patch-dev` and `integration`. + * + * The `@prisma/*` packages still get stable releases on `latest` from this branch, so for them `prev-dev` means + * "Prisma 7 dev build", not "dev line of `prev`". Revisit these names when Prisma 9 ships and 8.x needs `prev`. */ export const DEV_DIST_TAG = 'prev-dev' -/** - * npm dist-tag that holds the newest stable Prisma 7 release of `prisma`. `latest` belongs to prisma/prisma-cli. - */ export const PRISMA_STABLE_DIST_TAG = 'prev' +const PRISMA_MAJOR = 7 + export type PublishChannelInput = { branch: string | undefined patchBranch: string | null @@ -17,9 +19,9 @@ export type PublishChannelInput = { } export type PublishChannel = { - version: 'integration' | 'patch-dev' | 'release' | 'dev' + kind: 'integration' | 'patch-dev' | 'release' | 'dev' tag: string - tagForEcosystemTestsCheck?: string + ecosystemTestsBranch?: string } export function getPublishChannel({ @@ -29,34 +31,47 @@ export function getPublishChannel({ forceIntegrationRelease, }: PublishChannelInput): PublishChannel { if (branch && (forceIntegrationRelease || branch.startsWith('integration/'))) { - return { version: 'integration', tag: 'integration' } + return { kind: 'integration', tag: 'integration' } } if (patchBranch) { return releaseVersion - ? { version: 'release', tag: 'latest', tagForEcosystemTestsCheck: 'patch-dev' } - : { version: 'patch-dev', tag: 'patch-dev' } + ? { kind: 'release', tag: 'latest', ecosystemTestsBranch: 'patch-dev' } + : { kind: 'patch-dev', tag: 'patch-dev' } } if (releaseVersion) { - // Names the `dev` branch of prisma/ecosystem-tests, not an npm dist-tag. - return { version: 'release', tag: 'latest', tagForEcosystemTestsCheck: 'dev' } + return { kind: 'release', tag: 'latest', ecosystemTestsBranch: 'dev' } } - return { version: 'dev', tag: DEV_DIST_TAG } + return { kind: 'dev', tag: DEV_DIST_TAG } } +/** + * Returns the npm dist-tag to publish `pkgName` under. Every publish goes through this, including a custom dist tag. + * Throws if `prisma` would land on `dev`, which prisma/prisma-cli owns. + */ export function getPackageDistTag(pkgName: string, tag: string): string { - return pkgName === 'prisma' && tag === 'latest' ? PRISMA_STABLE_DIST_TAG : tag + if (pkgName !== 'prisma') return tag + if (tag === 'latest') return PRISMA_STABLE_DIST_TAG + if (tag === 'dev') { + throw new Error( + `Refusing to publish prisma under the "dev" dist-tag: prisma/prisma-cli owns it for Prisma 8. Prisma 7 dev builds use "${DEV_DIST_TAG}".`, + ) + } + return tag } /** - * Returns the next minor version after the newest stable Prisma 7 release, e.g. `7.10.1` -> `7.11.0`. - * Throws for a prerelease, which means the dist-tag no longer points at a Prisma 7 stable release. + * Returns the next minor after the highest stable Prisma 7 version in `publishedVersions`, e.g. `7.10.1` -> `7.11.0`. + * Reads the version list rather than a dist-tag, because a release from an older patch branch moves `prev` back. */ -export function getNextMinorStable(stableVersion: string): string { - const match = /^(\d+)\.(\d+)\.\d+$/.exec(stableVersion.trim()) - if (!match) { +export function getNextMinorStable(publishedVersions: readonly string[]): string { + const minors = publishedVersions.flatMap((version) => { + const match = /^(\d+)\.(\d+)\.\d+$/.exec(version.trim()) + return match && Number(match[1]) === PRISMA_MAJOR ? [Number(match[2])] : [] + }) + if (minors.length === 0) { throw new Error( - `Expected prisma@${PRISMA_STABLE_DIST_TAG} to be a stable x.y.z version, got "${stableVersion}". Dev and integration versions are based on it.`, + `Found no stable ${PRISMA_MAJOR}.x.y version of prisma on npm. Dev and integration versions are based on the highest one.`, ) } - return `${match[1]}.${Number(match[2]) + 1}.0` + return `${PRISMA_MAJOR}.${Math.max(...minors) + 1}.0` } diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index a6f4e96485f5..4c9c69429908 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -12,7 +12,7 @@ import { blue, bold, cyan, dim, magenta, red, underline } from 'kleur/colors' import pRetry from 'p-retry' import semver from 'semver' -import { getNextMinorStable, getPackageDistTag, getPublishChannel, PRISMA_STABLE_DIST_TAG } from './publish-channel' +import { getNextMinorStable, getPackageDistTag, getPublishChannel } from './publish-channel' const onlyPackages = process.env.ONLY_PACKAGES ? process.env.ONLY_PACKAGES.split(',') : null const skipPackages = process.env.SKIP_PACKAGES ? process.env.SKIP_PACKAGES.split(',') : null @@ -391,11 +391,15 @@ function getMaxPatchVersionIncrement(versions: string[]): number { /** * @param pkgs - * @param channel + * @param prereleaseId * @param prefix - * @returns All versions published on npm for a given channel and prefix + * @returns All versions published on npm that contain `prereleaseId` and start with `prefix` */ -export async function getAllVersionsPublishedFor(pkgs: Packages, channel: string, prefix: string): Promise { +export async function getAllVersionsPublishedFor( + pkgs: Packages, + prereleaseId: string, + prefix: string, +): Promise { // We check the versions for the `@prisma/debug` package // Why? // Because `@prisma/debug` is the first package that will be published @@ -425,7 +429,11 @@ export async function getAllVersionsPublishedFor(pkgs: Packages, channel: string const remoteVersions: string = JSON.parse(remoteVersionsString) for (const remoteVersion of remoteVersions) { - if (remoteVersion.includes(channel) && remoteVersion.startsWith(prefix) && !pkgVersions.includes(remoteVersion)) { + if ( + remoteVersion.includes(prereleaseId) && + remoteVersion.startsWith(prefix) && + !pkgVersions.includes(remoteVersion) + ) { pkgVersions.push(remoteVersion) } } @@ -438,13 +446,12 @@ export async function getAllVersionsPublishedFor(pkgs: Packages, channel: string /** * Only used for dev and integration versions (see `getNewDevVersion()` and `getNewIntegrationVersion()`) - * @returns The next minor version after `prisma@prev`, e.g. `7.11.0` when `prev` is `7.10.1` + * @returns The next minor version after the highest stable Prisma 7 release, e.g. `7.11.0` when it is `7.10.1` */ async function fetchNextMinorStable(): Promise { - // `prisma@latest` is the Prisma 8 CLI from prisma/prisma-cli, so the newest Prisma 7 release is read from `prev`. - const remoteVersionString = await pRetry( + const remoteVersionsString = await pRetry( async () => { - return await runResult('.', `npm info prisma@${PRISMA_STABLE_DIST_TAG} version`) + return await runResult('.', `npm info prisma versions --json`) }, { retries: 6, @@ -453,7 +460,7 @@ async function fetchNextMinorStable(): Promise { }, }, ) - return getNextMinorStable(remoteVersionString) + return getNextMinorStable(JSON.parse(remoteVersionsString) as string[]) } // TODO: could probably use the semver package @@ -555,11 +562,11 @@ async function publish() { releaseVersion: args['--release'], forceIntegrationRelease: process.env.FORCE_INTEGRATION_RELEASE === 'true', }) - const { tagForEcosystemTestsCheck } = channel + const { ecosystemTestsBranch } = channel let tag = channel.tag let prismaVersion: string - switch (channel.version) { + switch (channel.kind) { case 'integration': prismaVersion = await getNewIntegrationVersion(packages, branch!) break @@ -578,18 +585,20 @@ async function publish() { console.log(`Using custom dist tag: ${args['--custom-dist-tag']}`) tag = args['--custom-dist-tag'] } + const prismaTag = getPackageDistTag('prisma', tag) console.log({ patchBranch, tag, - tagForEcosystemTestsCheck, + prismaTag, + ecosystemTestsBranch, prismaVersion, }) if (typeof process.env.GITHUB_OUTPUT == 'string' && process.env.GITHUB_OUTPUT.length > 0) { fs.appendFileSync(process.env.GITHUB_OUTPUT, `patchBranch=${patchBranch}\n`) fs.appendFileSync(process.env.GITHUB_OUTPUT, `tag=${tag}\n`) - fs.appendFileSync(process.env.GITHUB_OUTPUT, `tagForEcosystemTestsCheck=${tagForEcosystemTestsCheck}\n`) + fs.appendFileSync(process.env.GITHUB_OUTPUT, `tagForEcosystemTestsCheck=${ecosystemTestsBranch}\n`) fs.appendFileSync(process.env.GITHUB_OUTPUT, `prismaVersion=${prismaVersion}\n`) } @@ -604,13 +613,13 @@ async function publish() { if (args['--publish'] || dryRun) { if (args['--release']) { - if (!tagForEcosystemTestsCheck) { - throw new Error(`tagForEcosystemTestsCheck missing`) + if (!ecosystemTestsBranch) { + throw new Error(`ecosystemTestsBranch missing`) } - const passing = await areEcosystemTestsPassing(tagForEcosystemTestsCheck) + const passing = await areEcosystemTestsPassing(ecosystemTestsBranch) if (!passing && process.env.SKIP_ECOSYSTEMTESTS_CHECK !== 'true') { - throw new Error(`We can't release, as the ecosystem-tests are not passing for the ${tag} npm tag! -Check them out at https://github.com/prisma/ecosystem-tests/actions?query=workflow%3Atest+branch%3A${tag}`) + throw new Error(`We can't release, as the ecosystem-tests are not passing on the ${ecosystemTestsBranch} branch! +Check them out at https://github.com/prisma/ecosystem-tests/actions?query=workflow%3Atest+branch%3A${ecosystemTestsBranch}`) } } @@ -892,11 +901,11 @@ async function getPrismaBranch(): Promise { return undefined } -async function areEcosystemTestsPassing(tag: string): Promise { +async function areEcosystemTestsPassing(branch: string): Promise { let svgUrl = 'https://github.com/prisma/ecosystem-tests/workflows/test/badge.svg?branch=' - if (tag === 'patch-dev') { - svgUrl += tag + if (branch === 'patch-dev') { + svgUrl += branch } else { svgUrl += 'dev' } From afe6d792e00d5aae6e1ea44ca3a62f46e6126eeb Mon Sep 17 00:00:00 2001 From: willbot Date: Tue, 17 Nov 2026 07:39:26 +1100 Subject: [PATCH 3/6] fix(ci): refuse to publish prisma under next, which prisma-cli also owns The tags prisma-cli owns on prisma are now one set that getPackageDistTag checks, so the code enforces the same list AGENTS.md states. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- scripts/ci/publish-channel.test.ts | 8 +++++--- scripts/ci/publish-channel.ts | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/ci/publish-channel.test.ts b/scripts/ci/publish-channel.test.ts index 9d5340763956..fe769af77afd 100644 --- a/scripts/ci/publish-channel.test.ts +++ b/scripts/ci/publish-channel.test.ts @@ -69,9 +69,11 @@ describe('getPackageDistTag', () => { }) } - test('refuses to publish prisma under dev', () => { - assert.throws(() => getPackageDistTag('prisma', 'dev'), /prisma\/prisma-cli owns it.*"prev-dev"/) - }) + for (const tag of ['dev', 'next']) { + test(`refuses to publish prisma under ${tag}`, () => { + assert.throws(() => getPackageDistTag('prisma', tag), /prisma\/prisma-cli owns it.*"prev-dev"/) + }) + } }) describe('getNextMinorStable', () => { diff --git a/scripts/ci/publish-channel.ts b/scripts/ci/publish-channel.ts index ed3659365a3f..05347e30b613 100644 --- a/scripts/ci/publish-channel.ts +++ b/scripts/ci/publish-channel.ts @@ -11,6 +11,8 @@ export const PRISMA_STABLE_DIST_TAG = 'prev' const PRISMA_MAJOR = 7 +const PRISMA_CLI_OWNED_DIST_TAGS: ReadonlySet = new Set(['latest', 'dev', 'next']) + export type PublishChannelInput = { branch: string | undefined patchBranch: string | null @@ -46,14 +48,14 @@ export function getPublishChannel({ /** * Returns the npm dist-tag to publish `pkgName` under. Every publish goes through this, including a custom dist tag. - * Throws if `prisma` would land on `dev`, which prisma/prisma-cli owns. + * Throws if `prisma` would land on a tag prisma/prisma-cli owns. */ export function getPackageDistTag(pkgName: string, tag: string): string { if (pkgName !== 'prisma') return tag if (tag === 'latest') return PRISMA_STABLE_DIST_TAG - if (tag === 'dev') { + if (PRISMA_CLI_OWNED_DIST_TAGS.has(tag)) { throw new Error( - `Refusing to publish prisma under the "dev" dist-tag: prisma/prisma-cli owns it for Prisma 8. Prisma 7 dev builds use "${DEV_DIST_TAG}".`, + `Refusing to publish prisma under the "${tag}" dist-tag: prisma/prisma-cli owns it for Prisma 8. Prisma 7 dev builds use "${DEV_DIST_TAG}".`, ) } return tag From afedb1d924ed553284bca73239d92e5beb10f2ea Mon Sep 17 00:00:00 2001 From: willbot Date: Tue, 17 Nov 2026 07:56:06 +1100 Subject: [PATCH 4/6] fix(ci): apply the prisma dist-tag rule only when prisma is being published A run limited with ONLY_PACKAGES or SKIP_PACKAGES to other packages, with a custom dist tag of dev or next, was refused although prisma would not be published. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- scripts/ci/publish.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index 4c9c69429908..cc866771a3fd 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -585,7 +585,7 @@ async function publish() { console.log(`Using custom dist tag: ${args['--custom-dist-tag']}`) tag = args['--custom-dist-tag'] } - const prismaTag = getPackageDistTag('prisma', tag) + const prismaTag = isSkipped('prisma') ? undefined : getPackageDistTag('prisma', tag) console.log({ patchBranch, @@ -794,7 +794,7 @@ async function publishPackages( const pkgDir = path.dirname(pkg.path) const newVersion = prismaVersion - const packageTag = getPackageDistTag(pkgName, tag) + const packageTag = isSkipped(pkgName) ? tag : getPackageDistTag(pkgName, tag) console.log(`\nPublishing ${magenta(`${pkgName}@${newVersion}`)} ${dim(`on ${packageTag}`)}`) From 5399ba9b33cb9a2573308aea66bad8ad24a4dde6 Mon Sep 17 00:00:00 2001 From: willbot Date: Mon, 23 Nov 2026 08:00:20 +1100 Subject: [PATCH 5/6] fix(ci): check the prisma dist-tag only on runs that publish A --test run with a custom dist tag of dev or next was refused although it publishes nothing. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- scripts/ci/publish.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index cc866771a3fd..ea4e741b5d9d 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -585,7 +585,8 @@ async function publish() { console.log(`Using custom dist tag: ${args['--custom-dist-tag']}`) tag = args['--custom-dist-tag'] } - const prismaTag = isSkipped('prisma') ? undefined : getPackageDistTag('prisma', tag) + const publishesPrisma = (args['--publish'] || dryRun) && !isSkipped('prisma') + const prismaTag = publishesPrisma ? getPackageDistTag('prisma', tag) : undefined console.log({ patchBranch, From c91204c26bb5ebbc4819f5bf0ae2fc38c15d00c5 Mon Sep 17 00:00:00 2001 From: willbot Date: Mon, 23 Nov 2026 08:03:57 +1100 Subject: [PATCH 6/6] fix(ci): refuse a custom dist tag that only differs from a prisma-cli tag by whitespace The custom tag reaches pnpm publish through a shell, which drops surrounding whitespace, so " dev" passed the comparison with "dev" and would still have published prisma under it. The tag is now trimmed and must be a plain tag name before it is checked. Co-Authored-By: Claude Fable 5.2 Signed-off-by: willbot Signed-off-by: Will Madden --- AGENTS.md | 2 +- scripts/ci/publish-channel.test.ts | 18 ++++++++++++++++++ scripts/ci/publish-channel.ts | 12 ++++++++++++ scripts/ci/publish.ts | 6 +++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 76fef4d6c257..54970c1f1d70 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ - **Key packages**: `packages/cli` (Prisma CLI entry point), `packages/migrate` (migrate/db namespace + fixtures), `packages/client` (client runtime), `packages/client-generator-ts` (new `prisma-client` generator), `packages/client-generator-js` (traditional `prisma-client-js` generator), `packages/client-generator-registry` (generator registry for managing generators), `packages/client-engine-runtime` (the core part of the new Rust binary free client based on Wasm query compiler, used by `ClientEngine` class in `packages/client`), `packages/client-common` (shared client utilities), `packages/client-runtime-utils` (utility types and singletons for Prisma Client), `packages/config` (`PrismaConfigInternal` + loader), `packages/internals` (shared CLI + engine glue), `packages/engines` (Rust binaries download wrapper), `packages/integration-tests` (matrix suites), `packages/query-plan-executor` (standalone query plan executor service for Prisma Accelerate), `packages/credentials-store` (credential storage utilities), sqlcommenter packages under `packages/sqlcommenter*`, and numerous driver adapters under `packages/adapter-*`. - **Driver adapters & runtimes**: `packages/bundled-js-drivers` plus the `adapter-*` packages ship JS driver adapters: `adapter-pg`, `adapter-neon`, `adapter-libsql`, `adapter-planetscale`, `adapter-d1`, `adapter-better-sqlite3`, `adapter-mssql`, `adapter-mariadb`, `adapter-ppg` (Prisma Postgres Serverless). These are built on helpers in `driver-adapter-utils`; migrate/client fixtures exercise them, so adapter changes typically require fixture/test updates. CI tests driver adapters with flavors: `js_pg`, `js_neon`, `js_libsql`, `js_planetscale`, `js_d1`, `js_better_sqlite3`, `js_mssql`, `js_mariadb`, `js_pg_cockroachdb`. - **Build & tooling**: Typescript-first repo with WASM/Rust assets (downloaded by `@prisma/engines`). Multiple `tsconfig.*` drive bundle vs runtime builds. Lint via `pnpm lint`, format via `pnpm format`. Maintenance scripts live in `scripts/` (e.g. `bump-engines.ts`, `bench.ts`, `ci/publish.ts` orchestrates build/test/publish flows). Build configuration uses esbuild via `helpers/compile/build.ts` with configs in `helpers/compile/configs.ts`. Most packages use `bundledConfig` which bundles to both CJS and ESM with type declarations. - - **npm dist-tags on this branch.** Two publishers share the npm package `prisma`: prisma/prisma-cli (Prisma 8) owns its `latest`, `dev` and `next` tags, and this branch owns `prev`, `prev-dev`, `patch-dev` and `integration`. Stable releases put `prisma` on `prev` and the `@prisma/*` packages on `latest`, so for `@prisma/*` the `prev-dev` tag means "Prisma 7 dev build", not "dev line of `prev`". Every push to `v7` publishes all packages as `-dev.N` under `prev-dev`. Tag and base-version selection live in `scripts/ci/publish-channel.ts`; `getPackageDistTag` there refuses to publish `prisma` under `dev`. Its test runs in the `Workspace types` CI job (`pnpm tsx --test scripts/ci/publish-channel.test.ts`). Revisit these tag names when Prisma 9 ships and 8.x needs `prev`. + - **npm dist-tags on this branch.** Two publishers share the npm package `prisma`: prisma/prisma-cli (Prisma 8) owns its `latest`, `dev` and `next` tags, and this branch owns `prev`, `prev-dev`, `patch-dev` and `integration`. Stable releases put `prisma` on `prev` and the `@prisma/*` packages on `latest`, so for `@prisma/*` the `prev-dev` tag means "Prisma 7 dev build", not "dev line of `prev`". Every push to `v7` publishes all packages as `-dev.N` under `prev-dev`. Tag and base-version selection live in `scripts/ci/publish-channel.ts`; `getPackageDistTag` there refuses to publish `prisma` under a tag prisma/prisma-cli owns. Its test runs in the `Workspace types` CI job (`pnpm tsx --test scripts/ci/publish-channel.test.ts`). Revisit these tag names when Prisma 9 ships and 8.x needs `prev`. - Build helpers that copy Wasm artifacts should resolve package assets through `require.resolve(...)` instead of hardcoding `packages/*/node_modules` paths. With pnpm hoisted installs, dependencies can live only at workspace root and package-local `node_modules/@prisma/*` entries may be absent. - **Benchmarking**: Comprehensive performance benchmarks using Benchmark.js with CodSpeed integration. See `docs/benchmarking.md` for full documentation. Key commands: - `pnpm bench` - Run all benchmarks (outputs to `output.txt`) diff --git a/scripts/ci/publish-channel.test.ts b/scripts/ci/publish-channel.test.ts index fe769af77afd..06097eff2713 100644 --- a/scripts/ci/publish-channel.test.ts +++ b/scripts/ci/publish-channel.test.ts @@ -7,6 +7,7 @@ import { getNextMinorStable, getPackageDistTag, getPublishChannel, + parseCustomDistTag, type PublishChannel, type PublishChannelInput, } from './publish-channel' @@ -76,6 +77,23 @@ describe('getPackageDistTag', () => { } }) +describe('parseCustomDistTag', () => { + test('removes the whitespace a shell would drop', () => { + assert.equal(parseCustomDistTag(' next'), 'next') + assert.equal(parseCustomDistTag('dev '), 'dev') + }) + + test('a padded prisma-cli tag is still refused for prisma', () => { + assert.throws(() => getPackageDistTag('prisma', parseCustomDistTag(' dev ')), /prisma\/prisma-cli owns it/) + }) + + for (const input of ['', 'my tag', 'Dev', 'dev;next', '--tag']) { + test(`refuses ${JSON.stringify(input)}`, () => { + assert.throws(() => parseCustomDistTag(input), /not a usable npm dist-tag/) + }) + } +}) + describe('getNextMinorStable', () => { test('returns the next minor after the highest stable 7.x version', () => { assert.equal(getNextMinorStable(['7.9.0', '7.10.0', '7.10.1', '7.10.0-dev.58']), '7.11.0') diff --git a/scripts/ci/publish-channel.ts b/scripts/ci/publish-channel.ts index 05347e30b613..427eb17b5c75 100644 --- a/scripts/ci/publish-channel.ts +++ b/scripts/ci/publish-channel.ts @@ -61,6 +61,18 @@ export function getPackageDistTag(pkgName: string, tag: string): string { return tag } +/** + * Returns a custom dist-tag as npm will receive it. The tag reaches `pnpm publish --tag` through a shell, which drops + * surrounding whitespace, so ` dev` would pass a comparison with `dev` and still publish under it. + */ +export function parseCustomDistTag(input: string): string { + const tag = input.trim() + if (!/^[a-z][a-z0-9._-]*$/.test(tag)) { + throw new Error(`"${input}" is not a usable npm dist-tag: use lowercase letters, digits, ".", "_" and "-".`) + } + return tag +} + /** * Returns the next minor after the highest stable Prisma 7 version in `publishedVersions`, e.g. `7.10.1` -> `7.11.0`. * Reads the version list rather than a dist-tag, because a release from an older patch branch moves `prev` back. diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index ea4e741b5d9d..17b725b718af 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -12,7 +12,7 @@ import { blue, bold, cyan, dim, magenta, red, underline } from 'kleur/colors' import pRetry from 'p-retry' import semver from 'semver' -import { getNextMinorStable, getPackageDistTag, getPublishChannel } from './publish-channel' +import { getNextMinorStable, getPackageDistTag, getPublishChannel, parseCustomDistTag } from './publish-channel' const onlyPackages = process.env.ONLY_PACKAGES ? process.env.ONLY_PACKAGES.split(',') : null const skipPackages = process.env.SKIP_PACKAGES ? process.env.SKIP_PACKAGES.split(',') : null @@ -582,8 +582,8 @@ async function publish() { } if (args['--custom-dist-tag']) { - console.log(`Using custom dist tag: ${args['--custom-dist-tag']}`) - tag = args['--custom-dist-tag'] + tag = parseCustomDistTag(args['--custom-dist-tag']) + console.log(`Using custom dist tag: ${tag}`) } const publishesPrisma = (args['--publish'] || dryRun) && !isSkipped('prisma') const prismaTag = publishesPrisma ? getPackageDistTag('prisma', tag) : undefined