create-prisma-php-app 1.18.510 → 1.18.512

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
@@ -10,50 +10,45 @@ const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = path.dirname(__filename);
11
11
  let updateAnswer = null;
12
12
  function bsConfigUrls(projectRootPath) {
13
- // Identify the base path dynamically up to and including 'htdocs'
14
- const htdocsIndex = projectRootPath.indexOf("\\htdocs\\");
15
- if (htdocsIndex === -1) {
16
- console.error(
17
- "Invalid PROJECT_ROOT_PATH. The path does not contain \\htdocs\\"
18
- );
13
+ // Identify the base path dynamically up to and including 'htdocs'
14
+ const htdocsIndex = projectRootPath.indexOf("\\htdocs\\");
15
+ if (htdocsIndex === -1) {
16
+ console.error("Invalid PROJECT_ROOT_PATH. The path does not contain \\htdocs\\");
17
+ return {
18
+ bsTarget: "",
19
+ bsPathRewrite: {},
20
+ };
21
+ }
22
+ // Extract the path up to and including 'htdocs\\'
23
+ const basePathToRemove = projectRootPath.substring(0, htdocsIndex + "\\htdocs\\".length);
24
+ // Escape backslashes for the regex pattern
25
+ const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
26
+ // Remove the base path and replace backslashes with forward slashes for URL compatibility
27
+ const relativeWebPath = projectRootPath
28
+ .replace(new RegExp(`^${escapedBasePathToRemove}`), "")
29
+ .replace(/\\/g, "/");
30
+ // Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
31
+ let proxyUrl = `http://localhost/${relativeWebPath}`;
32
+ // Ensure the proxy URL does not end with a slash before appending '/public'
33
+ proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
34
+ // Clean the URL by replacing "//" with "/" but not affecting "http://"
35
+ // We replace instances of "//" that are not preceded by ":"
36
+ const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
37
+ const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
38
+ // Correct the relativeWebPath to ensure it does not start with a "/"
39
+ const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
40
+ ? cleanRelativeWebPath.substring(1)
41
+ : cleanRelativeWebPath;
19
42
  return {
20
- bsTarget: "",
21
- bsPathRewrite: {},
43
+ bsTarget: `${cleanUrl}/`,
44
+ bsPathRewrite: {
45
+ "^/": `/${adjustedRelativeWebPath}/`,
46
+ },
22
47
  };
23
- }
24
- // Extract the path up to and including 'htdocs\\'
25
- const basePathToRemove = projectRootPath.substring(
26
- 0,
27
- htdocsIndex + "\\htdocs\\".length
28
- );
29
- // Escape backslashes for the regex pattern
30
- const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
31
- // Remove the base path and replace backslashes with forward slashes for URL compatibility
32
- const relativeWebPath = projectRootPath
33
- .replace(new RegExp(`^${escapedBasePathToRemove}`), "")
34
- .replace(/\\/g, "/");
35
- // Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
36
- let proxyUrl = `http://localhost/${relativeWebPath}`;
37
- // Ensure the proxy URL does not end with a slash before appending '/public'
38
- proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
39
- // Clean the URL by replacing "//" with "/" but not affecting "http://"
40
- // We replace instances of "//" that are not preceded by ":"
41
- const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
42
- const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
43
- // Correct the relativeWebPath to ensure it does not start with a "/"
44
- const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
45
- ? cleanRelativeWebPath.substring(1)
46
- : cleanRelativeWebPath;
47
- return {
48
- bsTarget: `${cleanUrl}/`,
49
- bsPathRewrite: {
50
- "^/": `/${adjustedRelativeWebPath}/`,
51
- },
52
- };
53
48
  }
54
49
  function configureBrowserSyncCommand(baseDir) {
55
- // TypeScript content to write
56
- const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
50
+ // TypeScript content to write
51
+ const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
57
52
  const fs = require("fs");
58
53
 
59
54
  const jsonData = fs.readFileSync("prisma-php.json", "utf8");
@@ -79,356 +74,299 @@ module.exports = {
79
74
  open: false,
80
75
  ghostMode: false,
81
76
  };`;
82
- // Determine the path and write the bs-config.js
83
- const bsConfigPath = path.join(baseDir, "settings", "bs-config.cjs");
84
- fs.writeFileSync(bsConfigPath, bsConfigTsContent, "utf8");
85
- // Return the Browser Sync command string, using the cleaned URL
86
- return `browser-sync start --config settings/bs-config.cjs`;
77
+ // Determine the path and write the bs-config.js
78
+ const bsConfigPath = path.join(baseDir, "settings", "bs-config.cjs");
79
+ fs.writeFileSync(bsConfigPath, bsConfigTsContent, "utf8");
80
+ // Return the Browser Sync command string, using the cleaned URL
81
+ return `browser-sync start --config settings/bs-config.cjs`;
87
82
  }
88
83
  async function updatePackageJson(baseDir, answer) {
89
- const packageJsonPath = path.join(baseDir, "package.json");
90
- if (checkExcludeFiles(packageJsonPath)) return;
91
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
92
- // Use the new function to configure the Browser Sync command
93
- const browserSyncCommand = configureBrowserSyncCommand(baseDir);
94
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), {
95
- projectName: "node settings/project-name.cjs",
96
- });
97
- let answersToInclude = [];
98
- if (answer.tailwindcss) {
99
- packageJson.scripts = Object.assign(
100
- Object.assign({}, packageJson.scripts),
101
- {
102
- tailwind:
103
- "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch",
104
- }
105
- );
106
- answersToInclude.push("tailwind");
107
- }
108
- if (answer.websocket) {
109
- packageJson.scripts = Object.assign(
110
- Object.assign({}, packageJson.scripts),
111
- { websocket: "node ./settings/restart-websocket.cjs" }
112
- );
113
- answersToInclude.push("websocket");
114
- }
115
- // if (answer.prisma) {
116
- // packageJson.scripts = {
117
- // ...packageJson.scripts,
118
- // postinstall: "prisma generate",
119
- // };
120
- // }
121
- if (answer.docker) {
122
- packageJson.scripts = Object.assign(
123
- Object.assign({}, packageJson.scripts),
124
- { docker: "docker-compose up" }
125
- );
126
- answersToInclude.push("docker");
127
- }
128
- // Initialize with existing scripts
129
- const updatedScripts = Object.assign({}, packageJson.scripts);
130
- // Conditionally add "browser-sync" command
131
- updatedScripts["browser-sync"] = browserSyncCommand;
132
- // Conditionally set the "dev" command
133
- updatedScripts.dev =
134
- answersToInclude.length > 0
135
- ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(
136
- " "
137
- )}`
138
- : `npm-run-all --parallel projectName browser-sync`;
139
- // Finally, assign the updated scripts back to packageJson
140
- packageJson.scripts = updatedScripts;
141
- packageJson.type = "module";
142
- if (answer.prisma)
143
- packageJson.prisma = {
144
- seed: "node prisma/seed.js",
145
- };
146
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
84
+ const packageJsonPath = path.join(baseDir, "package.json");
85
+ if (checkExcludeFiles(packageJsonPath))
86
+ return;
87
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
88
+ // Use the new function to configure the Browser Sync command
89
+ const browserSyncCommand = configureBrowserSyncCommand(baseDir);
90
+ packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { projectName: "node settings/project-name.cjs" });
91
+ let answersToInclude = [];
92
+ if (answer.tailwindcss) {
93
+ packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { tailwind: "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch" });
94
+ answersToInclude.push("tailwind");
95
+ }
96
+ if (answer.websocket) {
97
+ packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { websocket: "node ./settings/restart-websocket.cjs" });
98
+ answersToInclude.push("websocket");
99
+ }
100
+ // if (answer.prisma) {
101
+ // packageJson.scripts = {
102
+ // ...packageJson.scripts,
103
+ // postinstall: "prisma generate",
104
+ // };
105
+ // }
106
+ if (answer.docker) {
107
+ packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { docker: "docker-compose up" });
108
+ answersToInclude.push("docker");
109
+ }
110
+ // Initialize with existing scripts
111
+ const updatedScripts = Object.assign({}, packageJson.scripts);
112
+ // Conditionally add "browser-sync" command
113
+ updatedScripts["browser-sync"] = browserSyncCommand;
114
+ // Conditionally set the "dev" command
115
+ updatedScripts.dev =
116
+ answersToInclude.length > 0
117
+ ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(" ")}`
118
+ : `npm-run-all --parallel projectName browser-sync`;
119
+ // Finally, assign the updated scripts back to packageJson
120
+ packageJson.scripts = updatedScripts;
121
+ packageJson.type = "module";
122
+ if (answer.prisma)
123
+ packageJson.prisma = {
124
+ seed: "node prisma/seed.js",
125
+ };
126
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
147
127
  }
148
128
  async function updateComposerJson(baseDir, answer) {
149
- const composerJsonPath = path.join(baseDir, "composer.json");
150
- if (checkExcludeFiles(composerJsonPath)) return;
151
- let composerJson;
152
- // Check if the composer.json file exists
153
- if (fs.existsSync(composerJsonPath)) {
154
- // Read the current composer.json content
155
- const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
156
- composerJson = JSON.parse(composerJsonContent);
157
- } else {
158
- console.error("composer.json does not exist.");
159
- return;
160
- }
161
- // Conditionally add WebSocket dependency
162
- if (answer.websocket) {
163
- composerJson.require = Object.assign(
164
- Object.assign({}, composerJson.require),
165
- { "cboden/ratchet": "^0.4.4" }
166
- );
167
- }
168
- if (answer.prisma) {
169
- composerJson.require = Object.assign(
170
- Object.assign({}, composerJson.require),
171
- { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" }
172
- );
173
- }
174
- // Write the modified composer.json back to the file
175
- fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
176
- console.log("composer.json updated successfully.");
129
+ const composerJsonPath = path.join(baseDir, "composer.json");
130
+ if (checkExcludeFiles(composerJsonPath))
131
+ return;
132
+ let composerJson;
133
+ // Check if the composer.json file exists
134
+ if (fs.existsSync(composerJsonPath)) {
135
+ // Read the current composer.json content
136
+ const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
137
+ composerJson = JSON.parse(composerJsonContent);
138
+ }
139
+ else {
140
+ console.error("composer.json does not exist.");
141
+ return;
142
+ }
143
+ // Conditionally add WebSocket dependency
144
+ if (answer.websocket) {
145
+ composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "cboden/ratchet": "^0.4.4" });
146
+ }
147
+ if (answer.prisma) {
148
+ composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" });
149
+ }
150
+ // Write the modified composer.json back to the file
151
+ fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
152
+ console.log("composer.json updated successfully.");
177
153
  }
178
154
  async function updateIndexJsForWebSocket(baseDir, answer) {
179
- if (!answer.websocket) {
180
- return;
181
- }
182
- const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
183
- if (checkExcludeFiles(indexPath)) return;
184
- let indexContent = fs.readFileSync(indexPath, "utf8");
185
- // WebSocket initialization code to be appended
186
- const webSocketCode = `
155
+ if (!answer.websocket) {
156
+ return;
157
+ }
158
+ const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
159
+ if (checkExcludeFiles(indexPath))
160
+ return;
161
+ let indexContent = fs.readFileSync(indexPath, "utf8");
162
+ // WebSocket initialization code to be appended
163
+ const webSocketCode = `
187
164
  // WebSocket initialization
188
165
  const ws = new WebSocket("ws://localhost:8080");
189
166
  `;
190
- // Append WebSocket code if user chose to use WebSocket
191
- indexContent += webSocketCode;
192
- fs.writeFileSync(indexPath, indexContent, "utf8");
193
- console.log("WebSocket code added to index.js successfully.");
167
+ // Append WebSocket code if user chose to use WebSocket
168
+ indexContent += webSocketCode;
169
+ fs.writeFileSync(indexPath, indexContent, "utf8");
170
+ console.log("WebSocket code added to index.js successfully.");
194
171
  }
195
172
  // This function updates the .gitignore file
196
173
  async function createUpdateGitignoreFile(baseDir, additions) {
197
- const gitignorePath = path.join(baseDir, ".gitignore");
198
- if (checkExcludeFiles(gitignorePath)) return;
199
- let gitignoreContent = "";
200
- additions.forEach((addition) => {
201
- if (!gitignoreContent.includes(addition)) {
202
- gitignoreContent += `\n${addition}`;
203
- }
204
- });
205
- // Ensure there's no leading newline if the file was just created
206
- gitignoreContent = gitignoreContent.trimStart();
207
- fs.writeFileSync(gitignorePath, gitignoreContent);
174
+ const gitignorePath = path.join(baseDir, ".gitignore");
175
+ if (checkExcludeFiles(gitignorePath))
176
+ return;
177
+ let gitignoreContent = "";
178
+ additions.forEach((addition) => {
179
+ if (!gitignoreContent.includes(addition)) {
180
+ gitignoreContent += `\n${addition}`;
181
+ }
182
+ });
183
+ // Ensure there's no leading newline if the file was just created
184
+ gitignoreContent = gitignoreContent.trimStart();
185
+ fs.writeFileSync(gitignorePath, gitignoreContent);
208
186
  }
209
187
  // Recursive copy function
210
188
  function copyRecursiveSync(src, dest, answer) {
211
- var _a;
212
- console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
213
- console.log("🚀 ~ copyRecursiveSync ~ src:", src);
214
- const exists = fs.existsSync(src);
215
- const stats = exists && fs.statSync(src);
216
- const isDirectory = exists && stats && stats.isDirectory();
217
- if (isDirectory) {
218
- const destLower = dest.toLowerCase();
219
- if (!answer.websocket && destLower.includes("src\\lib\\websocket")) return;
220
- if (!answer.prisma && destLower.includes("src\\lib\\prisma")) return;
221
- if (
222
- (answer.backendOnly && destLower.includes("src\\app\\js")) ||
223
- (answer.backendOnly && destLower.includes("src\\app\\css"))
224
- )
225
- return;
226
- const destModified = dest.replace(/\\/g, "/");
227
- if (
228
- (_a =
229
- updateAnswer === null || updateAnswer === void 0
230
- ? void 0
231
- : updateAnswer.excludeFilePath) === null || _a === void 0
232
- ? void 0
233
- : _a.includes(destModified)
234
- )
235
- return;
236
- if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
237
- fs.readdirSync(src).forEach((childItemName) => {
238
- copyRecursiveSync(
239
- path.join(src, childItemName),
240
- path.join(dest, childItemName),
241
- answer
242
- );
243
- });
244
- } else {
245
- if (checkExcludeFiles(dest)) return;
246
- if (
247
- !answer.tailwindcss &&
248
- (dest.includes("tailwind.css") || dest.includes("styles.css"))
249
- )
250
- return;
251
- if (
252
- !answer.websocket &&
253
- (dest.includes("restart-websocket.cjs") ||
254
- dest.includes("restart-websocket.bat"))
255
- )
256
- return;
257
- if (
258
- !answer.docker &&
259
- (dest.includes(".dockerignore") ||
260
- dest.includes("docker-compose.yml") ||
261
- dest.includes("Dockerfile") ||
262
- dest.includes("apache.conf"))
263
- )
264
- return;
265
- if (
266
- (answer.backendOnly && dest.includes("favicon.ico")) ||
267
- (answer.backendOnly && dest.includes("index.php")) ||
268
- (answer.backendOnly && dest.includes("layout.php")) ||
269
- (answer.backendOnly && dest.includes("metadata.php")) ||
270
- (answer.backendOnly && dest.includes("not-found.php"))
271
- )
272
- return;
273
- if (!answer.backendOnly && dest.includes("route.php")) return;
274
- fs.copyFileSync(src, dest, 0);
275
- }
189
+ var _a;
190
+ console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
191
+ console.log("🚀 ~ copyRecursiveSync ~ src:", src);
192
+ const exists = fs.existsSync(src);
193
+ const stats = exists && fs.statSync(src);
194
+ const isDirectory = exists && stats && stats.isDirectory();
195
+ if (isDirectory) {
196
+ const destLower = dest.toLowerCase();
197
+ if (!answer.websocket && destLower.includes("src\\lib\\websocket"))
198
+ return;
199
+ if (!answer.prisma && destLower.includes("src\\lib\\prisma"))
200
+ return;
201
+ if ((answer.backendOnly && destLower.includes("src\\app\\js")) ||
202
+ (answer.backendOnly && destLower.includes("src\\app\\css")))
203
+ return;
204
+ const destModified = dest.replace(/\\/g, "/");
205
+ if ((_a = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFilePath) === null || _a === void 0 ? void 0 : _a.includes(destModified))
206
+ return;
207
+ if (!fs.existsSync(dest))
208
+ fs.mkdirSync(dest, { recursive: true });
209
+ fs.readdirSync(src).forEach((childItemName) => {
210
+ copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName), answer);
211
+ });
212
+ }
213
+ else {
214
+ if (checkExcludeFiles(dest))
215
+ return;
216
+ if (!answer.tailwindcss &&
217
+ (dest.includes("tailwind.css") || dest.includes("styles.css")))
218
+ return;
219
+ if (!answer.websocket &&
220
+ (dest.includes("restart-websocket.cjs") ||
221
+ dest.includes("restart-websocket.bat")))
222
+ return;
223
+ if (!answer.docker &&
224
+ (dest.includes(".dockerignore") ||
225
+ dest.includes("docker-compose.yml") ||
226
+ dest.includes("Dockerfile") ||
227
+ dest.includes("apache.conf")))
228
+ return;
229
+ if ((answer.backendOnly && dest.includes("favicon.ico")) ||
230
+ (answer.backendOnly && dest.includes("index.php")) ||
231
+ (answer.backendOnly && dest.includes("layout.php")) ||
232
+ (answer.backendOnly && dest.includes("metadata.php")) ||
233
+ (answer.backendOnly && dest.includes("not-found.php")))
234
+ return;
235
+ if (!answer.backendOnly && dest.includes("route.php"))
236
+ return;
237
+ fs.copyFileSync(src, dest, 0);
238
+ }
276
239
  }
