@better-auth/cli 1.5.0-beta.6 → 1.5.0-beta.7

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.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as generateKyselySchema, n as generateSchema, o as generateDrizzleSchema, r as generatePrismaSchema, t as adapters } from "./generators-CbhkbjDG.mjs";
1
+ import { a as generateKyselySchema, n as generateSchema, o as generateDrizzleSchema, r as generatePrismaSchema, t as adapters } from "./generators-CHN0StQX.mjs";
2
2
 
3
3
  export { adapters, generateDrizzleSchema, generateKyselySchema, generatePrismaSchema, generateSchema };
@@ -106,10 +106,10 @@ const generateDrizzleSchema = async ({ options, file, adapter }) => {
106
106
  else if (databaseType === "mysql") id = `varchar('id', { length: 36 }).primaryKey()`;
107
107
  else if (databaseType === "pg") id = `text('id').primaryKey()`;
108
108
  else id = `text('id').primaryKey()`;
109
- let indexes = [];
109
+ const indexes = [];
110
110
  const assignIndexes = (indexes$1) => {
111
111
  if (!indexes$1.length) return "";
112
- let code$1 = [`, (table) => [`];
112
+ const code$1 = [`, (table) => [`];
113
113
  for (const index of indexes$1) code$1.push(` ${index.type}("${index.name}").on(table.${index.on}),`);
114
114
  code$1.push(`]`);
115
115
  return code$1.join("\n");
@@ -444,7 +444,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
444
444
  fieldBuilder.attribute(`default("${JSON.stringify(attr.defaultValue).replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}")`);
445
445
  continue;
446
446
  }
447
- let jsonArray = [];
447
+ const jsonArray = [];
448
448
  for (const value of attr.defaultValue) jsonArray.push(value);
449
449
  fieldBuilder.attribute(`default("${JSON.stringify(jsonArray).replace(/"/g, "\\\"")}")`);
450
450
  continue;
@@ -453,11 +453,11 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
453
453
  fieldBuilder.attribute(`default([])`);
454
454
  continue;
455
455
  } else if (typeof attr.defaultValue[0] === "string" && attr.type === "string[]") {
456
- let valueArray = [];
456
+ const valueArray = [];
457
457
  for (const value of attr.defaultValue) valueArray.push(JSON.stringify(value));
458
458
  fieldBuilder.attribute(`default([${valueArray}])`);
459
459
  } else if (typeof attr.defaultValue[0] === "number") {
460
- let valueArray = [];
460
+ const valueArray = [];
461
461
  for (const value of attr.defaultValue) valueArray.push(`${value}`);
462
462
  fieldBuilder.attribute(`default([${valueArray}])`);
463
463
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as getPackageInfo, n as generateSchema } from "./generators-CbhkbjDG.mjs";
2
+ import { i as getPackageInfo, n as generateSchema } from "./generators-CHN0StQX.mjs";
3
3
  import { Command } from "commander";
4
4
  import * as fs$2 from "node:fs";
5
5
  import fs, { existsSync, readFileSync } from "node:fs";
