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.cjs CHANGED
@@ -54,7 +54,7 @@ var getPackageManager = () => {
54
54
  if (ua.includes("bun")) return "bun";
55
55
  if (ua.includes("pnpm")) return "pnpm";
56
56
  if (ua.includes("yarn")) return "yarn";
57
- return "npm";
57
+ return "pnpm";
58
58
  };
59
59
  var pm = getPackageManager();
60
60
  var packageManager = (pkg, dev = false) => {
@@ -85,14 +85,47 @@ var runCommand = (cmd) => {
85
85
 
86
86
  // script/authUi.ts
87
87
  var import_meta = {};
88
- var authUiRun = async ({ folder }) => {
88
+ var shadcnComponents = [
89
+ "button.tsx",
90
+ "card.tsx",
91
+ "field.tsx",
92
+ "input.tsx",
93
+ "label.tsx",
94
+ "separator.tsx",
95
+ "sonner.tsx"
96
+ ];
97
+ var authUiRun = async ({
98
+ folder,
99
+ packageJson: packageJson2,
100
+ cmd
101
+ }) => {
89
102
  try {
90
- console.log(import_chalk.default.yellow("\n Installing shadcn ui Components\n"));
91
- runCommand("shadcn@latest add button sonner card field input");
92
- packageManager("react-hook-form @hookform/resolvers");
103
+ const projectDir = process.cwd();
104
+ const shadcnPath = import_path.default.join(projectDir, folder, "components", "ui");
105
+ const shadcnConfigPath = import_path.default.join(projectDir, "components.json");
106
+ if (!import_fs.default.existsSync(shadcnPath) || !import_fs.default.existsSync(shadcnConfigPath)) {
107
+ console.log(import_chalk.default.yellow("\n Installing shadcn ui Components\n"));
108
+ if (cmd == true) {
109
+ runCommand("shadcn@latest init --base-color zinc --yes");
110
+ runCommand("shadcn@latest add button sonner card field input");
111
+ } else {
112
+ runCommand("shadcn@latest add button sonner card field input");
113
+ }
114
+ }
115
+ const shadcnFiles = import_fs.default.readdirSync(shadcnPath);
116
+ const missingComponents = shadcnComponents.filter(
117
+ (component) => !shadcnFiles.includes(component)
118
+ );
119
+ if (missingComponents.length > 0) {
120
+ console.log(import_chalk.default.yellow("\n Installing shadcn ui Components\n"));
121
+ const install = missingComponents.map((components) => components.split(".")[0]).join(" ");
122
+ runCommand(`shadcn@latest add ${install}`);
123
+ }
124
+ if (!packageJson2.dependencies?.["react-hook-form"] || !packageJson2.dependencies?.["@hookform/resolvers"] || !packageJson2.dependencies?.["zod"]) {
125
+ packageManager("react-hook-form @hookform/resolvers zod");
126
+ }
93
127
  const __filename = (0, import_url.fileURLToPath)(import_meta.url);
94
128
  const __dirname = import_path.default.dirname(__filename);
95
- const projectDir = process.cwd();
96
129
  const componentPath = import_path.default.resolve(__dirname, "./template/components");
97
130
  const destinationPath = import_path.default.join(
98
131
  projectDir,
@@ -174,14 +207,14 @@ ${layoutContent}`;
174
207
  // script/prisma.ts
175
208
  var import_inquirer = __toESM(require("inquirer"), 1);
176
209
  var import_meta2 = {};
177
- var prismaRun = async ({ authUi, database }) => {
210
+ var prismaRun = async ({ authUi, database, cmd }) => {
178
211
  try {
179
212
  const projectDir = process.cwd();
180
213
  const __filename = (0, import_url2.fileURLToPath)(import_meta2.url);
181
214
  const __dirname = import_path2.default.dirname(__filename);
182
215
  const packageJsonPath = import_path2.default.join(projectDir, "package.json");
183
216
  const packageJson2 = JSON.parse(import_fs2.default.readFileSync(packageJsonPath, "utf-8"));
184
- if (!packageJson2.devDependencies?.prisma && !packageJson2.dependencies?.["@prisma/client"]) {
217
+ if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
185
218
  console.log(import_chalk2.default.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
186
219
  if (database !== "Mongodb") {
187
220
  packageManager("prisma", true);
@@ -221,7 +254,7 @@ var prismaRun = async ({ authUi, database }) => {
221
254
  } else {
222
255
  const schemaPath = import_path2.default.join(prismaDir, "schema.prisma");
223
256
  const schemaContent = import_fs2.default.readFileSync(schemaPath, "utf-8");
224
- if (!schemaContent.includes("User") && !schemaContent.includes("Session") && !schemaContent.includes("Account") && !schemaContent.includes("Verification")) {
257
+ if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
225
258
  const templatePath = import_path2.default.resolve(
226
259
  __dirname,
227
260
  `./template/prisma/${database}/schema.prisma_copy`
@@ -254,16 +287,48 @@ BETTER_AUTH_URL=http://localhost:3000
254
287
  }
255
288
  const authPath = import_path2.default.join(libPath, "auth.ts");
256
289
  const authClientPath = import_path2.default.join(libPath, "auth-client.ts");
257
- if (import_fs2.default.existsSync(authPath) || import_fs2.default.existsSync(authClientPath)) {
258
- const answers = await import_inquirer.default.prompt([
259
- {
260
- type: "confirm",
261
- name: "overwrite",
262
- message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
263
- default: false
290
+ if (cmd !== true) {
291
+ if (import_fs2.default.existsSync(authPath) || import_fs2.default.existsSync(authClientPath)) {
292
+ const answers = await import_inquirer.default.prompt([
293
+ {
294
+ type: "confirm",
295
+ name: "overwrite",
296
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
297
+ default: false
298
+ }
299
+ ]);
300
+ if (answers.overwrite) {
301
+ const authTemplatePath = import_path2.default.resolve(
302
+ __dirname,
303
+ `./template/lib/${database}/auth.ts`
304
+ );
305
+ const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
306
+ import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
307
+ const authClientTemplatePath = import_path2.default.resolve(
308
+ __dirname,
309
+ "./template/lib/auth-client.ts"
310
+ );
311
+ const authClientDestinationPath = import_path2.default.join(
312
+ libPath,
313
+ "auth-client.ts"
314
+ );
315
+ import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
316
+ if (srcFolder === "src") {
317
+ const authContextPath = import_path2.default.join(libPath, "auth.ts");
318
+ const authContextContent = import_fs2.default.readFileSync(
319
+ authContextPath,
320
+ "utf-8"
321
+ );
322
+ import_fs2.default.writeFileSync(
323
+ authContextPath,
324
+ authContextContent.replace(
325
+ 'import { PrismaClient } from "@/generated/prisma/client";',
326
+ 'import { PrismaClient } from "../../generated/prisma/client";'
327
+ )
328
+ );
329
+ }
264
330
  }
265
- ]);
266
- if (answers.overwrite) {
331
+ } else {
267
332
  const authTemplatePath = import_path2.default.resolve(
268
333
  __dirname,
269
334
  `./template/lib/${database}/auth.ts`
@@ -288,30 +353,6 @@ BETTER_AUTH_URL=http://localhost:3000
288
353
  );
289
354
  }
290
355
  }
291
- } else {
292
- const authTemplatePath = import_path2.default.resolve(
293
- __dirname,
294
- `./template/lib/${database}/auth.ts`
295
- );
296
- const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
297
- import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
298
- const authClientTemplatePath = import_path2.default.resolve(
299
- __dirname,
300
- "./template/lib/auth-client.ts"
301
- );
302
- const authClientDestinationPath = import_path2.default.join(libPath, "auth-client.ts");
303
- import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
304
- if (srcFolder === "src") {
305
- const authContextPath = import_path2.default.join(libPath, "auth.ts");
306
- const authContextContent = import_fs2.default.readFileSync(authContextPath, "utf-8");
307
- import_fs2.default.writeFileSync(
308
- authContextPath,
309
- authContextContent.replace(
310
- 'import { PrismaClient } from "@/generated/prisma/client";',
311
- 'import { PrismaClient } from "../../generated/prisma/client";'
312
- )
313
- );
314
- }
315
356
  }
316
357
  const routeTemplatePath = import_path2.default.resolve(
317
358
  __dirname,
@@ -351,7 +392,11 @@ BETTER_AUTH_URL=http://localhost:3000
351
392
  );
352
393
  }
353
394
  if (authUi) {
354
- await authUiRun({ folder: srcFolder });
395
+ await authUiRun({
396
+ folder: srcFolder,
397
+ packageJson: packageJson2,
398
+ cmd
399
+ });
355
400
  } else {
356
401
  console.log(
357
402
  import_chalk2.default.green(
@@ -371,7 +416,7 @@ var import_url3 = require("url");
371
416
  var import_fs3 = __toESM(require("fs"), 1);
372
417
  var import_inquirer2 = __toESM(require("inquirer"), 1);
373
418
  var import_meta3 = {};
374
- var drizzleRun = async (authUi) => {
419
+ var drizzleRun = async ({ authUi, cmd }) => {
375
420
  try {
376
421
  const projectDir = process.cwd();
377
422
  const packageJsonPath = import_path3.default.join(projectDir, "package.json");
@@ -519,7 +564,11 @@ BETTER_AUTH_URL=http://localhost:3000
519
564
  const proxyDestinationPath = import_path3.default.join(proxyDestinationDir, "proxy.ts");
520
565
  import_fs3.default.copyFileSync(proxyTemplatePath, proxyDestinationPath);
521
566
  if (authUi) {
522
- await authUiRun({ folder: srcFolder });
567
+ await authUiRun({
568
+ folder: srcFolder,
569
+ packageJson: packageJson2,
570
+ cmd
571
+ });
523
572
  } else {
524
573
  console.log(
525
574
  import_chalk3.default.green(
@@ -532,10 +581,6 @@ BETTER_AUTH_URL=http://localhost:3000
532
581
  }
533
582
  };
534
583
 
535
- // cli/init.ts
536
- var import_path7 = __toESM(require("path"), 1);
537
- var import_fs7 = __toESM(require("fs"), 1);
538
-
539
584
  // script/prismaRunTanstackState.ts
540
585
  var import_chalk5 = __toESM(require("chalk"), 1);
541
586
  var import_path5 = __toESM(require("path"), 1);
@@ -548,14 +593,46 @@ var import_url4 = require("url");
548
593
  var import_path4 = __toESM(require("path"), 1);
549
594
  var import_fs4 = __toESM(require("fs"), 1);
550
595
  var import_meta4 = {};
551
- var authUiTanstackState = async () => {
596
+ var shadcnComponents2 = [
597
+ "button.tsx",
598
+ "card.tsx",
599
+ "field.tsx",
600
+ "input.tsx",
601
+ "label.tsx",
602
+ "separator.tsx",
603
+ "sonner.tsx"
604
+ ];
605
+ var authUiTanstackState = async ({
606
+ packageJson: packageJson2,
607
+ cmd
608
+ }) => {
552
609
  try {
553
- console.log(import_chalk4.default.yellow("\n Installing shadcn ui Components\n"));
554
- runCommand("shadcn@latest add button sonner card field input");
555
- packageManager("@tanstack/react-form");
610
+ const projectDir = process.cwd();
611
+ const shadcnPath = import_path4.default.join(projectDir, "src", "components", "ui");
612
+ const shadcnConfigPath = import_path4.default.join(projectDir, "components.json");
613
+ if (!import_fs4.default.existsSync(shadcnPath) || !import_fs4.default.existsSync(shadcnConfigPath)) {
614
+ console.log(import_chalk4.default.yellow("\n Installing shadcn ui Components\n"));
615
+ if (cmd == true) {
616
+ runCommand("shadcn@latest init --base-color zinc --yes");
617
+ runCommand("shadcn@latest add button sonner card field input");
618
+ } else {
619
+ runCommand("shadcn@latest add button sonner card field input");
620
+ }
621
+ }
622
+ const shadcnFiles = import_fs4.default.readdirSync(shadcnPath);
623
+ const missingComponents = shadcnComponents2.filter(
624
+ (component) => !shadcnFiles.includes(component)
625
+ );
626
+ if (missingComponents.length > 0) {
627
+ console.log(import_chalk4.default.yellow("\n Installing shadcn ui Components\n"));
628
+ const install = missingComponents.map((components) => components.split(".")[0]).join(" ");
629
+ runCommand(`shadcn@latest add ${install}`);
630
+ }
631
+ if (!packageJson2.dependencies?.["@tanstack/react-form"] || !packageJson2.dependencies?.["zod"]) {
632
+ packageManager("@tanstack/react-form zod");
633
+ }
556
634
  const __filename = (0, import_url4.fileURLToPath)(import_meta4.url);
557
635
  const __dirname = import_path4.default.dirname(__filename);
558
- const projectDir = process.cwd();
559
636
  const srcPath = import_path4.default.join(projectDir, "src");
560
637
  const componentPath = import_path4.default.resolve(
561
638
  __dirname,
@@ -618,7 +695,8 @@ ${rootContent}`;
618
695
  var import_meta5 = {};
619
696
  var prismaRunTanstackState = async ({
620
697
  authUi,
621
- database
698
+ database,
699
+ cmd
622
700
  }) => {
623
701
  try {
624
702
  const projectDir = process.cwd();
@@ -626,7 +704,7 @@ var prismaRunTanstackState = async ({
626
704
  const __dirname = import_path5.default.dirname(__filename);
627
705
  const packageJsonPath = import_path5.default.join(projectDir, "package.json");
628
706
  const packageJson2 = JSON.parse(import_fs5.default.readFileSync(packageJsonPath, "utf-8"));
629
- if (!packageJson2.devDependencies?.prisma && !packageJson2.dependencies?.["@prisma/client"]) {
707
+ if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
630
708
  console.log(import_chalk5.default.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
631
709
  if (database !== "Mongodb") {
632
710
  packageManager("prisma", true);
@@ -666,7 +744,7 @@ var prismaRunTanstackState = async ({
666
744
  } else {
667
745
  const schemaPath = import_path5.default.join(prismaDir, "schema.prisma");
668
746
  const schemaContent = import_fs5.default.readFileSync(schemaPath, "utf-8");
669
- if (!schemaContent.includes("User") && !schemaContent.includes("Session") && !schemaContent.includes("Account") && !schemaContent.includes("Verification")) {
747
+ if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
670
748
  const templatePath = import_path5.default.resolve(
671
749
  __dirname,
672
750
  `./template/prisma/${database}/schema.prisma_copy`
@@ -735,7 +813,10 @@ BETTER_AUTH_URL=http://localhost:3000
735
813
  const apiDestinationPath = import_path5.default.join(fileRouteDestinationPath, "$.ts");
736
814
  import_fs5.default.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
737
815
  if (authUi) {
738
- await authUiTanstackState();
816
+ await authUiTanstackState({
817
+ packageJson: packageJson2,
818
+ cmd
819
+ });
739
820
  } else {
740
821
  console.log(
741
822
  import_chalk5.default.green(
@@ -754,7 +835,10 @@ var import_path6 = __toESM(require("path"), 1);
754
835
  var import_fs6 = __toESM(require("fs"), 1);
755
836
  var import_url6 = require("url");
756
837
  var import_meta6 = {};
757
- var drizzleRunTanstackState = async (authUi) => {
838
+ var drizzleRunTanstackState = async ({
839
+ authUi,
840
+ cmd
841
+ }) => {
758
842
  try {
759
843
  const projectDir = process.cwd();
760
844
  const packageJsonPath = import_path6.default.join(projectDir, "package.json");
@@ -847,7 +931,10 @@ BETTER_AUTH_URL=http://localhost:3000
847
931
  const apiDestinationPath = import_path6.default.join(fileRouteDestinationPath, "$.ts");
848
932
  import_fs6.default.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
849
933
  if (authUi) {
850
- await authUiTanstackState();
934
+ await authUiTanstackState({
935
+ packageJson: packageJson2,
936
+ cmd
937
+ });
851
938
  } else {
852
939
  console.log(
853
940
  import_chalk6.default.green(
@@ -860,15 +947,47 @@ BETTER_AUTH_URL=http://localhost:3000
860
947
  }
861
948
  };
862
949
 
950
+ // utils/framework.ts
951
+ var import_path7 = __toESM(require("path"), 1);
952
+ var import_fs7 = __toESM(require("fs"), 1);
953
+ var getFramework = async () => {
954
+ const projectDir = process.cwd();
955
+ if (!import_fs7.default.existsSync(import_path7.default.join(projectDir, "package.json"))) {
956
+ return {
957
+ framework: null,
958
+ error: "No framework detected"
959
+ };
960
+ }
961
+ const packageJson2 = JSON.parse(
962
+ import_fs7.default.readFileSync(import_path7.default.join(projectDir, "package.json"), "utf-8")
963
+ );
964
+ const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
965
+ if (hasNext) {
966
+ return {
967
+ framework: "Next js",
968
+ error: null
969
+ };
970
+ }
971
+ const hasTanstackState = packageJson2?.devDependencies?.["@tanstack/devtools-vite"] || packageJson2?.devDependencies?.["@tanstack/eslint-config"] || packageJson2?.devDependencies?.["@tanstack/react-start"];
972
+ if (hasTanstackState) {
973
+ return {
974
+ framework: "tanstack state",
975
+ error: null
976
+ };
977
+ }
978
+ return {
979
+ framework: null,
980
+ error: "No framework supported authverse"
981
+ };
982
+ };
983
+
863
984
  // cli/init.ts
985
+ var import_chalk7 = __toESM(require("chalk"), 1);
864
986
  var initAnswer = async () => {
865
- const projectDir = process.cwd();
866
- const packageJsonPath = import_path7.default.join(projectDir, "package.json");
867
- let framework = "tanstack state";
868
- if (import_fs7.default.existsSync(packageJsonPath)) {
869
- const packageJson2 = JSON.parse(import_fs7.default.readFileSync(packageJsonPath, "utf-8"));
870
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
871
- framework = hasNext ? "Next js" : "tanstack state";
987
+ const { framework, error } = await getFramework();
988
+ if (error) {
989
+ console.log(import_chalk7.default.red(error));
990
+ return;
872
991
  }
873
992
  console.log(`\u2714 Detected framework: ${framework}`);
874
993
  const answers = await import_inquirer3.default.prompt([
@@ -895,31 +1014,39 @@ var initAnswer = async () => {
895
1014
  if (framework === "Next js" && answers.orm === "Prisma") {
896
1015
  await prismaRun({
897
1016
  authUi: answers.authUi,
898
- database: answers.database
1017
+ database: answers.database,
1018
+ cmd: false
899
1019
  });
900
1020
  }
901
1021
  if (framework === "Next js" && answers.orm === "Drizzle") {
902
- await drizzleRun(answers.authUi);
1022
+ await drizzleRun({
1023
+ authUi: answers.authUi,
1024
+ cmd: false
1025
+ });
903
1026
  }
904
1027
  if (framework === "tanstack state" && answers.orm === "Prisma") {
905
1028
  await prismaRunTanstackState({
906
1029
  authUi: answers.authUi,
907
- database: answers.database
1030
+ database: answers.database,
1031
+ cmd: false
908
1032
  });
909
1033
  }
910
1034
  if (framework === "tanstack state" && answers.orm === "Drizzle") {
911
- await drizzleRunTanstackState(answers.authUi);
1035
+ await drizzleRunTanstackState({
1036
+ authUi: answers.authUi,
1037
+ cmd: false
1038
+ });
912
1039
  }
913
1040
  };
914
1041
 
915
1042
  // index.ts
916
- var import_fs26 = require("fs");
1043
+ var import_fs23 = require("fs");
917
1044
 
918
1045
  // cli/provider.ts
919
- var import_chalk11 = __toESM(require("chalk"), 1);
1046
+ var import_chalk12 = __toESM(require("chalk"), 1);
920
1047
 
921
1048
  // script/googleRun.ts
922
- var import_chalk7 = __toESM(require("chalk"), 1);
1049
+ var import_chalk8 = __toESM(require("chalk"), 1);
923
1050
  var import_fs8 = __toESM(require("fs"), 1);
924
1051
  var import_path8 = __toESM(require("path"), 1);
925
1052
  var import_url7 = require("url");
@@ -933,16 +1060,16 @@ var googleRun = async () => {
933
1060
  const folder = import_fs8.default.existsSync(srcPath) ? "src" : "";
934
1061
  const authFilePath = import_path8.default.join(projectDir, folder, "lib", "auth.ts");
935
1062
  if (!import_fs8.default.existsSync(authFilePath)) {
936
- console.log(import_chalk7.default.red("\u274C auth.ts file not found"));
1063
+ console.log(import_chalk8.default.red("\u274C auth.ts file not found"));
937
1064
  return;
938
1065
  }
939
1066
  let content = import_fs8.default.readFileSync(authFilePath, "utf8");
940
1067
  if (!content.includes("betterAuth({")) {
941
- console.log(import_chalk7.default.red("betterAuth({}) block not found"));
1068
+ console.log(import_chalk8.default.red("betterAuth({}) block not found"));
942
1069
  return;
943
1070
  }
944
1071
  if (content.includes("socialProviders") && content.includes("google:")) {
945
- console.log(import_chalk7.default.yellow("Google provider already exists"));
1072
+ console.log(import_chalk8.default.yellow("Google provider already exists"));
946
1073
  return;
947
1074
  }
948
1075
  const googleProviderEntry = `
@@ -965,7 +1092,7 @@ var googleRun = async () => {
965
1092
  }
966
1093
  }
967
1094
  if (insertPos === -1) {
968
- console.log(import_chalk7.default.red("Failed to parse socialProviders block"));
1095
+ console.log(import_chalk8.default.red("Failed to parse socialProviders block"));
969
1096
  return;
970
1097
  }
971
1098
  content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
@@ -973,7 +1100,7 @@ var googleRun = async () => {
973
1100
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
974
1101
  if (!databaseRegex.test(content)) {
975
1102
  console.log(
976
- import_chalk7.default.red(
1103
+ import_chalk8.default.red(
977
1104
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
978
1105
  )
979
1106
  );
@@ -1022,14 +1149,14 @@ GOOGLE_CLIENT_SECRET=
1022
1149
  if (import_fs8.default.existsSync(componentTemplate)) {
1023
1150
  import_fs8.default.copyFileSync(componentTemplate, componentDest);
1024
1151
  }
1025
- console.log(import_chalk7.default.green("Google provider added & merged successfully"));
1152
+ console.log(import_chalk8.default.green("Google provider added & merged successfully"));
1026
1153
  } catch (error) {
1027
- console.log(import_chalk7.default.red("googleRun error:"), error);
1154
+ console.log(import_chalk8.default.red("googleRun error:"), error);
1028
1155
  }
1029
1156
  };
1030
1157
 
1031
1158
  // script/githubRun.ts
1032
- var import_chalk8 = __toESM(require("chalk"), 1);
1159
+ var import_chalk9 = __toESM(require("chalk"), 1);
1033
1160
  var import_fs9 = __toESM(require("fs"), 1);
1034
1161
  var import_path9 = __toESM(require("path"), 1);
1035
1162
  var import_url8 = require("url");
@@ -1043,16 +1170,16 @@ var githubRun = async () => {
1043
1170
  const folder = import_fs9.default.existsSync(srcPath) ? "src" : "";
1044
1171
  const authFilePath = import_path9.default.join(projectDir, folder, "lib", "auth.ts");
1045
1172
  if (!import_fs9.default.existsSync(authFilePath)) {
1046
- console.log(import_chalk8.default.red("auth.ts file not found"));
1173
+ console.log(import_chalk9.default.red("auth.ts file not found"));
1047
1174
  return;
1048
1175
  }
1049
1176
  let content = import_fs9.default.readFileSync(authFilePath, "utf8");
1050
1177
  if (!content.includes("betterAuth({")) {
1051
- console.log(import_chalk8.default.red("betterAuth({}) block not found"));
1178
+ console.log(import_chalk9.default.red("betterAuth({}) block not found"));
1052
1179
  return;
1053
1180
  }
1054
1181
  if (content.includes("socialProviders") && content.includes("github:")) {
1055
- console.log(import_chalk8.default.yellow("GitHub provider already exists"));
1182
+ console.log(import_chalk9.default.yellow("GitHub provider already exists"));
1056
1183
  return;
1057
1184
  }
1058
1185
  const githubProviderEntry = `
@@ -1075,7 +1202,7 @@ var githubRun = async () => {
1075
1202
  }
1076
1203
  }
1077
1204
  if (insertPos === -1) {
1078
- console.log(import_chalk8.default.red("Failed to parse socialProviders block"));
1205
+ console.log(import_chalk9.default.red("Failed to parse socialProviders block"));
1079
1206
  return;
1080
1207
  }
1081
1208
  content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
@@ -1083,7 +1210,7 @@ var githubRun = async () => {
1083
1210
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1084
1211
  if (!databaseRegex.test(content)) {
1085
1212
  console.log(
1086
- import_chalk8.default.red(
1213
+ import_chalk9.default.red(
1087
1214
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1088
1215
  )
1089
1216
  );
@@ -1132,18 +1259,14 @@ GITHUB_CLIENT_SECRET=
1132
1259
  if (import_fs9.default.existsSync(componentTemplate)) {
1133
1260
  import_fs9.default.copyFileSync(componentTemplate, componentDest);
1134
1261
  }
1135
- console.log(import_chalk8.default.green("GitHub provider added & merged successfully"));
1262
+ console.log(import_chalk9.default.green("GitHub provider added & merged successfully"));
1136
1263
  } catch (error) {
1137
- console.log(import_chalk8.default.red("githubRun error:"), error);
1264
+ console.log(import_chalk9.default.red("githubRun error:"), error);
1138
1265
  }
1139
1266
  };
1140
1267
 
1141
- // cli/provider.ts
1142
- var import_path12 = __toESM(require("path"), 1);
1143
- var import_fs12 = __toESM(require("fs"), 1);
1144
-
1145
1268
  // script/googleRunTanstackState.ts
1146
- var import_chalk9 = __toESM(require("chalk"), 1);
1269
+ var import_chalk10 = __toESM(require("chalk"), 1);
1147
1270
  var import_fs10 = __toESM(require("fs"), 1);
1148
1271
  var import_path10 = __toESM(require("path"), 1);
1149
1272
  var import_url9 = require("url");
@@ -1156,16 +1279,16 @@ var googleRunTanstackState = async () => {
1156
1279
  const srcPath = import_path10.default.join(projectDir, "src");
1157
1280
  const authFilePath = import_path10.default.join(srcPath, "lib", "auth.ts");
1158
1281
  if (!import_fs10.default.existsSync(authFilePath)) {
1159
- console.log(import_chalk9.default.red("auth.ts file not found"));
1282
+ console.log(import_chalk10.default.red("auth.ts file not found"));
1160
1283
  return;
1161
1284
  }
1162
1285
  let content = import_fs10.default.readFileSync(authFilePath, "utf8");
1163
1286
  if (!content.includes("betterAuth({")) {
1164
- console.log(import_chalk9.default.red("betterAuth({}) block not found"));
1287
+ console.log(import_chalk10.default.red("betterAuth({}) block not found"));
1165
1288
  return;
1166
1289
  }
1167
1290
  if (content.includes("socialProviders") && content.includes("google:")) {
1168
- console.log(import_chalk9.default.yellow("Google provider already exists"));
1291
+ console.log(import_chalk10.default.yellow("Google provider already exists"));
1169
1292
  return;
1170
1293
  }
1171
1294
  const googleProviderEntry = `
@@ -1188,7 +1311,7 @@ var googleRunTanstackState = async () => {
1188
1311
  }
1189
1312
  }
1190
1313
  if (insertPos === -1) {
1191
- console.log(import_chalk9.default.red("Failed to parse socialProviders block"));
1314
+ console.log(import_chalk10.default.red("Failed to parse socialProviders block"));
1192
1315
  return;
1193
1316
  }
1194
1317
  content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
@@ -1196,7 +1319,7 @@ var googleRunTanstackState = async () => {
1196
1319
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1197
1320
  if (!databaseRegex.test(content)) {
1198
1321
  console.log(
1199
- import_chalk9.default.red(
1322
+ import_chalk10.default.red(
1200
1323
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1201
1324
  )
1202
1325
  );
@@ -1240,14 +1363,14 @@ GOOGLE_CLIENT_SECRET=
1240
1363
  if (import_fs10.default.existsSync(componentTemplate)) {
1241
1364
  import_fs10.default.copyFileSync(componentTemplate, componentDest);
1242
1365
  }
1243
- console.log(import_chalk9.default.green("Google provider added & merged successfully"));
1366
+ console.log(import_chalk10.default.green("Google provider added & merged successfully"));
1244
1367
  } catch (error) {
1245
- console.log(import_chalk9.default.red("googleRunTanstackState error:"), error);
1368
+ console.log(import_chalk10.default.red("googleRunTanstackState error:"), error);
1246
1369
  }
1247
1370
  };
1248
1371
 
1249
1372
  // script/githubRunTanstackState.ts
1250
- var import_chalk10 = __toESM(require("chalk"), 1);
1373
+ var import_chalk11 = __toESM(require("chalk"), 1);
1251
1374
  var import_fs11 = __toESM(require("fs"), 1);
1252
1375
  var import_path11 = __toESM(require("path"), 1);
1253
1376
  var import_url10 = require("url");
@@ -1260,16 +1383,16 @@ var githubRunTanstackState = async () => {
1260
1383
  const srcPath = import_path11.default.join(projectDir, "src");
1261
1384
  const authFilePath = import_path11.default.join(srcPath, "lib", "auth.ts");
1262
1385
  if (!import_fs11.default.existsSync(authFilePath)) {
1263
- console.log(import_chalk10.default.red("auth.ts file not found"));
1386
+ console.log(import_chalk11.default.red("auth.ts file not found"));
1264
1387
  return;
1265
1388
  }
1266
1389
  let content = import_fs11.default.readFileSync(authFilePath, "utf8");
1267
1390
  if (!content.includes("betterAuth({")) {
1268
- console.log(import_chalk10.default.red("betterAuth({}) block not found"));
1391
+ console.log(import_chalk11.default.red("betterAuth({}) block not found"));
1269
1392
  return;
1270
1393
  }
1271
1394
  if (content.includes("socialProviders") && content.includes("github:")) {
1272
- console.log(import_chalk10.default.yellow("Github provider already exists"));
1395
+ console.log(import_chalk11.default.yellow("Github provider already exists"));
1273
1396
  return;
1274
1397
  }
1275
1398
  const githubProviderEntry = `
@@ -1292,7 +1415,7 @@ var githubRunTanstackState = async () => {
1292
1415
  }
1293
1416
  }
1294
1417
  if (insertPos === -1) {
1295
- console.log(import_chalk10.default.red("Failed to parse socialProviders block"));
1418
+ console.log(import_chalk11.default.red("Failed to parse socialProviders block"));
1296
1419
  return;
1297
1420
  }
1298
1421
  content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
@@ -1300,7 +1423,7 @@ var githubRunTanstackState = async () => {
1300
1423
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1301
1424
  if (!databaseRegex.test(content)) {
1302
1425
  console.log(
1303
- import_chalk10.default.red(
1426
+ import_chalk11.default.red(
1304
1427
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1305
1428
  )
1306
1429
  );
@@ -1344,22 +1467,19 @@ GITHUB_CLIENT_SECRET=
1344
1467
  if (import_fs11.default.existsSync(componentTemplate)) {
1345
1468
  import_fs11.default.copyFileSync(componentTemplate, componentDest);
1346
1469
  }
1347
- console.log(import_chalk10.default.green("Github provider added & merged successfully"));
1470
+ console.log(import_chalk11.default.green("Github provider added & merged successfully"));
1348
1471
  } catch (error) {
1349
- console.log(import_chalk10.default.red("githubRunTanstackState error:"), error);
1472
+ console.log(import_chalk11.default.red("githubRunTanstackState error:"), error);
1350
1473
  }
1351
1474
  };
1352
1475
 
1353
1476
  // cli/provider.ts
1354
1477
  var providers = async ({ provider }) => {
1355
1478
  try {
1356
- const projectDir = process.cwd();
1357
- const packageJsonPath = import_path12.default.join(projectDir, "package.json");
1358
- let framework = "tanstack state";
1359
- if (import_fs12.default.existsSync(packageJsonPath)) {
1360
- const packageJson2 = JSON.parse(import_fs12.default.readFileSync(packageJsonPath, "utf-8"));
1361
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
1362
- framework = hasNext ? "Next js" : "tanstack state";
1479
+ const { framework, error } = await getFramework();
1480
+ if (error) {
1481
+ console.log(import_chalk12.default.red(error));
1482
+ return;
1363
1483
  }
1364
1484
  if (framework === "Next js" && provider == "google") {
1365
1485
  await googleRun();
@@ -1372,46 +1492,98 @@ var providers = async ({ provider }) => {
1372
1492
  await githubRunTanstackState();
1373
1493
  }
1374
1494
  } catch (error) {
1375
- console.log(import_chalk11.default.red("Error adding provider:"), error);
1495
+ console.log(import_chalk12.default.red("Error adding provider:"), error);
1376
1496
  }
1377
1497
  };
1378
1498
 
1379
- // cli/forget.ts
1380
- var import_path22 = __toESM(require("path"), 1);
1381
- var import_fs22 = __toESM(require("fs"), 1);
1382
-
1383
1499
  // script/forgetNext.ts
1384
- var import_chalk18 = __toESM(require("chalk"), 1);
1385
- var import_path20 = __toESM(require("path"), 1);
1500
+ var import_chalk20 = __toESM(require("chalk"), 1);
1501
+ var import_path19 = __toESM(require("path"), 1);
1386
1502
  var import_url17 = require("url");
1387
- var import_fs20 = __toESM(require("fs"), 1);
1503
+ var import_fs19 = __toESM(require("fs"), 1);
1388
1504
 
1389
1505
  // cli/email.ts
1390
- var import_path19 = __toESM(require("path"), 1);
1391
- var import_fs19 = __toESM(require("fs"), 1);
1506
+ var import_path18 = __toESM(require("path"), 1);
1507
+ var import_fs18 = __toESM(require("fs"), 1);
1392
1508
  var import_inquirer4 = __toESM(require("inquirer"), 1);
1393
1509
 
1394
1510
  // email/gmailRun.ts
1395
- var import_chalk12 = __toESM(require("chalk"), 1);
1396
- var import_path13 = __toESM(require("path"), 1);
1397
- var import_fs13 = __toESM(require("fs"), 1);
1511
+ var import_chalk13 = __toESM(require("chalk"), 1);
1512
+ var import_path12 = __toESM(require("path"), 1);
1513
+ var import_fs12 = __toESM(require("fs"), 1);
1398
1514
  var import_url11 = require("url");
1399
1515
  var import_meta11 = {};
1400
1516
  var gmailRun = async () => {
1517
+ try {
1518
+ const projectDir = process.cwd();
1519
+ const packageJsonPath = import_path12.default.join(projectDir, "package.json");
1520
+ const packageJson2 = JSON.parse(import_fs12.default.readFileSync(packageJsonPath, "utf-8"));
1521
+ const srcFolder = import_fs12.default.existsSync(import_path12.default.join(projectDir, "src")) ? "src" : "";
1522
+ const __filename = (0, import_url11.fileURLToPath)(import_meta11.url);
1523
+ const __dirname = import_path12.default.dirname(__filename);
1524
+ if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1525
+ console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1526
+ packageManager("nodemailer");
1527
+ packageManager("@types/nodemailer", true);
1528
+ }
1529
+ if (!packageJson2.dependencies?.["@react-email/components"]) {
1530
+ console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1531
+ packageManager("@react-email/components");
1532
+ }
1533
+ const envPath = import_path12.default.join(projectDir, ".env");
1534
+ const envContent = import_fs12.default.readFileSync(envPath, "utf8");
1535
+ 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")) {
1536
+ import_fs12.default.appendFileSync(envPath, `
1537
+
1538
+ # Gmail API Key for sending emails`);
1539
+ import_fs12.default.appendFileSync(envPath, `
1540
+ GMAIL_HOST=`);
1541
+ import_fs12.default.appendFileSync(envPath, `
1542
+ GMAIL_PORT=`);
1543
+ import_fs12.default.appendFileSync(envPath, `
1544
+ GMAIL_SERVICE=`);
1545
+ import_fs12.default.appendFileSync(envPath, `
1546
+ GMAIL_MAIL=`);
1547
+ import_fs12.default.appendFileSync(envPath, `
1548
+ GMAIL_NAME=`);
1549
+ import_fs12.default.appendFileSync(envPath, `
1550
+ GMAIL_PASSWORD=`);
1551
+ }
1552
+ const templatePath = import_path12.default.resolve(
1553
+ __dirname,
1554
+ "./template/email/emailGmail.ts"
1555
+ );
1556
+ const libPath = import_path12.default.join(projectDir, srcFolder, "lib");
1557
+ if (!import_fs12.default.existsSync(libPath)) {
1558
+ import_fs12.default.mkdirSync(libPath, { recursive: true });
1559
+ }
1560
+ const libDestinationPath = import_path12.default.join(libPath, "email.ts");
1561
+ import_fs12.default.copyFileSync(templatePath, libDestinationPath);
1562
+ } catch (error) {
1563
+ console.log(import_chalk13.default.red(error));
1564
+ }
1565
+ };
1566
+
1567
+ // email/gmailRunTanstackState.ts
1568
+ var import_chalk14 = __toESM(require("chalk"), 1);
1569
+ var import_path13 = __toESM(require("path"), 1);
1570
+ var import_fs13 = __toESM(require("fs"), 1);
1571
+ var import_url12 = require("url");
1572
+ var import_meta12 = {};
1573
+ var gmailRunTanstackState = async () => {
1401
1574
  try {
1402
1575
  const projectDir = process.cwd();
1403
1576
  const packageJsonPath = import_path13.default.join(projectDir, "package.json");
1404
1577
  const packageJson2 = JSON.parse(import_fs13.default.readFileSync(packageJsonPath, "utf-8"));
1405
- const srcFolder = import_fs13.default.existsSync(import_path13.default.join(projectDir, "src")) ? "src" : "";
1406
- const __filename = (0, import_url11.fileURLToPath)(import_meta11.url);
1578
+ const __filename = (0, import_url12.fileURLToPath)(import_meta12.url);
1407
1579
  const __dirname = import_path13.default.dirname(__filename);
1408
1580
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1409
- console.log(import_chalk12.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1581
+ console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1410
1582
  packageManager("nodemailer");
1411
1583
  packageManager("@types/nodemailer", true);
1412
1584
  }
1413
1585
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1414
- console.log(import_chalk12.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1586
+ console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1415
1587
  packageManager("@react-email/components");
1416
1588
  }
1417
1589
  const envPath = import_path13.default.join(projectDir, ".env");
@@ -1437,94 +1609,94 @@ GMAIL_PASSWORD=`);
1437
1609
  __dirname,
1438
1610
  "./template/email/emailGmail.ts"
1439
1611
  );
1440
- const libPath = import_path13.default.join(projectDir, srcFolder, "lib");
1612
+ const libPath = import_path13.default.join(projectDir, "src", "lib");
1441
1613
  if (!import_fs13.default.existsSync(libPath)) {
1442
1614
  import_fs13.default.mkdirSync(libPath, { recursive: true });
1443
1615
  }
1444
1616
  const libDestinationPath = import_path13.default.join(libPath, "email.ts");
1445
1617
  import_fs13.default.copyFileSync(templatePath, libDestinationPath);
1446
1618
  } catch (error) {
1447
- console.log(import_chalk12.default.red(error));
1619
+ console.log(import_chalk14.default.red(error));
1448
1620
  }
1449
1621
  };
1450
1622
 
1451
- // email/gmailRunTanstackState.ts
1452
- var import_chalk13 = __toESM(require("chalk"), 1);
1623
+ // email/awsSesRun.ts
1624
+ var import_chalk15 = __toESM(require("chalk"), 1);
1453
1625
  var import_path14 = __toESM(require("path"), 1);
1454
1626
  var import_fs14 = __toESM(require("fs"), 1);
1455
- var import_url12 = require("url");
1456
- var import_meta12 = {};
1457
- var gmailRunTanstackState = async () => {
1627
+ var import_url13 = require("url");
1628
+ var import_meta13 = {};
1629
+ var awsSesRun = async () => {
1458
1630
  try {
1459
1631
  const projectDir = process.cwd();
1460
1632
  const packageJsonPath = import_path14.default.join(projectDir, "package.json");
1461
1633
  const packageJson2 = JSON.parse(import_fs14.default.readFileSync(packageJsonPath, "utf-8"));
1462
- const __filename = (0, import_url12.fileURLToPath)(import_meta12.url);
1634
+ const srcFolder = import_fs14.default.existsSync(import_path14.default.join(projectDir, "src")) ? "src" : "";
1635
+ const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
1463
1636
  const __dirname = import_path14.default.dirname(__filename);
1464
1637
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1465
- console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1638
+ console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1466
1639
  packageManager("nodemailer");
1467
1640
  packageManager("@types/nodemailer", true);
1468
1641
  }
1469
1642
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1470
- console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1643
+ console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1471
1644
  packageManager("@react-email/components");
1472
1645
  }
1473
1646
  const envPath = import_path14.default.join(projectDir, ".env");
1474
1647
  const envContent = import_fs14.default.readFileSync(envPath, "utf8");
1475
- 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")) {
1648
+ 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")) {
1476
1649
  import_fs14.default.appendFileSync(envPath, `
1477
1650
 
1478
- # Gmail API Key for sending emails`);
1651
+ # AWS SES API Key for sending emails`);
1479
1652
  import_fs14.default.appendFileSync(envPath, `
1480
- GMAIL_HOST=`);
1653
+ AWS_SES_HOST=`);
1481
1654
  import_fs14.default.appendFileSync(envPath, `
1482
- GMAIL_PORT=`);
1655
+ AWS_SES_PORT=`);
1483
1656
  import_fs14.default.appendFileSync(envPath, `
1484
- GMAIL_SERVICE=`);
1657
+ AWS_SES_SERVICE=`);
1485
1658
  import_fs14.default.appendFileSync(envPath, `
1486
- GMAIL_MAIL=`);
1659
+ AWS_SES_USER=`);
1487
1660
  import_fs14.default.appendFileSync(envPath, `
1488
- GMAIL_NAME=`);
1661
+ AWS_SES_PASS=`);
1489
1662
  import_fs14.default.appendFileSync(envPath, `
1490
- GMAIL_PASSWORD=`);
1663
+ AWS_SES_FROM=`);
1491
1664
  }
1492
1665
  const templatePath = import_path14.default.resolve(
1493
1666
  __dirname,
1494
- "./template/email/emailGmail.ts"
1667
+ "./template/email/emailAwsSes.ts"
1495
1668
  );
1496
- const libPath = import_path14.default.join(projectDir, "src", "lib");
1669
+ const libPath = import_path14.default.join(projectDir, srcFolder, "lib");
1497
1670
  if (!import_fs14.default.existsSync(libPath)) {
1498
1671
  import_fs14.default.mkdirSync(libPath, { recursive: true });
1499
1672
  }
1500
1673
  const libDestinationPath = import_path14.default.join(libPath, "email.ts");
1501
1674
  import_fs14.default.copyFileSync(templatePath, libDestinationPath);
1502
1675
  } catch (error) {
1503
- console.log(import_chalk13.default.red(error));
1676
+ console.log(import_chalk15.default.red(error));
1504
1677
  }
1505
1678
  };
1506
1679
 
1507
- // email/awsSesRun.ts
1508
- var import_chalk14 = __toESM(require("chalk"), 1);
1680
+ // email/awsSesRunTanstackState.ts
1681
+ var import_chalk16 = __toESM(require("chalk"), 1);
1509
1682
  var import_path15 = __toESM(require("path"), 1);
1510
1683
  var import_fs15 = __toESM(require("fs"), 1);
1511
- var import_url13 = require("url");
1512
- var import_meta13 = {};
1513
- var awsSesRun = async () => {
1684
+ var import_url14 = require("url");
1685
+ var import_meta14 = {};
1686
+ var awsSesRunTanstackState = async () => {
1514
1687
  try {
1515
1688
  const projectDir = process.cwd();
1516
1689
  const packageJsonPath = import_path15.default.join(projectDir, "package.json");
1517
1690
  const packageJson2 = JSON.parse(import_fs15.default.readFileSync(packageJsonPath, "utf-8"));
1518
- const srcFolder = import_fs15.default.existsSync(import_path15.default.join(projectDir, "src")) ? "src" : "";
1519
- const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
1691
+ const __filename = (0, import_url14.fileURLToPath)(import_meta14.url);
1520
1692
  const __dirname = import_path15.default.dirname(__filename);
1521
1693
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1522
- console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1694
+ console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1523
1695
  packageManager("nodemailer");
1524
1696
  packageManager("@types/nodemailer", true);
1525
1697
  }
1526
1698
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1527
- console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1699
+ console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1528
1700
  packageManager("@react-email/components");
1529
1701
  }
1530
1702
  const envPath = import_path15.default.join(projectDir, ".env");
@@ -1550,93 +1722,86 @@ AWS_SES_FROM=`);
1550
1722
  __dirname,
1551
1723
  "./template/email/emailAwsSes.ts"
1552
1724
  );
1553
- const libPath = import_path15.default.join(projectDir, srcFolder, "lib");
1725
+ const libPath = import_path15.default.join(projectDir, "src", "lib");
1554
1726
  if (!import_fs15.default.existsSync(libPath)) {
1555
1727
  import_fs15.default.mkdirSync(libPath, { recursive: true });
1556
1728
  }
1557
1729
  const libDestinationPath = import_path15.default.join(libPath, "email.ts");
1558
1730
  import_fs15.default.copyFileSync(templatePath, libDestinationPath);
1559
1731
  } catch (error) {
1560
- console.log(import_chalk14.default.red(error));
1732
+ console.log(import_chalk16.default.red(error));
1561
1733
  }
1562
1734
  };
1563
1735
 
1564
- // email/awsSesRunTanstackState.ts
1565
- var import_chalk15 = __toESM(require("chalk"), 1);
1736
+ // email/resendRun.ts
1737
+ var import_chalk17 = __toESM(require("chalk"), 1);
1566
1738
  var import_path16 = __toESM(require("path"), 1);
1567
1739
  var import_fs16 = __toESM(require("fs"), 1);
1568
- var import_url14 = require("url");
1569
- var import_meta14 = {};
1570
- var awsSesRunTanstackState = async () => {
1740
+ var import_url15 = require("url");
1741
+ var import_meta15 = {};
1742
+ var resendRun = async () => {
1571
1743
  try {
1572
1744
  const projectDir = process.cwd();
1573
1745
  const packageJsonPath = import_path16.default.join(projectDir, "package.json");
1574
1746
  const packageJson2 = JSON.parse(import_fs16.default.readFileSync(packageJsonPath, "utf-8"));
1575
- const __filename = (0, import_url14.fileURLToPath)(import_meta14.url);
1747
+ const srcFolder = import_fs16.default.existsSync(import_path16.default.join(projectDir, "src")) ? "src" : "";
1748
+ const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
1576
1749
  const __dirname = import_path16.default.dirname(__filename);
1577
- if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1578
- console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1579
- packageManager("nodemailer");
1580
- packageManager("@types/nodemailer", true);
1750
+ if (!packageJson2.dependencies?.resend) {
1751
+ console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1752
+ packageManager("resend");
1581
1753
  }
1582
1754
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1583
- console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1755
+ console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1584
1756
  packageManager("@react-email/components");
1585
1757
  }
1586
1758
  const envPath = import_path16.default.join(projectDir, ".env");
1587
1759
  const envContent = import_fs16.default.readFileSync(envPath, "utf8");
1588
- 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")) {
1760
+ if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1589
1761
  import_fs16.default.appendFileSync(envPath, `
1590
1762
 
1591
- # AWS SES API Key for sending emails`);
1592
- import_fs16.default.appendFileSync(envPath, `
1593
- AWS_SES_HOST=`);
1594
- import_fs16.default.appendFileSync(envPath, `
1595
- AWS_SES_PORT=`);
1596
- import_fs16.default.appendFileSync(envPath, `
1597
- AWS_SES_SERVICE=`);
1763
+ # Resend API Key for sending emails`);
1598
1764
  import_fs16.default.appendFileSync(envPath, `
1599
- AWS_SES_USER=`);
1765
+ RESEND_API_KEY=`);
1600
1766
  import_fs16.default.appendFileSync(envPath, `
1601
- AWS_SES_PASS=`);
1767
+ EMAIL_SENDER_NAME=Your Name`);
1602
1768
  import_fs16.default.appendFileSync(envPath, `
1603
- AWS_SES_FROM=`);
1769
+ EMAIL_SENDER_ADDRESS=`);
1604
1770
  }
1605
1771
  const templatePath = import_path16.default.resolve(
1606
1772
  __dirname,
1607
- "./template/email/emailAwsSes.ts"
1773
+ "./template/email/emailResend.ts"
1608
1774
  );
1609
- const libPath = import_path16.default.join(projectDir, "src", "lib");
1775
+ const libPath = import_path16.default.join(projectDir, srcFolder, "lib");
1610
1776
  if (!import_fs16.default.existsSync(libPath)) {
1611
1777
  import_fs16.default.mkdirSync(libPath, { recursive: true });
1612
1778
  }
1613
1779
  const libDestinationPath = import_path16.default.join(libPath, "email.ts");
1614
1780
  import_fs16.default.copyFileSync(templatePath, libDestinationPath);
1615
1781
  } catch (error) {
1616
- console.log(import_chalk15.default.red(error));
1782
+ console.log(import_chalk17.default.red(error));
1617
1783
  }
1618
1784
  };
1619
1785
 
1620
- // email/resendRun.ts
1621
- var import_chalk16 = __toESM(require("chalk"), 1);
1786
+ // email/resendRunTanstackState.ts
1787
+ var import_chalk18 = __toESM(require("chalk"), 1);
1622
1788
  var import_path17 = __toESM(require("path"), 1);
1623
1789
  var import_fs17 = __toESM(require("fs"), 1);
1624
- var import_url15 = require("url");
1625
- var import_meta15 = {};
1626
- var resendRun = async () => {
1790
+ var import_url16 = require("url");
1791
+ var import_meta16 = {};
1792
+ var resendRunTanstackState = async () => {
1627
1793
  try {
1628
1794
  const projectDir = process.cwd();
1629
1795
  const packageJsonPath = import_path17.default.join(projectDir, "package.json");
1630
1796
  const packageJson2 = JSON.parse(import_fs17.default.readFileSync(packageJsonPath, "utf-8"));
1631
- const srcFolder = import_fs17.default.existsSync(import_path17.default.join(projectDir, "src")) ? "src" : "";
1632
- const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
1797
+ const __filename = (0, import_url16.fileURLToPath)(import_meta16.url);
1633
1798
  const __dirname = import_path17.default.dirname(__filename);
1634
1799
  if (!packageJson2.dependencies?.resend) {
1635
- console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1800
+ console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1636
1801
  packageManager("resend");
1637
1802
  }
1638
1803
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1639
- console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1804
+ console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1640
1805
  packageManager("@react-email/components");
1641
1806
  }
1642
1807
  const envPath = import_path17.default.join(projectDir, ".env");
@@ -1656,80 +1821,30 @@ EMAIL_SENDER_ADDRESS=`);
1656
1821
  __dirname,
1657
1822
  "./template/email/emailResend.ts"
1658
1823
  );
1659
- const libPath = import_path17.default.join(projectDir, srcFolder, "lib");
1824
+ const libPath = import_path17.default.join(projectDir, "src", "lib");
1660
1825
  if (!import_fs17.default.existsSync(libPath)) {
1661
1826
  import_fs17.default.mkdirSync(libPath, { recursive: true });
1662
1827
  }
1663
1828
  const libDestinationPath = import_path17.default.join(libPath, "email.ts");
1664
1829
  import_fs17.default.copyFileSync(templatePath, libDestinationPath);
1665
1830
  } catch (error) {
1666
- console.log(import_chalk16.default.red(error));
1667
- }
1668
- };
1669
-
1670
- // email/resendRunTanstackState.ts
1671
- var import_chalk17 = __toESM(require("chalk"), 1);
1672
- var import_path18 = __toESM(require("path"), 1);
1673
- var import_fs18 = __toESM(require("fs"), 1);
1674
- var import_url16 = require("url");
1675
- var import_meta16 = {};
1676
- var resendRunTanstackState = async () => {
1677
- try {
1678
- const projectDir = process.cwd();
1679
- const packageJsonPath = import_path18.default.join(projectDir, "package.json");
1680
- const packageJson2 = JSON.parse(import_fs18.default.readFileSync(packageJsonPath, "utf-8"));
1681
- const __filename = (0, import_url16.fileURLToPath)(import_meta16.url);
1682
- const __dirname = import_path18.default.dirname(__filename);
1683
- if (!packageJson2.dependencies?.resend) {
1684
- console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1685
- packageManager("resend");
1686
- }
1687
- if (!packageJson2.dependencies?.["@react-email/components"]) {
1688
- console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1689
- packageManager("@react-email/components");
1690
- }
1691
- const envPath = import_path18.default.join(projectDir, ".env");
1692
- const envContent = import_fs18.default.readFileSync(envPath, "utf8");
1693
- if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1694
- import_fs18.default.appendFileSync(envPath, `
1695
-
1696
- # Resend API Key for sending emails`);
1697
- import_fs18.default.appendFileSync(envPath, `
1698
- RESEND_API_KEY=`);
1699
- import_fs18.default.appendFileSync(envPath, `
1700
- EMAIL_SENDER_NAME=Your Name`);
1701
- import_fs18.default.appendFileSync(envPath, `
1702
- EMAIL_SENDER_ADDRESS=`);
1703
- }
1704
- const templatePath = import_path18.default.resolve(
1705
- __dirname,
1706
- "./template/email/emailResend.ts"
1707
- );
1708
- const libPath = import_path18.default.join(projectDir, "src", "lib");
1709
- if (!import_fs18.default.existsSync(libPath)) {
1710
- import_fs18.default.mkdirSync(libPath, { recursive: true });
1711
- }
1712
- const libDestinationPath = import_path18.default.join(libPath, "email.ts");
1713
- import_fs18.default.copyFileSync(templatePath, libDestinationPath);
1714
- } catch (error) {
1715
- console.log(import_chalk17.default.red(error));
1831
+ console.log(import_chalk18.default.red(error));
1716
1832
  }
1717
1833
  };
1718
1834
 
1719
1835
  // cli/email.ts
1836
+ var import_chalk19 = __toESM(require("chalk"), 1);
1720
1837
  var email = async () => {
1721
1838
  const projectDir = process.cwd();
1722
- const packageJsonPath = import_path19.default.join(projectDir, "package.json");
1723
- let framework = "tanstack state";
1724
- if (import_fs19.default.existsSync(packageJsonPath)) {
1725
- const packageJson2 = JSON.parse(import_fs19.default.readFileSync(packageJsonPath, "utf-8"));
1726
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
1727
- framework = hasNext ? "Next js" : "tanstack state";
1839
+ const { framework, error } = await getFramework();
1840
+ if (error) {
1841
+ console.log(import_chalk19.default.red(error));
1842
+ return;
1728
1843
  }
1729
1844
  if (framework === "Next js") {
1730
- const srcFolder = import_fs19.default.existsSync(import_path19.default.join(projectDir, "src")) ? "src" : "";
1731
- const emailPath = import_path19.default.join(projectDir, srcFolder, "lib", "email.ts");
1732
- if (import_fs19.default.existsSync(emailPath)) {
1845
+ const srcFolder = import_fs18.default.existsSync(import_path18.default.join(projectDir, "src")) ? "src" : "";
1846
+ const emailPath = import_path18.default.join(projectDir, srcFolder, "lib", "email.ts");
1847
+ if (import_fs18.default.existsSync(emailPath)) {
1733
1848
  const answers2 = await import_inquirer4.default.prompt([
1734
1849
  {
1735
1850
  type: "confirm",
@@ -1744,12 +1859,12 @@ var email = async () => {
1744
1859
  }
1745
1860
  }
1746
1861
  if (framework === "tanstack state") {
1747
- const srcFolderTanstackState = import_path19.default.join(projectDir, "src");
1748
- const libPathTanstackState = import_path19.default.join(
1862
+ const srcFolderTanstackState = import_path18.default.join(projectDir, "src");
1863
+ const libPathTanstackState = import_path18.default.join(
1749
1864
  srcFolderTanstackState,
1750
1865
  "lib/email.ts"
1751
1866
  );
1752
- if (import_fs19.default.existsSync(libPathTanstackState)) {
1867
+ if (import_fs18.default.existsSync(libPathTanstackState)) {
1753
1868
  const answers2 = await import_inquirer4.default.prompt([
1754
1869
  {
1755
1870
  type: "confirm",
@@ -1797,19 +1912,19 @@ var forgetNext = async () => {
1797
1912
  try {
1798
1913
  const projectDir = process.cwd();
1799
1914
  const __filename = (0, import_url17.fileURLToPath)(import_meta17.url);
1800
- const __dirname = import_path20.default.dirname(__filename);
1801
- const srcPath = import_path20.default.join(projectDir, "src");
1802
- const folder = import_fs20.default.existsSync(srcPath) ? "src" : "";
1803
- const emailFilePath = import_path20.default.join(projectDir, folder, "lib", "email.ts");
1804
- if (!import_fs20.default.existsSync(emailFilePath)) {
1915
+ const __dirname = import_path19.default.dirname(__filename);
1916
+ const srcPath = import_path19.default.join(projectDir, "src");
1917
+ const folder = import_fs19.default.existsSync(srcPath) ? "src" : "";
1918
+ const emailFilePath = import_path19.default.join(projectDir, folder, "lib", "email.ts");
1919
+ if (!import_fs19.default.existsSync(emailFilePath)) {
1805
1920
  await email();
1806
1921
  }
1807
- const authFilePath = import_path20.default.join(projectDir, folder, "lib", "auth.ts");
1808
- if (!import_fs20.default.existsSync(authFilePath)) {
1809
- console.log(import_chalk18.default.red("auth.ts file not found."));
1922
+ const authFilePath = import_path19.default.join(projectDir, folder, "lib", "auth.ts");
1923
+ if (!import_fs19.default.existsSync(authFilePath)) {
1924
+ console.log(import_chalk20.default.red("auth.ts file not found."));
1810
1925
  return;
1811
1926
  }
1812
- let content = import_fs20.default.readFileSync(authFilePath, "utf8");
1927
+ let content = import_fs19.default.readFileSync(authFilePath, "utf8");
1813
1928
  const codeAdded = ` sendResetPassword: async ({ user, url, token }) => {
1814
1929
  await sendEmail({
1815
1930
  email: user.email!,
@@ -1853,7 +1968,7 @@ var forgetNext = async () => {
1853
1968
  content = before + `
1854
1969
  ${codeAdded}` + after;
1855
1970
  }
1856
- import_fs20.default.writeFileSync(authFilePath, content, "utf8");
1971
+ import_fs19.default.writeFileSync(authFilePath, content, "utf8");
1857
1972
  if (!content.includes("import { sendEmail }")) {
1858
1973
  const lastImportIndex = content.lastIndexOf("import");
1859
1974
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -1863,129 +1978,129 @@ var forgetNext = async () => {
1863
1978
  import { sendEmail } from "./email";
1864
1979
  `;
1865
1980
  content = beforeImports + newImports + afterImports;
1866
- import_fs20.default.writeFileSync(authFilePath, content, "utf8");
1981
+ import_fs19.default.writeFileSync(authFilePath, content, "utf8");
1867
1982
  }
1868
- const componentPath = import_path20.default.resolve(
1983
+ const componentPath = import_path19.default.resolve(
1869
1984
  __dirname,
1870
1985
  "./template/email/reset-password.tsx"
1871
1986
  );
1872
- const destinationPath = import_path20.default.join(
1987
+ const destinationPath = import_path19.default.join(
1873
1988
  projectDir,
1874
1989
  folder,
1875
1990
  "components",
1876
1991
  "email"
1877
1992
  );
1878
- if (!import_fs20.default.existsSync(destinationPath)) {
1879
- import_fs20.default.mkdirSync(destinationPath, { recursive: true });
1993
+ if (!import_fs19.default.existsSync(destinationPath)) {
1994
+ import_fs19.default.mkdirSync(destinationPath, { recursive: true });
1880
1995
  }
1881
- const emailDestinationPath = import_path20.default.join(
1996
+ const emailDestinationPath = import_path19.default.join(
1882
1997
  destinationPath,
1883
1998
  "reset-password.tsx"
1884
1999
  );
1885
- if (import_fs20.default.existsSync(componentPath)) {
1886
- import_fs20.default.copyFileSync(componentPath, emailDestinationPath);
2000
+ if (import_fs19.default.existsSync(componentPath)) {
2001
+ import_fs19.default.copyFileSync(componentPath, emailDestinationPath);
1887
2002
  }
1888
- const forgetComponentPath = import_path20.default.resolve(
2003
+ const forgetComponentPath = import_path19.default.resolve(
1889
2004
  __dirname,
1890
2005
  "./template/components/ForgetComponent.tsx"
1891
2006
  );
1892
- const componentsDestinationPath = import_path20.default.join(
2007
+ const componentsDestinationPath = import_path19.default.join(
1893
2008
  projectDir,
1894
2009
  folder,
1895
2010
  "components",
1896
2011
  "authverse"
1897
2012
  );
1898
- if (!import_fs20.default.existsSync(componentsDestinationPath)) {
1899
- import_fs20.default.mkdirSync(componentsDestinationPath, { recursive: true });
2013
+ if (!import_fs19.default.existsSync(componentsDestinationPath)) {
2014
+ import_fs19.default.mkdirSync(componentsDestinationPath, { recursive: true });
1900
2015
  }
1901
- const forgetDestinationPath = import_path20.default.join(
2016
+ const forgetDestinationPath = import_path19.default.join(
1902
2017
  componentsDestinationPath,
1903
2018
  "ForgetComponent.tsx"
1904
2019
  );
1905
- if (import_fs20.default.existsSync(forgetComponentPath)) {
1906
- import_fs20.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
2020
+ if (import_fs19.default.existsSync(forgetComponentPath)) {
2021
+ import_fs19.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
1907
2022
  }
1908
- const resetComponentPath = import_path20.default.resolve(
2023
+ const resetComponentPath = import_path19.default.resolve(
1909
2024
  __dirname,
1910
2025
  "./template/components/ResetComponent.tsx"
1911
2026
  );
1912
- const resetDestinationPath = import_path20.default.join(
2027
+ const resetDestinationPath = import_path19.default.join(
1913
2028
  componentsDestinationPath,
1914
2029
  "ResetComponent.tsx"
1915
2030
  );
1916
- if (import_fs20.default.existsSync(resetComponentPath)) {
1917
- import_fs20.default.copyFileSync(resetComponentPath, resetDestinationPath);
2031
+ if (import_fs19.default.existsSync(resetComponentPath)) {
2032
+ import_fs19.default.copyFileSync(resetComponentPath, resetDestinationPath);
1918
2033
  }
1919
- const authTemplatePath = import_path20.default.resolve(
2034
+ const authTemplatePath = import_path19.default.resolve(
1920
2035
  __dirname,
1921
2036
  "./template/app-auth-uiDesign"
1922
2037
  );
1923
- const appDestinationPath = import_path20.default.join(projectDir, folder, "app", "auth");
1924
- if (!import_fs20.default.existsSync(appDestinationPath)) {
1925
- import_fs20.default.mkdirSync(appDestinationPath, { recursive: true });
2038
+ const appDestinationPath = import_path19.default.join(projectDir, folder, "app", "auth");
2039
+ if (!import_fs19.default.existsSync(appDestinationPath)) {
2040
+ import_fs19.default.mkdirSync(appDestinationPath, { recursive: true });
1926
2041
  }
1927
- const forgetDestinationDir = import_path20.default.join(appDestinationPath, "forget");
1928
- if (!import_fs20.default.existsSync(forgetDestinationDir)) {
1929
- import_fs20.default.mkdirSync(forgetDestinationDir, { recursive: true });
2042
+ const forgetDestinationDir = import_path19.default.join(appDestinationPath, "forget");
2043
+ if (!import_fs19.default.existsSync(forgetDestinationDir)) {
2044
+ import_fs19.default.mkdirSync(forgetDestinationDir, { recursive: true });
1930
2045
  }
1931
- const forgetPageDestinationPath = import_path20.default.join(
2046
+ const forgetPageDestinationPath = import_path19.default.join(
1932
2047
  forgetDestinationDir,
1933
2048
  "page.tsx"
1934
2049
  );
1935
- import_fs20.default.copyFileSync(
2050
+ import_fs19.default.copyFileSync(
1936
2051
  `${authTemplatePath}/forget/page.tsx`,
1937
2052
  forgetPageDestinationPath
1938
2053
  );
1939
- const resetDestinationDir = import_path20.default.join(
2054
+ const resetDestinationDir = import_path19.default.join(
1940
2055
  appDestinationPath,
1941
2056
  "reset-password"
1942
2057
  );
1943
- if (!import_fs20.default.existsSync(resetDestinationDir)) {
1944
- import_fs20.default.mkdirSync(resetDestinationDir, { recursive: true });
2058
+ if (!import_fs19.default.existsSync(resetDestinationDir)) {
2059
+ import_fs19.default.mkdirSync(resetDestinationDir, { recursive: true });
1945
2060
  }
1946
- const resetPageDestinationPath = import_path20.default.join(
2061
+ const resetPageDestinationPath = import_path19.default.join(
1947
2062
  resetDestinationDir,
1948
2063
  "page.tsx"
1949
2064
  );
1950
- import_fs20.default.copyFileSync(
2065
+ import_fs19.default.copyFileSync(
1951
2066
  `${authTemplatePath}/reset-password/page.tsx`,
1952
2067
  resetPageDestinationPath
1953
2068
  );
1954
2069
  console.log(
1955
- import_chalk18.default.green("Successfully added forget and reset-password pages")
2070
+ import_chalk20.default.green("Successfully added forget and reset-password pages")
1956
2071
  );
1957
2072
  } else {
1958
2073
  console.log(
1959
- import_chalk18.default.red("Could not find emailAndPassword configuration in auth.ts")
2074
+ import_chalk20.default.red("Could not find emailAndPassword configuration in auth.ts")
1960
2075
  );
1961
2076
  }
1962
2077
  } catch (error) {
1963
- console.log(import_chalk18.default.red("Error adding sendResetPassword:"), error);
2078
+ console.log(import_chalk20.default.red("Error adding sendResetPassword:"), error);
1964
2079
  }
1965
2080
  };
1966
2081
 
1967
2082
  // script/forgetTanstack.ts
1968
- var import_chalk19 = __toESM(require("chalk"), 1);
1969
- var import_path21 = __toESM(require("path"), 1);
2083
+ var import_chalk21 = __toESM(require("chalk"), 1);
2084
+ var import_path20 = __toESM(require("path"), 1);
1970
2085
  var import_url18 = require("url");
1971
- var import_fs21 = __toESM(require("fs"), 1);
2086
+ var import_fs20 = __toESM(require("fs"), 1);
1972
2087
  var import_meta18 = {};
1973
2088
  var forgetTanstack = async () => {
1974
2089
  try {
1975
2090
  const projectDir = process.cwd();
1976
2091
  const __filename = (0, import_url18.fileURLToPath)(import_meta18.url);
1977
- const __dirname = import_path21.default.dirname(__filename);
1978
- const srcPath = import_path21.default.join(projectDir, "src");
1979
- const emailFilePath = import_path21.default.join(srcPath, "lib", "email.ts");
1980
- if (!import_fs21.default.existsSync(emailFilePath)) {
2092
+ const __dirname = import_path20.default.dirname(__filename);
2093
+ const srcPath = import_path20.default.join(projectDir, "src");
2094
+ const emailFilePath = import_path20.default.join(srcPath, "lib", "email.ts");
2095
+ if (!import_fs20.default.existsSync(emailFilePath)) {
1981
2096
  await email();
1982
2097
  }
1983
- const authFilePath = import_path21.default.join(srcPath, "lib", "auth.ts");
1984
- if (!import_fs21.default.existsSync(authFilePath)) {
1985
- console.log(import_chalk19.default.red("auth.ts file not found."));
2098
+ const authFilePath = import_path20.default.join(srcPath, "lib", "auth.ts");
2099
+ if (!import_fs20.default.existsSync(authFilePath)) {
2100
+ console.log(import_chalk21.default.red("auth.ts file not found."));
1986
2101
  return;
1987
2102
  }
1988
- let content = import_fs21.default.readFileSync(authFilePath, "utf8");
2103
+ let content = import_fs20.default.readFileSync(authFilePath, "utf8");
1989
2104
  const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
1990
2105
  await sendEmail({
1991
2106
  email: user.email!,
@@ -2029,7 +2144,7 @@ var forgetTanstack = async () => {
2029
2144
  content = before + `
2030
2145
  ${codeAdded}` + after;
2031
2146
  }
2032
- import_fs21.default.writeFileSync(authFilePath, content, "utf8");
2147
+ import_fs20.default.writeFileSync(authFilePath, content, "utf8");
2033
2148
  if (!content.includes("import { sendEmail }")) {
2034
2149
  const lastImportIndex = content.lastIndexOf("import");
2035
2150
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -2039,99 +2154,97 @@ var forgetTanstack = async () => {
2039
2154
  import { sendEmail } from "./email";
2040
2155
  `;
2041
2156
  content = beforeImports + newImports + afterImports;
2042
- import_fs21.default.writeFileSync(authFilePath, content, "utf8");
2157
+ import_fs20.default.writeFileSync(authFilePath, content, "utf8");
2043
2158
  }
2044
- const componentPath = import_path21.default.resolve(
2159
+ const componentPath = import_path20.default.resolve(
2045
2160
  __dirname,
2046
2161
  "./template/email/reset-password.tsx"
2047
2162
  );
2048
- const destinationPath = import_path21.default.join(srcPath, "components", "email");
2049
- if (!import_fs21.default.existsSync(destinationPath)) {
2050
- import_fs21.default.mkdirSync(destinationPath, { recursive: true });
2163
+ const destinationPath = import_path20.default.join(srcPath, "components", "email");
2164
+ if (!import_fs20.default.existsSync(destinationPath)) {
2165
+ import_fs20.default.mkdirSync(destinationPath, { recursive: true });
2051
2166
  }
2052
- const emailDestinationPath = import_path21.default.join(
2167
+ const emailDestinationPath = import_path20.default.join(
2053
2168
  destinationPath,
2054
2169
  "reset-password.tsx"
2055
2170
  );
2056
- if (import_fs21.default.existsSync(componentPath)) {
2057
- import_fs21.default.copyFileSync(componentPath, emailDestinationPath);
2171
+ if (import_fs20.default.existsSync(componentPath)) {
2172
+ import_fs20.default.copyFileSync(componentPath, emailDestinationPath);
2058
2173
  }
2059
- const forgetComponentPath = import_path21.default.resolve(
2174
+ const forgetComponentPath = import_path20.default.resolve(
2060
2175
  __dirname,
2061
2176
  "./template/TanstackState/components/ForgetComponent.tsx"
2062
2177
  );
2063
- const componentsDestinationPath = import_path21.default.join(
2178
+ const componentsDestinationPath = import_path20.default.join(
2064
2179
  srcPath,
2065
2180
  "components",
2066
2181
  "authverse"
2067
2182
  );
2068
- if (!import_fs21.default.existsSync(componentsDestinationPath)) {
2069
- import_fs21.default.mkdirSync(componentsDestinationPath, { recursive: true });
2183
+ if (!import_fs20.default.existsSync(componentsDestinationPath)) {
2184
+ import_fs20.default.mkdirSync(componentsDestinationPath, { recursive: true });
2070
2185
  }
2071
- const forgetDestinationPath = import_path21.default.join(
2186
+ const forgetDestinationPath = import_path20.default.join(
2072
2187
  componentsDestinationPath,
2073
2188
  "ForgetComponent.tsx"
2074
2189
  );
2075
- if (import_fs21.default.existsSync(forgetComponentPath)) {
2076
- import_fs21.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
2190
+ if (import_fs20.default.existsSync(forgetComponentPath)) {
2191
+ import_fs20.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
2077
2192
  }
2078
- const resetComponentPath = import_path21.default.resolve(
2193
+ const resetComponentPath = import_path20.default.resolve(
2079
2194
  __dirname,
2080
2195
  "./template/TanstackState/components/ResetComponent.tsx"
2081
2196
  );
2082
- const resetDestinationPath = import_path21.default.join(
2197
+ const resetDestinationPath = import_path20.default.join(
2083
2198
  componentsDestinationPath,
2084
2199
  "ResetComponent.tsx"
2085
2200
  );
2086
- if (import_fs21.default.existsSync(resetComponentPath)) {
2087
- import_fs21.default.copyFileSync(resetComponentPath, resetDestinationPath);
2201
+ if (import_fs20.default.existsSync(resetComponentPath)) {
2202
+ import_fs20.default.copyFileSync(resetComponentPath, resetDestinationPath);
2088
2203
  }
2089
- const authTemplatePath = import_path21.default.resolve(
2204
+ const authTemplatePath = import_path20.default.resolve(
2090
2205
  __dirname,
2091
2206
  "./template/TanstackState/routes/auth"
2092
2207
  );
2093
- const routesDestinationPath = import_path21.default.join(srcPath, "routes", "auth");
2094
- if (!import_fs21.default.existsSync(routesDestinationPath)) {
2095
- import_fs21.default.mkdirSync(routesDestinationPath, { recursive: true });
2208
+ const routesDestinationPath = import_path20.default.join(srcPath, "routes", "auth");
2209
+ if (!import_fs20.default.existsSync(routesDestinationPath)) {
2210
+ import_fs20.default.mkdirSync(routesDestinationPath, { recursive: true });
2096
2211
  }
2097
- const forgetPageDestinationPath = import_path21.default.join(
2212
+ const forgetPageDestinationPath = import_path20.default.join(
2098
2213
  routesDestinationPath,
2099
2214
  "forget.tsx"
2100
2215
  );
2101
- import_fs21.default.copyFileSync(
2216
+ import_fs20.default.copyFileSync(
2102
2217
  `${authTemplatePath}/forget.tsx`,
2103
2218
  forgetPageDestinationPath
2104
2219
  );
2105
- const resetPageDestinationPath = import_path21.default.join(
2220
+ const resetPageDestinationPath = import_path20.default.join(
2106
2221
  routesDestinationPath,
2107
2222
  "reset-password.tsx"
2108
2223
  );
2109
- import_fs21.default.copyFileSync(
2224
+ import_fs20.default.copyFileSync(
2110
2225
  `${authTemplatePath}/reset-password.tsx`,
2111
2226
  resetPageDestinationPath
2112
2227
  );
2113
2228
  console.log(
2114
- import_chalk19.default.green("Successfully added forget and reset-password pages")
2229
+ import_chalk21.default.green("Successfully added forget and reset-password pages")
2115
2230
  );
2116
2231
  } else {
2117
2232
  console.log(
2118
- import_chalk19.default.red("Could not find emailAndPassword configuration in auth.ts")
2233
+ import_chalk21.default.red("Could not find emailAndPassword configuration in auth.ts")
2119
2234
  );
2120
2235
  }
2121
2236
  } catch (error) {
2122
- console.log(import_chalk19.default.red("Error adding sendResetPassword:"), error);
2237
+ console.log(import_chalk21.default.red("Error adding sendResetPassword:"), error);
2123
2238
  }
2124
2239
  };
2125
2240
 
2126
2241
  // cli/forget.ts
2127
- var forget = () => {
2128
- const projectDir = process.cwd();
2129
- const packageJsonPath = import_path22.default.join(projectDir, "package.json");
2130
- let framework = "tanstack state";
2131
- if (import_fs22.default.existsSync(packageJsonPath)) {
2132
- const packageJson2 = JSON.parse(import_fs22.default.readFileSync(packageJsonPath, "utf-8"));
2133
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
2134
- framework = hasNext ? "Next js" : "tanstack state";
2242
+ var import_chalk22 = __toESM(require("chalk"), 1);
2243
+ var forget = async () => {
2244
+ const { framework, error } = await getFramework();
2245
+ if (error) {
2246
+ console.log(import_chalk22.default.red(error));
2247
+ return;
2135
2248
  }
2136
2249
  if (framework === "Next js") {
2137
2250
  return forgetNext();
@@ -2142,33 +2255,31 @@ var forget = () => {
2142
2255
  };
2143
2256
 
2144
2257
  // cli/verification.ts
2145
- var import_chalk22 = __toESM(require("chalk"), 1);
2146
- var import_fs25 = __toESM(require("fs"), 1);
2147
- var import_path25 = __toESM(require("path"), 1);
2258
+ var import_chalk25 = __toESM(require("chalk"), 1);
2148
2259
 
2149
2260
  // script/verifyNext.ts
2150
- var import_chalk20 = __toESM(require("chalk"), 1);
2151
- var import_fs23 = __toESM(require("fs"), 1);
2152
- var import_path23 = __toESM(require("path"), 1);
2261
+ var import_chalk23 = __toESM(require("chalk"), 1);
2262
+ var import_fs21 = __toESM(require("fs"), 1);
2263
+ var import_path21 = __toESM(require("path"), 1);
2153
2264
  var import_url19 = require("url");
2154
2265
  var import_meta19 = {};
2155
2266
  var verifyNext = async () => {
2156
2267
  try {
2157
2268
  const projectDir = process.cwd();
2158
2269
  const __filename = (0, import_url19.fileURLToPath)(import_meta19.url);
2159
- const __dirname = import_path23.default.dirname(__filename);
2160
- const srcPath = import_path23.default.join(projectDir, "src");
2161
- const folder = import_fs23.default.existsSync(srcPath) ? "src" : "";
2162
- const emailFilePath = import_path23.default.join(projectDir, folder, "lib", "email.ts");
2163
- if (!import_fs23.default.existsSync(emailFilePath)) {
2270
+ const __dirname = import_path21.default.dirname(__filename);
2271
+ const srcPath = import_path21.default.join(projectDir, "src");
2272
+ const folder = import_fs21.default.existsSync(srcPath) ? "src" : "";
2273
+ const emailFilePath = import_path21.default.join(projectDir, folder, "lib", "email.ts");
2274
+ if (!import_fs21.default.existsSync(emailFilePath)) {
2164
2275
  await email();
2165
2276
  }
2166
- const authFilePath = import_path23.default.join(projectDir, folder, "lib", "auth.ts");
2167
- if (!import_fs23.default.existsSync(authFilePath)) {
2168
- console.log(import_chalk20.default.red("auth.ts file not found."));
2277
+ const authFilePath = import_path21.default.join(projectDir, folder, "lib", "auth.ts");
2278
+ if (!import_fs21.default.existsSync(authFilePath)) {
2279
+ console.log(import_chalk23.default.red("auth.ts file not found."));
2169
2280
  return;
2170
2281
  }
2171
- let content = import_fs23.default.readFileSync(authFilePath, "utf8");
2282
+ let content = import_fs21.default.readFileSync(authFilePath, "utf8");
2172
2283
  if (content.includes("emailAndPassword: {")) {
2173
2284
  const start = content.indexOf("emailAndPassword: {");
2174
2285
  let end = start;
@@ -2228,47 +2339,47 @@ var verifyNext = async () => {
2228
2339
  `;
2229
2340
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2230
2341
  }
2231
- import_fs23.default.writeFileSync(authFilePath, content, "utf8");
2232
- const templatePath = import_path23.default.resolve(
2342
+ import_fs21.default.writeFileSync(authFilePath, content, "utf8");
2343
+ const templatePath = import_path21.default.resolve(
2233
2344
  __dirname,
2234
2345
  "./template/email/EmailVerification.tsx"
2235
2346
  );
2236
- const componentsDir = import_path23.default.join(projectDir, folder, "components", "email");
2237
- if (!import_fs23.default.existsSync(componentsDir)) {
2238
- import_fs23.default.mkdirSync(componentsDir, { recursive: true });
2347
+ const componentsDir = import_path21.default.join(projectDir, folder, "components", "email");
2348
+ if (!import_fs21.default.existsSync(componentsDir)) {
2349
+ import_fs21.default.mkdirSync(componentsDir, { recursive: true });
2239
2350
  }
2240
- const destFile = import_path23.default.join(componentsDir, "EmailVerification.tsx");
2241
- if (import_fs23.default.existsSync(templatePath) && !import_fs23.default.existsSync(destFile)) {
2242
- import_fs23.default.copyFileSync(templatePath, destFile);
2351
+ const destFile = import_path21.default.join(componentsDir, "EmailVerification.tsx");
2352
+ if (import_fs21.default.existsSync(templatePath) && !import_fs21.default.existsSync(destFile)) {
2353
+ import_fs21.default.copyFileSync(templatePath, destFile);
2243
2354
  }
2244
- console.log(import_chalk20.default.green("Email verification successfully configured"));
2355
+ console.log(import_chalk23.default.green("Email verification successfully configured"));
2245
2356
  } catch (error) {
2246
- console.log(import_chalk20.default.red(String(error)));
2357
+ console.log(import_chalk23.default.red(String(error)));
2247
2358
  }
2248
2359
  };
2249
2360
 
2250
2361
  // script/verifyTanstack.ts
2251
- var import_chalk21 = __toESM(require("chalk"), 1);
2252
- var import_fs24 = __toESM(require("fs"), 1);
2253
- var import_path24 = __toESM(require("path"), 1);
2362
+ var import_chalk24 = __toESM(require("chalk"), 1);
2363
+ var import_fs22 = __toESM(require("fs"), 1);
2364
+ var import_path22 = __toESM(require("path"), 1);
2254
2365
  var import_url20 = require("url");
2255
2366
  var import_meta20 = {};
2256
2367
  var verifyTanstack = async () => {
2257
2368
  try {
2258
2369
  const projectDir = process.cwd();
2259
2370
  const __filename = (0, import_url20.fileURLToPath)(import_meta20.url);
2260
- const __dirname = import_path24.default.dirname(__filename);
2261
- const srcPath = import_path24.default.join(projectDir, "src");
2262
- const emailFilePath = import_path24.default.join(srcPath, "lib", "email.ts");
2263
- if (!import_fs24.default.existsSync(emailFilePath)) {
2371
+ const __dirname = import_path22.default.dirname(__filename);
2372
+ const srcPath = import_path22.default.join(projectDir, "src");
2373
+ const emailFilePath = import_path22.default.join(srcPath, "lib", "email.ts");
2374
+ if (!import_fs22.default.existsSync(emailFilePath)) {
2264
2375
  await email();
2265
2376
  }
2266
- const authFilePath = import_path24.default.join(srcPath, "lib", "auth.ts");
2267
- if (!import_fs24.default.existsSync(authFilePath)) {
2268
- console.log(import_chalk21.default.red("auth.ts file not found."));
2377
+ const authFilePath = import_path22.default.join(srcPath, "lib", "auth.ts");
2378
+ if (!import_fs22.default.existsSync(authFilePath)) {
2379
+ console.log(import_chalk24.default.red("auth.ts file not found."));
2269
2380
  return;
2270
2381
  }
2271
- let content = import_fs24.default.readFileSync(authFilePath, "utf8");
2382
+ let content = import_fs22.default.readFileSync(authFilePath, "utf8");
2272
2383
  if (content.includes("emailAndPassword: {")) {
2273
2384
  const start = content.indexOf("emailAndPassword: {");
2274
2385
  let end = start;
@@ -2328,35 +2439,32 @@ var verifyTanstack = async () => {
2328
2439
  `;
2329
2440
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2330
2441
  }
2331
- import_fs24.default.writeFileSync(authFilePath, content, "utf8");
2332
- const templatePath = import_path24.default.resolve(
2442
+ import_fs22.default.writeFileSync(authFilePath, content, "utf8");
2443
+ const templatePath = import_path22.default.resolve(
2333
2444
  __dirname,
2334
2445
  "./template/email/EmailVerification.tsx"
2335
2446
  );
2336
- const componentsDir = import_path24.default.join(srcPath, "components", "email");
2337
- if (!import_fs24.default.existsSync(componentsDir)) {
2338
- import_fs24.default.mkdirSync(componentsDir, { recursive: true });
2447
+ const componentsDir = import_path22.default.join(srcPath, "components", "email");
2448
+ if (!import_fs22.default.existsSync(componentsDir)) {
2449
+ import_fs22.default.mkdirSync(componentsDir, { recursive: true });
2339
2450
  }
2340
- const destFile = import_path24.default.join(componentsDir, "EmailVerification.tsx");
2341
- if (import_fs24.default.existsSync(templatePath) && !import_fs24.default.existsSync(destFile)) {
2342
- import_fs24.default.copyFileSync(templatePath, destFile);
2451
+ const destFile = import_path22.default.join(componentsDir, "EmailVerification.tsx");
2452
+ if (import_fs22.default.existsSync(templatePath) && !import_fs22.default.existsSync(destFile)) {
2453
+ import_fs22.default.copyFileSync(templatePath, destFile);
2343
2454
  }
2344
- console.log(import_chalk21.default.green("Email verification successfully configured"));
2455
+ console.log(import_chalk24.default.green("Email verification successfully configured"));
2345
2456
  } catch (error) {
2346
- console.log(import_chalk21.default.red(String(error)));
2457
+ console.log(import_chalk24.default.red(String(error)));
2347
2458
  }
2348
2459
  };
2349
2460
 
2350
2461
  // cli/verification.ts
2351
2462
  var verification = async () => {
2352
2463
  try {
2353
- const projectDir = process.cwd();
2354
- const packageJsonPath = import_path25.default.join(projectDir, "package.json");
2355
- let framework = "tanstack state";
2356
- if (import_fs25.default.existsSync(packageJsonPath)) {
2357
- const packageJson2 = JSON.parse(import_fs25.default.readFileSync(packageJsonPath, "utf-8"));
2358
- const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
2359
- framework = hasNext ? "Next js" : "tanstack state";
2464
+ const { framework, error } = await getFramework();
2465
+ if (error) {
2466
+ console.log(import_chalk25.default.red(error));
2467
+ return;
2360
2468
  }
2361
2469
  if (framework === "Next js") {
2362
2470
  await verifyNext();
@@ -2365,23 +2473,75 @@ var verification = async () => {
2365
2473
  await verifyTanstack();
2366
2474
  }
2367
2475
  } catch (error) {
2368
- console.log(import_chalk22.default.red(error.message));
2476
+ console.log(import_chalk25.default.red(error.message));
2477
+ }
2478
+ };
2479
+
2480
+ // cli/initCmd.ts
2481
+ var import_chalk26 = __toESM(require("chalk"), 1);
2482
+ var initCmd = async (cmd) => {
2483
+ try {
2484
+ const { framework, error } = await getFramework();
2485
+ if (error) {
2486
+ console.log(import_chalk26.default.red(error));
2487
+ return;
2488
+ }
2489
+ if (framework === "Next js" && cmd.orm === "prisma") {
2490
+ await prismaRun({
2491
+ database: cmd.db,
2492
+ authUi: cmd.authUi === "yes" ? true : false,
2493
+ cmd: true
2494
+ });
2495
+ }
2496
+ if (framework === "Next js" && cmd.orm === "drizzle") {
2497
+ await drizzleRun({
2498
+ authUi: cmd.authUi === "yes" ? true : false,
2499
+ cmd: true
2500
+ });
2501
+ }
2502
+ if (framework === "tanstack state" && cmd.orm === "prisma") {
2503
+ await prismaRunTanstackState({
2504
+ authUi: cmd.authUi === "yes" ? true : false,
2505
+ database: cmd.db,
2506
+ cmd: true
2507
+ });
2508
+ }
2509
+ if (framework === "tanstack state" && cmd.orm === "drizzle") {
2510
+ await drizzleRunTanstackState({
2511
+ authUi: cmd.authUi === "yes" ? true : false,
2512
+ cmd: true
2513
+ });
2514
+ }
2515
+ } catch (error) {
2516
+ console.log(import_chalk26.default.red(error));
2369
2517
  }
2370
2518
  };
2371
2519
 
2372
2520
  // index.ts
2373
- var packageJson = JSON.parse((0, import_fs26.readFileSync)("./package.json", "utf8"));
2521
+ var packageJson = JSON.parse((0, import_fs23.readFileSync)("./package.json", "utf8"));
2374
2522
  var program = new import_commander.Command();
2375
2523
  program.name("authverse").description("CLI tool for creating authverse projects").version(
2376
2524
  packageJson.version || "1.0.0",
2377
2525
  "-v, --version",
2378
2526
  "display the version number"
2379
2527
  );
2380
- program.command("init").description("Select project template and configuration").action(async () => {
2381
- await initAnswer();
2528
+ 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) => {
2529
+ if (!cmd.orm || !cmd.db || !cmd.authUi) {
2530
+ await initAnswer();
2531
+ } else {
2532
+ await initCmd(cmd);
2533
+ }
2534
+ });
2535
+ program.command("add <provider>").description("Add a new authentication provider").action(async (provider) => {
2536
+ await providers({ provider });
2537
+ });
2538
+ program.command("forget").description("Forget stored configurations").action(async () => {
2539
+ await forget();
2540
+ });
2541
+ program.command("email").description("Configure email settings").action(async () => {
2542
+ await email();
2543
+ });
2544
+ program.command("verify").description("Verify authentication setup").action(async () => {
2545
+ await verification();
2382
2546
  });
2383
- program.command("add <provider>").description("Add a new authentication provider").action((provider) => providers({ provider }));
2384
- program.command("forget").description("Forget stored configurations").action(forget);
2385
- program.command("email").description("Configure email settings").action(email);
2386
- program.command("verify").description("Verify authentication setup").action(verification);
2387
2547
  program.parse(process.argv);