create-prisma-php-app 4.0.0-alpha.34 → 4.0.0-alpha.35

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 +90 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -373,6 +373,14 @@ function copyRecursiveSyncWithExclusions(
373
373
  );
374
374
  });
375
375
  } else {
376
+ const fileName = path.basename(dest);
377
+ // Always exclude critical config files from starter kit overwrites
378
+ if (fileName === "prisma-php.json") {
379
+ console.log(
380
+ chalk.yellow(`Protecting config file: ${dest.replace(/\\/g, "/")}`)
381
+ );
382
+ return;
383
+ }
376
384
  // Apply user-defined exclusions for files
377
385
  if (respectExclusions && checkExcludeFiles(dest)) {
378
386
  console.log(
@@ -407,6 +415,69 @@ function copyRecursiveSyncWithExclusions(
407
415
  fs.copyFileSync(src, dest, 0);
408
416
  }
409
417
  }
418
+ function mergeConfigurationFiles(
419
+ projectPath,
420
+ answer,
421
+ latestVersion,
422
+ existingConfig
423
+ ) {
424
+ const projectPathModified = projectPath.replace(/\\/g, "\\");
425
+ const bsConfig = bsConfigUrls(projectPathModified);
426
+ // If we have existing config, merge with it
427
+ if (existingConfig) {
428
+ const mergedConfig = {
429
+ ...existingConfig, // Start with existing config
430
+ // Only update specific fields that should be updated
431
+ projectName: answer.projectName,
432
+ projectRootPath: projectPathModified,
433
+ bsTarget: bsConfig.bsTarget,
434
+ bsPathRewrite: bsConfig.bsPathRewrite,
435
+ // Update feature flags only if they're different from existing
436
+ backendOnly: answer.backendOnly,
437
+ swaggerDocs: answer.swaggerDocs,
438
+ tailwindcss: answer.tailwindcss,
439
+ websocket: answer.websocket,
440
+ mcp: answer.mcp,
441
+ prisma: answer.prisma,
442
+ docker: answer.docker,
443
+ version: latestVersion,
444
+ // KEEP existing excludeFiles - this is crucial!
445
+ excludeFiles: existingConfig.excludeFiles || [],
446
+ };
447
+ fs.writeFileSync(
448
+ path.join(projectPath, "prisma-php.json"),
449
+ JSON.stringify(mergedConfig, null, 2),
450
+ { flag: "w" }
451
+ );
452
+ console.log(
453
+ chalk.green("✓ Configuration merged successfully, exclusions preserved")
454
+ );
455
+ } else {
456
+ // New project - create fresh config
457
+ const prismaPhpConfig = {
458
+ projectName: answer.projectName,
459
+ projectRootPath: projectPathModified,
460
+ phpEnvironment: "XAMPP",
461
+ phpRootPathExe: "C:\\xampp\\php\\php.exe",
462
+ bsTarget: bsConfig.bsTarget,
463
+ bsPathRewrite: bsConfig.bsPathRewrite,
464
+ backendOnly: answer.backendOnly,
465
+ swaggerDocs: answer.swaggerDocs,
466
+ tailwindcss: answer.tailwindcss,
467
+ websocket: answer.websocket,
468
+ mcp: answer.mcp,
469
+ prisma: answer.prisma,
470
+ docker: answer.docker,
471
+ version: latestVersion,
472
+ excludeFiles: [],
473
+ };
474
+ fs.writeFileSync(
475
+ path.join(projectPath, "prisma-php.json"),
476
+ JSON.stringify(prismaPhpConfig, null, 2),
477
+ { flag: "w" }
478
+ );
479
+ }
480
+ }
410
481
  async function main() {
411
482
  try {
412
483
  const args = process.argv.slice(2);
@@ -871,29 +942,25 @@ async function main() {
871
942
  await uninstallComposerDependencies(projectPath, composerToUninstall);
872
943
  }
873
944
  }
874
- const projectPathModified = projectPath.replace(/\\/g, "\\");
875
- const bsConfig = bsConfigUrls(projectPathModified);
876
- const prismaPhpConfig = {
877
- projectName: answer.projectName,
878
- projectRootPath: projectPathModified,
879
- phpEnvironment: "XAMPP",
880
- phpRootPathExe: "C:\\xampp\\php\\php.exe",
881
- bsTarget: bsConfig.bsTarget,
882
- bsPathRewrite: bsConfig.bsPathRewrite,
883
- backendOnly: answer.backendOnly,
884
- swaggerDocs: answer.swaggerDocs,
885
- tailwindcss: answer.tailwindcss,
886
- websocket: answer.websocket,
887
- mcp: answer.mcp,
888
- prisma: answer.prisma,
889
- docker: answer.docker,
890
- version: latestVersionOfCreatePrismaPhpApp,
891
- excludeFiles: updateAnswer?.excludeFiles ?? [],
892
- };
893
- fs.writeFileSync(
894
- path.join(projectPath, "prisma-php.json"),
895
- JSON.stringify(prismaPhpConfig, null, 2),
896
- { flag: "w" }
945
+ // Check if there's an existing config to merge with
946
+ let existingConfig = null;
947
+ const configPath = path.join(projectPath, "prisma-php.json");
948
+ if (fs.existsSync(configPath) && updateAnswer?.excludeFiles) {
949
+ try {
950
+ existingConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
951
+ console.log(chalk.blue("Found existing configuration, merging..."));
952
+ } catch (error) {
953
+ console.warn(
954
+ chalk.yellow("Could not read existing config, creating new one")
955
+ );
956
+ }
957
+ }
958
+ // Merge or create configuration
959
+ mergeConfigurationFiles(
960
+ projectPath,
961
+ answer,
962
+ latestVersionOfCreatePrismaPhpApp,
963
+ existingConfig
897
964
  );
898
965
  if (updateAnswer?.isUpdate) {
899
966
  execSync(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.0.0-alpha.34",
3
+ "version": "4.0.0-alpha.35",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",