create-prisma-php-app 4.0.0-alpha.46 → 4.0.0-alpha.47

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.
Files changed (2) hide show
  1. package/dist/index.js +63 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1061,9 +1061,39 @@ async function downloadStarterKit(starterKit, tempDir) {
1061
1061
  }
1062
1062
  async function mergeStarterKitFiles(starterKitPath, projectPath, answer) {
1063
1063
  console.log(chalk.blue("Merging starter kit files..."));
1064
- // Copy all files from starter kit, but don't overwrite base files
1064
+ // First, check if starter kit has a prisma-php.json to preserve excludeFiles
1065
+ const starterKitConfigPath = path.join(starterKitPath, "prisma-php.json");
1066
+ let starterKitExcludeFiles = [];
1067
+ if (fs.existsSync(starterKitConfigPath)) {
1068
+ try {
1069
+ const starterKitConfig = JSON.parse(
1070
+ fs.readFileSync(starterKitConfigPath, "utf8")
1071
+ );
1072
+ starterKitExcludeFiles = starterKitConfig.excludeFiles || [];
1073
+ console.log(
1074
+ chalk.blue(
1075
+ `Found ${starterKitExcludeFiles.length} excluded files in starter kit`
1076
+ )
1077
+ );
1078
+ } catch (error) {
1079
+ console.warn(chalk.yellow("Failed to parse starter kit prisma-php.json"));
1080
+ }
1081
+ }
1082
+ // Temporarily store excludeFiles for the copy process
1083
+ const tempUpdateAnswer = updateAnswer;
1084
+ updateAnswer = {
1085
+ ...answer,
1086
+ isUpdate: false, // Treat as new project for copying
1087
+ excludeFiles: starterKitExcludeFiles,
1088
+ excludeFilePath: starterKitExcludeFiles.map((file) =>
1089
+ path.join(projectPath, file).replace(/\\/g, "/")
1090
+ ),
1091
+ };
1092
+ // Copy all files from starter kit
1065
1093
  copyRecursiveSync(starterKitPath, projectPath, answer);
1066
- // Look for starter kit specific configuration
1094
+ // Restore original updateAnswer
1095
+ updateAnswer = tempUpdateAnswer;
1096
+ // Handle starter kit specific configuration
1067
1097
  const starterKitConfig = path.join(starterKitPath, "starter-kit.json");
1068
1098
  if (fs.existsSync(starterKitConfig)) {
1069
1099
  const config = JSON.parse(fs.readFileSync(starterKitConfig, "utf8"));
@@ -1090,6 +1120,18 @@ async function mergeStarterKitFiles(starterKitPath, projectPath, answer) {
1090
1120
  );
1091
1121
  }
1092
1122
  }
1123
+ // Store the excludeFiles for later use in main()
1124
+ if (starterKitExcludeFiles.length > 0) {
1125
+ // Create a temporary marker file to pass excludeFiles to main()
1126
+ const tempConfigPath = path.join(
1127
+ projectPath,
1128
+ ".temp-starter-kit-config.json"
1129
+ );
1130
+ fs.writeFileSync(
1131
+ tempConfigPath,
1132
+ JSON.stringify({ excludeFiles: starterKitExcludeFiles })
1133
+ );
1134
+ }
1093
1135
  }
1094
1136
  async function setupStarterKit(baseDir, answer) {
1095
1137
  if (!answer.starterKit) return;
@@ -1633,6 +1675,21 @@ async function main() {
1633
1675
  }
1634
1676
  const projectPathModified = projectPath.replace(/\\/g, "\\");
1635
1677
  const bsConfig = bsConfigUrls(projectPathModified);
1678
+ let starterKitExcludeFiles = [];
1679
+ const tempConfigPath = path.join(
1680
+ projectPath,
1681
+ ".temp-starter-kit-config.json"
1682
+ );
1683
+ if (fs.existsSync(tempConfigPath)) {
1684
+ try {
1685
+ const tempConfig = JSON.parse(fs.readFileSync(tempConfigPath, "utf8"));
1686
+ starterKitExcludeFiles = tempConfig.excludeFiles || [];
1687
+ fs.unlinkSync(tempConfigPath); // Clean up temp file
1688
+ } catch (error) {
1689
+ console.warn("Failed to read temp starter kit config");
1690
+ }
1691
+ }
1692
+ // Then update the prismaPhpConfig creation:
1636
1693
  const prismaPhpConfig = {
1637
1694
  projectName: answer.projectName,
1638
1695
  projectRootPath: projectPathModified,
@@ -1648,7 +1705,10 @@ async function main() {
1648
1705
  prisma: answer.prisma,
1649
1706
  docker: answer.docker,
1650
1707
  version: latestVersionOfCreatePrismaPhpApp,
1651
- excludeFiles: updateAnswer?.excludeFiles ?? [],
1708
+ excludeFiles:
1709
+ starterKitExcludeFiles.length > 0
1710
+ ? starterKitExcludeFiles
1711
+ : updateAnswer?.excludeFiles ?? [],
1652
1712
  };
1653
1713
  fs.writeFileSync(
1654
1714
  path.join(projectPath, "prisma-php.json"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.0.0-alpha.46",
3
+ "version": "4.0.0-alpha.47",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",