create-prisma-php-app 1.18.503 → 1.18.505

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 +96 -77
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -462,7 +462,7 @@ DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=pub
462
462
  await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
463
463
  }
464
464
  async function getAnswer(predefinedAnswers = {}) {
465
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
465
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
466
466
  console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
467
467
  const questionsArray = [];
468
468
  if (!predefinedAnswers.projectName) {
@@ -483,8 +483,9 @@ async function getAnswer(predefinedAnswers = {}) {
483
483
  inactive: "No",
484
484
  });
485
485
  }
486
+ const nonBackendOnlyQuestionsArray = [];
486
487
  if (!predefinedAnswers.websocket) {
487
- questionsArray.push({
488
+ nonBackendOnlyQuestionsArray.push({
488
489
  type: "toggle",
489
490
  name: "websocket",
490
491
  message: `Would you like to use ${chalk.blue("Websocket")}?`,
@@ -494,7 +495,7 @@ async function getAnswer(predefinedAnswers = {}) {
494
495
  });
495
496
  }
496
497
  if (!predefinedAnswers.prisma) {
497
- questionsArray.push({
498
+ nonBackendOnlyQuestionsArray.push({
498
499
  type: "toggle",
499
500
  name: "prisma",
500
501
  message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
@@ -504,7 +505,7 @@ async function getAnswer(predefinedAnswers = {}) {
504
505
  });
505
506
  }
506
507
  if (!predefinedAnswers.docker) {
507
- questionsArray.push({
508
+ nonBackendOnlyQuestionsArray.push({
508
509
  type: "toggle",
509
510
  name: "docker",
510
511
  message: `Would you like to use ${chalk.blue("Docker")}?`,
@@ -513,90 +514,90 @@ async function getAnswer(predefinedAnswers = {}) {
513
514
  inactive: "No",
514
515
  });
515
516
  }
516
- const questions = questionsArray;
517
- console.log("🚀 ~ questions:", questions);
517
+ // Execute the questionsArray first to determine the backendOnly option
518
518
  const onCancel = () => {
519
519
  console.log(chalk.red("Operation cancelled by the user."));
520
520
  process.exit(0);
521
521
  };
522
- try {
523
- const response = await prompts(questions, { onCancel });
524
- console.log("🚀 ~ response:", response);
525
- if (Object.keys(response).length === 0) {
526
- return null;
527
- }
528
- // Handle backendOnly response and skip Tailwind CSS if backendOnly is true
529
- if (response.backendOnly || predefinedAnswers.backendOnly) {
530
- return {
531
- projectName: response.projectName
532
- ? String(response.projectName).trim().replace(/ /g, "-")
533
- : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
534
- ? _a
535
- : "my-app",
536
- backendOnly:
537
- (_b = response.backendOnly) !== null && _b !== void 0
538
- ? _b
539
- : predefinedAnswers.backendOnly,
540
- tailwindcss: false, // Automatically set to false if backendOnly is true
541
- websocket:
542
- (_c = response.websocket) !== null && _c !== void 0
543
- ? _c
544
- : predefinedAnswers.websocket,
545
- prisma:
546
- (_d = response.prisma) !== null && _d !== void 0
547
- ? _d
548
- : predefinedAnswers.prisma,
549
- docker:
550
- (_e = response.docker) !== null && _e !== void 0
551
- ? _e
552
- : predefinedAnswers.docker,
553
- };
554
- }
555
- if (!predefinedAnswers.tailwindcss) {
556
- const tailwindResponse = await prompts(
557
- {
558
- type: "toggle",
559
- name: "tailwindcss",
560
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
561
- initial: true,
562
- active: "Yes",
563
- inactive: "No",
564
- },
565
- { onCancel }
566
- );
567
- response.tailwindcss = tailwindResponse.tailwindcss;
568
- }
522
+ const initialResponse = await prompts(questionsArray, { onCancel });
523
+ console.log("🚀 ~ initialResponse:", initialResponse);
524
+ if (initialResponse.backendOnly) {
569
525
  return {
570
- projectName: response.projectName
571
- ? String(response.projectName).trim().replace(/ /g, "-")
572
- : (_f = predefinedAnswers.projectName) !== null && _f !== void 0
573
- ? _f
526
+ projectName: initialResponse.projectName
527
+ ? String(initialResponse.projectName).trim().replace(/ /g, "-")
528
+ : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
529
+ ? _a
574
530
  : "my-app",
575
- backendOnly:
576
- (_g = response.backendOnly) !== null && _g !== void 0
577
- ? _g
578
- : predefinedAnswers.backendOnly,
579
- tailwindcss:
580
- (_h = response.tailwindcss) !== null && _h !== void 0
581
- ? _h
582
- : predefinedAnswers.tailwindcss,
531
+ backendOnly: initialResponse.backendOnly,
532
+ tailwindcss: false, // Automatically set to false if backendOnly is true
583
533
  websocket:
584
- (_j = response.websocket) !== null && _j !== void 0
585
- ? _j
586
- : predefinedAnswers.websocket,
534
+ (_b = predefinedAnswers.websocket) !== null && _b !== void 0
535
+ ? _b
536
+ : false,
587
537
  prisma:
588
- (_k = response.prisma) !== null && _k !== void 0
589
- ? _k
590
- : predefinedAnswers.prisma,
538
+ (_c = predefinedAnswers.prisma) !== null && _c !== void 0 ? _c : false,
591
539
  docker:
592
- (_l = response.docker) !== null && _l !== void 0
593
- ? _l
594
- : predefinedAnswers.docker,
540
+ (_d = predefinedAnswers.docker) !== null && _d !== void 0 ? _d : false,
595
541
  };
596
- } catch (error) {
597
- console.error(chalk.red("Prompt error:"), error);
598
- return null;
599
542
  }
543
+ // If it's not backend-only, add Tailwind CSS question to the front of nonBackendOnlyQuestionsArray
544
+ if (!predefinedAnswers.tailwindcss) {
545
+ nonBackendOnlyQuestionsArray.unshift({
546
+ type: "toggle",
547
+ name: "tailwindcss",
548
+ message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
549
+ initial: true,
550
+ active: "Yes",
551
+ inactive: "No",
552
+ });
553
+ }
554
+ // Now ask the rest of the questions
555
+ const nonBackendOnlyResponse = await prompts(nonBackendOnlyQuestionsArray, {
556
+ onCancel,
557
+ });
558
+ console.log("🚀 ~ nonBackendOnlyResponse:", nonBackendOnlyResponse);
559
+ return {
560
+ projectName: initialResponse.projectName
561
+ ? String(initialResponse.projectName).trim().replace(/ /g, "-")
562
+ : (_e = predefinedAnswers.projectName) !== null && _e !== void 0
563
+ ? _e
564
+ : "my-app",
565
+ backendOnly:
566
+ (_g =
567
+ (_f = initialResponse.backendOnly) !== null && _f !== void 0
568
+ ? _f
569
+ : predefinedAnswers.backendOnly) !== null && _g !== void 0
570
+ ? _g
571
+ : false,
572
+ tailwindcss:
573
+ (_j =
574
+ (_h = nonBackendOnlyResponse.tailwindcss) !== null && _h !== void 0
575
+ ? _h
576
+ : predefinedAnswers.tailwindcss) !== null && _j !== void 0
577
+ ? _j
578
+ : false,
579
+ websocket:
580
+ (_l =
581
+ (_k = nonBackendOnlyResponse.websocket) !== null && _k !== void 0
582
+ ? _k
583
+ : predefinedAnswers.websocket) !== null && _l !== void 0
584
+ ? _l
585
+ : false,
586
+ prisma:
587
+ (_o =
588
+ (_m = nonBackendOnlyResponse.prisma) !== null && _m !== void 0
589
+ ? _m
590
+ : predefinedAnswers.prisma) !== null && _o !== void 0
591
+ ? _o
592
+ : false,
593
+ docker:
594
+ (_q =
595
+ (_p = nonBackendOnlyResponse.docker) !== null && _p !== void 0
596
+ ? _p
597
+ : predefinedAnswers.docker) !== null && _q !== void 0
598
+ ? _q
599
+ : false,
600
+ };
600
601
  }
601
602
  /**
602
603
  * Install dependencies in the specified directory.
@@ -871,6 +872,24 @@ async function main() {
871
872
  : updateAnswer.isUpdate
872
873
  ) {
873
874
  const updateUninstallDependencies = [];
875
+ if (updateAnswer.backendOnly) {
876
+ const backendOnlyFiles = [
877
+ "favicon.ico",
878
+ "index.php",
879
+ "layout.php",
880
+ "metadata.php",
881
+ "not-found.php",
882
+ ];
883
+ backendOnlyFiles.forEach((file) => {
884
+ const filePath = path.join(projectPath, "src", "app", file);
885
+ if (fs.existsSync(filePath)) {
886
+ fs.unlinkSync(filePath); // Delete each file if it exists
887
+ console.log(`${file} was deleted successfully.`);
888
+ } else {
889
+ console.log(`${file} does not exist.`);
890
+ }
891
+ });
892
+ }
874
893
  if (!updateAnswer.tailwindcss) {
875
894
  const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
876
895
  tailwindFiles.forEach((file) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.18.503",
3
+ "version": "1.18.505",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",