@better-auth/cli 1.4.0-beta.3 → 1.4.0-beta.5
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/index.mjs +29 -13
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2331,7 +2331,11 @@ const generateDrizzleSchema = async ({
|
|
|
2331
2331
|
if (attr.defaultValue !== null && typeof attr.defaultValue !== "undefined") {
|
|
2332
2332
|
if (typeof attr.defaultValue === "function") {
|
|
2333
2333
|
if (attr.type === "date" && attr.defaultValue.toString().includes("new Date()")) {
|
|
2334
|
-
|
|
2334
|
+
if (databaseType === "sqlite") {
|
|
2335
|
+
type += `.default(sql\`(current_timestamp)\`)`;
|
|
2336
|
+
} else {
|
|
2337
|
+
type += `.defaultNow()`;
|
|
2338
|
+
}
|
|
2335
2339
|
} else {
|
|
2336
2340
|
type += `.$defaultFn(${attr.defaultValue})`;
|
|
2337
2341
|
}
|
|
@@ -2370,7 +2374,8 @@ function generateImport({
|
|
|
2370
2374
|
tables,
|
|
2371
2375
|
options
|
|
2372
2376
|
}) {
|
|
2373
|
-
|
|
2377
|
+
const rootImports = [];
|
|
2378
|
+
const coreImports = [];
|
|
2374
2379
|
let hasBigint = false;
|
|
2375
2380
|
let hasJson = false;
|
|
2376
2381
|
for (const table of Object.values(tables)) {
|
|
@@ -2381,12 +2386,14 @@ function generateImport({
|
|
|
2381
2386
|
if (hasJson && hasBigint) break;
|
|
2382
2387
|
}
|
|
2383
2388
|
const useNumberId = options.advanced?.database?.useNumberId;
|
|
2384
|
-
|
|
2385
|
-
|
|
2389
|
+
coreImports.push(`${databaseType}Table`);
|
|
2390
|
+
coreImports.push(
|
|
2386
2391
|
databaseType === "mysql" ? "varchar, text" : databaseType === "pg" ? "text" : "text"
|
|
2387
2392
|
);
|
|
2388
|
-
|
|
2389
|
-
|
|
2393
|
+
coreImports.push(
|
|
2394
|
+
hasBigint ? databaseType !== "sqlite" ? "bigint" : "" : ""
|
|
2395
|
+
);
|
|
2396
|
+
coreImports.push(databaseType !== "sqlite" ? "timestamp, boolean" : "");
|
|
2390
2397
|
if (databaseType === "mysql") {
|
|
2391
2398
|
const hasNonBigintNumber = Object.values(tables).some(
|
|
2392
2399
|
(table) => Object.values(table.fields).some(
|
|
@@ -2395,7 +2402,7 @@ function generateImport({
|
|
|
2395
2402
|
);
|
|
2396
2403
|
const needsInt = !!useNumberId || hasNonBigintNumber;
|
|
2397
2404
|
if (needsInt) {
|
|
2398
|
-
|
|
2405
|
+
coreImports.push("int");
|
|
2399
2406
|
}
|
|
2400
2407
|
} else if (databaseType === "pg") {
|
|
2401
2408
|
const hasNonBigintNumber = Object.values(tables).some(
|
|
@@ -2410,17 +2417,26 @@ function generateImport({
|
|
|
2410
2417
|
);
|
|
2411
2418
|
const needsInteger = hasNonBigintNumber || options.advanced?.database?.useNumberId && hasFkToId;
|
|
2412
2419
|
if (needsInteger) {
|
|
2413
|
-
|
|
2420
|
+
coreImports.push("integer");
|
|
2414
2421
|
}
|
|
2415
2422
|
} else {
|
|
2416
|
-
|
|
2423
|
+
coreImports.push("integer");
|
|
2417
2424
|
}
|
|
2418
|
-
|
|
2425
|
+
coreImports.push(useNumberId ? databaseType === "pg" ? "serial" : "" : "");
|
|
2419
2426
|
if (hasJson) {
|
|
2420
|
-
if (databaseType === "pg")
|
|
2421
|
-
if (databaseType === "mysql")
|
|
2427
|
+
if (databaseType === "pg") coreImports.push("jsonb");
|
|
2428
|
+
if (databaseType === "mysql") coreImports.push("json");
|
|
2429
|
+
}
|
|
2430
|
+
const hasSQLiteTimestamp = databaseType === "sqlite" && Object.values(tables).some(
|
|
2431
|
+
(table) => Object.values(table.fields).some(
|
|
2432
|
+
(field) => field.type === "date" && field.defaultValue && typeof field.defaultValue === "function" && field.defaultValue.toString().includes("new Date()")
|
|
2433
|
+
)
|
|
2434
|
+
);
|
|
2435
|
+
if (hasSQLiteTimestamp) {
|
|
2436
|
+
rootImports.push("sql");
|
|
2422
2437
|
}
|
|
2423
|
-
return
|
|
2438
|
+
return `${rootImports.length > 0 ? `import { ${rootImports.join(", ")} } from "drizzle-orm";
|
|
2439
|
+
` : ""}import { ${coreImports.map((x) => x.trim()).filter((x) => x !== "").join(", ")} } from "drizzle-orm/${databaseType}-core";
|
|
2424
2440
|
`;
|
|
2425
2441
|
}
|
|
2426
2442
|
function getModelName(modelName, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/cli",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.5",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"tinyexec": "^0.3.2",
|
|
57
57
|
"yocto-spinner": "^0.2.3",
|
|
58
58
|
"zod": "^4.1.5",
|
|
59
|
-
"better-auth": "1.4.0-beta.
|
|
59
|
+
"better-auth": "1.4.0-beta.5"
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
"dist"
|