@@ -950,9 +950,9 @@ async function generateAuthConfig({ format: format$1, current_user_config, spinn
950
950
  };
951
951
  const config_generation = {
952
952
  add_plugin: async (opts) => {
953
- let start_of_plugins = getGroupInfo(opts.config, common_indexes.START_OF_PLUGINS, {});
953
+ const start_of_plugins = getGroupInfo(opts.config, common_indexes.START_OF_PLUGINS, {});
954
954
  if (!start_of_plugins) throw new Error("Couldn't find start of your plugins array in your auth config file.");
955
- let end_of_plugins = getGroupInfo(opts.config, common_indexes.END_OF_PLUGINS, { start_of_plugins: start_of_plugins.index });
955
+ const end_of_plugins = getGroupInfo(opts.config, common_indexes.END_OF_PLUGINS, { start_of_plugins: start_of_plugins.index });
956
956
  if (!end_of_plugins) throw new Error("Couldn't find end of your plugins array in your auth config file.");
957
957
  let new_content;
958
958
  if (opts.direction_in_plugins_array === "prepend") new_content = insertContent({
@@ -1006,7 +1006,7 @@ async function generateAuthConfig({ format: format$1, current_user_config, spinn
1006
1006
  let database_code_str = "";
1007
1007
  async function add_db({ db_code, dependencies, envs, imports, code_before_betterAuth }) {
1008
1008
  if (code_before_betterAuth) {
1009
- let start_of_betterauth$1 = getGroupInfo(opts.config, common_indexes.START_OF_BETTERAUTH, {});
1009
+ const start_of_betterauth$1 = getGroupInfo(opts.config, common_indexes.START_OF_BETTERAUTH, {});
1010
1010
  if (!start_of_betterauth$1) throw new Error("Couldn't find start of betterAuth() function.");
1011
1011
  opts.config = insertContent({
1012
1012
  line: start_of_betterauth$1.line - 1,
@@ -1154,7 +1154,7 @@ async function generateAuthConfig({ format: format$1, current_user_config, spinn
1154
1154
  variables: [{ name: "MongoClient" }]
1155
1155
  }]
1156
1156
  });
1157
- let start_of_betterauth = getGroupInfo(opts.config, common_indexes.START_OF_BETTERAUTH, {});
1157
+ const start_of_betterauth = getGroupInfo(opts.config, common_indexes.START_OF_BETTERAUTH, {});
1158
1158
  if (!start_of_betterauth) throw new Error("Couldn't find start of betterAuth() function.");
1159
1159
  let new_content;
1160
1160
  new_content = insertContent({
@@ -1177,8 +1177,8 @@ async function generateAuthConfig({ format: format$1, current_user_config, spinn
1177
1177
  }
1178
1178
  };
1179
1179
  let new_user_config = await format$1(current_user_config);
1180
- let total_dependencies = [];
1181
- let total_envs = [];
1180
+ const total_dependencies = [];
1181
+ const total_envs = [];
1182
1182
  if (plugins.length !== 0) {
1183
1183
  const imports = [];
1184
1184
  for await (const plugin of plugins) {
@@ -1622,7 +1622,7 @@ const getDefaultAuthClientConfig = async ({ auth_config_path, framework, clientP
1622
1622
  }
1623
1623
  return result;
1624
1624
  }
1625
- let imports = groupImportVariables();
1625
+ const imports = groupImportVariables();
1626
1626
  let importString = "";
1627
1627
  for (const import_ of imports) if (Array.isArray(import_.variables)) importString += `import { ${import_.variables.map((x) => `${x.asType ? "type " : ""}${x.name}${x.as ? ` as ${x.as}` : ""}`).join(", ")} } from "${import_.path}";\n`;
1628
1628
  else importString += `import ${import_.variables.asType ? "type " : ""}${import_.variables.name}${import_.variables.as ? ` as ${import_.variables.as}` : ""} from "${import_.path}";\n`;
@@ -2020,7 +2020,7 @@ async function initAction(opts) {
2020
2020
  authClientConfigPath = path.join(cwd, "auth-client.ts");
2021
2021
  log.info(`Creating auth client config file: ${authClientConfigPath}`);
2022
2022
  try {
2023
- let contents = await getDefaultAuthClientConfig({
2023
+ const contents = await getDefaultAuthClientConfig({
2024
2024
  auth_config_path: ("./" + path.join(config_path.replace(cwd, ""))).replace(".//", "./"),
2025
2025
  clientPlugins: add_plugins.filter((x) => x.clientName).map((plugin) => {
2026
2026
  let contents$1 = "";
@@ -2079,7 +2079,7 @@ async function initAction(opts) {
2079
2079
  cancel(`✋ Operation cancelled.`);
2080
2080
  process.exit(0);
2081
2081
  }
2082
- let envs = [];
2082
+ const envs = [];
2083
2083
  if (isMissingSecret) envs.push("BETTER_AUTH_SECRET");
2084
2084
  if (isMissingUrl) envs.push("BETTER_AUTH_URL");
2085
2085
  if (shouldAdd === "yes") {
@@ -2163,7 +2163,7 @@ async function getPackageManager() {
2163
2163
  value: "npm",
2164
2164
  hint: "not recommended"
2165
2165
  });
2166
- let packageManager = await select({
2166
+ const packageManager = await select({
2167
2167
  message: "Choose a package manager",
2168
2168
  options: packageManagerOptions
2169
2169
  });
@@ -2349,69 +2349,100 @@ const login = new Command("login").description("Demo: Test device authorization
2349
2349
 
2350
2350
  //#endregion
2351
2351
  //#region src/commands/mcp.ts
2352
+ const REMOTE_MCP_URL = "https://mcp.chonkie.ai/better-auth/better-auth-builder/mcp";
2353
+ const LOCAL_MCP_COMMAND = "npx @better-auth/mcp";
2352
2354
  async function mcpAction(options) {
2353
- const mcpUrl = "https://mcp.chonkie.ai/better-auth/better-auth-builder/mcp";
2354
- const mcpName = "better-auth";
2355
- if (options.cursor) await handleCursorAction(mcpUrl, mcpName);
2356
- else if (options.claudeCode) handleClaudeCodeAction(mcpUrl);
2357
- else if (options.openCode) handleOpenCodeAction(mcpUrl);
2358
- else if (options.manual) handleManualAction(mcpUrl, mcpName);
2359
- else showAllOptions(mcpUrl, mcpName);
2355
+ const installLocal = !options.remoteOnly;
2356
+ const installRemote = !options.localOnly;
2357
+ if (options.cursor) await handleCursorAction(installLocal, installRemote);
2358
+ else if (options.claudeCode) handleClaudeCodeAction(installLocal, installRemote);
2359
+ else if (options.openCode) handleOpenCodeAction(installLocal, installRemote);
2360
+ else if (options.manual) handleManualAction(installLocal, installRemote);
2361
+ else showAllOptions();
2360
2362
  }
2361
- async function handleCursorAction(mcpUrl, mcpName) {
2362
- const mcpConfig = { url: mcpUrl };
2363
- const encodedConfig = base64.encode(new TextEncoder().encode(JSON.stringify(mcpConfig)));
2364
- const deeplinkUrl = `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(mcpName)}&config=${encodedConfig}`;
2363
+ async function handleCursorAction(installLocal, installRemote) {
2365
2364
  console.log(chalk.bold.blue("🚀 Adding Better Auth MCP to Cursor..."));
2366
- try {
2367
- const platform = os$1.platform();
2368
- let command;
2369
- switch (platform) {
2370
- case "darwin":
2371
- command = `open "${deeplinkUrl}"`;
2372
- break;
2373
- case "win32":
2374
- command = `start "" "${deeplinkUrl}"`;
2375
- break;
2376
- case "linux":
2377
- command = `xdg-open "${deeplinkUrl}"`;
2378
- break;
2379
- default: throw new Error(`Unsupported platform: ${platform}`);
2365
+ const platform = os$1.platform();
2366
+ let openCommand;
2367
+ switch (platform) {
2368
+ case "darwin":
2369
+ openCommand = "open";
2370
+ break;
2371
+ case "win32":
2372
+ openCommand = "start";
2373
+ break;
2374
+ case "linux":
2375
+ openCommand = "xdg-open";
2376
+ break;
2377
+ default: throw new Error(`Unsupported platform: ${platform}`);
2378
+ }
2379
+ const installed = [];
2380
+ if (installRemote) {
2381
+ const remoteConfig = { url: REMOTE_MCP_URL };
2382
+ const encodedRemote = base64.encode(new TextEncoder().encode(JSON.stringify(remoteConfig)));
2383
+ const remoteDeeplink = `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent("better-auth-docs")}&config=${encodedRemote}`;
2384
+ try {
2385
+ execSync(platform === "win32" ? `start "" "${remoteDeeplink}"` : `${openCommand} "${remoteDeeplink}"`, { stdio: "inherit" });
2386
+ installed.push("better-auth-docs (remote - documentation & search)");
2387
+ } catch {
2388
+ console.log(chalk.yellow("\n⚠ Could not automatically open Cursor for remote MCP."));
2380
2389
  }
2381
- execSync(command, { stdio: "inherit" });
2382
- console.log(chalk.green("\n✓ Cursor MCP installed successfully!"));
2383
- } catch {
2384
- console.log(chalk.yellow("\n⚠ Could not automatically open Cursor. Please copy the deeplink URL above and open it manually."));
2385
- console.log(chalk.gray("\nYou can also manually add this configuration to your Cursor MCP settings:"));
2386
- console.log(chalk.gray(JSON.stringify(mcpConfig, null, 2)));
2390
+ }
2391
+ if (installLocal) {
2392
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
2393
+ const localConfig = { command: LOCAL_MCP_COMMAND };
2394
+ const encodedLocal = base64.encode(new TextEncoder().encode(JSON.stringify(localConfig)));
2395
+ const localDeeplink = `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent("better-auth")}&config=${encodedLocal}`;
2396
+ try {
2397
+ execSync(platform === "win32" ? `start "" "${localDeeplink}"` : `${openCommand} "${localDeeplink}"`, { stdio: "inherit" });
2398
+ installed.push("better-auth (local - setup & diagnostics)");
2399
+ } catch {
2400
+ console.log(chalk.yellow("\n⚠ Could not automatically open Cursor for local MCP."));
2401
+ }
2402
+ }
2403
+ if (installed.length > 0) {
2404
+ console.log(chalk.green("\n✓ Cursor MCP servers installed:"));
2405
+ for (const name of installed) console.log(chalk.green(` • ${name}`));
2387
2406
  }
2388
2407
  console.log(chalk.bold.white("\n✨ Next Steps:"));
2389
- console.log(chalk.gray("• The MCP server will be added to your Cursor configuration"));
2408
+ console.log(chalk.gray("• The MCP servers will be added to your Cursor configuration"));
2390
2409
  console.log(chalk.gray("• You can now use Better Auth features directly in Cursor"));
2410
+ console.log(chalk.gray("• Try: \"Set up Better Auth with Google login\" or \"Help me debug my auth\""));
2391
2411
  }
2392
- function handleClaudeCodeAction(mcpUrl) {
2412
+ function handleClaudeCodeAction(installLocal, installRemote) {
2393
2413
  console.log(chalk.bold.blue("🤖 Adding Better Auth MCP to Claude Code..."));
2394
- const command = `claude mcp add --transport http better-auth ${mcpUrl}`;
2395
- try {
2414
+ const commands = [];
2415
+ if (installRemote) commands.push(`claude mcp add --transport http better-auth-docs ${REMOTE_MCP_URL}`);
2416
+ if (installLocal) commands.push(`claude mcp add better-auth -- ${LOCAL_MCP_COMMAND}`);
2417
+ let anySucceeded = false;
2418
+ for (const command of commands) try {
2396
2419
  execSync(command, { stdio: "inherit" });
2397
- console.log(chalk.green("\n✓ Claude Code MCP installed successfully!"));
2420
+ anySucceeded = true;
2398
2421
  } catch {
2399
2422
  console.log(chalk.yellow("\n⚠ Could not automatically add to Claude Code. Please run this command manually:"));
2400
2423
  console.log(chalk.cyan(command));
2401
2424
  }
2425
+ if (anySucceeded) console.log(chalk.green("\n✓ Claude Code MCP configured!"));
2402
2426
  console.log(chalk.bold.white("\n✨ Next Steps:"));
2403
- console.log(chalk.gray("• The MCP server will be added to your Claude Code configuration"));
2427
+ console.log(chalk.gray("• The MCP servers will be added to your Claude Code configuration"));
2404
2428
  console.log(chalk.gray("• You can now use Better Auth features directly in Claude Code"));
2405
2429
  }
2406
- function handleOpenCodeAction(mcpUrl) {
2430
+ function handleOpenCodeAction(installLocal, installRemote) {
2407
2431
  console.log(chalk.bold.blue("🔧 Adding Better Auth MCP to Open Code..."));
2432
+ const mcpConfig = {};
2433
+ if (installRemote) mcpConfig["better-auth-docs"] = {
2434
+ type: "remote",
2435
+ url: REMOTE_MCP_URL,
2436
+ enabled: true
2437
+ };
2438
+ if (installLocal) mcpConfig["better-auth"] = {
2439
+ type: "stdio",
2440
+ command: LOCAL_MCP_COMMAND,
2441
+ enabled: true
2442
+ };
2408
2443
  const openCodeConfig = {
2409
2444
  $schema: "https://opencode.ai/config.json",
2410
- mcp: { "better-auth": {
2411
- type: "remote",
2412
- url: mcpUrl,
2413
- enabled: true
2414
- } }
2445
+ mcp: mcpConfig
2415
2446
  };
2416
2447
  const configPath = path$1.join(process.cwd(), "opencode.json");
2417
2448
  try {
@@ -2430,18 +2461,20 @@ function handleOpenCodeAction(mcpUrl) {
2430
2461
  };
2431
2462
  fs$2.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2));
2432
2463
  console.log(chalk.green(`\n✓ Open Code configuration written to ${configPath}`));
2433
- console.log(chalk.green("✓ Better Auth MCP added successfully!"));
2464
+ console.log(chalk.green("✓ Better Auth MCP servers added successfully!"));
2434
2465
  } catch {
2435
2466
  console.log(chalk.yellow("\n⚠ Could not automatically write opencode.json. Please add this configuration manually:"));
2436
2467
  console.log(chalk.cyan(JSON.stringify(openCodeConfig, null, 2)));
2437
2468
  }
2438
2469
  console.log(chalk.bold.white("\n✨ Next Steps:"));
2439
- console.log(chalk.gray("• Restart Open Code to load the new MCP server"));
2470
+ console.log(chalk.gray("• Restart Open Code to load the new MCP servers"));
2440
2471
  console.log(chalk.gray("• You can now use Better Auth features directly in Open Code"));
2441
2472
  }
2442
- function handleManualAction(mcpUrl, mcpName) {
2443
- console.log(chalk.bold.blue("📝 Adding Better Auth MCP Configuration..."));
2444
- const manualConfig = { [mcpName]: { url: mcpUrl } };
2473
+ function handleManualAction(installLocal, installRemote) {
2474
+ console.log(chalk.bold.blue("📝 Better Auth MCP Configuration..."));
2475
+ const manualConfig = {};
2476
+ if (installRemote) manualConfig["better-auth-docs"] = { url: REMOTE_MCP_URL };
2477
+ if (installLocal) manualConfig["better-auth"] = { command: LOCAL_MCP_COMMAND };
2445
2478
  const configPath = path$1.join(process.cwd(), "mcp.json");
2446
2479
  try {
2447
2480
  let existingConfig = {};
@@ -2455,27 +2488,36 @@ function handleManualAction(mcpUrl, mcpName) {
2455
2488
  };
2456
2489
  fs$2.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2));
2457
2490
  console.log(chalk.green(`\n✓ MCP configuration written to ${configPath}`));
2458
- console.log(chalk.green("✓ Better Auth MCP added successfully!"));
2491
+ console.log(chalk.green("✓ Better Auth MCP servers added successfully!"));
2459
2492
  } catch {
2460
2493
  console.log(chalk.yellow("\n⚠ Could not automatically write mcp.json. Please add this configuration manually:"));
2461
2494
  console.log(chalk.cyan(JSON.stringify(manualConfig, null, 2)));
2462
2495
  }
2463
2496
  console.log(chalk.bold.white("\n✨ Next Steps:"));
2464
- console.log(chalk.gray("• Restart your MCP client to load the new server"));
2497
+ console.log(chalk.gray("• Restart your MCP client to load the new servers"));
2465
2498
  console.log(chalk.gray("• You can now use Better Auth features directly in your MCP client"));
2466
2499
  }
2467
- function showAllOptions(mcpUrl, mcpName) {
2468
- console.log(chalk.bold.blue("🔌 Better Auth MCP Server"));
2500
+ function showAllOptions() {
2501
+ console.log(chalk.bold.blue("🔌 Better Auth MCP Servers"));
2469
2502
  console.log(chalk.gray("Choose your MCP client to get started:"));
2470
2503
  console.log();
2471
- console.log(chalk.bold.white("Available Commands:"));
2504
+ console.log(chalk.bold.white("MCP Clients:"));
2472
2505
  console.log(chalk.cyan(" --cursor ") + chalk.gray("Add to Cursor"));
2473
2506
  console.log(chalk.cyan(" --claude-code ") + chalk.gray("Add to Claude Code"));
2474
2507
  console.log(chalk.cyan(" --open-code ") + chalk.gray("Add to Open Code"));
2475
2508
  console.log(chalk.cyan(" --manual ") + chalk.gray("Manual configuration"));
2476
2509
  console.log();
2510
+ console.log(chalk.bold.white("Server Selection:"));
2511
+ console.log(chalk.cyan(" --local-only ") + chalk.gray("Install only local MCP (setup & diagnostics)"));
2512
+ console.log(chalk.cyan(" --remote-only ") + chalk.gray("Install only remote MCP (documentation & search)"));
2513
+ console.log(chalk.gray(" (default: install both servers)"));
2514
+ console.log();
2515
+ console.log(chalk.bold.white("Servers:"));
2516
+ console.log(chalk.gray(" • ") + chalk.white("better-auth") + chalk.gray(" (local) - Setup auth, diagnose issues, validate config"));
2517
+ console.log(chalk.gray(" • ") + chalk.white("better-auth-docs") + chalk.gray(" (remote) - Search documentation, code examples"));
2518
+ console.log();
2477
2519
  }
2478
- const mcp = new Command("mcp").description("Add Better Auth MCP server to MCP Clients").option("--cursor", "Automatically open Cursor with the MCP configuration").option("--claude-code", "Show Claude Code MCP configuration command").option("--open-code", "Show Open Code MCP configuration").option("--manual", "Show manual MCP configuration for mcp.json").action(mcpAction);
2520
+ const mcp = new Command("mcp").description("Add Better Auth MCP servers to MCP Clients").option("--cursor", "Automatically open Cursor with the MCP configuration").option("--claude-code", "Show Claude Code MCP configuration command").option("--open-code", "Show Open Code MCP configuration").option("--manual", "Show manual MCP configuration for mcp.json").option("--local-only", "Install only local MCP server (setup & diagnostics)").option("--remote-only", "Install only remote MCP server (documentation & search)").action(mcpAction);
2479
2521
 
2480
2522
  //#endregion
2481
2523
  //#region src/commands/migrate.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/cli",
3
- "version": "1.5.0-beta.6",
3
+ "version": "1.5.0-beta.7",
4
4
  "type": "module",
5
5
  "description": "The CLI for Better Auth",
6
6
  "module": "dist/index.mjs",
@@ -50,7 +50,7 @@
50
50
  "tsx": "^4.20.6",
51
51
  "type-fest": "^5.2.0",
52
52
  "typescript": "^5.9.3",
53
- "@better-auth/passkey": "1.5.0-beta.6"
53
+ "@better-auth/passkey": "1.5.0-beta.7"
54
54
  },
55
55
  "dependencies": {
56
56
  "@babel/core": "^7.28.4",
@@ -74,9 +74,9 @@
74
74
  "semver": "^7.7.2",
75
75
  "yocto-spinner": "^0.2.3",
76
76
  "zod": "^4.1.12",
77
- "@better-auth/core": "1.5.0-beta.6",
78
- "@better-auth/telemetry": "1.5.0-beta.6",
79
- "better-auth": "^1.5.0-beta.6"
77
+ "@better-auth/core": "1.5.0-beta.7",
78
+ "@better-auth/telemetry": "1.5.0-beta.7",
79
+ "better-auth": "^1.5.0-beta.7"
80
80
  },
81
81
  "files": [
82
82
  "dist"