@prenta/cli 1.3.0 β 1.3.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +50 -50
- package/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/dist/utils/database.d.ts.map +1 -1
- package/dist/utils/database.js +2 -1
- package/dist/utils/database.js.map +1 -1
- package/dist/utils/pg-ssl-mode.d.ts +28 -0
- package/dist/utils/pg-ssl-mode.d.ts.map +1 -0
- package/dist/utils/pg-ssl-mode.js +56 -0
- package/dist/utils/pg-ssl-mode.js.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/pg-ssl-mode-in-step.test.ts +29 -0
- package/src/__tests__/pg-ssl-mode.test.ts +78 -0
- package/src/utils/database.ts +2 -1
- package/src/utils/pg-ssl-mode.ts +52 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
|
|
2
|
-
> @prenta/cli@1.3.
|
|
2
|
+
> @prenta/cli@1.3.2 test /home/runner/work/prenta/prenta/packages/cli
|
|
3
3
|
> vitest run "--no-file-parallelism"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.12 [39m[90m/home/runner/work/prenta/prenta/packages/cli[39m
|
|
7
7
|
|
|
8
|
-
[32mβ[39m src/__tests__/db-restore.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m
|
|
9
|
-
[33m[2mβ[22m[39m requires --target and never defaults to the env database [33m
|
|
10
|
-
[33m[2mβ[22m[39m warns when --target carries a password on argv and recommends PGPASSWORD instead [33m
|
|
11
|
-
[33m[2mβ[22m[39m OIDC mode (VERCEL_OIDC_TOKEN + BLOB_STORE_ID) lists and restores without passing a token [33m
|
|
12
|
-
[33m[2mβ[22m[39m
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[33m[2mβ[22m[39m refuses localhost / 127.0.0.1 unless --allow-local [33m
|
|
16
|
-
|
|
17
|
-
[32mβ[39m src/__tests__/
|
|
18
|
-
[32mβ[39m src/__tests__/backup-
|
|
19
|
-
[32mβ[39m src/__tests__/
|
|
20
|
-
[32mβ[39m src/__tests__/
|
|
21
|
-
[33m[2mβ[22m[39m refreshes an auto-synced schema and adds missing migrations [33m 306[2mms[22m[39m
|
|
22
|
-
[32mβ[39m src/__tests__/chrome.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 18141[2mms[22m[39m
|
|
8
|
+
[32mβ[39m src/__tests__/db-restore.test.ts [2m([22m[2m34 tests[22m[2m)[22m[33m 6911[2mms[22m[39m
|
|
9
|
+
[33m[2mβ[22m[39m requires --target and never defaults to the env database [33m 488[2mms[22m[39m
|
|
10
|
+
[33m[2mβ[22m[39m warns when --target carries a password on argv and recommends PGPASSWORD instead [33m 424[2mms[22m[39m
|
|
11
|
+
[33m[2mβ[22m[39m OIDC mode (VERCEL_OIDC_TOKEN + BLOB_STORE_ID) lists and restores without passing a token [33m 500[2mms[22m[39m
|
|
12
|
+
[33m[2mβ[22m[39m --list prints available backups newest first with stamps and sizes [32m 300[2mms[22m[39m
|
|
13
|
+
[33m[2mβ[22m[39m "latest" selects the newest stamp under the prefix [33m 348[2mms[22m[39m
|
|
14
|
+
[32mβ[39m src/__tests__/db-backup.test.ts [2m([22m[2m27 tests[22m[2m)[22m[33m 3345[2mms[22m[39m
|
|
15
|
+
[33m[2mβ[22m[39m refuses localhost / 127.0.0.1 unless --allow-local [33m 431[2mms[22m[39m
|
|
16
|
+
[32mβ[39m src/__tests__/deployment-diagnostics.test.ts [2m([22m[2m23 tests[22m[2m)[22m[32m 175[2mms[22m[39m
|
|
17
|
+
[32mβ[39m src/__tests__/backup-blob-store.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 855[2mms[22m[39m
|
|
18
|
+
[32mβ[39m src/__tests__/backup-pg-tools.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 275[2mms[22m[39m
|
|
19
|
+
[32mβ[39m src/__tests__/db-sync.test.ts [2m([22m[2m13 tests[22m[2m)[22m[33m 548[2mms[22m[39m
|
|
20
|
+
[32mβ[39m src/__tests__/chrome.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 17657[2mms[22m[39m
|
|
23
21
|
[2m[90mβ[39m[22m src/__tests__/integration/backup-roundtrip.int.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
|
|
24
|
-
[32mβ[39m src/__tests__/backup-manifest.test.ts [2m([22m[2m17 tests[22m[2m)[22m[32m
|
|
22
|
+
[32mβ[39m src/__tests__/backup-manifest.test.ts [2m([22m[2m17 tests[22m[2m)[22m[32m 77[2mms[22m[39m
|
|
25
23
|
- Resolving target versionsβ¦
|
|
26
24
|
β Target version: 9.0.0
|
|
27
|
-
[32mβ[39m src/__tests__/upgrade-workspaces.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m
|
|
28
|
-
[33m[2mβ[22m[39m passes `upgrade --version <ver>` to upgrade instead of printing the CLI version [33m
|
|
29
|
-
[33m[2mβ[22m[39m prints its own package version for `prenta --version` [33m
|
|
30
|
-
[32mβ[39m src/__tests__/seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m
|
|
31
|
-
[32mβ[39m src/__tests__/backup-crypto.test.ts [2m([22m[2m13 tests[22m[2m)[22m[
|
|
25
|
+
[32mβ[39m src/__tests__/upgrade-workspaces.test.ts [2m([22m[2m12 tests[22m[2m)[22m[33m 2797[2mms[22m[39m
|
|
26
|
+
[33m[2mβ[22m[39m passes `upgrade --version <ver>` to upgrade instead of printing the CLI version [33m 1685[2mms[22m[39m
|
|
27
|
+
[33m[2mβ[22m[39m prints its own package version for `prenta --version` [33m 926[2mms[22m[39m
|
|
28
|
+
[32mβ[39m src/__tests__/seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 63[2mms[22m[39m
|
|
29
|
+
[32mβ[39m src/__tests__/backup-crypto.test.ts [2m([22m[2m13 tests[22m[2m)[22m[33m 573[2mms[22m[39m
|
|
30
|
+
[33m[2mβ[22m[39m detects a flipped auth-tag byte [33m 324[2mms[22m[39m
|
|
32
31
|
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mcreates Claude Code, Cursor, and VS Code configs with placeholder key and git-ignores them
|
|
33
32
|
[22m[39mβ Created .mcp.json
|
|
34
33
|
|
|
@@ -117,16 +116,16 @@ Next steps
|
|
|
117
116
|
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mfails on invalid JSON without --force, overwrites with --force
|
|
118
117
|
[22m[39mβ Created .mcp.json
|
|
119
118
|
|
|
120
|
-
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mfails on invalid JSON without --force, overwrites with --force
|
|
121
119
|
[90mstderr[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mfails on invalid JSON without --force, overwrites with --force
|
|
122
|
-
[
|
|
120
|
+
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mfails on invalid JSON without --force, overwrites with --force
|
|
123
121
|
[22m[39mβ Created .vscode/mcp.json
|
|
124
122
|
|
|
125
|
-
|
|
126
123
|
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mfails on invalid JSON without --force, overwrites with --force
|
|
127
124
|
[22m[39mβ Added to .gitignore: .mcp.json, .cursor/mcp.json, .vscode/mcp.json
|
|
128
125
|
|
|
129
126
|
Next steps
|
|
127
|
+
[22m[39mβ .cursor/mcp.json contains invalid JSON β fix it or re-run with --force.
|
|
128
|
+
|
|
130
129
|
1. Mint an API key in Admin β Settings β API Keys (act_sk_...)
|
|
131
130
|
2. Replace act_sk_REPLACE_WITH_YOUR_KEY in the MCP config files with the real key
|
|
132
131
|
3. Restart Claude Code / Cursor / VS Code so the MCP server is picked up
|
|
@@ -167,10 +166,10 @@ Next steps
|
|
|
167
166
|
|
|
168
167
|
[90mstdout[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mrefuses to write a real key into a config git already tracks
|
|
169
168
|
[22m[39mβ Updated .mcp.json
|
|
170
|
-
|
|
171
169
|
[90mstderr[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mrefuses to write a real key into a config git already tracks
|
|
172
170
|
[22m[39mβ .cursor/mcp.json already has an "prenta" server β use --force to replace it.
|
|
173
171
|
|
|
172
|
+
|
|
174
173
|
[90mstderr[2m | src/__tests__/mcp-init.test.ts[2m > [22m[2mmcp:init[2m > [22m[2mrefuses to write a real key into a config git already tracks
|
|
175
174
|
[22m[39mβ .vscode/mcp.json already has an "prenta" server β use --force to replace it.
|
|
176
175
|
|
|
@@ -217,20 +216,20 @@ Next steps
|
|
|
217
216
|
3. Restart Claude Code / Cursor / VS Code so the MCP server is picked up
|
|
218
217
|
Tip: pass --url https://your-site.com to target a deployed CMS instead.
|
|
219
218
|
|
|
220
|
-
[32mβ[39m src/__tests__/mcp-init.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m
|
|
221
|
-
[32mβ[39m src/__tests__/backup-common.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m
|
|
219
|
+
[32mβ[39m src/__tests__/mcp-init.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 562[2mms[22m[39m
|
|
220
|
+
[32mβ[39m src/__tests__/backup-common.test.ts [2m([22m[2m14 tests[22m[2m)[22m[32m 88[2mms[22m[39m
|
|
222
221
|
- Reading canonical Prenta schema...
|
|
223
222
|
β Prenta CMS models added to schema.
|
|
224
|
-
- Running prisma generate...
|
|
225
223
|
[90mstdout[2m | src/__tests__/db-init.test.ts[2m > [22m[2mdb:init (WS-D D5 β canonical schema, no stale fragment)[2m > [22m[2mcommand[2m > [22m[2minjects canonical models with @@map and no duplicate datasource/generator
|
|
226
224
|
[22m[39mβ Prisma client generated.
|
|
225
|
+
- Running prisma generate...
|
|
227
226
|
βΉ Run `npx prisma migrate dev --name prenta-cms` to create the migration.
|
|
228
227
|
|
|
228
|
+
- Reading canonical Prenta schema...
|
|
229
|
+
β Could not locate @prenta/core.
|
|
229
230
|
[90mstdout[2m | src/__tests__/db-init.test.ts[2m > [22m[2mdb:init (WS-D D5 β canonical schema, no stale fragment)[2m > [22m[2mcommand[2m > [22m[2mfails clearly when cms-core cannot be located
|
|
230
231
|
[22m[39mβΉ Install it first: `npm install @prenta/core`.
|
|
231
232
|
|
|
232
|
-
- Reading canonical Prenta schema...
|
|
233
|
-
β Could not locate @prenta/core.
|
|
234
233
|
- Reading canonical Prenta schema...
|
|
235
234
|
β Prenta CMS models added to schema.
|
|
236
235
|
- Running prisma generate...
|
|
@@ -240,30 +239,31 @@ Next steps
|
|
|
240
239
|
|
|
241
240
|
- Reading canonical Prenta schema...
|
|
242
241
|
βΉ Prenta CMS models already present in schema. Use --force to overwrite.
|
|
243
|
-
[32mβ[39m src/__tests__/db-init.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m
|
|
244
|
-
[32mβ[39m src/__tests__/seed-sanitize.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m
|
|
245
|
-
[32mβ[39m src/__tests__/prisma-client-path.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m
|
|
246
|
-
[32mβ[39m src/__tests__/form-seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m
|
|
247
|
-
[32mβ[39m src/__tests__/
|
|
248
|
-
|
|
249
|
-
[32mβ[39m src/__tests__/vercel-env-matrix.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
250
|
-
[32mβ[39m src/__tests__/upgrade.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
251
|
-
[32mβ[39m src/__tests__/repo-root.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m
|
|
252
|
-
[32mβ[39m src/__tests__/load-dotenv.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
253
|
-
[32mβ[39m src/__tests__/import-typescript-hooks.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
242
|
+
[32mβ[39m src/__tests__/db-init.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 132[2mms[22m[39m
|
|
243
|
+
[32mβ[39m src/__tests__/seed-sanitize.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 54[2mms[22m[39m
|
|
244
|
+
[32mβ[39m src/__tests__/prisma-client-path.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 30[2mms[22m[39m
|
|
245
|
+
[32mβ[39m src/__tests__/form-seed.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 27[2mms[22m[39m
|
|
246
|
+
[32mβ[39m src/__tests__/pg-ssl-mode.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 25[2mms[22m[39m
|
|
247
|
+
[32mβ[39m src/__tests__/import-typescript.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 259[2mms[22m[39m
|
|
248
|
+
[32mβ[39m src/__tests__/vercel-env-matrix.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
249
|
+
[32mβ[39m src/__tests__/upgrade.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 23[2mms[22m[39m
|
|
250
|
+
[32mβ[39m src/__tests__/repo-root.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 80[2mms[22m[39m
|
|
251
|
+
[32mβ[39m src/__tests__/load-dotenv.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 25[2mms[22m[39m
|
|
252
|
+
[32mβ[39m src/__tests__/import-typescript-hooks.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 70[2mms[22m[39m
|
|
254
253
|
- Reading canonical Prenta schema...
|
|
255
|
-
β Prenta CMS models added to schema.
|
|
256
|
-
- Running prisma generate...
|
|
257
254
|
[90mstdout[2m | src/__tests__/schema-fragment.test.ts[2m > [22m[2mdb:init schema fragment[2m > [22m[2minjects all deploy-critical Prenta models
|
|
255
|
+
β Prenta CMS models added to schema.
|
|
258
256
|
[22m[39mβ Prisma client generated.
|
|
259
257
|
βΉ Run `npx prisma migrate dev --name prenta-cms` to create the migration.
|
|
260
258
|
|
|
261
|
-
|
|
262
|
-
[32mβ[39m src/__tests__/
|
|
259
|
+
- Running prisma generate...
|
|
260
|
+
[32mβ[39m src/__tests__/schema-fragment.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 50[2mms[22m[39m
|
|
261
|
+
[32mβ[39m src/__tests__/db-sync-resolver.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
262
|
+
[32mβ[39m src/__tests__/pg-ssl-mode-in-step.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
263
263
|
[32mβ[39m src/__tests__/init.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 25[2mms[22m[39m
|
|
264
264
|
|
|
265
|
-
[2m Test Files [22m [1m[
|
|
266
|
-
[2m Tests [22m [1m[
|
|
267
|
-
[2m Start at [22m
|
|
268
|
-
[2m Duration [22m
|
|
265
|
+
[2m Test Files [22m [1m[32m28 passed[39m[22m[2m | [22m[33m1 skipped[39m[90m (29)[39m
|
|
266
|
+
[2m Tests [22m [1m[32m300 passed[39m[22m[2m | [22m[33m1 skipped[39m[90m (301)[39m
|
|
267
|
+
[2m Start at [22m 09:03:26
|
|
268
|
+
[2m Duration [22m 74.96s[2m (transform 20.08s, setup 0ms, import 15.45s, tests 34.77s, environment 3ms)[22m
|
|
269
269
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @actuate-media/cli
|
|
2
2
|
|
|
3
|
+
## 1.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5230917: Point repository links at github.com/Prenta-dev/prenta, where the source now lives. The `repository` field on npm, the importer adapters' docs links, the section editor's help link and the docs link `create-prenta` prints all moved from `actuate-media/prenta`. No behaviour changes.
|
|
8
|
+
|
|
9
|
+
## 1.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 5c7026c: Stop pg's SSL mode warning from the core Postgres adapter and the CLI. Both handed the connection string straight to `pg`, which logs a SECURITY WARNING for `sslmode=require` because `pg` 9 will stop verifying the certificate for it. `createPostgresAdapter` and the CLI commands that open a database connection (`seed`, `populate`, `migrate:*`) now rewrite `prefer`, `require` and `verify-ca` to `verify-full` first: the same behaviour today, no warning, and full verification kept under `pg` 9. A URL with `uselibpqcompat=true` is left as it is.
|
|
14
|
+
|
|
3
15
|
## 1.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @prenta/cli
|
|
2
2
|
|
|
3
|
-
CLI for [Prenta CMS](https://github.com/
|
|
3
|
+
CLI for [Prenta CMS](https://github.com/Prenta-dev/prenta) β
|
|
4
4
|
migrations, codegen, seeding, imports/exports, verification, and upgrades.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
@@ -23,7 +23,7 @@ Run `prenta --help` for the full command list.
|
|
|
23
23
|
## Release notes
|
|
24
24
|
|
|
25
25
|
See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
|
|
26
|
-
[GitHub releases](https://github.com/
|
|
26
|
+
[GitHub releases](https://github.com/Prenta-dev/prenta/releases).
|
|
27
27
|
|
|
28
28
|
## License
|
|
29
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC;IAEtD,EAAE,EAAE,GAAG,CAAA;IACP,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAChC,CAAC,CAiBD"}
|
package/dist/utils/database.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { importProjectTypescript } from './import-typescript.js';
|
|
5
|
+
import { withExplicitSslMode } from './pg-ssl-mode.js';
|
|
5
6
|
import { resolvePrismaClientLoadPlan } from './prisma-client-path.js';
|
|
6
7
|
/**
|
|
7
8
|
* Shared helper for CLI commands that need a live connection to the consumer
|
|
@@ -95,7 +96,7 @@ async function createClientFromGenerated(generatedClient) {
|
|
|
95
96
|
}
|
|
96
97
|
const { PrismaPg } = adapterModule;
|
|
97
98
|
const pg = pgModule.default ?? pgModule;
|
|
98
|
-
const pool = new pg.Pool({ connectionString: url });
|
|
99
|
+
const pool = new pg.Pool({ connectionString: withExplicitSslMode(url) });
|
|
99
100
|
const adapter = new PrismaPg(pool);
|
|
100
101
|
return new PrismaClient({ adapter });
|
|
101
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/utils/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAK1C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAA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M,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACzD,IAAI,OAAO;YAAE,OAAO,OAAO,CAAA;IAC7B,CAAC;IAED,MAAM,kBAAkB,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,CAAA;IAClF,MAAM,YAAY,GAAG,CAAC,MAAM,YAAY,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAE7E,CAAA;IACD,OAAO,IAAI,YAAY,CAAC,YAAY,EAAE,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a Postgres connection string's TLS mode explicit.
|
|
3
|
+
*
|
|
4
|
+
* `pg` 8 treats `sslmode=prefer`, `require` and `verify-ca` as aliases
|
|
5
|
+
* for `verify-full`, and logs a SECURITY WARNING the first time it parses
|
|
6
|
+
* one, to say that `pg` 9 will weaken them to libpq's meaning (no
|
|
7
|
+
* certificate verification for `require`). Hosted providers hand out
|
|
8
|
+
* `sslmode=require` strings, so the warning shows up on every cold start.
|
|
9
|
+
*
|
|
10
|
+
* Rewriting those modes to `verify-full` asks for exactly what `pg` 8
|
|
11
|
+
* already does: the warning stops, and full certificate verification stays
|
|
12
|
+
* when `pg` 9 arrives.
|
|
13
|
+
*
|
|
14
|
+
* A string that opts in to libpq semantics with `uselibpqcompat=true` is
|
|
15
|
+
* left alone, as is one with no `sslmode`, `sslmode=disable` or
|
|
16
|
+
* `sslmode=no-verify`.
|
|
17
|
+
*
|
|
18
|
+
* The query is read the way `pg` reads it: names and values are
|
|
19
|
+
* percent-decoded, and the last of a repeated parameter wins. Only the one
|
|
20
|
+
* `sslmode` segment that takes effect is replaced; every other character,
|
|
21
|
+
* credentials included, is returned as it was given.
|
|
22
|
+
*
|
|
23
|
+
* A copy of `packages/cms-core/src/db/pg-ssl-mode.ts`. The CLI supports
|
|
24
|
+
* older `@prenta/core` versions, so it cannot import this from core. Keep
|
|
25
|
+
* the two in step.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withExplicitSslMode<T extends string | undefined>(connectionString: T): T;
|
|
28
|
+
//# sourceMappingURL=pg-ssl-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-ssl-mode.d.ts","sourceRoot":"","sources":["../../src/utils/pg-ssl-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAyBxF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a Postgres connection string's TLS mode explicit.
|
|
3
|
+
*
|
|
4
|
+
* `pg` 8 treats `sslmode=prefer`, `require` and `verify-ca` as aliases
|
|
5
|
+
* for `verify-full`, and logs a SECURITY WARNING the first time it parses
|
|
6
|
+
* one, to say that `pg` 9 will weaken them to libpq's meaning (no
|
|
7
|
+
* certificate verification for `require`). Hosted providers hand out
|
|
8
|
+
* `sslmode=require` strings, so the warning shows up on every cold start.
|
|
9
|
+
*
|
|
10
|
+
* Rewriting those modes to `verify-full` asks for exactly what `pg` 8
|
|
11
|
+
* already does: the warning stops, and full certificate verification stays
|
|
12
|
+
* when `pg` 9 arrives.
|
|
13
|
+
*
|
|
14
|
+
* A string that opts in to libpq semantics with `uselibpqcompat=true` is
|
|
15
|
+
* left alone, as is one with no `sslmode`, `sslmode=disable` or
|
|
16
|
+
* `sslmode=no-verify`.
|
|
17
|
+
*
|
|
18
|
+
* The query is read the way `pg` reads it: names and values are
|
|
19
|
+
* percent-decoded, and the last of a repeated parameter wins. Only the one
|
|
20
|
+
* `sslmode` segment that takes effect is replaced; every other character,
|
|
21
|
+
* credentials included, is returned as it was given.
|
|
22
|
+
*
|
|
23
|
+
* A copy of `packages/cms-core/src/db/pg-ssl-mode.ts`. The CLI supports
|
|
24
|
+
* older `@prenta/core` versions, so it cannot import this from core. Keep
|
|
25
|
+
* the two in step.
|
|
26
|
+
*/
|
|
27
|
+
export function withExplicitSslMode(connectionString) {
|
|
28
|
+
if (!connectionString)
|
|
29
|
+
return connectionString;
|
|
30
|
+
const queryStart = connectionString.indexOf('?');
|
|
31
|
+
if (queryStart === -1)
|
|
32
|
+
return connectionString;
|
|
33
|
+
const base = connectionString.slice(0, queryStart);
|
|
34
|
+
const afterQuestionMark = connectionString.slice(queryStart + 1);
|
|
35
|
+
const fragmentStart = afterQuestionMark.indexOf('#');
|
|
36
|
+
const query = fragmentStart === -1 ? afterQuestionMark : afterQuestionMark.slice(0, fragmentStart);
|
|
37
|
+
const fragment = fragmentStart === -1 ? '' : afterQuestionMark.slice(fragmentStart);
|
|
38
|
+
const params = new URLSearchParams(query);
|
|
39
|
+
// pg honours this flag only as the exact value "true".
|
|
40
|
+
if (params.getAll('uselibpqcompat').pop() === 'true')
|
|
41
|
+
return connectionString;
|
|
42
|
+
const mode = params.getAll('sslmode').pop();
|
|
43
|
+
if (mode !== 'prefer' && mode !== 'require' && mode !== 'verify-ca')
|
|
44
|
+
return connectionString;
|
|
45
|
+
const segments = query.split('&');
|
|
46
|
+
let effective = -1;
|
|
47
|
+
segments.forEach((segment, index) => {
|
|
48
|
+
if (new URLSearchParams(segment).has('sslmode'))
|
|
49
|
+
effective = index;
|
|
50
|
+
});
|
|
51
|
+
if (effective === -1)
|
|
52
|
+
return connectionString;
|
|
53
|
+
segments[effective] = 'sslmode=verify-full';
|
|
54
|
+
return (base + '?' + segments.join('&') + fragment);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=pg-ssl-mode.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,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,gBAAgB,CAAA;IAE5F,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAA;IAClB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;QAClC,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAS,GAAG,KAAK,CAAA;IACpE,CAAC,CAAC,CAAA;IACF,IAAI,SAAS,KAAK,CAAC,CAAC;QAAE,OAAO,gBAAgB,CAAA;IAC7C,QAAQ,CAAC,SAAS,CAAC,GAAG,qBAAqB,CAAA;IAC3C,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAM,CAAA;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prenta/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "CLI for Prenta CMS β migrations, codegen, imports, exports, and upgrades",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "https://github.com/Prenta-dev/prenta.git",
|
|
9
9
|
"directory": "packages/cli"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vercel/blob": "^2.3.1",
|
|
37
37
|
"typescript": "^5.7.0",
|
|
38
38
|
"vitest": "^4.1.12",
|
|
39
|
-
"@prenta/core": "8.21.
|
|
39
|
+
"@prenta/core": "8.21.11"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const cliCopy = path.join(here, '..', 'utils', 'pg-ssl-mode.ts')
|
|
8
|
+
const coreCopy = path.join(here, '..', '..', '..', 'cms-core', 'src', 'db', 'pg-ssl-mode.ts')
|
|
9
|
+
const cliDatabase = path.join(here, '..', 'utils', 'database.ts')
|
|
10
|
+
|
|
11
|
+
/** Everything from the function signature on: the doc comments differ on purpose. */
|
|
12
|
+
function implementation(source: string): string {
|
|
13
|
+
const start = source.indexOf('export function withExplicitSslMode')
|
|
14
|
+
if (start === -1) throw new Error('withExplicitSslMode not found')
|
|
15
|
+
return source.slice(start).replace(/\r\n/g, '\n')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('pg sslmode helper', () => {
|
|
19
|
+
it('is the same in the CLI as in @prenta/core', async () => {
|
|
20
|
+
const [cli, core] = await Promise.all([readFile(cliCopy, 'utf-8'), readFile(coreCopy, 'utf-8')])
|
|
21
|
+
expect(implementation(cli)).toBe(implementation(core))
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('wraps the connection string the CLI hands to pg', async () => {
|
|
25
|
+
const source = await readFile(cliDatabase, 'utf-8')
|
|
26
|
+
expect(source).toContain('.Pool({ connectionString: withExplicitSslMode(url) })')
|
|
27
|
+
expect(source).not.toContain('.Pool({ connectionString: url })')
|
|
28
|
+
})
|
|
29
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { withExplicitSslMode } from '../utils/pg-ssl-mode.js'
|
|
3
|
+
|
|
4
|
+
const BASE = 'postgres://user:p%40ss%2Fword@db.example.com:5432/app'
|
|
5
|
+
|
|
6
|
+
describe('withExplicitSslMode', () => {
|
|
7
|
+
it('rewrites the modes pg 8 treats as verify-full', () => {
|
|
8
|
+
for (const mode of ['prefer', 'require', 'verify-ca']) {
|
|
9
|
+
expect(withExplicitSslMode(`${BASE}?sslmode=${mode}`)).toBe(`${BASE}?sslmode=verify-full`)
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('keeps the other query parameters, their order and the credentials', () => {
|
|
14
|
+
expect(withExplicitSslMode(`${BASE}?connection_limit=5&sslmode=require&pgbouncer=true`)).toBe(
|
|
15
|
+
`${BASE}?connection_limit=5&sslmode=verify-full&pgbouncer=true`,
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('leaves strings it should not change', () => {
|
|
20
|
+
for (const url of [
|
|
21
|
+
BASE,
|
|
22
|
+
`${BASE}?sslmode=verify-full`,
|
|
23
|
+
`${BASE}?sslmode=disable`,
|
|
24
|
+
`${BASE}?sslmode=no-verify`,
|
|
25
|
+
`${BASE}?uselibpqcompat=true&sslmode=require`,
|
|
26
|
+
`${BASE}?sslmode=require&uselibpqcompat=true`,
|
|
27
|
+
`${BASE}?application_name=sslmode=require-ish`,
|
|
28
|
+
'prisma+postgres://accelerate.prisma-data.net/?api_key=abc',
|
|
29
|
+
]) {
|
|
30
|
+
expect(withExplicitSslMode(url)).toBe(url)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('reads percent-encoded names and values the way pg does', () => {
|
|
35
|
+
expect(withExplicitSslMode(`${BASE}?sslmode=%72equire`)).toBe(`${BASE}?sslmode=verify-full`)
|
|
36
|
+
expect(withExplicitSslMode(`${BASE}?%73slmode=require&x=1`)).toBe(
|
|
37
|
+
`${BASE}?sslmode=verify-full&x=1`,
|
|
38
|
+
)
|
|
39
|
+
// An encoded opt-in to libpq semantics is still an opt-in.
|
|
40
|
+
for (const url of [
|
|
41
|
+
`${BASE}?sslmode=require&uselibpqcompat=%74rue`,
|
|
42
|
+
`${BASE}?%75selibpqcompat=true&sslmode=require`,
|
|
43
|
+
]) {
|
|
44
|
+
expect(withExplicitSslMode(url)).toBe(url)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('lets the last of a repeated parameter win, as pg does', () => {
|
|
49
|
+
expect(withExplicitSslMode(`${BASE}?sslmode=disable&sslmode=require`)).toBe(
|
|
50
|
+
`${BASE}?sslmode=disable&sslmode=verify-full`,
|
|
51
|
+
)
|
|
52
|
+
const disabledLast = `${BASE}?sslmode=require&sslmode=disable`
|
|
53
|
+
expect(withExplicitSslMode(disabledLast)).toBe(disabledLast)
|
|
54
|
+
|
|
55
|
+
const compatLast = `${BASE}?uselibpqcompat=false&sslmode=require&uselibpqcompat=true`
|
|
56
|
+
expect(withExplicitSslMode(compatLast)).toBe(compatLast)
|
|
57
|
+
expect(
|
|
58
|
+
withExplicitSslMode(`${BASE}?uselibpqcompat=true&sslmode=require&uselibpqcompat=false`),
|
|
59
|
+
).toBe(`${BASE}?uselibpqcompat=true&sslmode=verify-full&uselibpqcompat=false`)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('rewrites when the libpq flag is not the exact value pg honours', () => {
|
|
63
|
+
expect(withExplicitSslMode(`${BASE}?sslmode=require&uselibpqcompat=TRUE`)).toBe(
|
|
64
|
+
`${BASE}?sslmode=verify-full&uselibpqcompat=TRUE`,
|
|
65
|
+
)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('keeps a fragment out of the sslmode value', () => {
|
|
69
|
+
expect(withExplicitSslMode(`${BASE}?sslmode=require#frag`)).toBe(
|
|
70
|
+
`${BASE}?sslmode=verify-full#frag`,
|
|
71
|
+
)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('passes an unset connection string through', () => {
|
|
75
|
+
expect(withExplicitSslMode(undefined)).toBeUndefined()
|
|
76
|
+
expect(withExplicitSslMode('')).toBe('')
|
|
77
|
+
})
|
|
78
|
+
})
|
package/src/utils/database.ts
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'node:path'
|
|
|
3
3
|
import { pathToFileURL } from 'node:url'
|
|
4
4
|
|
|
5
5
|
import { importProjectTypescript } from './import-typescript.js'
|
|
6
|
+
import { withExplicitSslMode } from './pg-ssl-mode.js'
|
|
6
7
|
import { resolvePrismaClientLoadPlan } from './prisma-client-path.js'
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -115,7 +116,7 @@ async function createClientFromGenerated(generatedClient: string): Promise<any>
|
|
|
115
116
|
|
|
116
117
|
const { PrismaPg } = adapterModule as { PrismaPg: new (pool: unknown) => unknown }
|
|
117
118
|
const pg = (pgModule as { default?: typeof pgModule }).default ?? pgModule
|
|
118
|
-
const pool = new (pg as any).Pool({ connectionString: url })
|
|
119
|
+
const pool = new (pg as any).Pool({ connectionString: withExplicitSslMode(url) })
|
|
119
120
|
const adapter = new PrismaPg(pool)
|
|
120
121
|
return new PrismaClient({ adapter } as any)
|
|
121
122
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a Postgres connection string's TLS mode explicit.
|
|
3
|
+
*
|
|
4
|
+
* `pg` 8 treats `sslmode=prefer`, `require` and `verify-ca` as aliases
|
|
5
|
+
* for `verify-full`, and logs a SECURITY WARNING the first time it parses
|
|
6
|
+
* one, to say that `pg` 9 will weaken them to libpq's meaning (no
|
|
7
|
+
* certificate verification for `require`). Hosted providers hand out
|
|
8
|
+
* `sslmode=require` strings, so the warning shows up on every cold start.
|
|
9
|
+
*
|
|
10
|
+
* Rewriting those modes to `verify-full` asks for exactly what `pg` 8
|
|
11
|
+
* already does: the warning stops, and full certificate verification stays
|
|
12
|
+
* when `pg` 9 arrives.
|
|
13
|
+
*
|
|
14
|
+
* A string that opts in to libpq semantics with `uselibpqcompat=true` is
|
|
15
|
+
* left alone, as is one with no `sslmode`, `sslmode=disable` or
|
|
16
|
+
* `sslmode=no-verify`.
|
|
17
|
+
*
|
|
18
|
+
* The query is read the way `pg` reads it: names and values are
|
|
19
|
+
* percent-decoded, and the last of a repeated parameter wins. Only the one
|
|
20
|
+
* `sslmode` segment that takes effect is replaced; every other character,
|
|
21
|
+
* credentials included, is returned as it was given.
|
|
22
|
+
*
|
|
23
|
+
* A copy of `packages/cms-core/src/db/pg-ssl-mode.ts`. The CLI supports
|
|
24
|
+
* older `@prenta/core` versions, so it cannot import this from core. Keep
|
|
25
|
+
* the two in step.
|
|
26
|
+
*/
|
|
27
|
+
export function withExplicitSslMode<T extends string | undefined>(connectionString: T): T {
|
|
28
|
+
if (!connectionString) return connectionString
|
|
29
|
+
const queryStart = connectionString.indexOf('?')
|
|
30
|
+
if (queryStart === -1) return connectionString
|
|
31
|
+
|
|
32
|
+
const base = connectionString.slice(0, queryStart)
|
|
33
|
+
const afterQuestionMark = connectionString.slice(queryStart + 1)
|
|
34
|
+
const fragmentStart = afterQuestionMark.indexOf('#')
|
|
35
|
+
const query = fragmentStart === -1 ? afterQuestionMark : afterQuestionMark.slice(0, fragmentStart)
|
|
36
|
+
const fragment = fragmentStart === -1 ? '' : afterQuestionMark.slice(fragmentStart)
|
|
37
|
+
|
|
38
|
+
const params = new URLSearchParams(query)
|
|
39
|
+
// pg honours this flag only as the exact value "true".
|
|
40
|
+
if (params.getAll('uselibpqcompat').pop() === 'true') return connectionString
|
|
41
|
+
const mode = params.getAll('sslmode').pop()
|
|
42
|
+
if (mode !== 'prefer' && mode !== 'require' && mode !== 'verify-ca') return connectionString
|
|
43
|
+
|
|
44
|
+
const segments = query.split('&')
|
|
45
|
+
let effective = -1
|
|
46
|
+
segments.forEach((segment, index) => {
|
|
47
|
+
if (new URLSearchParams(segment).has('sslmode')) effective = index
|
|
48
|
+
})
|
|
49
|
+
if (effective === -1) return connectionString
|
|
50
|
+
segments[effective] = 'sslmode=verify-full'
|
|
51
|
+
return (base + '?' + segments.join('&') + fragment) as T
|
|
52
|
+
}
|