authverse 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1544 -1003
- package/dist/index.js +1517 -978
- package/dist/template/email/emailAwsSes.ts +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
6
|
// cli/init.ts
|
|
7
|
-
import
|
|
7
|
+
import inquirer4 from "inquirer";
|
|
8
8
|
|
|
9
9
|
// script/prisma.ts
|
|
10
10
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -423,24 +423,40 @@ ${CreateFolder({ srcFolder, destFolder: "proxy.ts" })}
|
|
|
423
423
|
};
|
|
424
424
|
|
|
425
425
|
// script/drizzleRun.ts
|
|
426
|
+
import chalk5 from "chalk";
|
|
427
|
+
import path5 from "path";
|
|
428
|
+
import fs5 from "fs";
|
|
429
|
+
|
|
430
|
+
// drizzle/drizzleNextSetup.ts
|
|
426
431
|
import chalk3 from "chalk";
|
|
427
432
|
import path3 from "path";
|
|
428
|
-
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
429
433
|
import fs3 from "fs";
|
|
434
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
430
435
|
import inquirer2 from "inquirer";
|
|
431
|
-
var
|
|
436
|
+
var drizzleNextSetup = async ({
|
|
437
|
+
authUi,
|
|
438
|
+
cmd,
|
|
439
|
+
projectDir
|
|
440
|
+
}) => {
|
|
432
441
|
try {
|
|
433
|
-
const projectDir = process.cwd();
|
|
434
442
|
const packageJsonPath = path3.join(projectDir, "package.json");
|
|
435
443
|
const packageJson2 = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
436
444
|
if (!packageJson2.dependencies["better-auth"]) {
|
|
437
445
|
console.log(chalk3.cyan("\n\u2699\uFE0F Initializing better auth...\n"));
|
|
438
446
|
packageManager("better-auth");
|
|
439
447
|
}
|
|
440
|
-
|
|
448
|
+
const drizzleDeps = [
|
|
449
|
+
"drizzle-orm",
|
|
450
|
+
"@neondatabase/serverless",
|
|
451
|
+
"dotenv",
|
|
452
|
+
"drizzle-kit"
|
|
453
|
+
];
|
|
454
|
+
const missingDrizzleDeps = drizzleDeps.filter((dep) => {
|
|
455
|
+
return !packageJson2.dependencies?.[dep] && !packageJson2.devDependencies?.[dep];
|
|
456
|
+
});
|
|
457
|
+
if (missingDrizzleDeps.length > 0) {
|
|
441
458
|
console.log(chalk3.cyan("\n\u2699\uFE0F Initializing drizzle...\n"));
|
|
442
|
-
packageManager("
|
|
443
|
-
packageManager("drizzle-kit", true);
|
|
459
|
+
packageManager(missingDrizzleDeps.join(" "));
|
|
444
460
|
}
|
|
445
461
|
const __filename = fileURLToPath3(import.meta.url);
|
|
446
462
|
const __dirname = path3.dirname(__filename);
|
|
@@ -598,22 +614,316 @@ ${CreateFolder({ srcFolder, destFolder: "proxy.ts" })}
|
|
|
598
614
|
)
|
|
599
615
|
);
|
|
600
616
|
}
|
|
617
|
+
} catch (error) {
|
|
618
|
+
console.error(chalk3.red("Drizzle setup failed:"), error);
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// drizzle/drizzleNextChecker.ts
|
|
623
|
+
import path4 from "path";
|
|
624
|
+
import chalk4 from "chalk";
|
|
625
|
+
import fs4 from "fs";
|
|
626
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
627
|
+
import inquirer3 from "inquirer";
|
|
628
|
+
|
|
629
|
+
// drizzle/drizzle-utils.ts
|
|
630
|
+
var extractColumnNames = (tableDef) => {
|
|
631
|
+
const columns = [];
|
|
632
|
+
const lines = tableDef.split("\n");
|
|
633
|
+
for (const line of lines) {
|
|
634
|
+
const columnMatch = line.match(/^\s*(\w+):/);
|
|
635
|
+
if (columnMatch && !line.includes("//") && !line.includes("export const")) {
|
|
636
|
+
columns.push(columnMatch[1]);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return columns;
|
|
640
|
+
};
|
|
641
|
+
var extractTableDefinition = (content, tableName) => {
|
|
642
|
+
const tableRegex = new RegExp(
|
|
643
|
+
`export const ${tableName} = pgTable\\(["']${tableName}["'][\\s\\S]*?\\n\\}\\);`,
|
|
644
|
+
"m"
|
|
645
|
+
);
|
|
646
|
+
const match = content.match(tableRegex);
|
|
647
|
+
return match ? match[0] : null;
|
|
648
|
+
};
|
|
649
|
+
var addMissingColumnsToTable = (existingTableDef, templateTableDef) => {
|
|
650
|
+
const existingColumns = extractColumnNames(existingTableDef);
|
|
651
|
+
const templateColumns = extractColumnNames(templateTableDef);
|
|
652
|
+
const missingColumns = templateColumns.filter(
|
|
653
|
+
(col) => !existingColumns.includes(col)
|
|
654
|
+
);
|
|
655
|
+
if (missingColumns.length === 0) {
|
|
656
|
+
return existingTableDef;
|
|
657
|
+
}
|
|
658
|
+
const lines = templateTableDef.split("\n");
|
|
659
|
+
const columnDefinitions = [];
|
|
660
|
+
for (const line of lines) {
|
|
661
|
+
for (const col of missingColumns) {
|
|
662
|
+
if (line.trim().startsWith(`${col}:`)) {
|
|
663
|
+
columnDefinitions.push(line);
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const existingLines = existingTableDef.split("\n");
|
|
669
|
+
const insertPosition = existingLines.length - 1;
|
|
670
|
+
for (const colDef of columnDefinitions) {
|
|
671
|
+
existingLines.splice(insertPosition, 0, ` ${colDef.trim()}`);
|
|
672
|
+
}
|
|
673
|
+
return existingLines.join("\n");
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// drizzle/drizzleNextChecker.ts
|
|
677
|
+
var drizzleNextChecker = async ({
|
|
678
|
+
authUi,
|
|
679
|
+
cmd,
|
|
680
|
+
projectDir
|
|
681
|
+
}) => {
|
|
682
|
+
try {
|
|
683
|
+
const drizzleConfigPath = path4.join(projectDir, "drizzle.config.ts");
|
|
684
|
+
if (!fs4.existsSync(drizzleConfigPath)) {
|
|
685
|
+
return await drizzleNextSetup({ authUi, cmd, projectDir });
|
|
686
|
+
}
|
|
687
|
+
const drizzleConfigContent = fs4.readFileSync(drizzleConfigPath, "utf-8");
|
|
688
|
+
const schemaMatch = drizzleConfigContent.match(/schema:\s*["'`](.*?)["'`]/);
|
|
689
|
+
const schemaPath = schemaMatch ? schemaMatch[1] : null;
|
|
690
|
+
if (!schemaPath || schemaPath === "") {
|
|
691
|
+
return await drizzleNextSetup({ authUi, cmd, projectDir });
|
|
692
|
+
}
|
|
693
|
+
const __filename = fileURLToPath4(import.meta.url);
|
|
694
|
+
const __dirname = path4.dirname(__filename);
|
|
695
|
+
const dbTemplatePath = path4.resolve(__dirname, "./template/db/schema.ts");
|
|
696
|
+
const schemaFilePath = path4.join(projectDir, schemaPath);
|
|
697
|
+
if (!fs4.existsSync(schemaFilePath)) {
|
|
698
|
+
const dbFolder = path4.dirname(schemaFilePath);
|
|
699
|
+
if (!fs4.existsSync(dbFolder)) {
|
|
700
|
+
fs4.mkdirSync(dbFolder, { recursive: true });
|
|
701
|
+
}
|
|
702
|
+
fs4.copyFileSync(dbTemplatePath, schemaFilePath);
|
|
703
|
+
} else {
|
|
704
|
+
let schemaFileContent = fs4.readFileSync(schemaFilePath, "utf-8");
|
|
705
|
+
const dbTemplateContent = fs4.readFileSync(dbTemplatePath, "utf-8");
|
|
706
|
+
const requiredTables = ["user", "session", "account", "verification"];
|
|
707
|
+
let needsUpdate = false;
|
|
708
|
+
let updatedSchemaContent = schemaFileContent;
|
|
709
|
+
for (const table of requiredTables) {
|
|
710
|
+
const existingTable = extractTableDefinition(
|
|
711
|
+
updatedSchemaContent,
|
|
712
|
+
table
|
|
713
|
+
);
|
|
714
|
+
const templateTable = extractTableDefinition(dbTemplateContent, table);
|
|
715
|
+
if (!existingTable && templateTable) {
|
|
716
|
+
const schemaExportIndex = updatedSchemaContent.indexOf(
|
|
717
|
+
"export const schema ="
|
|
718
|
+
);
|
|
719
|
+
if (schemaExportIndex !== -1) {
|
|
720
|
+
updatedSchemaContent = updatedSchemaContent.slice(0, schemaExportIndex) + templateTable + "\n\n" + updatedSchemaContent.slice(schemaExportIndex);
|
|
721
|
+
} else {
|
|
722
|
+
updatedSchemaContent += "\n\n" + templateTable;
|
|
723
|
+
}
|
|
724
|
+
needsUpdate = true;
|
|
725
|
+
} else if (existingTable && templateTable) {
|
|
726
|
+
const existingColumns = extractColumnNames(existingTable);
|
|
727
|
+
const templateColumns = extractColumnNames(templateTable);
|
|
728
|
+
const missingColumns = templateColumns.filter(
|
|
729
|
+
(col) => !existingColumns.includes(col)
|
|
730
|
+
);
|
|
731
|
+
if (missingColumns.length > 0) {
|
|
732
|
+
const updatedTable = addMissingColumnsToTable(
|
|
733
|
+
existingTable,
|
|
734
|
+
templateTable
|
|
735
|
+
);
|
|
736
|
+
updatedSchemaContent = updatedSchemaContent.replace(
|
|
737
|
+
existingTable,
|
|
738
|
+
updatedTable
|
|
739
|
+
);
|
|
740
|
+
needsUpdate = true;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (needsUpdate) {
|
|
745
|
+
const schemaExportRegex = /export const schema = \{([\s\S]*?)\};/;
|
|
746
|
+
const schemaMatch2 = updatedSchemaContent.match(schemaExportRegex);
|
|
747
|
+
if (schemaMatch2) {
|
|
748
|
+
let currentSchemaContent = schemaMatch2[1];
|
|
749
|
+
for (const table of requiredTables) {
|
|
750
|
+
if (!currentSchemaContent.includes(`${table},`)) {
|
|
751
|
+
const lines = currentSchemaContent.split("\n");
|
|
752
|
+
const lastNonEmptyLine = lines.length - 1;
|
|
753
|
+
if (lines[lastNonEmptyLine].trim() === "}") {
|
|
754
|
+
lines[lastNonEmptyLine] = ` ${table},
|
|
755
|
+
${lines[lastNonEmptyLine]}`;
|
|
756
|
+
} else {
|
|
757
|
+
lines.push(` ${table},`);
|
|
758
|
+
}
|
|
759
|
+
currentSchemaContent = lines.join("\n");
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
updatedSchemaContent = updatedSchemaContent.replace(
|
|
763
|
+
schemaExportRegex,
|
|
764
|
+
`export const schema = {${currentSchemaContent}};`
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
fs4.writeFileSync(schemaFilePath, updatedSchemaContent);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
const packageJsonPath = path4.join(projectDir, "package.json");
|
|
771
|
+
const packageJson2 = JSON.parse(fs4.readFileSync(packageJsonPath, "utf-8"));
|
|
772
|
+
if (!packageJson2.dependencies["better-auth"]) {
|
|
773
|
+
console.log(chalk4.cyan("\n\u2699\uFE0F Initializing better auth...\n"));
|
|
774
|
+
packageManager("better-auth");
|
|
775
|
+
}
|
|
776
|
+
const drizzleDeps = [
|
|
777
|
+
"drizzle-orm",
|
|
778
|
+
"@neondatabase/serverless",
|
|
779
|
+
"dotenv",
|
|
780
|
+
"drizzle-kit"
|
|
781
|
+
];
|
|
782
|
+
const missingDrizzleDeps = drizzleDeps.filter((dep) => {
|
|
783
|
+
return !packageJson2.dependencies?.[dep] && !packageJson2.devDependencies?.[dep];
|
|
784
|
+
});
|
|
785
|
+
if (missingDrizzleDeps.length > 0) {
|
|
786
|
+
console.log(chalk4.cyan("\n\u2699\uFE0F Initializing drizzle...\n"));
|
|
787
|
+
packageManager(missingDrizzleDeps.join(" "));
|
|
788
|
+
}
|
|
789
|
+
const envPath = path4.join(projectDir, ".env");
|
|
790
|
+
if (!fs4.existsSync(envPath)) {
|
|
791
|
+
fs4.writeFileSync(envPath, "DATABASE_URL=\n");
|
|
792
|
+
}
|
|
793
|
+
const secret = await GenerateSecret();
|
|
794
|
+
const envContent = fs4.readFileSync(envPath, "utf-8");
|
|
795
|
+
if (!envContent.includes("BETTER_AUTH_SECRET")) {
|
|
796
|
+
fs4.appendFileSync(envPath, `
|
|
797
|
+
|
|
798
|
+
BETTER_AUTH_SECRET=${secret}`);
|
|
799
|
+
}
|
|
800
|
+
if (!envContent.includes("BETTER_AUTH_URL")) {
|
|
801
|
+
fs4.appendFileSync(envPath, `
|
|
802
|
+
BETTER_AUTH_URL=http://localhost:3000
|
|
803
|
+
`);
|
|
804
|
+
}
|
|
805
|
+
const srcFolder = fs4.existsSync(path4.join(projectDir, "src")) ? "src" : "";
|
|
806
|
+
const libPath = path4.join(projectDir, srcFolder, "lib");
|
|
807
|
+
if (!fs4.existsSync(libPath)) {
|
|
808
|
+
fs4.mkdirSync(libPath, { recursive: true });
|
|
809
|
+
}
|
|
810
|
+
const authPath = path4.join(libPath, "auth.ts");
|
|
811
|
+
const authClientPath = path4.join(libPath, "auth-client.ts");
|
|
812
|
+
if (fs4.existsSync(authPath) || fs4.existsSync(authClientPath)) {
|
|
813
|
+
const answers = await inquirer3.prompt([
|
|
814
|
+
{
|
|
815
|
+
type: "confirm",
|
|
816
|
+
name: "overwrite",
|
|
817
|
+
message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
|
|
818
|
+
default: false
|
|
819
|
+
}
|
|
820
|
+
]);
|
|
821
|
+
if (answers.overwrite) {
|
|
822
|
+
const authTemplatePath = path4.resolve(
|
|
823
|
+
__dirname,
|
|
824
|
+
"./template/lib/auth-drizzle.ts"
|
|
825
|
+
);
|
|
826
|
+
const authDestinationPath = path4.join(libPath, "auth.ts");
|
|
827
|
+
fs4.copyFileSync(authTemplatePath, authDestinationPath);
|
|
828
|
+
const authClientTemplatePath = path4.resolve(
|
|
829
|
+
__dirname,
|
|
830
|
+
"./template/lib/auth-client.ts"
|
|
831
|
+
);
|
|
832
|
+
const authClientDestinationPath = path4.join(libPath, "auth-client.ts");
|
|
833
|
+
fs4.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
834
|
+
}
|
|
835
|
+
} else {
|
|
836
|
+
const authTemplatePath = path4.resolve(
|
|
837
|
+
__dirname,
|
|
838
|
+
"./template/lib/auth-drizzle.ts"
|
|
839
|
+
);
|
|
840
|
+
const authDestinationPath = path4.join(libPath, "auth.ts");
|
|
841
|
+
fs4.copyFileSync(authTemplatePath, authDestinationPath);
|
|
842
|
+
const authClientTemplatePath = path4.resolve(
|
|
843
|
+
__dirname,
|
|
844
|
+
"./template/lib/auth-client.ts"
|
|
845
|
+
);
|
|
846
|
+
const authClientDestinationPath = path4.join(libPath, "auth-client.ts");
|
|
847
|
+
fs4.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
848
|
+
}
|
|
849
|
+
const routeTemplatePath = path4.resolve(
|
|
850
|
+
__dirname,
|
|
851
|
+
"./template/api/route.ts"
|
|
852
|
+
);
|
|
853
|
+
const routeDestinationDir = path4.join(
|
|
854
|
+
projectDir,
|
|
855
|
+
srcFolder,
|
|
856
|
+
"app",
|
|
857
|
+
"api",
|
|
858
|
+
"auth",
|
|
859
|
+
"[...all]"
|
|
860
|
+
);
|
|
861
|
+
if (!fs4.existsSync(routeDestinationDir)) {
|
|
862
|
+
fs4.mkdirSync(routeDestinationDir, { recursive: true });
|
|
863
|
+
}
|
|
864
|
+
const routeDestinationPath = path4.join(routeDestinationDir, "route.ts");
|
|
865
|
+
fs4.copyFileSync(routeTemplatePath, routeDestinationPath);
|
|
866
|
+
const proxyTemplatePath = path4.resolve(
|
|
867
|
+
__dirname,
|
|
868
|
+
"./template/proxy/proxy.ts"
|
|
869
|
+
);
|
|
870
|
+
const proxyDestinationDir = path4.join(projectDir, srcFolder);
|
|
871
|
+
const proxyDestinationPath = path4.join(proxyDestinationDir, "proxy.ts");
|
|
872
|
+
fs4.copyFileSync(proxyTemplatePath, proxyDestinationPath);
|
|
873
|
+
if (authUi) {
|
|
874
|
+
await authUiRun({
|
|
875
|
+
folder: srcFolder,
|
|
876
|
+
packageJson: projectDir,
|
|
877
|
+
cmd,
|
|
878
|
+
database: "drizzle"
|
|
879
|
+
});
|
|
880
|
+
} else {
|
|
881
|
+
console.log(chalk4.green("\nCompleted installation successfully"));
|
|
882
|
+
console.log(chalk4.cyan("\nInstall Package:"));
|
|
883
|
+
console.log(chalk4.white(`\u2022 drizzle schema
|
|
884
|
+
\u2022 better-auth`));
|
|
885
|
+
console.log(chalk4.cyan("\nFiles created:"));
|
|
886
|
+
console.log(
|
|
887
|
+
chalk4.white(
|
|
888
|
+
`${CreateFolder({ srcFolder, destFolder: "lib/auth.ts" })}
|
|
889
|
+
${CreateFolder({ srcFolder, destFolder: "lib/auth-client.ts" })}
|
|
890
|
+
${CreateFolder({ srcFolder, destFolder: "app/api/auth/[...all]/route.ts" })}
|
|
891
|
+
${CreateFolder({ srcFolder, destFolder: "proxy.ts" })}
|
|
892
|
+
`
|
|
893
|
+
)
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
} catch (error) {
|
|
897
|
+
console.error(chalk4.red("Error checking Drizzle setup:"), error);
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// script/drizzleRun.ts
|
|
902
|
+
var drizzleRun = async ({ authUi, cmd }) => {
|
|
903
|
+
try {
|
|
904
|
+
const projectDir = process.cwd();
|
|
905
|
+
const drizzleConfigPath = path5.join(projectDir, "drizzle.config.ts");
|
|
906
|
+
if (fs5.existsSync(drizzleConfigPath)) {
|
|
907
|
+
await drizzleNextChecker({ authUi, cmd, projectDir });
|
|
908
|
+
} else {
|
|
909
|
+
await drizzleNextSetup({ authUi, cmd, projectDir });
|
|
910
|
+
}
|
|
601
911
|
} catch (err) {
|
|
602
|
-
console.error(
|
|
912
|
+
console.error(chalk5.red("Drizzle setup failed:"), err);
|
|
603
913
|
}
|
|
604
914
|
};
|
|
605
915
|
|
|
606
916
|
// script/prismaRunTanstackStart.ts
|
|
607
|
-
import
|
|
608
|
-
import
|
|
609
|
-
import { fileURLToPath as
|
|
610
|
-
import
|
|
917
|
+
import chalk7 from "chalk";
|
|
918
|
+
import path7 from "path";
|
|
919
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
920
|
+
import fs7 from "fs";
|
|
611
921
|
|
|
612
922
|
// script/authUiTanstackState.ts
|
|
613
|
-
import
|
|
614
|
-
import { fileURLToPath as
|
|
615
|
-
import
|
|
616
|
-
import
|
|
923
|
+
import chalk6 from "chalk";
|
|
924
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
925
|
+
import path6 from "path";
|
|
926
|
+
import fs6 from "fs";
|
|
617
927
|
var shadcnComponents2 = [
|
|
618
928
|
"button.tsx",
|
|
619
929
|
"card.tsx",
|
|
@@ -630,10 +940,10 @@ var authUiTanstackState = async ({
|
|
|
630
940
|
}) => {
|
|
631
941
|
try {
|
|
632
942
|
const projectDir = process.cwd();
|
|
633
|
-
const shadcnPath =
|
|
634
|
-
const shadcnConfigPath =
|
|
635
|
-
if (!
|
|
636
|
-
console.log(
|
|
943
|
+
const shadcnPath = path6.join(projectDir, "src", "components", "ui");
|
|
944
|
+
const shadcnConfigPath = path6.join(projectDir, "components.json");
|
|
945
|
+
if (!fs6.existsSync(shadcnPath) || !fs6.existsSync(shadcnConfigPath)) {
|
|
946
|
+
console.log(chalk6.yellow("\n Installing shadcn ui Components\n"));
|
|
637
947
|
if (cmd == true) {
|
|
638
948
|
runCommand("shadcn@latest init");
|
|
639
949
|
runCommand("shadcn@latest add button sonner card field input");
|
|
@@ -641,60 +951,60 @@ var authUiTanstackState = async ({
|
|
|
641
951
|
runCommand("shadcn@latest add button sonner card field input");
|
|
642
952
|
}
|
|
643
953
|
}
|
|
644
|
-
const shadcnFiles =
|
|
954
|
+
const shadcnFiles = fs6.readdirSync(shadcnPath);
|
|
645
955
|
const missingComponents = shadcnComponents2.filter(
|
|
646
956
|
(component) => !shadcnFiles.includes(component)
|
|
647
957
|
);
|
|
648
958
|
if (missingComponents.length > 0) {
|
|
649
|
-
console.log(
|
|
959
|
+
console.log(chalk6.yellow("\n Installing shadcn ui Components\n"));
|
|
650
960
|
const install = missingComponents.map((components) => components.split(".")[0]).join(" ");
|
|
651
961
|
runCommand(`shadcn@latest add ${install}`);
|
|
652
962
|
}
|
|
653
963
|
if (!packageJson2.dependencies?.["@tanstack/react-form"] || !packageJson2.dependencies?.["zod"]) {
|
|
654
964
|
packageManager("@tanstack/react-form zod");
|
|
655
965
|
}
|
|
656
|
-
const __filename =
|
|
657
|
-
const __dirname =
|
|
658
|
-
const srcPath =
|
|
659
|
-
const componentPath =
|
|
966
|
+
const __filename = fileURLToPath5(import.meta.url);
|
|
967
|
+
const __dirname = path6.dirname(__filename);
|
|
968
|
+
const srcPath = path6.join(projectDir, "src");
|
|
969
|
+
const componentPath = path6.resolve(
|
|
660
970
|
__dirname,
|
|
661
971
|
"./template/TanstackStart/components"
|
|
662
972
|
);
|
|
663
|
-
const authversePathComponents =
|
|
973
|
+
const authversePathComponents = path6.join(
|
|
664
974
|
srcPath,
|
|
665
975
|
"components",
|
|
666
976
|
"authverse"
|
|
667
977
|
);
|
|
668
|
-
if (!
|
|
669
|
-
|
|
978
|
+
if (!fs6.existsSync(authversePathComponents)) {
|
|
979
|
+
fs6.mkdirSync(authversePathComponents, { recursive: true });
|
|
670
980
|
}
|
|
671
|
-
|
|
981
|
+
fs6.copyFileSync(
|
|
672
982
|
`${componentPath}/LoginComponent.tsx`,
|
|
673
|
-
|
|
983
|
+
path6.join(authversePathComponents, "LoginComponent.tsx")
|
|
674
984
|
);
|
|
675
|
-
|
|
985
|
+
fs6.copyFileSync(
|
|
676
986
|
`${componentPath}/SingUpComponent.tsx`,
|
|
677
|
-
|
|
987
|
+
path6.join(authversePathComponents, "SingUpComponent.tsx")
|
|
678
988
|
);
|
|
679
|
-
const pageRoutesPath =
|
|
680
|
-
if (!
|
|
681
|
-
|
|
989
|
+
const pageRoutesPath = path6.join(`${srcPath}/routes`, "auth");
|
|
990
|
+
if (!fs6.existsSync(pageRoutesPath)) {
|
|
991
|
+
fs6.mkdirSync(pageRoutesPath, { recursive: true });
|
|
682
992
|
}
|
|
683
|
-
const templateRoutesPage =
|
|
993
|
+
const templateRoutesPage = path6.resolve(
|
|
684
994
|
__dirname,
|
|
685
995
|
"./template/TanstackStart/routes/auth"
|
|
686
996
|
);
|
|
687
|
-
|
|
997
|
+
fs6.copyFileSync(
|
|
688
998
|
`${templateRoutesPage}/login.tsx`,
|
|
689
|
-
|
|
999
|
+
path6.join(pageRoutesPath, "login.tsx")
|
|
690
1000
|
);
|
|
691
|
-
|
|
1001
|
+
fs6.copyFileSync(
|
|
692
1002
|
`${templateRoutesPage}/signup.tsx`,
|
|
693
|
-
|
|
1003
|
+
path6.join(pageRoutesPath, "signup.tsx")
|
|
694
1004
|
);
|
|
695
|
-
const rootPath =
|
|
696
|
-
if (
|
|
697
|
-
let rootContent =
|
|
1005
|
+
const rootPath = path6.join(projectDir, "src/routes", "__root.tsx");
|
|
1006
|
+
if (fs6.existsSync(rootPath)) {
|
|
1007
|
+
let rootContent = fs6.readFileSync(rootPath, "utf-8");
|
|
698
1008
|
if (!rootContent.includes("Toaster")) {
|
|
699
1009
|
rootContent = `import { Toaster } from "@/components/ui/sonner";
|
|
700
1010
|
${rootContent}`;
|
|
@@ -705,15 +1015,15 @@ ${rootContent}`;
|
|
|
705
1015
|
" <Toaster />\n </body>"
|
|
706
1016
|
);
|
|
707
1017
|
}
|
|
708
|
-
|
|
1018
|
+
fs6.writeFileSync(rootPath, rootContent, "utf-8");
|
|
709
1019
|
}
|
|
710
|
-
console.log(
|
|
711
|
-
console.log(
|
|
712
|
-
console.log(
|
|
1020
|
+
console.log(chalk6.green("\nCompleted installation successfully"));
|
|
1021
|
+
console.log(chalk6.cyan("\nInstall Package:"));
|
|
1022
|
+
console.log(chalk6.white(`\u2022 ${database} schema
|
|
713
1023
|
\u2022 better-auth`));
|
|
714
|
-
console.log(
|
|
1024
|
+
console.log(chalk6.cyan("\nFiles created:"));
|
|
715
1025
|
console.log(
|
|
716
|
-
|
|
1026
|
+
chalk6.white(
|
|
717
1027
|
`\u2022 src/lib/auth.ts
|
|
718
1028
|
\u2022 src/lib/auth-client.ts
|
|
719
1029
|
\u2022 src/app/api/auth/[...all]/route.ts
|
|
@@ -727,7 +1037,7 @@ ${rootContent}`;
|
|
|
727
1037
|
)
|
|
728
1038
|
);
|
|
729
1039
|
} catch (error) {
|
|
730
|
-
console.log(
|
|
1040
|
+
console.log(chalk6.red("Auth Ui Tanstack State Error: ", error));
|
|
731
1041
|
}
|
|
732
1042
|
};
|
|
733
1043
|
|
|
@@ -739,12 +1049,12 @@ var prismaRunTanstackStart = async ({
|
|
|
739
1049
|
}) => {
|
|
740
1050
|
try {
|
|
741
1051
|
const projectDir = process.cwd();
|
|
742
|
-
const __filename =
|
|
743
|
-
const __dirname =
|
|
744
|
-
const packageJsonPath =
|
|
745
|
-
const packageJson2 = JSON.parse(
|
|
1052
|
+
const __filename = fileURLToPath6(import.meta.url);
|
|
1053
|
+
const __dirname = path7.dirname(__filename);
|
|
1054
|
+
const packageJsonPath = path7.join(projectDir, "package.json");
|
|
1055
|
+
const packageJson2 = JSON.parse(fs7.readFileSync(packageJsonPath, "utf-8"));
|
|
746
1056
|
if (!packageJson2.devDependencies?.prisma || !packageJson2.dependencies?.["@prisma/client"]) {
|
|
747
|
-
console.log(
|
|
1057
|
+
console.log(chalk7.cyan("\n\u2699\uFE0F Initializing Prisma...\n"));
|
|
748
1058
|
if (database !== "Mongodb") {
|
|
749
1059
|
packageManager("prisma", true);
|
|
750
1060
|
packageManager("@prisma/client");
|
|
@@ -759,98 +1069,98 @@ var prismaRunTanstackStart = async ({
|
|
|
759
1069
|
packageManager("@prisma/client@6.19.0");
|
|
760
1070
|
}
|
|
761
1071
|
}
|
|
762
|
-
const prismaDir =
|
|
763
|
-
if (!
|
|
764
|
-
console.log(
|
|
1072
|
+
const prismaDir = path7.join(projectDir, "prisma");
|
|
1073
|
+
if (!fs7.existsSync(prismaDir)) {
|
|
1074
|
+
console.log(chalk7.yellow("\n\u2699\uFE0F Initializing Prisma...\n"));
|
|
765
1075
|
runCommand("prisma init");
|
|
766
|
-
const templatePath =
|
|
1076
|
+
const templatePath = path7.resolve(
|
|
767
1077
|
__dirname,
|
|
768
1078
|
`./template/prisma/${database}/schema.prisma`
|
|
769
1079
|
);
|
|
770
|
-
if (!
|
|
771
|
-
|
|
1080
|
+
if (!fs7.existsSync(prismaDir)) {
|
|
1081
|
+
fs7.mkdirSync(prismaDir, { recursive: true });
|
|
772
1082
|
}
|
|
773
|
-
const destinationPath =
|
|
774
|
-
|
|
1083
|
+
const destinationPath = path7.join(prismaDir, "schema.prisma");
|
|
1084
|
+
fs7.copyFileSync(templatePath, destinationPath);
|
|
775
1085
|
if (database === "Mongodb") {
|
|
776
|
-
const prismaConfigPath =
|
|
1086
|
+
const prismaConfigPath = path7.resolve(
|
|
777
1087
|
__dirname,
|
|
778
1088
|
`./template/config/prisma.config.ts`
|
|
779
1089
|
);
|
|
780
|
-
const prismaConfigDestinationPath =
|
|
781
|
-
|
|
1090
|
+
const prismaConfigDestinationPath = path7.join("", "prisma.config.ts");
|
|
1091
|
+
fs7.copyFileSync(prismaConfigPath, prismaConfigDestinationPath);
|
|
782
1092
|
}
|
|
783
1093
|
} else {
|
|
784
|
-
const schemaPath =
|
|
785
|
-
const schemaContent =
|
|
1094
|
+
const schemaPath = path7.join(prismaDir, "schema.prisma");
|
|
1095
|
+
const schemaContent = fs7.readFileSync(schemaPath, "utf-8");
|
|
786
1096
|
if (!schemaContent.includes("User") || !schemaContent.includes("Session") || !schemaContent.includes("Account") || !schemaContent.includes("Verification")) {
|
|
787
|
-
const templatePath =
|
|
1097
|
+
const templatePath = path7.resolve(
|
|
788
1098
|
__dirname,
|
|
789
1099
|
`./template/prisma/${database}/schema.prisma_copy`
|
|
790
1100
|
);
|
|
791
|
-
|
|
792
|
-
|
|
1101
|
+
fs7.appendFileSync(schemaPath, "\n");
|
|
1102
|
+
fs7.appendFileSync(schemaPath, fs7.readFileSync(templatePath));
|
|
793
1103
|
}
|
|
794
1104
|
}
|
|
795
1105
|
if (!packageJson2.dependencies?.["better-auth"]) {
|
|
796
|
-
console.log(
|
|
1106
|
+
console.log(chalk7.yellow("\n\u2699\uFE0F Initializing better-auth...\n"));
|
|
797
1107
|
packageManager("better-auth");
|
|
798
1108
|
}
|
|
799
1109
|
const secret = await GenerateSecret();
|
|
800
|
-
const envPath =
|
|
801
|
-
const envContent =
|
|
1110
|
+
const envPath = path7.join(projectDir, ".env");
|
|
1111
|
+
const envContent = fs7.readFileSync(envPath, "utf-8");
|
|
802
1112
|
if (!envContent.includes("BETTER_AUTH_SECRET")) {
|
|
803
|
-
|
|
1113
|
+
fs7.appendFileSync(envPath, `
|
|
804
1114
|
|
|
805
1115
|
BETTER_AUTH_SECRET=${secret}`);
|
|
806
1116
|
}
|
|
807
1117
|
if (!envContent.includes("BETTER_AUTH_URL")) {
|
|
808
|
-
|
|
1118
|
+
fs7.appendFileSync(envPath, `
|
|
809
1119
|
BETTER_AUTH_URL=http://localhost:3000
|
|
810
1120
|
`);
|
|
811
1121
|
}
|
|
812
|
-
const srcPath =
|
|
813
|
-
const libPath =
|
|
814
|
-
if (!
|
|
815
|
-
|
|
1122
|
+
const srcPath = path7.join(projectDir, "src");
|
|
1123
|
+
const libPath = path7.join(srcPath, "lib");
|
|
1124
|
+
if (!fs7.existsSync(libPath)) {
|
|
1125
|
+
fs7.mkdirSync(libPath, { recursive: true });
|
|
816
1126
|
}
|
|
817
|
-
const authTemplatePath =
|
|
1127
|
+
const authTemplatePath = path7.resolve(
|
|
818
1128
|
__dirname,
|
|
819
1129
|
`./template/TanstackStart/lib/${database}/auth.ts`
|
|
820
1130
|
);
|
|
821
|
-
const authDestinationPath =
|
|
822
|
-
|
|
823
|
-
const authClientTemplatePath =
|
|
1131
|
+
const authDestinationPath = path7.join(libPath, "auth.ts");
|
|
1132
|
+
fs7.copyFileSync(authTemplatePath, authDestinationPath);
|
|
1133
|
+
const authClientTemplatePath = path7.resolve(
|
|
824
1134
|
__dirname,
|
|
825
1135
|
"./template/lib/auth-client.ts"
|
|
826
1136
|
);
|
|
827
|
-
const authClientDestinationPath =
|
|
828
|
-
|
|
829
|
-
const middlewarePath =
|
|
830
|
-
if (!
|
|
831
|
-
|
|
1137
|
+
const authClientDestinationPath = path7.join(libPath, "auth-client.ts");
|
|
1138
|
+
fs7.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
1139
|
+
const middlewarePath = path7.join(srcPath, "middleware");
|
|
1140
|
+
if (!fs7.existsSync(middlewarePath)) {
|
|
1141
|
+
fs7.mkdirSync(middlewarePath, { recursive: true });
|
|
832
1142
|
}
|
|
833
|
-
const authMiddlewareTemplatePath =
|
|
1143
|
+
const authMiddlewareTemplatePath = path7.resolve(
|
|
834
1144
|
__dirname,
|
|
835
1145
|
`./template/TanstackStart/middleware/auth.ts`
|
|
836
1146
|
);
|
|
837
|
-
const authMiddlewareDestinationPath =
|
|
838
|
-
|
|
839
|
-
const fileRouteTemplatePath =
|
|
1147
|
+
const authMiddlewareDestinationPath = path7.join(middlewarePath, "auth.ts");
|
|
1148
|
+
fs7.copyFileSync(authMiddlewareTemplatePath, authMiddlewareDestinationPath);
|
|
1149
|
+
const fileRouteTemplatePath = path7.resolve(
|
|
840
1150
|
__dirname,
|
|
841
1151
|
`./template/TanstackStart/routes/$.ts`
|
|
842
1152
|
);
|
|
843
|
-
const fileRouteDestinationPath =
|
|
1153
|
+
const fileRouteDestinationPath = path7.join(
|
|
844
1154
|
srcPath,
|
|
845
1155
|
"routes",
|
|
846
1156
|
"api",
|
|
847
1157
|
"auth"
|
|
848
1158
|
);
|
|
849
|
-
if (!
|
|
850
|
-
|
|
1159
|
+
if (!fs7.existsSync(fileRouteDestinationPath)) {
|
|
1160
|
+
fs7.mkdirSync(fileRouteDestinationPath, { recursive: true });
|
|
851
1161
|
}
|
|
852
|
-
const apiDestinationPath =
|
|
853
|
-
|
|
1162
|
+
const apiDestinationPath = path7.join(fileRouteDestinationPath, "$.ts");
|
|
1163
|
+
fs7.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
|
|
854
1164
|
if (authUi) {
|
|
855
1165
|
await authUiTanstackState({
|
|
856
1166
|
packageJson: packageJson2,
|
|
@@ -858,13 +1168,13 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
858
1168
|
database: "prisma"
|
|
859
1169
|
});
|
|
860
1170
|
} else {
|
|
861
|
-
console.log(
|
|
862
|
-
console.log(
|
|
863
|
-
console.log(
|
|
1171
|
+
console.log(chalk7.green("\nCompleted installation successfully"));
|
|
1172
|
+
console.log(chalk7.cyan("\nInstall Package:"));
|
|
1173
|
+
console.log(chalk7.white(`\u2022 prisma ${database} schema
|
|
864
1174
|
\u2022 better-auth`));
|
|
865
|
-
console.log(
|
|
1175
|
+
console.log(chalk7.cyan("\nFiles created:"));
|
|
866
1176
|
console.log(
|
|
867
|
-
|
|
1177
|
+
chalk7.white(
|
|
868
1178
|
`\u2022 src/lib/auth.ts
|
|
869
1179
|
\u2022 src/lib/auth-client.ts
|
|
870
1180
|
\u2022 src/app/api/auth/[...all]/route.ts
|
|
@@ -874,110 +1184,115 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
874
1184
|
);
|
|
875
1185
|
}
|
|
876
1186
|
} catch (err) {
|
|
877
|
-
console.log(
|
|
1187
|
+
console.log(chalk7.red("Prisma Run Tanstack State Error: ", err));
|
|
878
1188
|
}
|
|
879
1189
|
};
|
|
880
1190
|
|
|
881
1191
|
// script/drizzleRunTanstackStart.ts
|
|
882
|
-
import
|
|
883
|
-
import
|
|
884
|
-
import
|
|
885
|
-
|
|
886
|
-
|
|
1192
|
+
import chalk10 from "chalk";
|
|
1193
|
+
import path10 from "path";
|
|
1194
|
+
import fs10 from "fs";
|
|
1195
|
+
|
|
1196
|
+
// drizzle/drizzleTanstackSetup.ts
|
|
1197
|
+
import chalk8 from "chalk";
|
|
1198
|
+
import path8 from "path";
|
|
1199
|
+
import fs8 from "fs";
|
|
1200
|
+
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
1201
|
+
var drizzleTanstackSetup = async ({
|
|
887
1202
|
authUi,
|
|
888
|
-
cmd
|
|
1203
|
+
cmd,
|
|
1204
|
+
projectDir
|
|
889
1205
|
}) => {
|
|
890
1206
|
try {
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
const packageJson2 = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
|
|
1207
|
+
const packageJsonPath = path8.join(projectDir, "package.json");
|
|
1208
|
+
const packageJson2 = JSON.parse(fs8.readFileSync(packageJsonPath, "utf-8"));
|
|
894
1209
|
if (!packageJson2.dependencies["better-auth"]) {
|
|
895
|
-
console.log(
|
|
1210
|
+
console.log(chalk8.cyan("\n\u2699\uFE0F Initializing better auth...\n"));
|
|
896
1211
|
packageManager("better-auth");
|
|
897
1212
|
}
|
|
898
1213
|
if (!packageJson2.dependencies["drizzle-orm"] && !packageJson2.dependencies["drizzle-orm"] && !packageJson2.dependencies["drizzle-kit"] && !packageJson2.devDependencies["drizzle-kit"]) {
|
|
899
|
-
console.log(
|
|
1214
|
+
console.log(chalk8.cyan("\n\u2699\uFE0F Initializing drizzle...\n"));
|
|
900
1215
|
packageManager("drizzle-orm @neondatabase/serverless dotenv");
|
|
901
1216
|
packageManager("drizzle-kit", true);
|
|
902
1217
|
}
|
|
903
|
-
const __filename =
|
|
904
|
-
const __dirname =
|
|
905
|
-
const envPath =
|
|
906
|
-
if (!
|
|
907
|
-
|
|
1218
|
+
const __filename = fileURLToPath7(import.meta.url);
|
|
1219
|
+
const __dirname = path8.dirname(__filename);
|
|
1220
|
+
const envPath = path8.join(projectDir, ".env");
|
|
1221
|
+
if (!fs8.existsSync(envPath)) {
|
|
1222
|
+
fs8.writeFileSync(envPath, "DATABASE_URL=\n");
|
|
908
1223
|
}
|
|
909
1224
|
const secret = await GenerateSecret();
|
|
910
|
-
const envContent =
|
|
1225
|
+
const envContent = fs8.readFileSync(envPath, "utf-8");
|
|
911
1226
|
if (!envContent.includes("BETTER_AUTH_SECRET")) {
|
|
912
|
-
|
|
1227
|
+
fs8.appendFileSync(envPath, `
|
|
913
1228
|
|
|
914
1229
|
BETTER_AUTH_SECRET=${secret}`);
|
|
915
1230
|
}
|
|
916
1231
|
if (!envContent.includes("BETTER_AUTH_URL")) {
|
|
917
|
-
|
|
1232
|
+
fs8.appendFileSync(envPath, `
|
|
918
1233
|
BETTER_AUTH_URL=http://localhost:3000
|
|
919
1234
|
`);
|
|
920
1235
|
}
|
|
921
|
-
const srcPath =
|
|
922
|
-
const libPath =
|
|
923
|
-
if (!
|
|
924
|
-
|
|
1236
|
+
const srcPath = path8.join(projectDir, "src");
|
|
1237
|
+
const libPath = path8.join(srcPath, "lib");
|
|
1238
|
+
if (!fs8.existsSync(libPath)) {
|
|
1239
|
+
fs8.mkdirSync(libPath, { recursive: true });
|
|
925
1240
|
}
|
|
926
|
-
const authTemplatePath =
|
|
1241
|
+
const authTemplatePath = path8.resolve(
|
|
927
1242
|
__dirname,
|
|
928
1243
|
"./template/TanstackStart/lib/auth-drizzle.ts"
|
|
929
1244
|
);
|
|
930
|
-
const authDestinationPath =
|
|
931
|
-
|
|
932
|
-
const authClientTemplatePath =
|
|
1245
|
+
const authDestinationPath = path8.join(libPath, "auth.ts");
|
|
1246
|
+
fs8.copyFileSync(authTemplatePath, authDestinationPath);
|
|
1247
|
+
const authClientTemplatePath = path8.resolve(
|
|
933
1248
|
__dirname,
|
|
934
1249
|
"./template/lib/auth-client.ts"
|
|
935
1250
|
);
|
|
936
|
-
const authClientDestinationPath =
|
|
937
|
-
|
|
938
|
-
const dbTemplatePath =
|
|
939
|
-
const dbDir =
|
|
940
|
-
if (!
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
const dbDestinationPath =
|
|
944
|
-
|
|
945
|
-
const schemaDestinationPath =
|
|
946
|
-
|
|
947
|
-
const drizzleConfigTemplatePath =
|
|
1251
|
+
const authClientDestinationPath = path8.join(libPath, "auth-client.ts");
|
|
1252
|
+
fs8.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
1253
|
+
const dbTemplatePath = path8.resolve(__dirname, "./template/db");
|
|
1254
|
+
const dbDir = path8.join(projectDir, "db");
|
|
1255
|
+
if (!fs8.existsSync(dbDir)) {
|
|
1256
|
+
fs8.mkdirSync(dbDir, { recursive: true });
|
|
1257
|
+
}
|
|
1258
|
+
const dbDestinationPath = path8.join(dbDir, "drizzle.ts");
|
|
1259
|
+
fs8.copyFileSync(`${dbTemplatePath}/drizzle.ts`, dbDestinationPath);
|
|
1260
|
+
const schemaDestinationPath = path8.join(dbDir, "schema.ts");
|
|
1261
|
+
fs8.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
|
|
1262
|
+
const drizzleConfigTemplatePath = path8.resolve(
|
|
948
1263
|
__dirname,
|
|
949
1264
|
"./template/config/drizzle.config.ts"
|
|
950
1265
|
);
|
|
951
|
-
const drizzleConfigDestinationPath =
|
|
1266
|
+
const drizzleConfigDestinationPath = path8.join(
|
|
952
1267
|
projectDir,
|
|
953
1268
|
"drizzle.config.ts"
|
|
954
1269
|
);
|
|
955
|
-
|
|
956
|
-
const middlewarePath =
|
|
957
|
-
if (!
|
|
958
|
-
|
|
1270
|
+
fs8.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
|
|
1271
|
+
const middlewarePath = path8.join(srcPath, "middleware");
|
|
1272
|
+
if (!fs8.existsSync(middlewarePath)) {
|
|
1273
|
+
fs8.mkdirSync(middlewarePath, { recursive: true });
|
|
959
1274
|
}
|
|
960
|
-
const authMiddlewareTemplatePath =
|
|
1275
|
+
const authMiddlewareTemplatePath = path8.resolve(
|
|
961
1276
|
__dirname,
|
|
962
1277
|
`./template/TanstackStart/middleware/auth.ts`
|
|
963
1278
|
);
|
|
964
|
-
const authMiddlewareDestinationPath =
|
|
965
|
-
|
|
966
|
-
const fileRouteTemplatePath =
|
|
1279
|
+
const authMiddlewareDestinationPath = path8.join(middlewarePath, "auth.ts");
|
|
1280
|
+
fs8.copyFileSync(authMiddlewareTemplatePath, authMiddlewareDestinationPath);
|
|
1281
|
+
const fileRouteTemplatePath = path8.resolve(
|
|
967
1282
|
__dirname,
|
|
968
1283
|
`./template/TanstackStart/routes/$.ts`
|
|
969
1284
|
);
|
|
970
|
-
const fileRouteDestinationPath =
|
|
1285
|
+
const fileRouteDestinationPath = path8.join(
|
|
971
1286
|
srcPath,
|
|
972
1287
|
"routes",
|
|
973
1288
|
"api",
|
|
974
1289
|
"auth"
|
|
975
1290
|
);
|
|
976
|
-
if (!
|
|
977
|
-
|
|
1291
|
+
if (!fs8.existsSync(fileRouteDestinationPath)) {
|
|
1292
|
+
fs8.mkdirSync(fileRouteDestinationPath, { recursive: true });
|
|
978
1293
|
}
|
|
979
|
-
const apiDestinationPath =
|
|
980
|
-
|
|
1294
|
+
const apiDestinationPath = path8.join(fileRouteDestinationPath, "$.ts");
|
|
1295
|
+
fs8.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
|
|
981
1296
|
if (authUi) {
|
|
982
1297
|
await authUiTanstackState({
|
|
983
1298
|
packageJson: packageJson2,
|
|
@@ -985,13 +1300,13 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
985
1300
|
database: "drizzle"
|
|
986
1301
|
});
|
|
987
1302
|
} else {
|
|
988
|
-
console.log(
|
|
989
|
-
console.log(
|
|
990
|
-
console.log(
|
|
1303
|
+
console.log(chalk8.green("\nCompleted installation successfully"));
|
|
1304
|
+
console.log(chalk8.cyan("\nInstall Package:"));
|
|
1305
|
+
console.log(chalk8.white(`\u2022 drizzle schema
|
|
991
1306
|
\u2022 better-auth`));
|
|
992
|
-
console.log(
|
|
1307
|
+
console.log(chalk8.cyan("\nFiles created:"));
|
|
993
1308
|
console.log(
|
|
994
|
-
|
|
1309
|
+
chalk8.white(
|
|
995
1310
|
`\u2022 src/lib/auth.ts
|
|
996
1311
|
\u2022 src/lib/auth-client.ts
|
|
997
1312
|
\u2022 src/app/api/auth/[...all]/route.ts
|
|
@@ -1000,73 +1315,293 @@ BETTER_AUTH_URL=http://localhost:3000
|
|
|
1000
1315
|
)
|
|
1001
1316
|
);
|
|
1002
1317
|
}
|
|
1003
|
-
} catch (
|
|
1004
|
-
console.
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
// utils/framework.ts
|
|
1009
|
-
import path7 from "path";
|
|
1010
|
-
import fs7 from "fs";
|
|
1011
|
-
var getFramework = async () => {
|
|
1012
|
-
const projectDir = process.cwd();
|
|
1013
|
-
if (!fs7.existsSync(path7.join(projectDir, "package.json"))) {
|
|
1014
|
-
return {
|
|
1015
|
-
framework: null,
|
|
1016
|
-
error: "No framework detected"
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
const packageJson2 = JSON.parse(
|
|
1020
|
-
fs7.readFileSync(path7.join(projectDir, "package.json"), "utf-8")
|
|
1021
|
-
);
|
|
1022
|
-
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
1023
|
-
if (hasNext) {
|
|
1024
|
-
return {
|
|
1025
|
-
framework: "Next js",
|
|
1026
|
-
error: null
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
|
-
const hasTanstackState = packageJson2?.devDependencies?.["@tanstack/devtools-vite"] || packageJson2?.devDependencies?.["@tanstack/eslint-config"] || packageJson2?.devDependencies?.["@tanstack/react-start"];
|
|
1030
|
-
if (hasTanstackState) {
|
|
1031
|
-
return {
|
|
1032
|
-
framework: "tanstack start",
|
|
1033
|
-
error: null
|
|
1034
|
-
};
|
|
1318
|
+
} catch (error) {
|
|
1319
|
+
console.log(chalk8.red("Failed to setup drizzle ", error));
|
|
1035
1320
|
}
|
|
1036
|
-
return {
|
|
1037
|
-
framework: null,
|
|
1038
|
-
error: "No framework supported authverse"
|
|
1039
|
-
};
|
|
1040
1321
|
};
|
|
1041
1322
|
|
|
1042
|
-
//
|
|
1043
|
-
import
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1323
|
+
// drizzle/drizzleTanstackChecker.ts
|
|
1324
|
+
import chalk9 from "chalk";
|
|
1325
|
+
import path9 from "path";
|
|
1326
|
+
import fs9 from "fs";
|
|
1327
|
+
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
1328
|
+
var drizzleTanstackChecker = async ({
|
|
1329
|
+
authUi,
|
|
1330
|
+
cmd,
|
|
1331
|
+
projectDir
|
|
1332
|
+
}) => {
|
|
1333
|
+
try {
|
|
1334
|
+
const drizzleConfigPath = path9.join(projectDir, "drizzle.config.ts");
|
|
1335
|
+
if (!fs9.existsSync(drizzleConfigPath)) {
|
|
1336
|
+
return await drizzleTanstackSetup({ authUi, cmd, projectDir });
|
|
1337
|
+
}
|
|
1338
|
+
const drizzleConfigContent = fs9.readFileSync(drizzleConfigPath, "utf-8");
|
|
1339
|
+
const schemaMatch = drizzleConfigContent.match(/schema:\s*["'`](.*?)["'`]/);
|
|
1340
|
+
const schemaPath = schemaMatch ? schemaMatch[1] : null;
|
|
1341
|
+
if (!schemaPath || schemaPath === "") {
|
|
1342
|
+
return await drizzleTanstackSetup({ authUi, cmd, projectDir });
|
|
1343
|
+
}
|
|
1344
|
+
const __filename = fileURLToPath8(import.meta.url);
|
|
1345
|
+
const __dirname = path9.dirname(__filename);
|
|
1346
|
+
const dbTemplatePath = path9.resolve(__dirname, "./template/db/schema.ts");
|
|
1347
|
+
const schemaFilePath = path9.join(projectDir, schemaPath);
|
|
1348
|
+
if (!fs9.existsSync(schemaFilePath)) {
|
|
1349
|
+
const dbFolder = path9.dirname(schemaFilePath);
|
|
1350
|
+
if (!fs9.existsSync(dbFolder)) {
|
|
1351
|
+
fs9.mkdirSync(dbFolder, { recursive: true });
|
|
1352
|
+
}
|
|
1353
|
+
fs9.copyFileSync(dbTemplatePath, schemaFilePath);
|
|
1354
|
+
} else {
|
|
1355
|
+
let schemaFileContent = fs9.readFileSync(schemaFilePath, "utf-8");
|
|
1356
|
+
const dbTemplateContent = fs9.readFileSync(dbTemplatePath, "utf-8");
|
|
1357
|
+
const requiredTables = ["user", "session", "account", "verification"];
|
|
1358
|
+
let needsUpdate = false;
|
|
1359
|
+
let updatedSchemaContent = schemaFileContent;
|
|
1360
|
+
for (const table of requiredTables) {
|
|
1361
|
+
const existingTable = extractTableDefinition(
|
|
1362
|
+
updatedSchemaContent,
|
|
1363
|
+
table
|
|
1364
|
+
);
|
|
1365
|
+
const templateTable = extractTableDefinition(dbTemplateContent, table);
|
|
1366
|
+
if (!existingTable && templateTable) {
|
|
1367
|
+
const schemaExportIndex = updatedSchemaContent.indexOf(
|
|
1368
|
+
"export const schema ="
|
|
1369
|
+
);
|
|
1370
|
+
if (schemaExportIndex !== -1) {
|
|
1371
|
+
updatedSchemaContent = updatedSchemaContent.slice(0, schemaExportIndex) + templateTable + "\n\n" + updatedSchemaContent.slice(schemaExportIndex);
|
|
1372
|
+
} else {
|
|
1373
|
+
updatedSchemaContent += "\n\n" + templateTable;
|
|
1374
|
+
}
|
|
1375
|
+
needsUpdate = true;
|
|
1376
|
+
} else if (existingTable && templateTable) {
|
|
1377
|
+
const existingColumns = extractColumnNames(existingTable);
|
|
1378
|
+
const templateColumns = extractColumnNames(templateTable);
|
|
1379
|
+
const missingColumns = templateColumns.filter(
|
|
1380
|
+
(col) => !existingColumns.includes(col)
|
|
1381
|
+
);
|
|
1382
|
+
if (missingColumns.length > 0) {
|
|
1383
|
+
const updatedTable = addMissingColumnsToTable(
|
|
1384
|
+
existingTable,
|
|
1385
|
+
templateTable
|
|
1386
|
+
);
|
|
1387
|
+
updatedSchemaContent = updatedSchemaContent.replace(
|
|
1388
|
+
existingTable,
|
|
1389
|
+
updatedTable
|
|
1390
|
+
);
|
|
1391
|
+
needsUpdate = true;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
if (needsUpdate) {
|
|
1396
|
+
const schemaExportRegex = /export const schema = \{([\s\S]*?)\};/;
|
|
1397
|
+
const schemaMatch2 = updatedSchemaContent.match(schemaExportRegex);
|
|
1398
|
+
if (schemaMatch2) {
|
|
1399
|
+
let currentSchemaContent = schemaMatch2[1];
|
|
1400
|
+
for (const table of requiredTables) {
|
|
1401
|
+
if (!currentSchemaContent.includes(`${table},`)) {
|
|
1402
|
+
const lines = currentSchemaContent.split("\n");
|
|
1403
|
+
const lastNonEmptyLine = lines.length - 1;
|
|
1404
|
+
if (lines[lastNonEmptyLine].trim() === "}") {
|
|
1405
|
+
lines[lastNonEmptyLine] = ` ${table},
|
|
1406
|
+
${lines[lastNonEmptyLine]}`;
|
|
1407
|
+
} else {
|
|
1408
|
+
lines.push(` ${table},`);
|
|
1409
|
+
}
|
|
1410
|
+
currentSchemaContent = lines.join("\n");
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
updatedSchemaContent = updatedSchemaContent.replace(
|
|
1414
|
+
schemaExportRegex,
|
|
1415
|
+
`export const schema = {${currentSchemaContent}};`
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
fs9.writeFileSync(schemaFilePath, updatedSchemaContent);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
const packageJsonPath = path9.join(projectDir, "package.json");
|
|
1422
|
+
const packageJson2 = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8"));
|
|
1423
|
+
if (!packageJson2.dependencies["better-auth"]) {
|
|
1424
|
+
console.log(chalk9.cyan("\n\u2699\uFE0F Initializing better auth...\n"));
|
|
1425
|
+
packageManager("better-auth");
|
|
1426
|
+
}
|
|
1427
|
+
const drizzleDeps = [
|
|
1428
|
+
"drizzle-orm",
|
|
1429
|
+
"@neondatabase/serverless",
|
|
1430
|
+
"dotenv",
|
|
1431
|
+
"drizzle-kit"
|
|
1432
|
+
];
|
|
1433
|
+
const missingDrizzleDeps = drizzleDeps.filter((dep) => {
|
|
1434
|
+
return !packageJson2.dependencies?.[dep] && !packageJson2.devDependencies?.[dep];
|
|
1435
|
+
});
|
|
1436
|
+
if (missingDrizzleDeps.length > 0) {
|
|
1437
|
+
console.log(chalk9.cyan("\n\u2699\uFE0F Initializing drizzle...\n"));
|
|
1438
|
+
packageManager(missingDrizzleDeps.join(" "));
|
|
1439
|
+
}
|
|
1440
|
+
const envPath = path9.join(projectDir, ".env");
|
|
1441
|
+
if (!fs9.existsSync(envPath)) {
|
|
1442
|
+
fs9.writeFileSync(envPath, "DATABASE_URL=\n");
|
|
1443
|
+
}
|
|
1444
|
+
const secret = await GenerateSecret();
|
|
1445
|
+
const envContent = fs9.readFileSync(envPath, "utf-8");
|
|
1446
|
+
if (!envContent.includes("BETTER_AUTH_SECRET")) {
|
|
1447
|
+
fs9.appendFileSync(envPath, `
|
|
1448
|
+
|
|
1449
|
+
BETTER_AUTH_SECRET=${secret}`);
|
|
1450
|
+
}
|
|
1451
|
+
if (!envContent.includes("BETTER_AUTH_URL")) {
|
|
1452
|
+
fs9.appendFileSync(envPath, `
|
|
1453
|
+
BETTER_AUTH_URL=http://localhost:3000
|
|
1454
|
+
`);
|
|
1455
|
+
}
|
|
1456
|
+
const srcPath = path9.join(projectDir, "src");
|
|
1457
|
+
const libPath = path9.join(srcPath, "lib");
|
|
1458
|
+
if (!fs9.existsSync(libPath)) {
|
|
1459
|
+
fs9.mkdirSync(libPath, { recursive: true });
|
|
1460
|
+
}
|
|
1461
|
+
const authTemplatePath = path9.resolve(
|
|
1462
|
+
__dirname,
|
|
1463
|
+
"./template/TanstackStart/lib/auth-drizzle.ts"
|
|
1464
|
+
);
|
|
1465
|
+
const authDestinationPath = path9.join(libPath, "auth.ts");
|
|
1466
|
+
fs9.copyFileSync(authTemplatePath, authDestinationPath);
|
|
1467
|
+
const authClientTemplatePath = path9.resolve(
|
|
1468
|
+
__dirname,
|
|
1469
|
+
"./template/lib/auth-client.ts"
|
|
1470
|
+
);
|
|
1471
|
+
const authClientDestinationPath = path9.join(libPath, "auth-client.ts");
|
|
1472
|
+
fs9.copyFileSync(authClientTemplatePath, authClientDestinationPath);
|
|
1473
|
+
const middlewarePath = path9.join(srcPath, "middleware");
|
|
1474
|
+
if (!fs9.existsSync(middlewarePath)) {
|
|
1475
|
+
fs9.mkdirSync(middlewarePath, { recursive: true });
|
|
1476
|
+
}
|
|
1477
|
+
const authMiddlewareTemplatePath = path9.resolve(
|
|
1478
|
+
__dirname,
|
|
1479
|
+
`./template/TanstackStart/middleware/auth.ts`
|
|
1480
|
+
);
|
|
1481
|
+
const authMiddlewareDestinationPath = path9.join(middlewarePath, "auth.ts");
|
|
1482
|
+
fs9.copyFileSync(authMiddlewareTemplatePath, authMiddlewareDestinationPath);
|
|
1483
|
+
const fileRouteTemplatePath = path9.resolve(
|
|
1484
|
+
__dirname,
|
|
1485
|
+
`./template/TanstackStart/routes/$.ts`
|
|
1486
|
+
);
|
|
1487
|
+
const fileRouteDestinationPath = path9.join(
|
|
1488
|
+
srcPath,
|
|
1489
|
+
"routes",
|
|
1490
|
+
"api",
|
|
1491
|
+
"auth"
|
|
1492
|
+
);
|
|
1493
|
+
if (!fs9.existsSync(fileRouteDestinationPath)) {
|
|
1494
|
+
fs9.mkdirSync(fileRouteDestinationPath, { recursive: true });
|
|
1495
|
+
}
|
|
1496
|
+
const apiDestinationPath = path9.join(fileRouteDestinationPath, "$.ts");
|
|
1497
|
+
fs9.copyFileSync(fileRouteTemplatePath, apiDestinationPath);
|
|
1498
|
+
if (authUi) {
|
|
1499
|
+
await authUiTanstackState({
|
|
1500
|
+
packageJson: packageJson2,
|
|
1501
|
+
cmd,
|
|
1502
|
+
database: "drizzle"
|
|
1503
|
+
});
|
|
1504
|
+
} else {
|
|
1505
|
+
console.log(chalk9.green("\nCompleted installation successfully"));
|
|
1506
|
+
console.log(chalk9.cyan("\nInstall Package:"));
|
|
1507
|
+
console.log(chalk9.white(`\u2022 drizzle schema
|
|
1508
|
+
\u2022 better-auth`));
|
|
1509
|
+
console.log(chalk9.cyan("\nFiles created:"));
|
|
1510
|
+
console.log(
|
|
1511
|
+
chalk9.white(
|
|
1512
|
+
`\u2022 src/lib/auth.ts
|
|
1513
|
+
\u2022 src/lib/auth-client.ts
|
|
1514
|
+
\u2022 src/app/api/auth/[...all]/route.ts
|
|
1515
|
+
\u2022 src/proxy.ts
|
|
1516
|
+
`
|
|
1517
|
+
)
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
} catch (error) {
|
|
1521
|
+
console.log(chalk9.red("Failed to setup drizzle ", error));
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
// script/drizzleRunTanstackStart.ts
|
|
1526
|
+
var drizzleRunTanstackStart = async ({
|
|
1527
|
+
authUi,
|
|
1528
|
+
cmd
|
|
1529
|
+
}) => {
|
|
1530
|
+
try {
|
|
1531
|
+
const projectDir = process.cwd();
|
|
1532
|
+
const drizzleConfigPath = path10.join(projectDir, "drizzle.config.ts");
|
|
1533
|
+
if (fs10.existsSync(drizzleConfigPath)) {
|
|
1534
|
+
await drizzleTanstackChecker({ authUi, cmd, projectDir });
|
|
1535
|
+
} else {
|
|
1536
|
+
await drizzleTanstackSetup({ authUi, cmd, projectDir });
|
|
1537
|
+
}
|
|
1538
|
+
} catch (err) {
|
|
1539
|
+
console.error(chalk10.red("Drizzle setup failed:"), err);
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
// utils/framework.ts
|
|
1544
|
+
import path11 from "path";
|
|
1545
|
+
import fs11 from "fs";
|
|
1546
|
+
var getFramework = async () => {
|
|
1547
|
+
const projectDir = process.cwd();
|
|
1548
|
+
if (!fs11.existsSync(path11.join(projectDir, "package.json"))) {
|
|
1549
|
+
return {
|
|
1550
|
+
framework: null,
|
|
1551
|
+
error: "No framework detected"
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
const packageJson2 = JSON.parse(
|
|
1555
|
+
fs11.readFileSync(path11.join(projectDir, "package.json"), "utf-8")
|
|
1556
|
+
);
|
|
1557
|
+
const hasNext = packageJson2?.dependencies?.["next"] || packageJson2?.devDependencies?.["next"];
|
|
1558
|
+
if (hasNext) {
|
|
1559
|
+
return {
|
|
1560
|
+
framework: "Next js",
|
|
1561
|
+
error: null
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
const hasTanstackState = packageJson2?.devDependencies?.["@tanstack/devtools-vite"] || packageJson2?.devDependencies?.["@tanstack/eslint-config"] || packageJson2?.devDependencies?.["@tanstack/react-start"];
|
|
1565
|
+
if (hasTanstackState) {
|
|
1566
|
+
return {
|
|
1567
|
+
framework: "tanstack start",
|
|
1568
|
+
error: null
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
return {
|
|
1572
|
+
framework: null,
|
|
1573
|
+
error: "No framework supported authverse"
|
|
1574
|
+
};
|
|
1575
|
+
};
|
|
1576
|
+
|
|
1577
|
+
// cli/init.ts
|
|
1578
|
+
import chalk11 from "chalk";
|
|
1579
|
+
var initAnswer = async () => {
|
|
1580
|
+
const { framework, error } = await getFramework();
|
|
1581
|
+
if (error) {
|
|
1582
|
+
console.log(chalk11.red(error));
|
|
1583
|
+
return;
|
|
1584
|
+
}
|
|
1585
|
+
console.log(`\u2714 Detected framework: ${framework}`);
|
|
1586
|
+
const answers = await inquirer4.prompt([
|
|
1587
|
+
{
|
|
1588
|
+
type: "select",
|
|
1589
|
+
name: "orm",
|
|
1590
|
+
message: "Choose Your ORM:",
|
|
1591
|
+
choices: ["Prisma", "Drizzle"]
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
type: "select",
|
|
1595
|
+
name: "database",
|
|
1596
|
+
message: "Select Database:",
|
|
1597
|
+
choices: ["Postgresql", "Mongodb", "Mysql"],
|
|
1598
|
+
when: (ans) => ans.orm === "Prisma"
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
type: "confirm",
|
|
1602
|
+
name: "authUi",
|
|
1603
|
+
message: "Do you want to include auth UI design?",
|
|
1604
|
+
default: true
|
|
1070
1605
|
}
|
|
1071
1606
|
]);
|
|
1072
1607
|
if (framework === "Next js" && answers.orm === "Prisma") {
|
|
@@ -1101,33 +1636,33 @@ var initAnswer = async () => {
|
|
|
1101
1636
|
import { readFileSync } from "fs";
|
|
1102
1637
|
|
|
1103
1638
|
// cli/oauth.ts
|
|
1104
|
-
import
|
|
1639
|
+
import chalk24 from "chalk";
|
|
1105
1640
|
|
|
1106
1641
|
// oauth/googleNext.ts
|
|
1107
|
-
import
|
|
1108
|
-
import
|
|
1109
|
-
import
|
|
1110
|
-
import { fileURLToPath as
|
|
1642
|
+
import chalk12 from "chalk";
|
|
1643
|
+
import fs12 from "fs";
|
|
1644
|
+
import path12 from "path";
|
|
1645
|
+
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
1111
1646
|
var googleNext = async () => {
|
|
1112
1647
|
try {
|
|
1113
|
-
const __filename =
|
|
1114
|
-
const __dirname =
|
|
1648
|
+
const __filename = fileURLToPath9(import.meta.url);
|
|
1649
|
+
const __dirname = path12.dirname(__filename);
|
|
1115
1650
|
const projectDir = process.cwd();
|
|
1116
|
-
const srcPath =
|
|
1117
|
-
const folder =
|
|
1118
|
-
const authFilePath =
|
|
1119
|
-
if (!
|
|
1120
|
-
console.log(
|
|
1121
|
-
console.log(
|
|
1651
|
+
const srcPath = path12.join(projectDir, "src");
|
|
1652
|
+
const folder = fs12.existsSync(srcPath) ? "src" : "";
|
|
1653
|
+
const authFilePath = path12.join(projectDir, folder, "lib", "auth.ts");
|
|
1654
|
+
if (!fs12.existsSync(authFilePath)) {
|
|
1655
|
+
console.log(chalk12.red("No Configured Better Auth file found"));
|
|
1656
|
+
console.log(chalk12.cyan("Run authverse init to initialize better auth"));
|
|
1122
1657
|
return;
|
|
1123
1658
|
}
|
|
1124
|
-
let content =
|
|
1659
|
+
let content = fs12.readFileSync(authFilePath, "utf8");
|
|
1125
1660
|
if (!content.includes("betterAuth({")) {
|
|
1126
|
-
console.log(
|
|
1661
|
+
console.log(chalk12.red("betterAuth({}) block not found"));
|
|
1127
1662
|
return;
|
|
1128
1663
|
}
|
|
1129
1664
|
if (content.includes("socialProviders") && content.includes("google:")) {
|
|
1130
|
-
console.log(
|
|
1665
|
+
console.log(chalk12.yellow("Google provider already exists"));
|
|
1131
1666
|
return;
|
|
1132
1667
|
}
|
|
1133
1668
|
const googleProviderEntry = `
|
|
@@ -1150,7 +1685,7 @@ var googleNext = async () => {
|
|
|
1150
1685
|
}
|
|
1151
1686
|
}
|
|
1152
1687
|
if (insertPos === -1) {
|
|
1153
|
-
console.log(
|
|
1688
|
+
console.log(chalk12.red("Failed to parse socialProviders block"));
|
|
1154
1689
|
return;
|
|
1155
1690
|
}
|
|
1156
1691
|
content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1158,7 +1693,7 @@ var googleNext = async () => {
|
|
|
1158
1693
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1159
1694
|
if (!databaseRegex.test(content)) {
|
|
1160
1695
|
console.log(
|
|
1161
|
-
|
|
1696
|
+
chalk12.red(
|
|
1162
1697
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1163
1698
|
)
|
|
1164
1699
|
);
|
|
@@ -1174,12 +1709,12 @@ ${googleProviderEntry}
|
|
|
1174
1709
|
${socialProvidersBlock}`
|
|
1175
1710
|
);
|
|
1176
1711
|
}
|
|
1177
|
-
|
|
1178
|
-
const envPath =
|
|
1179
|
-
if (
|
|
1180
|
-
const envContent =
|
|
1712
|
+
fs12.writeFileSync(authFilePath, content, "utf8");
|
|
1713
|
+
const envPath = path12.join(projectDir, ".env");
|
|
1714
|
+
if (fs12.existsSync(envPath)) {
|
|
1715
|
+
const envContent = fs12.readFileSync(envPath, "utf8");
|
|
1181
1716
|
if (!envContent.includes("GOOGLE_CLIENT_ID")) {
|
|
1182
|
-
|
|
1717
|
+
fs12.appendFileSync(
|
|
1183
1718
|
envPath,
|
|
1184
1719
|
`
|
|
1185
1720
|
|
|
@@ -1190,60 +1725,60 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1190
1725
|
);
|
|
1191
1726
|
}
|
|
1192
1727
|
}
|
|
1193
|
-
const componentTemplate =
|
|
1728
|
+
const componentTemplate = path12.resolve(
|
|
1194
1729
|
__dirname,
|
|
1195
1730
|
"./template/components/GoogleOAuthButton.tsx"
|
|
1196
1731
|
);
|
|
1197
|
-
const componentsDir =
|
|
1732
|
+
const componentsDir = path12.join(
|
|
1198
1733
|
projectDir,
|
|
1199
1734
|
folder,
|
|
1200
1735
|
"components",
|
|
1201
1736
|
"authverse"
|
|
1202
1737
|
);
|
|
1203
|
-
if (!
|
|
1204
|
-
|
|
1738
|
+
if (!fs12.existsSync(componentsDir)) {
|
|
1739
|
+
fs12.mkdirSync(componentsDir, { recursive: true });
|
|
1205
1740
|
}
|
|
1206
|
-
const componentDest =
|
|
1207
|
-
if (
|
|
1208
|
-
|
|
1741
|
+
const componentDest = path12.join(componentsDir, "GoogleOAuthButton.tsx");
|
|
1742
|
+
if (fs12.existsSync(componentTemplate)) {
|
|
1743
|
+
fs12.copyFileSync(componentTemplate, componentDest);
|
|
1209
1744
|
}
|
|
1210
|
-
console.log(
|
|
1745
|
+
console.log(chalk12.green("Google provider added & merged successfully\n"));
|
|
1211
1746
|
console.log(
|
|
1212
|
-
|
|
1747
|
+
chalk12.white(
|
|
1213
1748
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/GoogleOAuthButton.tsx" })}
|
|
1214
1749
|
`
|
|
1215
1750
|
)
|
|
1216
1751
|
);
|
|
1217
1752
|
} catch (error) {
|
|
1218
|
-
console.log(
|
|
1753
|
+
console.log(chalk12.red("googleRun error:"), error);
|
|
1219
1754
|
}
|
|
1220
1755
|
};
|
|
1221
1756
|
|
|
1222
1757
|
// oauth/githubNext.ts
|
|
1223
|
-
import
|
|
1224
|
-
import
|
|
1225
|
-
import
|
|
1226
|
-
import { fileURLToPath as
|
|
1758
|
+
import chalk13 from "chalk";
|
|
1759
|
+
import fs13 from "fs";
|
|
1760
|
+
import path13 from "path";
|
|
1761
|
+
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
1227
1762
|
var githubNext = async () => {
|
|
1228
1763
|
try {
|
|
1229
|
-
const __filename =
|
|
1230
|
-
const __dirname =
|
|
1764
|
+
const __filename = fileURLToPath10(import.meta.url);
|
|
1765
|
+
const __dirname = path13.dirname(__filename);
|
|
1231
1766
|
const projectDir = process.cwd();
|
|
1232
|
-
const srcPath =
|
|
1233
|
-
const folder =
|
|
1234
|
-
const authFilePath =
|
|
1235
|
-
if (!
|
|
1236
|
-
console.log(
|
|
1237
|
-
console.log(
|
|
1767
|
+
const srcPath = path13.join(projectDir, "src");
|
|
1768
|
+
const folder = fs13.existsSync(srcPath) ? "src" : "";
|
|
1769
|
+
const authFilePath = path13.join(projectDir, folder, "lib", "auth.ts");
|
|
1770
|
+
if (!fs13.existsSync(authFilePath)) {
|
|
1771
|
+
console.log(chalk13.red("No Configured Better Auth file found"));
|
|
1772
|
+
console.log(chalk13.cyan("Run authverse init to initialize better auth"));
|
|
1238
1773
|
return;
|
|
1239
1774
|
}
|
|
1240
|
-
let content =
|
|
1775
|
+
let content = fs13.readFileSync(authFilePath, "utf8");
|
|
1241
1776
|
if (!content.includes("betterAuth({")) {
|
|
1242
|
-
console.log(
|
|
1777
|
+
console.log(chalk13.red("betterAuth({}) block not found"));
|
|
1243
1778
|
return;
|
|
1244
1779
|
}
|
|
1245
1780
|
if (content.includes("socialProviders") && content.includes("github:")) {
|
|
1246
|
-
console.log(
|
|
1781
|
+
console.log(chalk13.yellow("GitHub provider already exists"));
|
|
1247
1782
|
return;
|
|
1248
1783
|
}
|
|
1249
1784
|
const githubProviderEntry = `
|
|
@@ -1266,7 +1801,7 @@ var githubNext = async () => {
|
|
|
1266
1801
|
}
|
|
1267
1802
|
}
|
|
1268
1803
|
if (insertPos === -1) {
|
|
1269
|
-
console.log(
|
|
1804
|
+
console.log(chalk13.red("Failed to parse socialProviders block"));
|
|
1270
1805
|
return;
|
|
1271
1806
|
}
|
|
1272
1807
|
content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1274,7 +1809,7 @@ var githubNext = async () => {
|
|
|
1274
1809
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1275
1810
|
if (!databaseRegex.test(content)) {
|
|
1276
1811
|
console.log(
|
|
1277
|
-
|
|
1812
|
+
chalk13.red(
|
|
1278
1813
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1279
1814
|
)
|
|
1280
1815
|
);
|
|
@@ -1290,12 +1825,12 @@ ${githubProviderEntry}
|
|
|
1290
1825
|
${socialProvidersBlock}`
|
|
1291
1826
|
);
|
|
1292
1827
|
}
|
|
1293
|
-
|
|
1294
|
-
const envPath =
|
|
1295
|
-
if (
|
|
1296
|
-
const envContent =
|
|
1828
|
+
fs13.writeFileSync(authFilePath, content, "utf8");
|
|
1829
|
+
const envPath = path13.join(projectDir, ".env");
|
|
1830
|
+
if (fs13.existsSync(envPath)) {
|
|
1831
|
+
const envContent = fs13.readFileSync(envPath, "utf8");
|
|
1297
1832
|
if (!envContent.includes("GITHUB_CLIENT_ID")) {
|
|
1298
|
-
|
|
1833
|
+
fs13.appendFileSync(
|
|
1299
1834
|
envPath,
|
|
1300
1835
|
`
|
|
1301
1836
|
|
|
@@ -1306,59 +1841,59 @@ GITHUB_CLIENT_SECRET=
|
|
|
1306
1841
|
);
|
|
1307
1842
|
}
|
|
1308
1843
|
}
|
|
1309
|
-
const componentTemplate =
|
|
1844
|
+
const componentTemplate = path13.resolve(
|
|
1310
1845
|
__dirname,
|
|
1311
1846
|
"./template/components/GithubOAuthButton.tsx"
|
|
1312
1847
|
);
|
|
1313
|
-
const componentsDir =
|
|
1848
|
+
const componentsDir = path13.join(
|
|
1314
1849
|
projectDir,
|
|
1315
1850
|
folder,
|
|
1316
1851
|
"components",
|
|
1317
1852
|
"authverse"
|
|
1318
1853
|
);
|
|
1319
|
-
if (!
|
|
1320
|
-
|
|
1854
|
+
if (!fs13.existsSync(componentsDir)) {
|
|
1855
|
+
fs13.mkdirSync(componentsDir, { recursive: true });
|
|
1321
1856
|
}
|
|
1322
|
-
const componentDest =
|
|
1323
|
-
if (
|
|
1324
|
-
|
|
1857
|
+
const componentDest = path13.join(componentsDir, "GithubOAuthButton.tsx");
|
|
1858
|
+
if (fs13.existsSync(componentTemplate)) {
|
|
1859
|
+
fs13.copyFileSync(componentTemplate, componentDest);
|
|
1325
1860
|
}
|
|
1326
|
-
console.log(
|
|
1861
|
+
console.log(chalk13.green("GitHub provider added & merged successfully\n"));
|
|
1327
1862
|
console.log(
|
|
1328
|
-
|
|
1863
|
+
chalk13.white(
|
|
1329
1864
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/GithubOAuthButton.tsx" })}
|
|
1330
1865
|
`
|
|
1331
1866
|
)
|
|
1332
1867
|
);
|
|
1333
1868
|
} catch (error) {
|
|
1334
|
-
console.log(
|
|
1869
|
+
console.log(chalk13.red("githubRun error:"), error);
|
|
1335
1870
|
}
|
|
1336
1871
|
};
|
|
1337
1872
|
|
|
1338
1873
|
// oauth/googleTanstackStart.ts
|
|
1339
|
-
import
|
|
1340
|
-
import
|
|
1341
|
-
import
|
|
1342
|
-
import { fileURLToPath as
|
|
1874
|
+
import chalk14 from "chalk";
|
|
1875
|
+
import fs14 from "fs";
|
|
1876
|
+
import path14 from "path";
|
|
1877
|
+
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
1343
1878
|
var googleTanstackStart = async () => {
|
|
1344
1879
|
try {
|
|
1345
|
-
const __filename =
|
|
1346
|
-
const __dirname =
|
|
1880
|
+
const __filename = fileURLToPath11(import.meta.url);
|
|
1881
|
+
const __dirname = path14.dirname(__filename);
|
|
1347
1882
|
const projectDir = process.cwd();
|
|
1348
|
-
const srcPath =
|
|
1349
|
-
const authFilePath =
|
|
1350
|
-
if (!
|
|
1351
|
-
console.log(
|
|
1352
|
-
console.log(
|
|
1883
|
+
const srcPath = path14.join(projectDir, "src");
|
|
1884
|
+
const authFilePath = path14.join(srcPath, "lib", "auth.ts");
|
|
1885
|
+
if (!fs14.existsSync(authFilePath)) {
|
|
1886
|
+
console.log(chalk14.red("No Configured Better Auth file found"));
|
|
1887
|
+
console.log(chalk14.cyan("Run authverse init to initialize better auth"));
|
|
1353
1888
|
return;
|
|
1354
1889
|
}
|
|
1355
|
-
let content =
|
|
1890
|
+
let content = fs14.readFileSync(authFilePath, "utf8");
|
|
1356
1891
|
if (!content.includes("betterAuth({")) {
|
|
1357
|
-
console.log(
|
|
1892
|
+
console.log(chalk14.red("betterAuth({}) block not found"));
|
|
1358
1893
|
return;
|
|
1359
1894
|
}
|
|
1360
1895
|
if (content.includes("socialProviders") && content.includes("google:")) {
|
|
1361
|
-
console.log(
|
|
1896
|
+
console.log(chalk14.yellow("Google provider already exists"));
|
|
1362
1897
|
return;
|
|
1363
1898
|
}
|
|
1364
1899
|
const googleProviderEntry = `
|
|
@@ -1381,7 +1916,7 @@ var googleTanstackStart = async () => {
|
|
|
1381
1916
|
}
|
|
1382
1917
|
}
|
|
1383
1918
|
if (insertPos === -1) {
|
|
1384
|
-
console.log(
|
|
1919
|
+
console.log(chalk14.red("Failed to parse socialProviders block"));
|
|
1385
1920
|
return;
|
|
1386
1921
|
}
|
|
1387
1922
|
content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1389,7 +1924,7 @@ var googleTanstackStart = async () => {
|
|
|
1389
1924
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1390
1925
|
if (!databaseRegex.test(content)) {
|
|
1391
1926
|
console.log(
|
|
1392
|
-
|
|
1927
|
+
chalk14.red(
|
|
1393
1928
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1394
1929
|
)
|
|
1395
1930
|
);
|
|
@@ -1405,12 +1940,12 @@ ${googleProviderEntry}
|
|
|
1405
1940
|
${socialProvidersBlock}`
|
|
1406
1941
|
);
|
|
1407
1942
|
}
|
|
1408
|
-
|
|
1409
|
-
const envPath =
|
|
1410
|
-
if (
|
|
1411
|
-
const envContent =
|
|
1943
|
+
fs14.writeFileSync(authFilePath, content, "utf8");
|
|
1944
|
+
const envPath = path14.join(projectDir, ".env");
|
|
1945
|
+
if (fs14.existsSync(envPath)) {
|
|
1946
|
+
const envContent = fs14.readFileSync(envPath, "utf8");
|
|
1412
1947
|
if (!envContent.includes("GOOGLE_CLIENT_ID")) {
|
|
1413
|
-
|
|
1948
|
+
fs14.appendFileSync(
|
|
1414
1949
|
envPath,
|
|
1415
1950
|
`
|
|
1416
1951
|
|
|
@@ -1421,51 +1956,51 @@ GOOGLE_CLIENT_SECRET=
|
|
|
1421
1956
|
);
|
|
1422
1957
|
}
|
|
1423
1958
|
}
|
|
1424
|
-
const componentTemplate =
|
|
1959
|
+
const componentTemplate = path14.resolve(
|
|
1425
1960
|
__dirname,
|
|
1426
1961
|
"./template/TanstackStart/components/GoogleOAuthButton.tsx"
|
|
1427
1962
|
);
|
|
1428
|
-
const componentsDir =
|
|
1429
|
-
if (!
|
|
1430
|
-
|
|
1963
|
+
const componentsDir = path14.join(srcPath, "components", "authverse");
|
|
1964
|
+
if (!fs14.existsSync(componentsDir)) {
|
|
1965
|
+
fs14.mkdirSync(componentsDir, { recursive: true });
|
|
1431
1966
|
}
|
|
1432
|
-
const componentDest =
|
|
1433
|
-
if (
|
|
1434
|
-
|
|
1967
|
+
const componentDest = path14.join(componentsDir, "GoogleOAuthButton.tsx");
|
|
1968
|
+
if (fs14.existsSync(componentTemplate)) {
|
|
1969
|
+
fs14.copyFileSync(componentTemplate, componentDest);
|
|
1435
1970
|
}
|
|
1436
|
-
console.log(
|
|
1971
|
+
console.log(chalk14.green("Google provider added & merged successfully\n"));
|
|
1437
1972
|
console.log(
|
|
1438
|
-
|
|
1973
|
+
chalk14.white("\u2022 src/components/authverse/GoogleOAuthButton.tsx")
|
|
1439
1974
|
);
|
|
1440
1975
|
} catch (error) {
|
|
1441
|
-
console.log(
|
|
1976
|
+
console.log(chalk14.red("googleRunTanstackState error:"), error);
|
|
1442
1977
|
}
|
|
1443
1978
|
};
|
|
1444
1979
|
|
|
1445
1980
|
// oauth/githubTanstackStart.ts
|
|
1446
|
-
import
|
|
1447
|
-
import
|
|
1448
|
-
import
|
|
1449
|
-
import { fileURLToPath as
|
|
1981
|
+
import chalk15 from "chalk";
|
|
1982
|
+
import fs15 from "fs";
|
|
1983
|
+
import path15 from "path";
|
|
1984
|
+
import { fileURLToPath as fileURLToPath12 } from "url";
|
|
1450
1985
|
var githubTanstackStart = async () => {
|
|
1451
1986
|
try {
|
|
1452
|
-
const __filename =
|
|
1453
|
-
const __dirname =
|
|
1987
|
+
const __filename = fileURLToPath12(import.meta.url);
|
|
1988
|
+
const __dirname = path15.dirname(__filename);
|
|
1454
1989
|
const projectDir = process.cwd();
|
|
1455
|
-
const srcPath =
|
|
1456
|
-
const authFilePath =
|
|
1457
|
-
if (!
|
|
1458
|
-
console.log(
|
|
1459
|
-
console.log(
|
|
1990
|
+
const srcPath = path15.join(projectDir, "src");
|
|
1991
|
+
const authFilePath = path15.join(srcPath, "lib", "auth.ts");
|
|
1992
|
+
if (!fs15.existsSync(authFilePath)) {
|
|
1993
|
+
console.log(chalk15.red("No Configured Better Auth file found"));
|
|
1994
|
+
console.log(chalk15.cyan("Run authverse init to initialize better auth"));
|
|
1460
1995
|
return;
|
|
1461
1996
|
}
|
|
1462
|
-
let content =
|
|
1997
|
+
let content = fs15.readFileSync(authFilePath, "utf8");
|
|
1463
1998
|
if (!content.includes("betterAuth({")) {
|
|
1464
|
-
console.log(
|
|
1999
|
+
console.log(chalk15.red("betterAuth({}) block not found"));
|
|
1465
2000
|
return;
|
|
1466
2001
|
}
|
|
1467
2002
|
if (content.includes("socialProviders") && content.includes("github:")) {
|
|
1468
|
-
console.log(
|
|
2003
|
+
console.log(chalk15.yellow("Github provider already exists"));
|
|
1469
2004
|
return;
|
|
1470
2005
|
}
|
|
1471
2006
|
const githubProviderEntry = `
|
|
@@ -1488,7 +2023,7 @@ var githubTanstackStart = async () => {
|
|
|
1488
2023
|
}
|
|
1489
2024
|
}
|
|
1490
2025
|
if (insertPos === -1) {
|
|
1491
|
-
console.log(
|
|
2026
|
+
console.log(chalk15.red("Failed to parse socialProviders block"));
|
|
1492
2027
|
return;
|
|
1493
2028
|
}
|
|
1494
2029
|
content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1496,7 +2031,7 @@ var githubTanstackStart = async () => {
|
|
|
1496
2031
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1497
2032
|
if (!databaseRegex.test(content)) {
|
|
1498
2033
|
console.log(
|
|
1499
|
-
|
|
2034
|
+
chalk15.red(
|
|
1500
2035
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1501
2036
|
)
|
|
1502
2037
|
);
|
|
@@ -1512,12 +2047,12 @@ ${githubProviderEntry}
|
|
|
1512
2047
|
${socialProvidersBlock}`
|
|
1513
2048
|
);
|
|
1514
2049
|
}
|
|
1515
|
-
|
|
1516
|
-
const envPath =
|
|
1517
|
-
if (
|
|
1518
|
-
const envContent =
|
|
2050
|
+
fs15.writeFileSync(authFilePath, content, "utf8");
|
|
2051
|
+
const envPath = path15.join(projectDir, ".env");
|
|
2052
|
+
if (fs15.existsSync(envPath)) {
|
|
2053
|
+
const envContent = fs15.readFileSync(envPath, "utf8");
|
|
1519
2054
|
if (!envContent.includes("GITHUB_CLIENT_ID")) {
|
|
1520
|
-
|
|
2055
|
+
fs15.appendFileSync(
|
|
1521
2056
|
envPath,
|
|
1522
2057
|
`
|
|
1523
2058
|
|
|
@@ -1528,52 +2063,52 @@ GITHUB_CLIENT_SECRET=
|
|
|
1528
2063
|
);
|
|
1529
2064
|
}
|
|
1530
2065
|
}
|
|
1531
|
-
const componentTemplate =
|
|
2066
|
+
const componentTemplate = path15.resolve(
|
|
1532
2067
|
__dirname,
|
|
1533
2068
|
"./template/TanstackStart/components/GithubOAuthButton.tsx"
|
|
1534
2069
|
);
|
|
1535
|
-
const componentsDir =
|
|
1536
|
-
if (!
|
|
1537
|
-
|
|
2070
|
+
const componentsDir = path15.join(srcPath, "components", "authverse");
|
|
2071
|
+
if (!fs15.existsSync(componentsDir)) {
|
|
2072
|
+
fs15.mkdirSync(componentsDir, { recursive: true });
|
|
1538
2073
|
}
|
|
1539
|
-
const componentDest =
|
|
1540
|
-
if (
|
|
1541
|
-
|
|
2074
|
+
const componentDest = path15.join(componentsDir, "GithubOAuthButton.tsx");
|
|
2075
|
+
if (fs15.existsSync(componentTemplate)) {
|
|
2076
|
+
fs15.copyFileSync(componentTemplate, componentDest);
|
|
1542
2077
|
}
|
|
1543
|
-
console.log(
|
|
2078
|
+
console.log(chalk15.green("Github provider added & merged successfully\n"));
|
|
1544
2079
|
console.log(
|
|
1545
|
-
|
|
2080
|
+
chalk15.white("\u2022 src/components/authverse/GithubOAuthButton.tsx")
|
|
1546
2081
|
);
|
|
1547
2082
|
} catch (error) {
|
|
1548
|
-
console.log(
|
|
2083
|
+
console.log(chalk15.red("githubRunTanstackState error:"), error);
|
|
1549
2084
|
}
|
|
1550
2085
|
};
|
|
1551
2086
|
|
|
1552
2087
|
// oauth/facebookNext.ts
|
|
1553
|
-
import
|
|
1554
|
-
import
|
|
1555
|
-
import
|
|
1556
|
-
import { fileURLToPath as
|
|
2088
|
+
import chalk16 from "chalk";
|
|
2089
|
+
import fs16 from "fs";
|
|
2090
|
+
import path16 from "path";
|
|
2091
|
+
import { fileURLToPath as fileURLToPath13 } from "url";
|
|
1557
2092
|
var facebookNext = async () => {
|
|
1558
2093
|
try {
|
|
1559
|
-
const __filename =
|
|
1560
|
-
const __dirname =
|
|
2094
|
+
const __filename = fileURLToPath13(import.meta.url);
|
|
2095
|
+
const __dirname = path16.dirname(__filename);
|
|
1561
2096
|
const projectDir = process.cwd();
|
|
1562
|
-
const srcPath =
|
|
1563
|
-
const folder =
|
|
1564
|
-
const authFilePath =
|
|
1565
|
-
if (!
|
|
1566
|
-
console.log(
|
|
1567
|
-
console.log(
|
|
2097
|
+
const srcPath = path16.join(projectDir, "src");
|
|
2098
|
+
const folder = fs16.existsSync(srcPath) ? "src" : "";
|
|
2099
|
+
const authFilePath = path16.join(projectDir, folder, "lib", "auth.ts");
|
|
2100
|
+
if (!fs16.existsSync(authFilePath)) {
|
|
2101
|
+
console.log(chalk16.red("No Configured Better Auth file found"));
|
|
2102
|
+
console.log(chalk16.cyan("Run authverse init to initialize better auth"));
|
|
1568
2103
|
return;
|
|
1569
2104
|
}
|
|
1570
|
-
let content =
|
|
2105
|
+
let content = fs16.readFileSync(authFilePath, "utf8");
|
|
1571
2106
|
if (!content.includes("betterAuth({")) {
|
|
1572
|
-
console.log(
|
|
2107
|
+
console.log(chalk16.red("betterAuth({}) block not found"));
|
|
1573
2108
|
return;
|
|
1574
2109
|
}
|
|
1575
2110
|
if (content.includes("socialProviders") && content.includes("facebook:")) {
|
|
1576
|
-
console.log(
|
|
2111
|
+
console.log(chalk16.yellow("Facebook provider already exists"));
|
|
1577
2112
|
return;
|
|
1578
2113
|
}
|
|
1579
2114
|
const facebookProviderEntry = `
|
|
@@ -1596,7 +2131,7 @@ var facebookNext = async () => {
|
|
|
1596
2131
|
}
|
|
1597
2132
|
}
|
|
1598
2133
|
if (insertPos === -1) {
|
|
1599
|
-
console.log(
|
|
2134
|
+
console.log(chalk16.red("Failed to parse socialProviders block"));
|
|
1600
2135
|
return;
|
|
1601
2136
|
}
|
|
1602
2137
|
content = content.slice(0, insertPos) + facebookProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1604,7 +2139,7 @@ var facebookNext = async () => {
|
|
|
1604
2139
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1605
2140
|
if (!databaseRegex.test(content)) {
|
|
1606
2141
|
console.log(
|
|
1607
|
-
|
|
2142
|
+
chalk16.red(
|
|
1608
2143
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1609
2144
|
)
|
|
1610
2145
|
);
|
|
@@ -1620,12 +2155,12 @@ ${facebookProviderEntry}
|
|
|
1620
2155
|
${socialProvidersBlock}`
|
|
1621
2156
|
);
|
|
1622
2157
|
}
|
|
1623
|
-
|
|
1624
|
-
const envPath =
|
|
1625
|
-
if (
|
|
1626
|
-
const envContent =
|
|
2158
|
+
fs16.writeFileSync(authFilePath, content, "utf8");
|
|
2159
|
+
const envPath = path16.join(projectDir, ".env");
|
|
2160
|
+
if (fs16.existsSync(envPath)) {
|
|
2161
|
+
const envContent = fs16.readFileSync(envPath, "utf8");
|
|
1627
2162
|
if (!envContent.includes("FACEBOOK_CLIENT_ID")) {
|
|
1628
|
-
|
|
2163
|
+
fs16.appendFileSync(
|
|
1629
2164
|
envPath,
|
|
1630
2165
|
`
|
|
1631
2166
|
|
|
@@ -1636,59 +2171,59 @@ FACEBOOK_CLIENT_SECRET=
|
|
|
1636
2171
|
);
|
|
1637
2172
|
}
|
|
1638
2173
|
}
|
|
1639
|
-
const componentTemplate =
|
|
2174
|
+
const componentTemplate = path16.resolve(
|
|
1640
2175
|
__dirname,
|
|
1641
2176
|
"./template/components/FacebookOAuthButton.tsx"
|
|
1642
2177
|
);
|
|
1643
|
-
const componentsDir =
|
|
2178
|
+
const componentsDir = path16.join(
|
|
1644
2179
|
projectDir,
|
|
1645
2180
|
folder,
|
|
1646
2181
|
"components",
|
|
1647
2182
|
"authverse"
|
|
1648
2183
|
);
|
|
1649
|
-
if (!
|
|
1650
|
-
|
|
2184
|
+
if (!fs16.existsSync(componentsDir)) {
|
|
2185
|
+
fs16.mkdirSync(componentsDir, { recursive: true });
|
|
1651
2186
|
}
|
|
1652
|
-
const componentDest =
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
2187
|
+
const componentDest = path16.join(componentsDir, "FacebookOAuthButton.tsx");
|
|
2188
|
+
if (fs16.existsSync(componentTemplate)) {
|
|
2189
|
+
fs16.copyFileSync(componentTemplate, componentDest);
|
|
1655
2190
|
}
|
|
1656
|
-
console.log(
|
|
2191
|
+
console.log(chalk16.green("Facebook provider added & merged successfully\n"));
|
|
1657
2192
|
console.log(
|
|
1658
|
-
|
|
2193
|
+
chalk16.white(
|
|
1659
2194
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/FacebookOAuthButton.tsx" })}
|
|
1660
2195
|
`
|
|
1661
2196
|
)
|
|
1662
2197
|
);
|
|
1663
2198
|
} catch (error) {
|
|
1664
|
-
console.log(
|
|
2199
|
+
console.log(chalk16.red("facebookRun error:"), error);
|
|
1665
2200
|
}
|
|
1666
2201
|
};
|
|
1667
2202
|
|
|
1668
2203
|
// oauth/facebookTanstackStart.ts
|
|
1669
|
-
import
|
|
1670
|
-
import
|
|
1671
|
-
import
|
|
1672
|
-
import { fileURLToPath as
|
|
2204
|
+
import chalk17 from "chalk";
|
|
2205
|
+
import fs17 from "fs";
|
|
2206
|
+
import path17 from "path";
|
|
2207
|
+
import { fileURLToPath as fileURLToPath14 } from "url";
|
|
1673
2208
|
var facebookTanstackStart = async () => {
|
|
1674
2209
|
try {
|
|
1675
|
-
const __filename =
|
|
1676
|
-
const __dirname =
|
|
2210
|
+
const __filename = fileURLToPath14(import.meta.url);
|
|
2211
|
+
const __dirname = path17.dirname(__filename);
|
|
1677
2212
|
const projectDir = process.cwd();
|
|
1678
|
-
const srcPath =
|
|
1679
|
-
const authFilePath =
|
|
1680
|
-
if (!
|
|
1681
|
-
console.log(
|
|
1682
|
-
console.log(
|
|
2213
|
+
const srcPath = path17.join(projectDir, "src");
|
|
2214
|
+
const authFilePath = path17.join(srcPath, "lib", "auth.ts");
|
|
2215
|
+
if (!fs17.existsSync(authFilePath)) {
|
|
2216
|
+
console.log(chalk17.red("No Configured Better Auth file found"));
|
|
2217
|
+
console.log(chalk17.cyan("Run authverse init to initialize better auth"));
|
|
1683
2218
|
return;
|
|
1684
2219
|
}
|
|
1685
|
-
let content =
|
|
2220
|
+
let content = fs17.readFileSync(authFilePath, "utf8");
|
|
1686
2221
|
if (!content.includes("betterAuth({")) {
|
|
1687
|
-
console.log(
|
|
2222
|
+
console.log(chalk17.red("betterAuth({}) block not found"));
|
|
1688
2223
|
return;
|
|
1689
2224
|
}
|
|
1690
2225
|
if (content.includes("socialProviders") && content.includes("facebook:")) {
|
|
1691
|
-
console.log(
|
|
2226
|
+
console.log(chalk17.yellow("Facebook provider already exists"));
|
|
1692
2227
|
return;
|
|
1693
2228
|
}
|
|
1694
2229
|
const facebookProviderEntry = `
|
|
@@ -1711,7 +2246,7 @@ var facebookTanstackStart = async () => {
|
|
|
1711
2246
|
}
|
|
1712
2247
|
}
|
|
1713
2248
|
if (insertPos === -1) {
|
|
1714
|
-
console.log(
|
|
2249
|
+
console.log(chalk17.red("Failed to parse socialProviders block"));
|
|
1715
2250
|
return;
|
|
1716
2251
|
}
|
|
1717
2252
|
content = content.slice(0, insertPos) + facebookProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1719,7 +2254,7 @@ var facebookTanstackStart = async () => {
|
|
|
1719
2254
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1720
2255
|
if (!databaseRegex.test(content)) {
|
|
1721
2256
|
console.log(
|
|
1722
|
-
|
|
2257
|
+
chalk17.red(
|
|
1723
2258
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1724
2259
|
)
|
|
1725
2260
|
);
|
|
@@ -1735,12 +2270,12 @@ ${facebookProviderEntry}
|
|
|
1735
2270
|
${socialProvidersBlock}`
|
|
1736
2271
|
);
|
|
1737
2272
|
}
|
|
1738
|
-
|
|
1739
|
-
const envPath =
|
|
1740
|
-
if (
|
|
1741
|
-
const envContent =
|
|
2273
|
+
fs17.writeFileSync(authFilePath, content, "utf8");
|
|
2274
|
+
const envPath = path17.join(projectDir, ".env");
|
|
2275
|
+
if (fs17.existsSync(envPath)) {
|
|
2276
|
+
const envContent = fs17.readFileSync(envPath, "utf8");
|
|
1742
2277
|
if (!envContent.includes("FACEBOOK_CLIENT_ID")) {
|
|
1743
|
-
|
|
2278
|
+
fs17.appendFileSync(
|
|
1744
2279
|
envPath,
|
|
1745
2280
|
`
|
|
1746
2281
|
|
|
@@ -1751,52 +2286,52 @@ FACEBOOK_CLIENT_SECRET=
|
|
|
1751
2286
|
);
|
|
1752
2287
|
}
|
|
1753
2288
|
}
|
|
1754
|
-
const componentTemplate =
|
|
2289
|
+
const componentTemplate = path17.resolve(
|
|
1755
2290
|
__dirname,
|
|
1756
2291
|
"./template/TanstackStart/components/FacebookOAuthButton.tsx"
|
|
1757
2292
|
);
|
|
1758
|
-
const componentsDir =
|
|
1759
|
-
if (!
|
|
1760
|
-
|
|
2293
|
+
const componentsDir = path17.join(srcPath, "components", "authverse");
|
|
2294
|
+
if (!fs17.existsSync(componentsDir)) {
|
|
2295
|
+
fs17.mkdirSync(componentsDir, { recursive: true });
|
|
1761
2296
|
}
|
|
1762
|
-
const componentDest =
|
|
1763
|
-
if (
|
|
1764
|
-
|
|
2297
|
+
const componentDest = path17.join(componentsDir, "FacebookOAuthButton.tsx");
|
|
2298
|
+
if (fs17.existsSync(componentTemplate)) {
|
|
2299
|
+
fs17.copyFileSync(componentTemplate, componentDest);
|
|
1765
2300
|
}
|
|
1766
|
-
console.log(
|
|
2301
|
+
console.log(chalk17.green("Facebook provider added & merged successfully\n"));
|
|
1767
2302
|
console.log(
|
|
1768
|
-
|
|
2303
|
+
chalk17.white("\u2022 src/components/authverse/FacebookOAuthButton.tsx")
|
|
1769
2304
|
);
|
|
1770
2305
|
} catch (error) {
|
|
1771
|
-
console.log(
|
|
2306
|
+
console.log(chalk17.red("facebookRunTanstackState error:"), error);
|
|
1772
2307
|
}
|
|
1773
2308
|
};
|
|
1774
2309
|
|
|
1775
2310
|
// oauth/LinkedInNext.ts
|
|
1776
|
-
import
|
|
1777
|
-
import
|
|
1778
|
-
import
|
|
1779
|
-
import { fileURLToPath as
|
|
2311
|
+
import chalk18 from "chalk";
|
|
2312
|
+
import fs18 from "fs";
|
|
2313
|
+
import path18 from "path";
|
|
2314
|
+
import { fileURLToPath as fileURLToPath15 } from "url";
|
|
1780
2315
|
var LinkedInNext = async () => {
|
|
1781
2316
|
try {
|
|
1782
|
-
const __filename =
|
|
1783
|
-
const __dirname =
|
|
2317
|
+
const __filename = fileURLToPath15(import.meta.url);
|
|
2318
|
+
const __dirname = path18.dirname(__filename);
|
|
1784
2319
|
const projectDir = process.cwd();
|
|
1785
|
-
const srcPath =
|
|
1786
|
-
const folder =
|
|
1787
|
-
const authFilePath =
|
|
1788
|
-
if (!
|
|
1789
|
-
console.log(
|
|
1790
|
-
console.log(
|
|
2320
|
+
const srcPath = path18.join(projectDir, "src");
|
|
2321
|
+
const folder = fs18.existsSync(srcPath) ? "src" : "";
|
|
2322
|
+
const authFilePath = path18.join(projectDir, folder, "lib", "auth.ts");
|
|
2323
|
+
if (!fs18.existsSync(authFilePath)) {
|
|
2324
|
+
console.log(chalk18.red("No Configured Better Auth file found"));
|
|
2325
|
+
console.log(chalk18.cyan("Run authverse init to initialize better auth"));
|
|
1791
2326
|
return;
|
|
1792
2327
|
}
|
|
1793
|
-
let content =
|
|
2328
|
+
let content = fs18.readFileSync(authFilePath, "utf8");
|
|
1794
2329
|
if (!content.includes("betterAuth({")) {
|
|
1795
|
-
console.log(
|
|
2330
|
+
console.log(chalk18.red("betterAuth({}) block not found"));
|
|
1796
2331
|
return;
|
|
1797
2332
|
}
|
|
1798
2333
|
if (content.includes("socialProviders") && content.includes("LinkedIn:")) {
|
|
1799
|
-
console.log(
|
|
2334
|
+
console.log(chalk18.yellow("LinkedIn provider already exists"));
|
|
1800
2335
|
return;
|
|
1801
2336
|
}
|
|
1802
2337
|
const LinkedInProviderEntry = `
|
|
@@ -1819,7 +2354,7 @@ var LinkedInNext = async () => {
|
|
|
1819
2354
|
}
|
|
1820
2355
|
}
|
|
1821
2356
|
if (insertPos === -1) {
|
|
1822
|
-
console.log(
|
|
2357
|
+
console.log(chalk18.red("Failed to parse socialProviders block"));
|
|
1823
2358
|
return;
|
|
1824
2359
|
}
|
|
1825
2360
|
content = content.slice(0, insertPos) + LinkedInProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1827,7 +2362,7 @@ var LinkedInNext = async () => {
|
|
|
1827
2362
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1828
2363
|
if (!databaseRegex.test(content)) {
|
|
1829
2364
|
console.log(
|
|
1830
|
-
|
|
2365
|
+
chalk18.red(
|
|
1831
2366
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1832
2367
|
)
|
|
1833
2368
|
);
|
|
@@ -1843,12 +2378,12 @@ ${LinkedInProviderEntry}
|
|
|
1843
2378
|
${socialProvidersBlock}`
|
|
1844
2379
|
);
|
|
1845
2380
|
}
|
|
1846
|
-
|
|
1847
|
-
const envPath =
|
|
1848
|
-
if (
|
|
1849
|
-
const envContent =
|
|
2381
|
+
fs18.writeFileSync(authFilePath, content, "utf8");
|
|
2382
|
+
const envPath = path18.join(projectDir, ".env");
|
|
2383
|
+
if (fs18.existsSync(envPath)) {
|
|
2384
|
+
const envContent = fs18.readFileSync(envPath, "utf8");
|
|
1850
2385
|
if (!envContent.includes("LINKEDIN_CLIENT_ID")) {
|
|
1851
|
-
|
|
2386
|
+
fs18.appendFileSync(
|
|
1852
2387
|
envPath,
|
|
1853
2388
|
`
|
|
1854
2389
|
|
|
@@ -1859,59 +2394,59 @@ LINKEDIN_CLIENT_SECRET=
|
|
|
1859
2394
|
);
|
|
1860
2395
|
}
|
|
1861
2396
|
}
|
|
1862
|
-
const componentTemplate =
|
|
2397
|
+
const componentTemplate = path18.resolve(
|
|
1863
2398
|
__dirname,
|
|
1864
2399
|
"./template/components/LinkedInOAuthButton.tsx"
|
|
1865
2400
|
);
|
|
1866
|
-
const componentsDir =
|
|
2401
|
+
const componentsDir = path18.join(
|
|
1867
2402
|
projectDir,
|
|
1868
2403
|
folder,
|
|
1869
2404
|
"components",
|
|
1870
2405
|
"authverse"
|
|
1871
2406
|
);
|
|
1872
|
-
if (!
|
|
1873
|
-
|
|
2407
|
+
if (!fs18.existsSync(componentsDir)) {
|
|
2408
|
+
fs18.mkdirSync(componentsDir, { recursive: true });
|
|
1874
2409
|
}
|
|
1875
|
-
const componentDest =
|
|
1876
|
-
if (
|
|
1877
|
-
|
|
2410
|
+
const componentDest = path18.join(componentsDir, "LinkedInOAuthButton.tsx");
|
|
2411
|
+
if (fs18.existsSync(componentTemplate)) {
|
|
2412
|
+
fs18.copyFileSync(componentTemplate, componentDest);
|
|
1878
2413
|
}
|
|
1879
|
-
console.log(
|
|
2414
|
+
console.log(chalk18.green("LinkedIn provider added & merged successfully\n"));
|
|
1880
2415
|
console.log(
|
|
1881
|
-
|
|
2416
|
+
chalk18.white(
|
|
1882
2417
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/LinkedInOAuthButton.tsx" })}
|
|
1883
2418
|
`
|
|
1884
2419
|
)
|
|
1885
2420
|
);
|
|
1886
2421
|
} catch (error) {
|
|
1887
|
-
console.log(
|
|
2422
|
+
console.log(chalk18.red("LinkedIn error:"), error);
|
|
1888
2423
|
}
|
|
1889
2424
|
};
|
|
1890
2425
|
|
|
1891
2426
|
// oauth/LinkedInTanstackStart.ts
|
|
1892
|
-
import
|
|
1893
|
-
import
|
|
1894
|
-
import
|
|
1895
|
-
import { fileURLToPath as
|
|
2427
|
+
import chalk19 from "chalk";
|
|
2428
|
+
import fs19 from "fs";
|
|
2429
|
+
import path19 from "path";
|
|
2430
|
+
import { fileURLToPath as fileURLToPath16 } from "url";
|
|
1896
2431
|
var LinkedInTanstackStart = async () => {
|
|
1897
2432
|
try {
|
|
1898
|
-
const __filename =
|
|
1899
|
-
const __dirname =
|
|
2433
|
+
const __filename = fileURLToPath16(import.meta.url);
|
|
2434
|
+
const __dirname = path19.dirname(__filename);
|
|
1900
2435
|
const projectDir = process.cwd();
|
|
1901
|
-
const srcPath =
|
|
1902
|
-
const authFilePath =
|
|
1903
|
-
if (!
|
|
1904
|
-
console.log(
|
|
1905
|
-
console.log(
|
|
2436
|
+
const srcPath = path19.join(projectDir, "src");
|
|
2437
|
+
const authFilePath = path19.join(srcPath, "lib", "auth.ts");
|
|
2438
|
+
if (!fs19.existsSync(authFilePath)) {
|
|
2439
|
+
console.log(chalk19.red("No Configured Better Auth file found"));
|
|
2440
|
+
console.log(chalk19.cyan("Run authverse init to initialize better auth"));
|
|
1906
2441
|
return;
|
|
1907
2442
|
}
|
|
1908
|
-
let content =
|
|
2443
|
+
let content = fs19.readFileSync(authFilePath, "utf8");
|
|
1909
2444
|
if (!content.includes("betterAuth({")) {
|
|
1910
|
-
console.log(
|
|
2445
|
+
console.log(chalk19.red("betterAuth({}) block not found"));
|
|
1911
2446
|
return;
|
|
1912
2447
|
}
|
|
1913
2448
|
if (content.includes("socialProviders") && content.includes("linkedin:")) {
|
|
1914
|
-
console.log(
|
|
2449
|
+
console.log(chalk19.yellow("LinkedIn provider already exists"));
|
|
1915
2450
|
return;
|
|
1916
2451
|
}
|
|
1917
2452
|
const LinkedInProviderEntry = `
|
|
@@ -1934,7 +2469,7 @@ var LinkedInTanstackStart = async () => {
|
|
|
1934
2469
|
}
|
|
1935
2470
|
}
|
|
1936
2471
|
if (insertPos === -1) {
|
|
1937
|
-
console.log(
|
|
2472
|
+
console.log(chalk19.red("Failed to parse socialProviders block"));
|
|
1938
2473
|
return;
|
|
1939
2474
|
}
|
|
1940
2475
|
content = content.slice(0, insertPos) + LinkedInProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -1942,7 +2477,7 @@ var LinkedInTanstackStart = async () => {
|
|
|
1942
2477
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
1943
2478
|
if (!databaseRegex.test(content)) {
|
|
1944
2479
|
console.log(
|
|
1945
|
-
|
|
2480
|
+
chalk19.red(
|
|
1946
2481
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
1947
2482
|
)
|
|
1948
2483
|
);
|
|
@@ -1958,12 +2493,12 @@ ${LinkedInProviderEntry}
|
|
|
1958
2493
|
${socialProvidersBlock}`
|
|
1959
2494
|
);
|
|
1960
2495
|
}
|
|
1961
|
-
|
|
1962
|
-
const envPath =
|
|
1963
|
-
if (
|
|
1964
|
-
const envContent =
|
|
2496
|
+
fs19.writeFileSync(authFilePath, content, "utf8");
|
|
2497
|
+
const envPath = path19.join(projectDir, ".env");
|
|
2498
|
+
if (fs19.existsSync(envPath)) {
|
|
2499
|
+
const envContent = fs19.readFileSync(envPath, "utf8");
|
|
1965
2500
|
if (!envContent.includes("LINKEDIN_CLIENT_ID")) {
|
|
1966
|
-
|
|
2501
|
+
fs19.appendFileSync(
|
|
1967
2502
|
envPath,
|
|
1968
2503
|
`
|
|
1969
2504
|
|
|
@@ -1974,52 +2509,52 @@ LINKEDIN_CLIENT_SECRET=
|
|
|
1974
2509
|
);
|
|
1975
2510
|
}
|
|
1976
2511
|
}
|
|
1977
|
-
const componentTemplate =
|
|
2512
|
+
const componentTemplate = path19.resolve(
|
|
1978
2513
|
__dirname,
|
|
1979
2514
|
"./template/TanstackStart/components/LinkedInOAuthButton.tsx"
|
|
1980
2515
|
);
|
|
1981
|
-
const componentsDir =
|
|
1982
|
-
if (!
|
|
1983
|
-
|
|
2516
|
+
const componentsDir = path19.join(srcPath, "components", "authverse");
|
|
2517
|
+
if (!fs19.existsSync(componentsDir)) {
|
|
2518
|
+
fs19.mkdirSync(componentsDir, { recursive: true });
|
|
1984
2519
|
}
|
|
1985
|
-
const componentDest =
|
|
1986
|
-
if (
|
|
1987
|
-
|
|
2520
|
+
const componentDest = path19.join(componentsDir, "LinkedInOAuthButton.tsx");
|
|
2521
|
+
if (fs19.existsSync(componentTemplate)) {
|
|
2522
|
+
fs19.copyFileSync(componentTemplate, componentDest);
|
|
1988
2523
|
}
|
|
1989
|
-
console.log(
|
|
2524
|
+
console.log(chalk19.green("LinkedIn provider added & merged successfully\n"));
|
|
1990
2525
|
console.log(
|
|
1991
|
-
|
|
2526
|
+
chalk19.white("\u2022 src/components/authverse/LinkedInOAuthButton.tsx")
|
|
1992
2527
|
);
|
|
1993
2528
|
} catch (error) {
|
|
1994
|
-
console.log(
|
|
2529
|
+
console.log(chalk19.red("LinkedInTanstackState error:"), error);
|
|
1995
2530
|
}
|
|
1996
2531
|
};
|
|
1997
2532
|
|
|
1998
2533
|
// oauth/twitterNext.ts
|
|
1999
|
-
import
|
|
2000
|
-
import
|
|
2001
|
-
import
|
|
2002
|
-
import { fileURLToPath as
|
|
2534
|
+
import chalk20 from "chalk";
|
|
2535
|
+
import fs20 from "fs";
|
|
2536
|
+
import path20 from "path";
|
|
2537
|
+
import { fileURLToPath as fileURLToPath17 } from "url";
|
|
2003
2538
|
var twitterNext = async () => {
|
|
2004
2539
|
try {
|
|
2005
|
-
const __filename =
|
|
2006
|
-
const __dirname =
|
|
2540
|
+
const __filename = fileURLToPath17(import.meta.url);
|
|
2541
|
+
const __dirname = path20.dirname(__filename);
|
|
2007
2542
|
const projectDir = process.cwd();
|
|
2008
|
-
const srcPath =
|
|
2009
|
-
const folder =
|
|
2010
|
-
const authFilePath =
|
|
2011
|
-
if (!
|
|
2012
|
-
console.log(
|
|
2013
|
-
console.log(
|
|
2543
|
+
const srcPath = path20.join(projectDir, "src");
|
|
2544
|
+
const folder = fs20.existsSync(srcPath) ? "src" : "";
|
|
2545
|
+
const authFilePath = path20.join(projectDir, folder, "lib", "auth.ts");
|
|
2546
|
+
if (!fs20.existsSync(authFilePath)) {
|
|
2547
|
+
console.log(chalk20.red("No Configured Better Auth file found"));
|
|
2548
|
+
console.log(chalk20.cyan("Run authverse init to initialize better auth"));
|
|
2014
2549
|
return;
|
|
2015
2550
|
}
|
|
2016
|
-
let content =
|
|
2551
|
+
let content = fs20.readFileSync(authFilePath, "utf8");
|
|
2017
2552
|
if (!content.includes("betterAuth({")) {
|
|
2018
|
-
console.log(
|
|
2553
|
+
console.log(chalk20.red("betterAuth({}) block not found"));
|
|
2019
2554
|
return;
|
|
2020
2555
|
}
|
|
2021
2556
|
if (content.includes("socialProviders") && content.includes("twitter:")) {
|
|
2022
|
-
console.log(
|
|
2557
|
+
console.log(chalk20.yellow("twitter provider already exists"));
|
|
2023
2558
|
return;
|
|
2024
2559
|
}
|
|
2025
2560
|
const twitterProviderEntry = `
|
|
@@ -2042,7 +2577,7 @@ var twitterNext = async () => {
|
|
|
2042
2577
|
}
|
|
2043
2578
|
}
|
|
2044
2579
|
if (insertPos === -1) {
|
|
2045
|
-
console.log(
|
|
2580
|
+
console.log(chalk20.red("Failed to parse socialProviders block"));
|
|
2046
2581
|
return;
|
|
2047
2582
|
}
|
|
2048
2583
|
content = content.slice(0, insertPos) + twitterProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -2050,7 +2585,7 @@ var twitterNext = async () => {
|
|
|
2050
2585
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
2051
2586
|
if (!databaseRegex.test(content)) {
|
|
2052
2587
|
console.log(
|
|
2053
|
-
|
|
2588
|
+
chalk20.red(
|
|
2054
2589
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
2055
2590
|
)
|
|
2056
2591
|
);
|
|
@@ -2066,12 +2601,12 @@ ${twitterProviderEntry}
|
|
|
2066
2601
|
${socialProvidersBlock}`
|
|
2067
2602
|
);
|
|
2068
2603
|
}
|
|
2069
|
-
|
|
2070
|
-
const envPath =
|
|
2071
|
-
if (
|
|
2072
|
-
const envContent =
|
|
2604
|
+
fs20.writeFileSync(authFilePath, content, "utf8");
|
|
2605
|
+
const envPath = path20.join(projectDir, ".env");
|
|
2606
|
+
if (fs20.existsSync(envPath)) {
|
|
2607
|
+
const envContent = fs20.readFileSync(envPath, "utf8");
|
|
2073
2608
|
if (!envContent.includes("TWITTER_CLIENT_ID")) {
|
|
2074
|
-
|
|
2609
|
+
fs20.appendFileSync(
|
|
2075
2610
|
envPath,
|
|
2076
2611
|
`
|
|
2077
2612
|
|
|
@@ -2082,59 +2617,59 @@ TWITTER_CLIENT_SECRET=
|
|
|
2082
2617
|
);
|
|
2083
2618
|
}
|
|
2084
2619
|
}
|
|
2085
|
-
const componentTemplate =
|
|
2620
|
+
const componentTemplate = path20.resolve(
|
|
2086
2621
|
__dirname,
|
|
2087
2622
|
"./template/components/twitterOAuthButton.tsx"
|
|
2088
2623
|
);
|
|
2089
|
-
const componentsDir =
|
|
2624
|
+
const componentsDir = path20.join(
|
|
2090
2625
|
projectDir,
|
|
2091
2626
|
folder,
|
|
2092
2627
|
"components",
|
|
2093
2628
|
"authverse"
|
|
2094
2629
|
);
|
|
2095
|
-
if (!
|
|
2096
|
-
|
|
2630
|
+
if (!fs20.existsSync(componentsDir)) {
|
|
2631
|
+
fs20.mkdirSync(componentsDir, { recursive: true });
|
|
2097
2632
|
}
|
|
2098
|
-
const componentDest =
|
|
2099
|
-
if (
|
|
2100
|
-
|
|
2633
|
+
const componentDest = path20.join(componentsDir, "twitterOAuthButton.tsx");
|
|
2634
|
+
if (fs20.existsSync(componentTemplate)) {
|
|
2635
|
+
fs20.copyFileSync(componentTemplate, componentDest);
|
|
2101
2636
|
}
|
|
2102
|
-
console.log(
|
|
2637
|
+
console.log(chalk20.green("Twitter provider added & merged successfully\n"));
|
|
2103
2638
|
console.log(
|
|
2104
|
-
|
|
2639
|
+
chalk20.white(
|
|
2105
2640
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/TwitterOAuthButton.tsx" })}
|
|
2106
2641
|
`
|
|
2107
2642
|
)
|
|
2108
2643
|
);
|
|
2109
2644
|
} catch (error) {
|
|
2110
|
-
console.log(
|
|
2645
|
+
console.log(chalk20.red("twitter error:"), error);
|
|
2111
2646
|
}
|
|
2112
2647
|
};
|
|
2113
2648
|
|
|
2114
2649
|
// oauth/twitterTanstackStart.ts
|
|
2115
|
-
import
|
|
2116
|
-
import
|
|
2117
|
-
import
|
|
2118
|
-
import { fileURLToPath as
|
|
2650
|
+
import chalk21 from "chalk";
|
|
2651
|
+
import fs21 from "fs";
|
|
2652
|
+
import path21 from "path";
|
|
2653
|
+
import { fileURLToPath as fileURLToPath18 } from "url";
|
|
2119
2654
|
var twitterTanstackStart = async () => {
|
|
2120
2655
|
try {
|
|
2121
|
-
const __filename =
|
|
2122
|
-
const __dirname =
|
|
2656
|
+
const __filename = fileURLToPath18(import.meta.url);
|
|
2657
|
+
const __dirname = path21.dirname(__filename);
|
|
2123
2658
|
const projectDir = process.cwd();
|
|
2124
|
-
const srcPath =
|
|
2125
|
-
const authFilePath =
|
|
2126
|
-
if (!
|
|
2127
|
-
console.log(
|
|
2128
|
-
console.log(
|
|
2659
|
+
const srcPath = path21.join(projectDir, "src");
|
|
2660
|
+
const authFilePath = path21.join(srcPath, "lib", "auth.ts");
|
|
2661
|
+
if (!fs21.existsSync(authFilePath)) {
|
|
2662
|
+
console.log(chalk21.red("No Configured Better Auth file found"));
|
|
2663
|
+
console.log(chalk21.cyan("Run authverse init to initialize better auth"));
|
|
2129
2664
|
return;
|
|
2130
2665
|
}
|
|
2131
|
-
let content =
|
|
2666
|
+
let content = fs21.readFileSync(authFilePath, "utf8");
|
|
2132
2667
|
if (!content.includes("betterAuth({")) {
|
|
2133
|
-
console.log(
|
|
2668
|
+
console.log(chalk21.red("betterAuth({}) block not found"));
|
|
2134
2669
|
return;
|
|
2135
2670
|
}
|
|
2136
2671
|
if (content.includes("socialProviders") && content.includes("twitter:")) {
|
|
2137
|
-
console.log(
|
|
2672
|
+
console.log(chalk21.yellow("twitter provider already exists"));
|
|
2138
2673
|
return;
|
|
2139
2674
|
}
|
|
2140
2675
|
const twitterProviderEntry = `
|
|
@@ -2157,7 +2692,7 @@ var twitterTanstackStart = async () => {
|
|
|
2157
2692
|
}
|
|
2158
2693
|
}
|
|
2159
2694
|
if (insertPos === -1) {
|
|
2160
|
-
console.log(
|
|
2695
|
+
console.log(chalk21.red("Failed to parse socialProviders block"));
|
|
2161
2696
|
return;
|
|
2162
2697
|
}
|
|
2163
2698
|
content = content.slice(0, insertPos) + twitterProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -2165,7 +2700,7 @@ var twitterTanstackStart = async () => {
|
|
|
2165
2700
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
2166
2701
|
if (!databaseRegex.test(content)) {
|
|
2167
2702
|
console.log(
|
|
2168
|
-
|
|
2703
|
+
chalk21.red(
|
|
2169
2704
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
2170
2705
|
)
|
|
2171
2706
|
);
|
|
@@ -2181,12 +2716,12 @@ ${twitterProviderEntry}
|
|
|
2181
2716
|
${socialProvidersBlock}`
|
|
2182
2717
|
);
|
|
2183
2718
|
}
|
|
2184
|
-
|
|
2185
|
-
const envPath =
|
|
2186
|
-
if (
|
|
2187
|
-
const envContent =
|
|
2719
|
+
fs21.writeFileSync(authFilePath, content, "utf8");
|
|
2720
|
+
const envPath = path21.join(projectDir, ".env");
|
|
2721
|
+
if (fs21.existsSync(envPath)) {
|
|
2722
|
+
const envContent = fs21.readFileSync(envPath, "utf8");
|
|
2188
2723
|
if (!envContent.includes("TWITTER_CLIENT_ID")) {
|
|
2189
|
-
|
|
2724
|
+
fs21.appendFileSync(
|
|
2190
2725
|
envPath,
|
|
2191
2726
|
`
|
|
2192
2727
|
|
|
@@ -2197,53 +2732,53 @@ TWITTER_CLIENT_SECRET=
|
|
|
2197
2732
|
);
|
|
2198
2733
|
}
|
|
2199
2734
|
}
|
|
2200
|
-
const componentTemplate =
|
|
2735
|
+
const componentTemplate = path21.resolve(
|
|
2201
2736
|
__dirname,
|
|
2202
2737
|
"./template/TanstackStart/components/twitterOAuthButton.tsx"
|
|
2203
2738
|
);
|
|
2204
|
-
const componentsDir =
|
|
2205
|
-
if (!
|
|
2206
|
-
|
|
2739
|
+
const componentsDir = path21.join(srcPath, "components", "authverse");
|
|
2740
|
+
if (!fs21.existsSync(componentsDir)) {
|
|
2741
|
+
fs21.mkdirSync(componentsDir, { recursive: true });
|
|
2207
2742
|
}
|
|
2208
|
-
const componentDest =
|
|
2209
|
-
if (
|
|
2210
|
-
|
|
2743
|
+
const componentDest = path21.join(componentsDir, "twitterOAuthButton.tsx");
|
|
2744
|
+
if (fs21.existsSync(componentTemplate)) {
|
|
2745
|
+
fs21.copyFileSync(componentTemplate, componentDest);
|
|
2211
2746
|
}
|
|
2212
|
-
console.log(
|
|
2747
|
+
console.log(chalk21.green("twitter provider added & merged successfully\n"));
|
|
2213
2748
|
console.log(
|
|
2214
|
-
|
|
2749
|
+
chalk21.white("\u2022 src/components/authverse/twitterOAuthButton.tsx")
|
|
2215
2750
|
);
|
|
2216
2751
|
} catch (error) {
|
|
2217
|
-
console.log(
|
|
2752
|
+
console.log(chalk21.red("twitter tanstack state error:"), error);
|
|
2218
2753
|
}
|
|
2219
2754
|
};
|
|
2220
2755
|
|
|
2221
2756
|
// oauth/AppleNext.ts
|
|
2222
|
-
import
|
|
2223
|
-
import
|
|
2224
|
-
import
|
|
2225
|
-
import { fileURLToPath as
|
|
2757
|
+
import chalk22 from "chalk";
|
|
2758
|
+
import fs22 from "fs";
|
|
2759
|
+
import path22 from "path";
|
|
2760
|
+
import { fileURLToPath as fileURLToPath19 } from "url";
|
|
2226
2761
|
var AppleNext = async () => {
|
|
2227
2762
|
try {
|
|
2228
|
-
const __filename =
|
|
2229
|
-
const __dirname =
|
|
2763
|
+
const __filename = fileURLToPath19(import.meta.url);
|
|
2764
|
+
const __dirname = path22.dirname(__filename);
|
|
2230
2765
|
const projectDir = process.cwd();
|
|
2231
|
-
const srcPath =
|
|
2232
|
-
const folder =
|
|
2233
|
-
const authFilePath =
|
|
2234
|
-
if (!
|
|
2235
|
-
console.log(
|
|
2236
|
-
console.log(
|
|
2766
|
+
const srcPath = path22.join(projectDir, "src");
|
|
2767
|
+
const folder = fs22.existsSync(srcPath) ? "src" : "";
|
|
2768
|
+
const authFilePath = path22.join(projectDir, folder, "lib", "auth.ts");
|
|
2769
|
+
if (!fs22.existsSync(authFilePath)) {
|
|
2770
|
+
console.log(chalk22.red("No Configured Better Auth file found"));
|
|
2771
|
+
console.log(chalk22.cyan("Run authverse init to initialize better auth"));
|
|
2237
2772
|
return;
|
|
2238
2773
|
}
|
|
2239
|
-
let content =
|
|
2774
|
+
let content = fs22.readFileSync(authFilePath, "utf8");
|
|
2240
2775
|
if (!content.includes("betterAuth({")) {
|
|
2241
|
-
console.log(
|
|
2242
|
-
console.log(
|
|
2776
|
+
console.log(chalk22.red("betterAuth({}) block not found"));
|
|
2777
|
+
console.log(chalk22.cyan("Run authverse init to initialize better auth"));
|
|
2243
2778
|
return;
|
|
2244
2779
|
}
|
|
2245
2780
|
if (content.includes("socialProviders") && content.includes("apple:")) {
|
|
2246
|
-
console.log(
|
|
2781
|
+
console.log(chalk22.yellow("Apple provider already exists"));
|
|
2247
2782
|
return;
|
|
2248
2783
|
}
|
|
2249
2784
|
const appleProviderEntry = `
|
|
@@ -2268,7 +2803,7 @@ var AppleNext = async () => {
|
|
|
2268
2803
|
}
|
|
2269
2804
|
}
|
|
2270
2805
|
if (insertPos === -1) {
|
|
2271
|
-
console.log(
|
|
2806
|
+
console.log(chalk22.red("Failed to parse socialProviders block"));
|
|
2272
2807
|
return;
|
|
2273
2808
|
}
|
|
2274
2809
|
content = content.slice(0, insertPos) + appleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -2276,7 +2811,7 @@ var AppleNext = async () => {
|
|
|
2276
2811
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
2277
2812
|
if (!databaseRegex.test(content)) {
|
|
2278
2813
|
console.log(
|
|
2279
|
-
|
|
2814
|
+
chalk22.red(
|
|
2280
2815
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
2281
2816
|
)
|
|
2282
2817
|
);
|
|
@@ -2306,12 +2841,12 @@ ${socialProvidersBlock}`
|
|
|
2306
2841
|
content = content.slice(0, insertPos) + '\n trustedOrigins: ["https://appleid.apple.com"],' + content.slice(insertPos);
|
|
2307
2842
|
}
|
|
2308
2843
|
}
|
|
2309
|
-
|
|
2310
|
-
const envPath =
|
|
2311
|
-
if (
|
|
2312
|
-
const envContent =
|
|
2844
|
+
fs22.writeFileSync(authFilePath, content, "utf8");
|
|
2845
|
+
const envPath = path22.join(projectDir, ".env");
|
|
2846
|
+
if (fs22.existsSync(envPath)) {
|
|
2847
|
+
const envContent = fs22.readFileSync(envPath, "utf8");
|
|
2313
2848
|
if (!envContent.includes("APPLE_CLIENT_ID")) {
|
|
2314
|
-
|
|
2849
|
+
fs22.appendFileSync(
|
|
2315
2850
|
envPath,
|
|
2316
2851
|
`
|
|
2317
2852
|
|
|
@@ -2323,59 +2858,59 @@ APPLE_BUNDLE_ID=
|
|
|
2323
2858
|
);
|
|
2324
2859
|
}
|
|
2325
2860
|
}
|
|
2326
|
-
const componentTemplate =
|
|
2861
|
+
const componentTemplate = path22.resolve(
|
|
2327
2862
|
__dirname,
|
|
2328
2863
|
"./template/components/AppleOAuthButton.tsx"
|
|
2329
2864
|
);
|
|
2330
|
-
const componentsDir =
|
|
2865
|
+
const componentsDir = path22.join(
|
|
2331
2866
|
projectDir,
|
|
2332
2867
|
folder,
|
|
2333
2868
|
"components",
|
|
2334
2869
|
"authverse"
|
|
2335
2870
|
);
|
|
2336
|
-
if (!
|
|
2337
|
-
|
|
2871
|
+
if (!fs22.existsSync(componentsDir)) {
|
|
2872
|
+
fs22.mkdirSync(componentsDir, { recursive: true });
|
|
2338
2873
|
}
|
|
2339
|
-
const componentDest =
|
|
2340
|
-
if (
|
|
2341
|
-
|
|
2874
|
+
const componentDest = path22.join(componentsDir, "AppleOAuthButton.tsx");
|
|
2875
|
+
if (fs22.existsSync(componentTemplate)) {
|
|
2876
|
+
fs22.copyFileSync(componentTemplate, componentDest);
|
|
2342
2877
|
}
|
|
2343
|
-
console.log(
|
|
2878
|
+
console.log(chalk22.green("Apple provider added & merged successfully\n"));
|
|
2344
2879
|
console.log(
|
|
2345
|
-
|
|
2880
|
+
chalk22.white(
|
|
2346
2881
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/AppleOAuthButton.tsx" })}
|
|
2347
2882
|
`
|
|
2348
2883
|
)
|
|
2349
2884
|
);
|
|
2350
2885
|
} catch (error) {
|
|
2351
|
-
console.log(
|
|
2886
|
+
console.log(chalk22.red("apple next error:"), error);
|
|
2352
2887
|
}
|
|
2353
|
-
};
|
|
2354
|
-
|
|
2355
|
-
// oauth/AppleTanstackStart.ts
|
|
2356
|
-
import
|
|
2357
|
-
import
|
|
2358
|
-
import
|
|
2359
|
-
import { fileURLToPath as
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
// oauth/AppleTanstackStart.ts
|
|
2891
|
+
import chalk23 from "chalk";
|
|
2892
|
+
import fs23 from "fs";
|
|
2893
|
+
import path23 from "path";
|
|
2894
|
+
import { fileURLToPath as fileURLToPath20 } from "url";
|
|
2360
2895
|
var AppleTanstackStart = async () => {
|
|
2361
2896
|
try {
|
|
2362
|
-
const __filename =
|
|
2363
|
-
const __dirname =
|
|
2897
|
+
const __filename = fileURLToPath20(import.meta.url);
|
|
2898
|
+
const __dirname = path23.dirname(__filename);
|
|
2364
2899
|
const projectDir = process.cwd();
|
|
2365
|
-
const srcPath =
|
|
2366
|
-
const authFilePath =
|
|
2367
|
-
if (!
|
|
2368
|
-
console.log(
|
|
2369
|
-
console.log(
|
|
2900
|
+
const srcPath = path23.join(projectDir, "src");
|
|
2901
|
+
const authFilePath = path23.join(srcPath, "lib", "auth.ts");
|
|
2902
|
+
if (!fs23.existsSync(authFilePath)) {
|
|
2903
|
+
console.log(chalk23.red("No Configured Better Auth file found"));
|
|
2904
|
+
console.log(chalk23.cyan("Run authverse init to initialize better auth"));
|
|
2370
2905
|
return;
|
|
2371
2906
|
}
|
|
2372
|
-
let content =
|
|
2907
|
+
let content = fs23.readFileSync(authFilePath, "utf8");
|
|
2373
2908
|
if (!content.includes("betterAuth({")) {
|
|
2374
|
-
console.log(
|
|
2909
|
+
console.log(chalk23.red("betterAuth({}) block not found"));
|
|
2375
2910
|
return;
|
|
2376
2911
|
}
|
|
2377
2912
|
if (content.includes("socialProviders") && content.includes("apple:")) {
|
|
2378
|
-
console.log(
|
|
2913
|
+
console.log(chalk23.yellow("Apple provider already exists"));
|
|
2379
2914
|
return;
|
|
2380
2915
|
}
|
|
2381
2916
|
const appleProviderEntry = `
|
|
@@ -2400,7 +2935,7 @@ var AppleTanstackStart = async () => {
|
|
|
2400
2935
|
}
|
|
2401
2936
|
}
|
|
2402
2937
|
if (insertPos === -1) {
|
|
2403
|
-
console.log(
|
|
2938
|
+
console.log(chalk23.red("Failed to parse socialProviders block"));
|
|
2404
2939
|
return;
|
|
2405
2940
|
}
|
|
2406
2941
|
content = content.slice(0, insertPos) + appleProviderEntry + "\n " + content.slice(insertPos);
|
|
@@ -2408,7 +2943,7 @@ var AppleTanstackStart = async () => {
|
|
|
2408
2943
|
const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
|
|
2409
2944
|
if (!databaseRegex.test(content)) {
|
|
2410
2945
|
console.log(
|
|
2411
|
-
|
|
2946
|
+
chalk23.red(
|
|
2412
2947
|
"Could not find database adapter (prismaAdapter or drizzleAdapter)"
|
|
2413
2948
|
)
|
|
2414
2949
|
);
|
|
@@ -2438,12 +2973,12 @@ ${socialProvidersBlock}`
|
|
|
2438
2973
|
content = content.slice(0, insertPos) + '\n trustedOrigins: ["https://appleid.apple.com"],' + content.slice(insertPos);
|
|
2439
2974
|
}
|
|
2440
2975
|
}
|
|
2441
|
-
|
|
2442
|
-
const envPath =
|
|
2443
|
-
if (
|
|
2444
|
-
const envContent =
|
|
2976
|
+
fs23.writeFileSync(authFilePath, content, "utf8");
|
|
2977
|
+
const envPath = path23.join(projectDir, ".env");
|
|
2978
|
+
if (fs23.existsSync(envPath)) {
|
|
2979
|
+
const envContent = fs23.readFileSync(envPath, "utf8");
|
|
2445
2980
|
if (!envContent.includes("APPLE_CLIENT_ID")) {
|
|
2446
|
-
|
|
2981
|
+
fs23.appendFileSync(
|
|
2447
2982
|
envPath,
|
|
2448
2983
|
`
|
|
2449
2984
|
|
|
@@ -2455,22 +2990,22 @@ APPLE_BUNDLE_ID=
|
|
|
2455
2990
|
);
|
|
2456
2991
|
}
|
|
2457
2992
|
}
|
|
2458
|
-
const componentTemplate =
|
|
2993
|
+
const componentTemplate = path23.resolve(
|
|
2459
2994
|
__dirname,
|
|
2460
2995
|
"./template/TanstackStart/components/AppleOAuthButton.tsx"
|
|
2461
2996
|
);
|
|
2462
|
-
const componentsDir =
|
|
2463
|
-
if (!
|
|
2464
|
-
|
|
2997
|
+
const componentsDir = path23.join(srcPath, "components", "authverse");
|
|
2998
|
+
if (!fs23.existsSync(componentsDir)) {
|
|
2999
|
+
fs23.mkdirSync(componentsDir, { recursive: true });
|
|
2465
3000
|
}
|
|
2466
|
-
const componentDest =
|
|
2467
|
-
if (
|
|
2468
|
-
|
|
3001
|
+
const componentDest = path23.join(componentsDir, "AppleOAuthButton.tsx");
|
|
3002
|
+
if (fs23.existsSync(componentTemplate)) {
|
|
3003
|
+
fs23.copyFileSync(componentTemplate, componentDest);
|
|
2469
3004
|
}
|
|
2470
|
-
console.log(
|
|
2471
|
-
console.log(
|
|
3005
|
+
console.log(chalk23.green("Apple provider added & merged successfully\n"));
|
|
3006
|
+
console.log(chalk23.white("\u2022 src/components/authverse/AppleOAuthButton.tsx"));
|
|
2472
3007
|
} catch (error) {
|
|
2473
|
-
console.log(
|
|
3008
|
+
console.log(chalk23.red("apple tanstack state error:"), error);
|
|
2474
3009
|
}
|
|
2475
3010
|
};
|
|
2476
3011
|
|
|
@@ -2479,7 +3014,7 @@ var Oauth = async ({ oauth }) => {
|
|
|
2479
3014
|
try {
|
|
2480
3015
|
const { framework, error } = await getFramework();
|
|
2481
3016
|
if (error) {
|
|
2482
|
-
console.log(
|
|
3017
|
+
console.log(chalk24.red(error));
|
|
2483
3018
|
return;
|
|
2484
3019
|
}
|
|
2485
3020
|
if (framework === "Next js" && oauth == "google") {
|
|
@@ -2513,455 +3048,459 @@ var Oauth = async ({ oauth }) => {
|
|
|
2513
3048
|
await AppleTanstackStart();
|
|
2514
3049
|
}
|
|
2515
3050
|
if (oauth !== "google" && oauth !== "github" && oauth !== "facebook" && oauth !== "LinkedIn" && oauth !== "twitter" && oauth !== "apple") {
|
|
2516
|
-
console.log(
|
|
3051
|
+
console.log(chalk24.red("Invalid oauth provider"));
|
|
2517
3052
|
return;
|
|
2518
3053
|
}
|
|
2519
3054
|
} catch (error) {
|
|
2520
|
-
console.log(
|
|
3055
|
+
console.log(chalk24.red("Error adding oauth:"), error);
|
|
2521
3056
|
}
|
|
2522
3057
|
};
|
|
2523
3058
|
|
|
2524
3059
|
// script/forgetNext.ts
|
|
2525
|
-
import
|
|
2526
|
-
import
|
|
2527
|
-
import { fileURLToPath as
|
|
2528
|
-
import
|
|
3060
|
+
import chalk32 from "chalk";
|
|
3061
|
+
import path31 from "path";
|
|
3062
|
+
import { fileURLToPath as fileURLToPath27 } from "url";
|
|
3063
|
+
import fs31 from "fs";
|
|
2529
3064
|
|
|
2530
3065
|
// cli/email.ts
|
|
2531
|
-
import
|
|
2532
|
-
import
|
|
2533
|
-
import
|
|
3066
|
+
import path30 from "path";
|
|
3067
|
+
import fs30 from "fs";
|
|
3068
|
+
import inquirer5 from "inquirer";
|
|
2534
3069
|
|
|
2535
3070
|
// email/gmailRun.ts
|
|
2536
|
-
import
|
|
2537
|
-
import
|
|
2538
|
-
import
|
|
2539
|
-
import { fileURLToPath as
|
|
3071
|
+
import chalk25 from "chalk";
|
|
3072
|
+
import path24 from "path";
|
|
3073
|
+
import fs24 from "fs";
|
|
3074
|
+
import { fileURLToPath as fileURLToPath21 } from "url";
|
|
2540
3075
|
var gmailRun = async () => {
|
|
2541
3076
|
try {
|
|
2542
3077
|
const projectDir = process.cwd();
|
|
2543
|
-
const packageJsonPath =
|
|
2544
|
-
const packageJson2 = JSON.parse(
|
|
2545
|
-
const srcFolder =
|
|
2546
|
-
const __filename =
|
|
2547
|
-
const __dirname =
|
|
3078
|
+
const packageJsonPath = path24.join(projectDir, "package.json");
|
|
3079
|
+
const packageJson2 = JSON.parse(fs24.readFileSync(packageJsonPath, "utf-8"));
|
|
3080
|
+
const srcFolder = fs24.existsSync(path24.join(projectDir, "src")) ? "src" : "";
|
|
3081
|
+
const __filename = fileURLToPath21(import.meta.url);
|
|
3082
|
+
const __dirname = path24.dirname(__filename);
|
|
2548
3083
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
2549
|
-
console.log(
|
|
3084
|
+
console.log(chalk25.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
2550
3085
|
packageManager("nodemailer");
|
|
2551
3086
|
packageManager("@types/nodemailer", true);
|
|
2552
3087
|
}
|
|
2553
3088
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2554
|
-
console.log(
|
|
3089
|
+
console.log(chalk25.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2555
3090
|
packageManager("@react-email/components");
|
|
2556
3091
|
}
|
|
2557
3092
|
if (!packageJson2.dependencies?.["@react-email/render"]) {
|
|
2558
|
-
console.log(
|
|
3093
|
+
console.log(chalk25.cyan("\n\u2699\uFE0F Installing @react-email/render...\n"));
|
|
2559
3094
|
packageManager("@react-email/render");
|
|
2560
3095
|
}
|
|
2561
|
-
const envPath =
|
|
2562
|
-
const envContent =
|
|
3096
|
+
const envPath = path24.join(projectDir, ".env");
|
|
3097
|
+
const envContent = fs24.readFileSync(envPath, "utf8");
|
|
2563
3098
|
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")) {
|
|
2564
|
-
|
|
3099
|
+
fs24.appendFileSync(envPath, `
|
|
2565
3100
|
|
|
2566
3101
|
# Gmail API Key for sending emails`);
|
|
2567
|
-
|
|
3102
|
+
fs24.appendFileSync(envPath, `
|
|
2568
3103
|
GMAIL_HOST=`);
|
|
2569
|
-
|
|
3104
|
+
fs24.appendFileSync(envPath, `
|
|
2570
3105
|
GMAIL_PORT=`);
|
|
2571
|
-
|
|
3106
|
+
fs24.appendFileSync(envPath, `
|
|
2572
3107
|
GMAIL_SERVICE=`);
|
|
2573
|
-
|
|
3108
|
+
fs24.appendFileSync(envPath, `
|
|
2574
3109
|
GMAIL_MAIL=`);
|
|
2575
|
-
|
|
3110
|
+
fs24.appendFileSync(envPath, `
|
|
2576
3111
|
GMAIL_NAME=`);
|
|
2577
|
-
|
|
3112
|
+
fs24.appendFileSync(envPath, `
|
|
2578
3113
|
GMAIL_PASSWORD=`);
|
|
2579
3114
|
}
|
|
2580
|
-
const templatePath =
|
|
3115
|
+
const templatePath = path24.resolve(
|
|
2581
3116
|
__dirname,
|
|
2582
3117
|
"./template/email/emailGmail.ts"
|
|
2583
3118
|
);
|
|
2584
|
-
const libPath =
|
|
2585
|
-
if (!
|
|
2586
|
-
|
|
3119
|
+
const libPath = path24.join(projectDir, srcFolder, "lib");
|
|
3120
|
+
if (!fs24.existsSync(libPath)) {
|
|
3121
|
+
fs24.mkdirSync(libPath, { recursive: true });
|
|
2587
3122
|
}
|
|
2588
|
-
const libDestinationPath =
|
|
2589
|
-
|
|
2590
|
-
console.log(
|
|
2591
|
-
console.log(
|
|
3123
|
+
const libDestinationPath = path24.join(libPath, "email.ts");
|
|
3124
|
+
fs24.copyFileSync(templatePath, libDestinationPath);
|
|
3125
|
+
console.log(chalk25.green("\nCompleted installation successfully"));
|
|
3126
|
+
console.log(chalk25.cyan("\nInstall Package:"));
|
|
2592
3127
|
console.log(
|
|
2593
|
-
|
|
3128
|
+
chalk25.white(
|
|
2594
3129
|
`\u2022 nodemailer
|
|
2595
3130
|
\u2022 @react-email/components
|
|
2596
3131
|
\u2022 @react-email/render`
|
|
2597
3132
|
)
|
|
2598
3133
|
);
|
|
2599
|
-
console.log(
|
|
3134
|
+
console.log(chalk25.cyan("\nFiles created:"));
|
|
2600
3135
|
console.log(
|
|
2601
|
-
|
|
3136
|
+
chalk25.white(
|
|
2602
3137
|
`${CreateFolder({ srcFolder, destFolder: "lib/email.ts" })}
|
|
2603
3138
|
`
|
|
2604
3139
|
)
|
|
2605
3140
|
);
|
|
2606
3141
|
} catch (error) {
|
|
2607
|
-
console.log(
|
|
3142
|
+
console.log(chalk25.red(error));
|
|
2608
3143
|
}
|
|
2609
3144
|
};
|
|
2610
3145
|
|
|
2611
3146
|
// email/gmailRunTanstackStart.ts
|
|
2612
|
-
import
|
|
2613
|
-
import
|
|
2614
|
-
import
|
|
2615
|
-
import { fileURLToPath as
|
|
3147
|
+
import chalk26 from "chalk";
|
|
3148
|
+
import path25 from "path";
|
|
3149
|
+
import fs25 from "fs";
|
|
3150
|
+
import { fileURLToPath as fileURLToPath22 } from "url";
|
|
2616
3151
|
var gmailRunTanstackStart = async () => {
|
|
2617
3152
|
try {
|
|
2618
3153
|
const projectDir = process.cwd();
|
|
2619
|
-
const packageJsonPath =
|
|
2620
|
-
const packageJson2 = JSON.parse(
|
|
2621
|
-
const __filename =
|
|
2622
|
-
const __dirname =
|
|
3154
|
+
const packageJsonPath = path25.join(projectDir, "package.json");
|
|
3155
|
+
const packageJson2 = JSON.parse(fs25.readFileSync(packageJsonPath, "utf-8"));
|
|
3156
|
+
const __filename = fileURLToPath22(import.meta.url);
|
|
3157
|
+
const __dirname = path25.dirname(__filename);
|
|
2623
3158
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
2624
|
-
console.log(
|
|
3159
|
+
console.log(chalk26.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
2625
3160
|
packageManager("nodemailer");
|
|
2626
3161
|
packageManager("@types/nodemailer", true);
|
|
2627
3162
|
}
|
|
2628
3163
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2629
|
-
console.log(
|
|
3164
|
+
console.log(chalk26.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2630
3165
|
packageManager("@react-email/components");
|
|
2631
3166
|
}
|
|
2632
3167
|
if (!packageJson2.dependencies?.["@react-email/render"]) {
|
|
2633
|
-
console.log(
|
|
3168
|
+
console.log(chalk26.cyan("\n\u2699\uFE0F Installing @react-email/render...\n"));
|
|
2634
3169
|
packageManager("@react-email/render");
|
|
2635
3170
|
}
|
|
2636
|
-
const envPath =
|
|
2637
|
-
const envContent =
|
|
3171
|
+
const envPath = path25.join(projectDir, ".env");
|
|
3172
|
+
const envContent = fs25.readFileSync(envPath, "utf8");
|
|
2638
3173
|
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")) {
|
|
2639
|
-
|
|
3174
|
+
fs25.appendFileSync(envPath, `
|
|
2640
3175
|
|
|
2641
3176
|
# Gmail API Key for sending emails`);
|
|
2642
|
-
|
|
3177
|
+
fs25.appendFileSync(envPath, `
|
|
2643
3178
|
GMAIL_HOST=`);
|
|
2644
|
-
|
|
3179
|
+
fs25.appendFileSync(envPath, `
|
|
2645
3180
|
GMAIL_PORT=`);
|
|
2646
|
-
|
|
3181
|
+
fs25.appendFileSync(envPath, `
|
|
2647
3182
|
GMAIL_SERVICE=`);
|
|
2648
|
-
|
|
3183
|
+
fs25.appendFileSync(envPath, `
|
|
2649
3184
|
GMAIL_MAIL=`);
|
|
2650
|
-
|
|
3185
|
+
fs25.appendFileSync(envPath, `
|
|
2651
3186
|
GMAIL_NAME=`);
|
|
2652
|
-
|
|
3187
|
+
fs25.appendFileSync(envPath, `
|
|
2653
3188
|
GMAIL_PASSWORD=`);
|
|
2654
3189
|
}
|
|
2655
|
-
const templatePath =
|
|
3190
|
+
const templatePath = path25.resolve(
|
|
2656
3191
|
__dirname,
|
|
2657
3192
|
"./template/email/emailGmail.ts"
|
|
2658
3193
|
);
|
|
2659
|
-
const libPath =
|
|
2660
|
-
if (!
|
|
2661
|
-
|
|
3194
|
+
const libPath = path25.join(projectDir, "src", "lib");
|
|
3195
|
+
if (!fs25.existsSync(libPath)) {
|
|
3196
|
+
fs25.mkdirSync(libPath, { recursive: true });
|
|
2662
3197
|
}
|
|
2663
|
-
const libDestinationPath =
|
|
2664
|
-
|
|
2665
|
-
console.log(
|
|
2666
|
-
console.log(
|
|
3198
|
+
const libDestinationPath = path25.join(libPath, "email.ts");
|
|
3199
|
+
fs25.copyFileSync(templatePath, libDestinationPath);
|
|
3200
|
+
console.log(chalk26.green("\nCompleted installation successfully"));
|
|
3201
|
+
console.log(chalk26.cyan("\nInstall Package:"));
|
|
2667
3202
|
console.log(
|
|
2668
|
-
|
|
3203
|
+
chalk26.white(
|
|
2669
3204
|
`\u2022 nodemailer
|
|
2670
3205
|
\u2022 @react-email/components
|
|
2671
3206
|
\u2022 @react-email/render`
|
|
2672
3207
|
)
|
|
2673
3208
|
);
|
|
2674
|
-
console.log(
|
|
2675
|
-
console.log(
|
|
3209
|
+
console.log(chalk26.cyan("\nFiles created:"));
|
|
3210
|
+
console.log(chalk26.white("\u2022 src/lib/email.ts\n"));
|
|
2676
3211
|
} catch (error) {
|
|
2677
|
-
console.log(
|
|
3212
|
+
console.log(chalk26.red(error));
|
|
2678
3213
|
}
|
|
2679
3214
|
};
|
|
2680
3215
|
|
|
2681
3216
|
// email/awsSesRun.ts
|
|
2682
|
-
import
|
|
2683
|
-
import
|
|
2684
|
-
import
|
|
2685
|
-
import { fileURLToPath as
|
|
3217
|
+
import chalk27 from "chalk";
|
|
3218
|
+
import path26 from "path";
|
|
3219
|
+
import fs26 from "fs";
|
|
3220
|
+
import { fileURLToPath as fileURLToPath23 } from "url";
|
|
2686
3221
|
var awsSesRun = async () => {
|
|
2687
3222
|
try {
|
|
2688
3223
|
const projectDir = process.cwd();
|
|
2689
|
-
const packageJsonPath =
|
|
2690
|
-
const packageJson2 = JSON.parse(
|
|
2691
|
-
const srcFolder =
|
|
2692
|
-
const __filename =
|
|
2693
|
-
const __dirname =
|
|
3224
|
+
const packageJsonPath = path26.join(projectDir, "package.json");
|
|
3225
|
+
const packageJson2 = JSON.parse(fs26.readFileSync(packageJsonPath, "utf-8"));
|
|
3226
|
+
const srcFolder = fs26.existsSync(path26.join(projectDir, "src")) ? "src" : "";
|
|
3227
|
+
const __filename = fileURLToPath23(import.meta.url);
|
|
3228
|
+
const __dirname = path26.dirname(__filename);
|
|
2694
3229
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
2695
|
-
console.log(
|
|
3230
|
+
console.log(chalk27.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
2696
3231
|
packageManager("nodemailer");
|
|
2697
3232
|
packageManager("@types/nodemailer", true);
|
|
2698
3233
|
}
|
|
2699
3234
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2700
|
-
console.log(
|
|
3235
|
+
console.log(chalk27.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2701
3236
|
packageManager("@react-email/components");
|
|
2702
3237
|
}
|
|
2703
3238
|
if (!packageJson2.dependencies?.["@react-email/render"]) {
|
|
2704
|
-
console.log(
|
|
3239
|
+
console.log(chalk27.cyan("\n\u2699\uFE0F Installing @react-email/render...\n"));
|
|
2705
3240
|
packageManager("@react-email/render");
|
|
2706
3241
|
}
|
|
2707
|
-
const envPath =
|
|
2708
|
-
const envContent =
|
|
2709
|
-
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")) {
|
|
2710
|
-
|
|
3242
|
+
const envPath = path26.join(projectDir, ".env");
|
|
3243
|
+
const envContent = fs26.readFileSync(envPath, "utf8");
|
|
3244
|
+
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") && !envContent.includes("AWS_SES_FROM_NAME")) {
|
|
3245
|
+
fs26.appendFileSync(envPath, `
|
|
2711
3246
|
|
|
2712
3247
|
# AWS SES API Key for sending emails`);
|
|
2713
|
-
|
|
3248
|
+
fs26.appendFileSync(envPath, `
|
|
2714
3249
|
AWS_SES_HOST=`);
|
|
2715
|
-
|
|
3250
|
+
fs26.appendFileSync(envPath, `
|
|
2716
3251
|
AWS_SES_PORT=`);
|
|
2717
|
-
|
|
3252
|
+
fs26.appendFileSync(envPath, `
|
|
2718
3253
|
AWS_SES_SERVICE=`);
|
|
2719
|
-
|
|
3254
|
+
fs26.appendFileSync(envPath, `
|
|
2720
3255
|
AWS_SES_USER=`);
|
|
2721
|
-
|
|
3256
|
+
fs26.appendFileSync(envPath, `
|
|
2722
3257
|
AWS_SES_PASS=`);
|
|
2723
|
-
|
|
3258
|
+
fs26.appendFileSync(envPath, `
|
|
2724
3259
|
AWS_SES_FROM=`);
|
|
3260
|
+
fs26.appendFileSync(envPath, `
|
|
3261
|
+
AWS_SES_FROM_NAME=`);
|
|
2725
3262
|
}
|
|
2726
|
-
const templatePath =
|
|
3263
|
+
const templatePath = path26.resolve(
|
|
2727
3264
|
__dirname,
|
|
2728
3265
|
"./template/email/emailAwsSes.ts"
|
|
2729
3266
|
);
|
|
2730
|
-
const libPath =
|
|
2731
|
-
if (!
|
|
2732
|
-
|
|
2733
|
-
}
|
|
2734
|
-
const libDestinationPath =
|
|
2735
|
-
|
|
2736
|
-
console.log(
|
|
2737
|
-
console.log(
|
|
3267
|
+
const libPath = path26.join(projectDir, srcFolder, "lib");
|
|
3268
|
+
if (!fs26.existsSync(libPath)) {
|
|
3269
|
+
fs26.mkdirSync(libPath, { recursive: true });
|
|
3270
|
+
}
|
|
3271
|
+
const libDestinationPath = path26.join(libPath, "email.ts");
|
|
3272
|
+
fs26.copyFileSync(templatePath, libDestinationPath);
|
|
3273
|
+
console.log(chalk27.green("\nCompleted installation successfully"));
|
|
3274
|
+
console.log(chalk27.cyan("\nInstall Package:"));
|
|
2738
3275
|
console.log(
|
|
2739
|
-
|
|
3276
|
+
chalk27.white(
|
|
2740
3277
|
`\u2022 nodemailer
|
|
2741
3278
|
\u2022 @react-email/components
|
|
2742
3279
|
\u2022 @react-email/render`
|
|
2743
3280
|
)
|
|
2744
3281
|
);
|
|
2745
|
-
console.log(
|
|
3282
|
+
console.log(chalk27.cyan("\nFiles created:"));
|
|
2746
3283
|
console.log(
|
|
2747
|
-
|
|
3284
|
+
chalk27.white(
|
|
2748
3285
|
`${CreateFolder({ srcFolder, destFolder: "lib/email.ts" })}
|
|
2749
3286
|
`
|
|
2750
3287
|
)
|
|
2751
3288
|
);
|
|
2752
3289
|
} catch (error) {
|
|
2753
|
-
console.log(
|
|
3290
|
+
console.log(chalk27.red(error));
|
|
2754
3291
|
}
|
|
2755
3292
|
};
|
|
2756
3293
|
|
|
2757
3294
|
// email/awsSesRunTanstackStart.ts
|
|
2758
|
-
import
|
|
2759
|
-
import
|
|
2760
|
-
import
|
|
2761
|
-
import { fileURLToPath as
|
|
3295
|
+
import chalk28 from "chalk";
|
|
3296
|
+
import path27 from "path";
|
|
3297
|
+
import fs27 from "fs";
|
|
3298
|
+
import { fileURLToPath as fileURLToPath24 } from "url";
|
|
2762
3299
|
var awsSesRunTanstackStart = async () => {
|
|
2763
3300
|
try {
|
|
2764
3301
|
const projectDir = process.cwd();
|
|
2765
|
-
const packageJsonPath =
|
|
2766
|
-
const packageJson2 = JSON.parse(
|
|
2767
|
-
const __filename =
|
|
2768
|
-
const __dirname =
|
|
3302
|
+
const packageJsonPath = path27.join(projectDir, "package.json");
|
|
3303
|
+
const packageJson2 = JSON.parse(fs27.readFileSync(packageJsonPath, "utf-8"));
|
|
3304
|
+
const __filename = fileURLToPath24(import.meta.url);
|
|
3305
|
+
const __dirname = path27.dirname(__filename);
|
|
2769
3306
|
if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
|
|
2770
|
-
console.log(
|
|
3307
|
+
console.log(chalk28.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
|
|
2771
3308
|
packageManager("nodemailer");
|
|
2772
3309
|
packageManager("@types/nodemailer", true);
|
|
2773
3310
|
}
|
|
2774
3311
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2775
|
-
console.log(
|
|
3312
|
+
console.log(chalk28.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2776
3313
|
packageManager("@react-email/components");
|
|
2777
3314
|
}
|
|
2778
3315
|
if (!packageJson2.dependencies?.["@react-email/render"]) {
|
|
2779
|
-
console.log(
|
|
3316
|
+
console.log(chalk28.cyan("\n\u2699\uFE0F Installing @react-email/render...\n"));
|
|
2780
3317
|
packageManager("@react-email/render");
|
|
2781
3318
|
}
|
|
2782
|
-
const envPath =
|
|
2783
|
-
const envContent =
|
|
2784
|
-
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")) {
|
|
2785
|
-
|
|
3319
|
+
const envPath = path27.join(projectDir, ".env");
|
|
3320
|
+
const envContent = fs27.readFileSync(envPath, "utf8");
|
|
3321
|
+
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") && !envContent.includes("AWS_SES_FROM_NAME")) {
|
|
3322
|
+
fs27.appendFileSync(envPath, `
|
|
2786
3323
|
|
|
2787
3324
|
# AWS SES API Key for sending emails`);
|
|
2788
|
-
|
|
3325
|
+
fs27.appendFileSync(envPath, `
|
|
2789
3326
|
AWS_SES_HOST=`);
|
|
2790
|
-
|
|
3327
|
+
fs27.appendFileSync(envPath, `
|
|
2791
3328
|
AWS_SES_PORT=`);
|
|
2792
|
-
|
|
3329
|
+
fs27.appendFileSync(envPath, `
|
|
2793
3330
|
AWS_SES_SERVICE=`);
|
|
2794
|
-
|
|
3331
|
+
fs27.appendFileSync(envPath, `
|
|
2795
3332
|
AWS_SES_USER=`);
|
|
2796
|
-
|
|
3333
|
+
fs27.appendFileSync(envPath, `
|
|
2797
3334
|
AWS_SES_PASS=`);
|
|
2798
|
-
|
|
3335
|
+
fs27.appendFileSync(envPath, `
|
|
2799
3336
|
AWS_SES_FROM=`);
|
|
3337
|
+
fs27.appendFileSync(envPath, `
|
|
3338
|
+
AWS_SES_FROM_NAME=`);
|
|
2800
3339
|
}
|
|
2801
|
-
const templatePath =
|
|
3340
|
+
const templatePath = path27.resolve(
|
|
2802
3341
|
__dirname,
|
|
2803
3342
|
"./template/email/emailAwsSes.ts"
|
|
2804
3343
|
);
|
|
2805
|
-
const libPath =
|
|
2806
|
-
if (!
|
|
2807
|
-
|
|
2808
|
-
}
|
|
2809
|
-
const libDestinationPath =
|
|
2810
|
-
|
|
2811
|
-
console.log(
|
|
2812
|
-
console.log(
|
|
3344
|
+
const libPath = path27.join(projectDir, "src", "lib");
|
|
3345
|
+
if (!fs27.existsSync(libPath)) {
|
|
3346
|
+
fs27.mkdirSync(libPath, { recursive: true });
|
|
3347
|
+
}
|
|
3348
|
+
const libDestinationPath = path27.join(libPath, "email.ts");
|
|
3349
|
+
fs27.copyFileSync(templatePath, libDestinationPath);
|
|
3350
|
+
console.log(chalk28.green("\nCompleted installation successfully"));
|
|
3351
|
+
console.log(chalk28.cyan("\nInstall Package:"));
|
|
2813
3352
|
console.log(
|
|
2814
|
-
|
|
3353
|
+
chalk28.white(
|
|
2815
3354
|
`\u2022 nodemailer
|
|
2816
3355
|
\u2022 @react-email/components
|
|
2817
3356
|
\u2022 @react-email/render`
|
|
2818
3357
|
)
|
|
2819
3358
|
);
|
|
2820
|
-
console.log(
|
|
2821
|
-
console.log(
|
|
3359
|
+
console.log(chalk28.cyan("\nFiles created:"));
|
|
3360
|
+
console.log(chalk28.white("\u2022 src/lib/email.ts\n"));
|
|
2822
3361
|
} catch (error) {
|
|
2823
|
-
console.log(
|
|
3362
|
+
console.log(chalk28.red(error));
|
|
2824
3363
|
}
|
|
2825
3364
|
};
|
|
2826
3365
|
|
|
2827
3366
|
// email/resendRun.ts
|
|
2828
|
-
import
|
|
2829
|
-
import
|
|
2830
|
-
import
|
|
2831
|
-
import { fileURLToPath as
|
|
3367
|
+
import chalk29 from "chalk";
|
|
3368
|
+
import path28 from "path";
|
|
3369
|
+
import fs28 from "fs";
|
|
3370
|
+
import { fileURLToPath as fileURLToPath25 } from "url";
|
|
2832
3371
|
var resendRun = async () => {
|
|
2833
3372
|
try {
|
|
2834
3373
|
const projectDir = process.cwd();
|
|
2835
|
-
const packageJsonPath =
|
|
2836
|
-
const packageJson2 = JSON.parse(
|
|
2837
|
-
const srcFolder =
|
|
2838
|
-
const __filename =
|
|
2839
|
-
const __dirname =
|
|
3374
|
+
const packageJsonPath = path28.join(projectDir, "package.json");
|
|
3375
|
+
const packageJson2 = JSON.parse(fs28.readFileSync(packageJsonPath, "utf-8"));
|
|
3376
|
+
const srcFolder = fs28.existsSync(path28.join(projectDir, "src")) ? "src" : "";
|
|
3377
|
+
const __filename = fileURLToPath25(import.meta.url);
|
|
3378
|
+
const __dirname = path28.dirname(__filename);
|
|
2840
3379
|
if (!packageJson2.dependencies?.resend) {
|
|
2841
|
-
console.log(
|
|
3380
|
+
console.log(chalk29.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
2842
3381
|
packageManager("resend");
|
|
2843
3382
|
}
|
|
2844
3383
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2845
|
-
console.log(
|
|
3384
|
+
console.log(chalk29.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2846
3385
|
packageManager("@react-email/components");
|
|
2847
3386
|
}
|
|
2848
3387
|
if (!packageJson2.dependencies?.["@react-email/render"]) {
|
|
2849
|
-
console.log(
|
|
3388
|
+
console.log(chalk29.cyan("\n\u2699\uFE0F Installing @react-email/render...\n"));
|
|
2850
3389
|
packageManager("@react-email/render");
|
|
2851
3390
|
}
|
|
2852
|
-
const envPath =
|
|
2853
|
-
const envContent =
|
|
3391
|
+
const envPath = path28.join(projectDir, ".env");
|
|
3392
|
+
const envContent = fs28.readFileSync(envPath, "utf8");
|
|
2854
3393
|
if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
|
|
2855
|
-
|
|
3394
|
+
fs28.appendFileSync(envPath, `
|
|
2856
3395
|
|
|
2857
3396
|
# Resend API Key for sending emails`);
|
|
2858
|
-
|
|
3397
|
+
fs28.appendFileSync(envPath, `
|
|
2859
3398
|
RESEND_API_KEY=`);
|
|
2860
|
-
|
|
3399
|
+
fs28.appendFileSync(envPath, `
|
|
2861
3400
|
EMAIL_SENDER_NAME=Your Name`);
|
|
2862
|
-
|
|
3401
|
+
fs28.appendFileSync(envPath, `
|
|
2863
3402
|
EMAIL_SENDER_ADDRESS=`);
|
|
2864
3403
|
}
|
|
2865
|
-
const templatePath =
|
|
3404
|
+
const templatePath = path28.resolve(
|
|
2866
3405
|
__dirname,
|
|
2867
3406
|
"./template/email/emailResend.ts"
|
|
2868
3407
|
);
|
|
2869
|
-
const libPath =
|
|
2870
|
-
if (!
|
|
2871
|
-
|
|
2872
|
-
}
|
|
2873
|
-
const libDestinationPath =
|
|
2874
|
-
|
|
2875
|
-
console.log(
|
|
2876
|
-
console.log(
|
|
3408
|
+
const libPath = path28.join(projectDir, srcFolder, "lib");
|
|
3409
|
+
if (!fs28.existsSync(libPath)) {
|
|
3410
|
+
fs28.mkdirSync(libPath, { recursive: true });
|
|
3411
|
+
}
|
|
3412
|
+
const libDestinationPath = path28.join(libPath, "email.ts");
|
|
3413
|
+
fs28.copyFileSync(templatePath, libDestinationPath);
|
|
3414
|
+
console.log(chalk29.green("\nCompleted installation successfully"));
|
|
3415
|
+
console.log(chalk29.cyan("\nInstall Package:"));
|
|
2877
3416
|
console.log(
|
|
2878
|
-
|
|
3417
|
+
chalk29.white(`\u2022 resend
|
|
2879
3418
|
\u2022 @react-email/components
|
|
2880
3419
|
\u2022 @react-email/render`)
|
|
2881
3420
|
);
|
|
2882
|
-
console.log(
|
|
3421
|
+
console.log(chalk29.cyan("\nFiles created:"));
|
|
2883
3422
|
console.log(
|
|
2884
|
-
|
|
3423
|
+
chalk29.white(
|
|
2885
3424
|
`${CreateFolder({ srcFolder, destFolder: "lib/email.ts" })}
|
|
2886
3425
|
`
|
|
2887
3426
|
)
|
|
2888
3427
|
);
|
|
2889
3428
|
} catch (error) {
|
|
2890
|
-
console.log(
|
|
3429
|
+
console.log(chalk29.red(error));
|
|
2891
3430
|
}
|
|
2892
3431
|
};
|
|
2893
3432
|
|
|
2894
3433
|
// email/resendRunTanstackStart.ts
|
|
2895
|
-
import
|
|
2896
|
-
import
|
|
2897
|
-
import
|
|
2898
|
-
import { fileURLToPath as
|
|
3434
|
+
import chalk30 from "chalk";
|
|
3435
|
+
import path29 from "path";
|
|
3436
|
+
import fs29 from "fs";
|
|
3437
|
+
import { fileURLToPath as fileURLToPath26 } from "url";
|
|
2899
3438
|
var resendRunTanstackStart = async () => {
|
|
2900
3439
|
try {
|
|
2901
3440
|
const projectDir = process.cwd();
|
|
2902
|
-
const packageJsonPath =
|
|
2903
|
-
const packageJson2 = JSON.parse(
|
|
2904
|
-
const __filename =
|
|
2905
|
-
const __dirname =
|
|
3441
|
+
const packageJsonPath = path29.join(projectDir, "package.json");
|
|
3442
|
+
const packageJson2 = JSON.parse(fs29.readFileSync(packageJsonPath, "utf-8"));
|
|
3443
|
+
const __filename = fileURLToPath26(import.meta.url);
|
|
3444
|
+
const __dirname = path29.dirname(__filename);
|
|
2906
3445
|
if (!packageJson2.dependencies?.resend) {
|
|
2907
|
-
console.log(
|
|
3446
|
+
console.log(chalk30.cyan("\n\u2699\uFE0F Installing Resend...\n"));
|
|
2908
3447
|
packageManager("resend");
|
|
2909
3448
|
}
|
|
2910
3449
|
if (!packageJson2.dependencies?.["@react-email/components"]) {
|
|
2911
|
-
console.log(
|
|
3450
|
+
console.log(chalk30.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
|
|
2912
3451
|
packageManager("@react-email/components");
|
|
2913
3452
|
}
|
|
2914
|
-
const envPath =
|
|
2915
|
-
const envContent =
|
|
3453
|
+
const envPath = path29.join(projectDir, ".env");
|
|
3454
|
+
const envContent = fs29.readFileSync(envPath, "utf8");
|
|
2916
3455
|
if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
|
|
2917
|
-
|
|
3456
|
+
fs29.appendFileSync(envPath, `
|
|
2918
3457
|
|
|
2919
3458
|
# Resend API Key for sending emails`);
|
|
2920
|
-
|
|
3459
|
+
fs29.appendFileSync(envPath, `
|
|
2921
3460
|
RESEND_API_KEY=`);
|
|
2922
|
-
|
|
3461
|
+
fs29.appendFileSync(envPath, `
|
|
2923
3462
|
EMAIL_SENDER_NAME=Your Name`);
|
|
2924
|
-
|
|
3463
|
+
fs29.appendFileSync(envPath, `
|
|
2925
3464
|
EMAIL_SENDER_ADDRESS=`);
|
|
2926
3465
|
}
|
|
2927
|
-
const templatePath =
|
|
3466
|
+
const templatePath = path29.resolve(
|
|
2928
3467
|
__dirname,
|
|
2929
3468
|
"./template/email/emailResend.ts"
|
|
2930
3469
|
);
|
|
2931
|
-
const libPath =
|
|
2932
|
-
if (!
|
|
2933
|
-
|
|
2934
|
-
}
|
|
2935
|
-
const libDestinationPath =
|
|
2936
|
-
|
|
2937
|
-
console.log(
|
|
2938
|
-
console.log(
|
|
3470
|
+
const libPath = path29.join(projectDir, "src", "lib");
|
|
3471
|
+
if (!fs29.existsSync(libPath)) {
|
|
3472
|
+
fs29.mkdirSync(libPath, { recursive: true });
|
|
3473
|
+
}
|
|
3474
|
+
const libDestinationPath = path29.join(libPath, "email.ts");
|
|
3475
|
+
fs29.copyFileSync(templatePath, libDestinationPath);
|
|
3476
|
+
console.log(chalk30.green("\nCompleted installation successfully"));
|
|
3477
|
+
console.log(chalk30.cyan("\nInstall Package:"));
|
|
2939
3478
|
console.log(
|
|
2940
|
-
|
|
3479
|
+
chalk30.white(`\u2022 resend
|
|
2941
3480
|
\u2022 @react-email/components
|
|
2942
3481
|
\u2022 @react-email/render`)
|
|
2943
3482
|
);
|
|
2944
|
-
console.log(
|
|
2945
|
-
console.log(
|
|
3483
|
+
console.log(chalk30.cyan("\nFiles created:"));
|
|
3484
|
+
console.log(chalk30.white("\u2022 src/lib/email.ts\n"));
|
|
2946
3485
|
} catch (error) {
|
|
2947
|
-
console.log(
|
|
3486
|
+
console.log(chalk30.red(error));
|
|
2948
3487
|
}
|
|
2949
3488
|
};
|
|
2950
3489
|
|
|
2951
3490
|
// cli/email.ts
|
|
2952
|
-
import
|
|
3491
|
+
import chalk31 from "chalk";
|
|
2953
3492
|
var email = async () => {
|
|
2954
3493
|
const projectDir = process.cwd();
|
|
2955
3494
|
const { framework, error } = await getFramework();
|
|
2956
3495
|
if (error) {
|
|
2957
|
-
console.log(
|
|
3496
|
+
console.log(chalk31.red(error));
|
|
2958
3497
|
return;
|
|
2959
3498
|
}
|
|
2960
3499
|
if (framework === "Next js") {
|
|
2961
|
-
const srcFolder =
|
|
2962
|
-
const emailPath =
|
|
2963
|
-
if (
|
|
2964
|
-
const answers2 = await
|
|
3500
|
+
const srcFolder = fs30.existsSync(path30.join(projectDir, "src")) ? "src" : "";
|
|
3501
|
+
const emailPath = path30.join(projectDir, srcFolder, "lib", "email.ts");
|
|
3502
|
+
if (fs30.existsSync(emailPath)) {
|
|
3503
|
+
const answers2 = await inquirer5.prompt([
|
|
2965
3504
|
{
|
|
2966
3505
|
type: "confirm",
|
|
2967
3506
|
name: "overwrite",
|
|
@@ -2975,13 +3514,13 @@ var email = async () => {
|
|
|
2975
3514
|
}
|
|
2976
3515
|
}
|
|
2977
3516
|
if (framework === "tanstack start") {
|
|
2978
|
-
const srcFolderTanstackState =
|
|
2979
|
-
const libPathTanstackState =
|
|
3517
|
+
const srcFolderTanstackState = path30.join(projectDir, "src");
|
|
3518
|
+
const libPathTanstackState = path30.join(
|
|
2980
3519
|
srcFolderTanstackState,
|
|
2981
3520
|
"lib/email.ts"
|
|
2982
3521
|
);
|
|
2983
|
-
if (
|
|
2984
|
-
const answers2 = await
|
|
3522
|
+
if (fs30.existsSync(libPathTanstackState)) {
|
|
3523
|
+
const answers2 = await inquirer5.prompt([
|
|
2985
3524
|
{
|
|
2986
3525
|
type: "confirm",
|
|
2987
3526
|
name: "overwrite",
|
|
@@ -2994,9 +3533,9 @@ var email = async () => {
|
|
|
2994
3533
|
}
|
|
2995
3534
|
}
|
|
2996
3535
|
}
|
|
2997
|
-
const answers = await
|
|
3536
|
+
const answers = await inquirer5.prompt([
|
|
2998
3537
|
{
|
|
2999
|
-
type: "
|
|
3538
|
+
type: "select",
|
|
3000
3539
|
name: "emailProvider",
|
|
3001
3540
|
message: "Choose Your Email Provider:",
|
|
3002
3541
|
choices: ["Gmail", "AWS SES", "Resend"]
|
|
@@ -3026,20 +3565,20 @@ var email = async () => {
|
|
|
3026
3565
|
var forgetNext = async () => {
|
|
3027
3566
|
try {
|
|
3028
3567
|
const projectDir = process.cwd();
|
|
3029
|
-
const __filename =
|
|
3030
|
-
const __dirname =
|
|
3031
|
-
const srcPath =
|
|
3032
|
-
const folder =
|
|
3033
|
-
const emailFilePath =
|
|
3034
|
-
if (!
|
|
3568
|
+
const __filename = fileURLToPath27(import.meta.url);
|
|
3569
|
+
const __dirname = path31.dirname(__filename);
|
|
3570
|
+
const srcPath = path31.join(projectDir, "src");
|
|
3571
|
+
const folder = fs31.existsSync(srcPath) ? "src" : "";
|
|
3572
|
+
const emailFilePath = path31.join(projectDir, folder, "lib", "email.ts");
|
|
3573
|
+
if (!fs31.existsSync(emailFilePath)) {
|
|
3035
3574
|
await email();
|
|
3036
3575
|
}
|
|
3037
|
-
const authFilePath =
|
|
3038
|
-
if (!
|
|
3039
|
-
console.log(
|
|
3576
|
+
const authFilePath = path31.join(projectDir, folder, "lib", "auth.ts");
|
|
3577
|
+
if (!fs31.existsSync(authFilePath)) {
|
|
3578
|
+
console.log(chalk32.red("auth.ts file not found."));
|
|
3040
3579
|
return;
|
|
3041
3580
|
}
|
|
3042
|
-
let content =
|
|
3581
|
+
let content = fs31.readFileSync(authFilePath, "utf8");
|
|
3043
3582
|
const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
|
|
3044
3583
|
await sendEmail({
|
|
3045
3584
|
email: user.email!,
|
|
@@ -3077,7 +3616,7 @@ var forgetNext = async () => {
|
|
|
3077
3616
|
const after = content.substring(emailAndPasswordEnd);
|
|
3078
3617
|
content = before + `${codeAdded}` + after;
|
|
3079
3618
|
}
|
|
3080
|
-
|
|
3619
|
+
fs31.writeFileSync(authFilePath, content, "utf8");
|
|
3081
3620
|
if (!content.includes("import { sendEmail }")) {
|
|
3082
3621
|
const lastImportIndex = content.lastIndexOf("import");
|
|
3083
3622
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -3086,7 +3625,7 @@ var forgetNext = async () => {
|
|
|
3086
3625
|
const newImports = `import { sendEmail } from "./email";
|
|
3087
3626
|
`;
|
|
3088
3627
|
content = beforeImports + newImports + afterImports;
|
|
3089
|
-
|
|
3628
|
+
fs31.writeFileSync(authFilePath, content, "utf8");
|
|
3090
3629
|
}
|
|
3091
3630
|
if (!content.includes("import ForgotPasswordEmail from")) {
|
|
3092
3631
|
const lastImportIndex = content.lastIndexOf("import");
|
|
@@ -3096,97 +3635,97 @@ var forgetNext = async () => {
|
|
|
3096
3635
|
const newImports = `import ForgotPasswordEmail from "@/components/email/reset-password";
|
|
3097
3636
|
`;
|
|
3098
3637
|
content = beforeImports + newImports + afterImports;
|
|
3099
|
-
|
|
3638
|
+
fs31.writeFileSync(authFilePath, content, "utf8");
|
|
3100
3639
|
}
|
|
3101
|
-
const componentPath =
|
|
3640
|
+
const componentPath = path31.resolve(
|
|
3102
3641
|
__dirname,
|
|
3103
3642
|
"./template/email/reset-password.tsx"
|
|
3104
3643
|
);
|
|
3105
|
-
const destinationPath =
|
|
3644
|
+
const destinationPath = path31.join(
|
|
3106
3645
|
projectDir,
|
|
3107
3646
|
folder,
|
|
3108
3647
|
"components",
|
|
3109
3648
|
"email"
|
|
3110
3649
|
);
|
|
3111
|
-
if (!
|
|
3112
|
-
|
|
3650
|
+
if (!fs31.existsSync(destinationPath)) {
|
|
3651
|
+
fs31.mkdirSync(destinationPath, { recursive: true });
|
|
3113
3652
|
}
|
|
3114
|
-
const emailDestinationPath =
|
|
3653
|
+
const emailDestinationPath = path31.join(
|
|
3115
3654
|
destinationPath,
|
|
3116
3655
|
"reset-password.tsx"
|
|
3117
3656
|
);
|
|
3118
|
-
if (
|
|
3119
|
-
|
|
3657
|
+
if (fs31.existsSync(componentPath)) {
|
|
3658
|
+
fs31.copyFileSync(componentPath, emailDestinationPath);
|
|
3120
3659
|
}
|
|
3121
|
-
const forgetComponentPath =
|
|
3660
|
+
const forgetComponentPath = path31.resolve(
|
|
3122
3661
|
__dirname,
|
|
3123
3662
|
"./template/components/ForgetComponent.tsx"
|
|
3124
3663
|
);
|
|
3125
|
-
const componentsDestinationPath =
|
|
3664
|
+
const componentsDestinationPath = path31.join(
|
|
3126
3665
|
projectDir,
|
|
3127
3666
|
folder,
|
|
3128
3667
|
"components",
|
|
3129
3668
|
"authverse"
|
|
3130
3669
|
);
|
|
3131
|
-
if (!
|
|
3132
|
-
|
|
3670
|
+
if (!fs31.existsSync(componentsDestinationPath)) {
|
|
3671
|
+
fs31.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
3133
3672
|
}
|
|
3134
|
-
const forgetDestinationPath =
|
|
3673
|
+
const forgetDestinationPath = path31.join(
|
|
3135
3674
|
componentsDestinationPath,
|
|
3136
3675
|
"ForgetComponent.tsx"
|
|
3137
3676
|
);
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3677
|
+
if (fs31.existsSync(forgetComponentPath)) {
|
|
3678
|
+
fs31.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
3140
3679
|
}
|
|
3141
|
-
const resetComponentPath =
|
|
3680
|
+
const resetComponentPath = path31.resolve(
|
|
3142
3681
|
__dirname,
|
|
3143
3682
|
"./template/components/ResetComponent.tsx"
|
|
3144
3683
|
);
|
|
3145
|
-
const resetDestinationPath =
|
|
3684
|
+
const resetDestinationPath = path31.join(
|
|
3146
3685
|
componentsDestinationPath,
|
|
3147
3686
|
"ResetComponent.tsx"
|
|
3148
3687
|
);
|
|
3149
|
-
if (
|
|
3150
|
-
|
|
3688
|
+
if (fs31.existsSync(resetComponentPath)) {
|
|
3689
|
+
fs31.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
3151
3690
|
}
|
|
3152
|
-
const authTemplatePath =
|
|
3691
|
+
const authTemplatePath = path31.resolve(
|
|
3153
3692
|
__dirname,
|
|
3154
3693
|
"./template/app-auth-uiDesign"
|
|
3155
3694
|
);
|
|
3156
|
-
const appDestinationPath =
|
|
3157
|
-
if (!
|
|
3158
|
-
|
|
3695
|
+
const appDestinationPath = path31.join(projectDir, folder, "app", "auth");
|
|
3696
|
+
if (!fs31.existsSync(appDestinationPath)) {
|
|
3697
|
+
fs31.mkdirSync(appDestinationPath, { recursive: true });
|
|
3159
3698
|
}
|
|
3160
|
-
const forgetDestinationDir =
|
|
3161
|
-
if (!
|
|
3162
|
-
|
|
3699
|
+
const forgetDestinationDir = path31.join(appDestinationPath, "forget");
|
|
3700
|
+
if (!fs31.existsSync(forgetDestinationDir)) {
|
|
3701
|
+
fs31.mkdirSync(forgetDestinationDir, { recursive: true });
|
|
3163
3702
|
}
|
|
3164
|
-
const forgetPageDestinationPath =
|
|
3703
|
+
const forgetPageDestinationPath = path31.join(
|
|
3165
3704
|
forgetDestinationDir,
|
|
3166
3705
|
"page.tsx"
|
|
3167
3706
|
);
|
|
3168
|
-
|
|
3707
|
+
fs31.copyFileSync(
|
|
3169
3708
|
`${authTemplatePath}/forget/page.tsx`,
|
|
3170
3709
|
forgetPageDestinationPath
|
|
3171
3710
|
);
|
|
3172
|
-
const resetDestinationDir =
|
|
3711
|
+
const resetDestinationDir = path31.join(
|
|
3173
3712
|
appDestinationPath,
|
|
3174
3713
|
"reset-password"
|
|
3175
3714
|
);
|
|
3176
|
-
if (!
|
|
3177
|
-
|
|
3715
|
+
if (!fs31.existsSync(resetDestinationDir)) {
|
|
3716
|
+
fs31.mkdirSync(resetDestinationDir, { recursive: true });
|
|
3178
3717
|
}
|
|
3179
|
-
const resetPageDestinationPath =
|
|
3718
|
+
const resetPageDestinationPath = path31.join(
|
|
3180
3719
|
resetDestinationDir,
|
|
3181
3720
|
"page.tsx"
|
|
3182
3721
|
);
|
|
3183
|
-
|
|
3722
|
+
fs31.copyFileSync(
|
|
3184
3723
|
`${authTemplatePath}/reset-password/page.tsx`,
|
|
3185
3724
|
resetPageDestinationPath
|
|
3186
3725
|
);
|
|
3187
|
-
console.log(
|
|
3726
|
+
console.log(chalk32.green("\nCompleted installation successfully"));
|
|
3188
3727
|
console.log(
|
|
3189
|
-
|
|
3728
|
+
chalk32.white(
|
|
3190
3729
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/ForgetComponent.tsx" })}
|
|
3191
3730
|
${CreateFolder({ srcFolder: folder, destFolder: "components/authverse/ResetComponent.tsx" })}
|
|
3192
3731
|
${CreateFolder({ srcFolder: folder, destFolder: "components/email/reset-password.tsx" })}
|
|
@@ -3197,35 +3736,35 @@ ${CreateFolder({ srcFolder: folder, destFolder: "app/auth/reset-password/page.ts
|
|
|
3197
3736
|
);
|
|
3198
3737
|
} else {
|
|
3199
3738
|
console.log(
|
|
3200
|
-
|
|
3739
|
+
chalk32.red("Could not find emailAndPassword configuration in auth.ts")
|
|
3201
3740
|
);
|
|
3202
3741
|
}
|
|
3203
3742
|
} catch (error) {
|
|
3204
|
-
console.log(
|
|
3743
|
+
console.log(chalk32.red("Error adding sendResetPassword:"), error);
|
|
3205
3744
|
}
|
|
3206
3745
|
};
|
|
3207
3746
|
|
|
3208
3747
|
// script/forgetTanstack.ts
|
|
3209
|
-
import
|
|
3210
|
-
import
|
|
3211
|
-
import { fileURLToPath as
|
|
3212
|
-
import
|
|
3748
|
+
import chalk33 from "chalk";
|
|
3749
|
+
import path32 from "path";
|
|
3750
|
+
import { fileURLToPath as fileURLToPath28 } from "url";
|
|
3751
|
+
import fs32 from "fs";
|
|
3213
3752
|
var forgetTanstack = async () => {
|
|
3214
3753
|
try {
|
|
3215
3754
|
const projectDir = process.cwd();
|
|
3216
|
-
const __filename =
|
|
3217
|
-
const __dirname =
|
|
3218
|
-
const srcPath =
|
|
3219
|
-
const emailFilePath =
|
|
3220
|
-
if (!
|
|
3755
|
+
const __filename = fileURLToPath28(import.meta.url);
|
|
3756
|
+
const __dirname = path32.dirname(__filename);
|
|
3757
|
+
const srcPath = path32.join(projectDir, "src");
|
|
3758
|
+
const emailFilePath = path32.join(srcPath, "lib", "email.ts");
|
|
3759
|
+
if (!fs32.existsSync(emailFilePath)) {
|
|
3221
3760
|
await email();
|
|
3222
3761
|
}
|
|
3223
|
-
const authFilePath =
|
|
3224
|
-
if (!
|
|
3225
|
-
console.log(
|
|
3762
|
+
const authFilePath = path32.join(srcPath, "lib", "auth.ts");
|
|
3763
|
+
if (!fs32.existsSync(authFilePath)) {
|
|
3764
|
+
console.log(chalk33.red("auth.ts file not found."));
|
|
3226
3765
|
return;
|
|
3227
3766
|
}
|
|
3228
|
-
let content =
|
|
3767
|
+
let content = fs32.readFileSync(authFilePath, "utf8");
|
|
3229
3768
|
const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
|
|
3230
3769
|
await sendEmail({
|
|
3231
3770
|
email: user.email!,
|
|
@@ -3263,7 +3802,7 @@ var forgetTanstack = async () => {
|
|
|
3263
3802
|
const after = content.substring(emailAndPasswordEnd);
|
|
3264
3803
|
content = before + `${codeAdded}` + after;
|
|
3265
3804
|
}
|
|
3266
|
-
|
|
3805
|
+
fs32.writeFileSync(authFilePath, content, "utf8");
|
|
3267
3806
|
if (!content.includes("import { sendEmail }")) {
|
|
3268
3807
|
const lastImportIndex = content.lastIndexOf("import");
|
|
3269
3808
|
const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
|
|
@@ -3272,7 +3811,7 @@ var forgetTanstack = async () => {
|
|
|
3272
3811
|
const newImports = `import { sendEmail } from "./email";
|
|
3273
3812
|
`;
|
|
3274
3813
|
content = beforeImports + newImports + afterImports;
|
|
3275
|
-
|
|
3814
|
+
fs32.writeFileSync(authFilePath, content, "utf8");
|
|
3276
3815
|
}
|
|
3277
3816
|
if (!content.includes("import ForgotPasswordEmail from")) {
|
|
3278
3817
|
const lastImportIndex = content.lastIndexOf("import");
|
|
@@ -3282,80 +3821,80 @@ var forgetTanstack = async () => {
|
|
|
3282
3821
|
const newImports = `import ForgotPasswordEmail from "@/components/email/reset-password";
|
|
3283
3822
|
`;
|
|
3284
3823
|
content = beforeImports + newImports + afterImports;
|
|
3285
|
-
|
|
3824
|
+
fs32.writeFileSync(authFilePath, content, "utf8");
|
|
3286
3825
|
}
|
|
3287
|
-
const componentPath =
|
|
3826
|
+
const componentPath = path32.resolve(
|
|
3288
3827
|
__dirname,
|
|
3289
3828
|
"./template/email/reset-password.tsx"
|
|
3290
3829
|
);
|
|
3291
|
-
const destinationPath =
|
|
3292
|
-
if (!
|
|
3293
|
-
|
|
3830
|
+
const destinationPath = path32.join(srcPath, "components", "email");
|
|
3831
|
+
if (!fs32.existsSync(destinationPath)) {
|
|
3832
|
+
fs32.mkdirSync(destinationPath, { recursive: true });
|
|
3294
3833
|
}
|
|
3295
|
-
const emailDestinationPath =
|
|
3834
|
+
const emailDestinationPath = path32.join(
|
|
3296
3835
|
destinationPath,
|
|
3297
3836
|
"reset-password.tsx"
|
|
3298
3837
|
);
|
|
3299
|
-
if (
|
|
3300
|
-
|
|
3838
|
+
if (fs32.existsSync(componentPath)) {
|
|
3839
|
+
fs32.copyFileSync(componentPath, emailDestinationPath);
|
|
3301
3840
|
}
|
|
3302
|
-
const forgetComponentPath =
|
|
3841
|
+
const forgetComponentPath = path32.resolve(
|
|
3303
3842
|
__dirname,
|
|
3304
3843
|
"./template/TanstackStart/components/ForgetComponent.tsx"
|
|
3305
3844
|
);
|
|
3306
|
-
const componentsDestinationPath =
|
|
3845
|
+
const componentsDestinationPath = path32.join(
|
|
3307
3846
|
srcPath,
|
|
3308
3847
|
"components",
|
|
3309
3848
|
"authverse"
|
|
3310
3849
|
);
|
|
3311
|
-
if (!
|
|
3312
|
-
|
|
3850
|
+
if (!fs32.existsSync(componentsDestinationPath)) {
|
|
3851
|
+
fs32.mkdirSync(componentsDestinationPath, { recursive: true });
|
|
3313
3852
|
}
|
|
3314
|
-
const forgetDestinationPath =
|
|
3853
|
+
const forgetDestinationPath = path32.join(
|
|
3315
3854
|
componentsDestinationPath,
|
|
3316
3855
|
"ForgetComponent.tsx"
|
|
3317
3856
|
);
|
|
3318
|
-
if (
|
|
3319
|
-
|
|
3857
|
+
if (fs32.existsSync(forgetComponentPath)) {
|
|
3858
|
+
fs32.copyFileSync(forgetComponentPath, forgetDestinationPath);
|
|
3320
3859
|
}
|
|
3321
|
-
const resetComponentPath =
|
|
3860
|
+
const resetComponentPath = path32.resolve(
|
|
3322
3861
|
__dirname,
|
|
3323
3862
|
"./template/TanstackStart/components/ResetComponent.tsx"
|
|
3324
3863
|
);
|
|
3325
|
-
const resetDestinationPath =
|
|
3864
|
+
const resetDestinationPath = path32.join(
|
|
3326
3865
|
componentsDestinationPath,
|
|
3327
3866
|
"ResetComponent.tsx"
|
|
3328
3867
|
);
|
|
3329
|
-
if (
|
|
3330
|
-
|
|
3868
|
+
if (fs32.existsSync(resetComponentPath)) {
|
|
3869
|
+
fs32.copyFileSync(resetComponentPath, resetDestinationPath);
|
|
3331
3870
|
}
|
|
3332
|
-
const authTemplatePath =
|
|
3871
|
+
const authTemplatePath = path32.resolve(
|
|
3333
3872
|
__dirname,
|
|
3334
3873
|
"./template/TanstackStart/routes/auth"
|
|
3335
3874
|
);
|
|
3336
|
-
const routesDestinationPath =
|
|
3337
|
-
if (!
|
|
3338
|
-
|
|
3875
|
+
const routesDestinationPath = path32.join(srcPath, "routes", "auth");
|
|
3876
|
+
if (!fs32.existsSync(routesDestinationPath)) {
|
|
3877
|
+
fs32.mkdirSync(routesDestinationPath, { recursive: true });
|
|
3339
3878
|
}
|
|
3340
|
-
const forgetPageDestinationPath =
|
|
3879
|
+
const forgetPageDestinationPath = path32.join(
|
|
3341
3880
|
routesDestinationPath,
|
|
3342
3881
|
"forget.tsx"
|
|
3343
3882
|
);
|
|
3344
|
-
|
|
3883
|
+
fs32.copyFileSync(
|
|
3345
3884
|
`${authTemplatePath}/forget.tsx`,
|
|
3346
3885
|
forgetPageDestinationPath
|
|
3347
3886
|
);
|
|
3348
|
-
const resetPageDestinationPath =
|
|
3887
|
+
const resetPageDestinationPath = path32.join(
|
|
3349
3888
|
routesDestinationPath,
|
|
3350
3889
|
"reset-password.tsx"
|
|
3351
3890
|
);
|
|
3352
|
-
|
|
3891
|
+
fs32.copyFileSync(
|
|
3353
3892
|
`${authTemplatePath}/reset-password.tsx`,
|
|
3354
3893
|
resetPageDestinationPath
|
|
3355
3894
|
);
|
|
3356
|
-
console.log(
|
|
3895
|
+
console.log(chalk33.green("\nCompleted installation successfully"));
|
|
3357
3896
|
console.log(
|
|
3358
|
-
|
|
3897
|
+
chalk33.white(
|
|
3359
3898
|
`\u2022 src/components/authverse/ForgetComponent.tsx
|
|
3360
3899
|
\u2022 src/components/authverse/ResetComponent.tsx
|
|
3361
3900
|
\u2022 src/components/email/reset-password.tsx
|
|
@@ -3366,20 +3905,20 @@ var forgetTanstack = async () => {
|
|
|
3366
3905
|
);
|
|
3367
3906
|
} else {
|
|
3368
3907
|
console.log(
|
|
3369
|
-
|
|
3908
|
+
chalk33.red("Could not find emailAndPassword configuration in auth.ts")
|
|
3370
3909
|
);
|
|
3371
3910
|
}
|
|
3372
3911
|
} catch (error) {
|
|
3373
|
-
console.log(
|
|
3912
|
+
console.log(chalk33.red("Error adding sendResetPassword:"), error);
|
|
3374
3913
|
}
|
|
3375
3914
|
};
|
|
3376
3915
|
|
|
3377
3916
|
// cli/forget.ts
|
|
3378
|
-
import
|
|
3917
|
+
import chalk34 from "chalk";
|
|
3379
3918
|
var forget = async () => {
|
|
3380
3919
|
const { framework, error } = await getFramework();
|
|
3381
3920
|
if (error) {
|
|
3382
|
-
console.log(
|
|
3921
|
+
console.log(chalk34.red(error));
|
|
3383
3922
|
return;
|
|
3384
3923
|
}
|
|
3385
3924
|
if (framework === "Next js") {
|
|
@@ -3391,30 +3930,30 @@ var forget = async () => {
|
|
|
3391
3930
|
};
|
|
3392
3931
|
|
|
3393
3932
|
// cli/verification.ts
|
|
3394
|
-
import
|
|
3933
|
+
import chalk37 from "chalk";
|
|
3395
3934
|
|
|
3396
3935
|
// script/verifyNext.ts
|
|
3397
|
-
import
|
|
3398
|
-
import
|
|
3399
|
-
import
|
|
3400
|
-
import { fileURLToPath as
|
|
3936
|
+
import chalk35 from "chalk";
|
|
3937
|
+
import fs33 from "fs";
|
|
3938
|
+
import path33 from "path";
|
|
3939
|
+
import { fileURLToPath as fileURLToPath29 } from "url";
|
|
3401
3940
|
var verifyNext = async () => {
|
|
3402
3941
|
try {
|
|
3403
3942
|
const projectDir = process.cwd();
|
|
3404
|
-
const __filename =
|
|
3405
|
-
const __dirname =
|
|
3406
|
-
const srcPath =
|
|
3407
|
-
const folder =
|
|
3408
|
-
const emailFilePath =
|
|
3409
|
-
if (!
|
|
3943
|
+
const __filename = fileURLToPath29(import.meta.url);
|
|
3944
|
+
const __dirname = path33.dirname(__filename);
|
|
3945
|
+
const srcPath = path33.join(projectDir, "src");
|
|
3946
|
+
const folder = fs33.existsSync(srcPath) ? "src" : "";
|
|
3947
|
+
const emailFilePath = path33.join(projectDir, folder, "lib", "email.ts");
|
|
3948
|
+
if (!fs33.existsSync(emailFilePath)) {
|
|
3410
3949
|
await email();
|
|
3411
3950
|
}
|
|
3412
|
-
const authFilePath =
|
|
3413
|
-
if (!
|
|
3414
|
-
console.log(
|
|
3951
|
+
const authFilePath = path33.join(projectDir, folder, "lib", "auth.ts");
|
|
3952
|
+
if (!fs33.existsSync(authFilePath)) {
|
|
3953
|
+
console.log(chalk35.red("auth.ts file not found."));
|
|
3415
3954
|
return;
|
|
3416
3955
|
}
|
|
3417
|
-
let content =
|
|
3956
|
+
let content = fs33.readFileSync(authFilePath, "utf8");
|
|
3418
3957
|
if (content.includes("emailAndPassword: {")) {
|
|
3419
3958
|
const start = content.indexOf("emailAndPassword: {");
|
|
3420
3959
|
let end = start;
|
|
@@ -3474,51 +4013,51 @@ var verifyNext = async () => {
|
|
|
3474
4013
|
`;
|
|
3475
4014
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
3476
4015
|
}
|
|
3477
|
-
|
|
3478
|
-
const templatePath =
|
|
4016
|
+
fs33.writeFileSync(authFilePath, content, "utf8");
|
|
4017
|
+
const templatePath = path33.resolve(
|
|
3479
4018
|
__dirname,
|
|
3480
4019
|
"./template/email/EmailVerification.tsx"
|
|
3481
4020
|
);
|
|
3482
|
-
const componentsDir =
|
|
3483
|
-
if (!
|
|
3484
|
-
|
|
4021
|
+
const componentsDir = path33.join(projectDir, folder, "components", "email");
|
|
4022
|
+
if (!fs33.existsSync(componentsDir)) {
|
|
4023
|
+
fs33.mkdirSync(componentsDir, { recursive: true });
|
|
3485
4024
|
}
|
|
3486
|
-
const destFile =
|
|
3487
|
-
if (
|
|
3488
|
-
|
|
4025
|
+
const destFile = path33.join(componentsDir, "EmailVerification.tsx");
|
|
4026
|
+
if (fs33.existsSync(templatePath) && !fs33.existsSync(destFile)) {
|
|
4027
|
+
fs33.copyFileSync(templatePath, destFile);
|
|
3489
4028
|
}
|
|
3490
|
-
console.log(
|
|
4029
|
+
console.log(chalk35.green("\nCompleted installation successfully"));
|
|
3491
4030
|
console.log(
|
|
3492
|
-
|
|
4031
|
+
chalk35.white(
|
|
3493
4032
|
`${CreateFolder({ srcFolder: folder, destFolder: "components/email/EmailVerification.tsx" })}`
|
|
3494
4033
|
)
|
|
3495
4034
|
);
|
|
3496
4035
|
} catch (error) {
|
|
3497
|
-
console.log(
|
|
4036
|
+
console.log(chalk35.red(String(error)));
|
|
3498
4037
|
}
|
|
3499
4038
|
};
|
|
3500
4039
|
|
|
3501
4040
|
// script/verifyTanstack.ts
|
|
3502
|
-
import
|
|
3503
|
-
import
|
|
3504
|
-
import
|
|
3505
|
-
import { fileURLToPath as
|
|
4041
|
+
import chalk36 from "chalk";
|
|
4042
|
+
import fs34 from "fs";
|
|
4043
|
+
import path34 from "path";
|
|
4044
|
+
import { fileURLToPath as fileURLToPath30 } from "url";
|
|
3506
4045
|
var verifyTanstack = async () => {
|
|
3507
4046
|
try {
|
|
3508
4047
|
const projectDir = process.cwd();
|
|
3509
|
-
const __filename =
|
|
3510
|
-
const __dirname =
|
|
3511
|
-
const srcPath =
|
|
3512
|
-
const emailFilePath =
|
|
3513
|
-
if (!
|
|
4048
|
+
const __filename = fileURLToPath30(import.meta.url);
|
|
4049
|
+
const __dirname = path34.dirname(__filename);
|
|
4050
|
+
const srcPath = path34.join(projectDir, "src");
|
|
4051
|
+
const emailFilePath = path34.join(srcPath, "lib", "email.ts");
|
|
4052
|
+
if (!fs34.existsSync(emailFilePath)) {
|
|
3514
4053
|
await email();
|
|
3515
4054
|
}
|
|
3516
|
-
const authFilePath =
|
|
3517
|
-
if (!
|
|
3518
|
-
console.log(
|
|
4055
|
+
const authFilePath = path34.join(srcPath, "lib", "auth.ts");
|
|
4056
|
+
if (!fs34.existsSync(authFilePath)) {
|
|
4057
|
+
console.log(chalk36.red("auth.ts file not found."));
|
|
3519
4058
|
return;
|
|
3520
4059
|
}
|
|
3521
|
-
let content =
|
|
4060
|
+
let content = fs34.readFileSync(authFilePath, "utf8");
|
|
3522
4061
|
if (content.includes("emailAndPassword: {")) {
|
|
3523
4062
|
const start = content.indexOf("emailAndPassword: {");
|
|
3524
4063
|
let end = start;
|
|
@@ -3578,23 +4117,23 @@ var verifyTanstack = async () => {
|
|
|
3578
4117
|
`;
|
|
3579
4118
|
content = content.slice(0, nextLine) + imports + content.slice(nextLine);
|
|
3580
4119
|
}
|
|
3581
|
-
|
|
3582
|
-
const templatePath =
|
|
4120
|
+
fs34.writeFileSync(authFilePath, content, "utf8");
|
|
4121
|
+
const templatePath = path34.resolve(
|
|
3583
4122
|
__dirname,
|
|
3584
4123
|
"./template/email/EmailVerification.tsx"
|
|
3585
4124
|
);
|
|
3586
|
-
const componentsDir =
|
|
3587
|
-
if (!
|
|
3588
|
-
|
|
4125
|
+
const componentsDir = path34.join(srcPath, "components", "email");
|
|
4126
|
+
if (!fs34.existsSync(componentsDir)) {
|
|
4127
|
+
fs34.mkdirSync(componentsDir, { recursive: true });
|
|
3589
4128
|
}
|
|
3590
|
-
const destFile =
|
|
3591
|
-
if (
|
|
3592
|
-
|
|
4129
|
+
const destFile = path34.join(componentsDir, "EmailVerification.tsx");
|
|
4130
|
+
if (fs34.existsSync(templatePath) && !fs34.existsSync(destFile)) {
|
|
4131
|
+
fs34.copyFileSync(templatePath, destFile);
|
|
3593
4132
|
}
|
|
3594
|
-
console.log(
|
|
3595
|
-
console.log(
|
|
4133
|
+
console.log(chalk36.green("\nCompleted installation successfully"));
|
|
4134
|
+
console.log(chalk36.white(`\u2022 src/components/email/EmailVerification.tsx`));
|
|
3596
4135
|
} catch (error) {
|
|
3597
|
-
console.log(
|
|
4136
|
+
console.log(chalk36.red(String(error)));
|
|
3598
4137
|
}
|
|
3599
4138
|
};
|
|
3600
4139
|
|
|
@@ -3603,7 +4142,7 @@ var verification = async () => {
|
|
|
3603
4142
|
try {
|
|
3604
4143
|
const { framework, error } = await getFramework();
|
|
3605
4144
|
if (error) {
|
|
3606
|
-
console.log(
|
|
4145
|
+
console.log(chalk37.red(error));
|
|
3607
4146
|
return;
|
|
3608
4147
|
}
|
|
3609
4148
|
if (framework === "Next js") {
|
|
@@ -3613,17 +4152,17 @@ var verification = async () => {
|
|
|
3613
4152
|
await verifyTanstack();
|
|
3614
4153
|
}
|
|
3615
4154
|
} catch (error) {
|
|
3616
|
-
console.log(
|
|
4155
|
+
console.log(chalk37.red(error.message));
|
|
3617
4156
|
}
|
|
3618
4157
|
};
|
|
3619
4158
|
|
|
3620
4159
|
// cli/initCmd.ts
|
|
3621
|
-
import
|
|
4160
|
+
import chalk38 from "chalk";
|
|
3622
4161
|
var initCmd = async (cmd) => {
|
|
3623
4162
|
try {
|
|
3624
4163
|
const { framework, error } = await getFramework();
|
|
3625
4164
|
if (error) {
|
|
3626
|
-
console.log(
|
|
4165
|
+
console.log(chalk38.red(error));
|
|
3627
4166
|
return;
|
|
3628
4167
|
}
|
|
3629
4168
|
if (framework === "Next js" && cmd.orm === "prisma") {
|
|
@@ -3653,7 +4192,7 @@ var initCmd = async (cmd) => {
|
|
|
3653
4192
|
});
|
|
3654
4193
|
}
|
|
3655
4194
|
} catch (error) {
|
|
3656
|
-
console.log(
|
|
4195
|
+
console.log(chalk38.red(error));
|
|
3657
4196
|
}
|
|
3658
4197
|
};
|
|
3659
4198
|
|