auth 1.7.0-beta.2 → 1.7.0-beta.4

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/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Better Auth CLI
2
2
 
3
3
  Better Auth comes with a built-in CLI to help you manage the database schema
4
- needed for both core functionality and plugins.
4
+ needed for both core functionality and plugins, and to create an initial admin user
5
+ for projects using the Admin plugin.
5
6
 
6
7
  ### **Init**
7
8
 
@@ -34,6 +35,16 @@ tool.
34
35
  npx auth@latest migrate
35
36
  ```
36
37
 
38
+ ### **Create Admin**
39
+
40
+ Create the first admin user for an app using the Admin plugin. The command
41
+ uses your Better Auth config and prompts before creating an admin when users
42
+ already exist. The created admin email is marked as verified by default.
43
+
44
+ ```bash title="terminal"
45
+ npx auth@latest create-admin --email admin@example.com --name "Admin" --role admin
46
+ ```
47
+
37
48
  ### **Secret**
38
49
 
39
50
  The CLI also provides a way to generate a secret key for your Better Auth
package/dist/api.mjs CHANGED
@@ -1,16 +1,15 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
+ import { capitalizeFirstLetter, toSnakeCase } from "@better-auth/core/utils/string";
2
3
  import { initGetFieldName, initGetModelName } from "better-auth/adapters";
3
4
  import { getAuthTables } from "better-auth/db";
4
5
  import prettier from "prettier";
5
6
  import { getMigrations } from "better-auth/db/migration";
6
7
  import fs from "node:fs/promises";
7
8
  import path from "node:path";
8
- import { capitalizeFirstLetter } from "@better-auth/core/utils/string";
9
9
  import { produceSchema } from "@mrleebo/prisma-ast";
10
10
  //#region src/generators/drizzle.ts
11
11
  function convertToSnakeCase(str, camelCase) {
12
- if (camelCase) return str;
13
- return str.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").toLowerCase();
12
+ return camelCase ? str : toSnakeCase(str);
14
13
  }
15
14
  const generateDrizzleSchema = async ({ options, file, adapter }) => {
16
15
  const tables = getAuthTables(options);