authverse 1.1.4 → 1.1.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/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var getPackageManager = () => {
32
32
  if (ua.includes("bun")) return "bun";
33
33
  if (ua.includes("pnpm")) return "pnpm";
34
34
  if (ua.includes("yarn")) return "yarn";
35
- return "npm";
35
+ return "pnpm";
36
36
  };
37
37
  var pm = getPackageManager();
38
38
  var packageManager = (pkg, dev = false) => {
@@ -62,14 +62,47 @@ var runCommand = (cmd) => {
62
62
  };
63
63
 
64
64
  // script/authUi.ts
65
- var authUiRun = async ({ folder }) => {
65
+ var shadcnComponents = [
66
+ "button.tsx",
67
+ "card.tsx",
68
+ "field.tsx",
69
+ "input.tsx",
70
+ "label.tsx",
71
+ "separator.tsx",
72
+ "sonner.tsx"
73
+ ];
74
+ var authUiRun = async ({
75
+ folder,
76
+ packageJson: packageJson2,
77
+ cmd
78
+ }) => {
66
79
  try {
67
- console.log(chalk.yellow("\n Installing shadcn ui Components\n"));
68
- runCommand("shadcn@latest add button sonner card field input");
69
- packageManager("react-hook-form @hookform/resolvers");
80
+ const projectDir = process.cwd();
81
+ const shadcnPath = path.join(projectDir, folder, "components", "ui");
82
+ const shadcnConfigPath = path.join(projectDir, "components.json");
83
+ if (!fs.existsSync(shadcnPath) || !fs.existsSync(shadcnConfigPath)) {
84
+ console.log(chalk.yellow("\n Installing shadcn ui Components\n"));
85
+ if (cmd == true) {
86
+ runCommand("shadcn@latest init --base-color zinc --yes");
87
+ runCommand("shadcn@latest add button sonner card field input");
88
+ } else {
89
+ runCommand("shadcn@latest add button sonner card field input");
90
+ }
91
+ }
92
+ const shadcnFiles = fs.readdirSync(shadcnPath);
93
+ const missingComponents = shadcnComponents.filter(
94
+ (component) => !shadcnFiles.includes(component)
95
+ );
96
+ if (missingComponents.length > 0) {
97
+ console.log(chalk.yellow("\n Installing shadcn ui Components\n"));
98
+ const install = missingComponents.map((components) => components.split(".")[0]).join(" ");
99
+ runCommand(`shadcn@latest add ${install}`);
100
+ }
101
+ if (!packageJson2.dependencies?.["react-hook-form"] || !packageJson2.dependencies?.["@hookform/resolvers"] || !packageJson2.dependencies?.["zod"]) {
102
+ packageManager("react-hook-form @hookform/resolvers zod");
103
+ }
70
104
  const __filename = fileURLToPath(import.meta.url);
71
105
  const __dirname = path.dirname(__filename);
72
- const projectDir = process.cwd();
73
106
  const componentPath = path.resolve(__dirname, "./template/components");
74
107
  const destinationPath = path.join(
75
108
  projectDir,
@@ -150,14 +183,14 @@ ${layoutContent}`;
150
183
 
151
184
  // script/prisma.ts
152
185
  import inquirer from "inquirer";
153
- var prismaRun = async ({ authUi, database }) => {
186
+ var prismaRun = async ({ authUi, database, cmd }) => {
154
187
  try {
155
188
  const projectDir = process.cwd();
156
189
  const __filename = fileURLToPath2(import.meta.url);
157
190
  const __dirname = path2.dirname(__filename);
158
191
  const packageJsonPath = path2.join(projectDir, "package.json");
159
192
  const packageJson2 = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
160
- if (!packageJson2.devDependencies?.prisma && !packageJson2.dependencies?.["@prisma/client"]) {
193
+ if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
161
194
  console.log(chalk2.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
162
195
  if (database !== "Mongodb") {
163
196
  packageManager("prisma", true);
@@ -197,7 +230,7 @@ var prismaRun = async ({ authUi, database }) => {
197
230
  } else {
198
231
  const schemaPath = path2.join(prismaDir, "schema.prisma");
199
232
  const schemaContent = fs2.readFileSync(schemaPath, "utf-8");
200
- if (!schemaContent.includes("User") && !schemaContent.includes("Session") && !schemaContent.includes("Account") && !schemaContent.includes("Verification")) {
233
+ if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
201
234
  const templatePath = path2.resolve(
202
235
  __dirname,
203
236
  `./template/prisma/${database}/schema.prisma_copy`
@@ -230,16 +263,48 @@ BETTER_AUTH_URL=http://localhost:3000
230
263
  }
231
264
  const authPath = path2.join(libPath, "auth.ts");
232
265
  const authClientPath = path2.join(libPath, "auth-client.ts");
233
- if (fs2.existsSync(authPath) || fs2.existsSync(authClientPath)) {
234
- const answers = await inquirer.prompt([
235
- {
236
- type: "confirm",
237
- name: "overwrite",
238
- message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
239
- default: false
266
+ if (cmd !== true) {
267
+ if (fs2.existsSync(authPath) || fs2.existsSync(authClientPath)) {
268
+ const answers = await inquirer.prompt([
269
+ {
270
+ type: "confirm",
271
+ name: "overwrite",
272
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
273
+ default: false
274
+ }
275
+ ]);
276
+ if (answers.overwrite) {
277
+ const authTemplatePath = path2.resolve(
278
+ __dirname,
279
+ `./template/lib/${database}/auth.ts`
280
+ );
281
+ const authDestinationPath = path2.join(libPath, "auth.ts");
282
+ fs2.copyFileSync(authTemplatePath, authDestinationPath);
283
+ const authClientTemplatePath = path2.resolve(
284
+ __dirname,
285
+ "./template/lib/auth-client.ts"
286
+ );
287
+ const authClientDestinationPath = path2.join(
288
+ libPath,
289
+ "auth-client.ts"
290
+ );
291
+ fs2.copyFileSync(authClientTemplatePath, authClientDestinationPath);
292
+ if (srcFolder === "src") {
293
+ const authContextPath = path2.join(libPath, "auth.ts");
294
+ const authContextContent = fs2.readFileSync(
295
+ authContextPath,
296
+ "utf-8"
297
+ );
298
+ fs2.writeFileSync(
299
+ authContextPath,
300
+ authContextContent.replace(
301
+ 'import { PrismaClient } from "@/generated/prisma/client";',
302
+ 'import { PrismaClient } from "../../generated/prisma/client";'
303
+ )
304
+ );
305
+ }
240
306
  }
241
- ]);
242
- if (answers.overwrite) {
307
+ } else {
243
308
  const authTemplatePath = path2.resolve(
244
309
  __dirname,
245
310
  `./template/lib/${database}/auth.ts`
@@ -264,30 +329,6 @@ BETTER_AUTH_URL=http://localhost:3000
264
329
  );
265
330
  }
266
331
  }
267
- } else {
268
- const authTemplatePath = path2.resolve(
269
- __dirname,
270
- `./template/lib/${database}/auth.ts`
271
- );
272
- const authDestinationPath = path2.join(libPath, "auth.ts");
273
- fs2.copyFileSync(authTemplatePath, authDestinationPath);
274
- const authClientTemplatePath = path2.resolve(
275
- __dirname,
276
- "./template/lib/auth-client.ts"
277
- );
278
- const authClientDestinationPath = path2.join(libPath, "auth-client.ts");
279
- fs2.copyFileSync(authClientTemplatePath, authClientDestinationPath);
280
- if (srcFolder === "src") {
281
- const authContextPath = path2.join(libPath, "auth.ts");
282
- const authContextContent = fs2.readFileSync(authContextPath, "utf-8");
283
- fs2.writeFileSync(
284
- authContextPath,
285
- authContextContent.replace(
286
- 'import { PrismaClient } from "@/generated/prisma/client";',
287
- 'import { PrismaClient } from "../../generated/prisma/client";'
288
- )
289
- );
290
- }
291
332
  }
292
333
  const routeTemplatePath = path2.resolve(
293
334
  __dirname,
@@ -327,7 +368,11 @@ BETTER_AUTH_URL=http://localhost:3000
327
368
  );
328
369
  }
329
370
  if (authUi) {
330
- await authUiRun({ folder: srcFolder });
371
+ await authUiRun({
372
+ folder: srcFolder,
373
+ packageJson: packageJson2,
374
+ cmd
375
+ });
331
376
  } else {
332
377
  console.log(
333
378
  chalk2.green(
@@ -346,7 +391,7 @@ import path3 from "path";
346
391
  import { fileURLToPath as fileURLToPath3 } from "url";
347
392
  import fs3 from "fs";
348
393
  import inquirer2 from "inquirer";
349
- var drizzleRun = async (authUi) => {
394
+ var drizzleRun = async ({ authUi, cmd }) => {
350
395
  try {
351
396
  const projectDir = process.cwd();
352
397
  const packageJsonPath = path3.join(projectDir, "package.json");
@@ -494,7 +539,11 @@ BETTER_AUTH_URL=http://localhost:3000
494
539
  const proxyDestinationPath = path3.join(proxyDestinationDir, "proxy.ts");
495
540
  fs3.copyFileSync(proxyTemplatePath, proxyDestinationPath);
496
541
  if (authUi) {
497
- await authUiRun({ folder: srcFolder });
542
+ await authUiRun({
543
+ folder: srcFolder,
544
+ packageJson: packageJson2,
545
+ cmd
546
+ });
498
547
  } else {
499
548
  console.log(
500
549
  chalk3.green(
@@ -507,10 +556,6 @@ BETTER_AUTH_URL=http://localhost:3000
507
556
  }
508
557
  };
509
558
 
510
- // cli/init.ts
511
- import path7 from "path";
512
- import fs7 from "fs";
513
-
514
559
  // script/prismaRunTanstackState.ts
515
560
  import chalk5 from "chalk";
516
561
  import path5 from "path";
@@ -522,14 +567,46 @@ import chalk4 from "chalk";
522
567
  import { fileURLToPath as fileURLToPath4 } from "url";
523
568
  import path4 from "path";
524
569
  import fs4 from "fs";
525
- var authUiTanstackState = async () => {
570
+ var shadcnComponents2 = [
571
+ "button.tsx",
572
+ "card.tsx",
573
+ "field.tsx",
574
+ "input.tsx",
575
+ "label.tsx",
576
+ "separator.tsx",
577
+ "sonner.tsx"
578
+ ];
579
+ var authUiTanstackState = async ({
580
+ packageJson: packageJson2,
581
+ cmd
582
+ }) => {
526
583
  try {
527
- console.log(chalk4.yellow("\n Installing shadcn ui Components\n"));
528
- runCommand("shadcn@latest add button sonner card field input");
529
- packageManager("@tanstack/react-form");
584
+ const projectDir = process.cwd();
585
+ const shadcnPath = path4.join(projectDir, "src", "components", "ui");
586
+ const shadcnConfigPath = path4.join(projectDir, "components.json");
587
+ if (!fs4.existsSync(shadcnPath) || !fs4.existsSync(shadcnConfigPath)) {
588
+ console.log(chalk4.yellow("\n Installing shadcn ui Components\n"));
589
+ if (cmd == true) {
590
+ runCommand("shadcn@latest init --base-color zinc --yes");
591
+ runCommand("shadcn@latest add button sonner card field input");
592
+ } else {
593
+ runCommand("shadcn@latest add button sonner card field input");
594
+ }
595
+ }
596
+ const shadcnFiles = fs4.readdirSync(shadcnPath);
597
+ const missingComponents = shadcnComponents2.filter(
598
+ (component) => !shadcnFiles.includes(component)
599
+ );
600
+ if (missingComponents.length > 0) {
601
+ console.log(chalk4.yellow("\n Installing shadcn ui Components\n"));
602
+ const install = missingComponents.map((components) => components.split(".")[0]).join(" ");
603
+ runCommand(`shadcn@latest add ${install}`);
604
+ }
605
+ if (!packageJson2.dependencies?.["@tanstack/react-form"] || !packageJson2.dependencies?.["zod"]) {
606
+ packageManager("@tanstack/react-form zod");
607
+ }
530
608
  const __filename = fileURLToPath4(import.meta.url);
531
609
  const __dirname = path4.dirname(__filename);
532
- const projectDir = process.cwd();
533
610
  const srcPath = path4.join(projectDir, "src");
534
611
  const componentPath = path4.resolve(
535
612
  __dirname,
@@ -591,7 +668,8 @@ ${rootContent}`;
591
668
  // script/prismaRunTanstackState.ts
592
669
  var prismaRunTanstackState = async ({
593
670
  authUi,
594
- database
671
+ database,
672
+ cmd
595
673
  }) => {
596
674
  try {
597
675
  const projectDir = process.cwd();
@@ -599,7 +677,7 @@ var prismaRunTanstackState = async ({
599
677
  const __dirname = path5.dirname(__filename);
600
678
  const packageJsonPath = path5.join(projectDir, "package.json");
601
679
  const packageJson2 = JSON.parse(fs5.readFileSync(packageJsonPath, "utf-8"));
602
- if (!packageJson2.devDependencies?.prisma && !packageJson2.dependencies?.["@prisma/client"]) {
680
+ if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
603
681
  console.log(chalk5.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
604
682
  if (database !== "Mongodb") {
605
683
  packageManager("prisma", true);
@@ -639,7 +717,7 @@ var prismaRunTanstackState = async ({
639
717
  } else {
640
718
  const schemaPath = path5.join(prismaDir, "schema.prisma");
641
719
  const schemaContent = fs5.readFileSync(schemaPath, "utf-8");
642
- if (!schemaContent.includes("User") && !schemaContent.includes("Session") && !schemaContent.includes("Account") && !schemaContent.includes("Verification")) {
720
+ if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
643
721
  const templatePath = path5.resolve(
644
722
  __dirname,
645
723
  `./template/prisma/${database}/schema.prisma_copy`
@@ -708,7 +786,10 @@ BETTER_AUTH_URL=http://localhost:3000
708
786
  const apiDestinationPath = path5.join(fileRouteDestinationPath, "$.ts");
709
787
  fs5.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
710
788
  if (authUi) {
711
- await authUiTanstackState();
789
+ await authUiTanstackState({
790
+ packageJson: packageJson2,
791
+ cmd
792
+ });
712
793
  } else {
713
794
  console.log(
714
795
  chalk5.green(
@@ -726,7 +807,10 @@ import chalk6 from "chalk";
726
807
  import path6 from "path";
727
808
  import fs6 from "fs";
728
809
  import { fileURLToPath as fileURLToPath6 } from "url";
729
- var drizzleRunTanstackState = async (authUi) => {
810
+ var drizzleRunTanstackState = async ({
811
+ authUi,
812
+ cmd
813
+ }) => {
730
814
  try {
731
815
  const projectDir = process.cwd();
732
816
  const packageJsonPath = path6.join(projectDir, "package.json");
@@ -819,7 +903,10 @@ BETTER_AUTH_URL=http://localhost:3000
819
903
  const apiDestinationPath = path6.join(fileRouteDestinationPath, "$.ts");
820
904
  fs6.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
821
905
  if (authUi) {
822
- await authUiTanstackState();
906
+ await authUiTanstackState({
907
+ packageJson: packageJson2,
908
+ cmd
909
+ });
823
910
  } else {
824
911
  console.log(
825
912
  chalk6.green(
@@ -832,15 +919,47 @@ BETTER_AUTH_URL=http://localhost:3000
832
919
  }
833
920
  };
834
921
 
922
+ // utils/framework.ts
923
+ import path7 from "path";
924
+ import fs7 from "fs";
925
+ var getFramework = async () => {
926
+ const projectDir = process.cwd();
927
+ if (!fs7.existsSync(path7.join(projectDir, "package.json"))) {
928
+ return {
929
+ framework: null,
930
+ error: "No framework detected"
931
+ };
932
+ }
933
+ const packageJson2 = JSON.parse(
934
+ fs7.readFileSync(path7.join(projectDir, "package.json"), "utf-8")
935
+ );
936
+ const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
937
+ if (hasNext) {
938
+ return {
939
+ framework: "Next js",
940
+ error: null
941
+ };
942
+ }
943
+ const hasTanstackState = packageJson2?.devDependencies?.["@tanstack/devtools-vite"] || packageJson2?.devDependencies?.["@tanstack/eslint-config"] || packageJson2?.devDependencies?.["@tanstack/react-start"];
944
+ if (hasTanstackState) {
945
+ return {
946
+ framework: "tanstack state",
947
+ error: null
948
+ };
949
+ }
950
+ return {
951
+ framework: null,
952
+ error: "No framework supported authverse"
953
+ };
954
+ };
955
+
835
956
  // cli/init.ts
957
+ import chalk7 from "chalk";
836
958
  var initAnswer = async () => {
837
- const projectDir = process.cwd();
838
- const packageJsonPath = path7.join(projectDir, "package.json");
839
- let framework = "tanstack state";
840
- if (fs7.existsSync(packageJsonPath)) {
841
- const packageJson2 = JSON.parse(fs7.readFileSync(packageJsonPath, "utf-8"));
842
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
843
- framework = hasNext ? "Next js" : "tanstack state";
959
+ const { framework, error } = await getFramework();
960
+ if (error) {
961
+ console.log(chalk7.red(error));
962
+ return;
844
963
  }
845
964
  console.log(`\u2714 Detected framework: ${framework}`);
846
965
  const answers = await inquirer3.prompt([
@@ -867,20 +986,28 @@ var initAnswer = async () => {
867
986
  if (framework === "Next js" && answers.orm === "Prisma") {
868
987
  await prismaRun({
869
988
  authUi: answers.authUi,
870
- database: answers.database
989
+ database: answers.database,
990
+ cmd: false
871
991
  });
872
992
  }
873
993
  if (framework === "Next js" && answers.orm === "Drizzle") {
874
- await drizzleRun(answers.authUi);
994
+ await drizzleRun({
995
+ authUi: answers.authUi,
996
+ cmd: false
997
+ });
875
998
  }
876
999
  if (framework === "tanstack state" && answers.orm === "Prisma") {
877
1000
  await prismaRunTanstackState({
878
1001
  authUi: answers.authUi,
879
- database: answers.database
1002
+ database: answers.database,
1003
+ cmd: false
880
1004
  });
881
1005
  }
882
1006
  if (framework === "tanstack state" && answers.orm === "Drizzle") {
883
- await drizzleRunTanstackState(answers.authUi);
1007
+ await drizzleRunTanstackState({
1008
+ authUi: answers.authUi,
1009
+ cmd: false
1010
+ });
884
1011
  }
885
1012
  };
886
1013
 
@@ -888,10 +1015,10 @@ var initAnswer = async () => {
888
1015
  import { readFileSync } from "fs";
889
1016
 
890
1017
  // cli/provider.ts
891
- import chalk11 from "chalk";
1018
+ import chalk12 from "chalk";
892
1019
 
893
1020
  // script/googleRun.ts
894
- import chalk7 from "chalk";
1021
+ import chalk8 from "chalk";
895
1022
  import fs8 from "fs";
896
1023
  import path8 from "path";
897
1024
  import { fileURLToPath as fileURLToPath7 } from "url";
@@ -904,16 +1031,16 @@ var googleRun = async () => {
904
1031
  const folder = fs8.existsSync(srcPath) ? "src" : "";
905
1032
  const authFilePath = path8.join(projectDir, folder, "lib", "auth.ts");
906
1033
  if (!fs8.existsSync(authFilePath)) {
907
- console.log(chalk7.red("\u274C auth.ts file not found"));
1034
+ console.log(chalk8.red("\u274C auth.ts file not found"));
908
1035
  return;
909
1036
  }
910
1037
  let content = fs8.readFileSync(authFilePath, "utf8");
911
1038
  if (!content.includes("betterAuth({")) {
912
- console.log(chalk7.red("betterAuth({}) block not found"));
1039
+ console.log(chalk8.red("betterAuth({}) block not found"));
913
1040
  return;
914
1041
  }
915
1042
  if (content.includes("socialProviders") && content.includes("google:")) {
916
- console.log(chalk7.yellow("Google provider already exists"));
1043
+ console.log(chalk8.yellow("Google provider already exists"));
917
1044
  return;
918
1045
  }
919
1046
  const googleProviderEntry = `
@@ -936,7 +1063,7 @@ var googleRun = async () => {
936
1063
  }
937
1064
  }
938
1065
  if (insertPos === -1) {
939
- console.log(chalk7.red("Failed to parse socialProviders block"));
1066
+ console.log(chalk8.red("Failed to parse socialProviders block"));
940
1067
  return;
941
1068
  }
942
1069
  content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
@@ -944,7 +1071,7 @@ var googleRun = async () => {
944
1071
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
945
1072
  if (!databaseRegex.test(content)) {
946
1073
  console.log(
947
- chalk7.red(
1074
+ chalk8.red(
948
1075
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
949
1076
  )
950
1077
  );
@@ -993,14 +1120,14 @@ GOOGLE_CLIENT_SECRET=
993
1120
  if (fs8.existsSync(componentTemplate)) {
994
1121
  fs8.copyFileSync(componentTemplate, componentDest);
995
1122
  }
996
- console.log(chalk7.green("Google provider added & merged successfully"));
1123
+ console.log(chalk8.green("Google provider added & merged successfully"));
997
1124
  } catch (error) {
998
- console.log(chalk7.red("googleRun error:"), error);
1125
+ console.log(chalk8.red("googleRun error:"), error);
999
1126
  }
1000
1127
  };
1001
1128
 
1002
1129
  // script/githubRun.ts
1003
- import chalk8 from "chalk";
1130
+ import chalk9 from "chalk";
1004
1131
  import fs9 from "fs";
1005
1132
  import path9 from "path";
1006
1133
  import { fileURLToPath as fileURLToPath8 } from "url";
@@ -1013,16 +1140,16 @@ var githubRun = async () => {
1013
1140
  const folder = fs9.existsSync(srcPath) ? "src" : "";
1014
1141
  const authFilePath = path9.join(projectDir, folder, "lib", "auth.ts");
1015
1142
  if (!fs9.existsSync(authFilePath)) {
1016
- console.log(chalk8.red("auth.ts file not found"));
1143
+ console.log(chalk9.red("auth.ts file not found"));
1017
1144
  return;
1018
1145
  }
1019
1146
  let content = fs9.readFileSync(authFilePath, "utf8");
1020
1147
  if (!content.includes("betterAuth({")) {
1021
- console.log(chalk8.red("betterAuth({}) block not found"));
1148
+ console.log(chalk9.red("betterAuth({}) block not found"));
1022
1149
  return;
1023
1150
  }
1024
1151
  if (content.includes("socialProviders") && content.includes("github:")) {
1025
- console.log(chalk8.yellow("GitHub provider already exists"));
1152
+ console.log(chalk9.yellow("GitHub provider already exists"));
1026
1153
  return;
1027
1154
  }
1028
1155
  const githubProviderEntry = `
@@ -1045,7 +1172,7 @@ var githubRun = async () => {
1045
1172
  }
1046
1173
  }
1047
1174
  if (insertPos === -1) {
1048
- console.log(chalk8.red("Failed to parse socialProviders block"));
1175
+ console.log(chalk9.red("Failed to parse socialProviders block"));
1049
1176
  return;
1050
1177
  }
1051
1178
  content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
@@ -1053,7 +1180,7 @@ var githubRun = async () => {
1053
1180
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1054
1181
  if (!databaseRegex.test(content)) {
1055
1182
  console.log(
1056
- chalk8.red(
1183
+ chalk9.red(
1057
1184
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1058
1185
  )
1059
1186
  );
@@ -1102,18 +1229,14 @@ GITHUB_CLIENT_SECRET=
1102
1229
  if (fs9.existsSync(componentTemplate)) {
1103
1230
  fs9.copyFileSync(componentTemplate, componentDest);
1104
1231
  }
1105
- console.log(chalk8.green("GitHub provider added & merged successfully"));
1232
+ console.log(chalk9.green("GitHub provider added & merged successfully"));
1106
1233
  } catch (error) {
1107
- console.log(chalk8.red("githubRun error:"), error);
1234
+ console.log(chalk9.red("githubRun error:"), error);
1108
1235
  }
1109
1236
  };
1110
1237
 
1111
- // cli/provider.ts
1112
- import path12 from "path";
1113
- import fs12 from "fs";
1114
-
1115
1238
  // script/googleRunTanstackState.ts
1116
- import chalk9 from "chalk";
1239
+ import chalk10 from "chalk";
1117
1240
  import fs10 from "fs";
1118
1241
  import path10 from "path";
1119
1242
  import { fileURLToPath as fileURLToPath9 } from "url";
@@ -1125,16 +1248,16 @@ var googleRunTanstackState = async () => {
1125
1248
  const srcPath = path10.join(projectDir, "src");
1126
1249
  const authFilePath = path10.join(srcPath, "lib", "auth.ts");
1127
1250
  if (!fs10.existsSync(authFilePath)) {
1128
- console.log(chalk9.red("auth.ts file not found"));
1251
+ console.log(chalk10.red("auth.ts file not found"));
1129
1252
  return;
1130
1253
  }
1131
1254
  let content = fs10.readFileSync(authFilePath, "utf8");
1132
1255
  if (!content.includes("betterAuth({")) {
1133
- console.log(chalk9.red("betterAuth({}) block not found"));
1256
+ console.log(chalk10.red("betterAuth({}) block not found"));
1134
1257
  return;
1135
1258
  }
1136
1259
  if (content.includes("socialProviders") && content.includes("google:")) {
1137
- console.log(chalk9.yellow("Google provider already exists"));
1260
+ console.log(chalk10.yellow("Google provider already exists"));
1138
1261
  return;
1139
1262
  }
1140
1263
  const googleProviderEntry = `
@@ -1157,7 +1280,7 @@ var googleRunTanstackState = async () => {
1157
1280
  }
1158
1281
  }
1159
1282
  if (insertPos === -1) {
1160
- console.log(chalk9.red("Failed to parse socialProviders block"));
1283
+ console.log(chalk10.red("Failed to parse socialProviders block"));
1161
1284
  return;
1162
1285
  }
1163
1286
  content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
@@ -1165,7 +1288,7 @@ var googleRunTanstackState = async () => {
1165
1288
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1166
1289
  if (!databaseRegex.test(content)) {
1167
1290
  console.log(
1168
- chalk9.red(
1291
+ chalk10.red(
1169
1292
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1170
1293
  )
1171
1294
  );
@@ -1209,14 +1332,14 @@ GOOGLE_CLIENT_SECRET=
1209
1332
  if (fs10.existsSync(componentTemplate)) {
1210
1333
  fs10.copyFileSync(componentTemplate, componentDest);
1211
1334
  }
1212
- console.log(chalk9.green("Google provider added & merged successfully"));
1335
+ console.log(chalk10.green("Google provider added & merged successfully"));
1213
1336
  } catch (error) {
1214
- console.log(chalk9.red("googleRunTanstackState error:"), error);
1337
+ console.log(chalk10.red("googleRunTanstackState error:"), error);
1215
1338
  }
1216
1339
  };
1217
1340
 
1218
1341
  // script/githubRunTanstackState.ts
1219
- import chalk10 from "chalk";
1342
+ import chalk11 from "chalk";
1220
1343
  import fs11 from "fs";
1221
1344
  import path11 from "path";
1222
1345
  import { fileURLToPath as fileURLToPath10 } from "url";
@@ -1228,16 +1351,16 @@ var githubRunTanstackState = async () => {
1228
1351
  const srcPath = path11.join(projectDir, "src");
1229
1352
  const authFilePath = path11.join(srcPath, "lib", "auth.ts");
1230
1353
  if (!fs11.existsSync(authFilePath)) {
1231
- console.log(chalk10.red("auth.ts file not found"));
1354
+ console.log(chalk11.red("auth.ts file not found"));
1232
1355
  return;
1233
1356
  }
1234
1357
  let content = fs11.readFileSync(authFilePath, "utf8");
1235
1358
  if (!content.includes("betterAuth({")) {
1236
- console.log(chalk10.red("betterAuth({}) block not found"));
1359
+ console.log(chalk11.red("betterAuth({}) block not found"));
1237
1360
  return;
1238
1361
  }
1239
1362
  if (content.includes("socialProviders") && content.includes("github:")) {
1240
- console.log(chalk10.yellow("Github provider already exists"));
1363
+ console.log(chalk11.yellow("Github provider already exists"));
1241
1364
  return;
1242
1365
  }
1243
1366
  const githubProviderEntry = `
@@ -1260,7 +1383,7 @@ var githubRunTanstackState = async () => {
1260
1383
  }
1261
1384
  }
1262
1385
  if (insertPos === -1) {
1263
- console.log(chalk10.red("Failed to parse socialProviders block"));
1386
+ console.log(chalk11.red("Failed to parse socialProviders block"));
1264
1387
  return;
1265
1388
  }
1266
1389
  content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
@@ -1268,7 +1391,7 @@ var githubRunTanstackState = async () => {
1268
1391
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1269
1392
  if (!databaseRegex.test(content)) {
1270
1393
  console.log(
1271
- chalk10.red(
1394
+ chalk11.red(
1272
1395
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1273
1396
  )
1274
1397
  );
@@ -1312,22 +1435,19 @@ GITHUB_CLIENT_SECRET=
1312
1435
  if (fs11.existsSync(componentTemplate)) {
1313
1436
  fs11.copyFileSync(componentTemplate, componentDest);
1314
1437
  }
1315
- console.log(chalk10.green("Github provider added & merged successfully"));
1438
+ console.log(chalk11.green("Github provider added & merged successfully"));
1316
1439
  } catch (error) {
1317
- console.log(chalk10.red("githubRunTanstackState error:"), error);
1440
+ console.log(chalk11.red("githubRunTanstackState error:"), error);
1318
1441
  }
1319
1442
  };
1320
1443
 
1321
1444
  // cli/provider.ts
1322
1445
  var providers = async ({ provider }) => {
1323
1446
  try {
1324
- const projectDir = process.cwd();
1325
- const packageJsonPath = path12.join(projectDir, "package.json");
1326
- let framework = "tanstack state";
1327
- if (fs12.existsSync(packageJsonPath)) {
1328
- const packageJson2 = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1329
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
1330
- framework = hasNext ? "Next js" : "tanstack state";
1447
+ const { framework, error } = await getFramework();
1448
+ if (error) {
1449
+ console.log(chalk12.red(error));
1450
+ return;
1331
1451
  }
1332
1452
  if (framework === "Next js" && provider == "google") {
1333
1453
  await googleRun();
@@ -1340,45 +1460,96 @@ var providers = async ({ provider }) => {
1340
1460
  await githubRunTanstackState();
1341
1461
  }
1342
1462
  } catch (error) {
1343
- console.log(chalk11.red("Error adding provider:"), error);
1463
+ console.log(chalk12.red("Error adding provider:"), error);
1344
1464
  }
1345
1465
  };
1346
1466
 
1347
- // cli/forget.ts
1348
- import path22 from "path";
1349
- import fs22 from "fs";
1350
-
1351
1467
  // script/forgetNext.ts
1352
- import chalk18 from "chalk";
1353
- import path20 from "path";
1468
+ import chalk20 from "chalk";
1469
+ import path19 from "path";
1354
1470
  import { fileURLToPath as fileURLToPath17 } from "url";
1355
- import fs20 from "fs";
1471
+ import fs19 from "fs";
1356
1472
 
1357
1473
  // cli/email.ts
1358
- import path19 from "path";
1359
- import fs19 from "fs";
1474
+ import path18 from "path";
1475
+ import fs18 from "fs";
1360
1476
  import inquirer4 from "inquirer";
1361
1477
 
1362
1478
  // email/gmailRun.ts
1363
- import chalk12 from "chalk";
1364
- import path13 from "path";
1365
- import fs13 from "fs";
1479
+ import chalk13 from "chalk";
1480
+ import path12 from "path";
1481
+ import fs12 from "fs";
1366
1482
  import { fileURLToPath as fileURLToPath11 } from "url";
1367
1483
  var gmailRun = async () => {
1484
+ try {
1485
+ const projectDir = process.cwd();
1486
+ const packageJsonPath = path12.join(projectDir, "package.json");
1487
+ const packageJson2 = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1488
+ const srcFolder = fs12.existsSync(path12.join(projectDir, "src")) ? "src" : "";
1489
+ const __filename = fileURLToPath11(import.meta.url);
1490
+ const __dirname = path12.dirname(__filename);
1491
+ if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1492
+ console.log(chalk13.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1493
+ packageManager("nodemailer");
1494
+ packageManager("@types/nodemailer", true);
1495
+ }
1496
+ if (!packageJson2.dependencies?.["@react-email/components"]) {
1497
+ console.log(chalk13.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1498
+ packageManager("@react-email/components");
1499
+ }
1500
+ const envPath = path12.join(projectDir, ".env");
1501
+ const envContent = fs12.readFileSync(envPath, "utf8");
1502
+ if (!envContent.includes("GMAIL_HOST") && !envContent.includes("GMAIL_PORT") && !envContent.includes("GMAIL_SERVICE") && !envContent.includes("GMAIL_MAIL") && !envContent.includes("GMAIL_NAME") && !envContent.includes("GMAIL_PASSWORD")) {
1503
+ fs12.appendFileSync(envPath, `
1504
+
1505
+ # Gmail API Key for sending emails`);
1506
+ fs12.appendFileSync(envPath, `
1507
+ GMAIL_HOST=`);
1508
+ fs12.appendFileSync(envPath, `
1509
+ GMAIL_PORT=`);
1510
+ fs12.appendFileSync(envPath, `
1511
+ GMAIL_SERVICE=`);
1512
+ fs12.appendFileSync(envPath, `
1513
+ GMAIL_MAIL=`);
1514
+ fs12.appendFileSync(envPath, `
1515
+ GMAIL_NAME=`);
1516
+ fs12.appendFileSync(envPath, `
1517
+ GMAIL_PASSWORD=`);
1518
+ }
1519
+ const templatePath = path12.resolve(
1520
+ __dirname,
1521
+ "./template/email/emailGmail.ts"
1522
+ );
1523
+ const libPath = path12.join(projectDir, srcFolder, "lib");
1524
+ if (!fs12.existsSync(libPath)) {
1525
+ fs12.mkdirSync(libPath, { recursive: true });
1526
+ }
1527
+ const libDestinationPath = path12.join(libPath, "email.ts");
1528
+ fs12.copyFileSync(templatePath, libDestinationPath);
1529
+ } catch (error) {
1530
+ console.log(chalk13.red(error));
1531
+ }
1532
+ };
1533
+
1534
+ // email/gmailRunTanstackState.ts
1535
+ import chalk14 from "chalk";
1536
+ import path13 from "path";
1537
+ import fs13 from "fs";
1538
+ import { fileURLToPath as fileURLToPath12 } from "url";
1539
+ var gmailRunTanstackState = async () => {
1368
1540
  try {
1369
1541
  const projectDir = process.cwd();
1370
1542
  const packageJsonPath = path13.join(projectDir, "package.json");
1371
1543
  const packageJson2 = JSON.parse(fs13.readFileSync(packageJsonPath, "utf-8"));
1372
- const srcFolder = fs13.existsSync(path13.join(projectDir, "src")) ? "src" : "";
1373
- const __filename = fileURLToPath11(import.meta.url);
1544
+ const __filename = fileURLToPath12(import.meta.url);
1374
1545
  const __dirname = path13.dirname(__filename);
1375
1546
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1376
- console.log(chalk12.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1547
+ console.log(chalk14.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1377
1548
  packageManager("nodemailer");
1378
1549
  packageManager("@types/nodemailer", true);
1379
1550
  }
1380
1551
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1381
- console.log(chalk12.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1552
+ console.log(chalk14.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1382
1553
  packageManager("@react-email/components");
1383
1554
  }
1384
1555
  const envPath = path13.join(projectDir, ".env");
@@ -1404,92 +1575,92 @@ GMAIL_PASSWORD=`);
1404
1575
  __dirname,
1405
1576
  "./template/email/emailGmail.ts"
1406
1577
  );
1407
- const libPath = path13.join(projectDir, srcFolder, "lib");
1578
+ const libPath = path13.join(projectDir, "src", "lib");
1408
1579
  if (!fs13.existsSync(libPath)) {
1409
1580
  fs13.mkdirSync(libPath, { recursive: true });
1410
1581
  }
1411
1582
  const libDestinationPath = path13.join(libPath, "email.ts");
1412
1583
  fs13.copyFileSync(templatePath, libDestinationPath);
1413
1584
  } catch (error) {
1414
- console.log(chalk12.red(error));
1585
+ console.log(chalk14.red(error));
1415
1586
  }
1416
1587
  };
1417
1588
 
1418
- // email/gmailRunTanstackState.ts
1419
- import chalk13 from "chalk";
1589
+ // email/awsSesRun.ts
1590
+ import chalk15 from "chalk";
1420
1591
  import path14 from "path";
1421
1592
  import fs14 from "fs";
1422
- import { fileURLToPath as fileURLToPath12 } from "url";
1423
- var gmailRunTanstackState = async () => {
1593
+ import { fileURLToPath as fileURLToPath13 } from "url";
1594
+ var awsSesRun = async () => {
1424
1595
  try {
1425
1596
  const projectDir = process.cwd();
1426
1597
  const packageJsonPath = path14.join(projectDir, "package.json");
1427
1598
  const packageJson2 = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
1428
- const __filename = fileURLToPath12(import.meta.url);
1599
+ const srcFolder = fs14.existsSync(path14.join(projectDir, "src")) ? "src" : "";
1600
+ const __filename = fileURLToPath13(import.meta.url);
1429
1601
  const __dirname = path14.dirname(__filename);
1430
1602
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1431
- console.log(chalk13.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1603
+ console.log(chalk15.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1432
1604
  packageManager("nodemailer");
1433
1605
  packageManager("@types/nodemailer", true);
1434
1606
  }
1435
1607
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1436
- console.log(chalk13.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1608
+ console.log(chalk15.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1437
1609
  packageManager("@react-email/components");
1438
1610
  }
1439
1611
  const envPath = path14.join(projectDir, ".env");
1440
1612
  const envContent = fs14.readFileSync(envPath, "utf8");
1441
- if (!envContent.includes("GMAIL_HOST") && !envContent.includes("GMAIL_PORT") && !envContent.includes("GMAIL_SERVICE") && !envContent.includes("GMAIL_MAIL") && !envContent.includes("GMAIL_NAME") && !envContent.includes("GMAIL_PASSWORD")) {
1613
+ if (!envContent.includes("AWS_SES_HOST") && !envContent.includes("AWS_SES_PORT") && !envContent.includes("AWS_SES_SERVICE") && !envContent.includes("AWS_SES_USER") && !envContent.includes("AWS_SES_PASS") && !envContent.includes("AWS_SES_FROM")) {
1442
1614
  fs14.appendFileSync(envPath, `
1443
1615
 
1444
- # Gmail API Key for sending emails`);
1616
+ # AWS SES API Key for sending emails`);
1445
1617
  fs14.appendFileSync(envPath, `
1446
- GMAIL_HOST=`);
1618
+ AWS_SES_HOST=`);
1447
1619
  fs14.appendFileSync(envPath, `
1448
- GMAIL_PORT=`);
1620
+ AWS_SES_PORT=`);
1449
1621
  fs14.appendFileSync(envPath, `
1450
- GMAIL_SERVICE=`);
1622
+ AWS_SES_SERVICE=`);
1451
1623
  fs14.appendFileSync(envPath, `
1452
- GMAIL_MAIL=`);
1624
+ AWS_SES_USER=`);
1453
1625
  fs14.appendFileSync(envPath, `
1454
- GMAIL_NAME=`);
1626
+ AWS_SES_PASS=`);
1455
1627
  fs14.appendFileSync(envPath, `
1456
- GMAIL_PASSWORD=`);
1628
+ AWS_SES_FROM=`);
1457
1629
  }
1458
1630
  const templatePath = path14.resolve(
1459
1631
  __dirname,
1460
- "./template/email/emailGmail.ts"
1632
+ "./template/email/emailAwsSes.ts"
1461
1633
  );
1462
- const libPath = path14.join(projectDir, "src", "lib");
1634
+ const libPath = path14.join(projectDir, srcFolder, "lib");
1463
1635
  if (!fs14.existsSync(libPath)) {
1464
1636
  fs14.mkdirSync(libPath, { recursive: true });
1465
1637
  }
1466
1638
  const libDestinationPath = path14.join(libPath, "email.ts");
1467
1639
  fs14.copyFileSync(templatePath, libDestinationPath);
1468
1640
  } catch (error) {
1469
- console.log(chalk13.red(error));
1641
+ console.log(chalk15.red(error));
1470
1642
  }
1471
1643
  };
1472
1644
 
1473
- // email/awsSesRun.ts
1474
- import chalk14 from "chalk";
1645
+ // email/awsSesRunTanstackState.ts
1646
+ import chalk16 from "chalk";
1475
1647
  import path15 from "path";
1476
1648
  import fs15 from "fs";
1477
- import { fileURLToPath as fileURLToPath13 } from "url";
1478
- var awsSesRun = async () => {
1649
+ import { fileURLToPath as fileURLToPath14 } from "url";
1650
+ var awsSesRunTanstackState = async () => {
1479
1651
  try {
1480
1652
  const projectDir = process.cwd();
1481
1653
  const packageJsonPath = path15.join(projectDir, "package.json");
1482
1654
  const packageJson2 = JSON.parse(fs15.readFileSync(packageJsonPath, "utf-8"));
1483
- const srcFolder = fs15.existsSync(path15.join(projectDir, "src")) ? "src" : "";
1484
- const __filename = fileURLToPath13(import.meta.url);
1655
+ const __filename = fileURLToPath14(import.meta.url);
1485
1656
  const __dirname = path15.dirname(__filename);
1486
1657
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1487
- console.log(chalk14.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1658
+ console.log(chalk16.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1488
1659
  packageManager("nodemailer");
1489
1660
  packageManager("@types/nodemailer", true);
1490
1661
  }
1491
1662
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1492
- console.log(chalk14.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1663
+ console.log(chalk16.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1493
1664
  packageManager("@react-email/components");
1494
1665
  }
1495
1666
  const envPath = path15.join(projectDir, ".env");
@@ -1515,91 +1686,84 @@ AWS_SES_FROM=`);
1515
1686
  __dirname,
1516
1687
  "./template/email/emailAwsSes.ts"
1517
1688
  );
1518
- const libPath = path15.join(projectDir, srcFolder, "lib");
1689
+ const libPath = path15.join(projectDir, "src", "lib");
1519
1690
  if (!fs15.existsSync(libPath)) {
1520
1691
  fs15.mkdirSync(libPath, { recursive: true });
1521
1692
  }
1522
1693
  const libDestinationPath = path15.join(libPath, "email.ts");
1523
1694
  fs15.copyFileSync(templatePath, libDestinationPath);
1524
1695
  } catch (error) {
1525
- console.log(chalk14.red(error));
1696
+ console.log(chalk16.red(error));
1526
1697
  }
1527
1698
  };
1528
1699
 
1529
- // email/awsSesRunTanstackState.ts
1530
- import chalk15 from "chalk";
1700
+ // email/resendRun.ts
1701
+ import chalk17 from "chalk";
1531
1702
  import path16 from "path";
1532
1703
  import fs16 from "fs";
1533
- import { fileURLToPath as fileURLToPath14 } from "url";
1534
- var awsSesRunTanstackState = async () => {
1704
+ import { fileURLToPath as fileURLToPath15 } from "url";
1705
+ var resendRun = async () => {
1535
1706
  try {
1536
1707
  const projectDir = process.cwd();
1537
1708
  const packageJsonPath = path16.join(projectDir, "package.json");
1538
1709
  const packageJson2 = JSON.parse(fs16.readFileSync(packageJsonPath, "utf-8"));
1539
- const __filename = fileURLToPath14(import.meta.url);
1710
+ const srcFolder = fs16.existsSync(path16.join(projectDir, "src")) ? "src" : "";
1711
+ const __filename = fileURLToPath15(import.meta.url);
1540
1712
  const __dirname = path16.dirname(__filename);
1541
- if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1542
- console.log(chalk15.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1543
- packageManager("nodemailer");
1544
- packageManager("@types/nodemailer", true);
1713
+ if (!packageJson2.dependencies?.resend) {
1714
+ console.log(chalk17.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1715
+ packageManager("resend");
1545
1716
  }
1546
1717
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1547
- console.log(chalk15.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1718
+ console.log(chalk17.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1548
1719
  packageManager("@react-email/components");
1549
1720
  }
1550
1721
  const envPath = path16.join(projectDir, ".env");
1551
1722
  const envContent = fs16.readFileSync(envPath, "utf8");
1552
- if (!envContent.includes("AWS_SES_HOST") && !envContent.includes("AWS_SES_PORT") && !envContent.includes("AWS_SES_SERVICE") && !envContent.includes("AWS_SES_USER") && !envContent.includes("AWS_SES_PASS") && !envContent.includes("AWS_SES_FROM")) {
1723
+ if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1553
1724
  fs16.appendFileSync(envPath, `
1554
1725
 
1555
- # AWS SES API Key for sending emails`);
1556
- fs16.appendFileSync(envPath, `
1557
- AWS_SES_HOST=`);
1558
- fs16.appendFileSync(envPath, `
1559
- AWS_SES_PORT=`);
1560
- fs16.appendFileSync(envPath, `
1561
- AWS_SES_SERVICE=`);
1726
+ # Resend API Key for sending emails`);
1562
1727
  fs16.appendFileSync(envPath, `
1563
- AWS_SES_USER=`);
1728
+ RESEND_API_KEY=`);
1564
1729
  fs16.appendFileSync(envPath, `
1565
- AWS_SES_PASS=`);
1730
+ EMAIL_SENDER_NAME=Your Name`);
1566
1731
  fs16.appendFileSync(envPath, `
1567
- AWS_SES_FROM=`);
1732
+ EMAIL_SENDER_ADDRESS=`);
1568
1733
  }
1569
1734
  const templatePath = path16.resolve(
1570
1735
  __dirname,
1571
- "./template/email/emailAwsSes.ts"
1736
+ "./template/email/emailResend.ts"
1572
1737
  );
1573
- const libPath = path16.join(projectDir, "src", "lib");
1738
+ const libPath = path16.join(projectDir, srcFolder, "lib");
1574
1739
  if (!fs16.existsSync(libPath)) {
1575
1740
  fs16.mkdirSync(libPath, { recursive: true });
1576
1741
  }
1577
1742
  const libDestinationPath = path16.join(libPath, "email.ts");
1578
1743
  fs16.copyFileSync(templatePath, libDestinationPath);
1579
1744
  } catch (error) {
1580
- console.log(chalk15.red(error));
1745
+ console.log(chalk17.red(error));
1581
1746
  }
1582
1747
  };
1583
1748
 
1584
- // email/resendRun.ts
1585
- import chalk16 from "chalk";
1749
+ // email/resendRunTanstackState.ts
1750
+ import chalk18 from "chalk";
1586
1751
  import path17 from "path";
1587
1752
  import fs17 from "fs";
1588
- import { fileURLToPath as fileURLToPath15 } from "url";
1589
- var resendRun = async () => {
1753
+ import { fileURLToPath as fileURLToPath16 } from "url";
1754
+ var resendRunTanstackState = async () => {
1590
1755
  try {
1591
1756
  const projectDir = process.cwd();
1592
1757
  const packageJsonPath = path17.join(projectDir, "package.json");
1593
1758
  const packageJson2 = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
1594
- const srcFolder = fs17.existsSync(path17.join(projectDir, "src")) ? "src" : "";
1595
- const __filename = fileURLToPath15(import.meta.url);
1759
+ const __filename = fileURLToPath16(import.meta.url);
1596
1760
  const __dirname = path17.dirname(__filename);
1597
1761
  if (!packageJson2.dependencies?.resend) {
1598
- console.log(chalk16.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1762
+ console.log(chalk18.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1599
1763
  packageManager("resend");
1600
1764
  }
1601
1765
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1602
- console.log(chalk16.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1766
+ console.log(chalk18.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1603
1767
  packageManager("@react-email/components");
1604
1768
  }
1605
1769
  const envPath = path17.join(projectDir, ".env");
@@ -1619,79 +1783,30 @@ EMAIL_SENDER_ADDRESS=`);
1619
1783
  __dirname,
1620
1784
  "./template/email/emailResend.ts"
1621
1785
  );
1622
- const libPath = path17.join(projectDir, srcFolder, "lib");
1786
+ const libPath = path17.join(projectDir, "src", "lib");
1623
1787
  if (!fs17.existsSync(libPath)) {
1624
1788
  fs17.mkdirSync(libPath, { recursive: true });
1625
1789
  }
1626
1790
  const libDestinationPath = path17.join(libPath, "email.ts");
1627
1791
  fs17.copyFileSync(templatePath, libDestinationPath);
1628
1792
  } catch (error) {
1629
- console.log(chalk16.red(error));
1630
- }
1631
- };
1632
-
1633
- // email/resendRunTanstackState.ts
1634
- import chalk17 from "chalk";
1635
- import path18 from "path";
1636
- import fs18 from "fs";
1637
- import { fileURLToPath as fileURLToPath16 } from "url";
1638
- var resendRunTanstackState = async () => {
1639
- try {
1640
- const projectDir = process.cwd();
1641
- const packageJsonPath = path18.join(projectDir, "package.json");
1642
- const packageJson2 = JSON.parse(fs18.readFileSync(packageJsonPath, "utf-8"));
1643
- const __filename = fileURLToPath16(import.meta.url);
1644
- const __dirname = path18.dirname(__filename);
1645
- if (!packageJson2.dependencies?.resend) {
1646
- console.log(chalk17.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1647
- packageManager("resend");
1648
- }
1649
- if (!packageJson2.dependencies?.["@react-email/components"]) {
1650
- console.log(chalk17.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1651
- packageManager("@react-email/components");
1652
- }
1653
- const envPath = path18.join(projectDir, ".env");
1654
- const envContent = fs18.readFileSync(envPath, "utf8");
1655
- if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1656
- fs18.appendFileSync(envPath, `
1657
-
1658
- # Resend API Key for sending emails`);
1659
- fs18.appendFileSync(envPath, `
1660
- RESEND_API_KEY=`);
1661
- fs18.appendFileSync(envPath, `
1662
- EMAIL_SENDER_NAME=Your Name`);
1663
- fs18.appendFileSync(envPath, `
1664
- EMAIL_SENDER_ADDRESS=`);
1665
- }
1666
- const templatePath = path18.resolve(
1667
- __dirname,
1668
- "./template/email/emailResend.ts"
1669
- );
1670
- const libPath = path18.join(projectDir, "src", "lib");
1671
- if (!fs18.existsSync(libPath)) {
1672
- fs18.mkdirSync(libPath, { recursive: true });
1673
- }
1674
- const libDestinationPath = path18.join(libPath, "email.ts");
1675
- fs18.copyFileSync(templatePath, libDestinationPath);
1676
- } catch (error) {
1677
- console.log(chalk17.red(error));
1793
+ console.log(chalk18.red(error));
1678
1794
  }
1679
1795
  };
1680
1796
 
1681
1797
  // cli/email.ts
1798
+ import chalk19 from "chalk";
1682
1799
  var email = async () => {
1683
1800
  const projectDir = process.cwd();
1684
- const packageJsonPath = path19.join(projectDir, "package.json");
1685
- let framework = "tanstack state";
1686
- if (fs19.existsSync(packageJsonPath)) {
1687
- const packageJson2 = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
1688
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
1689
- framework = hasNext ? "Next js" : "tanstack state";
1801
+ const { framework, error } = await getFramework();
1802
+ if (error) {
1803
+ console.log(chalk19.red(error));
1804
+ return;
1690
1805
  }
1691
1806
  if (framework === "Next js") {
1692
- const srcFolder = fs19.existsSync(path19.join(projectDir, "src")) ? "src" : "";
1693
- const emailPath = path19.join(projectDir, srcFolder, "lib", "email.ts");
1694
- if (fs19.existsSync(emailPath)) {
1807
+ const srcFolder = fs18.existsSync(path18.join(projectDir, "src")) ? "src" : "";
1808
+ const emailPath = path18.join(projectDir, srcFolder, "lib", "email.ts");
1809
+ if (fs18.existsSync(emailPath)) {
1695
1810
  const answers2 = await inquirer4.prompt([
1696
1811
  {
1697
1812
  type: "confirm",
@@ -1706,12 +1821,12 @@ var email = async () => {
1706
1821
  }
1707
1822
  }
1708
1823
  if (framework === "tanstack state") {
1709
- const srcFolderTanstackState = path19.join(projectDir, "src");
1710
- const libPathTanstackState = path19.join(
1824
+ const srcFolderTanstackState = path18.join(projectDir, "src");
1825
+ const libPathTanstackState = path18.join(
1711
1826
  srcFolderTanstackState,
1712
1827
  "lib/email.ts"
1713
1828
  );
1714
- if (fs19.existsSync(libPathTanstackState)) {
1829
+ if (fs18.existsSync(libPathTanstackState)) {
1715
1830
  const answers2 = await inquirer4.prompt([
1716
1831
  {
1717
1832
  type: "confirm",
@@ -1758,19 +1873,19 @@ var forgetNext = async () => {
1758
1873
  try {
1759
1874
  const projectDir = process.cwd();
1760
1875
  const __filename = fileURLToPath17(import.meta.url);
1761
- const __dirname = path20.dirname(__filename);
1762
- const srcPath = path20.join(projectDir, "src");
1763
- const folder = fs20.existsSync(srcPath) ? "src" : "";
1764
- const emailFilePath = path20.join(projectDir, folder, "lib", "email.ts");
1765
- if (!fs20.existsSync(emailFilePath)) {
1876
+ const __dirname = path19.dirname(__filename);
1877
+ const srcPath = path19.join(projectDir, "src");
1878
+ const folder = fs19.existsSync(srcPath) ? "src" : "";
1879
+ const emailFilePath = path19.join(projectDir, folder, "lib", "email.ts");
1880
+ if (!fs19.existsSync(emailFilePath)) {
1766
1881
  await email();
1767
1882
  }
1768
- const authFilePath = path20.join(projectDir, folder, "lib", "auth.ts");
1769
- if (!fs20.existsSync(authFilePath)) {
1770
- console.log(chalk18.red("auth.ts file not found."));
1883
+ const authFilePath = path19.join(projectDir, folder, "lib", "auth.ts");
1884
+ if (!fs19.existsSync(authFilePath)) {
1885
+ console.log(chalk20.red("auth.ts file not found."));
1771
1886
  return;
1772
1887
  }
1773
- let content = fs20.readFileSync(authFilePath, "utf8");
1888
+ let content = fs19.readFileSync(authFilePath, "utf8");
1774
1889
  const codeAdded = ` sendResetPassword: async ({ user, url, token }) => {
1775
1890
  await sendEmail({
1776
1891
  email: user.email!,
@@ -1814,7 +1929,7 @@ var forgetNext = async () => {
1814
1929
  content = before + `
1815
1930
  ${codeAdded}` + after;
1816
1931
  }
1817
- fs20.writeFileSync(authFilePath, content, "utf8");
1932
+ fs19.writeFileSync(authFilePath, content, "utf8");
1818
1933
  if (!content.includes("import { sendEmail }")) {
1819
1934
  const lastImportIndex = content.lastIndexOf("import");
1820
1935
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -1824,128 +1939,128 @@ var forgetNext = async () => {
1824
1939
  import { sendEmail } from "./email";
1825
1940
  `;
1826
1941
  content = beforeImports + newImports + afterImports;
1827
- fs20.writeFileSync(authFilePath, content, "utf8");
1942
+ fs19.writeFileSync(authFilePath, content, "utf8");
1828
1943
  }
1829
- const componentPath = path20.resolve(
1944
+ const componentPath = path19.resolve(
1830
1945
  __dirname,
1831
1946
  "./template/email/reset-password.tsx"
1832
1947
  );
1833
- const destinationPath = path20.join(
1948
+ const destinationPath = path19.join(
1834
1949
  projectDir,
1835
1950
  folder,
1836
1951
  "components",
1837
1952
  "email"
1838
1953
  );
1839
- if (!fs20.existsSync(destinationPath)) {
1840
- fs20.mkdirSync(destinationPath, { recursive: true });
1954
+ if (!fs19.existsSync(destinationPath)) {
1955
+ fs19.mkdirSync(destinationPath, { recursive: true });
1841
1956
  }
1842
- const emailDestinationPath = path20.join(
1957
+ const emailDestinationPath = path19.join(
1843
1958
  destinationPath,
1844
1959
  "reset-password.tsx"
1845
1960
  );
1846
- if (fs20.existsSync(componentPath)) {
1847
- fs20.copyFileSync(componentPath, emailDestinationPath);
1961
+ if (fs19.existsSync(componentPath)) {
1962
+ fs19.copyFileSync(componentPath, emailDestinationPath);
1848
1963
  }
1849
- const forgetComponentPath = path20.resolve(
1964
+ const forgetComponentPath = path19.resolve(
1850
1965
  __dirname,
1851
1966
  "./template/components/ForgetComponent.tsx"
1852
1967
  );
1853
- const componentsDestinationPath = path20.join(
1968
+ const componentsDestinationPath = path19.join(
1854
1969
  projectDir,
1855
1970
  folder,
1856
1971
  "components",
1857
1972
  "authverse"
1858
1973
  );
1859
- if (!fs20.existsSync(componentsDestinationPath)) {
1860
- fs20.mkdirSync(componentsDestinationPath, { recursive: true });
1974
+ if (!fs19.existsSync(componentsDestinationPath)) {
1975
+ fs19.mkdirSync(componentsDestinationPath, { recursive: true });
1861
1976
  }
1862
- const forgetDestinationPath = path20.join(
1977
+ const forgetDestinationPath = path19.join(
1863
1978
  componentsDestinationPath,
1864
1979
  "ForgetComponent.tsx"
1865
1980
  );
1866
- if (fs20.existsSync(forgetComponentPath)) {
1867
- fs20.copyFileSync(forgetComponentPath, forgetDestinationPath);
1981
+ if (fs19.existsSync(forgetComponentPath)) {
1982
+ fs19.copyFileSync(forgetComponentPath, forgetDestinationPath);
1868
1983
  }
1869
- const resetComponentPath = path20.resolve(
1984
+ const resetComponentPath = path19.resolve(
1870
1985
  __dirname,
1871
1986
  "./template/components/ResetComponent.tsx"
1872
1987
  );
1873
- const resetDestinationPath = path20.join(
1988
+ const resetDestinationPath = path19.join(
1874
1989
  componentsDestinationPath,
1875
1990
  "ResetComponent.tsx"
1876
1991
  );
1877
- if (fs20.existsSync(resetComponentPath)) {
1878
- fs20.copyFileSync(resetComponentPath, resetDestinationPath);
1992
+ if (fs19.existsSync(resetComponentPath)) {
1993
+ fs19.copyFileSync(resetComponentPath, resetDestinationPath);
1879
1994
  }
1880
- const authTemplatePath = path20.resolve(
1995
+ const authTemplatePath = path19.resolve(
1881
1996
  __dirname,
1882
1997
  "./template/app-auth-uiDesign"
1883
1998
  );
1884
- const appDestinationPath = path20.join(projectDir, folder, "app", "auth");
1885
- if (!fs20.existsSync(appDestinationPath)) {
1886
- fs20.mkdirSync(appDestinationPath, { recursive: true });
1999
+ const appDestinationPath = path19.join(projectDir, folder, "app", "auth");
2000
+ if (!fs19.existsSync(appDestinationPath)) {
2001
+ fs19.mkdirSync(appDestinationPath, { recursive: true });
1887
2002
  }
1888
- const forgetDestinationDir = path20.join(appDestinationPath, "forget");
1889
- if (!fs20.existsSync(forgetDestinationDir)) {
1890
- fs20.mkdirSync(forgetDestinationDir, { recursive: true });
2003
+ const forgetDestinationDir = path19.join(appDestinationPath, "forget");
2004
+ if (!fs19.existsSync(forgetDestinationDir)) {
2005
+ fs19.mkdirSync(forgetDestinationDir, { recursive: true });
1891
2006
  }
1892
- const forgetPageDestinationPath = path20.join(
2007
+ const forgetPageDestinationPath = path19.join(
1893
2008
  forgetDestinationDir,
1894
2009
  "page.tsx"
1895
2010
  );
1896
- fs20.copyFileSync(
2011
+ fs19.copyFileSync(
1897
2012
  `${authTemplatePath}/forget/page.tsx`,
1898
2013
  forgetPageDestinationPath
1899
2014
  );
1900
- const resetDestinationDir = path20.join(
2015
+ const resetDestinationDir = path19.join(
1901
2016
  appDestinationPath,
1902
2017
  "reset-password"
1903
2018
  );
1904
- if (!fs20.existsSync(resetDestinationDir)) {
1905
- fs20.mkdirSync(resetDestinationDir, { recursive: true });
2019
+ if (!fs19.existsSync(resetDestinationDir)) {
2020
+ fs19.mkdirSync(resetDestinationDir, { recursive: true });
1906
2021
  }
1907
- const resetPageDestinationPath = path20.join(
2022
+ const resetPageDestinationPath = path19.join(
1908
2023
  resetDestinationDir,
1909
2024
  "page.tsx"
1910
2025
  );
1911
- fs20.copyFileSync(
2026
+ fs19.copyFileSync(
1912
2027
  `${authTemplatePath}/reset-password/page.tsx`,
1913
2028
  resetPageDestinationPath
1914
2029
  );
1915
2030
  console.log(
1916
- chalk18.green("Successfully added forget and reset-password pages")
2031
+ chalk20.green("Successfully added forget and reset-password pages")
1917
2032
  );
1918
2033
  } else {
1919
2034
  console.log(
1920
- chalk18.red("Could not find emailAndPassword configuration in auth.ts")
2035
+ chalk20.red("Could not find emailAndPassword configuration in auth.ts")
1921
2036
  );
1922
2037
  }
1923
2038
  } catch (error) {
1924
- console.log(chalk18.red("Error adding sendResetPassword:"), error);
2039
+ console.log(chalk20.red("Error adding sendResetPassword:"), error);
1925
2040
  }
1926
2041
  };
1927
2042
 
1928
2043
  // script/forgetTanstack.ts
1929
- import chalk19 from "chalk";
1930
- import path21 from "path";
2044
+ import chalk21 from "chalk";
2045
+ import path20 from "path";
1931
2046
  import { fileURLToPath as fileURLToPath18 } from "url";
1932
- import fs21 from "fs";
2047
+ import fs20 from "fs";
1933
2048
  var forgetTanstack = async () => {
1934
2049
  try {
1935
2050
  const projectDir = process.cwd();
1936
2051
  const __filename = fileURLToPath18(import.meta.url);
1937
- const __dirname = path21.dirname(__filename);
1938
- const srcPath = path21.join(projectDir, "src");
1939
- const emailFilePath = path21.join(srcPath, "lib", "email.ts");
1940
- if (!fs21.existsSync(emailFilePath)) {
2052
+ const __dirname = path20.dirname(__filename);
2053
+ const srcPath = path20.join(projectDir, "src");
2054
+ const emailFilePath = path20.join(srcPath, "lib", "email.ts");
2055
+ if (!fs20.existsSync(emailFilePath)) {
1941
2056
  await email();
1942
2057
  }
1943
- const authFilePath = path21.join(srcPath, "lib", "auth.ts");
1944
- if (!fs21.existsSync(authFilePath)) {
1945
- console.log(chalk19.red("auth.ts file not found."));
2058
+ const authFilePath = path20.join(srcPath, "lib", "auth.ts");
2059
+ if (!fs20.existsSync(authFilePath)) {
2060
+ console.log(chalk21.red("auth.ts file not found."));
1946
2061
  return;
1947
2062
  }
1948
- let content = fs21.readFileSync(authFilePath, "utf8");
2063
+ let content = fs20.readFileSync(authFilePath, "utf8");
1949
2064
  const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
1950
2065
  await sendEmail({
1951
2066
  email: user.email!,
@@ -1989,7 +2104,7 @@ var forgetTanstack = async () => {
1989
2104
  content = before + `
1990
2105
  ${codeAdded}` + after;
1991
2106
  }
1992
- fs21.writeFileSync(authFilePath, content, "utf8");
2107
+ fs20.writeFileSync(authFilePath, content, "utf8");
1993
2108
  if (!content.includes("import { sendEmail }")) {
1994
2109
  const lastImportIndex = content.lastIndexOf("import");
1995
2110
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -1999,99 +2114,97 @@ var forgetTanstack = async () => {
1999
2114
  import { sendEmail } from "./email";
2000
2115
  `;
2001
2116
  content = beforeImports + newImports + afterImports;
2002
- fs21.writeFileSync(authFilePath, content, "utf8");
2117
+ fs20.writeFileSync(authFilePath, content, "utf8");
2003
2118
  }
2004
- const componentPath = path21.resolve(
2119
+ const componentPath = path20.resolve(
2005
2120
  __dirname,
2006
2121
  "./template/email/reset-password.tsx"
2007
2122
  );
2008
- const destinationPath = path21.join(srcPath, "components", "email");
2009
- if (!fs21.existsSync(destinationPath)) {
2010
- fs21.mkdirSync(destinationPath, { recursive: true });
2123
+ const destinationPath = path20.join(srcPath, "components", "email");
2124
+ if (!fs20.existsSync(destinationPath)) {
2125
+ fs20.mkdirSync(destinationPath, { recursive: true });
2011
2126
  }
2012
- const emailDestinationPath = path21.join(
2127
+ const emailDestinationPath = path20.join(
2013
2128
  destinationPath,
2014
2129
  "reset-password.tsx"
2015
2130
  );
2016
- if (fs21.existsSync(componentPath)) {
2017
- fs21.copyFileSync(componentPath, emailDestinationPath);
2131
+ if (fs20.existsSync(componentPath)) {
2132
+ fs20.copyFileSync(componentPath, emailDestinationPath);
2018
2133
  }
2019
- const forgetComponentPath = path21.resolve(
2134
+ const forgetComponentPath = path20.resolve(
2020
2135
  __dirname,
2021
2136
  "./template/TanstackState/components/ForgetComponent.tsx"
2022
2137
  );
2023
- const componentsDestinationPath = path21.join(
2138
+ const componentsDestinationPath = path20.join(
2024
2139
  srcPath,
2025
2140
  "components",
2026
2141
  "authverse"
2027
2142
  );
2028
- if (!fs21.existsSync(componentsDestinationPath)) {
2029
- fs21.mkdirSync(componentsDestinationPath, { recursive: true });
2143
+ if (!fs20.existsSync(componentsDestinationPath)) {
2144
+ fs20.mkdirSync(componentsDestinationPath, { recursive: true });
2030
2145
  }
2031
- const forgetDestinationPath = path21.join(
2146
+ const forgetDestinationPath = path20.join(
2032
2147
  componentsDestinationPath,
2033
2148
  "ForgetComponent.tsx"
2034
2149
  );
2035
- if (fs21.existsSync(forgetComponentPath)) {
2036
- fs21.copyFileSync(forgetComponentPath, forgetDestinationPath);
2150
+ if (fs20.existsSync(forgetComponentPath)) {
2151
+ fs20.copyFileSync(forgetComponentPath, forgetDestinationPath);
2037
2152
  }
2038
- const resetComponentPath = path21.resolve(
2153
+ const resetComponentPath = path20.resolve(
2039
2154
  __dirname,
2040
2155
  "./template/TanstackState/components/ResetComponent.tsx"
2041
2156
  );
2042
- const resetDestinationPath = path21.join(
2157
+ const resetDestinationPath = path20.join(
2043
2158
  componentsDestinationPath,
2044
2159
  "ResetComponent.tsx"
2045
2160
  );
2046
- if (fs21.existsSync(resetComponentPath)) {
2047
- fs21.copyFileSync(resetComponentPath, resetDestinationPath);
2161
+ if (fs20.existsSync(resetComponentPath)) {
2162
+ fs20.copyFileSync(resetComponentPath, resetDestinationPath);
2048
2163
  }
2049
- const authTemplatePath = path21.resolve(
2164
+ const authTemplatePath = path20.resolve(
2050
2165
  __dirname,
2051
2166
  "./template/TanstackState/routes/auth"
2052
2167
  );
2053
- const routesDestinationPath = path21.join(srcPath, "routes", "auth");
2054
- if (!fs21.existsSync(routesDestinationPath)) {
2055
- fs21.mkdirSync(routesDestinationPath, { recursive: true });
2168
+ const routesDestinationPath = path20.join(srcPath, "routes", "auth");
2169
+ if (!fs20.existsSync(routesDestinationPath)) {
2170
+ fs20.mkdirSync(routesDestinationPath, { recursive: true });
2056
2171
  }
2057
- const forgetPageDestinationPath = path21.join(
2172
+ const forgetPageDestinationPath = path20.join(
2058
2173
  routesDestinationPath,
2059
2174
  "forget.tsx"
2060
2175
  );
2061
- fs21.copyFileSync(
2176
+ fs20.copyFileSync(
2062
2177
  `${authTemplatePath}/forget.tsx`,
2063
2178
  forgetPageDestinationPath
2064
2179
  );
2065
- const resetPageDestinationPath = path21.join(
2180
+ const resetPageDestinationPath = path20.join(
2066
2181
  routesDestinationPath,
2067
2182
  "reset-password.tsx"
2068
2183
  );
2069
- fs21.copyFileSync(
2184
+ fs20.copyFileSync(
2070
2185
  `${authTemplatePath}/reset-password.tsx`,
2071
2186
  resetPageDestinationPath
2072
2187
  );
2073
2188
  console.log(
2074
- chalk19.green("Successfully added forget and reset-password pages")
2189
+ chalk21.green("Successfully added forget and reset-password pages")
2075
2190
  );
2076
2191
  } else {
2077
2192
  console.log(
2078
- chalk19.red("Could not find emailAndPassword configuration in auth.ts")
2193
+ chalk21.red("Could not find emailAndPassword configuration in auth.ts")
2079
2194
  );
2080
2195
  }
2081
2196
  } catch (error) {
2082
- console.log(chalk19.red("Error adding sendResetPassword:"), error);
2197
+ console.log(chalk21.red("Error adding sendResetPassword:"), error);
2083
2198
  }
2084
2199
  };
2085
2200
 
2086
2201
  // cli/forget.ts
2087
- var forget = () => {
2088
- const projectDir = process.cwd();
2089
- const packageJsonPath = path22.join(projectDir, "package.json");
2090
- let framework = "tanstack state";
2091
- if (fs22.existsSync(packageJsonPath)) {
2092
- const packageJson2 = JSON.parse(fs22.readFileSync(packageJsonPath, "utf-8"));
2093
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
2094
- framework = hasNext ? "Next js" : "tanstack state";
2202
+ import chalk22 from "chalk";
2203
+ var forget = async () => {
2204
+ const { framework, error } = await getFramework();
2205
+ if (error) {
2206
+ console.log(chalk22.red(error));
2207
+ return;
2095
2208
  }
2096
2209
  if (framework === "Next js") {
2097
2210
  return forgetNext();
@@ -2102,32 +2215,30 @@ var forget = () => {
2102
2215
  };
2103
2216
 
2104
2217
  // cli/verification.ts
2105
- import chalk22 from "chalk";
2106
- import fs25 from "fs";
2107
- import path25 from "path";
2218
+ import chalk25 from "chalk";
2108
2219
 
2109
2220
  // script/verifyNext.ts
2110
- import chalk20 from "chalk";
2111
- import fs23 from "fs";
2112
- import path23 from "path";
2221
+ import chalk23 from "chalk";
2222
+ import fs21 from "fs";
2223
+ import path21 from "path";
2113
2224
  import { fileURLToPath as fileURLToPath19 } from "url";
2114
2225
  var verifyNext = async () => {
2115
2226
  try {
2116
2227
  const projectDir = process.cwd();
2117
2228
  const __filename = fileURLToPath19(import.meta.url);
2118
- const __dirname = path23.dirname(__filename);
2119
- const srcPath = path23.join(projectDir, "src");
2120
- const folder = fs23.existsSync(srcPath) ? "src" : "";
2121
- const emailFilePath = path23.join(projectDir, folder, "lib", "email.ts");
2122
- if (!fs23.existsSync(emailFilePath)) {
2229
+ const __dirname = path21.dirname(__filename);
2230
+ const srcPath = path21.join(projectDir, "src");
2231
+ const folder = fs21.existsSync(srcPath) ? "src" : "";
2232
+ const emailFilePath = path21.join(projectDir, folder, "lib", "email.ts");
2233
+ if (!fs21.existsSync(emailFilePath)) {
2123
2234
  await email();
2124
2235
  }
2125
- const authFilePath = path23.join(projectDir, folder, "lib", "auth.ts");
2126
- if (!fs23.existsSync(authFilePath)) {
2127
- console.log(chalk20.red("auth.ts file not found."));
2236
+ const authFilePath = path21.join(projectDir, folder, "lib", "auth.ts");
2237
+ if (!fs21.existsSync(authFilePath)) {
2238
+ console.log(chalk23.red("auth.ts file not found."));
2128
2239
  return;
2129
2240
  }
2130
- let content = fs23.readFileSync(authFilePath, "utf8");
2241
+ let content = fs21.readFileSync(authFilePath, "utf8");
2131
2242
  if (content.includes("emailAndPassword: {")) {
2132
2243
  const start = content.indexOf("emailAndPassword: {");
2133
2244
  let end = start;
@@ -2187,46 +2298,46 @@ var verifyNext = async () => {
2187
2298
  `;
2188
2299
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2189
2300
  }
2190
- fs23.writeFileSync(authFilePath, content, "utf8");
2191
- const templatePath = path23.resolve(
2301
+ fs21.writeFileSync(authFilePath, content, "utf8");
2302
+ const templatePath = path21.resolve(
2192
2303
  __dirname,
2193
2304
  "./template/email/EmailVerification.tsx"
2194
2305
  );
2195
- const componentsDir = path23.join(projectDir, folder, "components", "email");
2196
- if (!fs23.existsSync(componentsDir)) {
2197
- fs23.mkdirSync(componentsDir, { recursive: true });
2306
+ const componentsDir = path21.join(projectDir, folder, "components", "email");
2307
+ if (!fs21.existsSync(componentsDir)) {
2308
+ fs21.mkdirSync(componentsDir, { recursive: true });
2198
2309
  }
2199
- const destFile = path23.join(componentsDir, "EmailVerification.tsx");
2200
- if (fs23.existsSync(templatePath) && !fs23.existsSync(destFile)) {
2201
- fs23.copyFileSync(templatePath, destFile);
2310
+ const destFile = path21.join(componentsDir, "EmailVerification.tsx");
2311
+ if (fs21.existsSync(templatePath) && !fs21.existsSync(destFile)) {
2312
+ fs21.copyFileSync(templatePath, destFile);
2202
2313
  }
2203
- console.log(chalk20.green("Email verification successfully configured"));
2314
+ console.log(chalk23.green("Email verification successfully configured"));
2204
2315
  } catch (error) {
2205
- console.log(chalk20.red(String(error)));
2316
+ console.log(chalk23.red(String(error)));
2206
2317
  }
2207
2318
  };
2208
2319
 
2209
2320
  // script/verifyTanstack.ts
2210
- import chalk21 from "chalk";
2211
- import fs24 from "fs";
2212
- import path24 from "path";
2321
+ import chalk24 from "chalk";
2322
+ import fs22 from "fs";
2323
+ import path22 from "path";
2213
2324
  import { fileURLToPath as fileURLToPath20 } from "url";
2214
2325
  var verifyTanstack = async () => {
2215
2326
  try {
2216
2327
  const projectDir = process.cwd();
2217
2328
  const __filename = fileURLToPath20(import.meta.url);
2218
- const __dirname = path24.dirname(__filename);
2219
- const srcPath = path24.join(projectDir, "src");
2220
- const emailFilePath = path24.join(srcPath, "lib", "email.ts");
2221
- if (!fs24.existsSync(emailFilePath)) {
2329
+ const __dirname = path22.dirname(__filename);
2330
+ const srcPath = path22.join(projectDir, "src");
2331
+ const emailFilePath = path22.join(srcPath, "lib", "email.ts");
2332
+ if (!fs22.existsSync(emailFilePath)) {
2222
2333
  await email();
2223
2334
  }
2224
- const authFilePath = path24.join(srcPath, "lib", "auth.ts");
2225
- if (!fs24.existsSync(authFilePath)) {
2226
- console.log(chalk21.red("auth.ts file not found."));
2335
+ const authFilePath = path22.join(srcPath, "lib", "auth.ts");
2336
+ if (!fs22.existsSync(authFilePath)) {
2337
+ console.log(chalk24.red("auth.ts file not found."));
2227
2338
  return;
2228
2339
  }
2229
- let content = fs24.readFileSync(authFilePath, "utf8");
2340
+ let content = fs22.readFileSync(authFilePath, "utf8");
2230
2341
  if (content.includes("emailAndPassword: {")) {
2231
2342
  const start = content.indexOf("emailAndPassword: {");
2232
2343
  let end = start;
@@ -2286,35 +2397,32 @@ var verifyTanstack = async () => {
2286
2397
  `;
2287
2398
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2288
2399
  }
2289
- fs24.writeFileSync(authFilePath, content, "utf8");
2290
- const templatePath = path24.resolve(
2400
+ fs22.writeFileSync(authFilePath, content, "utf8");
2401
+ const templatePath = path22.resolve(
2291
2402
  __dirname,
2292
2403
  "./template/email/EmailVerification.tsx"
2293
2404
  );
2294
- const componentsDir = path24.join(srcPath, "components", "email");
2295
- if (!fs24.existsSync(componentsDir)) {
2296
- fs24.mkdirSync(componentsDir, { recursive: true });
2405
+ const componentsDir = path22.join(srcPath, "components", "email");
2406
+ if (!fs22.existsSync(componentsDir)) {
2407
+ fs22.mkdirSync(componentsDir, { recursive: true });
2297
2408
  }
2298
- const destFile = path24.join(componentsDir, "EmailVerification.tsx");
2299
- if (fs24.existsSync(templatePath) && !fs24.existsSync(destFile)) {
2300
- fs24.copyFileSync(templatePath, destFile);
2409
+ const destFile = path22.join(componentsDir, "EmailVerification.tsx");
2410
+ if (fs22.existsSync(templatePath) && !fs22.existsSync(destFile)) {
2411
+ fs22.copyFileSync(templatePath, destFile);
2301
2412
  }
2302
- console.log(chalk21.green("Email verification successfully configured"));
2413
+ console.log(chalk24.green("Email verification successfully configured"));
2303
2414
  } catch (error) {
2304
- console.log(chalk21.red(String(error)));
2415
+ console.log(chalk24.red(String(error)));
2305
2416
  }
2306
2417
  };
2307
2418
 
2308
2419
  // cli/verification.ts
2309
2420
  var verification = async () => {
2310
2421
  try {
2311
- const projectDir = process.cwd();
2312
- const packageJsonPath = path25.join(projectDir, "package.json");
2313
- let framework = "tanstack state";
2314
- if (fs25.existsSync(packageJsonPath)) {
2315
- const packageJson2 = JSON.parse(fs25.readFileSync(packageJsonPath, "utf-8"));
2316
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
2317
- framework = hasNext ? "Next js" : "tanstack state";
2422
+ const { framework, error } = await getFramework();
2423
+ if (error) {
2424
+ console.log(chalk25.red(error));
2425
+ return;
2318
2426
  }
2319
2427
  if (framework === "Next js") {
2320
2428
  await verifyNext();
@@ -2323,7 +2431,47 @@ var verification = async () => {
2323
2431
  await verifyTanstack();
2324
2432
  }
2325
2433
  } catch (error) {
2326
- console.log(chalk22.red(error.message));
2434
+ console.log(chalk25.red(error.message));
2435
+ }
2436
+ };
2437
+
2438
+ // cli/initCmd.ts
2439
+ import chalk26 from "chalk";
2440
+ var initCmd = async (cmd) => {
2441
+ try {
2442
+ const { framework, error } = await getFramework();
2443
+ if (error) {
2444
+ console.log(chalk26.red(error));
2445
+ return;
2446
+ }
2447
+ if (framework === "Next js" && cmd.orm === "prisma") {
2448
+ await prismaRun({
2449
+ database: cmd.db,
2450
+ authUi: cmd.authUi === "yes" ? true : false,
2451
+ cmd: true
2452
+ });
2453
+ }
2454
+ if (framework === "Next js" && cmd.orm === "drizzle") {
2455
+ await drizzleRun({
2456
+ authUi: cmd.authUi === "yes" ? true : false,
2457
+ cmd: true
2458
+ });
2459
+ }
2460
+ if (framework === "tanstack state" && cmd.orm === "prisma") {
2461
+ await prismaRunTanstackState({
2462
+ authUi: cmd.authUi === "yes" ? true : false,
2463
+ database: cmd.db,
2464
+ cmd: true
2465
+ });
2466
+ }
2467
+ if (framework === "tanstack state" && cmd.orm === "drizzle") {
2468
+ await drizzleRunTanstackState({
2469
+ authUi: cmd.authUi === "yes" ? true : false,
2470
+ cmd: true
2471
+ });
2472
+ }
2473
+ } catch (error) {
2474
+ console.log(chalk26.red(error));
2327
2475
  }
2328
2476
  };
2329
2477
 
@@ -2335,11 +2483,23 @@ program.name("authverse").description("CLI tool for creating authverse projects"
2335
2483
  "-v, --version",
2336
2484
  "display the version number"
2337
2485
  );
2338
- program.command("init").description("Select project template and configuration").action(async () => {
2339
- await initAnswer();
2486
+ program.command("init").description("Select project template and configuration").option("--orm <type>", "Select ORM (prisma, drizzle)").option("--db <type>", "Select database (mysql, postgres, mongodb)").option("--authUi <value>", "Include auth UI (yes/no)").action(async (cmd) => {
2487
+ if (!cmd.orm || !cmd.db || !cmd.authUi) {
2488
+ await initAnswer();
2489
+ } else {
2490
+ await initCmd(cmd);
2491
+ }
2492
+ });
2493
+ program.command("add <provider>").description("Add a new authentication provider").action(async (provider) => {
2494
+ await providers({ provider });
2495
+ });
2496
+ program.command("forget").description("Forget stored configurations").action(async () => {
2497
+ await forget();
2498
+ });
2499
+ program.command("email").description("Configure email settings").action(async () => {
2500
+ await email();
2501
+ });
2502
+ program.command("verify").description("Verify authentication setup").action(async () => {
2503
+ await verification();
2340
2504
  });
2341
- program.command("add <provider>").description("Add a new authentication provider").action((provider) => providers({ provider }));
2342
- program.command("forget").description("Forget stored configurations").action(forget);
2343
- program.command("email").description("Configure email settings").action(email);
2344
- program.command("verify").description("Verify authentication setup").action(verification);
2345
2505
  program.parse(process.argv);