@prisma-next/cli 0.1.0-dev.29 → 0.1.0-dev.30
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 +66 -12
- package/dist/{chunk-3XVN5I7J.js → chunk-464LNZCE.js} +3 -3
- package/dist/{chunk-3XVN5I7J.js.map → chunk-464LNZCE.js.map} +1 -1
- package/dist/{chunk-I3G6AX7S.js → chunk-BZMBKEEQ.js} +3 -1
- package/dist/chunk-BZMBKEEQ.js.map +1 -0
- package/dist/{chunk-K26YF42T.js → chunk-C7QQMZ3I.js} +43 -4
- package/dist/chunk-C7QQMZ3I.js.map +1 -0
- package/dist/cli.js +105 -31
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.js +2 -2
- package/dist/commands/db-init.js +12 -4
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.js +14 -3
- package/dist/commands/db-introspect.js.map +1 -1
- package/dist/commands/db-schema-verify.js +22 -14
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.js +23 -15
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.js +12 -2
- package/dist/commands/db-verify.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/package.json +10 -14
- package/dist/chunk-I3G6AX7S.js.map +0 -1
- package/dist/chunk-K26YF42T.js.map +0 -1
- package/dist/chunk-W5YXBFPY.js +0 -96
- package/dist/chunk-W5YXBFPY.js.map +0 -1
- package/dist/pack-loading.d.ts +0 -6
- package/dist/pack-loading.js +0 -9
- package/dist/pack-loading.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
errorConfigFileNotFound as errorConfigFileNotFound2,
|
|
62
62
|
errorConfigValidation,
|
|
63
63
|
errorContractConfigMissing,
|
|
64
|
+
errorContractMissingExtensionPacks,
|
|
64
65
|
errorContractValidationFailed,
|
|
65
66
|
errorDatabaseUrlRequired,
|
|
66
67
|
errorDriverRequired,
|
|
@@ -1137,7 +1138,7 @@ function createContractEmitCommand() {
|
|
|
1137
1138
|
target: config.target,
|
|
1138
1139
|
adapter: config.adapter,
|
|
1139
1140
|
driver: config.driver,
|
|
1140
|
-
|
|
1141
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1141
1142
|
});
|
|
1142
1143
|
let contractRaw;
|
|
1143
1144
|
if (typeof contractConfig.source === "function") {
|
|
@@ -1198,6 +1199,9 @@ import { redactDatabaseUrl } from "@prisma-next/utils/redact-db-url";
|
|
|
1198
1199
|
import { Command as Command2 } from "commander";
|
|
1199
1200
|
|
|
1200
1201
|
// src/utils/framework-components.ts
|
|
1202
|
+
import {
|
|
1203
|
+
checkContractComponentRequirements
|
|
1204
|
+
} from "@prisma-next/contract/framework-components";
|
|
1201
1205
|
function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId, frameworkComponents) {
|
|
1202
1206
|
for (let i = 0; i < frameworkComponents.length; i++) {
|
|
1203
1207
|
const component = frameworkComponents[i];
|
|
@@ -1243,6 +1247,40 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
|
|
|
1243
1247
|
}
|
|
1244
1248
|
return frameworkComponents;
|
|
1245
1249
|
}
|
|
1250
|
+
function assertContractRequirementsSatisfied({
|
|
1251
|
+
contract,
|
|
1252
|
+
family,
|
|
1253
|
+
target,
|
|
1254
|
+
adapter,
|
|
1255
|
+
extensionPacks
|
|
1256
|
+
}) {
|
|
1257
|
+
const providedComponentIds = /* @__PURE__ */ new Set([target.id, adapter.id]);
|
|
1258
|
+
for (const extension of extensionPacks ?? []) {
|
|
1259
|
+
providedComponentIds.add(extension.id);
|
|
1260
|
+
}
|
|
1261
|
+
const result = checkContractComponentRequirements({
|
|
1262
|
+
contract,
|
|
1263
|
+
expectedTargetFamily: family.familyId,
|
|
1264
|
+
expectedTargetId: target.targetId,
|
|
1265
|
+
providedComponentIds
|
|
1266
|
+
});
|
|
1267
|
+
if (result.familyMismatch) {
|
|
1268
|
+
throw errorConfigValidation("contract.targetFamily", {
|
|
1269
|
+
why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
if (result.targetMismatch) {
|
|
1273
|
+
throw errorConfigValidation("contract.target", {
|
|
1274
|
+
why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
if (result.missingExtensionPackIds.length > 0) {
|
|
1278
|
+
throw errorContractMissingExtensionPacks({
|
|
1279
|
+
missingExtensionPacks: result.missingExtensionPackIds,
|
|
1280
|
+
providedComponentIds: [...providedComponentIds]
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1246
1284
|
|
|
1247
1285
|
// src/commands/db-init.ts
|
|
1248
1286
|
function createDbInitCommand() {
|
|
@@ -1355,15 +1393,22 @@ function createDbInitCommand() {
|
|
|
1355
1393
|
target: config.target,
|
|
1356
1394
|
adapter: config.adapter,
|
|
1357
1395
|
driver: driverDescriptor,
|
|
1358
|
-
|
|
1396
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1359
1397
|
});
|
|
1360
|
-
const rawComponents = [config.target, config.adapter, ...config.
|
|
1398
|
+
const rawComponents = [config.target, config.adapter, ...config.extensionPacks ?? []];
|
|
1361
1399
|
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1362
1400
|
config.family.familyId,
|
|
1363
1401
|
config.target.targetId,
|
|
1364
1402
|
rawComponents
|
|
1365
1403
|
);
|
|
1366
1404
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1405
|
+
assertContractRequirementsSatisfied({
|
|
1406
|
+
contract: contractIR,
|
|
1407
|
+
family: config.family,
|
|
1408
|
+
target: config.target,
|
|
1409
|
+
adapter: config.adapter,
|
|
1410
|
+
extensionPacks: config.extensionPacks
|
|
1411
|
+
});
|
|
1367
1412
|
const planner = migrations.createPlanner(familyInstance);
|
|
1368
1413
|
const runner = migrations.createRunner(familyInstance);
|
|
1369
1414
|
const schemaIR = await withSpinner(() => familyInstance.introspect({ driver }), {
|
|
@@ -1621,10 +1666,18 @@ function createDbIntrospectCommand() {
|
|
|
1621
1666
|
target: config.target,
|
|
1622
1667
|
adapter: config.adapter,
|
|
1623
1668
|
driver: driverDescriptor,
|
|
1624
|
-
|
|
1669
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1625
1670
|
});
|
|
1626
1671
|
if (contractIR) {
|
|
1627
|
-
|
|
1672
|
+
const validatedContract = familyInstance.validateContractIR(contractIR);
|
|
1673
|
+
assertContractRequirementsSatisfied({
|
|
1674
|
+
contract: validatedContract,
|
|
1675
|
+
family: config.family,
|
|
1676
|
+
target: config.target,
|
|
1677
|
+
adapter: config.adapter,
|
|
1678
|
+
extensionPacks: config.extensionPacks
|
|
1679
|
+
});
|
|
1680
|
+
contractIR = validatedContract;
|
|
1628
1681
|
}
|
|
1629
1682
|
let schemaIR;
|
|
1630
1683
|
try {
|
|
@@ -1764,32 +1817,39 @@ function createDbSchemaVerifyCommand() {
|
|
|
1764
1817
|
});
|
|
1765
1818
|
}
|
|
1766
1819
|
const contractJson = JSON.parse(contractJsonContent);
|
|
1767
|
-
const dbUrl = options.db ?? config.db?.url;
|
|
1768
|
-
if (!dbUrl) {
|
|
1769
|
-
throw errorDatabaseUrlRequired3();
|
|
1770
|
-
}
|
|
1771
1820
|
if (!config.driver) {
|
|
1772
1821
|
throw errorDriverRequired3();
|
|
1773
1822
|
}
|
|
1774
1823
|
const driverDescriptor = config.driver;
|
|
1824
|
+
const familyInstance = config.family.create({
|
|
1825
|
+
target: config.target,
|
|
1826
|
+
adapter: config.adapter,
|
|
1827
|
+
driver: driverDescriptor,
|
|
1828
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1829
|
+
});
|
|
1830
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1831
|
+
assertContractRequirementsSatisfied({
|
|
1832
|
+
contract: contractIR,
|
|
1833
|
+
family: config.family,
|
|
1834
|
+
target: config.target,
|
|
1835
|
+
adapter: config.adapter,
|
|
1836
|
+
extensionPacks: config.extensionPacks
|
|
1837
|
+
});
|
|
1838
|
+
const dbUrl = options.db ?? config.db?.url;
|
|
1839
|
+
if (!dbUrl) {
|
|
1840
|
+
throw errorDatabaseUrlRequired3();
|
|
1841
|
+
}
|
|
1775
1842
|
const driver = await withSpinner(() => driverDescriptor.create(dbUrl), {
|
|
1776
1843
|
message: "Connecting to database...",
|
|
1777
1844
|
flags
|
|
1778
1845
|
});
|
|
1779
1846
|
try {
|
|
1780
|
-
const
|
|
1781
|
-
target: config.target,
|
|
1782
|
-
adapter: config.adapter,
|
|
1783
|
-
driver: driverDescriptor,
|
|
1784
|
-
extensions: config.extensions ?? []
|
|
1785
|
-
});
|
|
1786
|
-
const rawComponents = [config.target, config.adapter, ...config.extensions ?? []];
|
|
1847
|
+
const rawComponents = [config.target, config.adapter, ...config.extensionPacks ?? []];
|
|
1787
1848
|
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1788
1849
|
config.family.familyId,
|
|
1789
1850
|
config.target.targetId,
|
|
1790
1851
|
rawComponents
|
|
1791
1852
|
);
|
|
1792
|
-
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1793
1853
|
let schemaVerifyResult;
|
|
1794
1854
|
try {
|
|
1795
1855
|
schemaVerifyResult = await withSpinner(
|
|
@@ -1907,21 +1967,28 @@ function createDbSignCommand() {
|
|
|
1907
1967
|
throw errorDriverRequired4();
|
|
1908
1968
|
}
|
|
1909
1969
|
const driverDescriptor = config.driver;
|
|
1970
|
+
const familyInstance = config.family.create({
|
|
1971
|
+
target: config.target,
|
|
1972
|
+
adapter: config.adapter,
|
|
1973
|
+
driver: driverDescriptor,
|
|
1974
|
+
extensionPacks: config.extensionPacks ?? []
|
|
1975
|
+
});
|
|
1976
|
+
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1977
|
+
assertContractRequirementsSatisfied({
|
|
1978
|
+
contract: contractIR,
|
|
1979
|
+
family: config.family,
|
|
1980
|
+
target: config.target,
|
|
1981
|
+
adapter: config.adapter,
|
|
1982
|
+
extensionPacks: config.extensionPacks
|
|
1983
|
+
});
|
|
1984
|
+
const rawComponents = [config.target, config.adapter, ...config.extensionPacks ?? []];
|
|
1985
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1986
|
+
config.family.familyId,
|
|
1987
|
+
config.target.targetId,
|
|
1988
|
+
rawComponents
|
|
1989
|
+
);
|
|
1910
1990
|
const driver = await driverDescriptor.create(dbUrl);
|
|
1911
1991
|
try {
|
|
1912
|
-
const familyInstance = config.family.create({
|
|
1913
|
-
target: config.target,
|
|
1914
|
-
adapter: config.adapter,
|
|
1915
|
-
driver: driverDescriptor,
|
|
1916
|
-
extensions: config.extensions ?? []
|
|
1917
|
-
});
|
|
1918
|
-
const rawComponents = [config.target, config.adapter, ...config.extensions ?? []];
|
|
1919
|
-
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1920
|
-
config.family.familyId,
|
|
1921
|
-
config.target.targetId,
|
|
1922
|
-
rawComponents
|
|
1923
|
-
);
|
|
1924
|
-
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1925
1992
|
let schemaVerifyResult;
|
|
1926
1993
|
try {
|
|
1927
1994
|
schemaVerifyResult = await withSpinner(
|
|
@@ -2087,9 +2154,16 @@ function createDbVerifyCommand() {
|
|
|
2087
2154
|
target: config.target,
|
|
2088
2155
|
adapter: config.adapter,
|
|
2089
2156
|
driver: driverDescriptor,
|
|
2090
|
-
|
|
2157
|
+
extensionPacks: config.extensionPacks ?? []
|
|
2091
2158
|
});
|
|
2092
2159
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
2160
|
+
assertContractRequirementsSatisfied({
|
|
2161
|
+
contract: contractIR,
|
|
2162
|
+
family: config.family,
|
|
2163
|
+
target: config.target,
|
|
2164
|
+
adapter: config.adapter,
|
|
2165
|
+
extensionPacks: config.extensionPacks
|
|
2166
|
+
});
|
|
2093
2167
|
let verifyResult;
|
|
2094
2168
|
try {
|
|
2095
2169
|
verifyResult = await withSpinner(
|