create-prisma-php-app 1.18.502 → 1.18.504

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 +76 -47
  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;
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,18 +483,9 @@ async function getAnswer(predefinedAnswers = {}) {
483
483
  inactive: "No",
484
484
  });
485
485
  }
486
- if (!predefinedAnswers.backendOnly && !predefinedAnswers.tailwindcss) {
487
- questionsArray.push({
488
- type: "toggle",
489
- name: "tailwindcss",
490
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
491
- initial: true,
492
- active: "Yes",
493
- inactive: "No",
494
- });
495
- }
486
+ const nonBackendOnlyQuestionsArray = [];
496
487
  if (!predefinedAnswers.websocket) {
497
- questionsArray.push({
488
+ nonBackendOnlyQuestionsArray.push({
498
489
  type: "toggle",
499
490
  name: "websocket",
500
491
  message: `Would you like to use ${chalk.blue("Websocket")}?`,
@@ -504,7 +495,7 @@ async function getAnswer(predefinedAnswers = {}) {
504
495
  });
505
496
  }
506
497
  if (!predefinedAnswers.prisma) {
507
- questionsArray.push({
498
+ nonBackendOnlyQuestionsArray.push({
508
499
  type: "toggle",
509
500
  name: "prisma",
510
501
  message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
@@ -514,7 +505,7 @@ async function getAnswer(predefinedAnswers = {}) {
514
505
  });
515
506
  }
516
507
  if (!predefinedAnswers.docker) {
517
- questionsArray.push({
508
+ nonBackendOnlyQuestionsArray.push({
518
509
  type: "toggle",
519
510
  name: "docker",
520
511
  message: `Would you like to use ${chalk.blue("Docker")}?`,
@@ -523,52 +514,90 @@ async function getAnswer(predefinedAnswers = {}) {
523
514
  inactive: "No",
524
515
  });
525
516
  }
526
- const questions = questionsArray;
527
- console.log("🚀 ~ questions:", questions);
528
- if (questions.length === 0 && predefinedAnswers.projectName) {
529
- return predefinedAnswers;
530
- }
517
+ // Execute the questionsArray first to determine the backendOnly option
531
518
  const onCancel = () => {
532
519
  console.log(chalk.red("Operation cancelled by the user."));
533
520
  process.exit(0);
534
521
  };
535
- try {
536
- const response = await prompts(questions, { onCancel });
537
- console.log("🚀 ~ response:", response);
538
- if (Object.keys(response).length === 0) {
539
- return null;
540
- }
522
+ const initialResponse = await prompts(questionsArray, { onCancel });
523
+ console.log("🚀 ~ initialResponse:", initialResponse);
524
+ if (initialResponse.backendOnly) {
541
525
  return {
542
- projectName: response.projectName
543
- ? String(response.projectName).trim().replace(/ /g, "-")
526
+ projectName: initialResponse.projectName
527
+ ? String(initialResponse.projectName).trim().replace(/ /g, "-")
544
528
  : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
545
529
  ? _a
546
530
  : "my-app",
547
- backendOnly:
548
- (_b = response.backendOnly) !== null && _b !== void 0
549
- ? _b
550
- : predefinedAnswers.backendOnly,
551
- tailwindcss:
552
- (_c = response.tailwindcss) !== null && _c !== void 0
553
- ? _c
554
- : predefinedAnswers.tailwindcss,
531
+ backendOnly: initialResponse.backendOnly,
532
+ tailwindcss: false, // Automatically set to false if backendOnly is true
555
533
  websocket:
556
- (_d = response.websocket) !== null && _d !== void 0
557
- ? _d
558
- : predefinedAnswers.websocket,
534
+ (_b = predefinedAnswers.websocket) !== null && _b !== void 0
535
+ ? _b
536
+ : false,
559
537
  prisma:
560
- (_e = response.prisma) !== null && _e !== void 0
561
- ? _e
562
- : predefinedAnswers.prisma,
538
+ (_c = predefinedAnswers.prisma) !== null && _c !== void 0 ? _c : false,
563
539
  docker:
564
- (_f = response.docker) !== null && _f !== void 0
565
- ? _f
566
- : predefinedAnswers.docker,
540
+ (_d = predefinedAnswers.docker) !== null && _d !== void 0 ? _d : false,
567
541
  };
568
- } catch (error) {
569
- console.error(chalk.red("Prompt error:"), error);
570
- return null;
571
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
+ };
572
601
  }
573
602
  /**
574
603
  * Install dependencies in the specified directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.18.502",
3
+ "version": "1.18.504",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",