authverse 1.1.6 → 1.1.7-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1015,7 +1015,7 @@ var initAnswer = async () => {
1015
1015
  import { readFileSync } from "fs";
1016
1016
 
1017
1017
  // cli/oauth.ts
1018
- import chalk12 from "chalk";
1018
+ import chalk20 from "chalk";
1019
1019
 
1020
1020
  // oauth/googleNext.ts
1021
1021
  import chalk8 from "chalk";
@@ -1105,7 +1105,7 @@ GOOGLE_CLIENT_SECRET=
1105
1105
  }
1106
1106
  const componentTemplate = path8.resolve(
1107
1107
  __dirname,
1108
- "./template/components/GoogleProviders.tsx"
1108
+ "./template/components/GoogleOAuthButton.tsx"
1109
1109
  );
1110
1110
  const componentsDir = path8.join(
1111
1111
  projectDir,
@@ -1116,7 +1116,7 @@ GOOGLE_CLIENT_SECRET=
1116
1116
  if (!fs8.existsSync(componentsDir)) {
1117
1117
  fs8.mkdirSync(componentsDir, { recursive: true });
1118
1118
  }
1119
- const componentDest = path8.join(componentsDir, "GoogleProviders.tsx");
1119
+ const componentDest = path8.join(componentsDir, "GoogleOAuthButton.tsx");
1120
1120
  if (fs8.existsSync(componentTemplate)) {
1121
1121
  fs8.copyFileSync(componentTemplate, componentDest);
1122
1122
  }
@@ -1143,19 +1143,866 @@ var githubNext = async () => {
1143
1143
  console.log(chalk9.red("auth.ts file not found"));
1144
1144
  return;
1145
1145
  }
1146
- let content = fs9.readFileSync(authFilePath, "utf8");
1146
+ let content = fs9.readFileSync(authFilePath, "utf8");
1147
+ if (!content.includes("betterAuth({")) {
1148
+ console.log(chalk9.red("betterAuth({}) block not found"));
1149
+ return;
1150
+ }
1151
+ if (content.includes("socialProviders") && content.includes("github:")) {
1152
+ console.log(chalk9.yellow("GitHub provider already exists"));
1153
+ return;
1154
+ }
1155
+ const githubProviderEntry = `
1156
+ github: {
1157
+ clientId: process.env.GITHUB_CLIENT_ID as string,
1158
+ clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
1159
+ },`;
1160
+ if (content.includes("socialProviders: {")) {
1161
+ const start = content.indexOf("socialProviders: {");
1162
+ let braceCount = 0;
1163
+ let insertPos = -1;
1164
+ for (let i = start; i < content.length; i++) {
1165
+ if (content[i] === "{") braceCount++;
1166
+ if (content[i] === "}") {
1167
+ braceCount--;
1168
+ if (braceCount === 0) {
1169
+ insertPos = i;
1170
+ break;
1171
+ }
1172
+ }
1173
+ }
1174
+ if (insertPos === -1) {
1175
+ console.log(chalk9.red("Failed to parse socialProviders block"));
1176
+ return;
1177
+ }
1178
+ content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
1179
+ } else {
1180
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1181
+ if (!databaseRegex.test(content)) {
1182
+ console.log(
1183
+ chalk9.red(
1184
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1185
+ )
1186
+ );
1187
+ return;
1188
+ }
1189
+ const socialProvidersBlock = `
1190
+ socialProviders: {
1191
+ ${githubProviderEntry}
1192
+ },`;
1193
+ content = content.replace(
1194
+ databaseRegex,
1195
+ (match) => `${match}
1196
+ ${socialProvidersBlock}`
1197
+ );
1198
+ }
1199
+ fs9.writeFileSync(authFilePath, content, "utf8");
1200
+ const envPath = path9.join(projectDir, ".env");
1201
+ if (fs9.existsSync(envPath)) {
1202
+ const envContent = fs9.readFileSync(envPath, "utf8");
1203
+ if (!envContent.includes("GITHUB_CLIENT_ID")) {
1204
+ fs9.appendFileSync(
1205
+ envPath,
1206
+ `
1207
+
1208
+ # GitHub OAuth
1209
+ GITHUB_CLIENT_ID=
1210
+ GITHUB_CLIENT_SECRET=
1211
+ `
1212
+ );
1213
+ }
1214
+ }
1215
+ const componentTemplate = path9.resolve(
1216
+ __dirname,
1217
+ "./template/components/GithubOAuthButton.tsx"
1218
+ );
1219
+ const componentsDir = path9.join(
1220
+ projectDir,
1221
+ folder,
1222
+ "components",
1223
+ "authverse"
1224
+ );
1225
+ if (!fs9.existsSync(componentsDir)) {
1226
+ fs9.mkdirSync(componentsDir, { recursive: true });
1227
+ }
1228
+ const componentDest = path9.join(componentsDir, "GithubOAuthButton.tsx");
1229
+ if (fs9.existsSync(componentTemplate)) {
1230
+ fs9.copyFileSync(componentTemplate, componentDest);
1231
+ }
1232
+ console.log(chalk9.green("GitHub provider added & merged successfully"));
1233
+ } catch (error) {
1234
+ console.log(chalk9.red("githubRun error:"), error);
1235
+ }
1236
+ };
1237
+
1238
+ // oauth/googleTanstackState.ts
1239
+ import chalk10 from "chalk";
1240
+ import fs10 from "fs";
1241
+ import path10 from "path";
1242
+ import { fileURLToPath as fileURLToPath9 } from "url";
1243
+ var googleTanstackState = async () => {
1244
+ try {
1245
+ const __filename = fileURLToPath9(import.meta.url);
1246
+ const __dirname = path10.dirname(__filename);
1247
+ const projectDir = process.cwd();
1248
+ const srcPath = path10.join(projectDir, "src");
1249
+ const authFilePath = path10.join(srcPath, "lib", "auth.ts");
1250
+ if (!fs10.existsSync(authFilePath)) {
1251
+ console.log(chalk10.red("auth.ts file not found"));
1252
+ return;
1253
+ }
1254
+ let content = fs10.readFileSync(authFilePath, "utf8");
1255
+ if (!content.includes("betterAuth({")) {
1256
+ console.log(chalk10.red("betterAuth({}) block not found"));
1257
+ return;
1258
+ }
1259
+ if (content.includes("socialProviders") && content.includes("google:")) {
1260
+ console.log(chalk10.yellow("Google provider already exists"));
1261
+ return;
1262
+ }
1263
+ const googleProviderEntry = `
1264
+ google: {
1265
+ clientId: process.env.GOOGLE_CLIENT_ID as string,
1266
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
1267
+ },`;
1268
+ if (content.includes("socialProviders: {")) {
1269
+ const start = content.indexOf("socialProviders: {");
1270
+ let braceCount = 0;
1271
+ let insertPos = -1;
1272
+ for (let i = start; i < content.length; i++) {
1273
+ if (content[i] === "{") braceCount++;
1274
+ if (content[i] === "}") {
1275
+ braceCount--;
1276
+ if (braceCount === 0) {
1277
+ insertPos = i;
1278
+ break;
1279
+ }
1280
+ }
1281
+ }
1282
+ if (insertPos === -1) {
1283
+ console.log(chalk10.red("Failed to parse socialProviders block"));
1284
+ return;
1285
+ }
1286
+ content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
1287
+ } else {
1288
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1289
+ if (!databaseRegex.test(content)) {
1290
+ console.log(
1291
+ chalk10.red(
1292
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1293
+ )
1294
+ );
1295
+ return;
1296
+ }
1297
+ const socialProvidersBlock = `
1298
+ socialProviders: {
1299
+ ${googleProviderEntry}
1300
+ },`;
1301
+ content = content.replace(
1302
+ databaseRegex,
1303
+ (match) => `${match}
1304
+ ${socialProvidersBlock}`
1305
+ );
1306
+ }
1307
+ fs10.writeFileSync(authFilePath, content, "utf8");
1308
+ const envPath = path10.join(projectDir, ".env");
1309
+ if (fs10.existsSync(envPath)) {
1310
+ const envContent = fs10.readFileSync(envPath, "utf8");
1311
+ if (!envContent.includes("GOOGLE_CLIENT_ID")) {
1312
+ fs10.appendFileSync(
1313
+ envPath,
1314
+ `
1315
+
1316
+ # Google OAuth
1317
+ GOOGLE_CLIENT_ID=
1318
+ GOOGLE_CLIENT_SECRET=
1319
+ `
1320
+ );
1321
+ }
1322
+ }
1323
+ const componentTemplate = path10.resolve(
1324
+ __dirname,
1325
+ "./template/TanstackState/components/GoogleOAuthButton.tsx"
1326
+ );
1327
+ const componentsDir = path10.join(srcPath, "components", "authverse");
1328
+ if (!fs10.existsSync(componentsDir)) {
1329
+ fs10.mkdirSync(componentsDir, { recursive: true });
1330
+ }
1331
+ const componentDest = path10.join(componentsDir, "GoogleOAuthButton.tsx");
1332
+ if (fs10.existsSync(componentTemplate)) {
1333
+ fs10.copyFileSync(componentTemplate, componentDest);
1334
+ }
1335
+ console.log(chalk10.green("Google provider added & merged successfully"));
1336
+ } catch (error) {
1337
+ console.log(chalk10.red("googleRunTanstackState error:"), error);
1338
+ }
1339
+ };
1340
+
1341
+ // oauth/githubTanstackState.ts
1342
+ import chalk11 from "chalk";
1343
+ import fs11 from "fs";
1344
+ import path11 from "path";
1345
+ import { fileURLToPath as fileURLToPath10 } from "url";
1346
+ var githubTanstackState = async () => {
1347
+ try {
1348
+ const __filename = fileURLToPath10(import.meta.url);
1349
+ const __dirname = path11.dirname(__filename);
1350
+ const projectDir = process.cwd();
1351
+ const srcPath = path11.join(projectDir, "src");
1352
+ const authFilePath = path11.join(srcPath, "lib", "auth.ts");
1353
+ if (!fs11.existsSync(authFilePath)) {
1354
+ console.log(chalk11.red("auth.ts file not found"));
1355
+ return;
1356
+ }
1357
+ let content = fs11.readFileSync(authFilePath, "utf8");
1358
+ if (!content.includes("betterAuth({")) {
1359
+ console.log(chalk11.red("betterAuth({}) block not found"));
1360
+ return;
1361
+ }
1362
+ if (content.includes("socialProviders") && content.includes("github:")) {
1363
+ console.log(chalk11.yellow("Github provider already exists"));
1364
+ return;
1365
+ }
1366
+ const githubProviderEntry = `
1367
+ github: {
1368
+ clientId: process.env.GITHUB_CLIENT_ID as string,
1369
+ clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
1370
+ },`;
1371
+ if (content.includes("socialProviders: {")) {
1372
+ const start = content.indexOf("socialProviders: {");
1373
+ let braceCount = 0;
1374
+ let insertPos = -1;
1375
+ for (let i = start; i < content.length; i++) {
1376
+ if (content[i] === "{") braceCount++;
1377
+ if (content[i] === "}") {
1378
+ braceCount--;
1379
+ if (braceCount === 0) {
1380
+ insertPos = i;
1381
+ break;
1382
+ }
1383
+ }
1384
+ }
1385
+ if (insertPos === -1) {
1386
+ console.log(chalk11.red("Failed to parse socialProviders block"));
1387
+ return;
1388
+ }
1389
+ content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
1390
+ } else {
1391
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1392
+ if (!databaseRegex.test(content)) {
1393
+ console.log(
1394
+ chalk11.red(
1395
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1396
+ )
1397
+ );
1398
+ return;
1399
+ }
1400
+ const socialProvidersBlock = `
1401
+ socialProviders: {
1402
+ ${githubProviderEntry}
1403
+ },`;
1404
+ content = content.replace(
1405
+ databaseRegex,
1406
+ (match) => `${match}
1407
+ ${socialProvidersBlock}`
1408
+ );
1409
+ }
1410
+ fs11.writeFileSync(authFilePath, content, "utf8");
1411
+ const envPath = path11.join(projectDir, ".env");
1412
+ if (fs11.existsSync(envPath)) {
1413
+ const envContent = fs11.readFileSync(envPath, "utf8");
1414
+ if (!envContent.includes("GITHUB_CLIENT_ID")) {
1415
+ fs11.appendFileSync(
1416
+ envPath,
1417
+ `
1418
+
1419
+ # Github OAuth
1420
+ GITHUB_CLIENT_ID=
1421
+ GITHUB_CLIENT_SECRET=
1422
+ `
1423
+ );
1424
+ }
1425
+ }
1426
+ const componentTemplate = path11.resolve(
1427
+ __dirname,
1428
+ "./template/TanstackState/components/GithubOAuthButton.tsx"
1429
+ );
1430
+ const componentsDir = path11.join(srcPath, "components", "authverse");
1431
+ if (!fs11.existsSync(componentsDir)) {
1432
+ fs11.mkdirSync(componentsDir, { recursive: true });
1433
+ }
1434
+ const componentDest = path11.join(componentsDir, "GithubOAuthButton.tsx");
1435
+ if (fs11.existsSync(componentTemplate)) {
1436
+ fs11.copyFileSync(componentTemplate, componentDest);
1437
+ }
1438
+ console.log(chalk11.green("Github provider added & merged successfully"));
1439
+ } catch (error) {
1440
+ console.log(chalk11.red("githubRunTanstackState error:"), error);
1441
+ }
1442
+ };
1443
+
1444
+ // oauth/facebookNext.ts
1445
+ import chalk12 from "chalk";
1446
+ import fs12 from "fs";
1447
+ import path12 from "path";
1448
+ import { fileURLToPath as fileURLToPath11 } from "url";
1449
+ var facebookNext = async () => {
1450
+ try {
1451
+ const __filename = fileURLToPath11(import.meta.url);
1452
+ const __dirname = path12.dirname(__filename);
1453
+ const projectDir = process.cwd();
1454
+ const srcPath = path12.join(projectDir, "src");
1455
+ const folder = fs12.existsSync(srcPath) ? "src" : "";
1456
+ const authFilePath = path12.join(projectDir, folder, "lib", "auth.ts");
1457
+ if (!fs12.existsSync(authFilePath)) {
1458
+ console.log(chalk12.red("auth.ts file not found"));
1459
+ return;
1460
+ }
1461
+ let content = fs12.readFileSync(authFilePath, "utf8");
1462
+ if (!content.includes("betterAuth({")) {
1463
+ console.log(chalk12.red("betterAuth({}) block not found"));
1464
+ return;
1465
+ }
1466
+ if (content.includes("socialProviders") && content.includes("facebook:")) {
1467
+ console.log(chalk12.yellow("Facebook provider already exists"));
1468
+ return;
1469
+ }
1470
+ const facebookProviderEntry = `
1471
+ facebook: {
1472
+ clientId: process.env.FACEBOOK_CLIENT_ID as string,
1473
+ clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string,
1474
+ },`;
1475
+ if (content.includes("socialProviders: {")) {
1476
+ const start = content.indexOf("socialProviders: {");
1477
+ let braceCount = 0;
1478
+ let insertPos = -1;
1479
+ for (let i = start; i < content.length; i++) {
1480
+ if (content[i] === "{") braceCount++;
1481
+ if (content[i] === "}") {
1482
+ braceCount--;
1483
+ if (braceCount === 0) {
1484
+ insertPos = i;
1485
+ break;
1486
+ }
1487
+ }
1488
+ }
1489
+ if (insertPos === -1) {
1490
+ console.log(chalk12.red("Failed to parse socialProviders block"));
1491
+ return;
1492
+ }
1493
+ content = content.slice(0, insertPos) + facebookProviderEntry + "\n " + content.slice(insertPos);
1494
+ } else {
1495
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1496
+ if (!databaseRegex.test(content)) {
1497
+ console.log(
1498
+ chalk12.red(
1499
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1500
+ )
1501
+ );
1502
+ return;
1503
+ }
1504
+ const socialProvidersBlock = `
1505
+ socialProviders: {
1506
+ ${facebookProviderEntry}
1507
+ },`;
1508
+ content = content.replace(
1509
+ databaseRegex,
1510
+ (match) => `${match}
1511
+ ${socialProvidersBlock}`
1512
+ );
1513
+ }
1514
+ fs12.writeFileSync(authFilePath, content, "utf8");
1515
+ const envPath = path12.join(projectDir, ".env");
1516
+ if (fs12.existsSync(envPath)) {
1517
+ const envContent = fs12.readFileSync(envPath, "utf8");
1518
+ if (!envContent.includes("FACEBOOK_CLIENT_ID")) {
1519
+ fs12.appendFileSync(
1520
+ envPath,
1521
+ `
1522
+
1523
+ # Facebook OAuth
1524
+ FACEBOOK_CLIENT_ID=
1525
+ FACEBOOK_CLIENT_SECRET=
1526
+ `
1527
+ );
1528
+ }
1529
+ }
1530
+ const componentTemplate = path12.resolve(
1531
+ __dirname,
1532
+ "./template/components/FacebookOAuthButton.tsx"
1533
+ );
1534
+ const componentsDir = path12.join(
1535
+ projectDir,
1536
+ folder,
1537
+ "components",
1538
+ "authverse"
1539
+ );
1540
+ if (!fs12.existsSync(componentsDir)) {
1541
+ fs12.mkdirSync(componentsDir, { recursive: true });
1542
+ }
1543
+ const componentDest = path12.join(componentsDir, "FacebookOAuthButton.tsx");
1544
+ if (fs12.existsSync(componentTemplate)) {
1545
+ fs12.copyFileSync(componentTemplate, componentDest);
1546
+ }
1547
+ console.log(chalk12.green("Facebook provider added & merged successfully"));
1548
+ } catch (error) {
1549
+ console.log(chalk12.red("facebookRun error:"), error);
1550
+ }
1551
+ };
1552
+
1553
+ // oauth/facebookTanstackState.ts
1554
+ import chalk13 from "chalk";
1555
+ import fs13 from "fs";
1556
+ import path13 from "path";
1557
+ import { fileURLToPath as fileURLToPath12 } from "url";
1558
+ var facebookTanstackState = async () => {
1559
+ try {
1560
+ const __filename = fileURLToPath12(import.meta.url);
1561
+ const __dirname = path13.dirname(__filename);
1562
+ const projectDir = process.cwd();
1563
+ const srcPath = path13.join(projectDir, "src");
1564
+ const authFilePath = path13.join(srcPath, "lib", "auth.ts");
1565
+ if (!fs13.existsSync(authFilePath)) {
1566
+ console.log(chalk13.red("auth.ts file not found"));
1567
+ return;
1568
+ }
1569
+ let content = fs13.readFileSync(authFilePath, "utf8");
1570
+ if (!content.includes("betterAuth({")) {
1571
+ console.log(chalk13.red("betterAuth({}) block not found"));
1572
+ return;
1573
+ }
1574
+ if (content.includes("socialProviders") && content.includes("facebook:")) {
1575
+ console.log(chalk13.yellow("Facebook provider already exists"));
1576
+ return;
1577
+ }
1578
+ const facebookProviderEntry = `
1579
+ facebook: {
1580
+ clientId: process.env.FACEBOOK_CLIENT_ID as string,
1581
+ clientSecret: process.env.FACEBOOK_CLIENT_SECRET as string,
1582
+ },`;
1583
+ if (content.includes("socialProviders: {")) {
1584
+ const start = content.indexOf("socialProviders: {");
1585
+ let braceCount = 0;
1586
+ let insertPos = -1;
1587
+ for (let i = start; i < content.length; i++) {
1588
+ if (content[i] === "{") braceCount++;
1589
+ if (content[i] === "}") {
1590
+ braceCount--;
1591
+ if (braceCount === 0) {
1592
+ insertPos = i;
1593
+ break;
1594
+ }
1595
+ }
1596
+ }
1597
+ if (insertPos === -1) {
1598
+ console.log(chalk13.red("Failed to parse socialProviders block"));
1599
+ return;
1600
+ }
1601
+ content = content.slice(0, insertPos) + facebookProviderEntry + "\n " + content.slice(insertPos);
1602
+ } else {
1603
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1604
+ if (!databaseRegex.test(content)) {
1605
+ console.log(
1606
+ chalk13.red(
1607
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1608
+ )
1609
+ );
1610
+ return;
1611
+ }
1612
+ const socialProvidersBlock = `
1613
+ socialProviders: {
1614
+ ${facebookProviderEntry}
1615
+ },`;
1616
+ content = content.replace(
1617
+ databaseRegex,
1618
+ (match) => `${match}
1619
+ ${socialProvidersBlock}`
1620
+ );
1621
+ }
1622
+ fs13.writeFileSync(authFilePath, content, "utf8");
1623
+ const envPath = path13.join(projectDir, ".env");
1624
+ if (fs13.existsSync(envPath)) {
1625
+ const envContent = fs13.readFileSync(envPath, "utf8");
1626
+ if (!envContent.includes("FACEBOOK_CLIENT_ID")) {
1627
+ fs13.appendFileSync(
1628
+ envPath,
1629
+ `
1630
+
1631
+ # Facebook OAuth
1632
+ FACEBOOK_CLIENT_ID=
1633
+ FACEBOOK_CLIENT_SECRET=
1634
+ `
1635
+ );
1636
+ }
1637
+ }
1638
+ const componentTemplate = path13.resolve(
1639
+ __dirname,
1640
+ "./template/TanstackState/components/FacebookOAuthButton.tsx"
1641
+ );
1642
+ const componentsDir = path13.join(srcPath, "components", "authverse");
1643
+ if (!fs13.existsSync(componentsDir)) {
1644
+ fs13.mkdirSync(componentsDir, { recursive: true });
1645
+ }
1646
+ const componentDest = path13.join(componentsDir, "FacebookOAuthButton.tsx");
1647
+ if (fs13.existsSync(componentTemplate)) {
1648
+ fs13.copyFileSync(componentTemplate, componentDest);
1649
+ }
1650
+ console.log(chalk13.green("Facebook provider added & merged successfully"));
1651
+ } catch (error) {
1652
+ console.log(chalk13.red("facebookRunTanstackState error:"), error);
1653
+ }
1654
+ };
1655
+
1656
+ // oauth/LinkedInNext.ts
1657
+ import chalk14 from "chalk";
1658
+ import fs14 from "fs";
1659
+ import path14 from "path";
1660
+ import { fileURLToPath as fileURLToPath13 } from "url";
1661
+ var LinkedInNext = async () => {
1662
+ try {
1663
+ const __filename = fileURLToPath13(import.meta.url);
1664
+ const __dirname = path14.dirname(__filename);
1665
+ const projectDir = process.cwd();
1666
+ const srcPath = path14.join(projectDir, "src");
1667
+ const folder = fs14.existsSync(srcPath) ? "src" : "";
1668
+ const authFilePath = path14.join(projectDir, folder, "lib", "auth.ts");
1669
+ if (!fs14.existsSync(authFilePath)) {
1670
+ console.log(chalk14.red("auth.ts file not found"));
1671
+ return;
1672
+ }
1673
+ let content = fs14.readFileSync(authFilePath, "utf8");
1674
+ if (!content.includes("betterAuth({")) {
1675
+ console.log(chalk14.red("betterAuth({}) block not found"));
1676
+ return;
1677
+ }
1678
+ if (content.includes("socialProviders") && content.includes("LinkedIn:")) {
1679
+ console.log(chalk14.yellow("LinkedIn provider already exists"));
1680
+ return;
1681
+ }
1682
+ const LinkedInProviderEntry = `
1683
+ LinkedIn: {
1684
+ clientId: process.env.LINKEDIN_CLIENT_ID as string,
1685
+ clientSecret: process.env.LINKEDIN_CLIENT_SECRET as string,
1686
+ },`;
1687
+ if (content.includes("socialProviders: {")) {
1688
+ const start = content.indexOf("socialProviders: {");
1689
+ let braceCount = 0;
1690
+ let insertPos = -1;
1691
+ for (let i = start; i < content.length; i++) {
1692
+ if (content[i] === "{") braceCount++;
1693
+ if (content[i] === "}") {
1694
+ braceCount--;
1695
+ if (braceCount === 0) {
1696
+ insertPos = i;
1697
+ break;
1698
+ }
1699
+ }
1700
+ }
1701
+ if (insertPos === -1) {
1702
+ console.log(chalk14.red("Failed to parse socialProviders block"));
1703
+ return;
1704
+ }
1705
+ content = content.slice(0, insertPos) + LinkedInProviderEntry + "\n " + content.slice(insertPos);
1706
+ } else {
1707
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1708
+ if (!databaseRegex.test(content)) {
1709
+ console.log(
1710
+ chalk14.red(
1711
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1712
+ )
1713
+ );
1714
+ return;
1715
+ }
1716
+ const socialProvidersBlock = `
1717
+ socialProviders: {
1718
+ ${LinkedInProviderEntry}
1719
+ },`;
1720
+ content = content.replace(
1721
+ databaseRegex,
1722
+ (match) => `${match}
1723
+ ${socialProvidersBlock}`
1724
+ );
1725
+ }
1726
+ fs14.writeFileSync(authFilePath, content, "utf8");
1727
+ const envPath = path14.join(projectDir, ".env");
1728
+ if (fs14.existsSync(envPath)) {
1729
+ const envContent = fs14.readFileSync(envPath, "utf8");
1730
+ if (!envContent.includes("LINKEDIN_CLIENT_ID")) {
1731
+ fs14.appendFileSync(
1732
+ envPath,
1733
+ `
1734
+
1735
+ # LinkedIn OAuth
1736
+ LINKEDIN_CLIENT_ID=
1737
+ LINKEDIN_CLIENT_SECRET=
1738
+ `
1739
+ );
1740
+ }
1741
+ }
1742
+ const componentTemplate = path14.resolve(
1743
+ __dirname,
1744
+ "./template/components/LinkedInOAuthButton.tsx"
1745
+ );
1746
+ const componentsDir = path14.join(
1747
+ projectDir,
1748
+ folder,
1749
+ "components",
1750
+ "authverse"
1751
+ );
1752
+ if (!fs14.existsSync(componentsDir)) {
1753
+ fs14.mkdirSync(componentsDir, { recursive: true });
1754
+ }
1755
+ const componentDest = path14.join(componentsDir, "LinkedInOAuthButton.tsx");
1756
+ if (fs14.existsSync(componentTemplate)) {
1757
+ fs14.copyFileSync(componentTemplate, componentDest);
1758
+ }
1759
+ console.log(chalk14.green("LinkedIn provider added & merged successfully"));
1760
+ } catch (error) {
1761
+ console.log(chalk14.red("LinkedIn error:"), error);
1762
+ }
1763
+ };
1764
+
1765
+ // oauth/LinkedInTanstackState.ts
1766
+ import chalk15 from "chalk";
1767
+ import fs15 from "fs";
1768
+ import path15 from "path";
1769
+ import { fileURLToPath as fileURLToPath14 } from "url";
1770
+ var LinkedInTanstackState = async () => {
1771
+ try {
1772
+ const __filename = fileURLToPath14(import.meta.url);
1773
+ const __dirname = path15.dirname(__filename);
1774
+ const projectDir = process.cwd();
1775
+ const srcPath = path15.join(projectDir, "src");
1776
+ const authFilePath = path15.join(srcPath, "lib", "auth.ts");
1777
+ if (!fs15.existsSync(authFilePath)) {
1778
+ console.log(chalk15.red("auth.ts file not found"));
1779
+ return;
1780
+ }
1781
+ let content = fs15.readFileSync(authFilePath, "utf8");
1782
+ if (!content.includes("betterAuth({")) {
1783
+ console.log(chalk15.red("betterAuth({}) block not found"));
1784
+ return;
1785
+ }
1786
+ if (content.includes("socialProviders") && content.includes("linkedin:")) {
1787
+ console.log(chalk15.yellow("LinkedIn provider already exists"));
1788
+ return;
1789
+ }
1790
+ const LinkedInProviderEntry = `
1791
+ LinkedIn: {
1792
+ clientId: process.env.LINKEDIN_CLIENT_ID as string,
1793
+ clientSecret: process.env.LINKEDIN_CLIENT_SECRET as string,
1794
+ },`;
1795
+ if (content.includes("socialProviders: {")) {
1796
+ const start = content.indexOf("socialProviders: {");
1797
+ let braceCount = 0;
1798
+ let insertPos = -1;
1799
+ for (let i = start; i < content.length; i++) {
1800
+ if (content[i] === "{") braceCount++;
1801
+ if (content[i] === "}") {
1802
+ braceCount--;
1803
+ if (braceCount === 0) {
1804
+ insertPos = i;
1805
+ break;
1806
+ }
1807
+ }
1808
+ }
1809
+ if (insertPos === -1) {
1810
+ console.log(chalk15.red("Failed to parse socialProviders block"));
1811
+ return;
1812
+ }
1813
+ content = content.slice(0, insertPos) + LinkedInProviderEntry + "\n " + content.slice(insertPos);
1814
+ } else {
1815
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1816
+ if (!databaseRegex.test(content)) {
1817
+ console.log(
1818
+ chalk15.red(
1819
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1820
+ )
1821
+ );
1822
+ return;
1823
+ }
1824
+ const socialProvidersBlock = `
1825
+ socialProviders: {
1826
+ ${LinkedInProviderEntry}
1827
+ },`;
1828
+ content = content.replace(
1829
+ databaseRegex,
1830
+ (match) => `${match}
1831
+ ${socialProvidersBlock}`
1832
+ );
1833
+ }
1834
+ fs15.writeFileSync(authFilePath, content, "utf8");
1835
+ const envPath = path15.join(projectDir, ".env");
1836
+ if (fs15.existsSync(envPath)) {
1837
+ const envContent = fs15.readFileSync(envPath, "utf8");
1838
+ if (!envContent.includes("LINKEDIN_CLIENT_ID")) {
1839
+ fs15.appendFileSync(
1840
+ envPath,
1841
+ `
1842
+
1843
+ # LinkedIn OAuth
1844
+ LINKEDIN_CLIENT_ID=
1845
+ LINKEDIN_CLIENT_SECRET=
1846
+ `
1847
+ );
1848
+ }
1849
+ }
1850
+ const componentTemplate = path15.resolve(
1851
+ __dirname,
1852
+ "./template/TanstackState/components/LinkedInOAuthButton.tsx"
1853
+ );
1854
+ const componentsDir = path15.join(srcPath, "components", "authverse");
1855
+ if (!fs15.existsSync(componentsDir)) {
1856
+ fs15.mkdirSync(componentsDir, { recursive: true });
1857
+ }
1858
+ const componentDest = path15.join(componentsDir, "LinkedInOAuthButton.tsx");
1859
+ if (fs15.existsSync(componentTemplate)) {
1860
+ fs15.copyFileSync(componentTemplate, componentDest);
1861
+ }
1862
+ console.log(chalk15.green("LinkedIn provider added & merged successfully"));
1863
+ } catch (error) {
1864
+ console.log(chalk15.red("LinkedInTanstackState error:"), error);
1865
+ }
1866
+ };
1867
+
1868
+ // oauth/twitterNext.ts
1869
+ import chalk16 from "chalk";
1870
+ import fs16 from "fs";
1871
+ import path16 from "path";
1872
+ import { fileURLToPath as fileURLToPath15 } from "url";
1873
+ var twitterNext = async () => {
1874
+ try {
1875
+ const __filename = fileURLToPath15(import.meta.url);
1876
+ const __dirname = path16.dirname(__filename);
1877
+ const projectDir = process.cwd();
1878
+ const srcPath = path16.join(projectDir, "src");
1879
+ const folder = fs16.existsSync(srcPath) ? "src" : "";
1880
+ const authFilePath = path16.join(projectDir, folder, "lib", "auth.ts");
1881
+ if (!fs16.existsSync(authFilePath)) {
1882
+ console.log(chalk16.red("auth.ts file not found"));
1883
+ return;
1884
+ }
1885
+ let content = fs16.readFileSync(authFilePath, "utf8");
1886
+ if (!content.includes("betterAuth({")) {
1887
+ console.log(chalk16.red("betterAuth({}) block not found"));
1888
+ return;
1889
+ }
1890
+ if (content.includes("socialProviders") && content.includes("twitter:")) {
1891
+ console.log(chalk16.yellow("twitter provider already exists"));
1892
+ return;
1893
+ }
1894
+ const twitterProviderEntry = `
1895
+ twitter: {
1896
+ clientId: process.env.TWITTER_CLIENT_ID as string,
1897
+ clientSecret: process.env.TWITTER_CLIENT_SECRET as string,
1898
+ },`;
1899
+ if (content.includes("socialProviders: {")) {
1900
+ const start = content.indexOf("socialProviders: {");
1901
+ let braceCount = 0;
1902
+ let insertPos = -1;
1903
+ for (let i = start; i < content.length; i++) {
1904
+ if (content[i] === "{") braceCount++;
1905
+ if (content[i] === "}") {
1906
+ braceCount--;
1907
+ if (braceCount === 0) {
1908
+ insertPos = i;
1909
+ break;
1910
+ }
1911
+ }
1912
+ }
1913
+ if (insertPos === -1) {
1914
+ console.log(chalk16.red("Failed to parse socialProviders block"));
1915
+ return;
1916
+ }
1917
+ content = content.slice(0, insertPos) + twitterProviderEntry + "\n " + content.slice(insertPos);
1918
+ } else {
1919
+ const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1920
+ if (!databaseRegex.test(content)) {
1921
+ console.log(
1922
+ chalk16.red(
1923
+ "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1924
+ )
1925
+ );
1926
+ return;
1927
+ }
1928
+ const socialProvidersBlock = `
1929
+ socialProviders: {
1930
+ ${twitterProviderEntry}
1931
+ },`;
1932
+ content = content.replace(
1933
+ databaseRegex,
1934
+ (match) => `${match}
1935
+ ${socialProvidersBlock}`
1936
+ );
1937
+ }
1938
+ fs16.writeFileSync(authFilePath, content, "utf8");
1939
+ const envPath = path16.join(projectDir, ".env");
1940
+ if (fs16.existsSync(envPath)) {
1941
+ const envContent = fs16.readFileSync(envPath, "utf8");
1942
+ if (!envContent.includes("TWITTER_CLIENT_ID")) {
1943
+ fs16.appendFileSync(
1944
+ envPath,
1945
+ `
1946
+
1947
+ # Twitter OAuth
1948
+ TWITTER_CLIENT_ID=
1949
+ TWITTER_CLIENT_SECRET=
1950
+ `
1951
+ );
1952
+ }
1953
+ }
1954
+ const componentTemplate = path16.resolve(
1955
+ __dirname,
1956
+ "./template/components/twitterOAuthButton.tsx"
1957
+ );
1958
+ const componentsDir = path16.join(
1959
+ projectDir,
1960
+ folder,
1961
+ "components",
1962
+ "authverse"
1963
+ );
1964
+ if (!fs16.existsSync(componentsDir)) {
1965
+ fs16.mkdirSync(componentsDir, { recursive: true });
1966
+ }
1967
+ const componentDest = path16.join(componentsDir, "twitterOAuthButton.tsx");
1968
+ if (fs16.existsSync(componentTemplate)) {
1969
+ fs16.copyFileSync(componentTemplate, componentDest);
1970
+ }
1971
+ console.log(chalk16.green("twitter provider added & merged successfully"));
1972
+ } catch (error) {
1973
+ console.log(chalk16.red("twitter error:"), error);
1974
+ }
1975
+ };
1976
+
1977
+ // oauth/twitterTanstackState.ts
1978
+ import chalk17 from "chalk";
1979
+ import fs17 from "fs";
1980
+ import path17 from "path";
1981
+ import { fileURLToPath as fileURLToPath16 } from "url";
1982
+ var twitterTanstackState = async () => {
1983
+ try {
1984
+ const __filename = fileURLToPath16(import.meta.url);
1985
+ const __dirname = path17.dirname(__filename);
1986
+ const projectDir = process.cwd();
1987
+ const srcPath = path17.join(projectDir, "src");
1988
+ const authFilePath = path17.join(srcPath, "lib", "auth.ts");
1989
+ if (!fs17.existsSync(authFilePath)) {
1990
+ console.log(chalk17.red("auth.ts file not found"));
1991
+ return;
1992
+ }
1993
+ let content = fs17.readFileSync(authFilePath, "utf8");
1147
1994
  if (!content.includes("betterAuth({")) {
1148
- console.log(chalk9.red("betterAuth({}) block not found"));
1995
+ console.log(chalk17.red("betterAuth({}) block not found"));
1149
1996
  return;
1150
1997
  }
1151
- if (content.includes("socialProviders") && content.includes("github:")) {
1152
- console.log(chalk9.yellow("GitHub provider already exists"));
1998
+ if (content.includes("socialProviders") && content.includes("twitter:")) {
1999
+ console.log(chalk17.yellow("twitter provider already exists"));
1153
2000
  return;
1154
2001
  }
1155
- const githubProviderEntry = `
1156
- github: {
1157
- clientId: process.env.GITHUB_CLIENT_ID as string,
1158
- clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
2002
+ const twitterProviderEntry = `
2003
+ twitter: {
2004
+ clientId: process.env.TWITTER_CLIENT_ID as string,
2005
+ clientSecret: process.env.TWITTER_CLIENT_SECRET as string,
1159
2006
  },`;
1160
2007
  if (content.includes("socialProviders: {")) {
1161
2008
  const start = content.indexOf("socialProviders: {");
@@ -1172,15 +2019,15 @@ var githubNext = async () => {
1172
2019
  }
1173
2020
  }
1174
2021
  if (insertPos === -1) {
1175
- console.log(chalk9.red("Failed to parse socialProviders block"));
2022
+ console.log(chalk17.red("Failed to parse socialProviders block"));
1176
2023
  return;
1177
2024
  }
1178
- content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
2025
+ content = content.slice(0, insertPos) + twitterProviderEntry + "\n " + content.slice(insertPos);
1179
2026
  } else {
1180
2027
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1181
2028
  if (!databaseRegex.test(content)) {
1182
2029
  console.log(
1183
- chalk9.red(
2030
+ chalk17.red(
1184
2031
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1185
2032
  )
1186
2033
  );
@@ -1188,7 +2035,7 @@ var githubNext = async () => {
1188
2035
  }
1189
2036
  const socialProvidersBlock = `
1190
2037
  socialProviders: {
1191
- ${githubProviderEntry}
2038
+ ${twitterProviderEntry}
1192
2039
  },`;
1193
2040
  content = content.replace(
1194
2041
  databaseRegex,
@@ -1196,74 +2043,72 @@ ${githubProviderEntry}
1196
2043
  ${socialProvidersBlock}`
1197
2044
  );
1198
2045
  }
1199
- fs9.writeFileSync(authFilePath, content, "utf8");
1200
- const envPath = path9.join(projectDir, ".env");
1201
- if (fs9.existsSync(envPath)) {
1202
- const envContent = fs9.readFileSync(envPath, "utf8");
1203
- if (!envContent.includes("GITHUB_CLIENT_ID")) {
1204
- fs9.appendFileSync(
2046
+ fs17.writeFileSync(authFilePath, content, "utf8");
2047
+ const envPath = path17.join(projectDir, ".env");
2048
+ if (fs17.existsSync(envPath)) {
2049
+ const envContent = fs17.readFileSync(envPath, "utf8");
2050
+ if (!envContent.includes("TWITTER_CLIENT_ID")) {
2051
+ fs17.appendFileSync(
1205
2052
  envPath,
1206
2053
  `
1207
2054
 
1208
- # GitHub OAuth
1209
- GITHUB_CLIENT_ID=
1210
- GITHUB_CLIENT_SECRET=
2055
+ # twitter OAuth
2056
+ TWITTER_CLIENT_ID=
2057
+ TWITTER_CLIENT_SECRET=
1211
2058
  `
1212
2059
  );
1213
2060
  }
1214
2061
  }
1215
- const componentTemplate = path9.resolve(
2062
+ const componentTemplate = path17.resolve(
1216
2063
  __dirname,
1217
- "./template/components/GithubProviders.tsx"
1218
- );
1219
- const componentsDir = path9.join(
1220
- projectDir,
1221
- folder,
1222
- "components",
1223
- "authverse"
2064
+ "./template/TanstackState/components/twitterOAuthButton.tsx"
1224
2065
  );
1225
- if (!fs9.existsSync(componentsDir)) {
1226
- fs9.mkdirSync(componentsDir, { recursive: true });
2066
+ const componentsDir = path17.join(srcPath, "components", "authverse");
2067
+ if (!fs17.existsSync(componentsDir)) {
2068
+ fs17.mkdirSync(componentsDir, { recursive: true });
1227
2069
  }
1228
- const componentDest = path9.join(componentsDir, "GithubProviders.tsx");
1229
- if (fs9.existsSync(componentTemplate)) {
1230
- fs9.copyFileSync(componentTemplate, componentDest);
2070
+ const componentDest = path17.join(componentsDir, "twitterOAuthButton.tsx");
2071
+ if (fs17.existsSync(componentTemplate)) {
2072
+ fs17.copyFileSync(componentTemplate, componentDest);
1231
2073
  }
1232
- console.log(chalk9.green("GitHub provider added & merged successfully"));
2074
+ console.log(chalk17.green("twitter provider added & merged successfully"));
1233
2075
  } catch (error) {
1234
- console.log(chalk9.red("githubRun error:"), error);
2076
+ console.log(chalk17.red("twitter tanstack state error:"), error);
1235
2077
  }
1236
2078
  };
1237
2079
 
1238
- // oauth/googleTanstackState.ts
1239
- import chalk10 from "chalk";
1240
- import fs10 from "fs";
1241
- import path10 from "path";
1242
- import { fileURLToPath as fileURLToPath9 } from "url";
1243
- var googleTanstackState = async () => {
2080
+ // oauth/AppleNext.ts
2081
+ import chalk18 from "chalk";
2082
+ import fs18 from "fs";
2083
+ import path18 from "path";
2084
+ import { fileURLToPath as fileURLToPath17 } from "url";
2085
+ var AppleNext = async () => {
1244
2086
  try {
1245
- const __filename = fileURLToPath9(import.meta.url);
1246
- const __dirname = path10.dirname(__filename);
2087
+ const __filename = fileURLToPath17(import.meta.url);
2088
+ const __dirname = path18.dirname(__filename);
1247
2089
  const projectDir = process.cwd();
1248
- const srcPath = path10.join(projectDir, "src");
1249
- const authFilePath = path10.join(srcPath, "lib", "auth.ts");
1250
- if (!fs10.existsSync(authFilePath)) {
1251
- console.log(chalk10.red("auth.ts file not found"));
2090
+ const srcPath = path18.join(projectDir, "src");
2091
+ const folder = fs18.existsSync(srcPath) ? "src" : "";
2092
+ const authFilePath = path18.join(projectDir, folder, "lib", "auth.ts");
2093
+ if (!fs18.existsSync(authFilePath)) {
2094
+ console.log(chalk18.red("auth.ts file not found"));
1252
2095
  return;
1253
2096
  }
1254
- let content = fs10.readFileSync(authFilePath, "utf8");
2097
+ let content = fs18.readFileSync(authFilePath, "utf8");
1255
2098
  if (!content.includes("betterAuth({")) {
1256
- console.log(chalk10.red("betterAuth({}) block not found"));
2099
+ console.log(chalk18.red("betterAuth({}) block not found"));
1257
2100
  return;
1258
2101
  }
1259
- if (content.includes("socialProviders") && content.includes("google:")) {
1260
- console.log(chalk10.yellow("Google provider already exists"));
2102
+ if (content.includes("socialProviders") && content.includes("apple:")) {
2103
+ console.log(chalk18.yellow("Apple provider already exists"));
1261
2104
  return;
1262
2105
  }
1263
- const googleProviderEntry = `
1264
- google: {
1265
- clientId: process.env.GOOGLE_CLIENT_ID as string,
1266
- clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
2106
+ const appleProviderEntry = `
2107
+ apple: {
2108
+ clientId: process.env.APPLE_CLIENT_ID as string,
2109
+ clientSecret: process.env.APPLE_CLIENT_SECRET as string,
2110
+ // Important for native iOS: Use the app's bundle ID here, not the service ID
2111
+ appBundleIdentifier: process.env.APPLE_BUNDLE_ID,
1267
2112
  },`;
1268
2113
  if (content.includes("socialProviders: {")) {
1269
2114
  const start = content.indexOf("socialProviders: {");
@@ -1280,15 +2125,15 @@ var googleTanstackState = async () => {
1280
2125
  }
1281
2126
  }
1282
2127
  if (insertPos === -1) {
1283
- console.log(chalk10.red("Failed to parse socialProviders block"));
2128
+ console.log(chalk18.red("Failed to parse socialProviders block"));
1284
2129
  return;
1285
2130
  }
1286
- content = content.slice(0, insertPos) + googleProviderEntry + "\n " + content.slice(insertPos);
2131
+ content = content.slice(0, insertPos) + appleProviderEntry + "\n " + content.slice(insertPos);
1287
2132
  } else {
1288
2133
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1289
2134
  if (!databaseRegex.test(content)) {
1290
2135
  console.log(
1291
- chalk10.red(
2136
+ chalk18.red(
1292
2137
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1293
2138
  )
1294
2139
  );
@@ -1296,7 +2141,7 @@ var googleTanstackState = async () => {
1296
2141
  }
1297
2142
  const socialProvidersBlock = `
1298
2143
  socialProviders: {
1299
- ${googleProviderEntry}
2144
+ ${appleProviderEntry}
1300
2145
  },`;
1301
2146
  content = content.replace(
1302
2147
  databaseRegex,
@@ -1304,69 +2149,91 @@ ${googleProviderEntry}
1304
2149
  ${socialProvidersBlock}`
1305
2150
  );
1306
2151
  }
1307
- fs10.writeFileSync(authFilePath, content, "utf8");
1308
- const envPath = path10.join(projectDir, ".env");
1309
- if (fs10.existsSync(envPath)) {
1310
- const envContent = fs10.readFileSync(envPath, "utf8");
1311
- if (!envContent.includes("GOOGLE_CLIENT_ID")) {
1312
- fs10.appendFileSync(
2152
+ if (content.includes("trustedOrigins: [")) {
2153
+ if (!content.includes("https://appleid.apple.com")) {
2154
+ content = content.replace(
2155
+ "trustedOrigins: [",
2156
+ 'trustedOrigins: ["https://appleid.apple.com", '
2157
+ );
2158
+ }
2159
+ } else {
2160
+ const betterAuthMatch = content.match(/betterAuth\(\{/);
2161
+ if (betterAuthMatch) {
2162
+ const insertPos = betterAuthMatch.index + betterAuthMatch[0].length;
2163
+ content = content.slice(0, insertPos) + '\n trustedOrigins: ["https://appleid.apple.com"],' + content.slice(insertPos);
2164
+ }
2165
+ }
2166
+ fs18.writeFileSync(authFilePath, content, "utf8");
2167
+ const envPath = path18.join(projectDir, ".env");
2168
+ if (fs18.existsSync(envPath)) {
2169
+ const envContent = fs18.readFileSync(envPath, "utf8");
2170
+ if (!envContent.includes("APPLE_CLIENT_ID")) {
2171
+ fs18.appendFileSync(
1313
2172
  envPath,
1314
2173
  `
1315
2174
 
1316
- # Google OAuth
1317
- GOOGLE_CLIENT_ID=
1318
- GOOGLE_CLIENT_SECRET=
2175
+ # Apple OAuth
2176
+ APPLE_CLIENT_ID=
2177
+ APPLE_CLIENT_SECRET=
2178
+ APPLE_BUNDLE_ID=
1319
2179
  `
1320
2180
  );
1321
2181
  }
1322
2182
  }
1323
- const componentTemplate = path10.resolve(
2183
+ const componentTemplate = path18.resolve(
1324
2184
  __dirname,
1325
- "./template/TanstackState/components/GoogleProviders.tsx"
2185
+ "./template/components/AppleOAuthButton.tsx"
1326
2186
  );
1327
- const componentsDir = path10.join(srcPath, "components", "authverse");
1328
- if (!fs10.existsSync(componentsDir)) {
1329
- fs10.mkdirSync(componentsDir, { recursive: true });
2187
+ const componentsDir = path18.join(
2188
+ projectDir,
2189
+ folder,
2190
+ "components",
2191
+ "authverse"
2192
+ );
2193
+ if (!fs18.existsSync(componentsDir)) {
2194
+ fs18.mkdirSync(componentsDir, { recursive: true });
1330
2195
  }
1331
- const componentDest = path10.join(componentsDir, "GoogleProviders.tsx");
1332
- if (fs10.existsSync(componentTemplate)) {
1333
- fs10.copyFileSync(componentTemplate, componentDest);
2196
+ const componentDest = path18.join(componentsDir, "AppleOAuthButton.tsx");
2197
+ if (fs18.existsSync(componentTemplate)) {
2198
+ fs18.copyFileSync(componentTemplate, componentDest);
1334
2199
  }
1335
- console.log(chalk10.green("Google provider added & merged successfully"));
2200
+ console.log(chalk18.green("Apple provider added & merged successfully"));
1336
2201
  } catch (error) {
1337
- console.log(chalk10.red("googleRunTanstackState error:"), error);
2202
+ console.log(chalk18.red("apple next error:"), error);
1338
2203
  }
1339
2204
  };
1340
2205
 
1341
- // oauth/githubTanstackState.ts
1342
- import chalk11 from "chalk";
1343
- import fs11 from "fs";
1344
- import path11 from "path";
1345
- import { fileURLToPath as fileURLToPath10 } from "url";
1346
- var githubTanstackState = async () => {
2206
+ // oauth/AppleTanstackState.ts
2207
+ import chalk19 from "chalk";
2208
+ import fs19 from "fs";
2209
+ import path19 from "path";
2210
+ import { fileURLToPath as fileURLToPath18 } from "url";
2211
+ var AppleTanstackState = async () => {
1347
2212
  try {
1348
- const __filename = fileURLToPath10(import.meta.url);
1349
- const __dirname = path11.dirname(__filename);
2213
+ const __filename = fileURLToPath18(import.meta.url);
2214
+ const __dirname = path19.dirname(__filename);
1350
2215
  const projectDir = process.cwd();
1351
- const srcPath = path11.join(projectDir, "src");
1352
- const authFilePath = path11.join(srcPath, "lib", "auth.ts");
1353
- if (!fs11.existsSync(authFilePath)) {
1354
- console.log(chalk11.red("auth.ts file not found"));
2216
+ const srcPath = path19.join(projectDir, "src");
2217
+ const authFilePath = path19.join(srcPath, "lib", "auth.ts");
2218
+ if (!fs19.existsSync(authFilePath)) {
2219
+ console.log(chalk19.red("auth.ts file not found"));
1355
2220
  return;
1356
2221
  }
1357
- let content = fs11.readFileSync(authFilePath, "utf8");
2222
+ let content = fs19.readFileSync(authFilePath, "utf8");
1358
2223
  if (!content.includes("betterAuth({")) {
1359
- console.log(chalk11.red("betterAuth({}) block not found"));
2224
+ console.log(chalk19.red("betterAuth({}) block not found"));
1360
2225
  return;
1361
2226
  }
1362
- if (content.includes("socialProviders") && content.includes("github:")) {
1363
- console.log(chalk11.yellow("Github provider already exists"));
2227
+ if (content.includes("socialProviders") && content.includes("apple:")) {
2228
+ console.log(chalk19.yellow("Apple provider already exists"));
1364
2229
  return;
1365
2230
  }
1366
- const githubProviderEntry = `
1367
- github: {
1368
- clientId: process.env.GITHUB_CLIENT_ID as string,
1369
- clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
2231
+ const appleProviderEntry = `
2232
+ apple: {
2233
+ clientId: process.env.APPLE_CLIENT_ID as string,
2234
+ clientSecret: process.env.APPLE_CLIENT_SECRET as string,
2235
+ // Important for native iOS: Use the app's bundle ID here, not the service ID
2236
+ appBundleIdentifier: process.env.APPLE_BUNDLE_ID,
1370
2237
  },`;
1371
2238
  if (content.includes("socialProviders: {")) {
1372
2239
  const start = content.indexOf("socialProviders: {");
@@ -1383,15 +2250,15 @@ var githubTanstackState = async () => {
1383
2250
  }
1384
2251
  }
1385
2252
  if (insertPos === -1) {
1386
- console.log(chalk11.red("Failed to parse socialProviders block"));
2253
+ console.log(chalk19.red("Failed to parse socialProviders block"));
1387
2254
  return;
1388
2255
  }
1389
- content = content.slice(0, insertPos) + githubProviderEntry + "\n " + content.slice(insertPos);
2256
+ content = content.slice(0, insertPos) + appleProviderEntry + "\n " + content.slice(insertPos);
1390
2257
  } else {
1391
2258
  const databaseRegex = /database:\s*(prismaAdapter|drizzleAdapter)\([\s\S]*?\),/;
1392
2259
  if (!databaseRegex.test(content)) {
1393
2260
  console.log(
1394
- chalk11.red(
2261
+ chalk19.red(
1395
2262
  "Could not find database adapter (prismaAdapter or drizzleAdapter)"
1396
2263
  )
1397
2264
  );
@@ -1399,7 +2266,7 @@ var githubTanstackState = async () => {
1399
2266
  }
1400
2267
  const socialProvidersBlock = `
1401
2268
  socialProviders: {
1402
- ${githubProviderEntry}
2269
+ ${appleProviderEntry}
1403
2270
  },`;
1404
2271
  content = content.replace(
1405
2272
  databaseRegex,
@@ -1407,37 +2274,52 @@ ${githubProviderEntry}
1407
2274
  ${socialProvidersBlock}`
1408
2275
  );
1409
2276
  }
1410
- fs11.writeFileSync(authFilePath, content, "utf8");
1411
- const envPath = path11.join(projectDir, ".env");
1412
- if (fs11.existsSync(envPath)) {
1413
- const envContent = fs11.readFileSync(envPath, "utf8");
1414
- if (!envContent.includes("GITHUB_CLIENT_ID")) {
1415
- fs11.appendFileSync(
2277
+ if (content.includes("trustedOrigins: [")) {
2278
+ if (!content.includes("https://appleid.apple.com")) {
2279
+ content = content.replace(
2280
+ "trustedOrigins: [",
2281
+ 'trustedOrigins: ["https://appleid.apple.com", '
2282
+ );
2283
+ }
2284
+ } else {
2285
+ const betterAuthMatch = content.match(/betterAuth\(\{/);
2286
+ if (betterAuthMatch) {
2287
+ const insertPos = betterAuthMatch.index + betterAuthMatch[0].length;
2288
+ content = content.slice(0, insertPos) + '\n trustedOrigins: ["https://appleid.apple.com"],' + content.slice(insertPos);
2289
+ }
2290
+ }
2291
+ fs19.writeFileSync(authFilePath, content, "utf8");
2292
+ const envPath = path19.join(projectDir, ".env");
2293
+ if (fs19.existsSync(envPath)) {
2294
+ const envContent = fs19.readFileSync(envPath, "utf8");
2295
+ if (!envContent.includes("APPLE_CLIENT_ID")) {
2296
+ fs19.appendFileSync(
1416
2297
  envPath,
1417
2298
  `
1418
2299
 
1419
- # Github OAuth
1420
- GITHUB_CLIENT_ID=
1421
- GITHUB_CLIENT_SECRET=
2300
+ # Apple OAuth
2301
+ APPLE_CLIENT_ID=
2302
+ APPLE_CLIENT_SECRET=
2303
+ APPLE_BUNDLE_ID=
1422
2304
  `
1423
2305
  );
1424
2306
  }
1425
2307
  }
1426
- const componentTemplate = path11.resolve(
2308
+ const componentTemplate = path19.resolve(
1427
2309
  __dirname,
1428
- "./template/TanstackState/components/GithubProviders.tsx"
2310
+ "./template/TanstackState/components/AppleOAuthButton.tsx"
1429
2311
  );
1430
- const componentsDir = path11.join(srcPath, "components", "authverse");
1431
- if (!fs11.existsSync(componentsDir)) {
1432
- fs11.mkdirSync(componentsDir, { recursive: true });
2312
+ const componentsDir = path19.join(srcPath, "components", "authverse");
2313
+ if (!fs19.existsSync(componentsDir)) {
2314
+ fs19.mkdirSync(componentsDir, { recursive: true });
1433
2315
  }
1434
- const componentDest = path11.join(componentsDir, "GithubProviders.tsx");
1435
- if (fs11.existsSync(componentTemplate)) {
1436
- fs11.copyFileSync(componentTemplate, componentDest);
2316
+ const componentDest = path19.join(componentsDir, "AppleOAuthButton.tsx");
2317
+ if (fs19.existsSync(componentTemplate)) {
2318
+ fs19.copyFileSync(componentTemplate, componentDest);
1437
2319
  }
1438
- console.log(chalk11.green("Github provider added & merged successfully"));
2320
+ console.log(chalk19.green("Apple provider added & merged successfully"));
1439
2321
  } catch (error) {
1440
- console.log(chalk11.red("githubRunTanstackState error:"), error);
2322
+ console.log(chalk19.red("apple tanstack state error:"), error);
1441
2323
  }
1442
2324
  };
1443
2325
 
@@ -1446,7 +2328,7 @@ var Oauth = async ({ oauth }) => {
1446
2328
  try {
1447
2329
  const { framework, error } = await getFramework();
1448
2330
  if (error) {
1449
- console.log(chalk12.red(error));
2331
+ console.log(chalk20.red(error));
1450
2332
  return;
1451
2333
  }
1452
2334
  if (framework === "Next js" && oauth == "google") {
@@ -1459,358 +2341,378 @@ var Oauth = async ({ oauth }) => {
1459
2341
  } else if (framework === "tanstack state" && oauth == "github") {
1460
2342
  await githubTanstackState();
1461
2343
  }
1462
- if (oauth !== "google" && oauth !== "github") {
1463
- console.log(chalk12.red("Invalid oauth provider"));
2344
+ if (framework === "Next js" && oauth == "facebook") {
2345
+ await facebookNext();
2346
+ } else if (framework === "tanstack state" && oauth == "facebook") {
2347
+ await facebookTanstackState();
2348
+ }
2349
+ if (framework === "Next js" && oauth === "LinkedIn") {
2350
+ await LinkedInNext();
2351
+ } else if (framework === "tanstack state" && oauth === "LinkedIn") {
2352
+ await LinkedInTanstackState();
2353
+ }
2354
+ if (framework === "Next js" && oauth === "twitter") {
2355
+ await twitterNext();
2356
+ } else if (framework === "tanstack state" && oauth === "twitter") {
2357
+ await twitterTanstackState();
2358
+ }
2359
+ if (framework === "Next js" && oauth === "apple") {
2360
+ await AppleNext();
2361
+ } else if (framework === "tanstack state" && oauth === "apple") {
2362
+ await AppleTanstackState();
2363
+ }
2364
+ if (oauth !== "google" && oauth !== "github" && oauth !== "facebook" && oauth !== "LinkedIn" && oauth !== "twitter" && oauth !== "apple") {
2365
+ console.log(chalk20.red("Invalid oauth provider"));
1464
2366
  return;
1465
2367
  }
1466
2368
  } catch (error) {
1467
- console.log(chalk12.red("Error adding oauth:"), error);
2369
+ console.log(chalk20.red("Error adding oauth:"), error);
1468
2370
  }
1469
2371
  };
1470
2372
 
1471
2373
  // script/forgetNext.ts
1472
- import chalk20 from "chalk";
1473
- import path19 from "path";
1474
- import { fileURLToPath as fileURLToPath17 } from "url";
1475
- import fs19 from "fs";
2374
+ import chalk28 from "chalk";
2375
+ import path27 from "path";
2376
+ import { fileURLToPath as fileURLToPath25 } from "url";
2377
+ import fs27 from "fs";
1476
2378
 
1477
2379
  // cli/email.ts
1478
- import path18 from "path";
1479
- import fs18 from "fs";
2380
+ import path26 from "path";
2381
+ import fs26 from "fs";
1480
2382
  import inquirer4 from "inquirer";
1481
2383
 
1482
2384
  // email/gmailRun.ts
1483
- import chalk13 from "chalk";
1484
- import path12 from "path";
1485
- import fs12 from "fs";
1486
- import { fileURLToPath as fileURLToPath11 } from "url";
2385
+ import chalk21 from "chalk";
2386
+ import path20 from "path";
2387
+ import fs20 from "fs";
2388
+ import { fileURLToPath as fileURLToPath19 } from "url";
1487
2389
  var gmailRun = async () => {
1488
2390
  try {
1489
2391
  const projectDir = process.cwd();
1490
- const packageJsonPath = path12.join(projectDir, "package.json");
1491
- const packageJson2 = JSON.parse(fs12.readFileSync(packageJsonPath, "utf-8"));
1492
- const srcFolder = fs12.existsSync(path12.join(projectDir, "src")) ? "src" : "";
1493
- const __filename = fileURLToPath11(import.meta.url);
1494
- const __dirname = path12.dirname(__filename);
2392
+ const packageJsonPath = path20.join(projectDir, "package.json");
2393
+ const packageJson2 = JSON.parse(fs20.readFileSync(packageJsonPath, "utf-8"));
2394
+ const srcFolder = fs20.existsSync(path20.join(projectDir, "src")) ? "src" : "";
2395
+ const __filename = fileURLToPath19(import.meta.url);
2396
+ const __dirname = path20.dirname(__filename);
1495
2397
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1496
- console.log(chalk13.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
2398
+ console.log(chalk21.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1497
2399
  packageManager("nodemailer");
1498
2400
  packageManager("@types/nodemailer", true);
1499
2401
  }
1500
2402
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1501
- console.log(chalk13.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2403
+ console.log(chalk21.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1502
2404
  packageManager("@react-email/components");
1503
2405
  }
1504
- const envPath = path12.join(projectDir, ".env");
1505
- const envContent = fs12.readFileSync(envPath, "utf8");
2406
+ const envPath = path20.join(projectDir, ".env");
2407
+ const envContent = fs20.readFileSync(envPath, "utf8");
1506
2408
  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")) {
1507
- fs12.appendFileSync(envPath, `
2409
+ fs20.appendFileSync(envPath, `
1508
2410
 
1509
2411
  # Gmail API Key for sending emails`);
1510
- fs12.appendFileSync(envPath, `
2412
+ fs20.appendFileSync(envPath, `
1511
2413
  GMAIL_HOST=`);
1512
- fs12.appendFileSync(envPath, `
2414
+ fs20.appendFileSync(envPath, `
1513
2415
  GMAIL_PORT=`);
1514
- fs12.appendFileSync(envPath, `
2416
+ fs20.appendFileSync(envPath, `
1515
2417
  GMAIL_SERVICE=`);
1516
- fs12.appendFileSync(envPath, `
2418
+ fs20.appendFileSync(envPath, `
1517
2419
  GMAIL_MAIL=`);
1518
- fs12.appendFileSync(envPath, `
2420
+ fs20.appendFileSync(envPath, `
1519
2421
  GMAIL_NAME=`);
1520
- fs12.appendFileSync(envPath, `
2422
+ fs20.appendFileSync(envPath, `
1521
2423
  GMAIL_PASSWORD=`);
1522
2424
  }
1523
- const templatePath = path12.resolve(
2425
+ const templatePath = path20.resolve(
1524
2426
  __dirname,
1525
2427
  "./template/email/emailGmail.ts"
1526
2428
  );
1527
- const libPath = path12.join(projectDir, srcFolder, "lib");
1528
- if (!fs12.existsSync(libPath)) {
1529
- fs12.mkdirSync(libPath, { recursive: true });
2429
+ const libPath = path20.join(projectDir, srcFolder, "lib");
2430
+ if (!fs20.existsSync(libPath)) {
2431
+ fs20.mkdirSync(libPath, { recursive: true });
1530
2432
  }
1531
- const libDestinationPath = path12.join(libPath, "email.ts");
1532
- fs12.copyFileSync(templatePath, libDestinationPath);
2433
+ const libDestinationPath = path20.join(libPath, "email.ts");
2434
+ fs20.copyFileSync(templatePath, libDestinationPath);
1533
2435
  } catch (error) {
1534
- console.log(chalk13.red(error));
2436
+ console.log(chalk21.red(error));
1535
2437
  }
1536
2438
  };
1537
2439
 
1538
2440
  // email/gmailRunTanstackState.ts
1539
- import chalk14 from "chalk";
1540
- import path13 from "path";
1541
- import fs13 from "fs";
1542
- import { fileURLToPath as fileURLToPath12 } from "url";
2441
+ import chalk22 from "chalk";
2442
+ import path21 from "path";
2443
+ import fs21 from "fs";
2444
+ import { fileURLToPath as fileURLToPath20 } from "url";
1543
2445
  var gmailRunTanstackState = async () => {
1544
2446
  try {
1545
2447
  const projectDir = process.cwd();
1546
- const packageJsonPath = path13.join(projectDir, "package.json");
1547
- const packageJson2 = JSON.parse(fs13.readFileSync(packageJsonPath, "utf-8"));
1548
- const __filename = fileURLToPath12(import.meta.url);
1549
- const __dirname = path13.dirname(__filename);
2448
+ const packageJsonPath = path21.join(projectDir, "package.json");
2449
+ const packageJson2 = JSON.parse(fs21.readFileSync(packageJsonPath, "utf-8"));
2450
+ const __filename = fileURLToPath20(import.meta.url);
2451
+ const __dirname = path21.dirname(__filename);
1550
2452
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1551
- console.log(chalk14.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
2453
+ console.log(chalk22.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1552
2454
  packageManager("nodemailer");
1553
2455
  packageManager("@types/nodemailer", true);
1554
2456
  }
1555
2457
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1556
- console.log(chalk14.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2458
+ console.log(chalk22.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1557
2459
  packageManager("@react-email/components");
1558
2460
  }
1559
- const envPath = path13.join(projectDir, ".env");
1560
- const envContent = fs13.readFileSync(envPath, "utf8");
2461
+ const envPath = path21.join(projectDir, ".env");
2462
+ const envContent = fs21.readFileSync(envPath, "utf8");
1561
2463
  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")) {
1562
- fs13.appendFileSync(envPath, `
2464
+ fs21.appendFileSync(envPath, `
1563
2465
 
1564
2466
  # Gmail API Key for sending emails`);
1565
- fs13.appendFileSync(envPath, `
2467
+ fs21.appendFileSync(envPath, `
1566
2468
  GMAIL_HOST=`);
1567
- fs13.appendFileSync(envPath, `
2469
+ fs21.appendFileSync(envPath, `
1568
2470
  GMAIL_PORT=`);
1569
- fs13.appendFileSync(envPath, `
2471
+ fs21.appendFileSync(envPath, `
1570
2472
  GMAIL_SERVICE=`);
1571
- fs13.appendFileSync(envPath, `
2473
+ fs21.appendFileSync(envPath, `
1572
2474
  GMAIL_MAIL=`);
1573
- fs13.appendFileSync(envPath, `
2475
+ fs21.appendFileSync(envPath, `
1574
2476
  GMAIL_NAME=`);
1575
- fs13.appendFileSync(envPath, `
2477
+ fs21.appendFileSync(envPath, `
1576
2478
  GMAIL_PASSWORD=`);
1577
2479
  }
1578
- const templatePath = path13.resolve(
2480
+ const templatePath = path21.resolve(
1579
2481
  __dirname,
1580
2482
  "./template/email/emailGmail.ts"
1581
2483
  );
1582
- const libPath = path13.join(projectDir, "src", "lib");
1583
- if (!fs13.existsSync(libPath)) {
1584
- fs13.mkdirSync(libPath, { recursive: true });
2484
+ const libPath = path21.join(projectDir, "src", "lib");
2485
+ if (!fs21.existsSync(libPath)) {
2486
+ fs21.mkdirSync(libPath, { recursive: true });
1585
2487
  }
1586
- const libDestinationPath = path13.join(libPath, "email.ts");
1587
- fs13.copyFileSync(templatePath, libDestinationPath);
2488
+ const libDestinationPath = path21.join(libPath, "email.ts");
2489
+ fs21.copyFileSync(templatePath, libDestinationPath);
1588
2490
  } catch (error) {
1589
- console.log(chalk14.red(error));
2491
+ console.log(chalk22.red(error));
1590
2492
  }
1591
2493
  };
1592
2494
 
1593
2495
  // email/awsSesRun.ts
1594
- import chalk15 from "chalk";
1595
- import path14 from "path";
1596
- import fs14 from "fs";
1597
- import { fileURLToPath as fileURLToPath13 } from "url";
2496
+ import chalk23 from "chalk";
2497
+ import path22 from "path";
2498
+ import fs22 from "fs";
2499
+ import { fileURLToPath as fileURLToPath21 } from "url";
1598
2500
  var awsSesRun = async () => {
1599
2501
  try {
1600
2502
  const projectDir = process.cwd();
1601
- const packageJsonPath = path14.join(projectDir, "package.json");
1602
- const packageJson2 = JSON.parse(fs14.readFileSync(packageJsonPath, "utf-8"));
1603
- const srcFolder = fs14.existsSync(path14.join(projectDir, "src")) ? "src" : "";
1604
- const __filename = fileURLToPath13(import.meta.url);
1605
- const __dirname = path14.dirname(__filename);
2503
+ const packageJsonPath = path22.join(projectDir, "package.json");
2504
+ const packageJson2 = JSON.parse(fs22.readFileSync(packageJsonPath, "utf-8"));
2505
+ const srcFolder = fs22.existsSync(path22.join(projectDir, "src")) ? "src" : "";
2506
+ const __filename = fileURLToPath21(import.meta.url);
2507
+ const __dirname = path22.dirname(__filename);
1606
2508
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1607
- console.log(chalk15.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
2509
+ console.log(chalk23.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1608
2510
  packageManager("nodemailer");
1609
2511
  packageManager("@types/nodemailer", true);
1610
2512
  }
1611
2513
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1612
- console.log(chalk15.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2514
+ console.log(chalk23.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1613
2515
  packageManager("@react-email/components");
1614
2516
  }
1615
- const envPath = path14.join(projectDir, ".env");
1616
- const envContent = fs14.readFileSync(envPath, "utf8");
2517
+ const envPath = path22.join(projectDir, ".env");
2518
+ const envContent = fs22.readFileSync(envPath, "utf8");
1617
2519
  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")) {
1618
- fs14.appendFileSync(envPath, `
2520
+ fs22.appendFileSync(envPath, `
1619
2521
 
1620
2522
  # AWS SES API Key for sending emails`);
1621
- fs14.appendFileSync(envPath, `
2523
+ fs22.appendFileSync(envPath, `
1622
2524
  AWS_SES_HOST=`);
1623
- fs14.appendFileSync(envPath, `
2525
+ fs22.appendFileSync(envPath, `
1624
2526
  AWS_SES_PORT=`);
1625
- fs14.appendFileSync(envPath, `
2527
+ fs22.appendFileSync(envPath, `
1626
2528
  AWS_SES_SERVICE=`);
1627
- fs14.appendFileSync(envPath, `
2529
+ fs22.appendFileSync(envPath, `
1628
2530
  AWS_SES_USER=`);
1629
- fs14.appendFileSync(envPath, `
2531
+ fs22.appendFileSync(envPath, `
1630
2532
  AWS_SES_PASS=`);
1631
- fs14.appendFileSync(envPath, `
2533
+ fs22.appendFileSync(envPath, `
1632
2534
  AWS_SES_FROM=`);
1633
2535
  }
1634
- const templatePath = path14.resolve(
2536
+ const templatePath = path22.resolve(
1635
2537
  __dirname,
1636
2538
  "./template/email/emailAwsSes.ts"
1637
2539
  );
1638
- const libPath = path14.join(projectDir, srcFolder, "lib");
1639
- if (!fs14.existsSync(libPath)) {
1640
- fs14.mkdirSync(libPath, { recursive: true });
2540
+ const libPath = path22.join(projectDir, srcFolder, "lib");
2541
+ if (!fs22.existsSync(libPath)) {
2542
+ fs22.mkdirSync(libPath, { recursive: true });
1641
2543
  }
1642
- const libDestinationPath = path14.join(libPath, "email.ts");
1643
- fs14.copyFileSync(templatePath, libDestinationPath);
2544
+ const libDestinationPath = path22.join(libPath, "email.ts");
2545
+ fs22.copyFileSync(templatePath, libDestinationPath);
1644
2546
  } catch (error) {
1645
- console.log(chalk15.red(error));
2547
+ console.log(chalk23.red(error));
1646
2548
  }
1647
2549
  };
1648
2550
 
1649
2551
  // email/awsSesRunTanstackState.ts
1650
- import chalk16 from "chalk";
1651
- import path15 from "path";
1652
- import fs15 from "fs";
1653
- import { fileURLToPath as fileURLToPath14 } from "url";
2552
+ import chalk24 from "chalk";
2553
+ import path23 from "path";
2554
+ import fs23 from "fs";
2555
+ import { fileURLToPath as fileURLToPath22 } from "url";
1654
2556
  var awsSesRunTanstackState = async () => {
1655
2557
  try {
1656
2558
  const projectDir = process.cwd();
1657
- const packageJsonPath = path15.join(projectDir, "package.json");
1658
- const packageJson2 = JSON.parse(fs15.readFileSync(packageJsonPath, "utf-8"));
1659
- const __filename = fileURLToPath14(import.meta.url);
1660
- const __dirname = path15.dirname(__filename);
2559
+ const packageJsonPath = path23.join(projectDir, "package.json");
2560
+ const packageJson2 = JSON.parse(fs23.readFileSync(packageJsonPath, "utf-8"));
2561
+ const __filename = fileURLToPath22(import.meta.url);
2562
+ const __dirname = path23.dirname(__filename);
1661
2563
  if (!packageJson2.dependencies?.nodemailer || !packageJson2.devDependencies?.["@types/nodemailer"]) {
1662
- console.log(chalk16.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
2564
+ console.log(chalk24.cyan("\n\u2699\uFE0F Installing nodemailer...\n"));
1663
2565
  packageManager("nodemailer");
1664
2566
  packageManager("@types/nodemailer", true);
1665
2567
  }
1666
2568
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1667
- console.log(chalk16.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2569
+ console.log(chalk24.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1668
2570
  packageManager("@react-email/components");
1669
2571
  }
1670
- const envPath = path15.join(projectDir, ".env");
1671
- const envContent = fs15.readFileSync(envPath, "utf8");
2572
+ const envPath = path23.join(projectDir, ".env");
2573
+ const envContent = fs23.readFileSync(envPath, "utf8");
1672
2574
  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")) {
1673
- fs15.appendFileSync(envPath, `
2575
+ fs23.appendFileSync(envPath, `
1674
2576
 
1675
2577
  # AWS SES API Key for sending emails`);
1676
- fs15.appendFileSync(envPath, `
2578
+ fs23.appendFileSync(envPath, `
1677
2579
  AWS_SES_HOST=`);
1678
- fs15.appendFileSync(envPath, `
2580
+ fs23.appendFileSync(envPath, `
1679
2581
  AWS_SES_PORT=`);
1680
- fs15.appendFileSync(envPath, `
2582
+ fs23.appendFileSync(envPath, `
1681
2583
  AWS_SES_SERVICE=`);
1682
- fs15.appendFileSync(envPath, `
2584
+ fs23.appendFileSync(envPath, `
1683
2585
  AWS_SES_USER=`);
1684
- fs15.appendFileSync(envPath, `
2586
+ fs23.appendFileSync(envPath, `
1685
2587
  AWS_SES_PASS=`);
1686
- fs15.appendFileSync(envPath, `
2588
+ fs23.appendFileSync(envPath, `
1687
2589
  AWS_SES_FROM=`);
1688
2590
  }
1689
- const templatePath = path15.resolve(
2591
+ const templatePath = path23.resolve(
1690
2592
  __dirname,
1691
2593
  "./template/email/emailAwsSes.ts"
1692
2594
  );
1693
- const libPath = path15.join(projectDir, "src", "lib");
1694
- if (!fs15.existsSync(libPath)) {
1695
- fs15.mkdirSync(libPath, { recursive: true });
2595
+ const libPath = path23.join(projectDir, "src", "lib");
2596
+ if (!fs23.existsSync(libPath)) {
2597
+ fs23.mkdirSync(libPath, { recursive: true });
1696
2598
  }
1697
- const libDestinationPath = path15.join(libPath, "email.ts");
1698
- fs15.copyFileSync(templatePath, libDestinationPath);
2599
+ const libDestinationPath = path23.join(libPath, "email.ts");
2600
+ fs23.copyFileSync(templatePath, libDestinationPath);
1699
2601
  } catch (error) {
1700
- console.log(chalk16.red(error));
2602
+ console.log(chalk24.red(error));
1701
2603
  }
1702
2604
  };
1703
2605
 
1704
2606
  // email/resendRun.ts
1705
- import chalk17 from "chalk";
1706
- import path16 from "path";
1707
- import fs16 from "fs";
1708
- import { fileURLToPath as fileURLToPath15 } from "url";
2607
+ import chalk25 from "chalk";
2608
+ import path24 from "path";
2609
+ import fs24 from "fs";
2610
+ import { fileURLToPath as fileURLToPath23 } from "url";
1709
2611
  var resendRun = async () => {
1710
2612
  try {
1711
2613
  const projectDir = process.cwd();
1712
- const packageJsonPath = path16.join(projectDir, "package.json");
1713
- const packageJson2 = JSON.parse(fs16.readFileSync(packageJsonPath, "utf-8"));
1714
- const srcFolder = fs16.existsSync(path16.join(projectDir, "src")) ? "src" : "";
1715
- const __filename = fileURLToPath15(import.meta.url);
1716
- const __dirname = path16.dirname(__filename);
2614
+ const packageJsonPath = path24.join(projectDir, "package.json");
2615
+ const packageJson2 = JSON.parse(fs24.readFileSync(packageJsonPath, "utf-8"));
2616
+ const srcFolder = fs24.existsSync(path24.join(projectDir, "src")) ? "src" : "";
2617
+ const __filename = fileURLToPath23(import.meta.url);
2618
+ const __dirname = path24.dirname(__filename);
1717
2619
  if (!packageJson2.dependencies?.resend) {
1718
- console.log(chalk17.cyan("\n\u2699\uFE0F Installing Resend...\n"));
2620
+ console.log(chalk25.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1719
2621
  packageManager("resend");
1720
2622
  }
1721
2623
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1722
- console.log(chalk17.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2624
+ console.log(chalk25.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1723
2625
  packageManager("@react-email/components");
1724
2626
  }
1725
- const envPath = path16.join(projectDir, ".env");
1726
- const envContent = fs16.readFileSync(envPath, "utf8");
2627
+ const envPath = path24.join(projectDir, ".env");
2628
+ const envContent = fs24.readFileSync(envPath, "utf8");
1727
2629
  if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1728
- fs16.appendFileSync(envPath, `
2630
+ fs24.appendFileSync(envPath, `
1729
2631
 
1730
2632
  # Resend API Key for sending emails`);
1731
- fs16.appendFileSync(envPath, `
2633
+ fs24.appendFileSync(envPath, `
1732
2634
  RESEND_API_KEY=`);
1733
- fs16.appendFileSync(envPath, `
2635
+ fs24.appendFileSync(envPath, `
1734
2636
  EMAIL_SENDER_NAME=Your Name`);
1735
- fs16.appendFileSync(envPath, `
2637
+ fs24.appendFileSync(envPath, `
1736
2638
  EMAIL_SENDER_ADDRESS=`);
1737
2639
  }
1738
- const templatePath = path16.resolve(
2640
+ const templatePath = path24.resolve(
1739
2641
  __dirname,
1740
2642
  "./template/email/emailResend.ts"
1741
2643
  );
1742
- const libPath = path16.join(projectDir, srcFolder, "lib");
1743
- if (!fs16.existsSync(libPath)) {
1744
- fs16.mkdirSync(libPath, { recursive: true });
2644
+ const libPath = path24.join(projectDir, srcFolder, "lib");
2645
+ if (!fs24.existsSync(libPath)) {
2646
+ fs24.mkdirSync(libPath, { recursive: true });
1745
2647
  }
1746
- const libDestinationPath = path16.join(libPath, "email.ts");
1747
- fs16.copyFileSync(templatePath, libDestinationPath);
2648
+ const libDestinationPath = path24.join(libPath, "email.ts");
2649
+ fs24.copyFileSync(templatePath, libDestinationPath);
1748
2650
  } catch (error) {
1749
- console.log(chalk17.red(error));
2651
+ console.log(chalk25.red(error));
1750
2652
  }
1751
2653
  };
1752
2654
 
1753
2655
  // email/resendRunTanstackState.ts
1754
- import chalk18 from "chalk";
1755
- import path17 from "path";
1756
- import fs17 from "fs";
1757
- import { fileURLToPath as fileURLToPath16 } from "url";
2656
+ import chalk26 from "chalk";
2657
+ import path25 from "path";
2658
+ import fs25 from "fs";
2659
+ import { fileURLToPath as fileURLToPath24 } from "url";
1758
2660
  var resendRunTanstackState = async () => {
1759
2661
  try {
1760
2662
  const projectDir = process.cwd();
1761
- const packageJsonPath = path17.join(projectDir, "package.json");
1762
- const packageJson2 = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
1763
- const __filename = fileURLToPath16(import.meta.url);
1764
- const __dirname = path17.dirname(__filename);
2663
+ const packageJsonPath = path25.join(projectDir, "package.json");
2664
+ const packageJson2 = JSON.parse(fs25.readFileSync(packageJsonPath, "utf-8"));
2665
+ const __filename = fileURLToPath24(import.meta.url);
2666
+ const __dirname = path25.dirname(__filename);
1765
2667
  if (!packageJson2.dependencies?.resend) {
1766
- console.log(chalk18.cyan("\n\u2699\uFE0F Installing Resend...\n"));
2668
+ console.log(chalk26.cyan("\n\u2699\uFE0F Installing Resend...\n"));
1767
2669
  packageManager("resend");
1768
2670
  }
1769
2671
  if (!packageJson2.dependencies?.["@react-email/components"]) {
1770
- console.log(chalk18.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
2672
+ console.log(chalk26.cyan("\n\u2699\uFE0F Installing @react-email/components...\n"));
1771
2673
  packageManager("@react-email/components");
1772
2674
  }
1773
- const envPath = path17.join(projectDir, ".env");
1774
- const envContent = fs17.readFileSync(envPath, "utf8");
2675
+ const envPath = path25.join(projectDir, ".env");
2676
+ const envContent = fs25.readFileSync(envPath, "utf8");
1775
2677
  if (!envContent.includes("RESEND_API_KEY") && !envContent.includes("EMAIL_SENDER_NAME") && !envContent.includes("EMAIL_SENDER_ADDRESS")) {
1776
- fs17.appendFileSync(envPath, `
2678
+ fs25.appendFileSync(envPath, `
1777
2679
 
1778
2680
  # Resend API Key for sending emails`);
1779
- fs17.appendFileSync(envPath, `
2681
+ fs25.appendFileSync(envPath, `
1780
2682
  RESEND_API_KEY=`);
1781
- fs17.appendFileSync(envPath, `
2683
+ fs25.appendFileSync(envPath, `
1782
2684
  EMAIL_SENDER_NAME=Your Name`);
1783
- fs17.appendFileSync(envPath, `
2685
+ fs25.appendFileSync(envPath, `
1784
2686
  EMAIL_SENDER_ADDRESS=`);
1785
2687
  }
1786
- const templatePath = path17.resolve(
2688
+ const templatePath = path25.resolve(
1787
2689
  __dirname,
1788
2690
  "./template/email/emailResend.ts"
1789
2691
  );
1790
- const libPath = path17.join(projectDir, "src", "lib");
1791
- if (!fs17.existsSync(libPath)) {
1792
- fs17.mkdirSync(libPath, { recursive: true });
2692
+ const libPath = path25.join(projectDir, "src", "lib");
2693
+ if (!fs25.existsSync(libPath)) {
2694
+ fs25.mkdirSync(libPath, { recursive: true });
1793
2695
  }
1794
- const libDestinationPath = path17.join(libPath, "email.ts");
1795
- fs17.copyFileSync(templatePath, libDestinationPath);
2696
+ const libDestinationPath = path25.join(libPath, "email.ts");
2697
+ fs25.copyFileSync(templatePath, libDestinationPath);
1796
2698
  } catch (error) {
1797
- console.log(chalk18.red(error));
2699
+ console.log(chalk26.red(error));
1798
2700
  }
1799
2701
  };
1800
2702
 
1801
2703
  // cli/email.ts
1802
- import chalk19 from "chalk";
2704
+ import chalk27 from "chalk";
1803
2705
  var email = async () => {
1804
2706
  const projectDir = process.cwd();
1805
2707
  const { framework, error } = await getFramework();
1806
2708
  if (error) {
1807
- console.log(chalk19.red(error));
2709
+ console.log(chalk27.red(error));
1808
2710
  return;
1809
2711
  }
1810
2712
  if (framework === "Next js") {
1811
- const srcFolder = fs18.existsSync(path18.join(projectDir, "src")) ? "src" : "";
1812
- const emailPath = path18.join(projectDir, srcFolder, "lib", "email.ts");
1813
- if (fs18.existsSync(emailPath)) {
2713
+ const srcFolder = fs26.existsSync(path26.join(projectDir, "src")) ? "src" : "";
2714
+ const emailPath = path26.join(projectDir, srcFolder, "lib", "email.ts");
2715
+ if (fs26.existsSync(emailPath)) {
1814
2716
  const answers2 = await inquirer4.prompt([
1815
2717
  {
1816
2718
  type: "confirm",
@@ -1825,12 +2727,12 @@ var email = async () => {
1825
2727
  }
1826
2728
  }
1827
2729
  if (framework === "tanstack state") {
1828
- const srcFolderTanstackState = path18.join(projectDir, "src");
1829
- const libPathTanstackState = path18.join(
2730
+ const srcFolderTanstackState = path26.join(projectDir, "src");
2731
+ const libPathTanstackState = path26.join(
1830
2732
  srcFolderTanstackState,
1831
2733
  "lib/email.ts"
1832
2734
  );
1833
- if (fs18.existsSync(libPathTanstackState)) {
2735
+ if (fs26.existsSync(libPathTanstackState)) {
1834
2736
  const answers2 = await inquirer4.prompt([
1835
2737
  {
1836
2738
  type: "confirm",
@@ -1876,20 +2778,20 @@ var email = async () => {
1876
2778
  var forgetNext = async () => {
1877
2779
  try {
1878
2780
  const projectDir = process.cwd();
1879
- const __filename = fileURLToPath17(import.meta.url);
1880
- const __dirname = path19.dirname(__filename);
1881
- const srcPath = path19.join(projectDir, "src");
1882
- const folder = fs19.existsSync(srcPath) ? "src" : "";
1883
- const emailFilePath = path19.join(projectDir, folder, "lib", "email.ts");
1884
- if (!fs19.existsSync(emailFilePath)) {
2781
+ const __filename = fileURLToPath25(import.meta.url);
2782
+ const __dirname = path27.dirname(__filename);
2783
+ const srcPath = path27.join(projectDir, "src");
2784
+ const folder = fs27.existsSync(srcPath) ? "src" : "";
2785
+ const emailFilePath = path27.join(projectDir, folder, "lib", "email.ts");
2786
+ if (!fs27.existsSync(emailFilePath)) {
1885
2787
  await email();
1886
2788
  }
1887
- const authFilePath = path19.join(projectDir, folder, "lib", "auth.ts");
1888
- if (!fs19.existsSync(authFilePath)) {
1889
- console.log(chalk20.red("auth.ts file not found."));
2789
+ const authFilePath = path27.join(projectDir, folder, "lib", "auth.ts");
2790
+ if (!fs27.existsSync(authFilePath)) {
2791
+ console.log(chalk28.red("auth.ts file not found."));
1890
2792
  return;
1891
2793
  }
1892
- let content = fs19.readFileSync(authFilePath, "utf8");
2794
+ let content = fs27.readFileSync(authFilePath, "utf8");
1893
2795
  const codeAdded = ` sendResetPassword: async ({ user, url, token }) => {
1894
2796
  await sendEmail({
1895
2797
  email: user.email!,
@@ -1933,7 +2835,7 @@ var forgetNext = async () => {
1933
2835
  content = before + `
1934
2836
  ${codeAdded}` + after;
1935
2837
  }
1936
- fs19.writeFileSync(authFilePath, content, "utf8");
2838
+ fs27.writeFileSync(authFilePath, content, "utf8");
1937
2839
  if (!content.includes("import { sendEmail }")) {
1938
2840
  const lastImportIndex = content.lastIndexOf("import");
1939
2841
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -1943,128 +2845,128 @@ var forgetNext = async () => {
1943
2845
  import { sendEmail } from "./email";
1944
2846
  `;
1945
2847
  content = beforeImports + newImports + afterImports;
1946
- fs19.writeFileSync(authFilePath, content, "utf8");
2848
+ fs27.writeFileSync(authFilePath, content, "utf8");
1947
2849
  }
1948
- const componentPath = path19.resolve(
2850
+ const componentPath = path27.resolve(
1949
2851
  __dirname,
1950
2852
  "./template/email/reset-password.tsx"
1951
2853
  );
1952
- const destinationPath = path19.join(
2854
+ const destinationPath = path27.join(
1953
2855
  projectDir,
1954
2856
  folder,
1955
2857
  "components",
1956
2858
  "email"
1957
2859
  );
1958
- if (!fs19.existsSync(destinationPath)) {
1959
- fs19.mkdirSync(destinationPath, { recursive: true });
2860
+ if (!fs27.existsSync(destinationPath)) {
2861
+ fs27.mkdirSync(destinationPath, { recursive: true });
1960
2862
  }
1961
- const emailDestinationPath = path19.join(
2863
+ const emailDestinationPath = path27.join(
1962
2864
  destinationPath,
1963
2865
  "reset-password.tsx"
1964
2866
  );
1965
- if (fs19.existsSync(componentPath)) {
1966
- fs19.copyFileSync(componentPath, emailDestinationPath);
2867
+ if (fs27.existsSync(componentPath)) {
2868
+ fs27.copyFileSync(componentPath, emailDestinationPath);
1967
2869
  }
1968
- const forgetComponentPath = path19.resolve(
2870
+ const forgetComponentPath = path27.resolve(
1969
2871
  __dirname,
1970
2872
  "./template/components/ForgetComponent.tsx"
1971
2873
  );
1972
- const componentsDestinationPath = path19.join(
2874
+ const componentsDestinationPath = path27.join(
1973
2875
  projectDir,
1974
2876
  folder,
1975
2877
  "components",
1976
2878
  "authverse"
1977
2879
  );
1978
- if (!fs19.existsSync(componentsDestinationPath)) {
1979
- fs19.mkdirSync(componentsDestinationPath, { recursive: true });
2880
+ if (!fs27.existsSync(componentsDestinationPath)) {
2881
+ fs27.mkdirSync(componentsDestinationPath, { recursive: true });
1980
2882
  }
1981
- const forgetDestinationPath = path19.join(
2883
+ const forgetDestinationPath = path27.join(
1982
2884
  componentsDestinationPath,
1983
2885
  "ForgetComponent.tsx"
1984
2886
  );
1985
- if (fs19.existsSync(forgetComponentPath)) {
1986
- fs19.copyFileSync(forgetComponentPath, forgetDestinationPath);
2887
+ if (fs27.existsSync(forgetComponentPath)) {
2888
+ fs27.copyFileSync(forgetComponentPath, forgetDestinationPath);
1987
2889
  }
1988
- const resetComponentPath = path19.resolve(
2890
+ const resetComponentPath = path27.resolve(
1989
2891
  __dirname,
1990
2892
  "./template/components/ResetComponent.tsx"
1991
2893
  );
1992
- const resetDestinationPath = path19.join(
2894
+ const resetDestinationPath = path27.join(
1993
2895
  componentsDestinationPath,
1994
2896
  "ResetComponent.tsx"
1995
2897
  );
1996
- if (fs19.existsSync(resetComponentPath)) {
1997
- fs19.copyFileSync(resetComponentPath, resetDestinationPath);
2898
+ if (fs27.existsSync(resetComponentPath)) {
2899
+ fs27.copyFileSync(resetComponentPath, resetDestinationPath);
1998
2900
  }
1999
- const authTemplatePath = path19.resolve(
2901
+ const authTemplatePath = path27.resolve(
2000
2902
  __dirname,
2001
2903
  "./template/app-auth-uiDesign"
2002
2904
  );
2003
- const appDestinationPath = path19.join(projectDir, folder, "app", "auth");
2004
- if (!fs19.existsSync(appDestinationPath)) {
2005
- fs19.mkdirSync(appDestinationPath, { recursive: true });
2905
+ const appDestinationPath = path27.join(projectDir, folder, "app", "auth");
2906
+ if (!fs27.existsSync(appDestinationPath)) {
2907
+ fs27.mkdirSync(appDestinationPath, { recursive: true });
2006
2908
  }
2007
- const forgetDestinationDir = path19.join(appDestinationPath, "forget");
2008
- if (!fs19.existsSync(forgetDestinationDir)) {
2009
- fs19.mkdirSync(forgetDestinationDir, { recursive: true });
2909
+ const forgetDestinationDir = path27.join(appDestinationPath, "forget");
2910
+ if (!fs27.existsSync(forgetDestinationDir)) {
2911
+ fs27.mkdirSync(forgetDestinationDir, { recursive: true });
2010
2912
  }
2011
- const forgetPageDestinationPath = path19.join(
2913
+ const forgetPageDestinationPath = path27.join(
2012
2914
  forgetDestinationDir,
2013
2915
  "page.tsx"
2014
2916
  );
2015
- fs19.copyFileSync(
2917
+ fs27.copyFileSync(
2016
2918
  `${authTemplatePath}/forget/page.tsx`,
2017
2919
  forgetPageDestinationPath
2018
2920
  );
2019
- const resetDestinationDir = path19.join(
2921
+ const resetDestinationDir = path27.join(
2020
2922
  appDestinationPath,
2021
2923
  "reset-password"
2022
2924
  );
2023
- if (!fs19.existsSync(resetDestinationDir)) {
2024
- fs19.mkdirSync(resetDestinationDir, { recursive: true });
2925
+ if (!fs27.existsSync(resetDestinationDir)) {
2926
+ fs27.mkdirSync(resetDestinationDir, { recursive: true });
2025
2927
  }
2026
- const resetPageDestinationPath = path19.join(
2928
+ const resetPageDestinationPath = path27.join(
2027
2929
  resetDestinationDir,
2028
2930
  "page.tsx"
2029
2931
  );
2030
- fs19.copyFileSync(
2932
+ fs27.copyFileSync(
2031
2933
  `${authTemplatePath}/reset-password/page.tsx`,
2032
2934
  resetPageDestinationPath
2033
2935
  );
2034
2936
  console.log(
2035
- chalk20.green("Successfully added forget and reset-password pages")
2937
+ chalk28.green("Successfully added forget and reset-password pages")
2036
2938
  );
2037
2939
  } else {
2038
2940
  console.log(
2039
- chalk20.red("Could not find emailAndPassword configuration in auth.ts")
2941
+ chalk28.red("Could not find emailAndPassword configuration in auth.ts")
2040
2942
  );
2041
2943
  }
2042
2944
  } catch (error) {
2043
- console.log(chalk20.red("Error adding sendResetPassword:"), error);
2945
+ console.log(chalk28.red("Error adding sendResetPassword:"), error);
2044
2946
  }
2045
2947
  };
2046
2948
 
2047
2949
  // script/forgetTanstack.ts
2048
- import chalk21 from "chalk";
2049
- import path20 from "path";
2050
- import { fileURLToPath as fileURLToPath18 } from "url";
2051
- import fs20 from "fs";
2950
+ import chalk29 from "chalk";
2951
+ import path28 from "path";
2952
+ import { fileURLToPath as fileURLToPath26 } from "url";
2953
+ import fs28 from "fs";
2052
2954
  var forgetTanstack = async () => {
2053
2955
  try {
2054
2956
  const projectDir = process.cwd();
2055
- const __filename = fileURLToPath18(import.meta.url);
2056
- const __dirname = path20.dirname(__filename);
2057
- const srcPath = path20.join(projectDir, "src");
2058
- const emailFilePath = path20.join(srcPath, "lib", "email.ts");
2059
- if (!fs20.existsSync(emailFilePath)) {
2957
+ const __filename = fileURLToPath26(import.meta.url);
2958
+ const __dirname = path28.dirname(__filename);
2959
+ const srcPath = path28.join(projectDir, "src");
2960
+ const emailFilePath = path28.join(srcPath, "lib", "email.ts");
2961
+ if (!fs28.existsSync(emailFilePath)) {
2060
2962
  await email();
2061
2963
  }
2062
- const authFilePath = path20.join(srcPath, "lib", "auth.ts");
2063
- if (!fs20.existsSync(authFilePath)) {
2064
- console.log(chalk21.red("auth.ts file not found."));
2964
+ const authFilePath = path28.join(srcPath, "lib", "auth.ts");
2965
+ if (!fs28.existsSync(authFilePath)) {
2966
+ console.log(chalk29.red("auth.ts file not found."));
2065
2967
  return;
2066
2968
  }
2067
- let content = fs20.readFileSync(authFilePath, "utf8");
2969
+ let content = fs28.readFileSync(authFilePath, "utf8");
2068
2970
  const codeAdded = `sendResetPassword: async ({ user, url, token }) => {
2069
2971
  await sendEmail({
2070
2972
  email: user.email!,
@@ -2108,7 +3010,7 @@ var forgetTanstack = async () => {
2108
3010
  content = before + `
2109
3011
  ${codeAdded}` + after;
2110
3012
  }
2111
- fs20.writeFileSync(authFilePath, content, "utf8");
3013
+ fs28.writeFileSync(authFilePath, content, "utf8");
2112
3014
  if (!content.includes("import { sendEmail }")) {
2113
3015
  const lastImportIndex = content.lastIndexOf("import");
2114
3016
  const nextLineAfterLastImport = content.indexOf("\n", lastImportIndex) + 1;
@@ -2118,96 +3020,96 @@ var forgetTanstack = async () => {
2118
3020
  import { sendEmail } from "./email";
2119
3021
  `;
2120
3022
  content = beforeImports + newImports + afterImports;
2121
- fs20.writeFileSync(authFilePath, content, "utf8");
3023
+ fs28.writeFileSync(authFilePath, content, "utf8");
2122
3024
  }
2123
- const componentPath = path20.resolve(
3025
+ const componentPath = path28.resolve(
2124
3026
  __dirname,
2125
3027
  "./template/email/reset-password.tsx"
2126
3028
  );
2127
- const destinationPath = path20.join(srcPath, "components", "email");
2128
- if (!fs20.existsSync(destinationPath)) {
2129
- fs20.mkdirSync(destinationPath, { recursive: true });
3029
+ const destinationPath = path28.join(srcPath, "components", "email");
3030
+ if (!fs28.existsSync(destinationPath)) {
3031
+ fs28.mkdirSync(destinationPath, { recursive: true });
2130
3032
  }
2131
- const emailDestinationPath = path20.join(
3033
+ const emailDestinationPath = path28.join(
2132
3034
  destinationPath,
2133
3035
  "reset-password.tsx"
2134
3036
  );
2135
- if (fs20.existsSync(componentPath)) {
2136
- fs20.copyFileSync(componentPath, emailDestinationPath);
3037
+ if (fs28.existsSync(componentPath)) {
3038
+ fs28.copyFileSync(componentPath, emailDestinationPath);
2137
3039
  }
2138
- const forgetComponentPath = path20.resolve(
3040
+ const forgetComponentPath = path28.resolve(
2139
3041
  __dirname,
2140
3042
  "./template/TanstackState/components/ForgetComponent.tsx"
2141
3043
  );
2142
- const componentsDestinationPath = path20.join(
3044
+ const componentsDestinationPath = path28.join(
2143
3045
  srcPath,
2144
3046
  "components",
2145
3047
  "authverse"
2146
3048
  );
2147
- if (!fs20.existsSync(componentsDestinationPath)) {
2148
- fs20.mkdirSync(componentsDestinationPath, { recursive: true });
3049
+ if (!fs28.existsSync(componentsDestinationPath)) {
3050
+ fs28.mkdirSync(componentsDestinationPath, { recursive: true });
2149
3051
  }
2150
- const forgetDestinationPath = path20.join(
3052
+ const forgetDestinationPath = path28.join(
2151
3053
  componentsDestinationPath,
2152
3054
  "ForgetComponent.tsx"
2153
3055
  );
2154
- if (fs20.existsSync(forgetComponentPath)) {
2155
- fs20.copyFileSync(forgetComponentPath, forgetDestinationPath);
3056
+ if (fs28.existsSync(forgetComponentPath)) {
3057
+ fs28.copyFileSync(forgetComponentPath, forgetDestinationPath);
2156
3058
  }
2157
- const resetComponentPath = path20.resolve(
3059
+ const resetComponentPath = path28.resolve(
2158
3060
  __dirname,
2159
3061
  "./template/TanstackState/components/ResetComponent.tsx"
2160
3062
  );
2161
- const resetDestinationPath = path20.join(
3063
+ const resetDestinationPath = path28.join(
2162
3064
  componentsDestinationPath,
2163
3065
  "ResetComponent.tsx"
2164
3066
  );
2165
- if (fs20.existsSync(resetComponentPath)) {
2166
- fs20.copyFileSync(resetComponentPath, resetDestinationPath);
3067
+ if (fs28.existsSync(resetComponentPath)) {
3068
+ fs28.copyFileSync(resetComponentPath, resetDestinationPath);
2167
3069
  }
2168
- const authTemplatePath = path20.resolve(
3070
+ const authTemplatePath = path28.resolve(
2169
3071
  __dirname,
2170
3072
  "./template/TanstackState/routes/auth"
2171
3073
  );
2172
- const routesDestinationPath = path20.join(srcPath, "routes", "auth");
2173
- if (!fs20.existsSync(routesDestinationPath)) {
2174
- fs20.mkdirSync(routesDestinationPath, { recursive: true });
3074
+ const routesDestinationPath = path28.join(srcPath, "routes", "auth");
3075
+ if (!fs28.existsSync(routesDestinationPath)) {
3076
+ fs28.mkdirSync(routesDestinationPath, { recursive: true });
2175
3077
  }
2176
- const forgetPageDestinationPath = path20.join(
3078
+ const forgetPageDestinationPath = path28.join(
2177
3079
  routesDestinationPath,
2178
3080
  "forget.tsx"
2179
3081
  );
2180
- fs20.copyFileSync(
3082
+ fs28.copyFileSync(
2181
3083
  `${authTemplatePath}/forget.tsx`,
2182
3084
  forgetPageDestinationPath
2183
3085
  );
2184
- const resetPageDestinationPath = path20.join(
3086
+ const resetPageDestinationPath = path28.join(
2185
3087
  routesDestinationPath,
2186
3088
  "reset-password.tsx"
2187
3089
  );
2188
- fs20.copyFileSync(
3090
+ fs28.copyFileSync(
2189
3091
  `${authTemplatePath}/reset-password.tsx`,
2190
3092
  resetPageDestinationPath
2191
3093
  );
2192
3094
  console.log(
2193
- chalk21.green("Successfully added forget and reset-password pages")
3095
+ chalk29.green("Successfully added forget and reset-password pages")
2194
3096
  );
2195
3097
  } else {
2196
3098
  console.log(
2197
- chalk21.red("Could not find emailAndPassword configuration in auth.ts")
3099
+ chalk29.red("Could not find emailAndPassword configuration in auth.ts")
2198
3100
  );
2199
3101
  }
2200
3102
  } catch (error) {
2201
- console.log(chalk21.red("Error adding sendResetPassword:"), error);
3103
+ console.log(chalk29.red("Error adding sendResetPassword:"), error);
2202
3104
  }
2203
3105
  };
2204
3106
 
2205
3107
  // cli/forget.ts
2206
- import chalk22 from "chalk";
3108
+ import chalk30 from "chalk";
2207
3109
  var forget = async () => {
2208
3110
  const { framework, error } = await getFramework();
2209
3111
  if (error) {
2210
- console.log(chalk22.red(error));
3112
+ console.log(chalk30.red(error));
2211
3113
  return;
2212
3114
  }
2213
3115
  if (framework === "Next js") {
@@ -2219,30 +3121,30 @@ var forget = async () => {
2219
3121
  };
2220
3122
 
2221
3123
  // cli/verification.ts
2222
- import chalk25 from "chalk";
3124
+ import chalk33 from "chalk";
2223
3125
 
2224
3126
  // script/verifyNext.ts
2225
- import chalk23 from "chalk";
2226
- import fs21 from "fs";
2227
- import path21 from "path";
2228
- import { fileURLToPath as fileURLToPath19 } from "url";
3127
+ import chalk31 from "chalk";
3128
+ import fs29 from "fs";
3129
+ import path29 from "path";
3130
+ import { fileURLToPath as fileURLToPath27 } from "url";
2229
3131
  var verifyNext = async () => {
2230
3132
  try {
2231
3133
  const projectDir = process.cwd();
2232
- const __filename = fileURLToPath19(import.meta.url);
2233
- const __dirname = path21.dirname(__filename);
2234
- const srcPath = path21.join(projectDir, "src");
2235
- const folder = fs21.existsSync(srcPath) ? "src" : "";
2236
- const emailFilePath = path21.join(projectDir, folder, "lib", "email.ts");
2237
- if (!fs21.existsSync(emailFilePath)) {
3134
+ const __filename = fileURLToPath27(import.meta.url);
3135
+ const __dirname = path29.dirname(__filename);
3136
+ const srcPath = path29.join(projectDir, "src");
3137
+ const folder = fs29.existsSync(srcPath) ? "src" : "";
3138
+ const emailFilePath = path29.join(projectDir, folder, "lib", "email.ts");
3139
+ if (!fs29.existsSync(emailFilePath)) {
2238
3140
  await email();
2239
3141
  }
2240
- const authFilePath = path21.join(projectDir, folder, "lib", "auth.ts");
2241
- if (!fs21.existsSync(authFilePath)) {
2242
- console.log(chalk23.red("auth.ts file not found."));
3142
+ const authFilePath = path29.join(projectDir, folder, "lib", "auth.ts");
3143
+ if (!fs29.existsSync(authFilePath)) {
3144
+ console.log(chalk31.red("auth.ts file not found."));
2243
3145
  return;
2244
3146
  }
2245
- let content = fs21.readFileSync(authFilePath, "utf8");
3147
+ let content = fs29.readFileSync(authFilePath, "utf8");
2246
3148
  if (content.includes("emailAndPassword: {")) {
2247
3149
  const start = content.indexOf("emailAndPassword: {");
2248
3150
  let end = start;
@@ -2302,46 +3204,46 @@ var verifyNext = async () => {
2302
3204
  `;
2303
3205
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2304
3206
  }
2305
- fs21.writeFileSync(authFilePath, content, "utf8");
2306
- const templatePath = path21.resolve(
3207
+ fs29.writeFileSync(authFilePath, content, "utf8");
3208
+ const templatePath = path29.resolve(
2307
3209
  __dirname,
2308
3210
  "./template/email/EmailVerification.tsx"
2309
3211
  );
2310
- const componentsDir = path21.join(projectDir, folder, "components", "email");
2311
- if (!fs21.existsSync(componentsDir)) {
2312
- fs21.mkdirSync(componentsDir, { recursive: true });
3212
+ const componentsDir = path29.join(projectDir, folder, "components", "email");
3213
+ if (!fs29.existsSync(componentsDir)) {
3214
+ fs29.mkdirSync(componentsDir, { recursive: true });
2313
3215
  }
2314
- const destFile = path21.join(componentsDir, "EmailVerification.tsx");
2315
- if (fs21.existsSync(templatePath) && !fs21.existsSync(destFile)) {
2316
- fs21.copyFileSync(templatePath, destFile);
3216
+ const destFile = path29.join(componentsDir, "EmailVerification.tsx");
3217
+ if (fs29.existsSync(templatePath) && !fs29.existsSync(destFile)) {
3218
+ fs29.copyFileSync(templatePath, destFile);
2317
3219
  }
2318
- console.log(chalk23.green("Email verification successfully configured"));
3220
+ console.log(chalk31.green("Email verification successfully configured"));
2319
3221
  } catch (error) {
2320
- console.log(chalk23.red(String(error)));
3222
+ console.log(chalk31.red(String(error)));
2321
3223
  }
2322
3224
  };
2323
3225
 
2324
3226
  // script/verifyTanstack.ts
2325
- import chalk24 from "chalk";
2326
- import fs22 from "fs";
2327
- import path22 from "path";
2328
- import { fileURLToPath as fileURLToPath20 } from "url";
3227
+ import chalk32 from "chalk";
3228
+ import fs30 from "fs";
3229
+ import path30 from "path";
3230
+ import { fileURLToPath as fileURLToPath28 } from "url";
2329
3231
  var verifyTanstack = async () => {
2330
3232
  try {
2331
3233
  const projectDir = process.cwd();
2332
- const __filename = fileURLToPath20(import.meta.url);
2333
- const __dirname = path22.dirname(__filename);
2334
- const srcPath = path22.join(projectDir, "src");
2335
- const emailFilePath = path22.join(srcPath, "lib", "email.ts");
2336
- if (!fs22.existsSync(emailFilePath)) {
3234
+ const __filename = fileURLToPath28(import.meta.url);
3235
+ const __dirname = path30.dirname(__filename);
3236
+ const srcPath = path30.join(projectDir, "src");
3237
+ const emailFilePath = path30.join(srcPath, "lib", "email.ts");
3238
+ if (!fs30.existsSync(emailFilePath)) {
2337
3239
  await email();
2338
3240
  }
2339
- const authFilePath = path22.join(srcPath, "lib", "auth.ts");
2340
- if (!fs22.existsSync(authFilePath)) {
2341
- console.log(chalk24.red("auth.ts file not found."));
3241
+ const authFilePath = path30.join(srcPath, "lib", "auth.ts");
3242
+ if (!fs30.existsSync(authFilePath)) {
3243
+ console.log(chalk32.red("auth.ts file not found."));
2342
3244
  return;
2343
3245
  }
2344
- let content = fs22.readFileSync(authFilePath, "utf8");
3246
+ let content = fs30.readFileSync(authFilePath, "utf8");
2345
3247
  if (content.includes("emailAndPassword: {")) {
2346
3248
  const start = content.indexOf("emailAndPassword: {");
2347
3249
  let end = start;
@@ -2401,22 +3303,22 @@ var verifyTanstack = async () => {
2401
3303
  `;
2402
3304
  content = content.slice(0, nextLine) + imports + content.slice(nextLine);
2403
3305
  }
2404
- fs22.writeFileSync(authFilePath, content, "utf8");
2405
- const templatePath = path22.resolve(
3306
+ fs30.writeFileSync(authFilePath, content, "utf8");
3307
+ const templatePath = path30.resolve(
2406
3308
  __dirname,
2407
3309
  "./template/email/EmailVerification.tsx"
2408
3310
  );
2409
- const componentsDir = path22.join(srcPath, "components", "email");
2410
- if (!fs22.existsSync(componentsDir)) {
2411
- fs22.mkdirSync(componentsDir, { recursive: true });
3311
+ const componentsDir = path30.join(srcPath, "components", "email");
3312
+ if (!fs30.existsSync(componentsDir)) {
3313
+ fs30.mkdirSync(componentsDir, { recursive: true });
2412
3314
  }
2413
- const destFile = path22.join(componentsDir, "EmailVerification.tsx");
2414
- if (fs22.existsSync(templatePath) && !fs22.existsSync(destFile)) {
2415
- fs22.copyFileSync(templatePath, destFile);
3315
+ const destFile = path30.join(componentsDir, "EmailVerification.tsx");
3316
+ if (fs30.existsSync(templatePath) && !fs30.existsSync(destFile)) {
3317
+ fs30.copyFileSync(templatePath, destFile);
2416
3318
  }
2417
- console.log(chalk24.green("Email verification successfully configured"));
3319
+ console.log(chalk32.green("Email verification successfully configured"));
2418
3320
  } catch (error) {
2419
- console.log(chalk24.red(String(error)));
3321
+ console.log(chalk32.red(String(error)));
2420
3322
  }
2421
3323
  };
2422
3324
 
@@ -2425,7 +3327,7 @@ var verification = async () => {
2425
3327
  try {
2426
3328
  const { framework, error } = await getFramework();
2427
3329
  if (error) {
2428
- console.log(chalk25.red(error));
3330
+ console.log(chalk33.red(error));
2429
3331
  return;
2430
3332
  }
2431
3333
  if (framework === "Next js") {
@@ -2435,17 +3337,17 @@ var verification = async () => {
2435
3337
  await verifyTanstack();
2436
3338
  }
2437
3339
  } catch (error) {
2438
- console.log(chalk25.red(error.message));
3340
+ console.log(chalk33.red(error.message));
2439
3341
  }
2440
3342
  };
2441
3343
 
2442
3344
  // cli/initCmd.ts
2443
- import chalk26 from "chalk";
3345
+ import chalk34 from "chalk";
2444
3346
  var initCmd = async (cmd) => {
2445
3347
  try {
2446
3348
  const { framework, error } = await getFramework();
2447
3349
  if (error) {
2448
- console.log(chalk26.red(error));
3350
+ console.log(chalk34.red(error));
2449
3351
  return;
2450
3352
  }
2451
3353
  if (framework === "Next js" && cmd.orm === "prisma") {
@@ -2475,7 +3377,7 @@ var initCmd = async (cmd) => {
2475
3377
  });
2476
3378
  }
2477
3379
  } catch (error) {
2478
- console.log(chalk26.red(error));
3380
+ console.log(chalk34.red(error));
2479
3381
  }
2480
3382
  };
2481
3383
 
@@ -2494,7 +3396,7 @@ program.command("init").description("Select project template and configuration")
2494
3396
  await initCmd(cmd);
2495
3397
  }
2496
3398
  });
2497
- program.command("add <oauth>").description("Add a new authentication provider").action(async (oauth) => {
3399
+ program.command("oauth <oauth>").description("Add a new authentication OAuth").action(async (oauth) => {
2498
3400
  await Oauth({ oauth });
2499
3401
  });
2500
3402
  program.command("forget").description("Forget stored configurations").action(async () => {