@dashai/cli 0.32.0 → 0.32.1
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/dist/bin.js +106 -57
- package/dist/bin.js.map +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1027,6 +1027,99 @@ var init_manifest_io = __esm({
|
|
|
1027
1027
|
"src/lib/manifest-io.ts"() {
|
|
1028
1028
|
}
|
|
1029
1029
|
});
|
|
1030
|
+
function resolveSdkPackageJson(projectRoot) {
|
|
1031
|
+
let dir = projectRoot;
|
|
1032
|
+
for (; ; ) {
|
|
1033
|
+
const candidate = join(dir, "node_modules", "@dashai", "sdk", "package.json");
|
|
1034
|
+
if (existsSync(candidate)) return candidate;
|
|
1035
|
+
const parent = dirname(dir);
|
|
1036
|
+
if (parent === dir) return null;
|
|
1037
|
+
dir = parent;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
function readInstalledSdk(projectRoot) {
|
|
1041
|
+
const pkgPath = resolveSdkPackageJson(projectRoot);
|
|
1042
|
+
if (pkgPath === null) return null;
|
|
1043
|
+
try {
|
|
1044
|
+
const parsed = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
1045
|
+
if (typeof parsed.version !== "string" || parsed.version.length === 0) return null;
|
|
1046
|
+
return { version: parsed.version };
|
|
1047
|
+
} catch {
|
|
1048
|
+
return null;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
function compareVersions(a, b) {
|
|
1052
|
+
const parse = (v) => {
|
|
1053
|
+
const [core = "", pre] = v.trim().replace(/^[^0-9]*/, "").split("-", 2);
|
|
1054
|
+
const nums = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
1055
|
+
while (nums.length < 3) nums.push(0);
|
|
1056
|
+
return [nums.slice(0, 3), pre !== void 0 && pre.length > 0];
|
|
1057
|
+
};
|
|
1058
|
+
const [an, apre] = parse(a);
|
|
1059
|
+
const [bn, bpre] = parse(b);
|
|
1060
|
+
for (let i = 0; i < 3; i++) {
|
|
1061
|
+
const d = (an[i] ?? 0) - (bn[i] ?? 0);
|
|
1062
|
+
if (d !== 0) return d;
|
|
1063
|
+
}
|
|
1064
|
+
if (apre === bpre) return 0;
|
|
1065
|
+
return apre ? -1 : 1;
|
|
1066
|
+
}
|
|
1067
|
+
function satisfiesFloor(version, floor) {
|
|
1068
|
+
return compareVersions(version, floor) >= 0;
|
|
1069
|
+
}
|
|
1070
|
+
function checkSdkFloor(projectRoot, floor) {
|
|
1071
|
+
const installed = readInstalledSdk(projectRoot);
|
|
1072
|
+
if (installed === null) return { ok: true, installed: null, floor };
|
|
1073
|
+
return {
|
|
1074
|
+
ok: satisfiesFloor(installed.version, floor),
|
|
1075
|
+
installed: installed.version,
|
|
1076
|
+
floor
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
function sdkAcceptsSnakeUsesSlugs(version) {
|
|
1080
|
+
return compareVersions(version, LAST_SDK_WITHOUT_SNAKE_USES_SLUGS) > 0;
|
|
1081
|
+
}
|
|
1082
|
+
function multiWordUsesSlots(manifest) {
|
|
1083
|
+
const tables = manifest?.uses?.tables;
|
|
1084
|
+
if (!Array.isArray(tables)) return [];
|
|
1085
|
+
return tables.map((t) => t?.slug).filter((slug) => typeof slug === "string" && slug.includes("_"));
|
|
1086
|
+
}
|
|
1087
|
+
function checkUsesSlotsAgainstSdk(projectRoot, slots) {
|
|
1088
|
+
const multiWord = slots.filter((slug) => slug.includes("_"));
|
|
1089
|
+
if (multiWord.length === 0) return null;
|
|
1090
|
+
const installed = readInstalledSdk(projectRoot);
|
|
1091
|
+
if (installed === null || sdkAcceptsSnakeUsesSlugs(installed.version)) return null;
|
|
1092
|
+
return { installed: installed.version, slots: multiWord };
|
|
1093
|
+
}
|
|
1094
|
+
var USES_SDK_FLOOR, SCAFFOLD_SDK_RANGE, LAST_SDK_WITHOUT_SNAKE_USES_SLUGS;
|
|
1095
|
+
var init_sdk_version = __esm({
|
|
1096
|
+
"src/lib/sdk-version.ts"() {
|
|
1097
|
+
USES_SDK_FLOOR = "2.5.0";
|
|
1098
|
+
SCAFFOLD_SDK_RANGE = "^2.5.0";
|
|
1099
|
+
LAST_SDK_WITHOUT_SNAKE_USES_SLUGS = "2.14.0";
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
// src/lib/uses-slot-sdk-warning.ts
|
|
1104
|
+
function warnIfSdkRefusesUsesSlots(projectRoot, slots, alternative) {
|
|
1105
|
+
const check = checkUsesSlotsAgainstSdk(projectRoot, slots);
|
|
1106
|
+
if (check === null) return false;
|
|
1107
|
+
const one = check.slots.length === 1;
|
|
1108
|
+
const names = check.slots.map((s) => code(s)).join(", ");
|
|
1109
|
+
warn(
|
|
1110
|
+
`${names} ${one ? "is a multi-word uses slot" : "are multi-word uses slots"}, and the installed ${code(`@dashai/sdk ${check.installed}`)} refuses ${one ? "it" : "them"}: every import from ${code("@dashai/generated")} throws, including your own tables.`
|
|
1111
|
+
);
|
|
1112
|
+
info(
|
|
1113
|
+
`Upgrade to the first SDK with the fix (any release after ${LAST_SDK_WITHOUT_SNAKE_USES_SLUGS}): ${code("npm install @dashai/sdk@latest")}.${alternative ? ` ${alternative}` : ""}`
|
|
1114
|
+
);
|
|
1115
|
+
return true;
|
|
1116
|
+
}
|
|
1117
|
+
var init_uses_slot_sdk_warning = __esm({
|
|
1118
|
+
"src/lib/uses-slot-sdk-warning.ts"() {
|
|
1119
|
+
init_output();
|
|
1120
|
+
init_sdk_version();
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1030
1123
|
|
|
1031
1124
|
// src/lib/manifest-merge.ts
|
|
1032
1125
|
function tablesBySlug(manifest) {
|
|
@@ -1353,6 +1446,10 @@ async function devCommand(options) {
|
|
|
1353
1446
|
requestOptions: { baseUrl: apiUrl, auth: { token: apiToken } }
|
|
1354
1447
|
});
|
|
1355
1448
|
}
|
|
1449
|
+
try {
|
|
1450
|
+
warnIfSdkRefusesUsesSlots(projectRoot, multiWordUsesSlots(readManifest(projectRoot)));
|
|
1451
|
+
} catch {
|
|
1452
|
+
}
|
|
1356
1453
|
const children = [];
|
|
1357
1454
|
if (!options.nextOnly) {
|
|
1358
1455
|
const sdkChild = spawnSdkWatcher(projectRoot, childEnv);
|
|
@@ -1661,6 +1758,8 @@ var init_dev = __esm({
|
|
|
1661
1758
|
init_config();
|
|
1662
1759
|
init_declared_secrets();
|
|
1663
1760
|
init_manifest_io();
|
|
1761
|
+
init_sdk_version();
|
|
1762
|
+
init_uses_slot_sdk_warning();
|
|
1664
1763
|
init_manifest_poll();
|
|
1665
1764
|
init_output();
|
|
1666
1765
|
init_redact();
|
|
@@ -1673,62 +1772,6 @@ var init_dev = __esm({
|
|
|
1673
1772
|
PORT_PROBE_LIMIT = 10;
|
|
1674
1773
|
}
|
|
1675
1774
|
});
|
|
1676
|
-
function resolveSdkPackageJson(projectRoot) {
|
|
1677
|
-
let dir = projectRoot;
|
|
1678
|
-
for (; ; ) {
|
|
1679
|
-
const candidate = join(dir, "node_modules", "@dashai", "sdk", "package.json");
|
|
1680
|
-
if (existsSync(candidate)) return candidate;
|
|
1681
|
-
const parent = dirname(dir);
|
|
1682
|
-
if (parent === dir) return null;
|
|
1683
|
-
dir = parent;
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
function readInstalledSdk(projectRoot) {
|
|
1687
|
-
const pkgPath = resolveSdkPackageJson(projectRoot);
|
|
1688
|
-
if (pkgPath === null) return null;
|
|
1689
|
-
try {
|
|
1690
|
-
const parsed = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
1691
|
-
if (typeof parsed.version !== "string" || parsed.version.length === 0) return null;
|
|
1692
|
-
return { version: parsed.version };
|
|
1693
|
-
} catch {
|
|
1694
|
-
return null;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
function compareVersions(a, b) {
|
|
1698
|
-
const parse = (v) => {
|
|
1699
|
-
const [core = "", pre] = v.trim().replace(/^[^0-9]*/, "").split("-", 2);
|
|
1700
|
-
const nums = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
1701
|
-
while (nums.length < 3) nums.push(0);
|
|
1702
|
-
return [nums.slice(0, 3), pre !== void 0 && pre.length > 0];
|
|
1703
|
-
};
|
|
1704
|
-
const [an, apre] = parse(a);
|
|
1705
|
-
const [bn, bpre] = parse(b);
|
|
1706
|
-
for (let i = 0; i < 3; i++) {
|
|
1707
|
-
const d = (an[i] ?? 0) - (bn[i] ?? 0);
|
|
1708
|
-
if (d !== 0) return d;
|
|
1709
|
-
}
|
|
1710
|
-
if (apre === bpre) return 0;
|
|
1711
|
-
return apre ? -1 : 1;
|
|
1712
|
-
}
|
|
1713
|
-
function satisfiesFloor(version, floor) {
|
|
1714
|
-
return compareVersions(version, floor) >= 0;
|
|
1715
|
-
}
|
|
1716
|
-
function checkSdkFloor(projectRoot, floor) {
|
|
1717
|
-
const installed = readInstalledSdk(projectRoot);
|
|
1718
|
-
if (installed === null) return { ok: true, installed: null, floor };
|
|
1719
|
-
return {
|
|
1720
|
-
ok: satisfiesFloor(installed.version, floor),
|
|
1721
|
-
installed: installed.version,
|
|
1722
|
-
floor
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
var USES_SDK_FLOOR, SCAFFOLD_SDK_RANGE;
|
|
1726
|
-
var init_sdk_version = __esm({
|
|
1727
|
-
"src/lib/sdk-version.ts"() {
|
|
1728
|
-
USES_SDK_FLOOR = "2.5.0";
|
|
1729
|
-
SCAFFOLD_SDK_RANGE = "^2.5.0";
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1732
1775
|
async function selectWorkspace(opts) {
|
|
1733
1776
|
const workspaces = await apiRequest(
|
|
1734
1777
|
"GET",
|
|
@@ -23644,6 +23687,7 @@ init_config();
|
|
|
23644
23687
|
init_manifest_io();
|
|
23645
23688
|
init_uses_types();
|
|
23646
23689
|
init_sdk_version();
|
|
23690
|
+
init_uses_slot_sdk_warning();
|
|
23647
23691
|
init_output();
|
|
23648
23692
|
async function usesAddCommand(options) {
|
|
23649
23693
|
if (!options.fromTable) {
|
|
@@ -23693,6 +23737,11 @@ async function usesAddCommand(options) {
|
|
|
23693
23737
|
);
|
|
23694
23738
|
return 1;
|
|
23695
23739
|
}
|
|
23740
|
+
warnIfSdkRefusesUsesSlots(
|
|
23741
|
+
resolve(options.dir ?? process.cwd()),
|
|
23742
|
+
[slotSlug],
|
|
23743
|
+
`Or give the slot a one-word slug: ${code("--slug <slug>")}.`
|
|
23744
|
+
);
|
|
23696
23745
|
const { fields, skipped } = generateFields(table2.fields);
|
|
23697
23746
|
if (fields.length === 0) {
|
|
23698
23747
|
fail(
|
|
@@ -28381,7 +28430,7 @@ fieldCmd.command("set-type <table-slug> <field-slug> <new-type>").description(
|
|
|
28381
28430
|
}
|
|
28382
28431
|
);
|
|
28383
28432
|
function getVersion() {
|
|
28384
|
-
return "0.32.
|
|
28433
|
+
return "0.32.1";
|
|
28385
28434
|
}
|
|
28386
28435
|
function parsePositiveIdOption(value) {
|
|
28387
28436
|
if (!/^[1-9][0-9]*$/.test(value.trim())) {
|