@better-auth/cli 1.2.8-beta.3 → 1.2.8-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 +22 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -124,10 +124,15 @@ function stripJsonComments(jsonString) {
|
|
|
124
124
|
(m, g) => g ? "" : m
|
|
125
125
|
).replace(/,(?=\s*[}\]])/g, "");
|
|
126
126
|
}
|
|
127
|
-
function getTsconfigInfo(cwd) {
|
|
128
|
-
|
|
127
|
+
function getTsconfigInfo(cwd, flatPath) {
|
|
128
|
+
let tsConfigPath;
|
|
129
|
+
if (flatPath) {
|
|
130
|
+
tsConfigPath = flatPath;
|
|
131
|
+
} else {
|
|
132
|
+
tsConfigPath = cwd ? path.join(cwd, "tsconfig.json") : path.join("tsconfig.json");
|
|
133
|
+
}
|
|
129
134
|
try {
|
|
130
|
-
const text = fs.readFileSync(
|
|
135
|
+
const text = fs.readFileSync(tsConfigPath, "utf-8");
|
|
131
136
|
return JSON.parse(stripJsonComments(text));
|
|
132
137
|
} catch (error) {
|
|
133
138
|
throw error;
|
|
@@ -487,7 +492,15 @@ const generateDrizzleSchema = async ({
|
|
|
487
492
|
id: ${id},
|
|
488
493
|
${Object.keys(fields).map((field) => {
|
|
489
494
|
const attr = fields[field];
|
|
490
|
-
|
|
495
|
+
let type = getType(field, attr);
|
|
496
|
+
if (attr.defaultValue) {
|
|
497
|
+
if (typeof attr.defaultValue === "function") {
|
|
498
|
+
type += `.$defaultFn(${attr.defaultValue})`;
|
|
499
|
+
} else {
|
|
500
|
+
type += `.default(${attr.defaultValue})`;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return `${field}: ${type}${attr.required ? ".notNull()" : ""}${attr.unique ? ".unique()" : ""}${attr.references ? `.references(()=> ${getModelName(
|
|
491
504
|
attr.references.model,
|
|
492
505
|
adapter.options
|
|
493
506
|
)}.${attr.references.field}, { onDelete: '${attr.references.onDelete || "cascade"}' })` : ""}`;
|
|
@@ -1743,7 +1756,8 @@ const optionsSchema = z.object({
|
|
|
1743
1756
|
database: z.enum(supportedDatabases).optional(),
|
|
1744
1757
|
"skip-db": z.boolean().optional(),
|
|
1745
1758
|
"skip-plugins": z.boolean().optional(),
|
|
1746
|
-
"package-manager": z.string().optional()
|
|
1759
|
+
"package-manager": z.string().optional(),
|
|
1760
|
+
tsconfig: z.string().optional()
|
|
1747
1761
|
});
|
|
1748
1762
|
const outroText = `\u{1F973} All Done, Happy Hacking!`;
|
|
1749
1763
|
async function initAction(opts) {
|
|
@@ -1780,7 +1794,8 @@ async function initAction(opts) {
|
|
|
1780
1794
|
else targetEnvFile = "none";
|
|
1781
1795
|
let tsconfigInfo;
|
|
1782
1796
|
try {
|
|
1783
|
-
|
|
1797
|
+
const tsconfigPath = options.tsconfig !== void 0 ? path.resolve(cwd, options.tsconfig) : path.join(cwd, "tsconfig.json");
|
|
1798
|
+
tsconfigInfo = await getTsconfigInfo(cwd, tsconfigPath);
|
|
1784
1799
|
} catch (error) {
|
|
1785
1800
|
log.error(`\u274C Couldn't read your tsconfig.json file. (dir: ${cwd})`);
|
|
1786
1801
|
console.error(error);
|
|
@@ -2347,7 +2362,7 @@ async function initAction(opts) {
|
|
|
2347
2362
|
const init = new Command("init").option("-c, --cwd <cwd>", "The working directory.", process.cwd()).option(
|
|
2348
2363
|
"--config <config>",
|
|
2349
2364
|
"The path to the auth configuration file. defaults to the first `auth.ts` file found."
|
|
2350
|
-
).option("--skip-db", "Skip the database setup.").option("--skip-plugins", "Skip the plugins setup.").option(
|
|
2365
|
+
).option("--tsconfig <tsconfig>", "The path to the tsconfig file.").option("--skip-db", "Skip the database setup.").option("--skip-plugins", "Skip the plugins setup.").option(
|
|
2351
2366
|
"--package-manager <package-manager>",
|
|
2352
2367
|
"The package manager you want to use."
|
|
2353
2368
|
).action(initAction);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/cli",
|
|
3
|
-
"version": "1.2.8-beta.
|
|
3
|
+
"version": "1.2.8-beta.5",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"tinyexec": "^0.3.1",
|
|
47
47
|
"yocto-spinner": "^0.1.1",
|
|
48
48
|
"zod": "^3.23.8",
|
|
49
|
-
"better-auth": "1.2.8-beta.
|
|
49
|
+
"better-auth": "1.2.8-beta.5"
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
52
|
"dist"
|