auth 1.7.0-rc.4 → 1.7.0-rc.6
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/api.d.mts +1 -0
- package/dist/api.mjs +1 -1
- package/dist/index.mjs +55 -56
- package/package.json +6 -6
- package/dist/index.d.mts +0 -5
package/dist/api.d.mts
CHANGED
package/dist/api.mjs
CHANGED
|
@@ -35,7 +35,7 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
|
|
|
35
35
|
if (databaseType === "pg" && schemaName) {
|
|
36
36
|
schemaVarName = `${toValidIdentifier(schemaName)}Schema`;
|
|
37
37
|
if (schemaVarName === "pgSchema") schemaVarName = "pgCustomSchema";
|
|
38
|
-
code += `\
|
|
38
|
+
code += `\nexport const ${schemaVarName} = pgSchema(${JSON.stringify(schemaName)});\n\n`;
|
|
39
39
|
}
|
|
40
40
|
const getModelName = initGetModelName({
|
|
41
41
|
schema: tables,
|
package/dist/index.mjs
CHANGED
|
@@ -865,7 +865,7 @@ function filterPublicEnv(publicPrefix, privatePrefix) {
|
|
|
865
865
|
return Object.fromEntries(Object.entries(process.env).filter(([k]) => k.startsWith(publicPrefix) && (privatePrefix === "" || !k.startsWith(privatePrefix))));
|
|
866
866
|
}
|
|
867
867
|
const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
868
|
-
const reserved =
|
|
868
|
+
const reserved = new Set([
|
|
869
869
|
"do",
|
|
870
870
|
"if",
|
|
871
871
|
"in",
|
|
@@ -1085,7 +1085,7 @@ function resolveWithMatchers(specifier, matchers) {
|
|
|
1085
1085
|
* a jiti-side preprocessor artifact observed in the AST; revisit on jiti
|
|
1086
1086
|
* major version bumps (the regression suite catches a rename but not the why).
|
|
1087
1087
|
*/
|
|
1088
|
-
const LOADER_IDENTIFIERS =
|
|
1088
|
+
const LOADER_IDENTIFIERS = new Set([
|
|
1089
1089
|
"require",
|
|
1090
1090
|
"import",
|
|
1091
1091
|
"jitiImport"
|
|
@@ -1381,7 +1381,7 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
|
|
|
1381
1381
|
if (databaseType === "pg" && schemaName) {
|
|
1382
1382
|
schemaVarName = `${toValidIdentifier(schemaName)}Schema`;
|
|
1383
1383
|
if (schemaVarName === "pgSchema") schemaVarName = "pgCustomSchema";
|
|
1384
|
-
code += `\
|
|
1384
|
+
code += `\nexport const ${schemaVarName} = pgSchema(${JSON.stringify(schemaName)});\n\n`;
|
|
1385
1385
|
}
|
|
1386
1386
|
const getModelName = initGetModelName({
|
|
1387
1387
|
schema: tables,
|
|
@@ -2954,6 +2954,9 @@ function installDependencies({ dependencies, packageManager, cwd, type = "prod",
|
|
|
2954
2954
|
});
|
|
2955
2955
|
}
|
|
2956
2956
|
//#endregion
|
|
2957
|
+
//#region src/version.ts
|
|
2958
|
+
const cliVersion = "1.7.0-rc.6";
|
|
2959
|
+
//#endregion
|
|
2957
2960
|
//#region src/commands/init/configs/frameworks.config.ts
|
|
2958
2961
|
const FRAMEWORKS = [
|
|
2959
2962
|
{
|
|
@@ -5363,12 +5366,11 @@ const getAuthPluginsCode = async ({ plugins, options = {}, installDependency })
|
|
|
5363
5366
|
const getArguments = await getArgumentsPrompt(options, plugins, "auth");
|
|
5364
5367
|
const pluginsCode = [];
|
|
5365
5368
|
for (const plugin of plugins) {
|
|
5366
|
-
const
|
|
5367
|
-
const args = convertArgumentsCodeToStringArray(argumentsCode);
|
|
5369
|
+
const args = convertArgumentsCodeToStringArray(await buildArgumentsCode(plugin.auth.arguments, getArguments, plugin.auth.function));
|
|
5368
5370
|
removeTrailingUndefined(args);
|
|
5369
5371
|
pluginsCode.push(`${plugin.auth.function}(${args.join(", ")})`);
|
|
5370
|
-
const dependencies =
|
|
5371
|
-
const devDependencies =
|
|
5372
|
+
const dependencies = new Set([...plugin.dependencies || [], ...plugin.auth.dependencies || []]);
|
|
5373
|
+
const devDependencies = new Set([...plugin.devDependencies || [], ...plugin.auth.devDependencies || []]);
|
|
5372
5374
|
if (dependencies.size > 0) await installDependency([...dependencies]);
|
|
5373
5375
|
if (devDependencies.size > 0) await installDependency([...devDependencies], "dev");
|
|
5374
5376
|
}
|
|
@@ -5382,12 +5384,11 @@ const getAuthClientPluginsCode = async ({ plugins, options = {}, installDependen
|
|
|
5382
5384
|
const pluginsCode = [];
|
|
5383
5385
|
for (const plugin of pluginsWithClient) {
|
|
5384
5386
|
if (!plugin.authClient) continue;
|
|
5385
|
-
const
|
|
5386
|
-
const args = convertArgumentsCodeToStringArray(argumentsCode);
|
|
5387
|
+
const args = convertArgumentsCodeToStringArray(await buildArgumentsCode(plugin.authClient.arguments, getArguments, plugin.authClient.function));
|
|
5387
5388
|
removeTrailingUndefined(args);
|
|
5388
5389
|
pluginsCode.push(`${plugin.authClient.function}(${args.join(", ")})`);
|
|
5389
|
-
const dependencies =
|
|
5390
|
-
const devDependencies =
|
|
5390
|
+
const dependencies = new Set([...plugin.dependencies || [], ...plugin.authClient.dependencies || []]);
|
|
5391
|
+
const devDependencies = new Set([...plugin.devDependencies || [], ...plugin.authClient.devDependencies || []]);
|
|
5391
5392
|
if (dependencies.size > 0) await installDependency([...dependencies]);
|
|
5392
5393
|
if (devDependencies.size > 0) await installDependency([...devDependencies], "dev");
|
|
5393
5394
|
}
|
|
@@ -6560,10 +6561,9 @@ export const auth = betterAuth({
|
|
|
6560
6561
|
}
|
|
6561
6562
|
databaseChoice = dbChoice || null;
|
|
6562
6563
|
if (databaseChoice === "yes") {
|
|
6563
|
-
const availableORMs = getAvailableORMs();
|
|
6564
6564
|
const selectedOption = await select({
|
|
6565
6565
|
message: `Select the database you want to use:`,
|
|
6566
|
-
options:
|
|
6566
|
+
options: getAvailableORMs().map((opt) => ({
|
|
6567
6567
|
value: opt.adapter || opt.value,
|
|
6568
6568
|
label: opt.label
|
|
6569
6569
|
}))
|
|
@@ -6597,10 +6597,9 @@ export const auth = betterAuth({
|
|
|
6597
6597
|
database = sqliteVariants;
|
|
6598
6598
|
} else if (isDirectAdapter(selectedOption)) database = selectedOption;
|
|
6599
6599
|
else {
|
|
6600
|
-
const availableDialects = getDialectsForORM(selectedOption);
|
|
6601
6600
|
const selectedDialect = await select({
|
|
6602
6601
|
message: `Select the database dialect:`,
|
|
6603
|
-
options:
|
|
6602
|
+
options: getDialectsForORM(selectedOption).map((d) => ({
|
|
6604
6603
|
value: d.adapter,
|
|
6605
6604
|
label: d.label
|
|
6606
6605
|
}))
|
|
@@ -6618,7 +6617,7 @@ export const auth = betterAuth({
|
|
|
6618
6617
|
const { shouldInstallDeps } = await prompts({
|
|
6619
6618
|
type: "confirm",
|
|
6620
6619
|
name: "shouldInstallDeps",
|
|
6621
|
-
message: `Would you like to install the following dependencies: ${[
|
|
6620
|
+
message: `Would you like to install the following dependencies: ${[...new Set([...databaseConfig.dependencies, ...databaseConfig.devDependencies || []])].map((x) => chalk.cyan(x)).join(", ")}?`,
|
|
6622
6621
|
initial: true
|
|
6623
6622
|
});
|
|
6624
6623
|
if (isCancel(shouldInstallDeps)) {
|
|
@@ -7402,22 +7401,37 @@ const generateSecret = new Command("secret").action(() => {
|
|
|
7402
7401
|
${chalk.gray("# Auth Secret") + chalk.green(`\nBETTER_AUTH_SECRET=${secret}`)}`);
|
|
7403
7402
|
});
|
|
7404
7403
|
//#endregion
|
|
7405
|
-
//#region src/utils/fetch-latest-version.ts
|
|
7406
|
-
async function fetchLatestVersion(packageName) {
|
|
7407
|
-
const encoded = packageName.startsWith("@") ? `@${encodeURIComponent(packageName.slice(1))}` : encodeURIComponent(packageName);
|
|
7408
|
-
try {
|
|
7409
|
-
const response = await fetch(`https://registry.npmjs.org/${encoded}/latest`);
|
|
7410
|
-
if (!response.ok) return null;
|
|
7411
|
-
return (await response.json()).version ?? null;
|
|
7412
|
-
} catch {
|
|
7413
|
-
return null;
|
|
7414
|
-
}
|
|
7415
|
-
}
|
|
7416
|
-
//#endregion
|
|
7417
7404
|
//#region src/commands/upgrade.ts
|
|
7418
|
-
|
|
7419
|
-
|
|
7405
|
+
const fixedReleaseGroup = [[
|
|
7406
|
+
"better-auth",
|
|
7407
|
+
"@better-auth/core",
|
|
7408
|
+
"auth",
|
|
7409
|
+
"@better-auth/api-key",
|
|
7410
|
+
"@better-auth/cimd",
|
|
7411
|
+
"@better-auth/drizzle-adapter",
|
|
7412
|
+
"@better-auth/electron",
|
|
7413
|
+
"@better-auth/expo",
|
|
7414
|
+
"@better-auth/i18n",
|
|
7415
|
+
"@better-auth/kysely-adapter",
|
|
7416
|
+
"@better-auth/mcp",
|
|
7417
|
+
"@better-auth/memory-adapter",
|
|
7418
|
+
"@better-auth/mongo-adapter",
|
|
7419
|
+
"@better-auth/oauth-provider",
|
|
7420
|
+
"@better-auth/passkey",
|
|
7421
|
+
"@better-auth/prisma-adapter",
|
|
7422
|
+
"@better-auth/redis-storage",
|
|
7423
|
+
"@better-auth/scim",
|
|
7424
|
+
"@better-auth/sso",
|
|
7425
|
+
"@better-auth/stripe",
|
|
7426
|
+
"@better-auth/telemetry",
|
|
7427
|
+
"@better-auth/test-utils"
|
|
7428
|
+
]].find((group) => group.includes("better-auth"));
|
|
7429
|
+
if (!fixedReleaseGroup) throw new Error("The Better Auth fixed release group is not configured.");
|
|
7430
|
+
const SYNCHRONIZED_BETTER_AUTH_PACKAGES = new Set(fixedReleaseGroup.filter((name) => name !== "auth"));
|
|
7431
|
+
function isSynchronizedBetterAuthPackage(name) {
|
|
7432
|
+
return SYNCHRONIZED_BETTER_AUTH_PACKAGES.has(name);
|
|
7420
7433
|
}
|
|
7434
|
+
/** @internal */
|
|
7421
7435
|
async function upgradeAction(opts) {
|
|
7422
7436
|
const options = z.object({
|
|
7423
7437
|
cwd: z.string(),
|
|
@@ -7438,12 +7452,12 @@ async function upgradeAction(opts) {
|
|
|
7438
7452
|
const deps = packageJson.dependencies ?? {};
|
|
7439
7453
|
const devDeps = packageJson.devDependencies ?? {};
|
|
7440
7454
|
const candidates = [];
|
|
7441
|
-
for (const [name, version] of Object.entries(deps)) if (
|
|
7455
|
+
for (const [name, version] of Object.entries(deps)) if (isSynchronizedBetterAuthPackage(name) && !version.startsWith("workspace:")) candidates.push({
|
|
7442
7456
|
name,
|
|
7443
7457
|
current: version,
|
|
7444
7458
|
depType: "prod"
|
|
7445
7459
|
});
|
|
7446
|
-
for (const [name, version] of Object.entries(devDeps)) if (
|
|
7460
|
+
for (const [name, version] of Object.entries(devDeps)) if (isSynchronizedBetterAuthPackage(name) && !version.startsWith("workspace:")) candidates.push({
|
|
7447
7461
|
name,
|
|
7448
7462
|
current: version,
|
|
7449
7463
|
depType: "dev"
|
|
@@ -7453,22 +7467,13 @@ async function upgradeAction(opts) {
|
|
|
7453
7467
|
return;
|
|
7454
7468
|
}
|
|
7455
7469
|
const spinner = yoctoSpinner({ text: "checking for updates..." }).start();
|
|
7456
|
-
const results = await Promise.allSettled(candidates.map(async (c) => {
|
|
7457
|
-
const latest = await fetchLatestVersion(c.name);
|
|
7458
|
-
return {
|
|
7459
|
-
...c,
|
|
7460
|
-
latest
|
|
7461
|
-
};
|
|
7462
|
-
}));
|
|
7463
7470
|
const upgrades = [];
|
|
7464
|
-
for (const
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
const coerced = semver.coerce(current);
|
|
7468
|
-
if (coerced && semver.lt(coerced, latest)) upgrades.push({
|
|
7471
|
+
for (const { name, current, depType } of candidates) {
|
|
7472
|
+
const currentVersion = semver.minVersion(current);
|
|
7473
|
+
if (currentVersion && semver.lt(currentVersion, cliVersion)) upgrades.push({
|
|
7469
7474
|
name,
|
|
7470
7475
|
current,
|
|
7471
|
-
|
|
7476
|
+
target: cliVersion,
|
|
7472
7477
|
depType
|
|
7473
7478
|
});
|
|
7474
7479
|
}
|
|
@@ -7478,7 +7483,7 @@ async function upgradeAction(opts) {
|
|
|
7478
7483
|
return;
|
|
7479
7484
|
}
|
|
7480
7485
|
console.log(`\nThe following packages can be upgraded:\n`);
|
|
7481
|
-
for (const u of upgrades) console.log(` ${chalk.cyan(u.name)} ${chalk.gray(u.current)} ${chalk.white("→")} ${chalk.green(u.
|
|
7486
|
+
for (const u of upgrades) console.log(` ${chalk.cyan(u.name)} ${chalk.gray(u.current)} ${chalk.white("→")} ${chalk.green(u.target)}`);
|
|
7482
7487
|
console.log();
|
|
7483
7488
|
let confirmed = options.yes;
|
|
7484
7489
|
if (!confirmed) confirmed = (await prompts({
|
|
@@ -7492,8 +7497,8 @@ async function upgradeAction(opts) {
|
|
|
7492
7497
|
return;
|
|
7493
7498
|
}
|
|
7494
7499
|
const { packageManager } = await detectPackageManager(cwd, packageJson);
|
|
7495
|
-
const prodUpgrades = upgrades.filter((u) => u.depType === "prod").map((u) => `${u.name}@${u.
|
|
7496
|
-
const devUpgrades = upgrades.filter((u) => u.depType === "dev").map((u) => `${u.name}@${u.
|
|
7500
|
+
const prodUpgrades = upgrades.filter((u) => u.depType === "prod").map((u) => `${u.name}@${u.target}`);
|
|
7501
|
+
const devUpgrades = upgrades.filter((u) => u.depType === "dev").map((u) => `${u.name}@${u.target}`);
|
|
7497
7502
|
const installSpinner = yoctoSpinner({ text: "installing updates..." }).start();
|
|
7498
7503
|
try {
|
|
7499
7504
|
if (prodUpgrades.length > 0) await installDependencies({
|
|
@@ -7516,19 +7521,13 @@ async function upgradeAction(opts) {
|
|
|
7516
7521
|
process.exit(1);
|
|
7517
7522
|
}
|
|
7518
7523
|
}
|
|
7519
|
-
const upgrade = new Command("upgrade").description("Upgrade better-auth packages to
|
|
7524
|
+
const upgrade = new Command("upgrade").description("Upgrade better-auth packages to the running CLI version").option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd()).option("-y, --yes", "automatically accept and upgrade without prompting", false).action(upgradeAction);
|
|
7520
7525
|
//#endregion
|
|
7521
7526
|
//#region src/index.ts
|
|
7522
7527
|
process.on("SIGINT", () => process.exit(0));
|
|
7523
7528
|
process.on("SIGTERM", () => process.exit(0));
|
|
7524
|
-
let cliVersion = "1.1.2";
|
|
7525
7529
|
async function main() {
|
|
7526
7530
|
const program = new Command("better-auth");
|
|
7527
|
-
let packageInfo = {};
|
|
7528
|
-
try {
|
|
7529
|
-
packageInfo = await getPackageInfo();
|
|
7530
|
-
cliVersion = packageInfo.version || "1.1.2";
|
|
7531
|
-
} catch {}
|
|
7532
7531
|
program.addCommand(ai).addCommand(createAdmin).addCommand(init).addCommand(migrate).addCommand(generate).addCommand(generateSecret).addCommand(info).addCommand(login).addCommand(logout).addCommand(mcp).addCommand(upgrade).version(cliVersion).description("Better Auth CLI").action(() => program.help());
|
|
7533
7532
|
program.parse();
|
|
7534
7533
|
}
|
|
@@ -7537,4 +7536,4 @@ main().catch((error) => {
|
|
|
7537
7536
|
process.exit(1);
|
|
7538
7537
|
});
|
|
7539
7538
|
//#endregion
|
|
7540
|
-
export {
|
|
7539
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.6",
|
|
4
4
|
"description": "The CLI for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"semver": "^7.8.4",
|
|
65
65
|
"yocto-spinner": "^1.2.0",
|
|
66
66
|
"zod": "^4.3.6",
|
|
67
|
-
"@better-auth/core": "1.7.0-rc.
|
|
68
|
-
"@better-auth/telemetry": "1.7.0-rc.
|
|
69
|
-
"better-auth": "1.7.0-rc.
|
|
67
|
+
"@better-auth/core": "1.7.0-rc.6",
|
|
68
|
+
"@better-auth/telemetry": "1.7.0-rc.6",
|
|
69
|
+
"better-auth": "1.7.0-rc.6"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
"@types/semver": "^7.7.1",
|
|
75
75
|
"better-sqlite3": "^12.11.1",
|
|
76
76
|
"memfs": "^4.56.10",
|
|
77
|
-
"tsdown": "0.
|
|
77
|
+
"tsdown": "0.21.10",
|
|
78
78
|
"tsx": "^4.21.0",
|
|
79
79
|
"type-fest": "^5.7.0",
|
|
80
80
|
"typescript": "^6.0.3",
|
|
81
|
-
"@better-auth/passkey": "1.7.0-rc.
|
|
81
|
+
"@better-auth/passkey": "1.7.0-rc.6"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsdown",
|