authverse 1.1.3 → 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/README.md +0 -1
- package/dist/index.cjs +595 -445
- package/dist/index.js +588 -438
- package/dist/template/TanstackState/components/LoginComponent.tsx +0 -1
- package/dist/template/components/LoginComponent.tsx +18 -15
- package/dist/template/components/SingUpComponent.tsx +20 -20
- package/package.json +7 -13
- package/dist/template/components/Logout.tsx +0 -21
- package/dist/template/server/user.ts +0 -49
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,
|
|
@@ -119,8 +152,6 @@ var authUiRun = async ({ folder }) => {
|
|
|
119
152
|
`${componentPath}/SingUpComponent.tsx`,
|
|
120
153
|
SignUpDestinationPath
|
|
121
154
|
);
|
|
122
|
-
const LogoutDestinationPath = import_path.default.join(destinationPath, "Logout.tsx");
|
|
123
|
-
import_fs.default.copyFileSync(`${componentPath}/Logout.tsx`, LogoutDestinationPath);
|
|
124
155
|
const authTemplatePath = import_path.default.resolve(
|
|
125
156
|
__dirname,
|
|
126
157
|
"./template/app-auth-uiDesign"
|
|
@@ -176,14 +207,14 @@ ${layoutContent}`;
|
|
|
176
207
|
// script/prisma.ts
|
|
177
208
|
var import_inquirer = __toESM(require("inquirer"), 1);
|
|
178
209
|
var import_meta2 = {};
|
|
179
|
-
var prismaRun = async ({ authUi, database }) => {
|
|
210
|
+
var prismaRun = async ({ authUi, database, cmd }) => {
|
|
180
211
|
try {
|
|
181
212
|
const projectDir = process.cwd();
|
|
182
213
|
const __filename = (0, import_url2.fileURLToPath)(import_meta2.url);
|
|
183
214
|
const __dirname = import_path2.default.dirname(__filename);
|
|
184
215
|
const packageJsonPath = import_path2.default.join(projectDir, "package.json");
|
|
185
216
|
const packageJson2 = JSON.parse(import_fs2.default.readFileSync(packageJsonPath, "utf-8"));
|
|
186
|
-
if (!packageJson2.devDependencies?.prisma
|
|
217
|
+
if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
|
|
187
218
|
console.log(import_chalk2.default.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
|
|
188
219
|
if (database !== "Mongodb") {
|
|
189
220
|
packageManager("prisma", true);
|
|
@@ -223,7 +254,7 @@ var prismaRun = async ({ authUi, database }) => {
|
|
|
223
254
|
} else {
|
|
224
255
|
const schemaPath = import_path2.default.join(prismaDir, "schema.prisma");
|
|
225
256
|
const schemaContent = import_fs2.default.readFileSync(schemaPath, "utf-8");
|
|
226
|
-
if (!schemaContent.includes("User")
|
|
257
|
+
if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
|
|
227
258
|
const templatePath = import_path2.default.resolve(
|
|
228
259
|
__dirname,
|
|
229
260
|
`./template/prisma/${database}/schema.prisma_copy`
|
|
@@ -256,16 +287,48 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
256
287
|
}
|
|
257
288
|
const authPath = import_path2.default.join(libPath, "auth.ts");
|
|
258
289
|
const authClientPath = import_path2.default.join(libPath, "auth-client.ts");
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
}
|
|
266
330
|
}
|
|
267
|
-
|
|
268
|
-
if (answers.overwrite) {
|
|
331
|
+
} else {
|
|
269
332
|
const authTemplatePath = import_path2.default.resolve(
|
|
270
333
|
__dirname,
|
|
271
334
|
`./template/lib/${database}/auth.ts`
|
|
@@ -290,41 +353,7 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
290
353
|
);
|
|
291
354
|
}
|
|
292
355
|
}
|
|
293
|
-
} else {
|
|
294
|
-
const authTemplatePath = import_path2.default.resolve(
|
|
295
|
-
__dirname,
|
|
296
|
-
`./template/lib/${database}/auth.ts`
|
|
297
|
-
);
|
|
298
|
-
const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
|
|
299
|
-
import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
|
|
300
|
-
const authClientTemplatePath = import_path2.default.resolve(
|
|
301
|
-
__dirname,
|
|
302
|
-
"./template/lib/auth-client.ts"
|
|
303
|
-
);
|
|
304
|
-
const authClientDestinationPath = import_path2.default.join(libPath, "auth-client.ts");
|
|
305
|
-
import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
306
|
-
if (srcFolder === "src") {
|
|
307
|
-
const authContextPath = import_path2.default.join(libPath, "auth.ts");
|
|
308
|
-
const authContextContent = import_fs2.default.readFileSync(authContextPath, "utf-8");
|
|
309
|
-
import_fs2.default.writeFileSync(
|
|
310
|
-
authContextPath,
|
|
311
|
-
authContextContent.replace(
|
|
312
|
-
'import { PrismaClient } from "@/generated/prisma/client";',
|
|
313
|
-
'import { PrismaClient } from "../../generated/prisma/client";'
|
|
314
|
-
)
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
const serverPath = import_path2.default.join(projectDir, srcFolder, "server");
|
|
319
|
-
if (!import_fs2.default.existsSync(serverPath)) {
|
|
320
|
-
import_fs2.default.mkdirSync(serverPath, { recursive: true });
|
|
321
356
|
}
|
|
322
|
-
const userTemplatePath = import_path2.default.resolve(
|
|
323
|
-
__dirname,
|
|
324
|
-
"./template/server/user.ts"
|
|
325
|
-
);
|
|
326
|
-
const userDestinationPath = import_path2.default.join(serverPath, "user.ts");
|
|
327
|
-
import_fs2.default.copyFileSync(userTemplatePath, userDestinationPath);
|
|
328
357
|
const routeTemplatePath = import_path2.default.resolve(
|
|
329
358
|
__dirname,
|
|
330
359
|
"./template/api/route.ts"
|
|
@@ -363,7 +392,11 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
363
392
|
);
|
|
364
393
|
}
|
|
365
394
|
if (authUi) {
|
|
366
|
-
await authUiRun({
|
|
395
|
+
await authUiRun({
|
|
396
|
+
folder: srcFolder,
|
|
397
|
+
packageJson: packageJson2,
|
|
398
|
+
cmd
|
|
399
|
+
});
|
|
367
400
|
} else {
|
|
368
401
|
console.log(
|
|
369
402
|
import_chalk2.default.green(
|
|
@@ -383,7 +416,7 @@ var import_url3 = require("url");
|
|
|
383
416
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
384
417
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
385
418
|
var import_meta3 = {};
|
|
386
|
-
var drizzleRun = async (authUi) => {
|
|
419
|
+
var drizzleRun = async ({ authUi, cmd }) => {
|
|
387
420
|
try {
|
|
388
421
|
const projectDir = process.cwd();
|
|
389
422
|
const packageJsonPath = import_path3.default.join(projectDir, "package.json");
|
|
@@ -506,16 +539,6 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
506
539
|
);
|
|
507
540
|
import_fs3.default.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
|
|
508
541
|
}
|
|
509
|
-
const serverPath = import_path3.default.join(projectDir, srcFolder, "server");
|
|
510
|
-
if (!import_fs3.default.existsSync(serverPath)) {
|
|
511
|
-
import_fs3.default.mkdirSync(serverPath, { recursive: true });
|
|
512
|
-
}
|
|
513
|
-
const userTemplatePath = import_path3.default.resolve(
|
|
514
|
-
__dirname,
|
|
515
|
-
"./template/server/user.ts"
|
|
516
|
-
);
|
|
517
|
-
const userDestinationPath = import_path3.default.join(serverPath, "user.ts");
|
|
518
|
-
import_fs3.default.copyFileSync(userTemplatePath, userDestinationPath);
|
|
519
542
|
const routeTemplatePath = import_path3.default.resolve(
|
|
520
543
|
__dirname,
|
|
521
544
|
"./template/api/route.ts"
|
|
@@ -541,7 +564,11 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
541
564
|
const proxyDestinationPath = import_path3.default.join(proxyDestinationDir, "proxy.ts");
|
|
542
565
|
import_fs3.default.copyFileSync(proxyTemplatePath, proxyDestinationPath);
|
|
543
566
|
if (authUi) {
|
|
544
|
-
await authUiRun({
|
|
567
|
+
await authUiRun({
|
|
568
|
+
folder: srcFolder,
|
|
569
|
+
packageJson: packageJson2,
|
|
570
|
+
cmd
|
|
571
|
+
});
|
|
545
572
|
} else {
|
|
546
573
|
console.log(
|
|
547
574
|
import_chalk3.default.green(
|
|
@@ -554,10 +581,6 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
554
581
|
}
|
|
555
582
|
};
|
|
556
583
|
|
|
557
|
-
// cli/init.ts
|
|
558
|
-
var import_path7 = __toESM(require("path"), 1);
|
|
559
|
-
var import_fs7 = __toESM(require("fs"), 1);
|
|
560
|
-
|
|
561
584
|
// script/prismaRunTanstackState.ts
|
|
562
585
|
var import_chalk5 = __toESM(require("chalk"), 1);
|
|
563
586
|
var import_path5 = __toESM(require("path"), 1);
|
|
@@ -570,14 +593,46 @@ var import_url4 = require("url");
|
|
|
570
593
|
var import_path4 = __toESM(require("path"), 1);
|
|
571
594
|
var import_fs4 = __toESM(require("fs"), 1);
|
|
572
595
|
var import_meta4 = {};
|
|
573
|
-
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
|
+
}) => {
|
|
574
609
|
try {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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
|
+
}
|
|
578
634
|
const __filename = (0, import_url4.fileURLToPath)(import_meta4.url);
|
|
579
635
|
const __dirname = import_path4.default.dirname(__filename);
|
|
580
|
-
const projectDir = process.cwd();
|
|
581
636
|
const srcPath = import_path4.default.join(projectDir, "src");
|
|
582
637
|
const componentPath = import_path4.default.resolve(
|
|
583
638
|
__dirname,
|
|
@@ -640,7 +695,8 @@ ${rootContent}`;
|
|
|
640
695
|
var import_meta5 = {};
|
|
641
696
|
var prismaRunTanstackState = async ({
|
|
642
697
|
authUi,
|
|
643
|
-
database
|
|
698
|
+
database,
|
|
699
|
+
cmd
|
|
644
700
|
}) => {
|
|
645
701
|
try {
|
|
646
702
|
const projectDir = process.cwd();
|
|
@@ -648,7 +704,7 @@ var prismaRunTanstackState = async ({
|
|
|
648
704
|
const __dirname = import_path5.default.dirname(__filename);
|
|
649
705
|
const packageJsonPath = import_path5.default.join(projectDir, "package.json");
|
|
650
706
|
const packageJson2 = JSON.parse(import_fs5.default.readFileSync(packageJsonPath, "utf-8"));
|
|
651
|
-
if (!packageJson2.devDependencies?.prisma
|
|
707
|
+
if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
|
|
652
708
|
console.log(import_chalk5.default.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
|
|
653
709
|
if (database !== "Mongodb") {
|
|
654
710
|
packageManager("prisma", true);
|
|
@@ -688,7 +744,7 @@ var prismaRunTanstackState = async ({
|
|
|
688
744
|
} else {
|
|
689
745
|
const schemaPath = import_path5.default.join(prismaDir, "schema.prisma");
|
|
690
746
|
const schemaContent = import_fs5.default.readFileSync(schemaPath, "utf-8");
|
|
691
|
-
if (!schemaContent.includes("User")
|
|
747
|
+
if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
|
|
692
748
|
const templatePath = import_path5.default.resolve(
|
|
693
749
|
__dirname,
|
|
694
750
|
`./template/prisma/${database}/schema.prisma_copy`
|
|
@@ -757,7 +813,10 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
757
813
|
const apiDestinationPath = import_path5.default.join(fileRouteDestinationPath, "$.ts");
|
|
758
814
|
import_fs5.default.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
|
|
759
815
|
if (authUi) {
|
|
760
|
-
await authUiTanstackState(
|
|
816
|
+
await authUiTanstackState({
|
|
817
|
+
packageJson: packageJson2,
|
|
818
|
+
cmd
|
|
819
|
+
});
|
|
761
820
|
} else {
|
|
762
821
|
console.log(
|
|
763
822
|
import_chalk5.default.green(
|
|
@@ -776,7 +835,10 @@ var import_path6 = __toESM(require("path"), 1);
|
|
|
776
835
|
var import_fs6 = __toESM(require("fs"), 1);
|
|
777
836
|
var import_url6 = require("url");
|
|
778
837
|
var import_meta6 = {};
|
|
779
|
-
var drizzleRunTanstackState = async (
|
|
838
|
+
var drizzleRunTanstackState = async ({
|
|
839
|
+
authUi,
|
|
840
|
+
cmd
|
|
841
|
+
}) => {
|
|
780
842
|
try {
|
|
781
843
|
const projectDir = process.cwd();
|
|
782
844
|
const packageJsonPath = import_path6.default.join(projectDir, "package.json");
|
|
@@ -869,7 +931,10 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
869
931
|
const apiDestinationPath = import_path6.default.join(fileRouteDestinationPath, "$.ts");
|
|
870
932
|
import_fs6.default.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
|
|
871
933
|
if (authUi) {
|
|
872
|
-
await authUiTanstackState(
|
|
934
|
+
await authUiTanstackState({
|
|
935
|
+
packageJson: packageJson2,
|
|
936
|
+
cmd
|
|
937
|
+
});
|
|
873
938
|
} else {
|
|
874
939
|
console.log(
|
|
875
940
|
import_chalk6.default.green(
|
|
@@ -882,15 +947,47 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
882
947
|
}
|
|
883
948
|
};
|
|
884
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
|
+
|
|
885
984
|
// cli/init.ts
|
|
985
|
+
var import_chalk7 = __toESM(require("chalk"), 1);
|
|
886
986
|
var initAnswer = async () => {
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const packageJson2 = JSON.parse(import_fs7.default.readFileSync(packageJsonPath, "utf-8"));
|
|
892
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
893
|
-
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;
|
|
894
991
|
}
|
|
895
992
|
console.log(`\u2714 Detected framework: ${framework}`);
|
|
896
993
|
const answers = await import_inquirer3.default.prompt([
|
|
@@ -917,31 +1014,39 @@ var initAnswer = async () => {
|
|
|
917
1014
|
if (framework === "Next js" && answers.orm === "Prisma") {
|
|
918
1015
|
await prismaRun({
|
|
919
1016
|
authUi: answers.authUi,
|
|
920
|
-
database: answers.database
|
|
1017
|
+
database: answers.database,
|
|
1018
|
+
cmd: false
|
|
921
1019
|
});
|
|
922
1020
|
}
|
|
923
1021
|
if (framework === "Next js" && answers.orm === "Drizzle") {
|
|
924
|
-
await drizzleRun(
|
|
1022
|
+
await drizzleRun({
|
|
1023
|
+
authUi: answers.authUi,
|
|
1024
|
+
cmd: false
|
|
1025
|
+
});
|
|
925
1026
|
}
|
|
926
1027
|
if (framework === "tanstack state" && answers.orm === "Prisma") {
|
|
927
1028
|
await prismaRunTanstackState({
|
|
928
1029
|
authUi: answers.authUi,
|
|
929
|
-
database: answers.database
|
|
1030
|
+
database: answers.database,
|
|
1031
|
+
cmd: false
|
|
930
1032
|
});
|
|
931
1033
|
}
|
|
932
1034
|
if (framework === "tanstack state" && answers.orm === "Drizzle") {
|
|
933
|
-
await drizzleRunTanstackState(
|
|
1035
|
+
await drizzleRunTanstackState({
|
|
1036
|
+
authUi: answers.authUi,
|
|
1037
|
+
cmd: false
|
|
1038
|
+
});
|
|
934
1039
|
}
|
|
935
1040
|
};
|
|
936
1041
|
|
|
937
1042
|
// index.ts
|
|
938
|
-
var
|
|
1043
|
+
var import_fs23 = require("fs");
|
|
939
1044
|
|
|
940
1045
|
// cli/provider.ts
|
|
941
|
-
var
|
|
1046
|
+
var import_chalk12 = __toESM(require("chalk"), 1);
|
|
942
1047
|
|
|
943
1048
|
// script/googleRun.ts
|
|
944
|
-
var
|
|
1049
|
+
var import_chalk8 = __toESM(require("chalk"), 1);
|
|
945
1050
|
var import_fs8 = __toESM(require("fs"), 1);
|
|
946
1051
|
var import_path8 = __toESM(require("path"), 1);
|
|
947
1052
|
var import_url7 = require("url");
|
|
@@ -955,16 +1060,16 @@ var googleRun = async () => {
|
|
|
955
1060
|
const folder = import_fs8.default.existsSync(srcPath) ? "src" : "";
|
|
956
1061
|
const authFilePath = import_path8.default.join(projectDir, folder, "lib", "auth.ts");
|
|
957
1062
|
if (!import_fs8.default.existsSync(authFilePath)) {
|
|
958
|
-
console.log(
|
|
1063
|
+
console.log(import_chalk8.default.red("\u274C auth.ts file not found"));
|
|
959
1064
|
return;
|
|
960
1065
|
}
|
|
961
1066
|
let content = import_fs8.default.readFileSync(authFilePath, "utf8");
|
|
962
1067
|
if (!content.includes("betterAuth({")) {
|
|
963
|
-
console.log(
|
|
1068
|
+
console.log(import_chalk8.default.red("betterAuth({}) block not found"));
|
|
964
1069
|
return;
|
|
965
1070
|
}
|
|
966
1071
|
if (content.includes("socialProviders") && content.includes("google:")) {
|
|
967
|
-
console.log(
|
|
1072
|
+
console.log(import_chalk8.default.yellow("Google provider already exists"));
|
|
968
1073
|
return;
|
|
969
1074
|
}
|
|
970
1075
|
const googleProviderEntry = `
|
|
@@ -987,7 +1092,7 @@ var googleRun = async () => {
|
|
|
987
1092
|
}
|
|
988
1093
|
}
|
|
989
1094
|
if (insertPos === -1) {
|
|
990
|
-
console.log(
|
|
1095
|
+
console.log(import_chalk8.default.red("Failed to parse socialProviders block"));
|
|
991
1096
|
return;
|
|
992
1097
|
}
|
|
993
1098
|
content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -995,7 +1100,7 @@ var googleRun = async () => {
|
|
|
995
1100
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
996
1101
|
if (!databaseRegex.test(content)) {
|
|
997
1102
|
console.log(
|
|
998
|
-
|
|
1103
|
+
import_chalk8.default.red(
|
|
999
1104
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1000
1105
|
)
|
|
1001
1106
|
);
|
|
@@ -1044,14 +1149,14 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1044
1149
|
if (import_fs8.default.existsSync(componentTemplate)) {
|
|
1045
1150
|
import_fs8.default.copyFileSync(componentTemplate, componentDest);
|
|
1046
1151
|
}
|
|
1047
|
-
console.log(
|
|
1152
|
+
console.log(import_chalk8.default.green("Google provider added & merged successfully"));
|
|
1048
1153
|
} catch (error) {
|
|
1049
|
-
console.log(
|
|
1154
|
+
console.log(import_chalk8.default.red("googleRun error:"), error);
|
|
1050
1155
|
}
|
|
1051
1156
|
};
|
|
1052
1157
|
|
|
1053
1158
|
// script/githubRun.ts
|
|
1054
|
-
var
|
|
1159
|
+
var import_chalk9 = __toESM(require("chalk"), 1);
|
|
1055
1160
|
var import_fs9 = __toESM(require("fs"), 1);
|
|
1056
1161
|
var import_path9 = __toESM(require("path"), 1);
|
|
1057
1162
|
var import_url8 = require("url");
|
|
@@ -1065,16 +1170,16 @@ var githubRun = async () => {
|
|
|
1065
1170
|
const folder = import_fs9.default.existsSync(srcPath) ? "src" : "";
|
|
1066
1171
|
const authFilePath = import_path9.default.join(projectDir, folder, "lib", "auth.ts");
|
|
1067
1172
|
if (!import_fs9.default.existsSync(authFilePath)) {
|
|
1068
|
-
console.log(
|
|
1173
|
+
console.log(import_chalk9.default.red("auth.ts file not found"));
|
|
1069
1174
|
return;
|
|
1070
1175
|
}
|
|
1071
1176
|
let content = import_fs9.default.readFileSync(authFilePath, "utf8");
|
|
1072
1177
|
if (!content.includes("betterAuth({")) {
|
|
1073
|
-
console.log(
|
|
1178
|
+
console.log(import_chalk9.default.red("betterAuth({}) block not found"));
|
|
1074
1179
|
return;
|
|
1075
1180
|
}
|
|
1076
1181
|
if (content.includes("socialProviders") && content.includes("github:")) {
|
|
1077
|
-
console.log(
|
|
1182
|
+
console.log(import_chalk9.default.yellow("GitHub provider already exists"));
|
|
1078
1183
|
return;
|
|
1079
1184
|
}
|
|
1080
1185
|
const githubProviderEntry = `
|
|
@@ -1097,7 +1202,7 @@ var githubRun = async () => {
|
|
|
1097
1202
|
}
|
|
1098
1203
|
}
|
|
1099
1204
|
if (insertPos === -1) {
|
|
1100
|
-
console.log(
|
|
1205
|
+
console.log(import_chalk9.default.red("Failed to parse socialProviders block"));
|
|
1101
1206
|
return;
|
|
1102
1207
|
}
|
|
1103
1208
|
content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1105,7 +1210,7 @@ var githubRun = async () => {
|
|
|
1105
1210
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1106
1211
|
if (!databaseRegex.test(content)) {
|
|
1107
1212
|
console.log(
|
|
1108
|
-
|
|
1213
|
+
import_chalk9.default.red(
|
|
1109
1214
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1110
1215
|
)
|
|
1111
1216
|
);
|
|
@@ -1154,18 +1259,14 @@ GITHUB_CLIENT_SECRET=
|
|
|
1154
1259
|
if (import_fs9.default.existsSync(componentTemplate)) {
|
|
1155
1260
|
import_fs9.default.copyFileSync(componentTemplate, componentDest);
|
|
1156
1261
|
}
|
|
1157
|
-
console.log(
|
|
1262
|
+
console.log(import_chalk9.default.green("GitHub provider added & merged successfully"));
|
|
1158
1263
|
} catch (error) {
|
|
1159
|
-
console.log(
|
|
1264
|
+
console.log(import_chalk9.default.red("githubRun error:"), error);
|
|
1160
1265
|
}
|
|
1161
1266
|
};
|
|
1162
1267
|
|
|
1163
|
-
// cli/provider.ts
|
|
1164
|
-
var import_path12 = __toESM(require("path"), 1);
|
|
1165
|
-
var import_fs12 = __toESM(require("fs"), 1);
|
|
1166
|
-
|
|
1167
1268
|
// script/googleRunTanstackState.ts
|
|
1168
|
-
var
|
|
1269
|
+
var import_chalk10 = __toESM(require("chalk"), 1);
|
|
1169
1270
|
var import_fs10 = __toESM(require("fs"), 1);
|
|
1170
1271
|
var import_path10 = __toESM(require("path"), 1);
|
|
1171
1272
|
var import_url9 = require("url");
|
|
@@ -1178,16 +1279,16 @@ var googleRunTanstackState = async () => {
|
|
|
1178
1279
|
const srcPath = import_path10.default.join(projectDir, "src");
|
|
1179
1280
|
const authFilePath = import_path10.default.join(srcPath, "lib", "auth.ts");
|
|
1180
1281
|
if (!import_fs10.default.existsSync(authFilePath)) {
|
|
1181
|
-
console.log(
|
|
1282
|
+
console.log(import_chalk10.default.red("auth.ts file not found"));
|
|
1182
1283
|
return;
|
|
1183
1284
|
}
|
|
1184
1285
|
let content = import_fs10.default.readFileSync(authFilePath, "utf8");
|
|
1185
1286
|
if (!content.includes("betterAuth({")) {
|
|
1186
|
-
console.log(
|
|
1287
|
+
console.log(import_chalk10.default.red("betterAuth({}) block not found"));
|
|
1187
1288
|
return;
|
|
1188
1289
|
}
|
|
1189
1290
|
if (content.includes("socialProviders") && content.includes("google:")) {
|
|
1190
|
-
console.log(
|
|
1291
|
+
console.log(import_chalk10.default.yellow("Google provider already exists"));
|
|
1191
1292
|
return;
|
|
1192
1293
|
}
|
|
1193
1294
|
const googleProviderEntry = `
|
|
@@ -1210,7 +1311,7 @@ var googleRunTanstackState = async () => {
|
|
|
1210
1311
|
}
|
|
1211
1312
|
}
|
|
1212
1313
|
if (insertPos === -1) {
|
|
1213
|
-
console.log(
|
|
1314
|
+
console.log(import_chalk10.default.red("Failed to parse socialProviders block"));
|
|
1214
1315
|
return;
|
|
1215
1316
|
}
|
|
1216
1317
|
content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1218,7 +1319,7 @@ var googleRunTanstackState = async () => {
|
|
|
1218
1319
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1219
1320
|
if (!databaseRegex.test(content)) {
|
|
1220
1321
|
console.log(
|
|
1221
|
-
|
|
1322
|
+
import_chalk10.default.red(
|
|
1222
1323
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1223
1324
|
)
|
|
1224
1325
|
);
|
|
@@ -1262,14 +1363,14 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1262
1363
|
if (import_fs10.default.existsSync(componentTemplate)) {
|
|
1263
1364
|
import_fs10.default.copyFileSync(componentTemplate, componentDest);
|
|
1264
1365
|
}
|
|
1265
|
-
console.log(
|
|
1366
|
+
console.log(import_chalk10.default.green("Google provider added & merged successfully"));
|
|
1266
1367
|
} catch (error) {
|
|
1267
|
-
console.log(
|
|
1368
|
+
console.log(import_chalk10.default.red("googleRunTanstackState error:"), error);
|
|
1268
1369
|
}
|
|
1269
1370
|
};
|
|
1270
1371
|
|
|
1271
1372
|
// script/githubRunTanstackState.ts
|
|
1272
|
-
var
|
|
1373
|
+
var import_chalk11 = __toESM(require("chalk"), 1);
|
|
1273
1374
|
var import_fs11 = __toESM(require("fs"), 1);
|
|
1274
1375
|
var import_path11 = __toESM(require("path"), 1);
|
|
1275
1376
|
var import_url10 = require("url");
|
|
@@ -1282,16 +1383,16 @@ var githubRunTanstackState = async () => {
|
|
|
1282
1383
|
const srcPath = import_path11.default.join(projectDir, "src");
|
|
1283
1384
|
const authFilePath = import_path11.default.join(srcPath, "lib", "auth.ts");
|
|
1284
1385
|
if (!import_fs11.default.existsSync(authFilePath)) {
|
|
1285
|
-
console.log(
|
|
1386
|
+
console.log(import_chalk11.default.red("auth.ts file not found"));
|
|
1286
1387
|
return;
|
|
1287
1388
|
}
|
|
1288
1389
|
let content = import_fs11.default.readFileSync(authFilePath, "utf8");
|
|
1289
1390
|
if (!content.includes("betterAuth({")) {
|
|
1290
|
-
console.log(
|
|
1391
|
+
console.log(import_chalk11.default.red("betterAuth({}) block not found"));
|
|
1291
1392
|
return;
|
|
1292
1393
|
}
|
|
1293
1394
|
if (content.includes("socialProviders") && content.includes("github:")) {
|
|
1294
|
-
console.log(
|
|
1395
|
+
console.log(import_chalk11.default.yellow("Github provider already exists"));
|
|
1295
1396
|
return;
|
|
1296
1397
|
}
|
|
1297
1398
|
const githubProviderEntry = `
|
|
@@ -1314,7 +1415,7 @@ var githubRunTanstackState = async () => {
|
|
|
1314
1415
|
}
|
|
1315
1416
|
}
|
|
1316
1417
|
if (insertPos === -1) {
|
|
1317
|
-
console.log(
|
|
1418
|
+
console.log(import_chalk11.default.red("Failed to parse socialProviders block"));
|
|
1318
1419
|
return;
|
|
1319
1420
|
}
|
|
1320
1421
|
content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1322,7 +1423,7 @@ var githubRunTanstackState = async () => {
|
|
|
1322
1423
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1323
1424
|
if (!databaseRegex.test(content)) {
|
|
1324
1425
|
console.log(
|
|
1325
|
-
|
|
1426
|
+
import_chalk11.default.red(
|
|
1326
1427
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1327
1428
|
)
|
|
1328
1429
|
);
|
|
@@ -1366,22 +1467,19 @@ GITHUB_CLIENT_SECRET=
|
|
|
1366
1467
|
if (import_fs11.default.existsSync(componentTemplate)) {
|
|
1367
1468
|
import_fs11.default.copyFileSync(componentTemplate, componentDest);
|
|
1368
1469
|
}
|
|
1369
|
-
console.log(
|
|
1470
|
+
console.log(import_chalk11.default.green("Github provider added & merged successfully"));
|
|
1370
1471
|
} catch (error) {
|
|
1371
|
-
console.log(
|
|
1472
|
+
console.log(import_chalk11.default.red("githubRunTanstackState error:"), error);
|
|
1372
1473
|
}
|
|
1373
1474
|
};
|
|
1374
1475
|
|
|
1375
1476
|
// cli/provider.ts
|
|
1376
1477
|
var providers = async ({ provider }) => {
|
|
1377
1478
|
try {
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const packageJson2 = JSON.parse(import_fs12.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1383
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
1384
|
-
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;
|
|
1385
1483
|
}
|
|
1386
1484
|
if (framework === "Next js" && provider == "google") {
|
|
1387
1485
|
await googleRun();
|
|
@@ -1394,46 +1492,98 @@ var providers = async ({ provider }) => {
|
|
|
1394
1492
|
await githubRunTanstackState();
|
|
1395
1493
|
}
|
|
1396
1494
|
} catch (error) {
|
|
1397
|
-
console.log(
|
|
1495
|
+
console.log(import_chalk12.default.red("Error adding provider:"), error);
|
|
1398
1496
|
}
|
|
1399
1497
|
};
|
|
1400
1498
|
|
|
1401
|
-
// cli/forget.ts
|
|
1402
|
-
var import_path22 = __toESM(require("path"), 1);
|
|
1403
|
-
var import_fs22 = __toESM(require("fs"), 1);
|
|
1404
|
-
|
|
1405
1499
|
// script/forgetNext.ts
|
|
1406
|
-
var
|
|
1407
|
-
var
|
|
1500
|
+
var import_chalk20 = __toESM(require("chalk"), 1);
|
|
1501
|
+
var import_path19 = __toESM(require("path"), 1);
|
|
1408
1502
|
var import_url17 = require("url");
|
|
1409
|
-
var
|
|
1503
|
+
var import_fs19 = __toESM(require("fs"), 1);
|
|
1410
1504
|
|
|
1411
1505
|
// cli/email.ts
|
|
1412
|
-
var
|
|
1413
|
-
var
|
|
1506
|
+
var import_path18 = __toESM(require("path"), 1);
|
|
1507
|
+
var import_fs18 = __toESM(require("fs"), 1);
|
|
1414
1508
|
var import_inquirer4 = __toESM(require("inquirer"), 1);
|
|
1415
1509
|
|
|
1416
1510
|
// email/gmailRun.ts
|
|
1417
|
-
var
|
|
1418
|
-
var
|
|
1419
|
-
var
|
|
1511
|
+
var import_chalk13 = __toESM(require("chalk"), 1);
|
|
1512
|
+
var import_path12 = __toESM(require("path"), 1);
|
|
1513
|
+
var import_fs12 = __toESM(require("fs"), 1);
|
|
1420
1514
|
var import_url11 = require("url");
|
|
1421
1515
|
var import_meta11 = {};
|
|
1422
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 () => {
|
|
1423
1574
|
try {
|
|
1424
1575
|
const projectDir = process.cwd();
|
|
1425
1576
|
const packageJsonPath = import_path13.default.join(projectDir, "package.json");
|
|
1426
1577
|
const packageJson2 = JSON.parse(import_fs13.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1427
|
-
const
|
|
1428
|
-
const __filename = (0, import_url11.fileURLToPath)(import_meta11.url);
|
|
1578
|
+
const __filename = (0, import_url12.fileURLToPath)(import_meta12.url);
|
|
1429
1579
|
const __dirname = import_path13.default.dirname(__filename);
|
|
1430
1580
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1431
|
-
console.log(
|
|
1581
|
+
console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1432
1582
|
packageManager("nodemailer");
|
|
1433
1583
|
packageManager("@types/nodemailer", true);
|
|
1434
1584
|
}
|
|
1435
1585
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1436
|
-
console.log(
|
|
1586
|
+
console.log(import_chalk14.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1437
1587
|
packageManager("@react-email/components");
|
|
1438
1588
|
}
|
|
1439
1589
|
const envPath = import_path13.default.join(projectDir, ".env");
|
|
@@ -1459,94 +1609,94 @@ GMAIL_PASSWORD=`);
|
|
|
1459
1609
|
__dirname,
|
|
1460
1610
|
"./template/email/emailGmail.ts"
|
|
1461
1611
|
);
|
|
1462
|
-
const libPath = import_path13.default.join(projectDir,
|
|
1612
|
+
const libPath = import_path13.default.join(projectDir, "src", "lib");
|
|
1463
1613
|
if (!import_fs13.default.existsSync(libPath)) {
|
|
1464
1614
|
import_fs13.default.mkdirSync(libPath, { recursive: true });
|
|
1465
1615
|
}
|
|
1466
1616
|
const libDestinationPath = import_path13.default.join(libPath, "email.ts");
|
|
1467
1617
|
import_fs13.default.copyFileSync(templatePath, libDestinationPath);
|
|
1468
1618
|
} catch (error) {
|
|
1469
|
-
console.log(
|
|
1619
|
+
console.log(import_chalk14.default.red(error));
|
|
1470
1620
|
}
|
|
1471
1621
|
};
|
|
1472
1622
|
|
|
1473
|
-
// email/
|
|
1474
|
-
var
|
|
1623
|
+
// email/awsSesRun.ts
|
|
1624
|
+
var import_chalk15 = __toESM(require("chalk"), 1);
|
|
1475
1625
|
var import_path14 = __toESM(require("path"), 1);
|
|
1476
1626
|
var import_fs14 = __toESM(require("fs"), 1);
|
|
1477
|
-
var
|
|
1478
|
-
var
|
|
1479
|
-
var
|
|
1627
|
+
var import_url13 = require("url");
|
|
1628
|
+
var import_meta13 = {};
|
|
1629
|
+
var awsSesRun = async () => {
|
|
1480
1630
|
try {
|
|
1481
1631
|
const projectDir = process.cwd();
|
|
1482
1632
|
const packageJsonPath = import_path14.default.join(projectDir, "package.json");
|
|
1483
1633
|
const packageJson2 = JSON.parse(import_fs14.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1484
|
-
const
|
|
1634
|
+
const srcFolder = import_fs14.default.existsSync(import_path14.default.join(projectDir, "src")) ? "src" : "";
|
|
1635
|
+
const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
|
|
1485
1636
|
const __dirname = import_path14.default.dirname(__filename);
|
|
1486
1637
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1487
|
-
console.log(
|
|
1638
|
+
console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1488
1639
|
packageManager("nodemailer");
|
|
1489
1640
|
packageManager("@types/nodemailer", true);
|
|
1490
1641
|
}
|
|
1491
1642
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1492
|
-
console.log(
|
|
1643
|
+
console.log(import_chalk15.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1493
1644
|
packageManager("@react-email/components");
|
|
1494
1645
|
}
|
|
1495
1646
|
const envPath = import_path14.default.join(projectDir, ".env");
|
|
1496
1647
|
const envContent = import_fs14.default.readFileSync(envPath, "utf8");
|
|
1497
|
-
if (!envContent.includes("
|
|
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")) {
|
|
1498
1649
|
import_fs14.default.appendFileSync(envPath, `
|
|
1499
1650
|
|
|
1500
|
-
#
|
|
1651
|
+
# AWS SES API Key for sending emails`);
|
|
1501
1652
|
import_fs14.default.appendFileSync(envPath, `
|
|
1502
|
-
|
|
1653
|
+
AWS_SES_HOST=`);
|
|
1503
1654
|
import_fs14.default.appendFileSync(envPath, `
|
|
1504
|
-
|
|
1655
|
+
AWS_SES_PORT=`);
|
|
1505
1656
|
import_fs14.default.appendFileSync(envPath, `
|
|
1506
|
-
|
|
1657
|
+
AWS_SES_SERVICE=`);
|
|
1507
1658
|
import_fs14.default.appendFileSync(envPath, `
|
|
1508
|
-
|
|
1659
|
+
AWS_SES_USER=`);
|
|
1509
1660
|
import_fs14.default.appendFileSync(envPath, `
|
|
1510
|
-
|
|
1661
|
+
AWS_SES_PASS=`);
|
|
1511
1662
|
import_fs14.default.appendFileSync(envPath, `
|
|
1512
|
-
|
|
1663
|
+
AWS_SES_FROM=`);
|
|
1513
1664
|
}
|
|
1514
1665
|
const templatePath = import_path14.default.resolve(
|
|
1515
1666
|
__dirname,
|
|
1516
|
-
"./template/email/
|
|
1667
|
+
"./template/email/emailAwsSes.ts"
|
|
1517
1668
|
);
|
|
1518
|
-
const libPath = import_path14.default.join(projectDir,
|
|
1669
|
+
const libPath = import_path14.default.join(projectDir, srcFolder, "lib");
|
|
1519
1670
|
if (!import_fs14.default.existsSync(libPath)) {
|
|
1520
1671
|
import_fs14.default.mkdirSync(libPath, { recursive: true });
|
|
1521
1672
|
}
|
|
1522
1673
|
const libDestinationPath = import_path14.default.join(libPath, "email.ts");
|
|
1523
1674
|
import_fs14.default.copyFileSync(templatePath, libDestinationPath);
|
|
1524
1675
|
} catch (error) {
|
|
1525
|
-
console.log(
|
|
1676
|
+
console.log(import_chalk15.default.red(error));
|
|
1526
1677
|
}
|
|
1527
1678
|
};
|
|
1528
1679
|
|
|
1529
|
-
// email/
|
|
1530
|
-
var
|
|
1680
|
+
// email/awsSesRunTanstackState.ts
|
|
1681
|
+
var import_chalk16 = __toESM(require("chalk"), 1);
|
|
1531
1682
|
var import_path15 = __toESM(require("path"), 1);
|
|
1532
1683
|
var import_fs15 = __toESM(require("fs"), 1);
|
|
1533
|
-
var
|
|
1534
|
-
var
|
|
1535
|
-
var
|
|
1684
|
+
var import_url14 = require("url");
|
|
1685
|
+
var import_meta14 = {};
|
|
1686
|
+
var awsSesRunTanstackState = async () => {
|
|
1536
1687
|
try {
|
|
1537
1688
|
const projectDir = process.cwd();
|
|
1538
1689
|
const packageJsonPath = import_path15.default.join(projectDir, "package.json");
|
|
1539
1690
|
const packageJson2 = JSON.parse(import_fs15.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1540
|
-
const
|
|
1541
|
-
const __filename = (0, import_url13.fileURLToPath)(import_meta13.url);
|
|
1691
|
+
const __filename = (0, import_url14.fileURLToPath)(import_meta14.url);
|
|
1542
1692
|
const __dirname = import_path15.default.dirname(__filename);
|
|
1543
1693
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
1544
|
-
console.log(
|
|
1694
|
+
console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
1545
1695
|
packageManager("nodemailer");
|
|
1546
1696
|
packageManager("@types/nodemailer", true);
|
|
1547
1697
|
}
|
|
1548
1698
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1549
|
-
console.log(
|
|
1699
|
+
console.log(import_chalk16.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1550
1700
|
packageManager("@react-email/components");
|
|
1551
1701
|
}
|
|
1552
1702
|
const envPath = import_path15.default.join(projectDir, ".env");
|
|
@@ -1572,93 +1722,86 @@ AWS_SES_FROM=`);
|
|
|
1572
1722
|
__dirname,
|
|
1573
1723
|
"./template/email/emailAwsSes.ts"
|
|
1574
1724
|
);
|
|
1575
|
-
const libPath = import_path15.default.join(projectDir,
|
|
1725
|
+
const libPath = import_path15.default.join(projectDir, "src", "lib");
|
|
1576
1726
|
if (!import_fs15.default.existsSync(libPath)) {
|
|
1577
1727
|
import_fs15.default.mkdirSync(libPath, { recursive: true });
|
|
1578
1728
|
}
|
|
1579
1729
|
const libDestinationPath = import_path15.default.join(libPath, "email.ts");
|
|
1580
1730
|
import_fs15.default.copyFileSync(templatePath, libDestinationPath);
|
|
1581
1731
|
} catch (error) {
|
|
1582
|
-
console.log(
|
|
1732
|
+
console.log(import_chalk16.default.red(error));
|
|
1583
1733
|
}
|
|
1584
1734
|
};
|
|
1585
1735
|
|
|
1586
|
-
// email/
|
|
1587
|
-
var
|
|
1736
|
+
// email/resendRun.ts
|
|
1737
|
+
var import_chalk17 = __toESM(require("chalk"), 1);
|
|
1588
1738
|
var import_path16 = __toESM(require("path"), 1);
|
|
1589
1739
|
var import_fs16 = __toESM(require("fs"), 1);
|
|
1590
|
-
var
|
|
1591
|
-
var
|
|
1592
|
-
var
|
|
1740
|
+
var import_url15 = require("url");
|
|
1741
|
+
var import_meta15 = {};
|
|
1742
|
+
var resendRun = async () => {
|
|
1593
1743
|
try {
|
|
1594
1744
|
const projectDir = process.cwd();
|
|
1595
1745
|
const packageJsonPath = import_path16.default.join(projectDir, "package.json");
|
|
1596
1746
|
const packageJson2 = JSON.parse(import_fs16.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1597
|
-
const
|
|
1747
|
+
const srcFolder = import_fs16.default.existsSync(import_path16.default.join(projectDir, "src")) ? "src" : "";
|
|
1748
|
+
const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
|
|
1598
1749
|
const __dirname = import_path16.default.dirname(__filename);
|
|
1599
|
-
if (!packageJson2.dependencies?.
|
|
1600
|
-
console.log(
|
|
1601
|
-
packageManager("
|
|
1602
|
-
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");
|
|
1603
1753
|
}
|
|
1604
1754
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1605
|
-
console.log(
|
|
1755
|
+
console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1606
1756
|
packageManager("@react-email/components");
|
|
1607
1757
|
}
|
|
1608
1758
|
const envPath = import_path16.default.join(projectDir, ".env");
|
|
1609
1759
|
const envContent = import_fs16.default.readFileSync(envPath, "utf8");
|
|
1610
|
-
if (!envContent.includes("
|
|
1760
|
+
if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
|
|
1611
1761
|
import_fs16.default.appendFileSync(envPath, `
|
|
1612
1762
|
|
|
1613
|
-
#
|
|
1614
|
-
import_fs16.default.appendFileSync(envPath, `
|
|
1615
|
-
AWS_SES_HOST=`);
|
|
1616
|
-
import_fs16.default.appendFileSync(envPath, `
|
|
1617
|
-
AWS_SES_PORT=`);
|
|
1618
|
-
import_fs16.default.appendFileSync(envPath, `
|
|
1619
|
-
AWS_SES_SERVICE=`);
|
|
1763
|
+
# Resend API Key for sending emails`);
|
|
1620
1764
|
import_fs16.default.appendFileSync(envPath, `
|
|
1621
|
-
|
|
1765
|
+
RESEND_API_KEY=`);
|
|
1622
1766
|
import_fs16.default.appendFileSync(envPath, `
|
|
1623
|
-
|
|
1767
|
+
EMAIL_SENDER_NAME=Your Name`);
|
|
1624
1768
|
import_fs16.default.appendFileSync(envPath, `
|
|
1625
|
-
|
|
1769
|
+
EMAIL_SENDER_ADDRESS=`);
|
|
1626
1770
|
}
|
|
1627
1771
|
const templatePath = import_path16.default.resolve(
|
|
1628
1772
|
__dirname,
|
|
1629
|
-
"./template/email/
|
|
1773
|
+
"./template/email/emailResend.ts"
|
|
1630
1774
|
);
|
|
1631
|
-
const libPath = import_path16.default.join(projectDir,
|
|
1775
|
+
const libPath = import_path16.default.join(projectDir, srcFolder, "lib");
|
|
1632
1776
|
if (!import_fs16.default.existsSync(libPath)) {
|
|
1633
1777
|
import_fs16.default.mkdirSync(libPath, { recursive: true });
|
|
1634
1778
|
}
|
|
1635
1779
|
const libDestinationPath = import_path16.default.join(libPath, "email.ts");
|
|
1636
1780
|
import_fs16.default.copyFileSync(templatePath, libDestinationPath);
|
|
1637
1781
|
} catch (error) {
|
|
1638
|
-
console.log(
|
|
1782
|
+
console.log(import_chalk17.default.red(error));
|
|
1639
1783
|
}
|
|
1640
1784
|
};
|
|
1641
1785
|
|
|
1642
|
-
// email/
|
|
1643
|
-
var
|
|
1786
|
+
// email/resendRunTanstackState.ts
|
|
1787
|
+
var import_chalk18 = __toESM(require("chalk"), 1);
|
|
1644
1788
|
var import_path17 = __toESM(require("path"), 1);
|
|
1645
1789
|
var import_fs17 = __toESM(require("fs"), 1);
|
|
1646
|
-
var
|
|
1647
|
-
var
|
|
1648
|
-
var
|
|
1790
|
+
var import_url16 = require("url");
|
|
1791
|
+
var import_meta16 = {};
|
|
1792
|
+
var resendRunTanstackState = async () => {
|
|
1649
1793
|
try {
|
|
1650
1794
|
const projectDir = process.cwd();
|
|
1651
1795
|
const packageJsonPath = import_path17.default.join(projectDir, "package.json");
|
|
1652
1796
|
const packageJson2 = JSON.parse(import_fs17.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1653
|
-
const
|
|
1654
|
-
const __filename = (0, import_url15.fileURLToPath)(import_meta15.url);
|
|
1797
|
+
const __filename = (0, import_url16.fileURLToPath)(import_meta16.url);
|
|
1655
1798
|
const __dirname = import_path17.default.dirname(__filename);
|
|
1656
1799
|
if (!packageJson2.dependencies?.resend) {
|
|
1657
|
-
console.log(
|
|
1800
|
+
console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
1658
1801
|
packageManager("resend");
|
|
1659
1802
|
}
|
|
1660
1803
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1661
|
-
console.log(
|
|
1804
|
+
console.log(import_chalk18.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1662
1805
|
packageManager("@react-email/components");
|
|
1663
1806
|
}
|
|
1664
1807
|
const envPath = import_path17.default.join(projectDir, ".env");
|
|
@@ -1678,80 +1821,30 @@ EMAIL_SENDER_ADDRESS=`);
|
|
|
1678
1821
|
__dirname,
|
|
1679
1822
|
"./template/email/emailResend.ts"
|
|
1680
1823
|
);
|
|
1681
|
-
const libPath = import_path17.default.join(projectDir,
|
|
1824
|
+
const libPath = import_path17.default.join(projectDir, "src", "lib");
|
|
1682
1825
|
if (!import_fs17.default.existsSync(libPath)) {
|
|
1683
1826
|
import_fs17.default.mkdirSync(libPath, { recursive: true });
|
|
1684
1827
|
}
|
|
1685
1828
|
const libDestinationPath = import_path17.default.join(libPath, "email.ts");
|
|
1686
1829
|
import_fs17.default.copyFileSync(templatePath, libDestinationPath);
|
|
1687
1830
|
} catch (error) {
|
|
1688
|
-
console.log(
|
|
1689
|
-
}
|
|
1690
|
-
};
|
|
1691
|
-
|
|
1692
|
-
// email/resendRunTanstackState.ts
|
|
1693
|
-
var import_chalk17 = __toESM(require("chalk"), 1);
|
|
1694
|
-
var import_path18 = __toESM(require("path"), 1);
|
|
1695
|
-
var import_fs18 = __toESM(require("fs"), 1);
|
|
1696
|
-
var import_url16 = require("url");
|
|
1697
|
-
var import_meta16 = {};
|
|
1698
|
-
var resendRunTanstackState = async () => {
|
|
1699
|
-
try {
|
|
1700
|
-
const projectDir = process.cwd();
|
|
1701
|
-
const packageJsonPath = import_path18.default.join(projectDir, "package.json");
|
|
1702
|
-
const packageJson2 = JSON.parse(import_fs18.default.readFileSync(packageJsonPath, "utf-8"));
|
|
1703
|
-
const __filename = (0, import_url16.fileURLToPath)(import_meta16.url);
|
|
1704
|
-
const __dirname = import_path18.default.dirname(__filename);
|
|
1705
|
-
if (!packageJson2.dependencies?.resend) {
|
|
1706
|
-
console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
1707
|
-
packageManager("resend");
|
|
1708
|
-
}
|
|
1709
|
-
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
1710
|
-
console.log(import_chalk17.default.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
1711
|
-
packageManager("@react-email/components");
|
|
1712
|
-
}
|
|
1713
|
-
const envPath = import_path18.default.join(projectDir, ".env");
|
|
1714
|
-
const envContent = import_fs18.default.readFileSync(envPath, "utf8");
|
|
1715
|
-
if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
|
|
1716
|
-
import_fs18.default.appendFileSync(envPath, `
|
|
1717
|
-
|
|
1718
|
-
# Resend API Key for sending emails`);
|
|
1719
|
-
import_fs18.default.appendFileSync(envPath, `
|
|
1720
|
-
RESEND_API_KEY=`);
|
|
1721
|
-
import_fs18.default.appendFileSync(envPath, `
|
|
1722
|
-
EMAIL_SENDER_NAME=Your Name`);
|
|
1723
|
-
import_fs18.default.appendFileSync(envPath, `
|
|
1724
|
-
EMAIL_SENDER_ADDRESS=`);
|
|
1725
|
-
}
|
|
1726
|
-
const templatePath = import_path18.default.resolve(
|
|
1727
|
-
__dirname,
|
|
1728
|
-
"./template/email/emailResend.ts"
|
|
1729
|
-
);
|
|
1730
|
-
const libPath = import_path18.default.join(projectDir, "src", "lib");
|
|
1731
|
-
if (!import_fs18.default.existsSync(libPath)) {
|
|
1732
|
-
import_fs18.default.mkdirSync(libPath, { recursive: true });
|
|
1733
|
-
}
|
|
1734
|
-
const libDestinationPath = import_path18.default.join(libPath, "email.ts");
|
|
1735
|
-
import_fs18.default.copyFileSync(templatePath, libDestinationPath);
|
|
1736
|
-
} catch (error) {
|
|
1737
|
-
console.log(import_chalk17.default.red(error));
|
|
1831
|
+
console.log(import_chalk18.default.red(error));
|
|
1738
1832
|
}
|
|
1739
1833
|
};
|
|
1740
1834
|
|
|
1741
1835
|
// cli/email.ts
|
|
1836
|
+
var import_chalk19 = __toESM(require("chalk"), 1);
|
|
1742
1837
|
var email = async () => {
|
|
1743
1838
|
const projectDir = process.cwd();
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
1749
|
-
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;
|
|
1750
1843
|
}
|
|
1751
1844
|
if (framework === "Next js") {
|
|
1752
|
-
const srcFolder =
|
|
1753
|
-
const emailPath =
|
|
1754
|
-
if (
|
|
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)) {
|
|
1755
1848
|
const answers2 = await import_inquirer4.default.prompt([
|
|
1756
1849
|
{
|
|
1757
1850
|
type: "confirm",
|
|
@@ -1766,12 +1859,12 @@ var email = async () => {
|
|
|
1766
1859
|
}
|
|
1767
1860
|
}
|
|
1768
1861
|
if (framework === "tanstack state") {
|
|
1769
|
-
const srcFolderTanstackState =
|
|
1770
|
-
const libPathTanstackState =
|
|
1862
|
+
const srcFolderTanstackState = import_path18.default.join(projectDir, "src");
|
|
1863
|
+
const libPathTanstackState = import_path18.default.join(
|
|
1771
1864
|
srcFolderTanstackState,
|
|
1772
1865
|
"lib/email.ts"
|
|
1773
1866
|
);
|
|
1774
|
-
if (
|
|
1867
|
+
if (import_fs18.default.existsSync(libPathTanstackState)) {
|
|
1775
1868
|
const answers2 = await import_inquirer4.default.prompt([
|
|
1776
1869
|
{
|
|
1777
1870
|
type: "confirm",
|
|
@@ -1819,19 +1912,19 @@ var forgetNext = async () => {
|
|
|
1819
1912
|
try {
|
|
1820
1913
|
const projectDir = process.cwd();
|
|
1821
1914
|
const __filename = (0, import_url17.fileURLToPath)(import_meta17.url);
|
|
1822
|
-
const __dirname =
|
|
1823
|
-
const srcPath =
|
|
1824
|
-
const folder =
|
|
1825
|
-
const emailFilePath =
|
|
1826
|
-
if (!
|
|
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)) {
|
|
1827
1920
|
await email();
|
|
1828
1921
|
}
|
|
1829
|
-
const authFilePath =
|
|
1830
|
-
if (!
|
|
1831
|
-
console.log(
|
|
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."));
|
|
1832
1925
|
return;
|
|
1833
1926
|
}
|
|
1834
|
-
let content =
|
|
1927
|
+
let content = import_fs19.default.readFileSync(authFilePath, "utf8");
|
|
1835
1928
|
const codeAdded = ` sendResetPassword: async ({ user, url, token }) => {
|
|
1836
1929
|
await sendEmail({
|
|
1837
1930
|
email: user.email!,
|
|
@@ -1875,7 +1968,7 @@ var forgetNext = async () => {
|
|
|
1875
1968
|
content = before + `
|
|
1876
1969
|
${codeAdded}` + after;
|
|
1877
1970
|
}
|
|
1878
|
-
|
|
1971
|
+
import_fs19.default.writeFileSync(authFilePath, content, "utf8");
|
|
1879
1972
|
if (!content.includes("import { sendEmail }")) {
|
|
1880
1973
|
const lastImportIndex = content.lastIndexOf("import");
|
|
1881
1974
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -1885,129 +1978,129 @@ var forgetNext = async () => {
|
|
|
1885
1978
|
import { sendEmail } from "./email";
|
|
1886
1979
|
`;
|
|
1887
1980
|
content = beforeImports + newImports + afterImports;
|
|
1888
|
-
|
|
1981
|
+
import_fs19.default.writeFileSync(authFilePath, content, "utf8");
|
|
1889
1982
|
}
|
|
1890
|
-
const componentPath =
|
|
1983
|
+
const componentPath = import_path19.default.resolve(
|
|
1891
1984
|
__dirname,
|
|
1892
1985
|
"./template/email/reset-password.tsx"
|
|
1893
1986
|
);
|
|
1894
|
-
const destinationPath =
|
|
1987
|
+
const destinationPath = import_path19.default.join(
|
|
1895
1988
|
projectDir,
|
|
1896
1989
|
folder,
|
|
1897
1990
|
"components",
|
|
1898
1991
|
"email"
|
|
1899
1992
|
);
|
|
1900
|
-
if (!
|
|
1901
|
-
|
|
1993
|
+
if (!import_fs19.default.existsSync(destinationPath)) {
|
|
1994
|
+
import_fs19.default.mkdirSync(destinationPath, { recursive: true });
|
|
1902
1995
|
}
|
|
1903
|
-
const emailDestinationPath =
|
|
1996
|
+
const emailDestinationPath = import_path19.default.join(
|
|
1904
1997
|
destinationPath,
|
|
1905
1998
|
"reset-password.tsx"
|
|
1906
1999
|
);
|
|
1907
|
-
if (
|
|
1908
|
-
|
|
2000
|
+
if (import_fs19.default.existsSync(componentPath)) {
|
|
2001
|
+
import_fs19.default.copyFileSync(componentPath, emailDestinationPath);
|
|
1909
2002
|
}
|
|
1910
|
-
const forgetComponentPath =
|
|
2003
|
+
const forgetComponentPath = import_path19.default.resolve(
|
|
1911
2004
|
__dirname,
|
|
1912
2005
|
"./template/components/ForgetComponent.tsx"
|
|
1913
2006
|
);
|
|
1914
|
-
const componentsDestinationPath =
|
|
2007
|
+
const componentsDestinationPath = import_path19.default.join(
|
|
1915
2008
|
projectDir,
|
|
1916
2009
|
folder,
|
|
1917
2010
|
"components",
|
|
1918
2011
|
"authverse"
|
|
1919
2012
|
);
|
|
1920
|
-
if (!
|
|
1921
|
-
|
|
2013
|
+
if (!import_fs19.default.existsSync(componentsDestinationPath)) {
|
|
2014
|
+
import_fs19.default.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
1922
2015
|
}
|
|
1923
|
-
const forgetDestinationPath =
|
|
2016
|
+
const forgetDestinationPath = import_path19.default.join(
|
|
1924
2017
|
componentsDestinationPath,
|
|
1925
2018
|
"ForgetComponent.tsx"
|
|
1926
2019
|
);
|
|
1927
|
-
if (
|
|
1928
|
-
|
|
2020
|
+
if (import_fs19.default.existsSync(forgetComponentPath)) {
|
|
2021
|
+
import_fs19.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
1929
2022
|
}
|
|
1930
|
-
const resetComponentPath =
|
|
2023
|
+
const resetComponentPath = import_path19.default.resolve(
|
|
1931
2024
|
__dirname,
|
|
1932
2025
|
"./template/components/ResetComponent.tsx"
|
|
1933
2026
|
);
|
|
1934
|
-
const resetDestinationPath =
|
|
2027
|
+
const resetDestinationPath = import_path19.default.join(
|
|
1935
2028
|
componentsDestinationPath,
|
|
1936
2029
|
"ResetComponent.tsx"
|
|
1937
2030
|
);
|
|
1938
|
-
if (
|
|
1939
|
-
|
|
2031
|
+
if (import_fs19.default.existsSync(resetComponentPath)) {
|
|
2032
|
+
import_fs19.default.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
1940
2033
|
}
|
|
1941
|
-
const authTemplatePath =
|
|
2034
|
+
const authTemplatePath = import_path19.default.resolve(
|
|
1942
2035
|
__dirname,
|
|
1943
2036
|
"./template/app-auth-uiDesign"
|
|
1944
2037
|
);
|
|
1945
|
-
const appDestinationPath =
|
|
1946
|
-
if (!
|
|
1947
|
-
|
|
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 });
|
|
1948
2041
|
}
|
|
1949
|
-
const forgetDestinationDir =
|
|
1950
|
-
if (!
|
|
1951
|
-
|
|
2042
|
+
const forgetDestinationDir = import_path19.default.join(appDestinationPath, "forget");
|
|
2043
|
+
if (!import_fs19.default.existsSync(forgetDestinationDir)) {
|
|
2044
|
+
import_fs19.default.mkdirSync(forgetDestinationDir, { recursive: true });
|
|
1952
2045
|
}
|
|
1953
|
-
const forgetPageDestinationPath =
|
|
2046
|
+
const forgetPageDestinationPath = import_path19.default.join(
|
|
1954
2047
|
forgetDestinationDir,
|
|
1955
2048
|
"page.tsx"
|
|
1956
2049
|
);
|
|
1957
|
-
|
|
2050
|
+
import_fs19.default.copyFileSync(
|
|
1958
2051
|
`${authTemplatePath}/forget/page.tsx`,
|
|
1959
2052
|
forgetPageDestinationPath
|
|
1960
2053
|
);
|
|
1961
|
-
const resetDestinationDir =
|
|
2054
|
+
const resetDestinationDir = import_path19.default.join(
|
|
1962
2055
|
appDestinationPath,
|
|
1963
2056
|
"reset-password"
|
|
1964
2057
|
);
|
|
1965
|
-
if (!
|
|
1966
|
-
|
|
2058
|
+
if (!import_fs19.default.existsSync(resetDestinationDir)) {
|
|
2059
|
+
import_fs19.default.mkdirSync(resetDestinationDir, { recursive: true });
|
|
1967
2060
|
}
|
|
1968
|
-
const resetPageDestinationPath =
|
|
2061
|
+
const resetPageDestinationPath = import_path19.default.join(
|
|
1969
2062
|
resetDestinationDir,
|
|
1970
2063
|
"page.tsx"
|
|
1971
2064
|
);
|
|
1972
|
-
|
|
2065
|
+
import_fs19.default.copyFileSync(
|
|
1973
2066
|
`${authTemplatePath}/reset-password/page.tsx`,
|
|
1974
2067
|
resetPageDestinationPath
|
|
1975
2068
|
);
|
|
1976
2069
|
console.log(
|
|
1977
|
-
|
|
2070
|
+
import_chalk20.default.green("Successfully added forget and reset-password pages")
|
|
1978
2071
|
);
|
|
1979
2072
|
} else {
|
|
1980
2073
|
console.log(
|
|
1981
|
-
|
|
2074
|
+
import_chalk20.default.red("Could not find emailAndPassword configuration in auth.ts")
|
|
1982
2075
|
);
|
|
1983
2076
|
}
|
|
1984
2077
|
} catch (error) {
|
|
1985
|
-
console.log(
|
|
2078
|
+
console.log(import_chalk20.default.red("Error adding sendResetPassword:"), error);
|
|
1986
2079
|
}
|
|
1987
2080
|
};
|
|
1988
2081
|
|
|
1989
2082
|
// script/forgetTanstack.ts
|
|
1990
|
-
var
|
|
1991
|
-
var
|
|
2083
|
+
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
2084
|
+
var import_path20 = __toESM(require("path"), 1);
|
|
1992
2085
|
var import_url18 = require("url");
|
|
1993
|
-
var
|
|
2086
|
+
var import_fs20 = __toESM(require("fs"), 1);
|
|
1994
2087
|
var import_meta18 = {};
|
|
1995
2088
|
var forgetTanstack = async () => {
|
|
1996
2089
|
try {
|
|
1997
2090
|
const projectDir = process.cwd();
|
|
1998
2091
|
const __filename = (0, import_url18.fileURLToPath)(import_meta18.url);
|
|
1999
|
-
const __dirname =
|
|
2000
|
-
const srcPath =
|
|
2001
|
-
const emailFilePath =
|
|
2002
|
-
if (!
|
|
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)) {
|
|
2003
2096
|
await email();
|
|
2004
2097
|
}
|
|
2005
|
-
const authFilePath =
|
|
2006
|
-
if (!
|
|
2007
|
-
console.log(
|
|
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."));
|
|
2008
2101
|
return;
|
|
2009
2102
|
}
|
|
2010
|
-
let content =
|
|
2103
|
+
let content = import_fs20.default.readFileSync(authFilePath, "utf8");
|
|
2011
2104
|
const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
|
|
2012
2105
|
await sendEmail({
|
|
2013
2106
|
email: user.email!,
|
|
@@ -2051,7 +2144,7 @@ var forgetTanstack = async () => {
|
|
|
2051
2144
|
content = before + `
|
|
2052
2145
|
${codeAdded}` + after;
|
|
2053
2146
|
}
|
|
2054
|
-
|
|
2147
|
+
import_fs20.default.writeFileSync(authFilePath, content, "utf8");
|
|
2055
2148
|
if (!content.includes("import { sendEmail }")) {
|
|
2056
2149
|
const lastImportIndex = content.lastIndexOf("import");
|
|
2057
2150
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -2061,99 +2154,97 @@ var forgetTanstack = async () => {
|
|
|
2061
2154
|
import { sendEmail } from "./email";
|
|
2062
2155
|
`;
|
|
2063
2156
|
content = beforeImports + newImports + afterImports;
|
|
2064
|
-
|
|
2157
|
+
import_fs20.default.writeFileSync(authFilePath, content, "utf8");
|
|
2065
2158
|
}
|
|
2066
|
-
const componentPath =
|
|
2159
|
+
const componentPath = import_path20.default.resolve(
|
|
2067
2160
|
__dirname,
|
|
2068
2161
|
"./template/email/reset-password.tsx"
|
|
2069
2162
|
);
|
|
2070
|
-
const destinationPath =
|
|
2071
|
-
if (!
|
|
2072
|
-
|
|
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 });
|
|
2073
2166
|
}
|
|
2074
|
-
const emailDestinationPath =
|
|
2167
|
+
const emailDestinationPath = import_path20.default.join(
|
|
2075
2168
|
destinationPath,
|
|
2076
2169
|
"reset-password.tsx"
|
|
2077
2170
|
);
|
|
2078
|
-
if (
|
|
2079
|
-
|
|
2171
|
+
if (import_fs20.default.existsSync(componentPath)) {
|
|
2172
|
+
import_fs20.default.copyFileSync(componentPath, emailDestinationPath);
|
|
2080
2173
|
}
|
|
2081
|
-
const forgetComponentPath =
|
|
2174
|
+
const forgetComponentPath = import_path20.default.resolve(
|
|
2082
2175
|
__dirname,
|
|
2083
2176
|
"./template/TanstackState/components/ForgetComponent.tsx"
|
|
2084
2177
|
);
|
|
2085
|
-
const componentsDestinationPath =
|
|
2178
|
+
const componentsDestinationPath = import_path20.default.join(
|
|
2086
2179
|
srcPath,
|
|
2087
2180
|
"components",
|
|
2088
2181
|
"authverse"
|
|
2089
2182
|
);
|
|
2090
|
-
if (!
|
|
2091
|
-
|
|
2183
|
+
if (!import_fs20.default.existsSync(componentsDestinationPath)) {
|
|
2184
|
+
import_fs20.default.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
2092
2185
|
}
|
|
2093
|
-
const forgetDestinationPath =
|
|
2186
|
+
const forgetDestinationPath = import_path20.default.join(
|
|
2094
2187
|
componentsDestinationPath,
|
|
2095
2188
|
"ForgetComponent.tsx"
|
|
2096
2189
|
);
|
|
2097
|
-
if (
|
|
2098
|
-
|
|
2190
|
+
if (import_fs20.default.existsSync(forgetComponentPath)) {
|
|
2191
|
+
import_fs20.default.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
2099
2192
|
}
|
|
2100
|
-
const resetComponentPath =
|
|
2193
|
+
const resetComponentPath = import_path20.default.resolve(
|
|
2101
2194
|
__dirname,
|
|
2102
2195
|
"./template/TanstackState/components/ResetComponent.tsx"
|
|
2103
2196
|
);
|
|
2104
|
-
const resetDestinationPath =
|
|
2197
|
+
const resetDestinationPath = import_path20.default.join(
|
|
2105
2198
|
componentsDestinationPath,
|
|
2106
2199
|
"ResetComponent.tsx"
|
|
2107
2200
|
);
|
|
2108
|
-
if (
|
|
2109
|
-
|
|
2201
|
+
if (import_fs20.default.existsSync(resetComponentPath)) {
|
|
2202
|
+
import_fs20.default.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
2110
2203
|
}
|
|
2111
|
-
const authTemplatePath =
|
|
2204
|
+
const authTemplatePath = import_path20.default.resolve(
|
|
2112
2205
|
__dirname,
|
|
2113
2206
|
"./template/TanstackState/routes/auth"
|
|
2114
2207
|
);
|
|
2115
|
-
const routesDestinationPath =
|
|
2116
|
-
if (!
|
|
2117
|
-
|
|
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 });
|
|
2118
2211
|
}
|
|
2119
|
-
const forgetPageDestinationPath =
|
|
2212
|
+
const forgetPageDestinationPath = import_path20.default.join(
|
|
2120
2213
|
routesDestinationPath,
|
|
2121
2214
|
"forget.tsx"
|
|
2122
2215
|
);
|
|
2123
|
-
|
|
2216
|
+
import_fs20.default.copyFileSync(
|
|
2124
2217
|
`${authTemplatePath}/forget.tsx`,
|
|
2125
2218
|
forgetPageDestinationPath
|
|
2126
2219
|
);
|
|
2127
|
-
const resetPageDestinationPath =
|
|
2220
|
+
const resetPageDestinationPath = import_path20.default.join(
|
|
2128
2221
|
routesDestinationPath,
|
|
2129
2222
|
"reset-password.tsx"
|
|
2130
2223
|
);
|
|
2131
|
-
|
|
2224
|
+
import_fs20.default.copyFileSync(
|
|
2132
2225
|
`${authTemplatePath}/reset-password.tsx`,
|
|
2133
2226
|
resetPageDestinationPath
|
|
2134
2227
|
);
|
|
2135
2228
|
console.log(
|
|
2136
|
-
|
|
2229
|
+
import_chalk21.default.green("Successfully added forget and reset-password pages")
|
|
2137
2230
|
);
|
|
2138
2231
|
} else {
|
|
2139
2232
|
console.log(
|
|
2140
|
-
|
|
2233
|
+
import_chalk21.default.red("Could not find emailAndPassword configuration in auth.ts")
|
|
2141
2234
|
);
|
|
2142
2235
|
}
|
|
2143
2236
|
} catch (error) {
|
|
2144
|
-
console.log(
|
|
2237
|
+
console.log(import_chalk21.default.red("Error adding sendResetPassword:"), error);
|
|
2145
2238
|
}
|
|
2146
2239
|
};
|
|
2147
2240
|
|
|
2148
2241
|
// cli/forget.ts
|
|
2149
|
-
var
|
|
2150
|
-
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
2156
|
-
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;
|
|
2157
2248
|
}
|
|
2158
2249
|
if (framework === "Next js") {
|
|
2159
2250
|
return forgetNext();
|
|
@@ -2164,33 +2255,31 @@ var forget = () => {
|
|
|
2164
2255
|
};
|
|
2165
2256
|
|
|
2166
2257
|
// cli/verification.ts
|
|
2167
|
-
var
|
|
2168
|
-
var import_fs25 = __toESM(require("fs"), 1);
|
|
2169
|
-
var import_path25 = __toESM(require("path"), 1);
|
|
2258
|
+
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
2170
2259
|
|
|
2171
2260
|
// script/verifyNext.ts
|
|
2172
|
-
var
|
|
2173
|
-
var
|
|
2174
|
-
var
|
|
2261
|
+
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
2262
|
+
var import_fs21 = __toESM(require("fs"), 1);
|
|
2263
|
+
var import_path21 = __toESM(require("path"), 1);
|
|
2175
2264
|
var import_url19 = require("url");
|
|
2176
2265
|
var import_meta19 = {};
|
|
2177
2266
|
var verifyNext = async () => {
|
|
2178
2267
|
try {
|
|
2179
2268
|
const projectDir = process.cwd();
|
|
2180
2269
|
const __filename = (0, import_url19.fileURLToPath)(import_meta19.url);
|
|
2181
|
-
const __dirname =
|
|
2182
|
-
const srcPath =
|
|
2183
|
-
const folder =
|
|
2184
|
-
const emailFilePath =
|
|
2185
|
-
if (!
|
|
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)) {
|
|
2186
2275
|
await email();
|
|
2187
2276
|
}
|
|
2188
|
-
const authFilePath =
|
|
2189
|
-
if (!
|
|
2190
|
-
console.log(
|
|
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."));
|
|
2191
2280
|
return;
|
|
2192
2281
|
}
|
|
2193
|
-
let content =
|
|
2282
|
+
let content = import_fs21.default.readFileSync(authFilePath, "utf8");
|
|
2194
2283
|
if (content.includes("emailAndPassword: {")) {
|
|
2195
2284
|
const start = content.indexOf("emailAndPassword: {");
|
|
2196
2285
|
let end = start;
|
|
@@ -2236,55 +2325,61 @@ var verifyNext = async () => {
|
|
|
2236
2325
|
`;
|
|
2237
2326
|
content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
|
|
2238
2327
|
}
|
|
2239
|
-
if (!content.includes("EmailVerification")) {
|
|
2328
|
+
if (!content.includes("import EmailVerification")) {
|
|
2240
2329
|
const lastImport = content.lastIndexOf("import");
|
|
2241
2330
|
const nextLine = content.indexOf("\n", lastImport) + 1;
|
|
2242
2331
|
const imports = `import EmailVerification from "@/components/email/EmailVerification";
|
|
2243
|
-
import { sendEmail } from "./email";
|
|
2244
2332
|
`;
|
|
2245
2333
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2246
2334
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2335
|
+
if (!content.includes("import { sendEmail }")) {
|
|
2336
|
+
const lastImport = content.lastIndexOf("import");
|
|
2337
|
+
const nextLine = content.indexOf("\n", lastImport) + 1;
|
|
2338
|
+
const imports = `import { sendEmail } from "./email";
|
|
2339
|
+
`;
|
|
2340
|
+
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2341
|
+
}
|
|
2342
|
+
import_fs21.default.writeFileSync(authFilePath, content, "utf8");
|
|
2343
|
+
const templatePath = import_path21.default.resolve(
|
|
2249
2344
|
__dirname,
|
|
2250
2345
|
"./template/email/EmailVerification.tsx"
|
|
2251
2346
|
);
|
|
2252
|
-
const componentsDir =
|
|
2253
|
-
if (!
|
|
2254
|
-
|
|
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 });
|
|
2255
2350
|
}
|
|
2256
|
-
const destFile =
|
|
2257
|
-
if (
|
|
2258
|
-
|
|
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);
|
|
2259
2354
|
}
|
|
2260
|
-
console.log(
|
|
2355
|
+
console.log(import_chalk23.default.green("Email verification successfully configured"));
|
|
2261
2356
|
} catch (error) {
|
|
2262
|
-
console.log(
|
|
2357
|
+
console.log(import_chalk23.default.red(String(error)));
|
|
2263
2358
|
}
|
|
2264
2359
|
};
|
|
2265
2360
|
|
|
2266
2361
|
// script/verifyTanstack.ts
|
|
2267
|
-
var
|
|
2268
|
-
var
|
|
2269
|
-
var
|
|
2362
|
+
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
2363
|
+
var import_fs22 = __toESM(require("fs"), 1);
|
|
2364
|
+
var import_path22 = __toESM(require("path"), 1);
|
|
2270
2365
|
var import_url20 = require("url");
|
|
2271
2366
|
var import_meta20 = {};
|
|
2272
2367
|
var verifyTanstack = async () => {
|
|
2273
2368
|
try {
|
|
2274
2369
|
const projectDir = process.cwd();
|
|
2275
2370
|
const __filename = (0, import_url20.fileURLToPath)(import_meta20.url);
|
|
2276
|
-
const __dirname =
|
|
2277
|
-
const srcPath =
|
|
2278
|
-
const emailFilePath =
|
|
2279
|
-
if (!
|
|
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)) {
|
|
2280
2375
|
await email();
|
|
2281
2376
|
}
|
|
2282
|
-
const authFilePath =
|
|
2283
|
-
if (!
|
|
2284
|
-
console.log(
|
|
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."));
|
|
2285
2380
|
return;
|
|
2286
2381
|
}
|
|
2287
|
-
let content =
|
|
2382
|
+
let content = import_fs22.default.readFileSync(authFilePath, "utf8");
|
|
2288
2383
|
if (content.includes("emailAndPassword: {")) {
|
|
2289
2384
|
const start = content.indexOf("emailAndPassword: {");
|
|
2290
2385
|
let end = start;
|
|
@@ -2330,43 +2425,46 @@ var verifyTanstack = async () => {
|
|
|
2330
2425
|
`;
|
|
2331
2426
|
content = content.slice(0, insertAt + 2) + emailVerificationBlock + content.slice(insertAt + 2);
|
|
2332
2427
|
}
|
|
2333
|
-
if (!content.includes("EmailVerification")) {
|
|
2428
|
+
if (!content.includes("import EmailVerification")) {
|
|
2334
2429
|
const lastImport = content.lastIndexOf("import");
|
|
2335
2430
|
const nextLine = content.indexOf("\n", lastImport) + 1;
|
|
2336
2431
|
const imports = `import EmailVerification from "@/components/email/EmailVerification";
|
|
2337
|
-
import { sendEmail } from "./email";
|
|
2338
2432
|
`;
|
|
2339
2433
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2340
2434
|
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2435
|
+
if (!content.includes("import { sendEmail }")) {
|
|
2436
|
+
const lastImport = content.lastIndexOf("import");
|
|
2437
|
+
const nextLine = content.indexOf("\n", lastImport) + 1;
|
|
2438
|
+
const imports = `import { sendEmail } from "./email";
|
|
2439
|
+
`;
|
|
2440
|
+
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
2441
|
+
}
|
|
2442
|
+
import_fs22.default.writeFileSync(authFilePath, content, "utf8");
|
|
2443
|
+
const templatePath = import_path22.default.resolve(
|
|
2343
2444
|
__dirname,
|
|
2344
2445
|
"./template/email/EmailVerification.tsx"
|
|
2345
2446
|
);
|
|
2346
|
-
const componentsDir =
|
|
2347
|
-
if (!
|
|
2348
|
-
|
|
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 });
|
|
2349
2450
|
}
|
|
2350
|
-
const destFile =
|
|
2351
|
-
if (
|
|
2352
|
-
|
|
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);
|
|
2353
2454
|
}
|
|
2354
|
-
console.log(
|
|
2455
|
+
console.log(import_chalk24.default.green("Email verification successfully configured"));
|
|
2355
2456
|
} catch (error) {
|
|
2356
|
-
console.log(
|
|
2457
|
+
console.log(import_chalk24.default.red(String(error)));
|
|
2357
2458
|
}
|
|
2358
2459
|
};
|
|
2359
2460
|
|
|
2360
2461
|
// cli/verification.ts
|
|
2361
2462
|
var verification = async () => {
|
|
2362
2463
|
try {
|
|
2363
|
-
const
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
const packageJson2 = JSON.parse(import_fs25.default.readFileSync(packageJsonPath, "utf-8"));
|
|
2368
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
2369
|
-
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;
|
|
2370
2468
|
}
|
|
2371
2469
|
if (framework === "Next js") {
|
|
2372
2470
|
await verifyNext();
|
|
@@ -2375,23 +2473,75 @@ var verification = async () => {
|
|
|
2375
2473
|
await verifyTanstack();
|
|
2376
2474
|
}
|
|
2377
2475
|
} catch (error) {
|
|
2378
|
-
console.log(
|
|
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));
|
|
2379
2517
|
}
|
|
2380
2518
|
};
|
|
2381
2519
|
|
|
2382
2520
|
// index.ts
|
|
2383
|
-
var packageJson = JSON.parse((0,
|
|
2521
|
+
var packageJson = JSON.parse((0, import_fs23.readFileSync)("./package.json", "utf8"));
|
|
2384
2522
|
var program = new import_commander.Command();
|
|
2385
2523
|
program.name("authverse").description("CLI tool for creating authverse projects").version(
|
|
2386
2524
|
packageJson.version || "1.0.0",
|
|
2387
2525
|
"-v, --version",
|
|
2388
2526
|
"display the version number"
|
|
2389
2527
|
);
|
|
2390
|
-
program.command("init").description("Select project template and configuration").action(async () => {
|
|
2391
|
-
|
|
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();
|
|
2392
2546
|
});
|
|
2393
|
-
program.command("add <provider>").description("Add a new authentication provider").action((provider) => providers({ provider }));
|
|
2394
|
-
program.command("forget").description("Forget stored configurations").action(forget);
|
|
2395
|
-
program.command("email").description("Configure email settings").action(email);
|
|
2396
|
-
program.command("verify").description("Verify authentication setup").action(verification);
|
|
2397
2547
|
program.parse(process.argv);
|