auth 1.7.0-beta.3 → 1.7.0-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/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);
@@ -439,6 +438,7 @@ const generatePrismaSchema = async ({ adapter, options, file }) => {
439
438
  if (provider === "mongodb") fieldBuilder.attribute(`map("_id")`);
440
439
  }
441
440
  if (attr.unique) builder.model(modelName).blockAttribute(`unique([${fieldName}])`);
441
+ if ((attr.type === "string[]" || attr.type === "number[]") && provider !== "sqlite" && provider !== "mysql" && attr.defaultValue === void 0) fieldBuilder.attribute("default([])");
442
442
  if (attr.defaultValue !== void 0) {
443
443
  if (Array.isArray(attr.defaultValue)) {
444
444
  if (attr.type === "json") {