Repository navigation
Commit 91b2a0e
authored
feat(engine):
## At a glance
`prisma orm init` in an npm project writes the ORM packages with a caret
today. After this change, and the ORM change that uses it, it writes the
exact version:
```diff
"dependencies": {
- "@prisma/orm-postgres": "^8.0.0-rc.28",
+ "@prisma/orm-postgres": "8.0.0-rc.28",
```
`orm init` installs packages through the engine (`@prisma/cli-engine`).
A command reaches the engine's package installs through
`ctx.packages.install`. That call can now ask for the version to be
saved exactly as given:
```ts
await ctx.packages.install({
packages: ["@prisma/orm-postgres@8.0.0-rc.28"],
exact: true,
});
```
| Manager | Command the engine runs |
| --- | --- |
| npm | `npm add --save-exact @prisma/orm-postgres@8.0.0-rc.28` |
| pnpm | `pnpm add --save-exact @prisma/orm-postgres@8.0.0-rc.28` |
| yarn | `yarn add --exact @prisma/orm-postgres@8.0.0-rc.28` |
| bun | `bun add --exact @prisma/orm-postgres@8.0.0-rc.28` |
| deno | `deno add npm:@prisma/orm-postgres@8.0.0-rc.28` (no flag) |
With `dev: true` both flags are passed (`npm add -D --save-exact …`).
Without `exact`, every command is unchanged.
## Why
Until release 8.0, the ORM's [versioning
policy](https://github.com/prisma/orm/blob/main/docs/oss/versioning.md)
says an application lists every Prisma ORM package at one exact version,
and `orm init` asks for exactly that version. npm saves an exact request
with a caret unless told not to. The other managers already save it as
given.
The caret breaks the project at the next ORM release. Since
[#417](#417), `prisma` refuses
an ORM command when the project's ORM packages are not the version it
runs. `npm update` moves the ORM packages through the caret while the
project's `prisma` stays where it is, and every ORM command stops until
the user also updates `prisma`. The ORM cannot fix this alone, because
the engine writes the install command and had no way to say "save
exactly".
## What changes
- **The option.** `PackageOperations.install` takes an optional `exact`.
`installCommand`, the engine's one place that writes each manager's
command line, maps it to the manager's own flag, as in the table above.
The engine shows that command line before it runs it, and repeats it in
the error when the install fails, so both carry the flag too.
- **deno gets no flag.** deno's docs list `--save-exact`, but deno
2.6.10 rejects it and installs nothing. deno already saves an exact
request as given.
- **Pass `exact` only when every package names an exact version.** npm's
flag also turns a range into the version it resolved: `npm add
--save-exact pkg@^7.0.0` saves `7.0.0`. pnpm, Yarn and bun keep a range
as given under their flags. The option's doc comment says this, so a
caller installs ranges in a separate call.
- **How the flags were checked.** pnpm 10 and 11, Yarn 1 and 4, bun 1.3
and deno 2.6 were run with each case: an exact pre-release, an exact
plain version, a range, and the dev flag. npm's behaviour comes from its
documentation and its source (`@npmcli/arborist`).
- **Engine 0.10.4 → 0.10.5.** This is a patch because the option is
optional. The two packages the CLI mounts commands from,
`@prisma/orm-toolchain` (the ORM's commands) and `@prisma/composer-cli`
(Composer's), each require one exact engine version, and still require
0.10.4. As [ADR
0004](docs/architecture/adrs/0004-engine-version-pinning.md) prescribes
for this case, `packages/cli/scripts/conformance.ts` records an
exception for each, for development builds only. The CLI's pre-publish
check still refuses a release until both require 0.10.5.
## Tests
`tests/package-manager.test.ts` asserts the whole command for each
manager with `exact`, and with `dev` and `exact` together.
`tests/package-operations.test.ts` asserts that `exact` reaches the
spawned command, the command line the engine shows, and the failure's
error. The new non-deno cases fail without the change. The two deno
cases pass on the old code by design: they stop a later change from
adding a flag that breaks deno installs.
## What follows
1. Merging this publishes engine 0.10.5.
2. A prisma/orm pull request moves `@prisma/orm-toolchain` to 0.10.5,
and has `orm init` pass `exact` for its exact-version installs.
3. Composer moves `@prisma/composer-cli` to 0.10.5.
4. The next CLI release ships 0.10.5, and the two exceptions are
removed.
## Alternatives considered
- **`orm init` rewrites `package.json` after the install.** The lockfile
still records the caret, and `npm ci` then refuses because
`package.json` and the lockfile disagree.
- **Set npm's `save_exact` setting in the environment from `orm init`.**
It works for npm only, and it goes around the engine, which is meant to
own the command line.
- **Always save exact.** Other callers install ranges and tags such as
`prisma@latest`, and npm would save those as one fixed version.
Agent: lucius-31
---------
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>prisma orm init can save exact versions under npm, through a new exact option on package installs (#437)1 parent 0193c5d commit 91b2a0e
9 files changed
Lines changed: 184 additions & 16 deletions
File tree
- packages
- cli-engine
- src
- execution
- tests
- cli
- scripts
- prisma
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
| 246 | + | |
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
138 | | - | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| |||
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
173 | | - | |
174 | | - | |
175 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| |||
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
184 | | - | |
| 195 | + | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
188 | | - | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
192 | | - | |
| 203 | + | |
193 | 204 | | |
194 | 205 | | |
195 | 206 | | |
196 | | - | |
| 207 | + | |
197 | 208 | | |
198 | 209 | | |
199 | 210 | | |
200 | | - | |
| 211 | + | |
| 212 | + | |
201 | 213 | | |
202 | 214 | | |
203 | 215 | | |
| |||
214 | 226 | | |
215 | 227 | | |
216 | 228 | | |
| 229 | + | |
217 | 230 | | |
218 | 231 | | |
219 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
220 | 236 | | |
221 | 237 | | |
222 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
202 | 285 | | |
203 | 286 | | |
204 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
345 | 390 | | |
346 | 391 | | |
347 | 392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
126 | 147 | | |
127 | 148 | | |
128 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments