create-prisma-php-app 1.20.509 → 1.20.511

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
@@ -142,27 +142,19 @@ async function updatePackageJson(baseDir, answer) {
142
142
  Object.assign({}, packageJson.scripts),
143
143
  { "create-swagger-docs": "node settings/swagger-setup.js" }
144
144
  );
145
- answersToInclude.push("swaggerDocs");
146
- }
147
- if (answer.swaggerDocs) {
148
- packageJson.scripts = Object.assign(
149
- Object.assign({}, packageJson.scripts),
150
- { dev: "node settings/start-dev.js" }
151
- );
152
145
  }
153
146
  // Initialize with existing scripts
154
- const updatedScripts = Object.assign({}, packageJson.scripts);
147
+ let updatedScripts = Object.assign({}, packageJson.scripts);
155
148
  // Conditionally add "browser-sync" command
156
- updatedScripts["browser-sync"] = browserSyncCommand;
157
- // Conditionally set the "dev" command
158
- if (!answer.swaggerDocs) {
159
- updatedScripts.dev =
160
- answersToInclude.length > 0
161
- ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(
162
- " "
163
- )}`
164
- : `npm-run-all --parallel projectName browser-sync`;
165
- }
149
+ updatedScripts.browserSync = browserSyncCommand;
150
+ updatedScripts._dev =
151
+ answersToInclude.length > 0
152
+ ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(
153
+ " "
154
+ )}`
155
+ : `npm-run-all --parallel projectName browser-sync`;
156
+ updatedScripts.startDev = `node settings/start-dev.js`;
157
+ updatedScripts.dev = `npm run startDev`;
166
158
  // Finally, assign the updated scripts back to packageJson
167
159
  packageJson.scripts = updatedScripts;
168
160
  packageJson.type = "module";
@@ -594,7 +586,7 @@ async function getAnswer(predefinedAnswers = {}) {
594
586
  });
595
587
  }
596
588
  if (!predefinedAnswers.tailwindcss) {
597
- nonBackendOnlyQuestionsArray.unshift({
589
+ nonBackendOnlyQuestionsArray.push({
598
590
  type: "toggle",
599
591
  name: "tailwindcss",
600
592
  message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
@@ -933,13 +925,11 @@ async function main() {
933
925
  "ts-node",
934
926
  "http-proxy-middleware@^3.0.0",
935
927
  "chalk",
928
+ "npm-run-all",
936
929
  ];
937
930
  if (answer.swaggerDocs) {
938
931
  dependencies.push("swagger-jsdoc");
939
932
  }
940
- if (!answer.backendOnly && !answer.swaggerDocs) {
941
- dependencies.push("npm-run-all");
942
- }
943
933
  if (answer.tailwindcss) {
944
934
  dependencies.push(
945
935
  "tailwindcss",
@@ -1,132 +1,80 @@
1
- import { exec, execSync } from "child_process";
1
+ import { exec } from "child_process";
2
2
  import chalk from "chalk";
3
3
  import { writeFileSync } from "fs";
4
4
 
5
- // Function to check if a command exists in the system
6
- function commandExists(command) {
7
- try {
8
- execSync(`command -v ${command}`, { stdio: "ignore" }); // Works for Linux/macOS
9
- return true;
10
- } catch {
11
- return false;
12
- }
13
- }
14
-
15
- function startDev() {
16
- // Start projectName first, since it's always required
17
- console.log("Starting projectName...");
18
- const projectName = exec("npm run projectName");
19
-
20
- projectName.stdout.on("data", (data) => {
21
- console.log(`projectName: ${data}`);
22
- });
23
-
24
- projectName.stderr.on("data", (data) => {
25
- console.error(`projectName error: ${data}`);
26
- });
27
-
28
- projectName.on("close", (code) => {
29
- // console.log(`projectName process exited with code ${code}`);
30
-
31
- // Start browser-sync after projectName completes
32
- console.log("Starting browser-sync...");
33
- const browserSync = exec("npm run browser-sync");
34
- let formattedLog = {
35
- local: "",
36
- external: "",
37
- ui: "",
38
- uiExternal: "",
39
- };
40
-
41
- browserSync.stdout.on("data", (data) => {
42
- const lines = data.split("\n");
5
+ // Run the original dev command and capture the output
6
+ const devProcess = exec("npm run _dev");
43
7
 
44
- lines.forEach((line) => {
45
- if (/Proxying/.test(line)) {
46
- console.log(chalk.blue("[Browsersync]") + ` ${line.trim()}`);
47
- } else if (/Access URLs:/.test(line)) {
48
- console.log(chalk.green("[Browsersync] Access URLs:"));
49
- } else if (/Local:/.test(line)) {
50
- const localUrl = line.match(/Local:\s*(http:\/\/.+)/)[1];
51
- formattedLog.local = localUrl;
52
- console.log(chalk.white("Local: ") + chalk.cyanBright(localUrl));
53
- } else if (/^ {4}External:/.test(line)) {
54
- const externalUrl = line.match(/External:\s*(http:\/\/\S+)/)[1];
55
- formattedLog.external = externalUrl;
56
- console.log(
57
- chalk.white("External: ") + chalk.magentaBright(externalUrl)
58
- );
59
- } else if (/UI:/.test(line)) {
60
- const uiUrl = line.match(/UI:\s*(http:\/\/.+)/)[1];
61
- formattedLog.ui = uiUrl;
62
- console.log(chalk.yellow("UI: ") + chalk.cyanBright(uiUrl));
63
- } else if (/UI External:/.test(line)) {
64
- const uiExternalUrl = line.match(/UI External:\s*(http:\/\/.+)/)[1];
65
- formattedLog.uiExternal = uiExternalUrl;
66
- console.log(
67
- chalk.yellow("UI External: ") + chalk.magentaBright(uiExternalUrl)
68
- );
69
- } else if (/Watching files/.test(line)) {
70
- console.log(chalk.blue("[Browsersync] Watching files..."));
71
- const outputPath = "./settings/bs-output.json";
72
- writeFileSync(
73
- outputPath,
74
- JSON.stringify(formattedLog, null, 2),
75
- "utf-8"
76
- );
77
- console.log(`Browser-sync output saved to ${outputPath}`);
78
- }
79
- });
80
- });
8
+ // Use a Set to track logged lines to avoid duplicate logging
9
+ const loggedLines = new Set();
81
10
 
82
- browserSync.stderr.on("data", (data) => {
83
- console.error(`browser-sync error: ${data}`);
84
- });
11
+ // Log the output from stdout (standard output)
12
+ devProcess.stdout.on("data", (data) => {
13
+ const dataString = data.toString(); // Ensure data is a string
85
14
 
86
- // Check if tailwind exists, and if so, execute it
87
- if (commandExists("tailwindcss")) {
88
- console.log("Starting tailwind...");
89
- const tailwind = exec("npm run tailwind");
90
-
91
- tailwind.stdout.on("data", (data) => {
92
- console.log(chalk.magenta("tailwind: ") + data);
93
- });
94
-
95
- tailwind.stderr.on("data", (data) => {
96
- console.error(chalk.red("tailwind error: ") + data);
97
- });
98
-
99
- tailwind.on("close", (code) => {
100
- console.log(`tailwind process exited with code ${code}`);
101
- });
102
- } else {
103
- // console.log(
104
- // chalk.red("tailwindcss is not installed, skipping tailwind task.")
105
- // );
106
- }
107
-
108
- // Check if websocket exists, and if so, execute it
109
- if (commandExists("node")) {
110
- console.log("Starting websocket...");
111
- const websocket = exec("npm run websocket");
112
-
113
- websocket.stdout.on("data", (data) => {
114
- console.log(chalk.blue("websocket: ") + data);
115
- });
116
-
117
- websocket.stderr.on("data", (data) => {
118
- console.error(chalk.red("websocket error: ") + data);
119
- });
15
+ // Only log if neither "Proxying" nor "Access URLs" have been logged before
16
+ if (
17
+ !dataString.includes("[Browsersync] Proxying:") &&
18
+ !dataString.includes("[Browsersync] Access URLs:") &&
19
+ !loggedLines.has(dataString)
20
+ ) {
21
+ console.log(dataString);
22
+ loggedLines.add(dataString); // Add to set to avoid future duplicates
23
+ }
120
24
 
121
- websocket.on("close", (code) => {
122
- console.log(`websocket process exited with code ${code}`);
123
- });
124
- } else {
125
- // console.log(
126
- // chalk.red("Websocket is not installed, skipping websocket task.")
127
- // );
25
+ let formattedLog = {
26
+ local: "",
27
+ external: "",
28
+ ui: "",
29
+ uiExternal: "",
30
+ };
31
+ const lines = dataString.split("\n");
32
+
33
+ lines.forEach((line) => {
34
+ if (/Proxying/.test(line) && !loggedLines.has(line)) {
35
+ console.log(`${line.trim()}`);
36
+ loggedLines.add(line); // Mark this line as logged
37
+ } else if (/Access URLs:/.test(line) && !loggedLines.has(line)) {
38
+ console.log(chalk.green("[Browsersync] Access URLs:"));
39
+ loggedLines.add(line);
40
+ } else if (/Local:/.test(line) && !loggedLines.has(line)) {
41
+ const localUrl = line.match(/Local:\s*(http:\/\/.+)/)[1];
42
+ formattedLog.local = localUrl;
43
+ console.log(chalk.white("Local: ") + chalk.cyanBright(localUrl));
44
+ loggedLines.add(line);
45
+ } else if (/^ {4}External:/.test(line) && !loggedLines.has(line)) {
46
+ const externalUrl = line.match(/External:\s*(http:\/\/\S+)/)[1];
47
+ formattedLog.external = externalUrl;
48
+ console.log(chalk.white("External: ") + chalk.magentaBright(externalUrl));
49
+ loggedLines.add(line);
50
+ } else if (/UI:/.test(line) && !loggedLines.has(line)) {
51
+ const uiUrl = line.match(/UI:\s*(http:\/\/.+)/)[1];
52
+ formattedLog.ui = uiUrl;
53
+ console.log(chalk.yellow("UI: ") + chalk.cyanBright(uiUrl));
54
+ loggedLines.add(line);
55
+ } else if (/UI External:/.test(line) && !loggedLines.has(line)) {
56
+ const uiExternalUrl = line.match(/UI External:\s*(http:\/\/.+)/)[1];
57
+ formattedLog.uiExternal = uiExternalUrl;
58
+ console.log(
59
+ chalk.yellow("UI External: ") + chalk.magentaBright(uiExternalUrl)
60
+ );
61
+ loggedLines.add(line);
62
+ } else if (/Watching files/.test(line) && !loggedLines.has(line)) {
63
+ console.log(chalk.blue("[Browsersync] Watching files..."));
64
+ const outputPath = "./settings/bs-output.json";
65
+ writeFileSync(outputPath, JSON.stringify(formattedLog, null, 2), "utf-8");
66
+ console.log(`Browser-sync output saved to ${outputPath}`);
67
+ loggedLines.add(line);
128
68
  }
129
69
  });
130
- }
70
+ });
71
+
72
+ // Log the output from stderr (error output)
73
+ devProcess.stderr.on("data", (data) => {
74
+ console.error(data.toString()); // Convert data to string
75
+ });
131
76
 
132
- startDev();
77
+ // Handle process exit
78
+ devProcess.on("exit", (code) => {
79
+ console.log(`Dev process exited with code ${code}`);
80
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.20.509",
3
+ "version": "1.20.511",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",