@prisma-next/cli 0.11.0-dev.7 → 0.11.0-dev.70
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/README.md +13 -9
- package/dist/cli.mjs +10 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-oXO2WCPD.mjs → client-6WehTnUh.mjs} +72 -60
- package/dist/client-6WehTnUh.mjs.map +1 -0
- package/dist/{command-helpers-DtavI0wJ.mjs → command-helpers-CoceqqMl.mjs} +642 -45
- package/dist/command-helpers-CoceqqMl.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +32 -7
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +3 -4
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +12 -10
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +41 -11
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +6 -2
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +75 -40
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +4 -3
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +1 -280
- package/dist/commands/migration-graph.d.mts +13 -2
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +2 -137
- package/dist/commands/migration-list.d.mts +67 -4
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -103
- package/dist/commands/migration-log.d.mts +10 -1
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +10 -15
- package/dist/commands/migration-log.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +32 -38
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +3 -2
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +4 -55
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +61 -153
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +12 -49
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +85 -81
- package/dist/commands/migration-status.mjs.map +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +38 -10
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/contract-at-errors-Bhf2jnkp.mjs +42 -0
- package/dist/contract-at-errors-Bhf2jnkp.mjs.map +1 -0
- package/dist/{contract-emit-CmsklifJ.mjs → contract-emit-C47r1loe.mjs} +4 -6
- package/dist/{contract-emit-CmsklifJ.mjs.map → contract-emit-C47r1loe.mjs.map} +1 -1
- package/dist/{contract-emit-o-8VmdQX.mjs → contract-emit-DxEfEc-M.mjs} +21 -7
- package/dist/{contract-emit-o-8VmdQX.mjs.map → contract-emit-DxEfEc-M.mjs.map} +1 -1
- package/dist/{contract-enrichment-Dani0mMW.mjs → contract-enrichment-a0V5Y_mL.mjs} +4 -25
- package/dist/contract-enrichment-a0V5Y_mL.mjs.map +1 -0
- package/dist/{contract-infer-pKkiCt7C.mjs → contract-infer-BLiomU8g.mjs} +3 -4
- package/dist/{contract-infer-pKkiCt7C.mjs.map → contract-infer-BLiomU8g.mjs.map} +1 -1
- package/dist/contract-space-aggregate-loader-lafgkTwG.mjs +247 -0
- package/dist/contract-space-aggregate-loader-lafgkTwG.mjs.map +1 -0
- package/dist/{db-verify-AoIUriL4.mjs → db-verify-D44Qj3w9.mjs} +5 -7
- package/dist/{db-verify-AoIUriL4.mjs.map → db-verify-D44Qj3w9.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +3 -3
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/extension-pack-inputs-IDvjRCi3.mjs +62 -0
- package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +1 -0
- package/dist/{framework-components-65gOHkHB.mjs → framework-components-R_O3y5IW.mjs} +2 -2
- package/dist/{framework-components-65gOHkHB.mjs.map → framework-components-R_O3y5IW.mjs.map} +1 -1
- package/dist/global-flags-DG4uY5tV.d.mts +34 -0
- package/dist/global-flags-DG4uY5tV.d.mts.map +1 -0
- package/dist/{graph-render-DJVv0_uf.mjs → graph-render-rFAqZujX.mjs} +2 -2
- package/dist/{graph-render-DJVv0_uf.mjs.map → graph-render-rFAqZujX.mjs.map} +1 -1
- package/dist/{init-Db5Itt5r.mjs → init-DE-phHWK.mjs} +4 -5
- package/dist/{init-Db5Itt5r.mjs.map → init-DE-phHWK.mjs.map} +1 -1
- package/dist/{inspect-live-schema-LeWvkZVz.mjs → inspect-live-schema-Ccnmg5bz.mjs} +4 -5
- package/dist/{inspect-live-schema-LeWvkZVz.mjs.map → inspect-live-schema-Ccnmg5bz.mjs.map} +1 -1
- package/dist/migration-check-CKfQlAWR.mjs +341 -0
- package/dist/migration-check-CKfQlAWR.mjs.map +1 -0
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +4 -4
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-BtkunvFQ.mjs → migration-command-scaffold-C_KuV0Gm.mjs} +4 -5
- package/dist/{migration-command-scaffold-BtkunvFQ.mjs.map → migration-command-scaffold-C_KuV0Gm.mjs.map} +1 -1
- package/dist/migration-graph-kPluRdF2.mjs +1232 -0
- package/dist/migration-graph-kPluRdF2.mjs.map +1 -0
- package/dist/migration-list-CE35R5Ag.mjs +505 -0
- package/dist/migration-list-CE35R5Ag.mjs.map +1 -0
- package/dist/migration-list-styler-DeAwACt3.mjs +402 -0
- package/dist/migration-list-styler-DeAwACt3.mjs.map +1 -0
- package/dist/{migration-plan-C2jeH1J5.mjs → migration-plan-DHLa2Khm.mjs} +372 -133
- package/dist/migration-plan-DHLa2Khm.mjs.map +1 -0
- package/dist/{migration-types-BXWvz12q.d.mts → migration-types-CAQ-0TEE.d.mts} +1 -1
- package/dist/{migration-types-BXWvz12q.d.mts.map → migration-types-CAQ-0TEE.d.mts.map} +1 -1
- package/dist/{migrations-CwZMa1Ck.mjs → migrations-CjO1DsYe.mjs} +12 -13
- package/dist/migrations-CjO1DsYe.mjs.map +1 -0
- package/dist/{output-BlsrGMEF.mjs → output-CF_hqzI-.mjs} +1 -1
- package/dist/{output-BlsrGMEF.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs → progress-adapter-C644QK8l.mjs} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs.map → progress-adapter-C644QK8l.mjs.map} +1 -1
- package/dist/ref-advancement-DUZqsue6.mjs +50 -0
- package/dist/ref-advancement-DUZqsue6.mjs.map +1 -0
- package/dist/terminal-ui-BbtqsQYY.d.mts +133 -0
- package/dist/terminal-ui-BbtqsQYY.d.mts.map +1 -0
- package/dist/{types-C9FfXb1l.d.mts → types-Ci7TndCS.d.mts} +21 -28
- package/dist/types-Ci7TndCS.d.mts.map +1 -0
- package/dist/{verify-Bom75OYI.mjs → verify-vl983Ed-.mjs} +2 -2
- package/dist/{verify-Bom75OYI.mjs.map → verify-vl983Ed-.mjs.map} +1 -1
- package/package.json +19 -19
- package/src/commands/db-init.ts +48 -2
- package/src/commands/db-sign.ts +9 -5
- package/src/commands/db-update.ts +54 -8
- package/src/commands/migrate.ts +125 -44
- package/src/commands/migration-check.ts +43 -83
- package/src/commands/migration-graph.ts +75 -60
- package/src/commands/migration-list.ts +231 -74
- package/src/commands/migration-log.ts +8 -14
- package/src/commands/migration-new.ts +44 -48
- package/src/commands/migration-plan.ts +412 -197
- package/src/commands/migration-show.ts +65 -284
- package/src/commands/migration-status.ts +127 -124
- package/src/commands/ref.ts +53 -8
- package/src/control-api/client.ts +0 -1
- package/src/control-api/contract-enrichment.ts +6 -42
- package/src/control-api/operations/{apply-aggregate.ts → apply.ts} +44 -75
- package/src/control-api/operations/contract-emit.ts +7 -2
- package/src/control-api/operations/{db-apply-aggregate.ts → db-apply.ts} +19 -19
- package/src/control-api/operations/db-init.ts +4 -4
- package/src/control-api/operations/db-update.ts +4 -4
- package/src/control-api/operations/db-verify.ts +15 -11
- package/src/control-api/operations/migration-apply.ts +56 -47
- package/src/control-api/types.ts +19 -27
- package/src/migration-cli.ts +4 -4
- package/src/utils/cli-errors.ts +234 -0
- package/src/utils/command-helpers.ts +1 -20
- package/src/utils/contract-at-errors.ts +96 -0
- package/src/utils/contract-space-aggregate-loader.ts +336 -117
- package/src/utils/formatters/migration-graph-layout.ts +1119 -0
- package/src/utils/formatters/migration-graph-rows.ts +336 -0
- package/src/utils/formatters/migration-graph-tree-render.ts +459 -0
- package/src/utils/formatters/migration-list-data-column.ts +115 -0
- package/src/utils/formatters/migration-list-graph-layout.ts +268 -0
- package/src/utils/formatters/migration-list-graph-render.ts +311 -0
- package/src/utils/formatters/migration-list-graph-topology.ts +368 -0
- package/src/utils/formatters/migration-list-render.ts +191 -0
- package/src/utils/formatters/migration-list-styler.ts +63 -0
- package/src/utils/formatters/migration-list-types.ts +21 -0
- package/src/utils/formatters/migrations.ts +37 -46
- package/src/utils/glyph-mode.ts +22 -0
- package/src/utils/integrity-violation-to-check-failure.ts +130 -0
- package/src/utils/plan-resolution.ts +258 -0
- package/src/utils/ref-advancement.ts +68 -0
- package/src/utils/terminal-ui.ts +42 -1
- package/dist/cli-errors-Czmx92Zy.d.mts +0 -3
- package/dist/cli-errors-Djtz98Vm.mjs +0 -71
- package/dist/cli-errors-Djtz98Vm.mjs.map +0 -1
- package/dist/client-oXO2WCPD.mjs.map +0 -1
- package/dist/command-helpers-DtavI0wJ.mjs.map +0 -1
- package/dist/commands/migration-check.mjs.map +0 -1
- package/dist/commands/migration-graph.mjs.map +0 -1
- package/dist/commands/migration-list.mjs.map +0 -1
- package/dist/contract-enrichment-Dani0mMW.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-BmNQwlws.mjs +0 -160
- package/dist/contract-space-aggregate-loader-BmNQwlws.mjs.map +0 -1
- package/dist/global-flags-CdE7M0d9.d.mts +0 -15
- package/dist/global-flags-CdE7M0d9.d.mts.map +0 -1
- package/dist/migration-plan-C2jeH1J5.mjs.map +0 -1
- package/dist/migrations-CwZMa1Ck.mjs.map +0 -1
- package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
- package/dist/terminal-ui-BiB_8KNo.mjs +0 -379
- package/dist/terminal-ui-BiB_8KNo.mjs.map +0 -1
- package/dist/types-C9FfXb1l.d.mts.map +0 -1
|
@@ -12,19 +12,15 @@ import { readFile } from 'node:fs/promises';
|
|
|
12
12
|
import type { Contract } from '@prisma-next/contract/types';
|
|
13
13
|
import { getEmittedArtifactPaths } from '@prisma-next/emitter';
|
|
14
14
|
import { APP_SPACE_ID, createControlStack } from '@prisma-next/framework-components/control';
|
|
15
|
-
import {
|
|
15
|
+
import { loadContractSpaceAggregate } from '@prisma-next/migration-tools/aggregate';
|
|
16
16
|
import { computeMigrationHash } from '@prisma-next/migration-tools/hash';
|
|
17
17
|
import {
|
|
18
18
|
copyFilesWithRename,
|
|
19
19
|
formatMigrationDirName,
|
|
20
|
-
readMigrationsDir,
|
|
21
20
|
writeMigrationPackage,
|
|
22
21
|
} from '@prisma-next/migration-tools/io';
|
|
23
22
|
import type { MigrationMetadata } from '@prisma-next/migration-tools/metadata';
|
|
24
|
-
import {
|
|
25
|
-
findLatestMigration,
|
|
26
|
-
reconstructGraph,
|
|
27
|
-
} from '@prisma-next/migration-tools/migration-graph';
|
|
23
|
+
import { findLatestMigration } from '@prisma-next/migration-tools/migration-graph';
|
|
28
24
|
import { writeMigrationTs } from '@prisma-next/migration-tools/migration-ts';
|
|
29
25
|
import { notOk, ok, type Result } from '@prisma-next/utils/result';
|
|
30
26
|
import { Command } from 'commander';
|
|
@@ -36,7 +32,6 @@ import {
|
|
|
36
32
|
errorRuntime,
|
|
37
33
|
errorTargetMigrationNotSupported,
|
|
38
34
|
errorUnexpected,
|
|
39
|
-
mapMigrationToolsError,
|
|
40
35
|
} from '../utils/cli-errors';
|
|
41
36
|
import {
|
|
42
37
|
addGlobalOptions,
|
|
@@ -46,6 +41,7 @@ import {
|
|
|
46
41
|
setCommandDescriptions,
|
|
47
42
|
setCommandExamples,
|
|
48
43
|
} from '../utils/command-helpers';
|
|
44
|
+
import { refusePackageCorruptionOnAggregate } from '../utils/contract-space-aggregate-loader';
|
|
49
45
|
import { formatStyledHeader } from '../utils/formatters/styled';
|
|
50
46
|
import { assertFrameworkComponentsCompatible } from '../utils/framework-components';
|
|
51
47
|
import type { CommonCommandOptions } from '../utils/global-flags';
|
|
@@ -71,7 +67,10 @@ async function executeMigrationNewCommand(
|
|
|
71
67
|
options: MigrationNewOptions,
|
|
72
68
|
): Promise<Result<MigrationNewResult, CliStructuredError>> {
|
|
73
69
|
const config = await loadConfig(options.config);
|
|
74
|
-
const { appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(
|
|
70
|
+
const { migrationsDir, appMigrationsDir, appMigrationsRelative } = resolveMigrationPaths(
|
|
71
|
+
options.config,
|
|
72
|
+
config,
|
|
73
|
+
);
|
|
75
74
|
|
|
76
75
|
// Construct the family instance up-front so the on-disk contract read
|
|
77
76
|
// below crosses the serializer seam (`familyInstance.deserializeContract`)
|
|
@@ -98,7 +97,8 @@ async function executeMigrationNewCommand(
|
|
|
98
97
|
|
|
99
98
|
let toContract: Contract;
|
|
100
99
|
try {
|
|
101
|
-
|
|
100
|
+
const parsedContract: unknown = JSON.parse(contractJsonContent);
|
|
101
|
+
toContract = familyInstance.deserializeContract(parsedContract);
|
|
102
102
|
} catch (error) {
|
|
103
103
|
return notOk(
|
|
104
104
|
errorRuntime('Contract JSON is invalid', {
|
|
@@ -118,45 +118,47 @@ async function executeMigrationNewCommand(
|
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const aggregate = await loadContractSpaceAggregate({
|
|
122
|
+
migrationsDir,
|
|
123
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json),
|
|
124
|
+
appContract: toContract,
|
|
125
|
+
});
|
|
126
|
+
const packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate);
|
|
127
|
+
if (packageCorruptionFailure) {
|
|
128
|
+
return notOk(packageCorruptionFailure);
|
|
129
|
+
}
|
|
123
130
|
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
const packages = aggregate.app.packages;
|
|
132
|
+
const graph = aggregate.app.graph();
|
|
126
133
|
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
let fromHash: string | null = null;
|
|
135
|
+
let fromContractSourceDir: string | null = null;
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
if (packages.length > 0) {
|
|
138
|
+
if (options.from) {
|
|
139
|
+
const match = packages.find((p) => p.metadata.to.startsWith(options.from!));
|
|
140
|
+
if (!match) {
|
|
141
|
+
return notOk(
|
|
142
|
+
errorRuntime('Starting contract not found', {
|
|
143
|
+
why: `No migration with to hash matching "${options.from}" exists in ${appMigrationsRelative}`,
|
|
144
|
+
fix: 'Check that the --from hash matches a known migration target hash.',
|
|
145
|
+
}),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
fromHash = match.metadata.to;
|
|
149
|
+
fromContractSourceDir = match.dirPath;
|
|
150
|
+
} else {
|
|
151
|
+
const latestMigration = findLatestMigration(graph);
|
|
152
|
+
if (latestMigration) {
|
|
153
|
+
fromHash = latestMigration.to;
|
|
154
|
+
const leafPkg = packages.find(
|
|
155
|
+
(p) => p.metadata.migrationHash === latestMigration.migrationHash,
|
|
156
|
+
);
|
|
157
|
+
if (leafPkg) {
|
|
158
|
+
fromContractSourceDir = leafPkg.dirPath;
|
|
152
159
|
}
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (MigrationToolsError.is(error)) {
|
|
157
|
-
return notOk(mapMigrationToolsError(error));
|
|
158
|
-
}
|
|
159
|
-
throw error;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
if (fromHash === toStorageHash && !options.from) {
|
|
@@ -180,12 +182,6 @@ async function executeMigrationNewCommand(
|
|
|
180
182
|
const baseMetadata: Omit<MigrationMetadata, 'migrationHash'> = {
|
|
181
183
|
from: fromHash,
|
|
182
184
|
to: toStorageHash,
|
|
183
|
-
hints: {
|
|
184
|
-
used: [],
|
|
185
|
-
applied: [],
|
|
186
|
-
plannerVersion: '1.0.0',
|
|
187
|
-
},
|
|
188
|
-
labels: [],
|
|
189
185
|
providedInvariants: [],
|
|
190
186
|
createdAt: timestamp.toISOString(),
|
|
191
187
|
};
|