authverse 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/index.cjs +604 -440
- package/dist/index.js +597 -433
- package/dist/template/TanstackState/components/LoginComponent.tsx +4 -1
- package/dist/template/TanstackState/components/ResetComponent.tsx +6 -4
- package/dist/template/TanstackState/components/SingUpComponent.tsx +4 -1
- package/package.json +7 -13
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 "
|
|
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
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
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")
|
|
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 (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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({
|
|
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({
|
|
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
|
|
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
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
|
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")
|
|
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 (
|
|
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
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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,36 +1014,44 @@ 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(
|
|
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(
|
|
1035
|
+
await drizzleRunTanstackState({
|
|
1036
|
+
authUi: answers.authUi,
|
|
1037
|
+
cmd: false
|
|
1038
|
+
});
|
|
912
1039
|
}
|
|
913
1040
|
};
|
|
914
1041
|
|
|
915
1042
|
// index.ts
|
|
916
|
-
var
|
|
1043
|
+
var import_fs23 = require("fs");
|
|
917
1044
|
|
|
918
|
-
// cli/
|
|
919
|
-
var
|
|
1045
|
+
// cli/oauth.ts
|
|
1046
|
+
var import_chalk12 = __toESM(require("chalk"), 1);
|
|
920
1047
|
|
|
921
|
-
//
|
|
922
|
-
var
|
|
1048
|
+
// oauth/googleNext.ts
|
|
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");
|
|
926
1053
|
var import_meta7 = {};
|
|
927
|
-
var
|
|
1054
|
+
var googleNext = async () => {
|
|
928
1055
|
try {
|
|
929
1056
|
const __filename = (0, import_url7.fileURLToPath)(import_meta7.url);
|
|
930
1057
|
const __dirname = import_path8.default.dirname(__filename);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
1103
|
+
import_chalk8.default.red(
|
|
977
1104
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
978
1105
|
)
|
|
979
1106
|
);
|
|
@@ -1022,19 +1149,19 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1022
1149
|
if (import_fs8.default.existsSync(componentTemplate)) {
|
|
1023
1150
|
import_fs8.default.copyFileSync(componentTemplate, componentDest);
|
|
1024
1151
|
}
|
|
1025
|
-
console.log(
|
|
1152
|
+
console.log(import_chalk8.default.green("Google provider added & merged successfully"));
|
|
1026
1153
|
} catch (error) {
|
|
1027
|
-
console.log(
|
|
1154
|
+
console.log(import_chalk8.default.red("googleRun error:"), error);
|
|
1028
1155
|
}
|
|
1029
1156
|
};
|
|
1030
1157
|
|
|
1031
|
-
//
|
|
1032
|
-
var
|
|
1158
|
+
// oauth/githubNext.ts
|
|
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");
|
|
1036
1163
|
var import_meta8 = {};
|
|
1037
|
-
var
|
|
1164
|
+
var githubNext = async () => {
|
|
1038
1165
|
try {
|
|
1039
1166
|
const __filename = (0, import_url8.fileURLToPath)(import_meta8.url);
|
|
1040
1167
|
const __dirname = import_path9.default.dirname(__filename);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
1213
|
+
import_chalk9.default.red(
|
|
1087
1214
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1088
1215
|
)
|
|
1089
1216
|
);
|
|
@@ -1132,23 +1259,19 @@ GITHUB_CLIENT_SECRET=
|
|
|
1132
1259
|
if (import_fs9.default.existsSync(componentTemplate)) {
|
|
1133
1260
|
import_fs9.default.copyFileSync(componentTemplate, componentDest);
|
|
1134
1261
|
}
|
|
1135
|
-
console.log(
|
|
1262
|
+
console.log(import_chalk9.default.green("GitHub provider added & merged successfully"));
|
|
1136
1263
|
} catch (error) {
|
|
1137
|
-
console.log(
|
|
1264
|
+
console.log(import_chalk9.default.red("githubRun error:"), error);
|
|
1138
1265
|
}
|
|
1139
1266
|
};
|
|
1140
1267
|
|
|
1141
|
-
//
|
|
1142
|
-
var
|
|
1143
|
-
var import_fs12 = __toESM(require("fs"), 1);
|
|
1144
|
-
|
|
1145
|
-
// script/googleRunTanstackState.ts
|
|
1146
|
-
var import_chalk9 = __toESM(require("chalk"), 1);
|
|
1268
|
+
// oauth/googleTanstackState.ts
|
|
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");
|
|
1150
1273
|
var import_meta9 = {};
|
|
1151
|
-
var
|
|
1274
|
+
var googleTanstackState = async () => {
|
|
1152
1275
|
try {
|
|
1153
1276
|
const __filename = (0, import_url9.fileURLToPath)(import_meta9.url);
|
|
1154
1277
|
const __dirname = import_path10.default.dirname(__filename);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
1322
|
+
import_chalk10.default.red(
|
|
1200
1323
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1201
1324
|
)
|
|
1202
1325
|
);
|
|
@@ -1240,19 +1363,19 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1240
1363
|
if (import_fs10.default.existsSync(componentTemplate)) {
|
|
1241
1364
|
import_fs10.default.copyFileSync(componentTemplate, componentDest);
|
|
1242
1365
|
}
|
|
1243
|
-
console.log(
|
|
1366
|
+
console.log(import_chalk10.default.green("Google provider added & merged successfully"));
|
|
1244
1367
|
} catch (error) {
|
|
1245
|
-
console.log(
|
|
1368
|
+
console.log(import_chalk10.default.red("googleRunTanstackState error:"), error);
|
|
1246
1369
|
}
|
|
1247
1370
|
};
|
|
1248
1371
|
|
|
1249
|
-
//
|
|
1250
|
-
var
|
|
1372
|
+
// oauth/githubTanstackState.ts
|
|
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");
|
|
1254
1377
|
var import_meta10 = {};
|
|
1255
|
-
var
|
|
1378
|
+
var githubTanstackState = async () => {
|
|
1256
1379
|
try {
|
|
1257
1380
|
const __filename = (0, import_url10.fileURLToPath)(import_meta10.url);
|
|
1258
1381
|
const __dirname = import_path11.default.dirname(__filename);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
1426
|
+
import_chalk11.default.red(
|
|
1304
1427
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1305
1428
|
)
|
|
1306
1429
|
);
|
|
@@ -1344,74 +1467,127 @@ GITHUB_CLIENT_SECRET=
|
|
|
1344
1467
|
if (import_fs11.default.existsSync(componentTemplate)) {
|
|
1345
1468
|
import_fs11.default.copyFileSync(componentTemplate, componentDest);
|
|
1346
1469
|
}
|
|
1347
|
-
console.log(
|
|
1470
|
+
console.log(import_chalk11.default.green("Github provider added & merged successfully"));
|
|
1348
1471
|
} catch (error) {
|
|
1349
|
-
console.log(
|
|
1472
|
+
console.log(import_chalk11.default.red("githubRunTanstackState error:"), error);
|
|
1350
1473
|
}
|
|
1351
1474
|
};
|
|
1352
1475
|
|
|
1353
|
-
// cli/
|
|
1354
|
-
var
|
|
1476
|
+
// cli/oauth.ts
|
|
1477
|
+
var Oauth = async ({ oauth }) => {
|
|
1355
1478
|
try {
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
await
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1479
|
+
const { framework, error } = await getFramework();
|
|
1480
|
+
if (error) {
|
|
1481
|
+
console.log(import_chalk12.default.red(error));
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
if (framework === "Next js" && oauth == "google") {
|
|
1485
|
+
await googleNext();
|
|
1486
|
+
} else if (framework === "Next js" && oauth == "github") {
|
|
1487
|
+
await githubNext();
|
|
1488
|
+
}
|
|
1489
|
+
if (framework === "tanstack state" && oauth == "google") {
|
|
1490
|
+
await googleTanstackState();
|
|
1491
|
+
} else if (framework === "tanstack state" && oauth == "github") {
|
|
1492
|
+
await githubTanstackState();
|
|
1493
|
+
}
|
|
1494
|
+
if (oauth !== "google" && oauth !== "github") {
|
|
1495
|
+
console.log(import_chalk12.default.red("Invalid oauth provider"));
|
|
1496
|
+
return;
|
|
1373
1497
|
}
|
|
1374
1498
|
} catch (error) {
|
|
1375
|
-
console.log(
|
|
1499
|
+
console.log(import_chalk12.default.red("Error adding oauth:"), error);
|
|
1376
1500
|
}
|
|
1377
1501
|
};
|
|
1378
1502
|
|
|
1379
|
-
// cli/forget.ts
|
|
1380
|
-
var import_path22 = __toESM(require("path"), 1);
|
|
1381
|
-
var import_fs22 = __toESM(require("fs"), 1);
|
|
1382
|
-
|
|
1383
1503
|
// script/forgetNext.ts
|
|
1384
|
-
var
|
|
1385
|
-
var
|
|
1504
|
+
var import_chalk20 = __toESM(require("chalk"), 1);
|
|
1505
|
+
var import_path19 = __toESM(require("path"), 1);
|
|
1386
1506
|
var import_url17 = require("url");
|
|
1387
|
-
var
|
|
1507
|
+
var import_fs19 = __toESM(require("fs"), 1);
|
|
1388
1508
|
|
|
1389
1509
|
// cli/email.ts
|
|
1390
|
-
var
|
|
1391
|
-
var
|
|
1510
|
+
var import_path18 = __toESM(require("path"), 1);
|
|
1511
|
+
var import_fs18 = __toESM(require("fs"), 1);
|
|
1392
1512
|
var import_inquirer4 = __toESM(require("inquirer"), 1);
|
|
1393
1513
|
|
|
1394
1514
|
// email/gmailRun.ts
|
|
1395
|
-
var
|
|
1396
|
-
var
|
|
1397
|
-
var
|
|
1515
|
+
var import_chalk13 = __toESM(require("chalk"), 1);
|
|
1516
|
+
var import_path12 = __toESM(require("path"), 1);
|
|
1517
|
+
var import_fs12 = __toESM(require("fs"), 1);
|
|
1398
1518
|
var import_url11 = require("url");
|
|
1399
1519
|
var import_meta11 = {};
|
|
1400
1520
|
var gmailRun = async () => {
|
|
1521
|
+
try {
|
|
1522
|
+
const projectDir = process.cwd();
|
|
1523
|
+
const packageJsonPath = import_path12.default.join(projectDir, "package.json");
|
|
1524
|
+
const packageJson2 = JSON.parse(import_fs12.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1525
|
+
const srcFolder = import_fs12.default.existsSync(import_path12.default.join(projectDir, "src")) ? "src" : "";
|
|
1526
|
+
const __filename = (0, import_url11.fileURLToPath)(import_meta11.url);
|
|
1527
|
+
const __dirname = import_path12.default.dirname(__filename);
|
|
1528
|
+
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1529
|
+
console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1530
|
+
packageManager("nodemailer");
|
|
1531
|
+
packageManager("@types/nodemailer", true);
|
|
1532
|
+
}
|
|
1533
|
+
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1534
|
+
console.log(import_chalk13.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1535
|
+
packageManager("@react-email/components");
|
|
1536
|
+
}
|
|
1537
|
+
const envPath = import_path12.default.join(projectDir, ".env");
|
|
1538
|
+
const envContent = import_fs12.default.readFileSync(envPath, "utf8");
|
|
1539
|
+
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")) {
|
|
1540
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1541
|
+
|
|
1542
|
+
# Gmail API Key for sending emails`);
|
|
1543
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1544
|
+
GMAIL_HOST=`);
|
|
1545
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1546
|
+
GMAIL_PORT=`);
|
|
1547
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1548
|
+
GMAIL_SERVICE=`);
|
|
1549
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1550
|
+
GMAIL_MAIL=`);
|
|
1551
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1552
|
+
GMAIL_NAME=`);
|
|
1553
|
+
import_fs12.default.appendFileSync(envPath, `
|
|
1554
|
+
GMAIL_PASSWORD=`);
|
|
1555
|
+
}
|
|
1556
|
+
const templatePath = import_path12.default.resolve(
|
|
1557
|
+
__dirname,
|
|
1558
|
+
"./template/email/emailGmail.ts"
|
|
1559
|
+
);
|
|
1560
|
+
const libPath = import_path12.default.join(projectDir, srcFolder, "lib");
|
|
1561
|
+
if (!import_fs12.default.existsSync(libPath)) {
|
|
1562
|
+
import_fs12.default.mkdirSync(libPath, { recursive: true });
|
|
1563
|
+
}
|
|
1564
|
+
const libDestinationPath = import_path12.default.join(libPath, "email.ts");
|
|
1565
|
+
import_fs12.default.copyFileSync(templatePath, libDestinationPath);
|
|
1566
|
+
} catch (error) {
|
|
1567
|
+
console.log(import_chalk13.default.red(error));
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
// email/gmailRunTanstackState.ts
|
|
1572
|
+
var import_chalk14 = __toESM(require("chalk"), 1);
|
|
1573
|
+
var import_path13 = __toESM(require("path"), 1);
|
|
1574
|
+
var import_fs13 = __toESM(require("fs"), 1);
|
|
1575
|
+
var import_url12 = require("url");
|
|
1576
|
+
var import_meta12 = {};
|
|
1577
|
+
var gmailRunTanstackState = async () => {
|
|
1401
1578
|
try {
|
|
1402
1579
|
const projectDir = process.cwd();
|
|
1403
1580
|
const packageJsonPath = import_path13.default.join(projectDir, "package.json");
|
|
1404
1581
|
const packageJson2 = JSON.parse(import_fs13.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1405
|
-
const
|
|
1406
|
-
const __filename = (0, import_url11.fileURLToPath)(import_meta11.url);
|
|
1582
|
+
const __filename = (0, import_url12.fileURLToPath)(import_meta12.url);
|
|
1407
1583
|
const __dirname = import_path13.default.dirname(__filename);
|
|
1408
1584
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1409
|
-
console.log(
|
|
1585
|
+
console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1410
1586
|
packageManager("nodemailer");
|
|
1411
1587
|
packageManager("@types/nodemailer", true);
|
|
1412
1588
|
}
|
|
1413
1589
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1414
|
-
console.log(
|
|
1590
|
+
console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1415
1591
|
packageManager("@react-email/components");
|
|
1416
1592
|
}
|
|
1417
1593
|
const envPath = import_path13.default.join(projectDir, ".env");
|
|
@@ -1437,94 +1613,94 @@ GMAIL_PASSWORD=`);
|
|
|
1437
1613
|
__dirname,
|
|
1438
1614
|
"./template/email/emailGmail.ts"
|
|
1439
1615
|
);
|
|
1440
|
-
const libPath = import_path13.default.join(projectDir,
|
|
1616
|
+
const libPath = import_path13.default.join(projectDir, "src", "lib");
|
|
1441
1617
|
if (!import_fs13.default.existsSync(libPath)) {
|
|
1442
1618
|
import_fs13.default.mkdirSync(libPath, { recursive: true });
|
|
1443
1619
|
}
|
|
1444
1620
|
const libDestinationPath = import_path13.default.join(libPath, "email.ts");
|
|
1445
1621
|
import_fs13.default.copyFileSync(templatePath, libDestinationPath);
|
|
1446
1622
|
} catch (error) {
|
|
1447
|
-
console.log(
|
|
1623
|
+
console.log(import_chalk14.default.red(error));
|
|
1448
1624
|
}
|
|
1449
1625
|
};
|
|
1450
1626
|
|
|
1451
|
-
// email/
|
|
1452
|
-
var
|
|
1627
|
+
// email/awsSesRun.ts
|
|
1628
|
+
var import_chalk15 = __toESM(require("chalk"), 1);
|
|
1453
1629
|
var import_path14 = __toESM(require("path"), 1);
|
|
1454
1630
|
var import_fs14 = __toESM(require("fs"), 1);
|
|
1455
|
-
var
|
|
1456
|
-
var
|
|
1457
|
-
var
|
|
1631
|
+
var import_url13 = require("url");
|
|
1632
|
+
var import_meta13 = {};
|
|
1633
|
+
var awsSesRun = async () => {
|
|
1458
1634
|
try {
|
|
1459
1635
|
const projectDir = process.cwd();
|
|
1460
1636
|
const packageJsonPath = import_path14.default.join(projectDir, "package.json");
|
|
1461
1637
|
const packageJson2 = JSON.parse(import_fs14.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1462
|
-
const
|
|
1638
|
+
const srcFolder = import_fs14.default.existsSync(import_path14.default.join(projectDir, "src")) ? "src" : "";
|
|
1639
|
+
const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
|
|
1463
1640
|
const __dirname = import_path14.default.dirname(__filename);
|
|
1464
1641
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1465
|
-
console.log(
|
|
1642
|
+
console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1466
1643
|
packageManager("nodemailer");
|
|
1467
1644
|
packageManager("@types/nodemailer", true);
|
|
1468
1645
|
}
|
|
1469
1646
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1470
|
-
console.log(
|
|
1647
|
+
console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1471
1648
|
packageManager("@react-email/components");
|
|
1472
1649
|
}
|
|
1473
1650
|
const envPath = import_path14.default.join(projectDir, ".env");
|
|
1474
1651
|
const envContent = import_fs14.default.readFileSync(envPath, "utf8");
|
|
1475
|
-
if (!envContent.includes("
|
|
1652
|
+
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
1653
|
import_fs14.default.appendFileSync(envPath, `
|
|
1477
1654
|
|
|
1478
|
-
#
|
|
1655
|
+
# AWS SES API Key for sending emails`);
|
|
1479
1656
|
import_fs14.default.appendFileSync(envPath, `
|
|
1480
|
-
|
|
1657
|
+
AWS_SES_HOST=`);
|
|
1481
1658
|
import_fs14.default.appendFileSync(envPath, `
|
|
1482
|
-
|
|
1659
|
+
AWS_SES_PORT=`);
|
|
1483
1660
|
import_fs14.default.appendFileSync(envPath, `
|
|
1484
|
-
|
|
1661
|
+
AWS_SES_SERVICE=`);
|
|
1485
1662
|
import_fs14.default.appendFileSync(envPath, `
|
|
1486
|
-
|
|
1663
|
+
AWS_SES_USER=`);
|
|
1487
1664
|
import_fs14.default.appendFileSync(envPath, `
|
|
1488
|
-
|
|
1665
|
+
AWS_SES_PASS=`);
|
|
1489
1666
|
import_fs14.default.appendFileSync(envPath, `
|
|
1490
|
-
|
|
1667
|
+
AWS_SES_FROM=`);
|
|
1491
1668
|
}
|
|
1492
1669
|
const templatePath = import_path14.default.resolve(
|
|
1493
1670
|
__dirname,
|
|
1494
|
-
"./template/email/
|
|
1671
|
+
"./template/email/emailAwsSes.ts"
|
|
1495
1672
|
);
|
|
1496
|
-
const libPath = import_path14.default.join(projectDir,
|
|
1673
|
+
const libPath = import_path14.default.join(projectDir, srcFolder, "lib");
|
|
1497
1674
|
if (!import_fs14.default.existsSync(libPath)) {
|
|
1498
1675
|
import_fs14.default.mkdirSync(libPath, { recursive: true });
|
|
1499
1676
|
}
|
|
1500
1677
|
const libDestinationPath = import_path14.default.join(libPath, "email.ts");
|
|
1501
1678
|
import_fs14.default.copyFileSync(templatePath, libDestinationPath);
|
|
1502
1679
|
} catch (error) {
|
|
1503
|
-
console.log(
|
|
1680
|
+
console.log(import_chalk15.default.red(error));
|
|
1504
1681
|
}
|
|
1505
1682
|
};
|
|
1506
1683
|
|
|
1507
|
-
// email/
|
|
1508
|
-
var
|
|
1684
|
+
// email/awsSesRunTanstackState.ts
|
|
1685
|
+
var import_chalk16 = __toESM(require("chalk"), 1);
|
|
1509
1686
|
var import_path15 = __toESM(require("path"), 1);
|
|
1510
1687
|
var import_fs15 = __toESM(require("fs"), 1);
|
|
1511
|
-
var
|
|
1512
|
-
var
|
|
1513
|
-
var
|
|
1688
|
+
var import_url14 = require("url");
|
|
1689
|
+
var import_meta14 = {};
|
|
1690
|
+
var awsSesRunTanstackState = async () => {
|
|
1514
1691
|
try {
|
|
1515
1692
|
const projectDir = process.cwd();
|
|
1516
1693
|
const packageJsonPath = import_path15.default.join(projectDir, "package.json");
|
|
1517
1694
|
const packageJson2 = JSON.parse(import_fs15.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1518
|
-
const
|
|
1519
|
-
const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
|
|
1695
|
+
const __filename = (0, import_url14.fileURLToPath)(import_meta14.url);
|
|
1520
1696
|
const __dirname = import_path15.default.dirname(__filename);
|
|
1521
1697
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1522
|
-
console.log(
|
|
1698
|
+
console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1523
1699
|
packageManager("nodemailer");
|
|
1524
1700
|
packageManager("@types/nodemailer", true);
|
|
1525
1701
|
}
|
|
1526
1702
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1527
|
-
console.log(
|
|
1703
|
+
console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1528
1704
|
packageManager("@react-email/components");
|
|
1529
1705
|
}
|
|
1530
1706
|
const envPath = import_path15.default.join(projectDir, ".env");
|
|
@@ -1550,93 +1726,86 @@ AWS_SES_FROM=`);
|
|
|
1550
1726
|
__dirname,
|
|
1551
1727
|
"./template/email/emailAwsSes.ts"
|
|
1552
1728
|
);
|
|
1553
|
-
const libPath = import_path15.default.join(projectDir,
|
|
1729
|
+
const libPath = import_path15.default.join(projectDir, "src", "lib");
|
|
1554
1730
|
if (!import_fs15.default.existsSync(libPath)) {
|
|
1555
1731
|
import_fs15.default.mkdirSync(libPath, { recursive: true });
|
|
1556
1732
|
}
|
|
1557
1733
|
const libDestinationPath = import_path15.default.join(libPath, "email.ts");
|
|
1558
1734
|
import_fs15.default.copyFileSync(templatePath, libDestinationPath);
|
|
1559
1735
|
} catch (error) {
|
|
1560
|
-
console.log(
|
|
1736
|
+
console.log(import_chalk16.default.red(error));
|
|
1561
1737
|
}
|
|
1562
1738
|
};
|
|
1563
1739
|
|
|
1564
|
-
// email/
|
|
1565
|
-
var
|
|
1740
|
+
// email/resendRun.ts
|
|
1741
|
+
var import_chalk17 = __toESM(require("chalk"), 1);
|
|
1566
1742
|
var import_path16 = __toESM(require("path"), 1);
|
|
1567
1743
|
var import_fs16 = __toESM(require("fs"), 1);
|
|
1568
|
-
var
|
|
1569
|
-
var
|
|
1570
|
-
var
|
|
1744
|
+
var import_url15 = require("url");
|
|
1745
|
+
var import_meta15 = {};
|
|
1746
|
+
var resendRun = async () => {
|
|
1571
1747
|
try {
|
|
1572
1748
|
const projectDir = process.cwd();
|
|
1573
1749
|
const packageJsonPath = import_path16.default.join(projectDir, "package.json");
|
|
1574
1750
|
const packageJson2 = JSON.parse(import_fs16.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1575
|
-
const
|
|
1751
|
+
const srcFolder = import_fs16.default.existsSync(import_path16.default.join(projectDir, "src")) ? "src" : "";
|
|
1752
|
+
const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
|
|
1576
1753
|
const __dirname = import_path16.default.dirname(__filename);
|
|
1577
|
-
if (!packageJson2.dependencies?.
|
|
1578
|
-
console.log(
|
|
1579
|
-
packageManager("
|
|
1580
|
-
packageManager("@types/nodemailer", true);
|
|
1754
|
+
if (!packageJson2.dependencies?.resend) {
|
|
1755
|
+
console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
1756
|
+
packageManager("resend");
|
|
1581
1757
|
}
|
|
1582
1758
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1583
|
-
console.log(
|
|
1759
|
+
console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1584
1760
|
packageManager("@react-email/components");
|
|
1585
1761
|
}
|
|
1586
1762
|
const envPath = import_path16.default.join(projectDir, ".env");
|
|
1587
1763
|
const envContent = import_fs16.default.readFileSync(envPath, "utf8");
|
|
1588
|
-
if (!envContent.includes("
|
|
1764
|
+
if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
|
|
1589
1765
|
import_fs16.default.appendFileSync(envPath, `
|
|
1590
1766
|
|
|
1591
|
-
#
|
|
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=`);
|
|
1767
|
+
# Resend API Key for sending emails`);
|
|
1598
1768
|
import_fs16.default.appendFileSync(envPath, `
|
|
1599
|
-
|
|
1769
|
+
RESEND_API_KEY=`);
|
|
1600
1770
|
import_fs16.default.appendFileSync(envPath, `
|
|
1601
|
-
|
|
1771
|
+
EMAIL_SENDER_NAME=Your Name`);
|
|
1602
1772
|
import_fs16.default.appendFileSync(envPath, `
|
|
1603
|
-
|
|
1773
|
+
EMAIL_SENDER_ADDRESS=`);
|
|
1604
1774
|
}
|
|
1605
1775
|
const templatePath = import_path16.default.resolve(
|
|
1606
1776
|
__dirname,
|
|
1607
|
-
"./template/email/
|
|
1777
|
+
"./template/email/emailResend.ts"
|
|
1608
1778
|
);
|
|
1609
|
-
const libPath = import_path16.default.join(projectDir,
|
|
1779
|
+
const libPath = import_path16.default.join(projectDir, srcFolder, "lib");
|
|
1610
1780
|
if (!import_fs16.default.existsSync(libPath)) {
|
|
1611
1781
|
import_fs16.default.mkdirSync(libPath, { recursive: true });
|
|
1612
1782
|
}
|
|
1613
1783
|
const libDestinationPath = import_path16.default.join(libPath, "email.ts");
|
|
1614
1784
|
import_fs16.default.copyFileSync(templatePath, libDestinationPath);
|
|
1615
1785
|
} catch (error) {
|
|
1616
|
-
console.log(
|
|
1786
|
+
console.log(import_chalk17.default.red(error));
|
|
1617
1787
|
}
|
|
1618
1788
|
};
|
|
1619
1789
|
|
|
1620
|
-
// email/
|
|
1621
|
-
var
|
|
1790
|
+
// email/resendRunTanstackState.ts
|
|
1791
|
+
var import_chalk18 = __toESM(require("chalk"), 1);
|
|
1622
1792
|
var import_path17 = __toESM(require("path"), 1);
|
|
1623
1793
|
var import_fs17 = __toESM(require("fs"), 1);
|
|
1624
|
-
var
|
|
1625
|
-
var
|
|
1626
|
-
var
|
|
1794
|
+
var import_url16 = require("url");
|
|
1795
|
+
var import_meta16 = {};
|
|
1796
|
+
var resendRunTanstackState = async () => {
|
|
1627
1797
|
try {
|
|
1628
1798
|
const projectDir = process.cwd();
|
|
1629
1799
|
const packageJsonPath = import_path17.default.join(projectDir, "package.json");
|
|
1630
1800
|
const packageJson2 = JSON.parse(import_fs17.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1631
|
-
const
|
|
1632
|
-
const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
|
|
1801
|
+
const __filename = (0, import_url16.fileURLToPath)(import_meta16.url);
|
|
1633
1802
|
const __dirname = import_path17.default.dirname(__filename);
|
|
1634
1803
|
if (!packageJson2.dependencies?.resend) {
|
|
1635
|
-
console.log(
|
|
1804
|
+
console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
1636
1805
|
packageManager("resend");
|
|
1637
1806
|
}
|
|
1638
1807
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1639
|
-
console.log(
|
|
1808
|
+
console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1640
1809
|
packageManager("@react-email/components");
|
|
1641
1810
|
}
|
|
1642
1811
|
const envPath = import_path17.default.join(projectDir, ".env");
|
|
@@ -1656,80 +1825,30 @@ EMAIL_SENDER_ADDRESS=`);
|
|
|
1656
1825
|
__dirname,
|
|
1657
1826
|
"./template/email/emailResend.ts"
|
|
1658
1827
|
);
|
|
1659
|
-
const libPath = import_path17.default.join(projectDir,
|
|
1828
|
+
const libPath = import_path17.default.join(projectDir, "src", "lib");
|
|
1660
1829
|
if (!import_fs17.default.existsSync(libPath)) {
|
|
1661
1830
|
import_fs17.default.mkdirSync(libPath, { recursive: true });
|
|
1662
1831
|
}
|
|
1663
1832
|
const libDestinationPath = import_path17.default.join(libPath, "email.ts");
|
|
1664
1833
|
import_fs17.default.copyFileSync(templatePath, libDestinationPath);
|
|
1665
1834
|
} catch (error) {
|
|
1666
|
-
console.log(
|
|
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));
|
|
1835
|
+
console.log(import_chalk18.default.red(error));
|
|
1716
1836
|
}
|
|
1717
1837
|
};
|
|
1718
1838
|
|
|
1719
1839
|
// cli/email.ts
|
|
1840
|
+
var import_chalk19 = __toESM(require("chalk"), 1);
|
|
1720
1841
|
var email = async () => {
|
|
1721
1842
|
const projectDir = process.cwd();
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
1727
|
-
framework = hasNext ? "Next js" : "tanstack state";
|
|
1843
|
+
const { framework, error } = await getFramework();
|
|
1844
|
+
if (error) {
|
|
1845
|
+
console.log(import_chalk19.default.red(error));
|
|
1846
|
+
return;
|
|
1728
1847
|
}
|
|
1729
1848
|
if (framework === "Next js") {
|
|
1730
|
-
const srcFolder =
|
|
1731
|
-
const emailPath =
|
|
1732
|
-
if (
|
|
1849
|
+
const srcFolder = import_fs18.default.existsSync(import_path18.default.join(projectDir, "src")) ? "src" : "";
|
|
1850
|
+
const emailPath = import_path18.default.join(projectDir, srcFolder, "lib", "email.ts");
|
|
1851
|
+
if (import_fs18.default.existsSync(emailPath)) {
|
|
1733
1852
|
const answers2 = await import_inquirer4.default.prompt([
|
|
1734
1853
|
{
|
|
1735
1854
|
type: "confirm",
|
|
@@ -1744,12 +1863,12 @@ var email = async () => {
|
|
|
1744
1863
|
}
|
|
1745
1864
|
}
|
|
1746
1865
|
if (framework === "tanstack state") {
|
|
1747
|
-
const srcFolderTanstackState =
|
|
1748
|
-
const libPathTanstackState =
|
|
1866
|
+
const srcFolderTanstackState = import_path18.default.join(projectDir, "src");
|
|
1867
|
+
const libPathTanstackState = import_path18.default.join(
|
|
1749
1868
|
srcFolderTanstackState,
|
|
1750
1869
|
"lib/email.ts"
|
|
1751
1870
|
);
|
|
1752
|
-
if (
|
|
1871
|
+
if (import_fs18.default.existsSync(libPathTanstackState)) {
|
|
1753
1872
|
const answers2 = await import_inquirer4.default.prompt([
|
|
1754
1873
|
{
|
|
1755
1874
|
type: "confirm",
|
|
@@ -1797,19 +1916,19 @@ var forgetNext = async () => {
|
|
|
1797
1916
|
try {
|
|
1798
1917
|
const projectDir = process.cwd();
|
|
1799
1918
|
const __filename = (0, import_url17.fileURLToPath)(import_meta17.url);
|
|
1800
|
-
const __dirname =
|
|
1801
|
-
const srcPath =
|
|
1802
|
-
const folder =
|
|
1803
|
-
const emailFilePath =
|
|
1804
|
-
if (!
|
|
1919
|
+
const __dirname = import_path19.default.dirname(__filename);
|
|
1920
|
+
const srcPath = import_path19.default.join(projectDir, "src");
|
|
1921
|
+
const folder = import_fs19.default.existsSync(srcPath) ? "src" : "";
|
|
1922
|
+
const emailFilePath = import_path19.default.join(projectDir, folder, "lib", "email.ts");
|
|
1923
|
+
if (!import_fs19.default.existsSync(emailFilePath)) {
|
|
1805
1924
|
await email();
|
|
1806
1925
|
}
|
|
1807
|
-
const authFilePath =
|
|
1808
|
-
if (!
|
|
1809
|
-
console.log(
|
|
1926
|
+
const authFilePath = import_path19.default.join(projectDir, folder, "lib", "auth.ts");
|
|
1927
|
+
if (!import_fs19.default.existsSync(authFilePath)) {
|
|
1928
|
+
console.log(import_chalk20.default.red("auth.ts file not found."));
|
|
1810
1929
|
return;
|
|
1811
1930
|
}
|
|
1812
|
-
let content =
|
|
1931
|
+
let content = import_fs19.default.readFileSync(authFilePath, "utf8");
|
|
1813
1932
|
const codeAdded = ` sendResetPassword: async ({ user, url, token }) => {
|
|
1814
1933
|
await sendEmail({
|
|
1815
1934
|
email: user.email!,
|
|
@@ -1853,7 +1972,7 @@ var forgetNext = async () => {
|
|
|
1853
1972
|
content = before + `
|
|
1854
1973
|
${codeAdded}` + after;
|
|
1855
1974
|
}
|
|
1856
|
-
|
|
1975
|
+
import_fs19.default.writeFileSync(authFilePath, content, "utf8");
|
|
1857
1976
|
if (!content.includes("import { sendEmail }")) {
|
|
1858
1977
|
const lastImportIndex = content.lastIndexOf("import");
|
|
1859
1978
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -1863,129 +1982,129 @@ var forgetNext = async () => {
|
|
|
1863
1982
|
import { sendEmail } from "./email";
|
|
1864
1983
|
`;
|
|
1865
1984
|
content = beforeImports + newImports + afterImports;
|
|
1866
|
-
|
|
1985
|
+
import_fs19.default.writeFileSync(authFilePath, content, "utf8");
|
|
1867
1986
|
}
|
|
1868
|
-
const componentPath =
|
|
1987
|
+
const componentPath = import_path19.default.resolve(
|
|
1869
1988
|
__dirname,
|
|
1870
1989
|
"./template/email/reset-password.tsx"
|
|
1871
1990
|
);
|
|
1872
|
-
const destinationPath =
|
|
1991
|
+
const destinationPath = import_path19.default.join(
|
|
1873
1992
|
projectDir,
|
|
1874
1993
|
folder,
|
|
1875
1994
|
"components",
|
|
1876
1995
|
"email"
|
|
1877
1996
|
);
|
|
1878
|
-
if (!
|
|
1879
|
-
|
|
1997
|
+
if (!import_fs19.default.existsSync(destinationPath)) {
|
|
1998
|
+
import_fs19.default.mkdirSync(destinationPath, { recursive: true });
|
|
1880
1999
|
}
|
|
1881
|
-
const emailDestinationPath =
|
|
2000
|
+
const emailDestinationPath = import_path19.default.join(
|
|
1882
2001
|
destinationPath,
|
|
1883
2002
|
"reset-password.tsx"
|
|
1884
2003
|
);
|
|
1885
|
-
if (
|
|
1886
|
-
|
|
2004
|
+
if (import_fs19.default.existsSync(componentPath)) {
|
|
2005
|
+
import_fs19.default.copyFileSync(componentPath, emailDestinationPath);
|
|
1887
2006
|
}
|
|
1888
|
-
const forgetComponentPath =
|
|
2007
|
+
const forgetComponentPath = import_path19.default.resolve(
|
|
1889
2008
|
__dirname,
|
|
1890
2009
|
"./template/components/ForgetComponent.tsx"
|
|
1891
2010
|
);
|
|
1892
|
-
const componentsDestinationPath =
|
|
2011
|
+
const componentsDestinationPath = import_path19.default.join(
|
|
1893
2012
|
projectDir,
|
|
1894
2013
|
folder,
|
|
1895
2014
|
"components",
|
|
1896
2015
|
"authverse"
|
|
1897
2016
|
);
|
|
1898
|
-
if (!
|
|
1899
|
-
|
|
2017
|
+
if (!import_fs19.default.existsSync(componentsDestinationPath)) {
|
|
2018
|
+
import_fs19.default.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
1900
2019
|
}
|
|
1901
|
-
const forgetDestinationPath =
|
|
2020
|
+
const forgetDestinationPath = import_path19.default.join(
|
|
1902
2021
|
componentsDestinationPath,
|
|
1903
2022
|
"ForgetComponent.tsx"
|
|
1904
2023
|
);
|
|
1905
|
-
if (
|
|
1906
|
-
|
|
2024
|
+
if (import_fs19.default.existsSync(forgetComponentPath)) {
|
|
2025
|
+
import_fs19.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
1907
2026
|
}
|
|
1908
|
-
const resetComponentPath =
|
|
2027
|
+
const resetComponentPath = import_path19.default.resolve(
|
|
1909
2028
|
__dirname,
|
|
1910
2029
|
"./template/components/ResetComponent.tsx"
|
|
1911
2030
|
);
|
|
1912
|
-
const resetDestinationPath =
|
|
2031
|
+
const resetDestinationPath = import_path19.default.join(
|
|
1913
2032
|
componentsDestinationPath,
|
|
1914
2033
|
"ResetComponent.tsx"
|
|
1915
2034
|
);
|
|
1916
|
-
if (
|
|
1917
|
-
|
|
2035
|
+
if (import_fs19.default.existsSync(resetComponentPath)) {
|
|
2036
|
+
import_fs19.default.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
1918
2037
|
}
|
|
1919
|
-
const authTemplatePath =
|
|
2038
|
+
const authTemplatePath = import_path19.default.resolve(
|
|
1920
2039
|
__dirname,
|
|
1921
2040
|
"./template/app-auth-uiDesign"
|
|
1922
2041
|
);
|
|
1923
|
-
const appDestinationPath =
|
|
1924
|
-
if (!
|
|
1925
|
-
|
|
2042
|
+
const appDestinationPath = import_path19.default.join(projectDir, folder, "app", "auth");
|
|
2043
|
+
if (!import_fs19.default.existsSync(appDestinationPath)) {
|
|
2044
|
+
import_fs19.default.mkdirSync(appDestinationPath, { recursive: true });
|
|
1926
2045
|
}
|
|
1927
|
-
const forgetDestinationDir =
|
|
1928
|
-
if (!
|
|
1929
|
-
|
|
2046
|
+
const forgetDestinationDir = import_path19.default.join(appDestinationPath, "forget");
|
|
2047
|
+
if (!import_fs19.default.existsSync(forgetDestinationDir)) {
|
|
2048
|
+
import_fs19.default.mkdirSync(forgetDestinationDir, { recursive: true });
|
|
1930
2049
|
}
|
|
1931
|
-
const forgetPageDestinationPath =
|
|
2050
|
+
const forgetPageDestinationPath = import_path19.default.join(
|
|
1932
2051
|
forgetDestinationDir,
|
|
1933
2052
|
"page.tsx"
|
|
1934
2053
|
);
|
|
1935
|
-
|
|
2054
|
+
import_fs19.default.copyFileSync(
|
|
1936
2055
|
`${authTemplatePath}/forget/page.tsx`,
|
|
1937
2056
|
forgetPageDestinationPath
|
|
1938
2057
|
);
|
|
1939
|
-
const resetDestinationDir =
|
|
2058
|
+
const resetDestinationDir = import_path19.default.join(
|
|
1940
2059
|
appDestinationPath,
|
|
1941
2060
|
"reset-password"
|
|
1942
2061
|
);
|
|
1943
|
-
if (!
|
|
1944
|
-
|
|
2062
|
+
if (!import_fs19.default.existsSync(resetDestinationDir)) {
|
|
2063
|
+
import_fs19.default.mkdirSync(resetDestinationDir, { recursive: true });
|
|
1945
2064
|
}
|
|
1946
|
-
const resetPageDestinationPath =
|
|
2065
|
+
const resetPageDestinationPath = import_path19.default.join(
|
|
1947
2066
|
resetDestinationDir,
|
|
1948
2067
|
"page.tsx"
|
|
1949
2068
|
);
|
|
1950
|
-
|
|
2069
|
+
import_fs19.default.copyFileSync(
|
|
1951
2070
|
`${authTemplatePath}/reset-password/page.tsx`,
|
|
1952
2071
|
resetPageDestinationPath
|
|
1953
2072
|
);
|
|
1954
2073
|
console.log(
|
|
1955
|
-
|
|
2074
|
+
import_chalk20.default.green("Successfully added forget and reset-password pages")
|
|
1956
2075
|
);
|
|
1957
2076
|
} else {
|
|
1958
2077
|
console.log(
|
|
1959
|
-
|
|
2078
|
+
import_chalk20.default.red("Could not find emailAndPassword configuration in auth.ts")
|
|
1960
2079
|
);
|
|
1961
2080
|
}
|
|
1962
2081
|
} catch (error) {
|
|
1963
|
-
console.log(
|
|
2082
|
+
console.log(import_chalk20.default.red("Error adding sendResetPassword:"), error);
|
|
1964
2083
|
}
|
|
1965
2084
|
};
|
|
1966
2085
|
|
|
1967
2086
|
// script/forgetTanstack.ts
|
|
1968
|
-
var
|
|
1969
|
-
var
|
|
2087
|
+
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
2088
|
+
var import_path20 = __toESM(require("path"), 1);
|
|
1970
2089
|
var import_url18 = require("url");
|
|
1971
|
-
var
|
|
2090
|
+
var import_fs20 = __toESM(require("fs"), 1);
|
|
1972
2091
|
var import_meta18 = {};
|
|
1973
2092
|
var forgetTanstack = async () => {
|
|
1974
2093
|
try {
|
|
1975
2094
|
const projectDir = process.cwd();
|
|
1976
2095
|
const __filename = (0, import_url18.fileURLToPath)(import_meta18.url);
|
|
1977
|
-
const __dirname =
|
|
1978
|
-
const srcPath =
|
|
1979
|
-
const emailFilePath =
|
|
1980
|
-
if (!
|
|
2096
|
+
const __dirname = import_path20.default.dirname(__filename);
|
|
2097
|
+
const srcPath = import_path20.default.join(projectDir, "src");
|
|
2098
|
+
const emailFilePath = import_path20.default.join(srcPath, "lib", "email.ts");
|
|
2099
|
+
if (!import_fs20.default.existsSync(emailFilePath)) {
|
|
1981
2100
|
await email();
|
|
1982
2101
|
}
|
|
1983
|
-
const authFilePath =
|
|
1984
|
-
if (!
|
|
1985
|
-
console.log(
|
|
2102
|
+
const authFilePath = import_path20.default.join(srcPath, "lib", "auth.ts");
|
|
2103
|
+
if (!import_fs20.default.existsSync(authFilePath)) {
|
|
2104
|
+
console.log(import_chalk21.default.red("auth.ts file not found."));
|
|
1986
2105
|
return;
|
|
1987
2106
|
}
|
|
1988
|
-
let content =
|
|
2107
|
+
let content = import_fs20.default.readFileSync(authFilePath, "utf8");
|
|
1989
2108
|
const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
|
|
1990
2109
|
await sendEmail({
|
|
1991
2110
|
email: user.email!,
|
|
@@ -2029,7 +2148,7 @@ var forgetTanstack = async () => {
|
|
|
2029
2148
|
content = before + `
|
|
2030
2149
|
${codeAdded}` + after;
|
|
2031
2150
|
}
|
|
2032
|
-
|
|
2151
|
+
import_fs20.default.writeFileSync(authFilePath, content, "utf8");
|
|
2033
2152
|
if (!content.includes("import { sendEmail }")) {
|
|
2034
2153
|
const lastImportIndex = content.lastIndexOf("import");
|
|
2035
2154
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -2039,99 +2158,97 @@ var forgetTanstack = async () => {
|
|
|
2039
2158
|
import { sendEmail } from "./email";
|
|
2040
2159
|
`;
|
|
2041
2160
|
content = beforeImports + newImports + afterImports;
|
|
2042
|
-
|
|
2161
|
+
import_fs20.default.writeFileSync(authFilePath, content, "utf8");
|
|
2043
2162
|
}
|
|
2044
|
-
const componentPath =
|
|
2163
|
+
const componentPath = import_path20.default.resolve(
|
|
2045
2164
|
__dirname,
|
|
2046
2165
|
"./template/email/reset-password.tsx"
|
|
2047
2166
|
);
|
|
2048
|
-
const destinationPath =
|
|
2049
|
-
if (!
|
|
2050
|
-
|
|
2167
|
+
const destinationPath = import_path20.default.join(srcPath, "components", "email");
|
|
2168
|
+
if (!import_fs20.default.existsSync(destinationPath)) {
|
|
2169
|
+
import_fs20.default.mkdirSync(destinationPath, { recursive: true });
|
|
2051
2170
|
}
|
|
2052
|
-
const emailDestinationPath =
|
|
2171
|
+
const emailDestinationPath = import_path20.default.join(
|
|
2053
2172
|
destinationPath,
|
|
2054
2173
|
"reset-password.tsx"
|
|
2055
2174
|
);
|
|
2056
|
-
if (
|
|
2057
|
-
|
|
2175
|
+
if (import_fs20.default.existsSync(componentPath)) {
|
|
2176
|
+
import_fs20.default.copyFileSync(componentPath, emailDestinationPath);
|
|
2058
2177
|
}
|
|
2059
|
-
const forgetComponentPath =
|
|
2178
|
+
const forgetComponentPath = import_path20.default.resolve(
|
|
2060
2179
|
__dirname,
|
|
2061
2180
|
"./template/TanstackState/components/ForgetComponent.tsx"
|
|
2062
2181
|
);
|
|
2063
|
-
const componentsDestinationPath =
|
|
2182
|
+
const componentsDestinationPath = import_path20.default.join(
|
|
2064
2183
|
srcPath,
|
|
2065
2184
|
"components",
|
|
2066
2185
|
"authverse"
|
|
2067
2186
|
);
|
|
2068
|
-
if (!
|
|
2069
|
-
|
|
2187
|
+
if (!import_fs20.default.existsSync(componentsDestinationPath)) {
|
|
2188
|
+
import_fs20.default.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
2070
2189
|
}
|
|
2071
|
-
const forgetDestinationPath =
|
|
2190
|
+
const forgetDestinationPath = import_path20.default.join(
|
|
2072
2191
|
componentsDestinationPath,
|
|
2073
2192
|
"ForgetComponent.tsx"
|
|
2074
2193
|
);
|
|
2075
|
-
if (
|
|
2076
|
-
|
|
2194
|
+
if (import_fs20.default.existsSync(forgetComponentPath)) {
|
|
2195
|
+
import_fs20.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
2077
2196
|
}
|
|
2078
|
-
const resetComponentPath =
|
|
2197
|
+
const resetComponentPath = import_path20.default.resolve(
|
|
2079
2198
|
__dirname,
|
|
2080
2199
|
"./template/TanstackState/components/ResetComponent.tsx"
|
|
2081
2200
|
);
|
|
2082
|
-
const resetDestinationPath =
|
|
2201
|
+
const resetDestinationPath = import_path20.default.join(
|
|
2083
2202
|
componentsDestinationPath,
|
|
2084
2203
|
"ResetComponent.tsx"
|
|
2085
2204
|
);
|
|
2086
|
-
if (
|
|
2087
|
-
|
|
2205
|
+
if (import_fs20.default.existsSync(resetComponentPath)) {
|
|
2206
|
+
import_fs20.default.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
2088
2207
|
}
|
|
2089
|
-
const authTemplatePath =
|
|
2208
|
+
const authTemplatePath = import_path20.default.resolve(
|
|
2090
2209
|
__dirname,
|
|
2091
2210
|
"./template/TanstackState/routes/auth"
|
|
2092
2211
|
);
|
|
2093
|
-
const routesDestinationPath =
|
|
2094
|
-
if (!
|
|
2095
|
-
|
|
2212
|
+
const routesDestinationPath = import_path20.default.join(srcPath, "routes", "auth");
|
|
2213
|
+
if (!import_fs20.default.existsSync(routesDestinationPath)) {
|
|
2214
|
+
import_fs20.default.mkdirSync(routesDestinationPath, { recursive: true });
|
|
2096
2215
|
}
|
|
2097
|
-
const forgetPageDestinationPath =
|
|
2216
|
+
const forgetPageDestinationPath = import_path20.default.join(
|
|
2098
2217
|
routesDestinationPath,
|
|
2099
2218
|
"forget.tsx"
|
|
2100
2219
|
);
|
|
2101
|
-
|
|
2220
|
+
import_fs20.default.copyFileSync(
|
|
2102
2221
|
`${authTemplatePath}/forget.tsx`,
|
|
2103
2222
|
forgetPageDestinationPath
|
|
2104
2223
|
);
|
|
2105
|
-
const resetPageDestinationPath =
|
|
2224
|
+
const resetPageDestinationPath = import_path20.default.join(
|
|
2106
2225
|
routesDestinationPath,
|
|
2107
2226
|
"reset-password.tsx"
|
|
2108
2227
|
);
|
|
2109
|
-
|
|
2228
|
+
import_fs20.default.copyFileSync(
|
|
2110
2229
|
`${authTemplatePath}/reset-password.tsx`,
|
|
2111
2230
|
resetPageDestinationPath
|
|
2112
2231
|
);
|
|
2113
2232
|
console.log(
|
|
2114
|
-
|
|
2233
|
+
import_chalk21.default.green("Successfully added forget and reset-password pages")
|
|
2115
2234
|
);
|
|
2116
2235
|
} else {
|
|
2117
2236
|
console.log(
|
|
2118
|
-
|
|
2237
|
+
import_chalk21.default.red("Could not find emailAndPassword configuration in auth.ts")
|
|
2119
2238
|
);
|
|
2120
2239
|
}
|
|
2121
2240
|
} catch (error) {
|
|
2122
|
-
console.log(
|
|
2241
|
+
console.log(import_chalk21.default.red("Error adding sendResetPassword:"), error);
|
|
2123
2242
|
}
|
|
2124
2243
|
};
|
|
2125
2244
|
|
|
2126
2245
|
// cli/forget.ts
|
|
2127
|
-
var
|
|
2128
|
-
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
2134
|
-
framework = hasNext ? "Next js" : "tanstack state";
|
|
2246
|
+
var import_chalk22 = __toESM(require("chalk"), 1);
|
|
2247
|
+
var forget = async () => {
|
|
2248
|
+
const { framework, error } = await getFramework();
|
|
2249
|
+
if (error) {
|
|
2250
|
+
console.log(import_chalk22.default.red(error));
|
|
2251
|
+
return;
|
|
2135
2252
|
}
|
|
2136
2253
|
if (framework === "Next js") {
|
|
2137
2254
|
return forgetNext();
|
|
@@ -2142,33 +2259,31 @@ var forget = () => {
|
|
|
2142
2259
|
};
|
|
2143
2260
|
|
|
2144
2261
|
// cli/verification.ts
|
|
2145
|
-
var
|
|
2146
|
-
var import_fs25 = __toESM(require("fs"), 1);
|
|
2147
|
-
var import_path25 = __toESM(require("path"), 1);
|
|
2262
|
+
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
2148
2263
|
|
|
2149
2264
|
// script/verifyNext.ts
|
|
2150
|
-
var
|
|
2151
|
-
var
|
|
2152
|
-
var
|
|
2265
|
+
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
2266
|
+
var import_fs21 = __toESM(require("fs"), 1);
|
|
2267
|
+
var import_path21 = __toESM(require("path"), 1);
|
|
2153
2268
|
var import_url19 = require("url");
|
|
2154
2269
|
var import_meta19 = {};
|
|
2155
2270
|
var verifyNext = async () => {
|
|
2156
2271
|
try {
|
|
2157
2272
|
const projectDir = process.cwd();
|
|
2158
2273
|
const __filename = (0, import_url19.fileURLToPath)(import_meta19.url);
|
|
2159
|
-
const __dirname =
|
|
2160
|
-
const srcPath =
|
|
2161
|
-
const folder =
|
|
2162
|
-
const emailFilePath =
|
|
2163
|
-
if (!
|
|
2274
|
+
const __dirname = import_path21.default.dirname(__filename);
|
|
2275
|
+
const srcPath = import_path21.default.join(projectDir, "src");
|
|
2276
|
+
const folder = import_fs21.default.existsSync(srcPath) ? "src" : "";
|
|
2277
|
+
const emailFilePath = import_path21.default.join(projectDir, folder, "lib", "email.ts");
|
|
2278
|
+
if (!import_fs21.default.existsSync(emailFilePath)) {
|
|
2164
2279
|
await email();
|
|
2165
2280
|
}
|
|
2166
|
-
const authFilePath =
|
|
2167
|
-
if (!
|
|
2168
|
-
console.log(
|
|
2281
|
+
const authFilePath = import_path21.default.join(projectDir, folder, "lib", "auth.ts");
|
|
2282
|
+
if (!import_fs21.default.existsSync(authFilePath)) {
|
|
2283
|
+
console.log(import_chalk23.default.red("auth.ts file not found."));
|
|
2169
2284
|
return;
|
|
2170
2285
|
}
|
|
2171
|
-
let content =
|
|
2286
|
+
let content = import_fs21.default.readFileSync(authFilePath, "utf8");
|
|
2172
2287
|
if (content.includes("emailAndPassword: {")) {
|
|
2173
2288
|
const start = content.indexOf("emailAndPassword: {");
|
|
2174
2289
|
let end = start;
|
|
@@ -2228,47 +2343,47 @@ var verifyNext = async () => {
|
|
|
2228
2343
|
`;
|
|
2229
2344
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2230
2345
|
}
|
|
2231
|
-
|
|
2232
|
-
const templatePath =
|
|
2346
|
+
import_fs21.default.writeFileSync(authFilePath, content, "utf8");
|
|
2347
|
+
const templatePath = import_path21.default.resolve(
|
|
2233
2348
|
__dirname,
|
|
2234
2349
|
"./template/email/EmailVerification.tsx"
|
|
2235
2350
|
);
|
|
2236
|
-
const componentsDir =
|
|
2237
|
-
if (!
|
|
2238
|
-
|
|
2351
|
+
const componentsDir = import_path21.default.join(projectDir, folder, "components", "email");
|
|
2352
|
+
if (!import_fs21.default.existsSync(componentsDir)) {
|
|
2353
|
+
import_fs21.default.mkdirSync(componentsDir, { recursive: true });
|
|
2239
2354
|
}
|
|
2240
|
-
const destFile =
|
|
2241
|
-
if (
|
|
2242
|
-
|
|
2355
|
+
const destFile = import_path21.default.join(componentsDir, "EmailVerification.tsx");
|
|
2356
|
+
if (import_fs21.default.existsSync(templatePath) && !import_fs21.default.existsSync(destFile)) {
|
|
2357
|
+
import_fs21.default.copyFileSync(templatePath, destFile);
|
|
2243
2358
|
}
|
|
2244
|
-
console.log(
|
|
2359
|
+
console.log(import_chalk23.default.green("Email verification successfully configured"));
|
|
2245
2360
|
} catch (error) {
|
|
2246
|
-
console.log(
|
|
2361
|
+
console.log(import_chalk23.default.red(String(error)));
|
|
2247
2362
|
}
|
|
2248
2363
|
};
|
|
2249
2364
|
|
|
2250
2365
|
// script/verifyTanstack.ts
|
|
2251
|
-
var
|
|
2252
|
-
var
|
|
2253
|
-
var
|
|
2366
|
+
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
2367
|
+
var import_fs22 = __toESM(require("fs"), 1);
|
|
2368
|
+
var import_path22 = __toESM(require("path"), 1);
|
|
2254
2369
|
var import_url20 = require("url");
|
|
2255
2370
|
var import_meta20 = {};
|
|
2256
2371
|
var verifyTanstack = async () => {
|
|
2257
2372
|
try {
|
|
2258
2373
|
const projectDir = process.cwd();
|
|
2259
2374
|
const __filename = (0, import_url20.fileURLToPath)(import_meta20.url);
|
|
2260
|
-
const __dirname =
|
|
2261
|
-
const srcPath =
|
|
2262
|
-
const emailFilePath =
|
|
2263
|
-
if (!
|
|
2375
|
+
const __dirname = import_path22.default.dirname(__filename);
|
|
2376
|
+
const srcPath = import_path22.default.join(projectDir, "src");
|
|
2377
|
+
const emailFilePath = import_path22.default.join(srcPath, "lib", "email.ts");
|
|
2378
|
+
if (!import_fs22.default.existsSync(emailFilePath)) {
|
|
2264
2379
|
await email();
|
|
2265
2380
|
}
|
|
2266
|
-
const authFilePath =
|
|
2267
|
-
if (!
|
|
2268
|
-
console.log(
|
|
2381
|
+
const authFilePath = import_path22.default.join(srcPath, "lib", "auth.ts");
|
|
2382
|
+
if (!import_fs22.default.existsSync(authFilePath)) {
|
|
2383
|
+
console.log(import_chalk24.default.red("auth.ts file not found."));
|
|
2269
2384
|
return;
|
|
2270
2385
|
}
|
|
2271
|
-
let content =
|
|
2386
|
+
let content = import_fs22.default.readFileSync(authFilePath, "utf8");
|
|
2272
2387
|
if (content.includes("emailAndPassword: {")) {
|
|
2273
2388
|
const start = content.indexOf("emailAndPassword: {");
|
|
2274
2389
|
let end = start;
|
|
@@ -2328,35 +2443,32 @@ var verifyTanstack = async () => {
|
|
|
2328
2443
|
`;
|
|
2329
2444
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2330
2445
|
}
|
|
2331
|
-
|
|
2332
|
-
const templatePath =
|
|
2446
|
+
import_fs22.default.writeFileSync(authFilePath, content, "utf8");
|
|
2447
|
+
const templatePath = import_path22.default.resolve(
|
|
2333
2448
|
__dirname,
|
|
2334
2449
|
"./template/email/EmailVerification.tsx"
|
|
2335
2450
|
);
|
|
2336
|
-
const componentsDir =
|
|
2337
|
-
if (!
|
|
2338
|
-
|
|
2451
|
+
const componentsDir = import_path22.default.join(srcPath, "components", "email");
|
|
2452
|
+
if (!import_fs22.default.existsSync(componentsDir)) {
|
|
2453
|
+
import_fs22.default.mkdirSync(componentsDir, { recursive: true });
|
|
2339
2454
|
}
|
|
2340
|
-
const destFile =
|
|
2341
|
-
if (
|
|
2342
|
-
|
|
2455
|
+
const destFile = import_path22.default.join(componentsDir, "EmailVerification.tsx");
|
|
2456
|
+
if (import_fs22.default.existsSync(templatePath) && !import_fs22.default.existsSync(destFile)) {
|
|
2457
|
+
import_fs22.default.copyFileSync(templatePath, destFile);
|
|
2343
2458
|
}
|
|
2344
|
-
console.log(
|
|
2459
|
+
console.log(import_chalk24.default.green("Email verification successfully configured"));
|
|
2345
2460
|
} catch (error) {
|
|
2346
|
-
console.log(
|
|
2461
|
+
console.log(import_chalk24.default.red(String(error)));
|
|
2347
2462
|
}
|
|
2348
2463
|
};
|
|
2349
2464
|
|
|
2350
2465
|
// cli/verification.ts
|
|
2351
2466
|
var verification = async () => {
|
|
2352
2467
|
try {
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
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";
|
|
2468
|
+
const { framework, error } = await getFramework();
|
|
2469
|
+
if (error) {
|
|
2470
|
+
console.log(import_chalk25.default.red(error));
|
|
2471
|
+
return;
|
|
2360
2472
|
}
|
|
2361
2473
|
if (framework === "Next js") {
|
|
2362
2474
|
await verifyNext();
|
|
@@ -2365,23 +2477,75 @@ var verification = async () => {
|
|
|
2365
2477
|
await verifyTanstack();
|
|
2366
2478
|
}
|
|
2367
2479
|
} catch (error) {
|
|
2368
|
-
console.log(
|
|
2480
|
+
console.log(import_chalk25.default.red(error.message));
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
// cli/initCmd.ts
|
|
2485
|
+
var import_chalk26 = __toESM(require("chalk"), 1);
|
|
2486
|
+
var initCmd = async (cmd) => {
|
|
2487
|
+
try {
|
|
2488
|
+
const { framework, error } = await getFramework();
|
|
2489
|
+
if (error) {
|
|
2490
|
+
console.log(import_chalk26.default.red(error));
|
|
2491
|
+
return;
|
|
2492
|
+
}
|
|
2493
|
+
if (framework === "Next js" && cmd.orm === "prisma") {
|
|
2494
|
+
await prismaRun({
|
|
2495
|
+
database: cmd.db,
|
|
2496
|
+
authUi: cmd.authUi === "yes" ? true : false,
|
|
2497
|
+
cmd: true
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
if (framework === "Next js" && cmd.orm === "drizzle") {
|
|
2501
|
+
await drizzleRun({
|
|
2502
|
+
authUi: cmd.authUi === "yes" ? true : false,
|
|
2503
|
+
cmd: true
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
if (framework === "tanstack state" && cmd.orm === "prisma") {
|
|
2507
|
+
await prismaRunTanstackState({
|
|
2508
|
+
authUi: cmd.authUi === "yes" ? true : false,
|
|
2509
|
+
database: cmd.db,
|
|
2510
|
+
cmd: true
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
if (framework === "tanstack state" && cmd.orm === "drizzle") {
|
|
2514
|
+
await drizzleRunTanstackState({
|
|
2515
|
+
authUi: cmd.authUi === "yes" ? true : false,
|
|
2516
|
+
cmd: true
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
} catch (error) {
|
|
2520
|
+
console.log(import_chalk26.default.red(error));
|
|
2369
2521
|
}
|
|
2370
2522
|
};
|
|
2371
2523
|
|
|
2372
2524
|
// index.ts
|
|
2373
|
-
var packageJson = JSON.parse((0,
|
|
2525
|
+
var packageJson = JSON.parse((0, import_fs23.readFileSync)("./package.json", "utf8"));
|
|
2374
2526
|
var program = new import_commander.Command();
|
|
2375
2527
|
program.name("authverse").description("CLI tool for creating authverse projects").version(
|
|
2376
2528
|
packageJson.version || "1.0.0",
|
|
2377
2529
|
"-v, --version",
|
|
2378
2530
|
"display the version number"
|
|
2379
2531
|
);
|
|
2380
|
-
program.command("init").description("Select project template and configuration").action(async () => {
|
|
2381
|
-
|
|
2532
|
+
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) => {
|
|
2533
|
+
if (!cmd.orm || !cmd.db || !cmd.authUi) {
|
|
2534
|
+
await initAnswer();
|
|
2535
|
+
} else {
|
|
2536
|
+
await initCmd(cmd);
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
program.command("add <oauth>").description("Add a new authentication provider").action(async (oauth) => {
|
|
2540
|
+
await Oauth({ oauth });
|
|
2541
|
+
});
|
|
2542
|
+
program.command("forget").description("Forget stored configurations").action(async () => {
|
|
2543
|
+
await forget();
|
|
2544
|
+
});
|
|
2545
|
+
program.command("email").description("Configure email settings").action(async () => {
|
|
2546
|
+
await email();
|
|
2547
|
+
});
|
|
2548
|
+
program.command("verify").description("Verify authentication setup").action(async () => {
|
|
2549
|
+
await verification();
|
|
2382
2550
|
});
|
|
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
2551
|
program.parse(process.argv);
|