@better-auth/cli 1.4.4-beta.3 → 1.4.6-beta.2
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 -11
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -276,6 +276,24 @@ const generateMigrations = async ({ options, file }) => {
|
|
|
276
276
|
};
|
|
277
277
|
};
|
|
278
278
|
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/utils/get-package-info.ts
|
|
281
|
+
function getPackageInfo(cwd) {
|
|
282
|
+
const packageJsonPath = cwd ? path.join(cwd, "package.json") : path.join("package.json");
|
|
283
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
284
|
+
}
|
|
285
|
+
function getPrismaVersion(cwd) {
|
|
286
|
+
try {
|
|
287
|
+
const packageInfo = getPackageInfo(cwd);
|
|
288
|
+
const prismaVersion = packageInfo.dependencies?.prisma || packageInfo.devDependencies?.prisma || packageInfo.dependencies?.["@prisma/client"] || packageInfo.devDependencies?.["@prisma/client"];
|
|
289
|
+
if (!prismaVersion) return null;
|
|
290
|
+
const match = prismaVersion.match(/(\d+)/);
|
|
291
|
+
return match ? parseInt(match[1], 10) : null;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
279
297
|
//#endregion
|
|
280
298
|
//#region src/generators/prisma.ts
|
|
281
299
|
const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
@@ -293,7 +311,15 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
293
311
|
});
|
|
294
312
|
let schemaPrisma = "";
|
|
295
313
|
if (schemaPrismaExist) schemaPrisma = await fs$1.readFile(path.join(process.cwd(), filePath), "utf-8");
|
|
296
|
-
else schemaPrisma = getNewPrisma(provider);
|
|
314
|
+
else schemaPrisma = getNewPrisma(provider, process.cwd());
|
|
315
|
+
const prismaVersion = getPrismaVersion(process.cwd());
|
|
316
|
+
if (prismaVersion && prismaVersion >= 7 && schemaPrismaExist) schemaPrisma = produceSchema(schemaPrisma, (builder) => {
|
|
317
|
+
const generator = builder.findByType("generator", { name: "client" });
|
|
318
|
+
if (generator && generator.properties) {
|
|
319
|
+
const providerProp = generator.properties.find((prop) => prop.type === "assignment" && prop.key === "provider");
|
|
320
|
+
if (providerProp && providerProp.value === "\"prisma-client-js\"") providerProp.value = "\"prisma-client\"";
|
|
321
|
+
}
|
|
322
|
+
});
|
|
297
323
|
const manyToManyRelations = /* @__PURE__ */ new Map();
|
|
298
324
|
for (const table in tables) {
|
|
299
325
|
const fields = tables[table]?.fields;
|
|
@@ -470,14 +496,17 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
|
|
|
470
496
|
overwrite: schemaPrismaExist && schemaChanged
|
|
471
497
|
};
|
|
472
498
|
};
|
|
473
|
-
const getNewPrisma = (provider) =>
|
|
474
|
-
|
|
499
|
+
const getNewPrisma = (provider, cwd) => {
|
|
500
|
+
const prismaVersion = getPrismaVersion(cwd);
|
|
501
|
+
return `generator client {
|
|
502
|
+
provider = "${prismaVersion && prismaVersion >= 7 ? "prisma-client" : "prisma-client-js"}"
|
|
475
503
|
}
|
|
476
|
-
|
|
504
|
+
|
|
477
505
|
datasource db {
|
|
478
506
|
provider = "${provider}"
|
|
479
507
|
url = ${provider === "sqlite" ? `"file:./dev.db"` : `env("DATABASE_URL")`}
|
|
480
508
|
}`;
|
|
509
|
+
};
|
|
481
510
|
|
|
482
511
|
//#endregion
|
|
483
512
|
//#region src/generators/index.ts
|
|
@@ -1028,13 +1057,6 @@ async function generateAction(opts) {
|
|
|
1028
1057
|
}
|
|
1029
1058
|
const generate = new Command("generate").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("--config <config>", "the path to the configuration file. defaults to the first configuration file found.").option("--output <output>", "the file to output to the generated schema").option("-y, --yes", "automatically answer yes to all prompts", false).option("--y", "(deprecated) same as --yes", false).action(generateAction);
|
|
1030
1059
|
|
|
1031
|
-
//#endregion
|
|
1032
|
-
//#region src/utils/get-package-info.ts
|
|
1033
|
-
function getPackageInfo(cwd) {
|
|
1034
|
-
const packageJsonPath = cwd ? path.join(cwd, "package.json") : path.join("package.json");
|
|
1035
|
-
return JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
1060
|
//#endregion
|
|
1039
1061
|
//#region src/commands/info.ts
|
|
1040
1062
|
function getSystemInfo() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/cli",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The CLI for Better Auth",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"tsx": "^4.20.6",
|
|
38
38
|
"type-fest": "^5.2.0",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
|
-
"@better-auth/passkey": "1.4.
|
|
40
|
+
"@better-auth/passkey": "1.4.6-beta.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/core": "^7.28.4",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"semver": "^7.7.2",
|
|
63
63
|
"yocto-spinner": "^0.2.3",
|
|
64
64
|
"zod": "^4.1.12",
|
|
65
|
-
"better-auth": "1.4.
|
|
66
|
-
"
|
|
65
|
+
"@better-auth/core": "1.4.6-beta.2",
|
|
66
|
+
"better-auth": "1.4.6-beta.2"
|
|
67
67
|
},
|
|
68
68
|
"files": [
|
|
69
69
|
"dist"
|