create-prisma-php-app 1.20.515 → 1.20.516

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
@@ -149,10 +149,8 @@ async function updatePackageJson(baseDir, answer) {
149
149
  updatedScripts.browserSync = browserSyncCommand;
150
150
  updatedScripts._dev =
151
151
  answersToInclude.length > 0
152
- ? `npm-run-all --parallel projectName browserSync ${answersToInclude.join(
153
- " "
154
- )}`
155
- : `npm-run-all --parallel projectName browserSync`;
152
+ ? `npm-run-all -p ${answersToInclude.join(" ")}`
153
+ : 'echo "No additional scripts to run"';
156
154
  updatedScripts.startDev = `node settings/start-dev.js`;
157
155
  updatedScripts.dev = `npm run startDev`;
158
156
  // Finally, assign the updated scripts back to packageJson
@@ -345,13 +343,17 @@ function modifyLayoutPHP(baseDir, answer) {
345
343
  if (checkExcludeFiles(layoutPath)) return;
346
344
  try {
347
345
  let indexContent = fs.readFileSync(layoutPath, "utf8");
348
- const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"></script>`;
346
+ const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>/css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>/js/index.js"></script>`;
349
347
  // Tailwind CSS link or CDN script
350
348
  const tailwindLink = answer.tailwindcss
351
- ? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
349
+ ? ` <link href="<?php echo $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
352
350
  : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
353
351
  // Insert before the closing </head> tag
354
- indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
352
+ indexContent = indexContent.replace(
353
+ "</head>",
354
+ `${tailwindLink}\n <!-- Dynamic Head -->\n
355
+ <?php echo implode("\n", $mainLayoutHead); ?></head>`
356
+ );
355
357
  fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
356
358
  console.log(
357
359
  chalk.green(
@@ -867,7 +869,7 @@ async function main() {
867
869
  answer = await getAnswer();
868
870
  }
869
871
  if (answer === null) {
870
- console.log(chalk.red("Installation cancelled."));
872
+ console.warn(chalk.red("Installation cancelled."));
871
873
  return;
872
874
  }
873
875
  const latestVersionOfCreatePrismaPhpApp = await fetchPackageVersion(
@@ -32,8 +32,8 @@ $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ||
32
32
  $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
33
33
  $domainName = $_SERVER['HTTP_HOST'];
34
34
  $scriptName = dirname($_SERVER['SCRIPT_NAME']) . '/';
35
- $baseUrl = $protocol . $domainName . rtrim($scriptName, '/') . '/src/app/';
36
- $documentUrl = $protocol . $domainName . rtrim($scriptName, '/') . '/';
35
+ $baseUrl = $protocol . $domainName . rtrim($scriptName, '/') . '/src/app';
36
+ $documentUrl = $protocol . $domainName . rtrim($scriptName, '/');
37
37
  $referer = $_SERVER['HTTP_REFERER'] ?? 'Unknown';
38
38
 
39
39
  $params = [];
@@ -1,73 +1,153 @@
1
1
  import { exec } from "child_process";
2
2
  import chalk from "chalk";
3
3
  import { writeFileSync } from "fs";
4
+ import readline from "readline";
4
5
 
5
- // Run the original dev command and capture the output
6
- const devProcess = exec("npm run _dev");
6
+ function runCommand(command, options = {}) {
7
+ return new Promise((resolve, reject) => {
8
+ const process = exec(command, options);
7
9
 
8
- // Use a Set to track logged lines to avoid duplicate logging
9
- const loggedLines = new Set();
10
+ let stdout = "";
11
+ let stderr = "";
10
12
 
11
- // Log the output from stdout (standard output)
12
- devProcess.stdout.on("data", (data) => {
13
- const dataString = data.toString(); // Ensure data is a string
13
+ process.stdout.on("data", (data) => {
14
+ stdout += data;
15
+ });
14
16
 
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
- }
17
+ process.stderr.on("data", (data) => {
18
+ stderr += data;
19
+ });
24
20
 
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)) {
35
- console.log(line.trim());
36
- } else if (/Access URLs:/.test(line)) {
37
- console.log(chalk.green("[Browsersync] Access URLs:"));
38
- } else if (/Local:/.test(line)) {
39
- const localUrl = line.match(/Local:\s*(http:\/\/.+)/)[1];
40
- formattedLog.local = localUrl;
41
- console.log(chalk.white("Local: ") + chalk.cyanBright(localUrl));
42
- } else if (/^ {4}External:/.test(line)) {
43
- const externalUrl = line.match(/External:\s*(http:\/\/\S+)/)[1];
44
- formattedLog.external = externalUrl;
45
- console.log(chalk.white("External: ") + chalk.magentaBright(externalUrl));
46
- } else if (/UI:/.test(line)) {
47
- const uiUrl = line.match(/UI:\s*(http:\/\/.+)/)[1];
48
- formattedLog.ui = uiUrl;
49
- console.log(chalk.yellow("UI: ") + chalk.cyanBright(uiUrl));
50
- } else if (/UI External:/.test(line)) {
51
- const uiExternalUrl = line.match(/UI External:\s*(http:\/\/.+)/)[1];
52
- formattedLog.uiExternal = uiExternalUrl;
53
- console.log(
54
- chalk.yellow("UI External: ") + chalk.magentaBright(uiExternalUrl)
55
- );
56
- } else if (/Watching files/.test(line)) {
57
- console.log(chalk.blue("[Browsersync] Watching files..."));
58
- const outputPath = "./settings/bs-output.json";
59
- writeFileSync(outputPath, JSON.stringify(formattedLog, null, 2), "utf-8");
60
- console.log(`Browser-sync output saved to ${outputPath}`);
61
- }
21
+ process.on("close", (code) => {
22
+ if (code === 0) {
23
+ resolve({ stdout, stderr });
24
+ } else {
25
+ reject(
26
+ new Error(`Command "${command}" exited with code ${code}\n${stderr}`)
27
+ );
28
+ }
29
+ });
62
30
  });
63
- });
31
+ }
32
+
33
+ async function startDev() {
34
+ try {
35
+ // Step 1: Start projectName and wait for it to complete
36
+ console.log("Starting projectName...");
37
+ const projectName = await runCommand("npm run projectName");
38
+ console.log(projectName.stdout);
39
+
40
+ // Step 2: Start browserSync and process its output
41
+ console.log("Starting browser-sync...");
42
+ const browserSync = exec("npm run browserSync");
43
+ let formattedLog = {
44
+ local: "",
45
+ external: "",
46
+ ui: "",
47
+ uiExternal: "",
48
+ };
49
+
50
+ const rl = readline.createInterface({
51
+ input: browserSync.stdout,
52
+ crlfDelay: Infinity,
53
+ });
54
+
55
+ let browserSyncReady = false;
56
+
57
+ rl.on("line", (line) => {
58
+ if (/Proxying/.test(line)) {
59
+ console.log(line.trim());
60
+ } else if (/Access URLs:/.test(line)) {
61
+ console.log(chalk.green("[Browsersync] Access URLs:"));
62
+ } else if (/Local:/.test(line)) {
63
+ const match = line.match(/Local:\s*(http:\/\/.+)/);
64
+ if (match) {
65
+ const localUrl = match[1];
66
+ formattedLog.local = localUrl;
67
+ console.log(chalk.white("Local: ") + chalk.cyanBright(localUrl));
68
+ }
69
+ } else if (/^ {4}External:/.test(line)) {
70
+ const match = line.match(/External:\s*(http:\/\/\S+)/);
71
+ if (match) {
72
+ const externalUrl = match[1];
73
+ formattedLog.external = externalUrl;
74
+ console.log(
75
+ chalk.white("External: ") + chalk.magentaBright(externalUrl)
76
+ );
77
+ }
78
+ } else if (/UI:/.test(line)) {
79
+ const match = line.match(/UI:\s*(http:\/\/.+)/);
80
+ if (match) {
81
+ const uiUrl = match[1];
82
+ formattedLog.ui = uiUrl;
83
+ console.log(chalk.yellow("UI: ") + chalk.cyanBright(uiUrl));
84
+ }
85
+ } else if (/UI External:/.test(line)) {
86
+ const match = line.match(/UI External:\s*(http:\/\/.+)/);
87
+ if (match) {
88
+ const uiExternalUrl = match[1];
89
+ formattedLog.uiExternal = uiExternalUrl;
90
+ console.log(
91
+ chalk.yellow("UI External: ") + chalk.magentaBright(uiExternalUrl)
92
+ );
93
+ }
94
+ } else if (/Watching files/.test(line)) {
95
+ console.log(`${chalk.blue("[Browsersync]")} Watching files...`);
96
+ const outputPath = "./settings/bs-output.json";
97
+ writeFileSync(
98
+ outputPath,
99
+ JSON.stringify(formattedLog, null, 2),
100
+ "utf-8"
101
+ );
102
+ console.log(`Browser-sync output saved to ${outputPath}`);
103
+
104
+ if (!browserSyncReady) {
105
+ browserSyncReady = true;
106
+ // Start _dev after browserSync is ready
107
+ startDevProcess();
108
+ }
109
+ } else if (/Reloading Browsers/.test(line)) {
110
+ console.log(`${chalk.blue("[Browsersync]")} Reloading Browsers...`);
111
+ } else {
112
+ // Print any other notifications
113
+ console.log(line);
114
+ }
115
+ });
64
116
 
65
- // Log the output from stderr (error output)
66
- devProcess.stderr.on("data", (data) => {
67
- console.error(data.toString()); // Convert data to string
68
- });
117
+ const rlErr = readline.createInterface({
118
+ input: browserSync.stderr,
119
+ crlfDelay: Infinity,
120
+ });
121
+
122
+ rlErr.on("line", (line) => {
123
+ console.error(`browser-sync error: ${line}`);
124
+ });
125
+
126
+ // Function to start _dev process
127
+ function startDevProcess() {
128
+ console.log("Starting _dev...");
129
+ const devProcess = exec("npm run _dev");
130
+
131
+ devProcess.stdout.on("data", (data) => {
132
+ process.stdout.write(data);
133
+ });
134
+
135
+ devProcess.stderr.on("data", (data) => {
136
+ process.stderr.write(data);
137
+ });
138
+
139
+ devProcess.on("close", (code) => {
140
+ console.log(`Dev process exited with code ${code}`);
141
+ });
142
+ }
143
+
144
+ // Handle browserSync close event
145
+ browserSync.on("close", (code) => {
146
+ console.log(`browserSync process exited with code ${code}`);
147
+ });
148
+ } catch (error) {
149
+ console.error("An error occurred:", error.message);
150
+ }
151
+ }
69
152
 
70
- // Handle process exit
71
- devProcess.on("exit", (code) => {
72
- console.log(`Dev process exited with code ${code}`);
73
- });
153
+ startDev();
@@ -6,11 +6,13 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <meta name="pp-description" content="<?php echo htmlspecialchars($metadata['description']); ?>">
8
8
  <title><?php echo htmlspecialchars($metadata['title']); ?></title>
9
- <link rel="icon" href="<?php echo $baseUrl; ?>favicon.ico" type="image/x-icon">
9
+ <link rel="icon" href="<?php echo $baseUrl; ?>\favicon.ico" type="image/x-icon">
10
10
  </head>
11
11
 
12
12
  <body>
13
13
  <?php echo $content; ?>
14
+ <!-- Dynamic Footer -->
15
+ <?php echo implode("\n", $mainLayoutFooter); ?>
14
16
  </body>
15
17
 
16
18
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.20.515",
3
+ "version": "1.20.516",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",