@prisma-next/cli 0.3.0-dev.16 → 0.3.0-dev.162
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/LICENSE +201 -0
- package/README.md +381 -128
- package/dist/cli-errors-BDCYR5ap.mjs +4 -0
- package/dist/cli-errors-Dzs7Oxz7.d.mts +3 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +1 -2671
- package/dist/cli.mjs +245 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-yYtotiSX.mjs +1063 -0
- package/dist/client-yYtotiSX.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts +7 -0
- package/dist/commands/contract-emit.d.mts.map +1 -0
- package/dist/commands/contract-emit.mjs +8 -0
- package/dist/commands/contract-infer.d.mts +7 -0
- package/dist/commands/contract-infer.d.mts.map +1 -0
- package/dist/commands/contract-infer.mjs +9 -0
- package/dist/commands/db-init.d.mts +7 -0
- package/dist/commands/db-init.d.mts.map +1 -0
- package/dist/commands/db-init.mjs +125 -0
- package/dist/commands/db-init.mjs.map +1 -0
- package/dist/commands/db-schema.d.mts +7 -0
- package/dist/commands/db-schema.d.mts.map +1 -0
- package/dist/commands/db-schema.mjs +55 -0
- package/dist/commands/db-schema.mjs.map +1 -0
- package/dist/commands/db-sign.d.mts +7 -0
- package/dist/commands/db-sign.d.mts.map +1 -0
- package/dist/commands/db-sign.mjs +136 -0
- package/dist/commands/db-sign.mjs.map +1 -0
- package/dist/commands/db-update.d.mts +7 -0
- package/dist/commands/db-update.d.mts.map +1 -0
- package/dist/commands/db-update.mjs +122 -0
- package/dist/commands/db-update.mjs.map +1 -0
- package/dist/commands/db-verify.d.mts +7 -0
- package/dist/commands/db-verify.d.mts.map +1 -0
- package/dist/commands/db-verify.mjs +322 -0
- package/dist/commands/db-verify.mjs.map +1 -0
- package/dist/commands/migration-apply.d.mts +36 -0
- package/dist/commands/migration-apply.d.mts.map +1 -0
- package/dist/commands/migration-apply.mjs +244 -0
- package/dist/commands/migration-apply.mjs.map +1 -0
- package/dist/commands/migration-new.d.mts +8 -0
- package/dist/commands/migration-new.d.mts.map +1 -0
- package/dist/commands/migration-new.mjs +151 -0
- package/dist/commands/migration-new.mjs.map +1 -0
- package/dist/commands/migration-plan.d.mts +47 -0
- package/dist/commands/migration-plan.d.mts.map +1 -0
- package/dist/commands/migration-plan.mjs +312 -0
- package/dist/commands/migration-plan.mjs.map +1 -0
- package/dist/commands/migration-ref.d.mts +43 -0
- package/dist/commands/migration-ref.d.mts.map +1 -0
- package/dist/commands/migration-ref.mjs +194 -0
- package/dist/commands/migration-ref.mjs.map +1 -0
- package/dist/commands/migration-show.d.mts +28 -0
- package/dist/commands/migration-show.d.mts.map +1 -0
- package/dist/commands/migration-show.mjs +139 -0
- package/dist/commands/migration-show.mjs.map +1 -0
- package/dist/commands/migration-status.d.mts +86 -0
- package/dist/commands/migration-status.d.mts.map +1 -0
- package/dist/commands/migration-status.mjs +8 -0
- package/dist/commands/migration-verify.d.mts +16 -0
- package/dist/commands/migration-verify.d.mts.map +1 -0
- package/dist/commands/migration-verify.mjs +109 -0
- package/dist/commands/migration-verify.mjs.map +1 -0
- package/dist/config-loader-C4VXKl8f.mjs +43 -0
- package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
- package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
- package/dist/config-loader.d.mts.map +1 -0
- package/dist/config-loader.mjs +3 -0
- package/dist/contract-emit-Bk_eEDKu.mjs +187 -0
- package/dist/contract-emit-Bk_eEDKu.mjs.map +1 -0
- package/dist/contract-infer-suMDmFSG.mjs +89 -0
- package/dist/contract-infer-suMDmFSG.mjs.map +1 -0
- package/dist/exports/config-types.d.mts +2 -0
- package/dist/exports/config-types.mjs +3 -0
- package/dist/exports/control-api.d.mts +624 -0
- package/dist/exports/control-api.d.mts.map +1 -0
- package/dist/exports/control-api.mjs +109 -0
- package/dist/exports/control-api.mjs.map +1 -0
- package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
- package/dist/exports/index.d.mts.map +1 -0
- package/dist/exports/index.mjs +141 -0
- package/dist/exports/index.mjs.map +1 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs +13 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs.map +1 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs +26 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs.map +1 -0
- package/dist/framework-components-BAsliT4V.mjs +59 -0
- package/dist/framework-components-BAsliT4V.mjs.map +1 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs +91 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs.map +1 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs +105 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs.map +1 -0
- package/dist/migration-status-BqfVmC0w.mjs +1582 -0
- package/dist/migration-status-BqfVmC0w.mjs.map +1 -0
- package/dist/migrations-Bv8oeiY_.mjs +173 -0
- package/dist/migrations-Bv8oeiY_.mjs.map +1 -0
- package/dist/progress-adapter-D4x8SbJa.mjs +43 -0
- package/dist/progress-adapter-D4x8SbJa.mjs.map +1 -0
- package/dist/terminal-ui-N5tR-ob5.mjs +967 -0
- package/dist/terminal-ui-N5tR-ob5.mjs.map +1 -0
- package/dist/verify-WARh5TjK.mjs +385 -0
- package/dist/verify-WARh5TjK.mjs.map +1 -0
- package/package.json +88 -42
- package/src/cli.ts +113 -58
- package/src/commands/contract-emit.ts +237 -144
- package/src/commands/contract-infer-paths.ts +32 -0
- package/src/commands/contract-infer.ts +143 -0
- package/src/commands/db-init.ts +97 -219
- package/src/commands/db-schema.ts +77 -0
- package/src/commands/db-sign.ts +208 -229
- package/src/commands/db-update.ts +236 -0
- package/src/commands/db-verify.ts +504 -184
- package/src/commands/inspect-live-schema.ts +170 -0
- package/src/commands/migration-apply.ts +427 -0
- package/src/commands/migration-new.ts +260 -0
- package/src/commands/migration-plan.ts +519 -0
- package/src/commands/migration-ref.ts +305 -0
- package/src/commands/migration-show.ts +246 -0
- package/src/commands/migration-status.ts +864 -0
- package/src/commands/migration-verify.ts +180 -0
- package/src/config-loader.ts +13 -3
- package/src/control-api/client.ts +424 -72
- package/src/control-api/contract-enrichment.ts +119 -0
- package/src/control-api/errors.ts +9 -0
- package/src/control-api/operations/contract-emit.ts +174 -0
- package/src/control-api/operations/db-init.ts +53 -49
- package/src/control-api/operations/db-update.ts +220 -0
- package/src/control-api/operations/extract-operation-statements.ts +14 -0
- package/src/control-api/operations/extract-sql-ddl.ts +47 -0
- package/src/control-api/operations/migration-apply.ts +191 -0
- package/src/control-api/operations/migration-helpers.ts +49 -0
- package/src/control-api/types.ts +388 -18
- package/src/exports/config-types.ts +4 -3
- package/src/exports/control-api.ts +21 -2
- package/src/load-ts-contract.ts +30 -19
- package/src/utils/cli-errors.ts +14 -8
- package/src/utils/command-helpers.ts +302 -3
- package/src/utils/formatters/emit.ts +67 -0
- package/src/utils/formatters/errors.ts +82 -0
- package/src/utils/formatters/graph-migration-mapper.ts +240 -0
- package/src/utils/formatters/graph-render.ts +1323 -0
- package/src/utils/formatters/graph-types.ts +120 -0
- package/src/utils/formatters/help.ts +380 -0
- package/src/utils/formatters/helpers.ts +28 -0
- package/src/utils/formatters/migrations.ts +346 -0
- package/src/utils/formatters/styled.ts +212 -0
- package/src/utils/formatters/verify.ts +621 -0
- package/src/utils/framework-components.ts +13 -10
- package/src/utils/global-flags.ts +41 -23
- package/src/utils/migration-command-scaffold.ts +184 -0
- package/src/utils/migration-types.ts +12 -0
- package/src/utils/progress-adapter.ts +18 -29
- package/src/utils/result-handler.ts +12 -13
- package/src/utils/shutdown.ts +92 -0
- package/src/utils/suggest-command.ts +31 -0
- package/src/utils/terminal-ui.ts +276 -0
- package/dist/chunk-5MPKZYVI.js +0 -47
- package/dist/chunk-5MPKZYVI.js.map +0 -1
- package/dist/chunk-6EPKRATC.js +0 -91
- package/dist/chunk-6EPKRATC.js.map +0 -1
- package/dist/chunk-74IELXRA.js +0 -371
- package/dist/chunk-74IELXRA.js.map +0 -1
- package/dist/chunk-HWYQOCAJ.js +0 -47
- package/dist/chunk-HWYQOCAJ.js.map +0 -1
- package/dist/chunk-U6QI3AZ3.js +0 -133
- package/dist/chunk-U6QI3AZ3.js.map +0 -1
- package/dist/chunk-VI2YETW7.js +0 -38
- package/dist/chunk-VI2YETW7.js.map +0 -1
- package/dist/chunk-ZG5T6OB5.js +0 -923
- package/dist/chunk-ZG5T6OB5.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/contract-emit.d.ts +0 -3
- package/dist/commands/contract-emit.d.ts.map +0 -1
- package/dist/commands/contract-emit.js +0 -11
- package/dist/commands/contract-emit.js.map +0 -1
- package/dist/commands/db-init.d.ts +0 -3
- package/dist/commands/db-init.d.ts.map +0 -1
- package/dist/commands/db-init.js +0 -302
- package/dist/commands/db-init.js.map +0 -1
- package/dist/commands/db-introspect.d.ts +0 -3
- package/dist/commands/db-introspect.d.ts.map +0 -1
- package/dist/commands/db-introspect.js +0 -185
- package/dist/commands/db-introspect.js.map +0 -1
- package/dist/commands/db-schema-verify.d.ts +0 -3
- package/dist/commands/db-schema-verify.d.ts.map +0 -1
- package/dist/commands/db-schema-verify.js +0 -163
- package/dist/commands/db-schema-verify.js.map +0 -1
- package/dist/commands/db-sign.d.ts +0 -3
- package/dist/commands/db-sign.d.ts.map +0 -1
- package/dist/commands/db-sign.js +0 -198
- package/dist/commands/db-sign.js.map +0 -1
- package/dist/commands/db-verify.d.ts +0 -3
- package/dist/commands/db-verify.d.ts.map +0 -1
- package/dist/commands/db-verify.js +0 -172
- package/dist/commands/db-verify.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -7
- package/dist/config-loader.js.map +0 -1
- package/dist/control-api/client.d.ts +0 -13
- package/dist/control-api/client.d.ts.map +0 -1
- package/dist/control-api/operations/db-init.d.ts +0 -29
- package/dist/control-api/operations/db-init.d.ts.map +0 -1
- package/dist/control-api/types.d.ts +0 -256
- package/dist/control-api/types.d.ts.map +0 -1
- package/dist/exports/config-types.d.ts +0 -3
- package/dist/exports/config-types.d.ts.map +0 -1
- package/dist/exports/config-types.js +0 -6
- package/dist/exports/config-types.js.map +0 -1
- package/dist/exports/control-api.d.ts +0 -13
- package/dist/exports/control-api.d.ts.map +0 -1
- package/dist/exports/control-api.js +0 -9
- package/dist/exports/control-api.js.map +0 -1
- package/dist/exports/index.d.ts +0 -4
- package/dist/exports/index.d.ts.map +0 -1
- package/dist/exports/index.js +0 -177
- package/dist/exports/index.js.map +0 -1
- package/dist/load-ts-contract.d.ts.map +0 -1
- package/dist/utils/action.d.ts +0 -16
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/cli-errors.d.ts +0 -7
- package/dist/utils/cli-errors.d.ts.map +0 -1
- package/dist/utils/command-helpers.d.ts +0 -12
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/framework-components.d.ts +0 -70
- package/dist/utils/framework-components.d.ts.map +0 -1
- package/dist/utils/global-flags.d.ts +0 -25
- package/dist/utils/global-flags.d.ts.map +0 -1
- package/dist/utils/output.d.ts +0 -142
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/progress-adapter.d.ts +0 -26
- package/dist/utils/progress-adapter.d.ts.map +0 -1
- package/dist/utils/result-handler.d.ts +0 -15
- package/dist/utils/result-handler.d.ts.map +0 -1
- package/dist/utils/spinner.d.ts +0 -29
- package/dist/utils/spinner.d.ts.map +0 -1
- package/src/commands/db-introspect.ts +0 -254
- package/src/commands/db-schema-verify.ts +0 -231
- package/src/utils/action.ts +0 -43
- package/src/utils/output.ts +0 -1471
- package/src/utils/spinner.ts +0 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/cli",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.162",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -11,83 +11,129 @@
|
|
|
11
11
|
"prisma-next": "./dist/cli.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@clack/prompts": "^1.1.0",
|
|
15
|
+
"@dagrejs/dagre": "^3.0.0",
|
|
14
16
|
"arktype": "^2.0.0",
|
|
15
17
|
"c12": "^3.3.2",
|
|
18
|
+
"closest-match": "^1.3.3",
|
|
16
19
|
"colorette": "^2.0.20",
|
|
17
20
|
"commander": "^12.0.0",
|
|
18
|
-
"esbuild": "^0.
|
|
19
|
-
"
|
|
20
|
-
"string-width": "^
|
|
21
|
+
"esbuild": "^0.25.11",
|
|
22
|
+
"pathe": "^2.0.3",
|
|
23
|
+
"string-width": "^8.2.0",
|
|
21
24
|
"strip-ansi": "^7.1.2",
|
|
22
|
-
"wrap-ansi": "^
|
|
23
|
-
"@prisma-next/
|
|
24
|
-
"@prisma-next/
|
|
25
|
-
"@prisma-next/emitter": "0.3.0-dev.
|
|
26
|
-
"@prisma-next/
|
|
25
|
+
"wrap-ansi": "^10.0.0",
|
|
26
|
+
"@prisma-next/config": "0.3.0-dev.162",
|
|
27
|
+
"@prisma-next/contract": "0.3.0-dev.162",
|
|
28
|
+
"@prisma-next/emitter": "0.3.0-dev.162",
|
|
29
|
+
"@prisma-next/errors": "0.3.0-dev.162",
|
|
30
|
+
"@prisma-next/framework-components": "0.3.0-dev.162",
|
|
31
|
+
"@prisma-next/migration-tools": "0.3.0-dev.162",
|
|
32
|
+
"@prisma-next/psl-printer": "0.3.0-dev.162",
|
|
33
|
+
"@prisma-next/utils": "0.3.0-dev.162"
|
|
27
34
|
},
|
|
28
35
|
"devDependencies": {
|
|
29
36
|
"@types/node": "24.10.4",
|
|
30
|
-
"
|
|
31
|
-
"tsup": "8.5.1",
|
|
37
|
+
"tsdown": "0.18.4",
|
|
32
38
|
"typescript": "5.9.3",
|
|
33
|
-
"vitest": "4.0.
|
|
34
|
-
"@prisma-next/sql-contract": "0.3.0-dev.
|
|
35
|
-
"@prisma-next/sql-contract-emitter": "0.3.0-dev.
|
|
36
|
-
"@prisma-next/sql-
|
|
37
|
-
"@prisma-next/sql-
|
|
38
|
-
"@prisma-next/sql-runtime": "0.3.0-dev.
|
|
39
|
-
"@prisma-next/test-utils": "0.0.1"
|
|
39
|
+
"vitest": "4.0.17",
|
|
40
|
+
"@prisma-next/sql-contract": "0.3.0-dev.162",
|
|
41
|
+
"@prisma-next/sql-contract-emitter": "0.3.0-dev.162",
|
|
42
|
+
"@prisma-next/sql-operations": "0.3.0-dev.162",
|
|
43
|
+
"@prisma-next/sql-contract-ts": "0.3.0-dev.162",
|
|
44
|
+
"@prisma-next/sql-runtime": "0.3.0-dev.162",
|
|
45
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
46
|
+
"@prisma-next/tsdown": "0.0.0",
|
|
47
|
+
"@prisma-next/tsconfig": "0.0.0"
|
|
40
48
|
},
|
|
41
49
|
"exports": {
|
|
42
50
|
".": {
|
|
43
|
-
"types": "./dist/exports/index.d.
|
|
44
|
-
"import": "./dist/exports/index.
|
|
51
|
+
"types": "./dist/exports/index.d.mts",
|
|
52
|
+
"import": "./dist/exports/index.mjs"
|
|
45
53
|
},
|
|
46
54
|
"./config-types": {
|
|
47
|
-
"types": "./dist/exports/config-types.d.
|
|
48
|
-
"import": "./dist/exports/config-types.
|
|
55
|
+
"types": "./dist/exports/config-types.d.mts",
|
|
56
|
+
"import": "./dist/exports/config-types.mjs"
|
|
49
57
|
},
|
|
50
58
|
"./commands/db-init": {
|
|
51
|
-
"types": "./dist/commands/db-init.d.
|
|
52
|
-
"import": "./dist/commands/db-init.
|
|
59
|
+
"types": "./dist/commands/db-init.d.mts",
|
|
60
|
+
"import": "./dist/commands/db-init.mjs"
|
|
53
61
|
},
|
|
54
|
-
"./commands/db-
|
|
55
|
-
"types": "./dist/commands/db-
|
|
56
|
-
"import": "./dist/commands/db-
|
|
62
|
+
"./commands/db-update": {
|
|
63
|
+
"types": "./dist/commands/db-update.d.mts",
|
|
64
|
+
"import": "./dist/commands/db-update.mjs"
|
|
57
65
|
},
|
|
58
|
-
"./commands/db-schema
|
|
59
|
-
"types": "./dist/commands/db-schema
|
|
60
|
-
"import": "./dist/commands/db-schema
|
|
66
|
+
"./commands/db-schema": {
|
|
67
|
+
"types": "./dist/commands/db-schema.d.mts",
|
|
68
|
+
"import": "./dist/commands/db-schema.mjs"
|
|
61
69
|
},
|
|
62
70
|
"./commands/db-sign": {
|
|
63
|
-
"types": "./dist/commands/db-sign.d.
|
|
64
|
-
"import": "./dist/commands/db-sign.
|
|
71
|
+
"types": "./dist/commands/db-sign.d.mts",
|
|
72
|
+
"import": "./dist/commands/db-sign.mjs"
|
|
65
73
|
},
|
|
66
74
|
"./commands/db-verify": {
|
|
67
|
-
"types": "./dist/commands/db-verify.d.
|
|
68
|
-
"import": "./dist/commands/db-verify.
|
|
75
|
+
"types": "./dist/commands/db-verify.d.mts",
|
|
76
|
+
"import": "./dist/commands/db-verify.mjs"
|
|
69
77
|
},
|
|
70
78
|
"./commands/contract-emit": {
|
|
71
|
-
"types": "./dist/commands/contract-emit.d.
|
|
72
|
-
"import": "./dist/commands/contract-emit.
|
|
79
|
+
"types": "./dist/commands/contract-emit.d.mts",
|
|
80
|
+
"import": "./dist/commands/contract-emit.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./commands/contract-infer": {
|
|
83
|
+
"types": "./dist/commands/contract-infer.d.mts",
|
|
84
|
+
"import": "./dist/commands/contract-infer.mjs"
|
|
85
|
+
},
|
|
86
|
+
"./commands/migration-new": {
|
|
87
|
+
"types": "./dist/commands/migration-new.d.mts",
|
|
88
|
+
"import": "./dist/commands/migration-new.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./commands/migration-plan": {
|
|
91
|
+
"types": "./dist/commands/migration-plan.d.mts",
|
|
92
|
+
"import": "./dist/commands/migration-plan.mjs"
|
|
93
|
+
},
|
|
94
|
+
"./commands/migration-show": {
|
|
95
|
+
"types": "./dist/commands/migration-show.d.mts",
|
|
96
|
+
"import": "./dist/commands/migration-show.mjs"
|
|
97
|
+
},
|
|
98
|
+
"./commands/migration-status": {
|
|
99
|
+
"types": "./dist/commands/migration-status.d.mts",
|
|
100
|
+
"import": "./dist/commands/migration-status.mjs"
|
|
101
|
+
},
|
|
102
|
+
"./commands/migration-verify": {
|
|
103
|
+
"types": "./dist/commands/migration-verify.d.mts",
|
|
104
|
+
"import": "./dist/commands/migration-verify.mjs"
|
|
105
|
+
},
|
|
106
|
+
"./commands/migration-apply": {
|
|
107
|
+
"types": "./dist/commands/migration-apply.d.mts",
|
|
108
|
+
"import": "./dist/commands/migration-apply.mjs"
|
|
109
|
+
},
|
|
110
|
+
"./commands/migration-ref": {
|
|
111
|
+
"types": "./dist/commands/migration-ref.d.mts",
|
|
112
|
+
"import": "./dist/commands/migration-ref.mjs"
|
|
73
113
|
},
|
|
74
114
|
"./config-loader": {
|
|
75
|
-
"types": "./dist/config-loader.d.
|
|
76
|
-
"import": "./dist/config-loader.
|
|
115
|
+
"types": "./dist/config-loader.d.mts",
|
|
116
|
+
"import": "./dist/config-loader.mjs"
|
|
77
117
|
},
|
|
78
118
|
"./control-api": {
|
|
79
|
-
"types": "./dist/exports/control-api.d.
|
|
80
|
-
"import": "./dist/exports/control-api.
|
|
119
|
+
"types": "./dist/exports/control-api.d.mts",
|
|
120
|
+
"import": "./dist/exports/control-api.mjs"
|
|
81
121
|
}
|
|
82
122
|
},
|
|
123
|
+
"repository": {
|
|
124
|
+
"type": "git",
|
|
125
|
+
"url": "https://github.com/prisma/prisma-next.git",
|
|
126
|
+
"directory": "packages/1-framework/3-tooling/cli"
|
|
127
|
+
},
|
|
83
128
|
"scripts": {
|
|
84
|
-
"build": "
|
|
129
|
+
"build": "tsdown && node ./scripts/write-cli-js-compat.mjs",
|
|
85
130
|
"test": "vitest run",
|
|
86
131
|
"test:coverage": "vitest run --coverage",
|
|
87
132
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
88
133
|
"lint": "biome check . --error-on-warnings",
|
|
89
134
|
"lint:fix": "biome check --write .",
|
|
90
135
|
"lint:fix:unsafe": "biome check --write --unsafe .",
|
|
91
|
-
"
|
|
136
|
+
"record": "tsx scripts/record.ts",
|
|
137
|
+
"clean": "rm -rf dist dist-tsc dist-tsc-prod coverage .tmp-output"
|
|
92
138
|
}
|
|
93
139
|
}
|
package/src/cli.ts
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { createContractEmitCommand } from './commands/contract-emit';
|
|
3
|
+
import { createContractInferCommand } from './commands/contract-infer';
|
|
4
|
+
import { installShutdownHandlers } from './utils/shutdown';
|
|
5
|
+
|
|
6
|
+
// Install SIGINT/SIGTERM handlers before anything else
|
|
7
|
+
installShutdownHandlers();
|
|
8
|
+
|
|
3
9
|
import { createDbInitCommand } from './commands/db-init';
|
|
4
|
-
import {
|
|
5
|
-
import { createDbSchemaVerifyCommand } from './commands/db-schema-verify';
|
|
10
|
+
import { createDbSchemaCommand } from './commands/db-schema';
|
|
6
11
|
import { createDbSignCommand } from './commands/db-sign';
|
|
12
|
+
import { createDbUpdateCommand } from './commands/db-update';
|
|
7
13
|
import { createDbVerifyCommand } from './commands/db-verify';
|
|
14
|
+
import { createMigrationApplyCommand } from './commands/migration-apply';
|
|
15
|
+
import { createMigrationNewCommand } from './commands/migration-new';
|
|
16
|
+
import { createMigrationPlanCommand } from './commands/migration-plan';
|
|
17
|
+
import { createMigrationRefCommand } from './commands/migration-ref';
|
|
18
|
+
import { createMigrationShowCommand } from './commands/migration-show';
|
|
19
|
+
import { createMigrationStatusCommand } from './commands/migration-status';
|
|
20
|
+
import { createMigrationVerifyCommand } from './commands/migration-verify';
|
|
8
21
|
import { setCommandDescriptions } from './utils/command-helpers';
|
|
22
|
+
import { formatCommandHelp, formatRootHelp } from './utils/formatters/help';
|
|
9
23
|
import { parseGlobalFlags } from './utils/global-flags';
|
|
10
|
-
import {
|
|
24
|
+
import { suggestCommands } from './utils/suggest-command';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Formats the "Did you mean ...?" hint for an unknown command.
|
|
28
|
+
*/
|
|
29
|
+
function formatSuggestion(input: string, candidates: readonly string[]): string {
|
|
30
|
+
const suggestions = suggestCommands(
|
|
31
|
+
input,
|
|
32
|
+
candidates.map((c) => c),
|
|
33
|
+
);
|
|
34
|
+
if (suggestions.length === 0) return '';
|
|
35
|
+
if (suggestions.length === 1) return `\nDid you mean ${suggestions[0]}?\n`;
|
|
36
|
+
return `\nDid you mean one of these?\n${suggestions.map((s) => ` ${s}`).join('\n')}\n`;
|
|
37
|
+
}
|
|
11
38
|
|
|
12
39
|
const program = new Command();
|
|
13
40
|
|
|
@@ -43,14 +70,11 @@ program.configureHelp({
|
|
|
43
70
|
// Commands handle structured errors themselves via process.exit()
|
|
44
71
|
program.exitOverride((err) => {
|
|
45
72
|
if (err) {
|
|
46
|
-
// Help requests are not errors - allow Commander to output help and exit normally
|
|
47
|
-
// Commander throws errors with codes like 'commander.help', 'commander.helpDisplayed', or 'outputHelp'
|
|
48
73
|
const errorCode = (err as { code?: string }).code;
|
|
49
74
|
const errorMessage = String(err.message ?? '');
|
|
50
75
|
const errorName = err.name ?? '';
|
|
51
76
|
|
|
52
|
-
//
|
|
53
|
-
// Commander.js uses code 'commander.unknownCommand' or error message contains 'unknown command'
|
|
77
|
+
// Unknown command/argument → exit 2 (CLI usage error)
|
|
54
78
|
const isUnknownCommandError =
|
|
55
79
|
errorCode === 'commander.unknownCommand' ||
|
|
56
80
|
errorCode === 'commander.unknownArgument' ||
|
|
@@ -58,40 +82,34 @@ program.exitOverride((err) => {
|
|
|
58
82
|
(errorMessage.includes('unknown command') || errorMessage.includes('unknown argument')));
|
|
59
83
|
if (isUnknownCommandError) {
|
|
60
84
|
const flags = parseGlobalFlags({});
|
|
61
|
-
// Extract the command/subcommand name from the error message
|
|
62
|
-
// Error message format: "unknown command 'command-name'"
|
|
63
85
|
const match = errorMessage.match(/unknown command ['"]([^'"]+)['"]/);
|
|
64
86
|
const commandName = match ? match[1] : process.argv[3] || process.argv[2] || 'unknown';
|
|
65
87
|
|
|
66
|
-
// Determine which command context we're in
|
|
67
|
-
// Check if the first argument is a recognized parent command
|
|
68
88
|
const firstArg = process.argv[2];
|
|
69
89
|
const parentCommand = firstArg
|
|
70
90
|
? program.commands.find((cmd) => cmd.name() === firstArg)
|
|
71
91
|
: undefined;
|
|
72
92
|
|
|
73
93
|
if (parentCommand && commandName !== firstArg) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
console.error('');
|
|
94
|
+
const subNames = parentCommand.commands.map((c) => c.name());
|
|
95
|
+
process.stderr.write(
|
|
96
|
+
`Unknown command: ${commandName}${formatSuggestion(commandName!, subNames)}\n`,
|
|
97
|
+
);
|
|
79
98
|
const helpText = formatCommandHelp({ command: parentCommand, flags });
|
|
80
|
-
|
|
81
|
-
console.log(helpText);
|
|
99
|
+
process.stderr.write(`${helpText}\n`);
|
|
82
100
|
} else {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.error('');
|
|
101
|
+
const topNames = program.commands.map((c) => c.name());
|
|
102
|
+
process.stderr.write(
|
|
103
|
+
`Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\n`,
|
|
104
|
+
);
|
|
88
105
|
const helpText = formatRootHelp({ program, flags });
|
|
89
|
-
|
|
90
|
-
console.log(helpText);
|
|
106
|
+
process.stderr.write(`${helpText}\n`);
|
|
91
107
|
}
|
|
92
|
-
process.exit(
|
|
108
|
+
process.exit(2);
|
|
93
109
|
return;
|
|
94
110
|
}
|
|
111
|
+
|
|
112
|
+
// Help requests → exit 0
|
|
95
113
|
const isHelpError =
|
|
96
114
|
errorCode === 'commander.help' ||
|
|
97
115
|
errorCode === 'commander.helpDisplayed' ||
|
|
@@ -103,25 +121,22 @@ program.exitOverride((err) => {
|
|
|
103
121
|
process.exit(0);
|
|
104
122
|
return;
|
|
105
123
|
}
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
// or when a command with subcommands is called without a subcommand
|
|
124
|
+
|
|
125
|
+
// Missing required arguments → exit 2 (CLI usage error)
|
|
109
126
|
const isMissingArgumentError =
|
|
110
127
|
errorCode === 'commander.missingArgument' ||
|
|
111
128
|
errorCode === 'commander.missingMandatoryOptionValue' ||
|
|
112
129
|
(errorName === 'CommanderError' &&
|
|
113
130
|
(errorMessage.includes('missing') || errorMessage.includes('required')));
|
|
114
131
|
if (isMissingArgumentError) {
|
|
115
|
-
|
|
116
|
-
process.exit(0);
|
|
132
|
+
process.exit(2);
|
|
117
133
|
return;
|
|
118
134
|
}
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
135
|
+
|
|
136
|
+
// Unhandled error → exit 1
|
|
137
|
+
process.stderr.write(`Unhandled error: ${err.message}\n`);
|
|
122
138
|
if (err.stack) {
|
|
123
|
-
|
|
124
|
-
console.error(err.stack);
|
|
139
|
+
process.stderr.write(`${err.stack}\n`);
|
|
125
140
|
}
|
|
126
141
|
process.exit(1);
|
|
127
142
|
}
|
|
@@ -148,6 +163,10 @@ contractCommand.configureHelp({
|
|
|
148
163
|
const contractEmitCommand = createContractEmitCommand();
|
|
149
164
|
contractCommand.addCommand(contractEmitCommand);
|
|
150
165
|
|
|
166
|
+
// Add infer subcommand to contract
|
|
167
|
+
const contractInferCommand = createContractInferCommand();
|
|
168
|
+
contractCommand.addCommand(contractInferCommand);
|
|
169
|
+
|
|
151
170
|
// Register contract command
|
|
152
171
|
program.addCommand(contractCommand);
|
|
153
172
|
|
|
@@ -175,13 +194,13 @@ dbCommand.addCommand(dbVerifyCommand);
|
|
|
175
194
|
const dbInitCommand = createDbInitCommand();
|
|
176
195
|
dbCommand.addCommand(dbInitCommand);
|
|
177
196
|
|
|
178
|
-
// Add
|
|
179
|
-
const
|
|
180
|
-
dbCommand.addCommand(
|
|
197
|
+
// Add update subcommand to db
|
|
198
|
+
const dbUpdateCommand = createDbUpdateCommand();
|
|
199
|
+
dbCommand.addCommand(dbUpdateCommand);
|
|
181
200
|
|
|
182
|
-
// Add schema
|
|
183
|
-
const
|
|
184
|
-
dbCommand.addCommand(
|
|
201
|
+
// Add schema subcommand to db
|
|
202
|
+
const dbSchemaCommand = createDbSchemaCommand();
|
|
203
|
+
dbCommand.addCommand(dbSchemaCommand);
|
|
185
204
|
|
|
186
205
|
// Add sign subcommand to db
|
|
187
206
|
const dbSignCommand = createDbSignCommand();
|
|
@@ -190,6 +209,45 @@ dbCommand.addCommand(dbSignCommand);
|
|
|
190
209
|
// Register db command
|
|
191
210
|
program.addCommand(dbCommand);
|
|
192
211
|
|
|
212
|
+
// Register migration subcommand
|
|
213
|
+
const migrationCommand = new Command('migration');
|
|
214
|
+
setCommandDescriptions(
|
|
215
|
+
migrationCommand,
|
|
216
|
+
'On-disk migration management commands',
|
|
217
|
+
'Plan, apply, verify, and scaffold on-disk migration packages. Migrations are\n' +
|
|
218
|
+
'contract-to-contract edges stored as versioned directories under migrations/.',
|
|
219
|
+
);
|
|
220
|
+
migrationCommand.configureHelp({
|
|
221
|
+
formatHelp: (cmd) => {
|
|
222
|
+
const flags = parseGlobalFlags({});
|
|
223
|
+
return formatCommandHelp({ command: cmd, flags });
|
|
224
|
+
},
|
|
225
|
+
subcommandDescription: () => '',
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const migrationPlanCommand = createMigrationPlanCommand();
|
|
229
|
+
migrationCommand.addCommand(migrationPlanCommand);
|
|
230
|
+
|
|
231
|
+
const migrationNewCommand = createMigrationNewCommand();
|
|
232
|
+
migrationCommand.addCommand(migrationNewCommand);
|
|
233
|
+
|
|
234
|
+
const migrationShowCommand = createMigrationShowCommand();
|
|
235
|
+
migrationCommand.addCommand(migrationShowCommand);
|
|
236
|
+
|
|
237
|
+
const migrationStatusCommand = createMigrationStatusCommand();
|
|
238
|
+
migrationCommand.addCommand(migrationStatusCommand);
|
|
239
|
+
|
|
240
|
+
const migrationVerifyCommand = createMigrationVerifyCommand();
|
|
241
|
+
migrationCommand.addCommand(migrationVerifyCommand);
|
|
242
|
+
|
|
243
|
+
const migrationApplyCommand = createMigrationApplyCommand();
|
|
244
|
+
migrationCommand.addCommand(migrationApplyCommand);
|
|
245
|
+
|
|
246
|
+
const migrationRefCommand = createMigrationRefCommand();
|
|
247
|
+
migrationCommand.addCommand(migrationRefCommand);
|
|
248
|
+
|
|
249
|
+
program.addCommand(migrationCommand);
|
|
250
|
+
|
|
193
251
|
// Create help command
|
|
194
252
|
const helpCommand = new Command('help')
|
|
195
253
|
.description('Show usage instructions')
|
|
@@ -202,8 +260,8 @@ const helpCommand = new Command('help')
|
|
|
202
260
|
.action(() => {
|
|
203
261
|
const flags = parseGlobalFlags({});
|
|
204
262
|
const helpText = formatRootHelp({ program, flags });
|
|
205
|
-
//
|
|
206
|
-
|
|
263
|
+
// Help is decoration → stderr
|
|
264
|
+
process.stderr.write(`${helpText}\n`);
|
|
207
265
|
process.exit(0);
|
|
208
266
|
});
|
|
209
267
|
|
|
@@ -213,8 +271,7 @@ program.addCommand(helpCommand);
|
|
|
213
271
|
program.action(() => {
|
|
214
272
|
const flags = parseGlobalFlags({});
|
|
215
273
|
const helpText = formatRootHelp({ program, flags });
|
|
216
|
-
|
|
217
|
-
console.log(helpText);
|
|
274
|
+
process.stderr.write(`${helpText}\n`);
|
|
218
275
|
process.exit(0);
|
|
219
276
|
});
|
|
220
277
|
|
|
@@ -225,8 +282,8 @@ if (args.length > 0) {
|
|
|
225
282
|
const commandName = args[0];
|
|
226
283
|
// Handle version option explicitly since we suppress default output
|
|
227
284
|
if (commandName === '--version' || commandName === '-V') {
|
|
228
|
-
//
|
|
229
|
-
|
|
285
|
+
// Version is data → stdout
|
|
286
|
+
process.stdout.write(`${program.version()}\n`);
|
|
230
287
|
process.exit(0);
|
|
231
288
|
}
|
|
232
289
|
// Skip command check for global options like --help, -h
|
|
@@ -236,22 +293,20 @@ if (args.length > 0) {
|
|
|
236
293
|
const command = program.commands.find((cmd) => cmd.name() === commandName);
|
|
237
294
|
|
|
238
295
|
if (!command) {
|
|
239
|
-
// Unrecognized command
|
|
296
|
+
// Unrecognized command → exit 2 (CLI usage error)
|
|
240
297
|
const flags = parseGlobalFlags({});
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
298
|
+
const topNames = program.commands.map((c) => c.name());
|
|
299
|
+
process.stderr.write(
|
|
300
|
+
`Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\n`,
|
|
301
|
+
);
|
|
245
302
|
const helpText = formatRootHelp({ program, flags });
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
process.exit(1);
|
|
303
|
+
process.stderr.write(`${helpText}\n`);
|
|
304
|
+
process.exit(2);
|
|
249
305
|
} else if (command.commands.length > 0 && args.length === 1) {
|
|
250
306
|
// Parent command called with no subcommand - show help and exit with 0
|
|
251
307
|
const flags = parseGlobalFlags({});
|
|
252
308
|
const helpText = formatCommandHelp({ command, flags });
|
|
253
|
-
|
|
254
|
-
console.log(helpText);
|
|
309
|
+
process.stderr.write(`${helpText}\n`);
|
|
255
310
|
process.exit(0);
|
|
256
311
|
}
|
|
257
312
|
}
|