@better-auth/cli 1.3.0-beta.8 → 1.3.0
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 +16 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
4
|
import fs$1, { existsSync } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import yoctoSpinner from 'yocto-spinner';
|
|
@@ -398,7 +398,10 @@ const migrate = new Command("migrate").option(
|
|
|
398
398
|
false
|
|
399
399
|
).action(migrateAction);
|
|
400
400
|
|
|
401
|
-
function convertToSnakeCase(str) {
|
|
401
|
+
function convertToSnakeCase(str, camelCase) {
|
|
402
|
+
if (camelCase) {
|
|
403
|
+
return str;
|
|
404
|
+
}
|
|
402
405
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
403
406
|
}
|
|
404
407
|
const generateDrizzleSchema = async ({
|
|
@@ -423,15 +426,20 @@ const generateDrizzleSchema = async ({
|
|
|
423
426
|
`Database provider type is undefined during Drizzle schema generation. Please define a \`provider\` in the Drizzle adapter config. Read more at https://better-auth.com/docs/adapters/drizzle`
|
|
424
427
|
);
|
|
425
428
|
}
|
|
426
|
-
name = convertToSnakeCase(name);
|
|
429
|
+
name = convertToSnakeCase(name, adapter.options?.camelCase);
|
|
427
430
|
if (field.references?.field === "id") {
|
|
428
431
|
if (options.advanced?.database?.useNumberId) {
|
|
429
432
|
if (databaseType === "pg") {
|
|
430
|
-
return `
|
|
433
|
+
return `integer('${name}')`;
|
|
431
434
|
} else if (databaseType === "mysql") {
|
|
432
|
-
return `int('${name}')
|
|
435
|
+
return `int('${name}')`;
|
|
433
436
|
} else {
|
|
434
|
-
return `integer(
|
|
437
|
+
return `integer('${name}')`;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (field.references.field) {
|
|
441
|
+
if (databaseType === "mysql") {
|
|
442
|
+
return `varchar('${name}', { length: 36 })`;
|
|
435
443
|
}
|
|
436
444
|
}
|
|
437
445
|
return `text('${name}')`;
|
|
@@ -491,7 +499,8 @@ const generateDrizzleSchema = async ({
|
|
|
491
499
|
}
|
|
492
500
|
}
|
|
493
501
|
const schema = `export const ${modelName} = ${databaseType}Table("${convertToSnakeCase(
|
|
494
|
-
modelName
|
|
502
|
+
modelName,
|
|
503
|
+
adapter.options?.camelCase
|
|
495
504
|
)}", {
|
|
496
505
|
id: ${id},
|
|
497
506
|
${Object.keys(fields).map((field) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/cli",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"tinyexec": "^0.3.1",
|
|
56
56
|
"yocto-spinner": "^0.1.1",
|
|
57
57
|
"zod": "^3.23.8",
|
|
58
|
-
"better-auth": "1.3.0
|
|
58
|
+
"better-auth": "1.3.0"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist"
|