@better-auth/cli 1.3.8-beta.9 → 1.3.9-beta.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/index.mjs +33 -3
- package/package.json +20 -20
package/dist/index.mjs
CHANGED
|
@@ -2217,7 +2217,7 @@ function convertToSnakeCase(str, camelCase) {
|
|
|
2217
2217
|
if (camelCase) {
|
|
2218
2218
|
return str;
|
|
2219
2219
|
}
|
|
2220
|
-
return str.replace(/[A-Z]/g, (
|
|
2220
|
+
return str.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").toLowerCase();
|
|
2221
2221
|
}
|
|
2222
2222
|
const generateDrizzleSchema = async ({
|
|
2223
2223
|
options,
|
|
@@ -2323,7 +2323,11 @@ const generateDrizzleSchema = async ({
|
|
|
2323
2323
|
let type = getType(field, attr);
|
|
2324
2324
|
if (attr.defaultValue !== null && typeof attr.defaultValue !== "undefined") {
|
|
2325
2325
|
if (typeof attr.defaultValue === "function") {
|
|
2326
|
-
type
|
|
2326
|
+
if (attr.type === "date" && attr.defaultValue.toString().includes("new Date()")) {
|
|
2327
|
+
type += `.defaultNow()`;
|
|
2328
|
+
} else {
|
|
2329
|
+
type += `.$defaultFn(${attr.defaultValue})`;
|
|
2330
|
+
}
|
|
2327
2331
|
} else if (typeof attr.defaultValue === "string") {
|
|
2328
2332
|
type += `.default("${attr.defaultValue}")`;
|
|
2329
2333
|
} else {
|
|
@@ -2526,6 +2530,29 @@ const generatePrismaSchema = async ({
|
|
|
2526
2530
|
if (attr.unique) {
|
|
2527
2531
|
builder.model(modelName).blockAttribute(`unique([${fieldName}])`);
|
|
2528
2532
|
}
|
|
2533
|
+
if (attr.defaultValue !== void 0) {
|
|
2534
|
+
if (field === "createdAt") {
|
|
2535
|
+
fieldBuilder.attribute("default(now())");
|
|
2536
|
+
} else if (typeof attr.defaultValue === "boolean") {
|
|
2537
|
+
fieldBuilder.attribute(`default(${attr.defaultValue})`);
|
|
2538
|
+
} else if (typeof attr.defaultValue === "function") {
|
|
2539
|
+
const defaultVal = attr.defaultValue();
|
|
2540
|
+
if (defaultVal instanceof Date) {
|
|
2541
|
+
fieldBuilder.attribute("default(now())");
|
|
2542
|
+
} else {
|
|
2543
|
+
console.warn(
|
|
2544
|
+
`Warning: Unsupported default function for field ${fieldName} in model ${modelName}. Please adjust manually.`
|
|
2545
|
+
);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
if (field === "updatedAt" && attr.onUpdate) {
|
|
2550
|
+
fieldBuilder.attribute("updatedAt");
|
|
2551
|
+
} else if (attr.onUpdate) {
|
|
2552
|
+
console.warn(
|
|
2553
|
+
`Warning: 'onUpdate' is only supported on 'updatedAt' fields. Please adjust manually for field ${fieldName} in model ${modelName}.`
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2529
2556
|
if (attr.references) {
|
|
2530
2557
|
const referencedOriginalModelName = attr.references.model;
|
|
2531
2558
|
const referencedCustomModelName = tables[referencedOriginalModelName]?.modelName || referencedOriginalModelName;
|
|
@@ -3425,4 +3452,7 @@ async function main() {
|
|
|
3425
3452
|
program.addCommand(init).addCommand(migrate).addCommand(generate).addCommand(generateSecret).addCommand(info).addCommand(login).version(packageInfo.version || "1.1.2").description("Better Auth CLI").action(() => program.help());
|
|
3426
3453
|
program.parse();
|
|
3427
3454
|
}
|
|
3428
|
-
main()
|
|
3455
|
+
main().catch((error) => {
|
|
3456
|
+
console.error("Error running Better Auth CLI:", error);
|
|
3457
|
+
process.exit(1);
|
|
3458
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9-beta.1",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -26,35 +26,35 @@
|
|
|
26
26
|
"exports": "./dist/index.mjs",
|
|
27
27
|
"bin": "./dist/index.mjs",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"tsx": "^4.20.
|
|
29
|
+
"tsx": "^4.20.5",
|
|
30
30
|
"typescript": "^5.9.2",
|
|
31
|
-
"unbuild": "^3.
|
|
31
|
+
"unbuild": "^3.6.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.
|
|
35
|
-
"@babel/preset-react": "^7.
|
|
36
|
-
"@babel/preset-typescript": "^7.
|
|
37
|
-
"@clack/prompts": "^0.
|
|
38
|
-
"@mrleebo/prisma-ast": "^0.
|
|
34
|
+
"@babel/core": "^7.28.3",
|
|
35
|
+
"@babel/preset-react": "^7.27.1",
|
|
36
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
37
|
+
"@clack/prompts": "^0.11.0",
|
|
38
|
+
"@mrleebo/prisma-ast": "^0.13.0",
|
|
39
39
|
"@prisma/client": "^5.22.0",
|
|
40
|
-
"@types/better-sqlite3": "^7.6.
|
|
40
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
41
41
|
"@types/prompts": "^2.4.9",
|
|
42
|
-
"better-sqlite3": "^
|
|
42
|
+
"better-sqlite3": "^12.2.0",
|
|
43
43
|
"c12": "^3.2.0",
|
|
44
|
-
"chalk": "^5.
|
|
44
|
+
"chalk": "^5.6.0",
|
|
45
45
|
"commander": "^12.1.0",
|
|
46
|
-
"dotenv": "^16.
|
|
46
|
+
"dotenv": "^16.6.1",
|
|
47
47
|
"drizzle-orm": "^0.33.0",
|
|
48
|
-
"get-tsconfig": "^4.
|
|
49
|
-
"open": "^10.
|
|
50
|
-
"prettier": "^3.
|
|
48
|
+
"get-tsconfig": "^4.10.1",
|
|
49
|
+
"open": "^10.2.0",
|
|
50
|
+
"prettier": "^3.6.2",
|
|
51
51
|
"prisma": "^5.22.0",
|
|
52
52
|
"prompts": "^2.4.2",
|
|
53
|
-
"semver": "^7.7.
|
|
54
|
-
"tinyexec": "^0.3.
|
|
55
|
-
"yocto-spinner": "^0.
|
|
56
|
-
"zod": "^4.
|
|
57
|
-
"better-auth": "1.3.
|
|
53
|
+
"semver": "^7.7.2",
|
|
54
|
+
"tinyexec": "^0.3.2",
|
|
55
|
+
"yocto-spinner": "^0.2.3",
|
|
56
|
+
"zod": "^4.1.5",
|
|
57
|
+
"better-auth": "1.3.9-beta.1"
|
|
58
58
|
},
|
|
59
59
|
"files": [
|
|
60
60
|
"dist"
|