277
240
  // Function to execute the recursive copy for entire directories
278
241
  async function executeCopy(baseDir, directoriesToCopy, answer) {
279
- directoriesToCopy.forEach(({ srcDir, destDir }) => {
280
- const sourcePath = path.join(__dirname, srcDir);
281
- const destPath = path.join(baseDir, destDir);
282
- copyRecursiveSync(sourcePath, destPath, answer);
283
- });
242
+ directoriesToCopy.forEach(({ srcDir, destDir }) => {
243
+ const sourcePath = path.join(__dirname, srcDir);
244
+ const destPath = path.join(baseDir, destDir);
245
+ copyRecursiveSync(sourcePath, destPath, answer);
246
+ });
284
247
  }
285
248
  function createOrUpdateTailwindConfig(baseDir) {
286
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
287
- const filePath = path.join(baseDir, "tailwind.config.js");
288
- if (checkExcludeFiles(filePath)) return;
289
- const newContent = [
290
- "./src/app/**/*.{html,js,php}",
291
- // Add more paths as needed
292
- ];
293
- let configData = fs.readFileSync(filePath, "utf8");
294
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
295
- const contentArrayString = newContent
296
- .map((item) => ` "${item}"`)
297
- .join(",\n");
298
- configData = configData.replace(
299
- /content: \[\],/g,
300
- `content: [\n${contentArrayString}\n],`
301
- );
302
- fs.writeFileSync(filePath, configData, { flag: "w" });
303
- console.log(chalk.green("Tailwind configuration updated successfully."));
249
+ console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
250
+ const filePath = path.join(baseDir, "tailwind.config.js");
251
+ if (checkExcludeFiles(filePath))
252
+ return;
253
+ const newContent = [
254
+ "./src/app/**/*.{html,js,php}",
255
+ // Add more paths as needed
256
+ ];
257
+ let configData = fs.readFileSync(filePath, "utf8");
258
+ console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
259
+ const contentArrayString = newContent
260
+ .map((item) => ` "${item}"`)
261
+ .join(",\n");
262
+ configData = configData.replace(/content: \[\],/g, `content: [\n${contentArrayString}\n],`);
263
+ fs.writeFileSync(filePath, configData, { flag: "w" });
264
+ console.log(chalk.green("Tailwind configuration updated successfully."));
304
265
  }
305
266
  function modifyPostcssConfig(baseDir) {
306
- const filePath = path.join(baseDir, "postcss.config.js");
307
- if (checkExcludeFiles(filePath)) return;
308
- const newContent = `export default {
267
+ const filePath = path.join(baseDir, "postcss.config.js");
268
+ if (checkExcludeFiles(filePath))
269
+ return;
270
+ const newContent = `export default {
309
271
  plugins: {
310
272
  tailwindcss: {},
311
273
  autoprefixer: {},
312
274
  cssnano: {},
313
275
  },
314
276
  };`;
315
- fs.writeFileSync(filePath, newContent, { flag: "w" });
316
- console.log(chalk.green("postcss.config.js updated successfully."));
277
+ fs.writeFileSync(filePath, newContent, { flag: "w" });
278
+ console.log(chalk.green("postcss.config.js updated successfully."));
317
279
  }
318
280
  function modifyLayoutPHP(baseDir, answer) {
319
- const layoutPath = path.join(baseDir, "src", "app", "layout.php");
320
- if (checkExcludeFiles(layoutPath)) return;
321
- try {
322
- let indexContent = fs.readFileSync(layoutPath, "utf8");
323
- const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"></script>`;
324
- // Tailwind CSS link or CDN script
325
- const tailwindLink = answer.tailwindcss
326
- ? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
327
- : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
328
- // Insert before the closing </head> tag
329
- indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
330
- fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
331
- console.log(
332
- chalk.green(
333
- `layout.php modified successfully for ${
334
- answer.tailwindcss ? "local Tailwind CSS" : "Tailwind CSS CDN"
335
- }.`
336
- )
337
- );
338
- } catch (error) {
339
- console.error(chalk.red("Error modifying layout.php:"), error);
340
- }
281
+ const layoutPath = path.join(baseDir, "src", "app", "layout.php");
282
+ if (checkExcludeFiles(layoutPath))
283
+ return;
284
+ try {
285
+ let indexContent = fs.readFileSync(layoutPath, "utf8");
286
+ const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"></script>`;
287
+ // Tailwind CSS link or CDN script
288
+ const tailwindLink = answer.tailwindcss
289
+ ? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
290
+ : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
291
+ // Insert before the closing </head> tag
292
+ indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
293
+ fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
294
+ console.log(chalk.green(`layout.php modified successfully for ${answer.tailwindcss ? "local Tailwind CSS" : "Tailwind CSS CDN"}.`));
295
+ }
296
+ catch (error) {
297
+ console.error(chalk.red("Error modifying layout.php:"), error);
298
+ }
341
299
  }
342
300
  // This function updates or creates the .env file
343
301
  async function createOrUpdateEnvFile(baseDir, content) {
344
- const envPath = path.join(baseDir, ".env");
345
- if (checkExcludeFiles(envPath)) return;
346
- console.log("🚀 ~ content:", content);
347
- fs.writeFileSync(envPath, content, { flag: "w" });
302
+ const envPath = path.join(baseDir, ".env");
303
+ if (checkExcludeFiles(envPath))
304
+ return;
305
+ console.log("🚀 ~ content:", content);
306
+ fs.writeFileSync(envPath, content, { flag: "w" });
348
307
  }
349
308
  function checkExcludeFiles(destPath) {
350
- var _a, _b;
351
- if (
352
- !(updateAnswer === null || updateAnswer === void 0
353
- ? void 0
354
- : updateAnswer.isUpdate)
355
- )
356
- return false;
357
- return (_b =
358
- (_a =
359
- updateAnswer === null || updateAnswer === void 0
360
- ? void 0
361
- : updateAnswer.excludeFilePath) === null || _a === void 0
362
- ? void 0
363
- : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0
364
- ? _b
365
- : false;
309
+ var _a, _b;
310
+ if (!(updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate))
311
+ return false;
312
+ return ((_b = (_a = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFilePath) === null || _a === void 0 ? void 0 : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0 ? _b : false);
366
313
  }
367
314
  async function createDirectoryStructure(baseDir, answer) {
368
- console.log("🚀 ~ baseDir:", baseDir);
369
- console.log("🚀 ~ answer:", answer);
370
- const filesToCopy = [
371
- { src: "/bootstrap.php", dest: "/bootstrap.php" },
372
- { src: "/.htaccess", dest: "/.htaccess" },
373
- { src: "/../composer.json", dest: "/composer.json" },
374
- ];
375
- if (
376
- updateAnswer === null || updateAnswer === void 0
377
- ? void 0
378
- : updateAnswer.isUpdate
379
- ) {
380
- filesToCopy.push({ src: "/tsconfig.json", dest: "/tsconfig.json" });
381
- if (updateAnswer.tailwindcss) {
382
- filesToCopy.push(
383
- { src: "/postcss.config.js", dest: "/postcss.config.js" },
384
- { src: "/tailwind.config.js", dest: "/tailwind.config.js" }
385
- );
315
+ console.log("🚀 ~ baseDir:", baseDir);
316
+ console.log("🚀 ~ answer:", answer);
317
+ const filesToCopy = [
318
+ { src: "/bootstrap.php", dest: "/bootstrap.php" },
319
+ { src: "/.htaccess", dest: "/.htaccess" },
320
+ { src: "/../composer.json", dest: "/composer.json" },
321
+ ];
322
+ if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
323
+ filesToCopy.push({ src: "/tsconfig.json", dest: "/tsconfig.json" });
324
+ if (updateAnswer.tailwindcss) {
325
+ filesToCopy.push({ src: "/postcss.config.js", dest: "/postcss.config.js" }, { src: "/tailwind.config.js", dest: "/tailwind.config.js" });
326
+ }
386
327
  }
387
- }
388
- const directoriesToCopy = [
389
- {
390
- srcDir: "/settings",
391
- destDir: "/settings",
392
- },
393
- {
394
- srcDir: "/src",
395
- destDir: "/src",
396
- },
397
- ];
398
- if (answer.prisma) {
399
- directoriesToCopy.push({
400
- srcDir: "/prisma",
401
- destDir: "/prisma",
328
+ const directoriesToCopy = [
329
+ {
330
+ srcDir: "/settings",
331
+ destDir: "/settings",
332
+ },
333
+ {
334
+ srcDir: "/src",
335
+ destDir: "/src",
336
+ },
337
+ ];
338
+ if (answer.prisma) {
339
+ directoriesToCopy.push({
340
+ srcDir: "/prisma",
341
+ destDir: "/prisma",
342
+ });
343
+ }
344
+ if (answer.docker) {
345
+ directoriesToCopy.push({ srcDir: "/.dockerignore", destDir: "/.dockerignore" }, { srcDir: "/docker-compose.yml", destDir: "/docker-compose.yml" }, { srcDir: "/Dockerfile", destDir: "/Dockerfile" }, { srcDir: "/apache.conf", destDir: "/apache.conf" });
346
+ }
347
+ console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
348
+ filesToCopy.forEach(({ src, dest }) => {
349
+ const sourcePath = path.join(__dirname, src);
350
+ const destPath = path.join(baseDir, dest);
351
+ if (checkExcludeFiles(destPath))
352
+ return;
353
+ const code = fs.readFileSync(sourcePath, "utf8");
354
+ fs.writeFileSync(destPath, code, { flag: "w" });
402
355
  });
403
- }
404
- if (answer.docker) {
405
- directoriesToCopy.push(
406
- { srcDir: "/.dockerignore", destDir: "/.dockerignore" },
407
- { srcDir: "/docker-compose.yml", destDir: "/docker-compose.yml" },
408
- { srcDir: "/Dockerfile", destDir: "/Dockerfile" },
409
- { srcDir: "/apache.conf", destDir: "/apache.conf" }
410
- );
411
- }
412
- console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
413
- filesToCopy.forEach(({ src, dest }) => {
414
- const sourcePath = path.join(__dirname, src);
415
- const destPath = path.join(baseDir, dest);
416
- if (checkExcludeFiles(destPath)) return;
417
- const code = fs.readFileSync(sourcePath, "utf8");
418
- fs.writeFileSync(destPath, code, { flag: "w" });
419
- });
420
- await executeCopy(baseDir, directoriesToCopy, answer);
421
- await updatePackageJson(baseDir, answer);
422
- await updateComposerJson(baseDir, answer);
423
- await updateIndexJsForWebSocket(baseDir, answer);
424
- if (answer.tailwindcss) {
425
- createOrUpdateTailwindConfig(baseDir);
426
- modifyLayoutPHP(baseDir, answer);
427
- modifyPostcssConfig(baseDir);
428
- } else {
429
- if (!answer.backendOnly) modifyLayoutPHP(baseDir, answer);
430
- }
431
- const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
356
+ await executeCopy(baseDir, directoriesToCopy, answer);
357
+ await updatePackageJson(baseDir, answer);
358
+ await updateComposerJson(baseDir, answer);
359
+ await updateIndexJsForWebSocket(baseDir, answer);
360
+ if (answer.tailwindcss) {
361
+ createOrUpdateTailwindConfig(baseDir);
362
+ modifyLayoutPHP(baseDir, answer);
363
+ modifyPostcssConfig(baseDir);
364
+ }
365
+ else {
366
+ if (!answer.backendOnly)
367
+ modifyLayoutPHP(baseDir, answer);
368
+ }
369
+ const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
432
370
  AUTH_SECRET=uxsjXVPHN038DEYls2Kw0QUgBcXKUyrjv416nIFWPY4=
433
371
 
434
372
  # PHPMailer
@@ -445,164 +383,143 @@ SHOW_ERRORS=true
445
383
 
446
384
  # ChatGPT API Key
447
385
  # CHATGPT_API_KEY=sk-your-api-key`;
448
- if (answer.prisma) {
449
- const prismaEnvContent = `# Environment variables declared in this file are automatically made available to Prisma.
386
+ if (answer.prisma) {
387
+ const prismaEnvContent = `# Environment variables declared in this file are automatically made available to Prisma.
450
388
  # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
451
389
 
452
390
  # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
453
391
  # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
454
392
 
455
393
  DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"`;
456
- const envContent = `${prismaEnvContent}\n\n${prismaPHPEnvContent}`;
457
- await createOrUpdateEnvFile(baseDir, envContent);
458
- } else {
459
- await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
460
- }
461
- // Add vendor to .gitignore
462
- await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
394
+ const envContent = `${prismaEnvContent}\n\n${prismaPHPEnvContent}`;
395
+ await createOrUpdateEnvFile(baseDir, envContent);
396
+ }
397
+ else {
398
+ await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
399
+ }
400
+ // Add vendor to .gitignore
401
+ await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
463
402
  }
464
403
  async function getAnswer(predefinedAnswers = {}) {
465
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
466
- console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
467
- const questionsArray = [];
468
- if (!predefinedAnswers.projectName) {
469
- questionsArray.push({
470
- type: "text",
471
- name: "projectName",
472
- message: "What is your project named?",
473
- initial: "my-app",
474
- });
475
- }
476
- if (!predefinedAnswers.backendOnly) {
477
- questionsArray.push({
478
- type: "toggle",
479
- name: "backendOnly",
480
- message: "Would you like to create a backend-only project?",
481
- initial: false,
482
- active: "Yes",
483
- inactive: "No",
484
- });
485
- }
486
- const nonBackendOnlyQuestionsArray = [];
487
- if (!predefinedAnswers.websocket) {
488
- nonBackendOnlyQuestionsArray.push({
489
- type: "toggle",
490
- name: "websocket",
491
- message: `Would you like to use ${chalk.blue("Websocket")}?`,
492
- initial: true,
493
- active: "Yes",
494
- inactive: "No",
495
- });
496
- }
497
- if (!predefinedAnswers.prisma) {
498
- nonBackendOnlyQuestionsArray.push({
499
- type: "toggle",
500
- name: "prisma",
501
- message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
502
- initial: true,
503
- active: "Yes",
504
- inactive: "No",
505
- });
506
- }
507
- if (!predefinedAnswers.docker) {
508
- nonBackendOnlyQuestionsArray.push({
509
- type: "toggle",
510
- name: "docker",
511
- message: `Would you like to use ${chalk.blue("Docker")}?`,
512
- initial: false,
513
- active: "Yes",
514
- inactive: "No",
404
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
405
+ console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
406
+ const questionsArray = [];
407
+ if (!predefinedAnswers.projectName) {
408
+ questionsArray.push({
409
+ type: "text",
410
+ name: "projectName",
411
+ message: "What is your project named?",
412
+ initial: "my-app",
413
+ });
414
+ }
415
+ if (!predefinedAnswers.backendOnly) {
416
+ questionsArray.push({
417
+ type: "toggle",
418
+ name: "backendOnly",
419
+ message: "Would you like to create a backend-only project?",
420
+ initial: false,
421
+ active: "Yes",
422
+ inactive: "No",
423
+ });
424
+ }
425
+ // Execute the initial questionsArray first
426
+ const onCancel = () => {
427
+ console.log(chalk.red("Operation cancelled by the user."));
428
+ process.exit(0);
429
+ };
430
+ const initialResponse = await prompts(questionsArray, { onCancel });
431
+ console.log("🚀 ~ initialResponse:", initialResponse);
432
+ const nonBackendOnlyQuestionsArray = [];
433
+ if (initialResponse.backendOnly || predefinedAnswers.backendOnly) {
434
+ // If it's a backend-only project, skip Tailwind CSS, but ask other questions
435
+ if (!predefinedAnswers.websocket) {
436
+ nonBackendOnlyQuestionsArray.push({
437
+ type: "toggle",
438
+ name: "websocket",
439
+ message: `Would you like to use ${chalk.blue("Websocket")}?`,
440
+ initial: true,
441
+ active: "Yes",
442
+ inactive: "No",
443
+ });
444
+ }
445
+ if (!predefinedAnswers.prisma) {
446
+ nonBackendOnlyQuestionsArray.push({
447
+ type: "toggle",
448
+ name: "prisma",
449
+ message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
450
+ initial: true,
451
+ active: "Yes",
452
+ inactive: "No",
453
+ });
454
+ }
455
+ if (!predefinedAnswers.docker) {
456
+ nonBackendOnlyQuestionsArray.push({
457
+ type: "toggle",
458
+ name: "docker",
459
+ message: `Would you like to use ${chalk.blue("Docker")}?`,
460
+ initial: false,
461
+ active: "Yes",
462
+ inactive: "No",
463
+ });
464
+ }
465
+ }
466
+ else {
467
+ // If it's not a backend-only project, ask Tailwind CSS as well
468
+ if (!predefinedAnswers.tailwindcss) {
469
+ nonBackendOnlyQuestionsArray.unshift({
470
+ type: "toggle",
471
+ name: "tailwindcss",
472
+ message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
473
+ initial: true,
474
+ active: "Yes",
475
+ inactive: "No",
476
+ });
477
+ }
478
+ if (!predefinedAnswers.websocket) {
479
+ nonBackendOnlyQuestionsArray.push({
480
+ type: "toggle",
481
+ name: "websocket",
482
+ message: `Would you like to use ${chalk.blue("Websocket")}?`,
483
+ initial: true,
484
+ active: "Yes",
485
+ inactive: "No",
486
+ });
487
+ }
488
+ if (!predefinedAnswers.prisma) {
489
+ nonBackendOnlyQuestionsArray.push({
490
+ type: "toggle",
491
+ name: "prisma",
492
+ message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
493
+ initial: true,
494
+ active: "Yes",
495
+ inactive: "No",
496
+ });
497
+ }
498
+ if (!predefinedAnswers.docker) {
499
+ nonBackendOnlyQuestionsArray.push({
500
+ type: "toggle",
501
+ name: "docker",
502
+ message: `Would you like to use ${chalk.blue("Docker")}?`,
503
+ initial: false,
504
+ active: "Yes",
505
+ inactive: "No",
506
+ });
507
+ }
508
+ }
509
+ const nonBackendOnlyResponse = await prompts(nonBackendOnlyQuestionsArray, {
510
+ onCancel,
515
511
  });
516
- }
517
- // Execute the questionsArray first to determine the backendOnly option const questions: PromptObject<string>[] =
518
- questionsArray;
519
- console.log("🚀 ~ questions:", questionsArray);
520
- if (questionsArray.length === 0 && predefinedAnswers.projectName) {
521
- return predefinedAnswers;
522
- }
523
- const onCancel = () => {
524
- console.log(chalk.red("Operation cancelled by the user."));
525
- process.exit(0);
526
- };
527
- const initialResponse = await prompts(questionsArray, { onCancel });
528
- console.log("🚀 ~ initialResponse:", initialResponse);
529
- if (initialResponse.backendOnly) {
512
+ console.log("🚀 ~ nonBackendOnlyResponse:", nonBackendOnlyResponse);
530
513
  return {
531
- projectName: initialResponse.projectName
532
- ? String(initialResponse.projectName).trim().replace(/ /g, "-")
533
- : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
534
- ? _a
535
- : "my-app",
536
- backendOnly: initialResponse.backendOnly,
537
- tailwindcss: false, // Automatically set to false if backendOnly is true
538
- websocket:
539
- (_b = predefinedAnswers.websocket) !== null && _b !== void 0
540
- ? _b
541
- : false,
542
- prisma:
543
- (_c = predefinedAnswers.prisma) !== null && _c !== void 0 ? _c : false,
544
- docker:
545
- (_d = predefinedAnswers.docker) !== null && _d !== void 0 ? _d : false,
514
+ projectName: initialResponse.projectName
515
+ ? String(initialResponse.projectName).trim().replace(/ /g, "-")
516
+ : (_a = predefinedAnswers.projectName) !== null && _a !== void 0 ? _a : "my-app",
517
+ backendOnly: (_c = (_b = initialResponse.backendOnly) !== null && _b !== void 0 ? _b : predefinedAnswers.backendOnly) !== null && _c !== void 0 ? _c : false,
518
+ tailwindcss: (_e = (_d = nonBackendOnlyResponse.tailwindcss) !== null && _d !== void 0 ? _d : predefinedAnswers.tailwindcss) !== null && _e !== void 0 ? _e : false,
519
+ websocket: (_g = (_f = nonBackendOnlyResponse.websocket) !== null && _f !== void 0 ? _f : predefinedAnswers.websocket) !== null && _g !== void 0 ? _g : false,
520
+ prisma: (_j = (_h = nonBackendOnlyResponse.prisma) !== null && _h !== void 0 ? _h : predefinedAnswers.prisma) !== null && _j !== void 0 ? _j : false,
521
+ docker: (_l = (_k = nonBackendOnlyResponse.docker) !== null && _k !== void 0 ? _k : predefinedAnswers.docker) !== null && _l !== void 0 ? _l : false,
546
522
  };
547
- }
548
- // If it's not backend-only, add Tailwind CSS question to the front of nonBackendOnlyQuestionsArray
549
- if (!predefinedAnswers.tailwindcss) {
550
- nonBackendOnlyQuestionsArray.unshift({
551
- type: "toggle",
552
- name: "tailwindcss",
553
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
554
- initial: true,
555
- active: "Yes",
556
- inactive: "No",
557
- });
558
- }
559
- // Now ask the rest of the questions
560
- const nonBackendOnlyResponse = await prompts(nonBackendOnlyQuestionsArray, {
561
- onCancel,
562
- });
563
- console.log("🚀 ~ nonBackendOnlyResponse:", nonBackendOnlyResponse);
564
- return {
565
- projectName: initialResponse.projectName
566
- ? String(initialResponse.projectName).trim().replace(/ /g, "-")
567
- : (_e = predefinedAnswers.projectName) !== null && _e !== void 0
568
- ? _e
569
- : "my-app",
570
- backendOnly:
571
- (_g =
572
- (_f = initialResponse.backendOnly) !== null && _f !== void 0
573
- ? _f
574
- : predefinedAnswers.backendOnly) !== null && _g !== void 0
575
- ? _g
576
- : false,
577
- tailwindcss:
578
- (_j =
579
- (_h = nonBackendOnlyResponse.tailwindcss) !== null && _h !== void 0
580
- ? _h
581
- : predefinedAnswers.tailwindcss) !== null && _j !== void 0
582
- ? _j
583
- : false,
584
- websocket:
585
- (_l =
586
- (_k = nonBackendOnlyResponse.websocket) !== null && _k !== void 0
587
- ? _k
588
- : predefinedAnswers.websocket) !== null && _l !== void 0
589
- ? _l
590
- : false,
591
- prisma:
592
- (_o =
593
- (_m = nonBackendOnlyResponse.prisma) !== null && _m !== void 0
594
- ? _m
595
- : predefinedAnswers.prisma) !== null && _o !== void 0
596
- ? _o
597
- : false,
598
- docker:
599
- (_q =
600
- (_p = nonBackendOnlyResponse.docker) !== null && _p !== void 0
601
- ? _p
602
- : predefinedAnswers.docker) !== null && _q !== void 0
603
- ? _q
604
- : false,
605
- };
606
523
  }
607
524
  /**
608
525
  * Install dependencies in the specified directory.
@@ -611,397 +528,312 @@ async function getAnswer(predefinedAnswers = {}) {
611
528
  * @param {boolean} [isDev=false] - Whether to install the dependencies as devDependencies.
612
529
  */
613
530
  async function installDependencies(baseDir, dependencies, isDev = false) {
614
- console.log("Initializing new Node.js project...");
615
- // Initialize a package.json if it doesn't exist
616
- if (!fs.existsSync(path.join(baseDir, "package.json")))
617
- execSync("npm init -y", {
618
- stdio: "inherit",
619
- cwd: baseDir,
531
+ console.log("Initializing new Node.js project...");
532
+ // Initialize a package.json if it doesn't exist
533
+ if (!fs.existsSync(path.join(baseDir, "package.json")))
534
+ execSync("npm init -y", {
535
+ stdio: "inherit",
536
+ cwd: baseDir,
537
+ });
538
+ // Log the dependencies being installed
539
+ console.log(`${isDev ? "Installing development dependencies" : "Installing dependencies"}:`);
540
+ dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
541
+ // Prepare the npm install command with the appropriate flag for dev dependencies
542
+ const npmInstallCommand = `npm install ${isDev ? "--save-dev" : ""} ${dependencies.join(" ")}`;
543
+ // Execute the npm install command
544
+ execSync(npmInstallCommand, {
545
+ stdio: "inherit",
546
+ cwd: baseDir,
620
547
  });
621
- // Log the dependencies being installed
622
- console.log(
623
- `${
624
- isDev ? "Installing development dependencies" : "Installing dependencies"
625
- }:`
626
- );
627
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
628
- // Prepare the npm install command with the appropriate flag for dev dependencies
629
- const npmInstallCommand = `npm install ${
630
- isDev ? "--save-dev" : ""
631
- } ${dependencies.join(" ")}`;
632
- // Execute the npm install command
633
- execSync(npmInstallCommand, {
634
- stdio: "inherit",
635
- cwd: baseDir,
636
- });
637
548
  }
638
549
  async function uninstallDependencies(baseDir, dependencies, isDev = false) {
639
- console.log("Uninstalling dependencies:");
640
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
641
- // Prepare the npm uninstall command with the appropriate flag for dev dependencies
642
- const npmUninstallCommand = `npm uninstall ${
643
- isDev ? "--save-dev" : "--save"
644
- } ${dependencies.join(" ")}`;
645
- // Execute the npm uninstall command
646
- execSync(npmUninstallCommand, {
647
- stdio: "inherit",
648
- cwd: baseDir,
649
- });
550
+ console.log("Uninstalling dependencies:");
551
+ dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
552
+ // Prepare the npm uninstall command with the appropriate flag for dev dependencies
553
+ const npmUninstallCommand = `npm uninstall ${isDev ? "--save-dev" : "--save"} ${dependencies.join(" ")}`;
554
+ // Execute the npm uninstall command
555
+ execSync(npmUninstallCommand, {
556
+ stdio: "inherit",
557
+ cwd: baseDir,
558
+ });
650
559
  }
651
560
  function fetchPackageVersion(packageName) {
652
- return new Promise((resolve, reject) => {
653
- https
654
- .get(`https://registry.npmjs.org/${packageName}`, (res) => {
655
- let data = "";
656
- res.on("data", (chunk) => (data += chunk));
657
- res.on("end", () => {
658
- try {
659
- const parsed = JSON.parse(data);
660
- resolve(parsed["dist-tags"].latest);
661
- } catch (error) {
662
- reject(new Error("Failed to parse JSON response"));
663
- }
664
- });
665
- })
666
- .on("error", (err) => reject(err));
667
- });
561
+ return new Promise((resolve, reject) => {
562
+ https
563
+ .get(`https://registry.npmjs.org/${packageName}`, (res) => {
564
+ let data = "";
565
+ res.on("data", (chunk) => (data += chunk));
566
+ res.on("end", () => {
567
+ try {
568
+ const parsed = JSON.parse(data);
569
+ resolve(parsed["dist-tags"].latest);
570
+ }
571
+ catch (error) {
572
+ reject(new Error("Failed to parse JSON response"));
573
+ }
574
+ });
575
+ })
576
+ .on("error", (err) => reject(err));
577
+ });
668
578
  }
669
579
  const readJsonFile = (filePath) => {
670
- const jsonData = fs.readFileSync(filePath, "utf8");
671
- return JSON.parse(jsonData);
580
+ const jsonData = fs.readFileSync(filePath, "utf8");
581
+ return JSON.parse(jsonData);
672
582
  };
673
583
  function compareVersions(installedVersion, currentVersion) {
674
- const installedVersionArray = installedVersion.split(".").map(Number);
675
- const currentVersionArray = currentVersion.split(".").map(Number);
676
- for (let i = 0; i < installedVersionArray.length; i++) {
677
- if (installedVersionArray[i] > currentVersionArray[i]) {
678
- return 1;
679
- } else if (installedVersionArray[i] < currentVersionArray[i]) {
680
- return -1;
584
+ const installedVersionArray = installedVersion.split(".").map(Number);
585
+ const currentVersionArray = currentVersion.split(".").map(Number);
586
+ for (let i = 0; i < installedVersionArray.length; i++) {
587
+ if (installedVersionArray[i] > currentVersionArray[i]) {
588
+ return 1;
589
+ }
590
+ else if (installedVersionArray[i] < currentVersionArray[i]) {
591
+ return -1;
592
+ }
681
593
  }
682
- }
683
- return 0;
594
+ return 0;
684
595
  }
685
596
  function getInstalledPackageVersion(packageName) {
686
- try {
687
- const output = execSync(`npm list -g ${packageName} --depth=0`).toString();
688
- const versionMatch = output.match(
689
- new RegExp(`${packageName}@(\\d+\\.\\d+\\.\\d+)`)
690
- );
691
- if (versionMatch) {
692
- return versionMatch[1];
693
- } else {
694
- console.error(`Package ${packageName} is not installed`);
695
- return null;
597
+ try {
598
+ const output = execSync(`npm list -g ${packageName} --depth=0`).toString();
599
+ const versionMatch = output.match(new RegExp(`${packageName}@(\\d+\\.\\d+\\.\\d+)`));
600
+ if (versionMatch) {
601
+ return versionMatch[1];
602
+ }
603
+ else {
604
+ console.error(`Package ${packageName} is not installed`);
605
+ return null;
606
+ }
607
+ }
608
+ catch (error) {
609
+ console.error(error instanceof Error ? error.message : String(error));
610
+ return null;
696
611
  }
697
- } catch (error) {
698
- console.error(error instanceof Error ? error.message : String(error));
699
- return null;
700
- }
701
612
  }
702
613
  async function main() {
703
- var _a, _b, _c, _d, _e, _f, _g, _h;
704
- try {
705
- const args = process.argv.slice(2);
706
- let projectName = args[0];
707
- let answer = null;
708
- if (projectName) {
709
- let useBackendOnly = args.includes("--backend-only");
710
- let useTailwind = args.includes("--tailwindcss");
711
- let useWebsocket = args.includes("--websocket");
712
- let usePrisma = args.includes("--prisma");
713
- let useDocker = args.includes("--docker");
714
- const predefinedAnswers = {
715
- projectName,
716
- backendOnly: useBackendOnly,
717
- tailwindcss: useTailwind,
718
- websocket: useWebsocket,
719
- prisma: usePrisma,
720
- docker: useDocker,
721
- };
722
- console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
723
- answer = await getAnswer(predefinedAnswers);
724
- if (answer === null) {
725
- console.log(chalk.red("Installation cancelled."));
726
- return;
727
- }
728
- const currentDir = process.cwd();
729
- const configPath = path.join(currentDir, "prisma-php.json");
730
- const localSettings = readJsonFile(configPath);
731
- let excludeFiles = [];
732
- (_a = localSettings.excludeFiles) === null || _a === void 0
733
- ? void 0
734
- : _a.map((file) => {
735
- const filePath = path.join(currentDir, file);
736
- if (fs.existsSync(filePath))
737
- excludeFiles.push(filePath.replace(/\\/g, "/"));
738
- });
739
- updateAnswer = {
740
- projectName,
741
- backendOnly:
742
- (_b =
743
- answer === null || answer === void 0
744
- ? void 0
745
- : answer.backendOnly) !== null && _b !== void 0
746
- ? _b
747
- : false,
748
- tailwindcss:
749
- (_c =
750
- answer === null || answer === void 0
751
- ? void 0
752
- : answer.tailwindcss) !== null && _c !== void 0
753
- ? _c
754
- : false,
755
- websocket:
756
- (_d =
757
- answer === null || answer === void 0
758
- ? void 0
759
- : answer.websocket) !== null && _d !== void 0
760
- ? _d
761
- : false,
762
- prisma:
763
- (_e =
764
- answer === null || answer === void 0 ? void 0 : answer.prisma) !==
765
- null && _e !== void 0
766
- ? _e
767
- : false,
768
- docker:
769
- (_f =
770
- answer === null || answer === void 0 ? void 0 : answer.docker) !==
771
- null && _f !== void 0
772
- ? _f
773
- : false,
774
- isUpdate: true,
775
- excludeFiles:
776
- (_g = localSettings.excludeFiles) !== null && _g !== void 0 ? _g : [],
777
- excludeFilePath:
778
- excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
779
- filePath: currentDir,
780
- };
781
- } else {
782
- answer = await getAnswer();
783
- }
784
- if (answer === null) {
785
- console.log(chalk.red("Installation cancelled."));
786
- return;
787
- }
788
- const latestVersionOfCreatePrismaPhpApp = await fetchPackageVersion(
789
- "create-prisma-php-app"
790
- );
791
- const isCreatePrismaPhpAppInstalled = getInstalledPackageVersion(
792
- "create-prisma-php-app"
793
- );
794
- if (isCreatePrismaPhpAppInstalled) {
795
- if (
796
- compareVersions(
797
- isCreatePrismaPhpAppInstalled,
798
- latestVersionOfCreatePrismaPhpApp
799
- ) === -1
800
- ) {
801
- execSync(`npm uninstall -g create-prisma-php-app`, {
802
- stdio: "inherit",
803
- });
804
- execSync(`npm install -g create-prisma-php-app`, {
805
- stdio: "inherit",
806
- });
807
- }
808
- } else {
809
- execSync("npm install -g create-prisma-php-app", { stdio: "inherit" });
810
- }
811
- const latestVersionOfBrowserSync = await fetchPackageVersion(
812
- "browser-sync"
813
- );
814
- const isBrowserSyncInstalled = getInstalledPackageVersion("browser-sync");
815
- if (isBrowserSyncInstalled) {
816
- if (
817
- compareVersions(isBrowserSyncInstalled, latestVersionOfBrowserSync) ===
818
- -1
819
- ) {
820
- execSync(`npm uninstall -g browser-sync`, {
821
- stdio: "inherit",
822
- });
823
- execSync(`npm install -g browser-sync`, {
824
- stdio: "inherit",
825
- });
826
- }
827
- } else {
828
- execSync("npm install -g browser-sync", { stdio: "inherit" });
829
- }
830
- // Create the project directory
831
- if (!projectName) fs.mkdirSync(answer.projectName);
832
- const currentDir = process.cwd();
833
- let projectPath = projectName
834
- ? currentDir
835
- : path.join(currentDir, answer.projectName);
836
- if (!projectName) process.chdir(answer.projectName);
837
- const dependencies = [
838
- "typescript",
839
- "@types/node",
840
- "ts-node",
841
- "http-proxy-middleware@^3.0.0",
842
- "npm-run-all",
843
- ];
844
- if (answer.tailwindcss) {
845
- dependencies.push(
846
- "tailwindcss",
847
- "autoprefixer",
848
- "postcss",
849
- "postcss-cli",
850
- "cssnano"
851
- );
852
- }
853
- if (answer.websocket) {
854
- dependencies.push("chokidar-cli");
855
- }
856
- if (answer.prisma) {
857
- dependencies.push("prisma", "@prisma/client");
858
- }
859
- await installDependencies(projectPath, dependencies, true);
860
- if (!projectName) {
861
- execSync(`npx tsc --init`, { stdio: "inherit" });
862
- }
863
- if (answer.tailwindcss)
864
- execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
865
- if (answer.prisma) {
866
- if (!fs.existsSync(path.join(projectPath, "prisma")))
867
- execSync(`npx prisma init`, { stdio: "inherit" });
868
- }
869
- await createDirectoryStructure(projectPath, answer);
870
- const publicDirPath = path.join(projectPath, "public");
871
- if (!fs.existsSync(publicDirPath)) {
872
- fs.mkdirSync(publicDirPath);
873
- }
874
- if (
875
- updateAnswer === null || updateAnswer === void 0
876
- ? void 0
877
- : updateAnswer.isUpdate
878
- ) {
879
- const updateUninstallDependencies = [];
880
- if (updateAnswer.backendOnly) {
881
- const backendOnlyFiles = [
882
- "favicon.ico",
883
- "index.php",
884
- "layout.php",
885
- "metadata.php",
886
- "not-found.php",
887
- ];
888
- backendOnlyFiles.forEach((file) => {
889
- const filePath = path.join(projectPath, "src", "app", file);
890
- if (fs.existsSync(filePath)) {
891
- fs.unlinkSync(filePath); // Delete each file if it exists
892
- console.log(`${file} was deleted successfully.`);
893
- } else {
894
- console.log(`${file} does not exist.`);
895
- }
896
- });
897
- }
898
- if (!updateAnswer.tailwindcss) {
899
- const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
900
- tailwindFiles.forEach((file) => {
901
- const filePath = path.join(projectPath, file);
902
- if (fs.existsSync(filePath)) {
903
- fs.unlinkSync(filePath); // Delete each file if it exists
904
- console.log(`${file} was deleted successfully.`);
905
- } else {
906
- console.log(`${file} does not exist.`);
907
- }
908
- });
909
- updateUninstallDependencies.push(
910
- "tailwindcss",
911
- "autoprefixer",
912
- "postcss",
913
- "postcss-cli",
914
- "cssnano"
915
- );
916
- }
917
- if (!updateAnswer.websocket) {
918
- updateUninstallDependencies.push("chokidar-cli");
919
- }
920
- if (!updateAnswer.prisma) {
921
- updateUninstallDependencies.push("prisma", "@prisma/client");
922
- }
923
- if (!updateAnswer.docker) {
924
- const dockerFiles = [
925
- ".dockerignore",
926
- "docker-compose.yml",
927
- "Dockerfile",
928
- "apache.conf",
614
+ var _a, _b, _c, _d, _e, _f, _g, _h;
615
+ try {
616
+ const args = process.argv.slice(2);
617
+ let projectName = args[0];
618
+ let answer = null;
619
+ if (projectName) {
620
+ let useBackendOnly = args.includes("--backend-only");
621
+ let useTailwind = args.includes("--tailwindcss");
622
+ let useWebsocket = args.includes("--websocket");
623
+ let usePrisma = args.includes("--prisma");
624
+ let useDocker = args.includes("--docker");
625
+ const predefinedAnswers = {
626
+ projectName,
627
+ backendOnly: useBackendOnly,
628
+ tailwindcss: useTailwind,
629
+ websocket: useWebsocket,
630
+ prisma: usePrisma,
631
+ docker: useDocker,
632
+ };
633
+ console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
634
+ answer = await getAnswer(predefinedAnswers);
635
+ if (answer === null) {
636
+ console.log(chalk.red("Installation cancelled."));
637
+ return;
638
+ }
639
+ const currentDir = process.cwd();
640
+ const configPath = path.join(currentDir, "prisma-php.json");
641
+ const localSettings = readJsonFile(configPath);
642
+ let excludeFiles = [];
643
+ (_a = localSettings.excludeFiles) === null || _a === void 0 ? void 0 : _a.map((file) => {
644
+ const filePath = path.join(currentDir, file);
645
+ if (fs.existsSync(filePath))
646
+ excludeFiles.push(filePath.replace(/\\/g, "/"));
647
+ });
648
+ updateAnswer = {
649
+ projectName,
650
+ backendOnly: (_b = answer === null || answer === void 0 ? void 0 : answer.backendOnly) !== null && _b !== void 0 ? _b : false,
651
+ tailwindcss: (_c = answer === null || answer === void 0 ? void 0 : answer.tailwindcss) !== null && _c !== void 0 ? _c : false,
652
+ websocket: (_d = answer === null || answer === void 0 ? void 0 : answer.websocket) !== null && _d !== void 0 ? _d : false,
653
+ prisma: (_e = answer === null || answer === void 0 ? void 0 : answer.prisma) !== null && _e !== void 0 ? _e : false,
654
+ docker: (_f = answer === null || answer === void 0 ? void 0 : answer.docker) !== null && _f !== void 0 ? _f : false,
655
+ isUpdate: true,
656
+ excludeFiles: (_g = localSettings.excludeFiles) !== null && _g !== void 0 ? _g : [],
657
+ excludeFilePath: excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
658
+ filePath: currentDir,
659
+ };
660
+ }
661
+ else {
662
+ answer = await getAnswer();
663
+ }
664
+ if (answer === null) {
665
+ console.log(chalk.red("Installation cancelled."));
666
+ return;
667
+ }
668
+ const latestVersionOfCreatePrismaPhpApp = await fetchPackageVersion("create-prisma-php-app");
669
+ const isCreatePrismaPhpAppInstalled = getInstalledPackageVersion("create-prisma-php-app");
670
+ if (isCreatePrismaPhpAppInstalled) {
671
+ if (compareVersions(isCreatePrismaPhpAppInstalled, latestVersionOfCreatePrismaPhpApp) === -1) {
672
+ execSync(`npm uninstall -g create-prisma-php-app`, {
673
+ stdio: "inherit",
674
+ });
675
+ execSync(`npm install -g create-prisma-php-app`, {
676
+ stdio: "inherit",
677
+ });
678
+ }
679
+ }
680
+ else {
681
+ execSync("npm install -g create-prisma-php-app", { stdio: "inherit" });
682
+ }
683
+ const latestVersionOfBrowserSync = await fetchPackageVersion("browser-sync");
684
+ const isBrowserSyncInstalled = getInstalledPackageVersion("browser-sync");
685
+ if (isBrowserSyncInstalled) {
686
+ if (compareVersions(isBrowserSyncInstalled, latestVersionOfBrowserSync) ===
687
+ -1) {
688
+ execSync(`npm uninstall -g browser-sync`, {
689
+ stdio: "inherit",
690
+ });
691
+ execSync(`npm install -g browser-sync`, {
692
+ stdio: "inherit",
693
+ });
694
+ }
695
+ }
696
+ else {
697
+ execSync("npm install -g browser-sync", { stdio: "inherit" });
698
+ }
699
+ // Create the project directory
700
+ if (!projectName)
701
+ fs.mkdirSync(answer.projectName);
702
+ const currentDir = process.cwd();
703
+ let projectPath = projectName
704
+ ? currentDir
705
+ : path.join(currentDir, answer.projectName);
706
+ if (!projectName)
707
+ process.chdir(answer.projectName);
708
+ const dependencies = [
709
+ "typescript",
710
+ "@types/node",
711
+ "ts-node",
712
+ "http-proxy-middleware@^3.0.0",
713
+ "npm-run-all",
929
714
  ];
930
- dockerFiles.forEach((file) => {
931
- const filePath = path.join(projectPath, file);
932
- if (fs.existsSync(filePath)) {
933
- fs.unlinkSync(filePath); // Delete each file if it exists
934
- console.log(`${file} was deleted successfully.`);
935
- } else {
936
- console.log(`${file} does not exist.`);
937
- }
938
- });
939
- }
940
- if (updateUninstallDependencies.length > 0) {
941
- await uninstallDependencies(
942
- projectPath,
943
- updateUninstallDependencies,
944
- true
945
- );
946
- }
947
- }
948
- const projectPathModified = projectPath.replace(/\\/g, "\\");
949
- const bsConfig = bsConfigUrls(projectPathModified);
950
- const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
951
- const prismaPhpConfig = {
952
- projectName: answer.projectName,
953
- projectRootPath: projectPathModified,
954
- phpEnvironment: "XAMPP",
955
- phpRootPathExe: "C:\\xampp\\php\\php.exe",
956
- phpGenerateClassPath,
957
- bsTarget: bsConfig.bsTarget,
958
- bsPathRewrite: bsConfig.bsPathRewrite,
959
- backendOnly: answer.backendOnly,
960
- tailwindcss: answer.tailwindcss,
961
- websocket: answer.websocket,
962
- prisma: answer.prisma,
963
- docker: answer.docker,
964
- version: latestVersionOfCreatePrismaPhpApp,
965
- excludeFiles:
966
- (_h =
967
- updateAnswer === null || updateAnswer === void 0
968
- ? void 0
969
- : updateAnswer.excludeFiles) !== null && _h !== void 0
970
- ? _h
971
- : [],
972
- };
973
- fs.writeFileSync(
974
- path.join(projectPath, "prisma-php.json"),
975
- JSON.stringify(prismaPhpConfig, null, 2),
976
- { flag: "w" }
977
- );
978
- if (
979
- updateAnswer === null || updateAnswer === void 0
980
- ? void 0
981
- : updateAnswer.isUpdate
982
- ) {
983
- execSync(
984
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`,
985
- {
986
- stdio: "inherit",
715
+ if (answer.tailwindcss) {
716
+ dependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
987
717
  }
988
- );
989
- } else {
990
- execSync(
991
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`,
992
- {
993
- stdio: "inherit",
718
+ if (answer.websocket) {
719
+ dependencies.push("chokidar-cli");
720
+ }
721
+ if (answer.prisma) {
722
+ dependencies.push("prisma", "@prisma/client");
994
723
  }
995
- );
724
+ await installDependencies(projectPath, dependencies, true);
725
+ if (!projectName) {
726
+ execSync(`npx tsc --init`, { stdio: "inherit" });
727
+ }
728
+ if (answer.tailwindcss)
729
+ execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
730
+ if (answer.prisma) {
731
+ if (!fs.existsSync(path.join(projectPath, "prisma")))
732
+ execSync(`npx prisma init`, { stdio: "inherit" });
733
+ }
734
+ await createDirectoryStructure(projectPath, answer);
735
+ const publicDirPath = path.join(projectPath, "public");
736
+ if (!fs.existsSync(publicDirPath)) {
737
+ fs.mkdirSync(publicDirPath);
738
+ }
739
+ if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
740
+ const updateUninstallDependencies = [];
741
+ if (updateAnswer.backendOnly) {
742
+ const backendOnlyFiles = [
743
+ "favicon.ico",
744
+ "index.php",
745
+ "layout.php",
746
+ "metadata.php",
747
+ "not-found.php",
748
+ ];
749
+ backendOnlyFiles.forEach((file) => {
750
+ const filePath = path.join(projectPath, "src", "app", file);
751
+ if (fs.existsSync(filePath)) {
752
+ fs.unlinkSync(filePath); // Delete each file if it exists
753
+ console.log(`${file} was deleted successfully.`);
754
+ }
755
+ else {
756
+ console.log(`${file} does not exist.`);
757
+ }
758
+ });
759
+ }
760
+ if (!updateAnswer.tailwindcss) {
761
+ const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
762
+ tailwindFiles.forEach((file) => {
763
+ const filePath = path.join(projectPath, file);
764
+ if (fs.existsSync(filePath)) {
765
+ fs.unlinkSync(filePath); // Delete each file if it exists
766
+ console.log(`${file} was deleted successfully.`);
767
+ }
768
+ else {
769
+ console.log(`${file} does not exist.`);
770
+ }
771
+ });
772
+ updateUninstallDependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
773
+ }
774
+ if (!updateAnswer.websocket) {
775
+ updateUninstallDependencies.push("chokidar-cli");
776
+ }
777
+ if (!updateAnswer.prisma) {
778
+ updateUninstallDependencies.push("prisma", "@prisma/client");
779
+ }
780
+ if (!updateAnswer.docker) {
781
+ const dockerFiles = [
782
+ ".dockerignore",
783
+ "docker-compose.yml",
784
+ "Dockerfile",
785
+ "apache.conf",
786
+ ];
787
+ dockerFiles.forEach((file) => {
788
+ const filePath = path.join(projectPath, file);
789
+ if (fs.existsSync(filePath)) {
790
+ fs.unlinkSync(filePath); // Delete each file if it exists
791
+ console.log(`${file} was deleted successfully.`);
792
+ }
793
+ else {
794
+ console.log(`${file} does not exist.`);
795
+ }
796
+ });
797
+ }
798
+ if (updateUninstallDependencies.length > 0) {
799
+ await uninstallDependencies(projectPath, updateUninstallDependencies, true);
800
+ }
801
+ }
802
+ const projectPathModified = projectPath.replace(/\\/g, "\\");
803
+ const bsConfig = bsConfigUrls(projectPathModified);
804
+ const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
805
+ const prismaPhpConfig = {
806
+ projectName: answer.projectName,
807
+ projectRootPath: projectPathModified,
808
+ phpEnvironment: "XAMPP",
809
+ phpRootPathExe: "C:\\xampp\\php\\php.exe",
810
+ phpGenerateClassPath,
811
+ bsTarget: bsConfig.bsTarget,
812
+ bsPathRewrite: bsConfig.bsPathRewrite,
813
+ backendOnly: answer.backendOnly,
814
+ tailwindcss: answer.tailwindcss,
815
+ websocket: answer.websocket,
816
+ prisma: answer.prisma,
817
+ docker: answer.docker,
818
+ version: latestVersionOfCreatePrismaPhpApp,
819
+ excludeFiles: (_h = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFiles) !== null && _h !== void 0 ? _h : [],
820
+ };
821
+ fs.writeFileSync(path.join(projectPath, "prisma-php.json"), JSON.stringify(prismaPhpConfig, null, 2), { flag: "w" });
822
+ if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
823
+ execSync(`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`, {
824
+ stdio: "inherit",
825
+ });
826
+ }
827
+ else {
828
+ execSync(`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`, {
829
+ stdio: "inherit",
830
+ });
831
+ }
832
+ console.log(`${chalk.green("Success!")} Prisma PHP project successfully created in ${answer.projectName}!`);
833
+ }
834
+ catch (error) {
835
+ console.error("Error while creating the project:", error);
836
+ process.exit(1);
996
837
  }
997
- console.log(
998
- `${chalk.green("Success!")} Prisma PHP project successfully created in ${
999
- answer.projectName
1000
- }!`
1001
- );
1002
- } catch (error) {
1003
- console.error("Error while creating the project:", error);
1004
- process.exit(1);
1005
- }
1006
838
  }
1007
839
  main();