create-prisma-php-app 1.9.15 → 1.9.16

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 +1 -714
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,715 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import { execSync } from "child_process";
3
- import fs from "fs";
4
- import { fileURLToPath } from "url";
5
- import path from "path";
6
- import chalk from "chalk";
7
- import prompts from "prompts";
8
- import https from "https";
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- let updateAnswer = null;
12
- function bsConfigUrls(projectSettings) {
13
- // Identify the base path dynamically up to and including 'htdocs'
14
- const htdocsIndex = projectSettings.PROJECT_ROOT_PATH.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 = projectSettings.PROJECT_ROOT_PATH.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 = projectSettings.PROJECT_ROOT_PATH.replace(new RegExp(`^${escapedBasePathToRemove}`), "").replace(/\\/g, "/");
28
- // Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
29
- let proxyUrl = `http://localhost/${relativeWebPath}`;
30
- // Ensure the proxy URL does not end with a slash before appending '/public'
31
- proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
32
- // Clean the URL by replacing "//" with "/" but not affecting "http://"
33
- // We replace instances of "//" that are not preceded by ":"
34
- const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
35
- const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
36
- // Correct the relativeWebPath to ensure it does not start with a "/"
37
- const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
38
- ? cleanRelativeWebPath.substring(1)
39
- : cleanRelativeWebPath;
40
- return {
41
- bsTarget: `${cleanUrl}/`,
42
- bsPathRewrite: {
43
- "^/": `/${adjustedRelativeWebPath}/`,
44
- },
45
- };
46
- }
47
- function configureBrowserSyncCommand(baseDir, projectSettings) {
48
- // TypeScript content to write
49
- const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
50
- const fs = require("fs");
51
-
52
- const jsonData = fs.readFileSync("prisma-php.json", "utf8");
53
- const config = JSON.parse(jsonData);
54
-
55
- module.exports = {
56
- // First middleware: Set Cache-Control headers
57
- function(req, res, next) {
58
- res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
59
- res.setHeader("Pragma", "no-cache");
60
- res.setHeader("Expires", "0");
61
- next();
62
- },
63
- // Use the 'middleware' option to create a proxy that masks the deep URL.
64
- middleware: [
65
- // This middleware intercepts requests to the root and proxies them to the deep path.
66
- createProxyMiddleware("/", {
67
- target: config.bsTarget,
68
- changeOrigin: true,
69
- pathRewrite: config.bsPathRewrite,
70
- }),
71
- ],
72
- proxy: "http://localhost:3000", // Proxy the BrowserSync server.
73
- files: "src/**/*.*",
74
- notify: false,
75
- open: false,
76
- ghostMode: false,
77
- };`;
78
- // Determine the path and write the bs-config.js
79
- const bsConfigPath = path.join(baseDir, "settings", "bs-config.cjs");
80
- fs.writeFileSync(bsConfigPath, bsConfigTsContent, "utf8");
81
- // Return the Browser Sync command string, using the cleaned URL
82
- return `browser-sync start --config settings/bs-config.cjs`;
83
- }
84
- async function updatePackageJson(baseDir, projectSettings, answer) {
85
- const packageJsonPath = path.join(baseDir, "package.json");
86
- if (checkExcludeFiles(packageJsonPath))
87
- return;
88
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
89
- // Use the new function to configure the Browser Sync command
90
- const browserSyncCommand = configureBrowserSyncCommand(baseDir, projectSettings);
91
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { projectName: "node settings/project-name.cjs" });
92
- let answersToInclude = [];
93
- if (answer.tailwindcss) {
94
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { tailwind: "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch" });
95
- answersToInclude.push("tailwind");
96
- }
97
- if (answer.websocket) {
98
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { websocket: "node ./settings/restartWebsocket.cjs" });
99
- answersToInclude.push("websocket");
100
- }
101
- if (answer.prisma) {
102
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { postinstall: "prisma generate" });
103
- }
104
- // Initialize with existing scripts
105
- const updatedScripts = Object.assign({}, packageJson.scripts);
106
- // Conditionally add "browser-sync" command
107
- updatedScripts["browser-sync"] = browserSyncCommand;
108
- // Conditionally set the "dev" command
109
- updatedScripts.dev =
110
- answersToInclude.length > 0
111
- ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(" ")}`
112
- : `npm-run-all --parallel projectName browser-sync`;
113
- // Finally, assign the updated scripts back to packageJson
114
- packageJson.scripts = updatedScripts;
115
- packageJson.type = "module";
116
- if (answer.prisma)
117
- packageJson.prisma = {
118
- seed: "node prisma/seed.js",
119
- };
120
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
121
- }
122
- async function updateComposerJson(baseDir, answer) {
123
- const composerJsonPath = path.join(baseDir, "composer.json");
124
- if (checkExcludeFiles(composerJsonPath))
125
- return;
126
- let composerJson;
127
- // Check if the composer.json file exists
128
- if (fs.existsSync(composerJsonPath)) {
129
- // Read the current composer.json content
130
- const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
131
- composerJson = JSON.parse(composerJsonContent);
132
- }
133
- else {
134
- console.error("composer.json does not exist.");
135
- return;
136
- }
137
- // Conditionally add WebSocket dependency
138
- if (answer.websocket) {
139
- composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "cboden/ratchet": "^0.4.4" });
140
- }
141
- if (answer.prisma) {
142
- composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" });
143
- }
144
- // Write the modified composer.json back to the file
145
- fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
146
- console.log("composer.json updated successfully.");
147
- }
148
- async function updateIndexJsForWebSocket(baseDir, answer) {
149
- if (!answer.websocket) {
150
- return;
151
- }
152
- const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
153
- if (checkExcludeFiles(indexPath))
154
- return;
155
- let indexContent = fs.readFileSync(indexPath, "utf8");
156
- // WebSocket initialization code to be appended
157
- const webSocketCode = `
158
- // WebSocket initialization
159
- const ws = new WebSocket("ws://localhost:8080");
160
- `;
161
- // Append WebSocket code if user chose to use WebSocket
162
- indexContent += webSocketCode;
163
- fs.writeFileSync(indexPath, indexContent, "utf8");
164
- console.log("WebSocket code added to index.js successfully.");
165
- }
166
- // This function updates the .gitignore file
167
- async function createUpdateGitignoreFile(baseDir, additions) {
168
- const gitignorePath = path.join(baseDir, ".gitignore");
169
- if (checkExcludeFiles(gitignorePath))
170
- return;
171
- // Check if the .gitignore file exists, create if it doesn't
172
- let gitignoreContent = "";
173
- if (fs.existsSync(gitignorePath)) {
174
- gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
175
- }
176
- additions.forEach((addition) => {
177
- if (!gitignoreContent.includes(addition)) {
178
- gitignoreContent += `\n${addition}`;
179
- }
180
- });
181
- // Ensure there's no leading newline if the file was just created
182
- gitignoreContent = gitignoreContent.trimStart();
183
- fs.writeFileSync(gitignorePath, gitignoreContent);
184
- }
185
- // Recursive copy function
186
- function copyRecursiveSync(src, dest) {
187
- console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
188
- console.log("🚀 ~ copyRecursiveSync ~ src:", src);
189
- const exists = fs.existsSync(src);
190
- const stats = exists && fs.statSync(src);
191
- const isDirectory = exists && stats && stats.isDirectory();
192
- if (isDirectory) {
193
- fs.mkdirSync(dest, { recursive: true });
194
- fs.readdirSync(src).forEach((childItemName) => {
195
- copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
196
- });
197
- }
198
- else {
199
- if (checkExcludeFiles(dest))
200
- return;
201
- fs.copyFileSync(src, dest, 0);
202
- }
203
- }
204
- // Function to execute the recursive copy for entire directories
205
- async function executeCopy(baseDir, directoriesToCopy, answer) {
206
- directoriesToCopy.forEach(({ srcDir, destDir }) => {
207
- if (!answer.prisma && srcDir === "/prisma-client-php")
208
- return;
209
- const sourcePath = path.join(__dirname, srcDir);
210
- const destPath = path.join(baseDir, destDir);
211
- copyRecursiveSync(sourcePath, destPath);
212
- });
213
- }
214
- function createOrUpdateTailwindConfig(baseDir) {
215
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
216
- const filePath = path.join(baseDir, "tailwind.config.js");
217
- if (checkExcludeFiles(filePath))
218
- return;
219
- const newContent = [
220
- "./src/app/**/*.{html,js,php}",
221
- // Add more paths as needed
222
- ];
223
- let configData = fs.readFileSync(filePath, "utf8");
224
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
225
- const contentArrayString = newContent
226
- .map((item) => ` "${item}"`)
227
- .join(",\n");
228
- configData = configData.replace(/content: \[\],/g, `content: [\n${contentArrayString}\n],`);
229
- fs.writeFileSync(filePath, configData, { flag: "w" });
230
- console.log(chalk.green("Tailwind configuration updated successfully."));
231
- }
232
- function modifyPostcssConfig(baseDir) {
233
- const filePath = path.join(baseDir, "postcss.config.js");
234
- if (checkExcludeFiles(filePath))
235
- return;
236
- const newContent = `export default {
237
- plugins: {
238
- tailwindcss: {},
239
- autoprefixer: {},
240
- cssnano: {},
241
- },
242
- };`;
243
- fs.writeFileSync(filePath, newContent, { flag: "w" });
244
- console.log(chalk.green("postcss.config.js updated successfully."));
245
- }
246
- function modifyLayoutPHP(baseDir, useTailwind) {
247
- const layoutPath = path.join(baseDir, "src", "app", "layout.php");
248
- if (checkExcludeFiles(layoutPath))
249
- return;
250
- try {
251
- let indexContent = fs.readFileSync(layoutPath, "utf8");
252
- const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"></script>\n <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">`;
253
- // Tailwind CSS link or CDN script
254
- const tailwindLink = useTailwind
255
- ? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
256
- : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
257
- // Insert before the closing </head> tag
258
- indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
259
- fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
260
- console.log(chalk.green(`index.php modified successfully for ${useTailwind ? "local Tailwind CSS" : "Tailwind CSS CDN"}.`));
261
- }
262
- catch (error) {
263
- console.error(chalk.red("Error modifying index.php:"), error);
264
- }
265
- }
266
- // This function updates or creates the .env file
267
- async function createOrUpdateEnvFile(baseDir, content) {
268
- const envPath = path.join(baseDir, ".env");
269
- if (checkExcludeFiles(envPath))
270
- return;
271
- let envContent = fs.existsSync(envPath)
272
- ? fs.readFileSync(envPath, "utf8")
273
- : "";
274
- // Check if the content already exists in the .env file
275
- if (!envContent.includes(content)) {
276
- envContent += `${envContent !== "" ? "\n\n" : ""}${content}`;
277
- fs.writeFileSync(envPath, envContent, { flag: "w" });
278
- }
279
- }
280
- function checkExcludeFiles(destPath) {
281
- var _a, _b;
282
- if (!(updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate))
283
- return false;
284
- 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);
285
- }
286
- async function createDirectoryStructure(baseDir, answer, projectSettings) {
287
- console.log("🚀 ~ baseDir:", baseDir);
288
- console.log("🚀 ~ answer:", answer);
289
- console.log("🚀 ~ projectSettings:", projectSettings);
290
- const filesToCopy = [
291
- { src: "/bootstrap.php", dest: "/bootstrap.php" },
292
- { src: "/bootstrap-ajax.php", dest: "/bootstrap-ajax.php" },
293
- { src: "/.htaccess", dest: "/.htaccess" },
294
- { src: "/../composer.json", dest: "/composer.json" },
295
- ];
296
- if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
297
- filesToCopy.push({ src: "/.env", dest: "/.env" }, { src: "/tsconfig.json", dest: "/tsconfig.json" });
298
- if (updateAnswer.tailwindcss) {
299
- filesToCopy.push({ src: "/postcss.config.js", dest: "/postcss.config.js" }, { src: "/tailwind.config.js", dest: "/tailwind.config.js" });
300
- }
301
- }
302
- // if (answer.websocket) {
303
- // filesToCopy.push({
304
- // src: "/../composer-websocket.lock",
305
- // dest: "/composer.lock",
306
- // });
307
- // } else {
308
- // filesToCopy.push({ src: "/../composer.lock", dest: "/composer.lock" });
309
- // }
310
- const directoriesToCopy = [
311
- {
312
- srcDir: "/settings",
313
- destDir: "/settings",
314
- },
315
- {
316
- srcDir: "/prisma",
317
- destDir: "/prisma",
318
- },
319
- {
320
- srcDir: "/src",
321
- destDir: "/src",
322
- },
323
- {
324
- srcDir: "/../vendor",
325
- destDir: "/vendor",
326
- },
327
- ];
328
- console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
329
- filesToCopy.forEach(({ src, dest }) => {
330
- const sourcePath = path.join(__dirname, src);
331
- const destPath = path.join(baseDir, dest);
332
- if (checkExcludeFiles(destPath))
333
- return;
334
- const code = fs.readFileSync(sourcePath, "utf8");
335
- fs.writeFileSync(destPath, code, { flag: "w" });
336
- });
337
- await executeCopy(baseDir, directoriesToCopy, answer);
338
- await updatePackageJson(baseDir, projectSettings, answer);
339
- await updateComposerJson(baseDir, answer);
340
- await updateIndexJsForWebSocket(baseDir, answer);
341
- if (answer.tailwindcss) {
342
- createOrUpdateTailwindConfig(baseDir);
343
- modifyLayoutPHP(baseDir, true);
344
- modifyPostcssConfig(baseDir);
345
- }
346
- else {
347
- modifyLayoutPHP(baseDir, false);
348
- }
349
- const envContent = `# PHPMailer
350
- # SMTP_HOST=smtp.gmail.com or your SMTP host
351
- # SMTP_USERNAME=john.doe@gmail.com or your SMTP username
352
- # SMTP_PASSWORD=123456
353
- # SMTP_PORT=587 for TLS, 465 for SSL or your SMTP port
354
- # SMTP_ENCRYPTION=ssl or tls
355
- # MAIL_FROM=john.doe@gmail.com
356
- # MAIL_FROM_NAME="John Doe"`;
357
- await createOrUpdateEnvFile(baseDir, envContent);
358
- // Add vendor to .gitignore
359
- await createUpdateGitignoreFile(baseDir, ["vendor"]);
360
- }
361
- async function getAnswer(predefinedAnswers = {}) {
362
- var _a, _b, _c, _d;
363
- console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
364
- const questionsArray = [];
365
- if (!predefinedAnswers.projectName) {
366
- questionsArray.push({
367
- type: "text",
368
- name: "projectName",
369
- message: "What is your project named?",
370
- initial: "my-app",
371
- });
372
- }
373
- if (!predefinedAnswers.tailwindcss) {
374
- questionsArray.push({
375
- type: "toggle",
376
- name: "tailwindcss",
377
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
378
- initial: true,
379
- active: "Yes",
380
- inactive: "No",
381
- });
382
- }
383
- if (!predefinedAnswers.websocket) {
384
- questionsArray.push({
385
- type: "toggle",
386
- name: "websocket",
387
- message: `Would you like to use ${chalk.blue("Websocket")}?`,
388
- initial: true,
389
- active: "Yes",
390
- inactive: "No",
391
- });
392
- }
393
- if (!predefinedAnswers.prisma) {
394
- questionsArray.push({
395
- type: "toggle",
396
- name: "prisma",
397
- message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
398
- initial: true,
399
- active: "Yes",
400
- inactive: "No",
401
- });
402
- }
403
- const questions = questionsArray;
404
- console.log("🚀 ~ questions:", questions);
405
- const onCancel = () => {
406
- console.log(chalk.red("Operation cancelled by the user."));
407
- process.exit(0);
408
- };
409
- try {
410
- const response = await prompts(questions, { onCancel });
411
- console.log("🚀 ~ response:", response);
412
- if (Object.keys(response).length === 0) {
413
- return null;
414
- }
415
- return {
416
- projectName: response.projectName
417
- ? String(response.projectName).trim().replace(/ /g, "-")
418
- : (_a = predefinedAnswers.projectName) !== null && _a !== void 0 ? _a : "my-app",
419
- tailwindcss: (_b = response.tailwindcss) !== null && _b !== void 0 ? _b : predefinedAnswers.tailwindcss,
420
- websocket: (_c = response.websocket) !== null && _c !== void 0 ? _c : predefinedAnswers.websocket,
421
- prisma: (_d = response.prisma) !== null && _d !== void 0 ? _d : predefinedAnswers.prisma,
422
- };
423
- }
424
- catch (error) {
425
- console.error(chalk.red("Prompt error:"), error);
426
- return null;
427
- }
428
- }
429
- /**
430
- * Install dependencies in the specified directory.
431
- * @param {string} baseDir - The base directory where to install the dependencies.
432
- * @param {string[]} dependencies - The list of dependencies to install.
433
- * @param {boolean} [isDev=false] - Whether to install the dependencies as devDependencies.
434
- */
435
- async function installDependencies(baseDir, dependencies, isDev = false) {
436
- console.log("Initializing new Node.js project...");
437
- // Initialize a package.json if it doesn't exist
438
- if (!fs.existsSync(path.join(baseDir, "package.json")))
439
- execSync("npm init -y", {
440
- stdio: "inherit",
441
- cwd: baseDir,
442
- });
443
- // Log the dependencies being installed
444
- console.log(`${isDev ? "Installing development dependencies" : "Installing dependencies"}:`);
445
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
446
- // Prepare the npm install command with the appropriate flag for dev dependencies
447
- const npmInstallCommand = `npm install ${isDev ? "--save-dev" : ""} ${dependencies.join(" ")}`;
448
- // Execute the npm install command
449
- execSync(npmInstallCommand, {
450
- stdio: "inherit",
451
- cwd: baseDir,
452
- });
453
- }
454
- async function uninstallDependencies(baseDir, dependencies, isDev = false) {
455
- console.log("Uninstalling dependencies:");
456
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
457
- // Prepare the npm uninstall command with the appropriate flag for dev dependencies
458
- const npmUninstallCommand = `npm uninstall ${isDev ? "--save-dev" : "--save"} ${dependencies.join(" ")}`;
459
- // Execute the npm uninstall command
460
- execSync(npmUninstallCommand, {
461
- stdio: "inherit",
462
- cwd: baseDir,
463
- });
464
- }
465
- function fetchPackageVersion(packageName) {
466
- return new Promise((resolve, reject) => {
467
- https
468
- .get(`https://registry.npmjs.org/${packageName}`, (res) => {
469
- let data = "";
470
- res.on("data", (chunk) => (data += chunk));
471
- res.on("end", () => {
472
- try {
473
- const parsed = JSON.parse(data);
474
- resolve(parsed["dist-tags"].latest);
475
- }
476
- catch (error) {
477
- reject(new Error("Failed to parse JSON response"));
478
- }
479
- });
480
- })
481
- .on("error", (err) => reject(err));
482
- });
483
- }
484
- const readJsonFile = (filePath) => {
485
- const jsonData = fs.readFileSync(filePath, "utf8");
486
- return JSON.parse(jsonData);
487
- };
488
- async function main() {
489
- var _a, _b, _c, _d, _e, _f;
490
- try {
491
- const args = process.argv.slice(2);
492
- let projectName = args[0];
493
- let answer = null;
494
- if (projectName) {
495
- let useTailwind = args.includes("--tailwindcss");
496
- let useWebsocket = args.includes("--websocket");
497
- let usePrisma = args.includes("--prisma");
498
- const predefinedAnswers = {
499
- projectName,
500
- tailwindcss: useTailwind,
501
- websocket: useWebsocket,
502
- prisma: usePrisma,
503
- };
504
- console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
505
- answer = await getAnswer(predefinedAnswers);
506
- if (answer === null) {
507
- console.log(chalk.red("Installation cancelled."));
508
- return;
509
- }
510
- const currentDir = process.cwd();
511
- const configPath = path.join(currentDir, "prisma-php.json");
512
- const localSettings = readJsonFile(configPath);
513
- let excludeFiles = [];
514
- (_a = localSettings.excludeFiles) === null || _a === void 0 ? void 0 : _a.map((file) => {
515
- const filePath = path.join(currentDir, file);
516
- if (fs.existsSync(filePath))
517
- excludeFiles.push(filePath.replace(/\\/g, "/"));
518
- });
519
- updateAnswer = {
520
- projectName,
521
- tailwindcss: (_b = answer === null || answer === void 0 ? void 0 : answer.tailwindcss) !== null && _b !== void 0 ? _b : false,
522
- websocket: (_c = answer === null || answer === void 0 ? void 0 : answer.websocket) !== null && _c !== void 0 ? _c : false,
523
- prisma: (_d = answer === null || answer === void 0 ? void 0 : answer.prisma) !== null && _d !== void 0 ? _d : false,
524
- isUpdate: true,
525
- excludeFiles: (_e = localSettings.excludeFiles) !== null && _e !== void 0 ? _e : [],
526
- excludeFilePath: excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
527
- filePath: currentDir,
528
- };
529
- }
530
- else {
531
- answer = await getAnswer();
532
- }
533
- if (answer === null) {
534
- console.log(chalk.red("Installation cancelled."));
535
- return;
536
- }
537
- // execSync(`npm install -g create-prisma-php-app`, { stdio: "inherit" }); // TODO: Uncomment this line before publishing the package
538
- // Support for browser-sync
539
- execSync(`npm install -g browser-sync`, { stdio: "inherit" });
540
- // Create the project directory
541
- if (!projectName)
542
- fs.mkdirSync(answer.projectName);
543
- const currentDir = process.cwd();
544
- let projectPath = projectName
545
- ? currentDir
546
- : path.join(currentDir, answer.projectName);
547
- if (!projectName)
548
- process.chdir(answer.projectName);
549
- const dependencies = [
550
- "typescript",
551
- "@types/node",
552
- "ts-node",
553
- "http-proxy-middleware@^2.0.6",
554
- "npm-run-all",
555
- ];
556
- if (answer.tailwindcss) {
557
- dependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
558
- }
559
- if (answer.websocket) {
560
- dependencies.push("chokidar-cli");
561
- }
562
- if (answer.prisma) {
563
- dependencies.push("prisma", "@prisma/client");
564
- }
565
- await installDependencies(projectPath, dependencies, true);
566
- if (!projectName) {
567
- execSync(`npx tsc --init`, { stdio: "inherit" });
568
- }
569
- if (answer.tailwindcss)
570
- execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
571
- if (answer.prisma)
572
- execSync(`npx prisma init`, { stdio: "inherit" });
573
- const projectPathModified = projectPath.replace(/\\/g, "\\");
574
- const PHP_GENERATE_CLASS_PATH = answer.prisma
575
- ? "src/Lib/Prisma/Classes"
576
- : "";
577
- const projectSettings = {
578
- PROJECT_NAME: answer.projectName,
579
- PROJECT_ROOT_PATH: projectPathModified,
580
- PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
581
- PHP_GENERATE_CLASS_PATH,
582
- };
583
- await createDirectoryStructure(projectPath, answer, projectSettings);
584
- // execSync(`composer install`, { stdio: "inherit" });
585
- // execSync(`composer dump-autoload`, { stdio: "inherit" });
586
- // Create settings file
587
- // const settingsPath = path.join(
588
- // projectPath,
589
- // "settings",
590
- // "project-settings.js"
591
- // );
592
- // const settingsCode = `export const projectSettings = {
593
- // PROJECT_NAME: "${answer.projectName}",
594
- // PROJECT_ROOT_PATH: "${projectPath.replace(/\\/g, "\\\\")}",
595
- // PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
596
- // PHP_GENERATE_CLASS_PATH: "src/Lib/Prisma/Classes",
597
- // };`;
598
- // fs.writeFileSync(settingsPath, settingsCode, { flag: "w" });
599
- const publicDirPath = path.join(projectPath, "public");
600
- if (!fs.existsSync(publicDirPath)) {
601
- fs.mkdirSync(publicDirPath);
602
- }
603
- if (!answer.tailwindcss) {
604
- const cssPath = path.join(projectPath, "src", "app", "css");
605
- const tailwindFiles = ["tailwind.css", "styles.css"];
606
- tailwindFiles.forEach((file) => {
607
- const filePath = path.join(cssPath, file);
608
- if (fs.existsSync(filePath)) {
609
- fs.unlinkSync(filePath); // Delete each file if it exists
610
- console.log(`${file} was deleted successfully.`);
611
- }
612
- else {
613
- console.log(`${file} does not exist.`);
614
- }
615
- });
616
- }
617
- // Update websocket if not chosen by the user
618
- if (!answer.websocket) {
619
- const wsPath = path.join(projectPath, "src", "Lib", "Websocket");
620
- // Check if the websocket directory exists
621
- if (fs.existsSync(wsPath)) {
622
- // Use fs.rmSync with recursive option set to true to delete the directory and its contents
623
- fs.rmSync(wsPath, { recursive: true, force: true }); // force option is not necessary but can be used to ensure deletion
624
- console.log("Websocket directory was deleted successfully.");
625
- }
626
- else {
627
- console.log("Websocket directory does not exist.");
628
- }
629
- // Update settings directory if websocket is not chosen
630
- const settingsPath = path.join(projectPath, "settings");
631
- const websocketFiles = ["restartWebsocket.cjs", "restart_websocket.bat"];
632
- websocketFiles.forEach((file) => {
633
- const filePath = path.join(settingsPath, file);
634
- if (fs.existsSync(filePath)) {
635
- fs.unlinkSync(filePath); // Delete each file if it exists
636
- console.log(`${file} was deleted successfully.`);
637
- }
638
- else {
639
- console.log(`${file} does not exist.`);
640
- }
641
- });
642
- }
643
- if (!answer.prisma) {
644
- const prismaPath = path.join(projectPath, "prisma");
645
- const prismClassPath = path.join(projectPath, "src", "Lib", "Prisma");
646
- // Check if the prisma directory exists
647
- if (fs.existsSync(prismaPath)) {
648
- // Use fs.rmSync with recursive option set to true to delete the directory and its contents
649
- fs.rmSync(prismaPath, { recursive: true, force: true }); // force option is not necessary but can be used to ensure deletion
650
- console.log("Prisma directory was deleted successfully.");
651
- }
652
- else {
653
- console.log("Prisma directory does not exist.");
654
- }
655
- // Check if the prisma class directory exists
656
- if (fs.existsSync(prismClassPath)) {
657
- // Use fs.rmSync with recursive option set to true to delete the directory and its contents
658
- fs.rmSync(prismClassPath, { recursive: true, force: true }); // force option is not necessary but can be used to ensure deletion
659
- console.log("Prisma class directory was deleted successfully.");
660
- }
661
- else {
662
- console.log("Prisma class directory does not exist.");
663
- }
664
- }
665
- if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
666
- const updateUninstallDependencies = [];
667
- if (!updateAnswer.tailwindcss) {
668
- const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
669
- tailwindFiles.forEach((file) => {
670
- const filePath = path.join(projectPath, file);
671
- if (fs.existsSync(filePath)) {
672
- fs.unlinkSync(filePath); // Delete each file if it exists
673
- console.log(`${file} was deleted successfully.`);
674
- }
675
- else {
676
- console.log(`${file} does not exist.`);
677
- }
678
- });
679
- updateUninstallDependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
680
- }
681
- if (!updateAnswer.websocket) {
682
- updateUninstallDependencies.push("chokidar-cli");
683
- }
684
- if (!updateAnswer.prisma) {
685
- updateUninstallDependencies.push("prisma", "@prisma/client");
686
- }
687
- if (updateUninstallDependencies.length > 0) {
688
- await uninstallDependencies(projectPath, updateUninstallDependencies, true);
689
- }
690
- }
691
- const version = await fetchPackageVersion("create-prisma-php-app");
692
- const bsConfig = bsConfigUrls(projectSettings);
693
- const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
694
- const prismaPhpConfig = {
695
- projectName: answer.projectName,
696
- projectRootPath: projectPathModified,
697
- phpRootPathExe: "D:\\xampp\\php\\php.exe",
698
- phpGenerateClassPath,
699
- bsTarget: bsConfig.bsTarget,
700
- bsPathRewrite: bsConfig.bsPathRewrite,
701
- tailwindcss: answer.tailwindcss,
702
- websocket: answer.websocket,
703
- prisma: answer.prisma,
704
- version,
705
- excludeFiles: (_f = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFiles) !== null && _f !== void 0 ? _f : [],
706
- };
707
- fs.writeFileSync(path.join(projectPath, "prisma-php.json"), JSON.stringify(prismaPhpConfig, null, 2), { flag: "w" });
708
- console.log(`${chalk.green("Success!")} Prisma PHP project successfully created in ${answer.projectName}!`);
709
- }
710
- catch (error) {
711
- console.error("Error while creating the project:", error);
712
- process.exit(1);
713
- }
714
- }
715
- main();
2
+ import{execSync}from"child_process";import fs from"fs";import{fileURLToPath}from"url";import path from"path";import chalk from"chalk";import prompts from"prompts";import https from"https";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename);let updateAnswer=null;function bsConfigUrls(e){const s=e.PROJECT_ROOT_PATH.indexOf("\\htdocs\\");if(-1===s)return{bsTarget:"",bsPathRewrite:{}};const t=e.PROJECT_ROOT_PATH.substring(0,s+"\\htdocs\\".length).replace(/\\/g,"\\\\"),n=e.PROJECT_ROOT_PATH.replace(new RegExp(`^${t}`),"").replace(/\\/g,"/");let i=`http://localhost/${n}`;i=i.endsWith("/")?i.slice(0,-1):i;const c=i.replace(/(?<!:)(\/\/+)/g,"/"),r=n.replace(/\/\/+/g,"/");return{bsTarget:`${c}/`,bsPathRewrite:{"^/":`/${r.startsWith("/")?r.substring(1):r}/`}}}function configureBrowserSyncCommand(e,s){const t=path.join(e,"settings","bs-config.cjs");return fs.writeFileSync(t,'const { createProxyMiddleware } = require("http-proxy-middleware");\n const fs = require("fs");\n \n const jsonData = fs.readFileSync("prisma-php.json", "utf8");\n const config = JSON.parse(jsonData);\n \n module.exports = {\n // First middleware: Set Cache-Control headers\n function(req, res, next) {\n res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");\n res.setHeader("Pragma", "no-cache");\n res.setHeader("Expires", "0");\n next();\n },\n // Use the \'middleware\' option to create a proxy that masks the deep URL.\n middleware: [\n // This middleware intercepts requests to the root and proxies them to the deep path.\n createProxyMiddleware("/", {\n target: config.bsTarget,\n changeOrigin: true,\n pathRewrite: config.bsPathRewrite,\n }),\n ],\n proxy: "http://localhost:3000", // Proxy the BrowserSync server.\n files: "src/**/*.*",\n notify: false,\n open: false,\n ghostMode: false,\n };',"utf8"),"browser-sync start --config settings/bs-config.cjs"}async function updatePackageJson(e,s,t){const n=path.join(e,"package.json");if(checkExcludeFiles(n))return;const i=JSON.parse(fs.readFileSync(n,"utf8")),c=configureBrowserSyncCommand(e,s);i.scripts=Object.assign(Object.assign({},i.scripts),{projectName:"node settings/project-name.cjs"});let r=[];t.tailwindcss&&(i.scripts=Object.assign(Object.assign({},i.scripts),{tailwind:"postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch"}),r.push("tailwind")),t.websocket&&(i.scripts=Object.assign(Object.assign({},i.scripts),{websocket:"node ./settings/restartWebsocket.cjs"}),r.push("websocket")),t.prisma&&(i.scripts=Object.assign(Object.assign({},i.scripts),{postinstall:"prisma generate"}));const a=Object.assign({},i.scripts);a["browser-sync"]=c,a.dev=r.length>0?`npm-run-all --parallel projectName browser-sync ${r.join(" ")}`:"npm-run-all --parallel projectName browser-sync",i.scripts=a,i.type="module",t.prisma&&(i.prisma={seed:"node prisma/seed.js"}),fs.writeFileSync(n,JSON.stringify(i,null,2))}async function updateComposerJson(e,s){const t=path.join(e,"composer.json");if(checkExcludeFiles(t))return;let n;if(fs.existsSync(t)){{const e=fs.readFileSync(t,"utf8");n=JSON.parse(e)}s.websocket&&(n.require=Object.assign(Object.assign({},n.require),{"cboden/ratchet":"^0.4.4"})),s.prisma&&(n.require=Object.assign(Object.assign({},n.require),{"ramsey/uuid":"5.x-dev","hidehalo/nanoid-php":"1.x-dev"})),fs.writeFileSync(t,JSON.stringify(n,null,2))}}async function updateIndexJsForWebSocket(e,s){if(!s.websocket)return;const t=path.join(e,"src","app","js","index.js");if(checkExcludeFiles(t))return;let n=fs.readFileSync(t,"utf8");n+='\n// WebSocket initialization\nconst ws = new WebSocket("ws://localhost:8080");\n',fs.writeFileSync(t,n,"utf8")}async function createUpdateGitignoreFile(e,s){const t=path.join(e,".gitignore");if(checkExcludeFiles(t))return;let n="";fs.existsSync(t)&&(n=fs.readFileSync(t,"utf8")),s.forEach((e=>{n.includes(e)||(n+=`\n${e}`)})),n=n.trimStart(),fs.writeFileSync(t,n)}function copyRecursiveSync(e,s){const t=fs.existsSync(e),n=t&&fs.statSync(e);if(t&&n&&n.isDirectory())fs.mkdirSync(s,{recursive:!0}),fs.readdirSync(e).forEach((t=>{copyRecursiveSync(path.join(e,t),path.join(s,t))}));else{if(checkExcludeFiles(s))return;fs.copyFileSync(e,s,0)}}async function executeCopy(e,s,t){s.forEach((({srcDir:s,destDir:n})=>{if(!t.prisma&&"/prisma-client-php"===s)return;copyRecursiveSync(path.join(__dirname,s),path.join(e,n))}))}function createOrUpdateTailwindConfig(e){const s=path.join(e,"tailwind.config.js");if(checkExcludeFiles(s))return;let t=fs.readFileSync(s,"utf8");const n=["./src/app/**/*.{html,js,php}"].map((e=>` "${e}"`)).join(",\n");t=t.replace(/content: \[\],/g,`content: [\n${n}\n],`),fs.writeFileSync(s,t,{flag:"w"})}function modifyPostcssConfig(e){const s=path.join(e,"postcss.config.js");if(checkExcludeFiles(s))return;fs.writeFileSync(s,"export default {\n plugins: {\n tailwindcss: {},\n autoprefixer: {},\n cssnano: {},\n },\n};",{flag:"w"})}function modifyLayoutPHP(e,s){const t=path.join(e,"src","app","layout.php");if(!checkExcludeFiles(t))try{let e=fs.readFileSync(t,"utf8");const n='\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"><\/script>\n <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">',i=s?` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${n}`:` <script src="https://cdn.tailwindcss.com"><\/script> ${n}`;e=e.replace("</head>",`${i}\n</head>`),fs.writeFileSync(t,e,{flag:"w"})}catch(e){}}async function createOrUpdateEnvFile(e,s){const t=path.join(e,".env");if(checkExcludeFiles(t))return;let n=fs.existsSync(t)?fs.readFileSync(t,"utf8"):"";n.includes(s)||(n+=`${""!==n?"\n\n":""}${s}`,fs.writeFileSync(t,n,{flag:"w"}))}function checkExcludeFiles(e){var s,t;return!!(null==updateAnswer?void 0:updateAnswer.isUpdate)&&(null!==(t=null===(s=null==updateAnswer?void 0:updateAnswer.excludeFilePath)||void 0===s?void 0:s.includes(e.replace(/\\/g,"/")))&&void 0!==t&&t)}async function createDirectoryStructure(e,s,t){const n=[{src:"/bootstrap.php",dest:"/bootstrap.php"},{src:"/bootstrap-ajax.php",dest:"/bootstrap-ajax.php"},{src:"/.htaccess",dest:"/.htaccess"},{src:"/../composer.json",dest:"/composer.json"}];(null==updateAnswer?void 0:updateAnswer.isUpdate)&&(n.push({src:"/.env",dest:"/.env"},{src:"/tsconfig.json",dest:"/tsconfig.json"}),updateAnswer.tailwindcss&&n.push({src:"/postcss.config.js",dest:"/postcss.config.js"},{src:"/tailwind.config.js",dest:"/tailwind.config.js"}));n.forEach((({src:s,dest:t})=>{const n=path.join(__dirname,s),i=path.join(e,t);if(checkExcludeFiles(i))return;const c=fs.readFileSync(n,"utf8");fs.writeFileSync(i,c,{flag:"w"})})),await executeCopy(e,[{srcDir:"/settings",destDir:"/settings"},{srcDir:"/prisma",destDir:"/prisma"},{srcDir:"/src",destDir:"/src"},{srcDir:"/../vendor",destDir:"/vendor"}],s),await updatePackageJson(e,t,s),await updateComposerJson(e,s),await updateIndexJsForWebSocket(e,s),s.tailwindcss?(createOrUpdateTailwindConfig(e),modifyLayoutPHP(e,!0),modifyPostcssConfig(e)):modifyLayoutPHP(e,!1);await createOrUpdateEnvFile(e,'# PHPMailer\n# SMTP_HOST=smtp.gmail.com or your SMTP host\n# SMTP_USERNAME=john.doe@gmail.com or your SMTP username\n# SMTP_PASSWORD=123456\n# SMTP_PORT=587 for TLS, 465 for SSL or your SMTP port\n# SMTP_ENCRYPTION=ssl or tls\n# MAIL_FROM=john.doe@gmail.com\n# MAIL_FROM_NAME="John Doe"'),await createUpdateGitignoreFile(e,["vendor"])}async function getAnswer(e={}){var s,t,n,i;const c=[];e.projectName||c.push({type:"text",name:"projectName",message:"What is your project named?",initial:"my-app"}),e.tailwindcss||c.push({type:"toggle",name:"tailwindcss",message:`Would you like to use ${chalk.blue("Tailwind CSS")}?`,initial:!0,active:"Yes",inactive:"No"}),e.websocket||c.push({type:"toggle",name:"websocket",message:`Would you like to use ${chalk.blue("Websocket")}?`,initial:!0,active:"Yes",inactive:"No"}),e.prisma||c.push({type:"toggle",name:"prisma",message:`Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,initial:!0,active:"Yes",inactive:"No"});const r=c,a=()=>{process.exit(0)};try{const c=await prompts(r,{onCancel:a});return 0===Object.keys(c).length?null:{projectName:c.projectName?String(c.projectName).trim().replace(/ /g,"-"):null!==(s=e.projectName)&&void 0!==s?s:"my-app",tailwindcss:null!==(t=c.tailwindcss)&&void 0!==t?t:e.tailwindcss,websocket:null!==(n=c.websocket)&&void 0!==n?n:e.websocket,prisma:null!==(i=c.prisma)&&void 0!==i?i:e.prisma}}catch(e){return null}}async function installDependencies(e,s,t=!1){fs.existsSync(path.join(e,"package.json"))||execSync("npm init -y",{stdio:"inherit",cwd:e}),s.forEach((e=>{}));const n=`npm install ${t?"--save-dev":""} ${s.join(" ")}`;execSync(n,{stdio:"inherit",cwd:e})}async function uninstallDependencies(e,s,t=!1){s.forEach((e=>{}));const n=`npm uninstall ${t?"--save-dev":"--save"} ${s.join(" ")}`;execSync(n,{stdio:"inherit",cwd:e})}function fetchPackageVersion(e){return new Promise(((s,t)=>{https.get(`https://registry.npmjs.org/${e}`,(e=>{let n="";e.on("data",(e=>n+=e)),e.on("end",(()=>{try{const e=JSON.parse(n);s(e["dist-tags"].latest)}catch(e){t(new Error("Failed to parse JSON response"))}}))})).on("error",(e=>t(e)))}))}const readJsonFile=e=>{const s=fs.readFileSync(e,"utf8");return JSON.parse(s)};async function main(){var e,s,t,n,i,c;try{const r=process.argv.slice(2);let a=r[0],o=null;if(a){const c={projectName:a,tailwindcss:r.includes("--tailwindcss"),websocket:r.includes("--websocket"),prisma:r.includes("--prisma")};if(o=await getAnswer(c),null===o)return;const p=process.cwd(),l=path.join(p,"prisma-php.json"),d=readJsonFile(l);let u=[];null===(e=d.excludeFiles)||void 0===e||e.map((e=>{const s=path.join(p,e);fs.existsSync(s)&&u.push(s.replace(/\\/g,"/"))})),updateAnswer={projectName:a,tailwindcss:null!==(s=null==o?void 0:o.tailwindcss)&&void 0!==s&&s,websocket:null!==(t=null==o?void 0:o.websocket)&&void 0!==t&&t,prisma:null!==(n=null==o?void 0:o.prisma)&&void 0!==n&&n,isUpdate:!0,excludeFiles:null!==(i=d.excludeFiles)&&void 0!==i?i:[],excludeFilePath:null!=u?u:[],filePath:p}}else o=await getAnswer();if(null===o)return;execSync("npm install -g browser-sync",{stdio:"inherit"}),a||fs.mkdirSync(o.projectName);const p=process.cwd();let l=a?p:path.join(p,o.projectName);a||process.chdir(o.projectName);const d=["typescript","@types/node","ts-node","http-proxy-middleware@^2.0.6","npm-run-all"];o.tailwindcss&&d.push("tailwindcss","autoprefixer","postcss","postcss-cli","cssnano"),o.websocket&&d.push("chokidar-cli"),o.prisma&&d.push("prisma","@prisma/client"),await installDependencies(l,d,!0),a||execSync("npx tsc --init",{stdio:"inherit"}),o.tailwindcss&&execSync("npx tailwindcss init -p",{stdio:"inherit"}),o.prisma&&execSync("npx prisma init",{stdio:"inherit"});const u=l.replace(/\\/g,"\\"),f=o.prisma?"src/Lib/Prisma/Classes":"",h={PROJECT_NAME:o.projectName,PROJECT_ROOT_PATH:u,PHP_ROOT_PATH_EXE:"D:\\\\xampp\\\\php\\\\php.exe",PHP_GENERATE_CLASS_PATH:f};await createDirectoryStructure(l,o,h);const m=path.join(l,"public");if(fs.existsSync(m)||fs.mkdirSync(m),!o.tailwindcss){const e=path.join(l,"src","app","css");["tailwind.css","styles.css"].forEach((s=>{const t=path.join(e,s);fs.existsSync(t)&&fs.unlinkSync(t)}))}if(!o.websocket){const e=path.join(l,"src","Lib","Websocket");fs.existsSync(e)&&fs.rmSync(e,{recursive:!0,force:!0});const s=path.join(l,"settings");["restartWebsocket.cjs","restart_websocket.bat"].forEach((e=>{const t=path.join(s,e);fs.existsSync(t)&&fs.unlinkSync(t)}))}if(!o.prisma){const e=path.join(l,"prisma"),s=path.join(l,"src","Lib","Prisma");fs.existsSync(e)&&fs.rmSync(e,{recursive:!0,force:!0}),fs.existsSync(s)&&fs.rmSync(s,{recursive:!0,force:!0})}if(null==updateAnswer?void 0:updateAnswer.isUpdate){const e=[];if(!updateAnswer.tailwindcss){["postcss.config.js","tailwind.config.js"].forEach((e=>{const s=path.join(l,e);fs.existsSync(s)&&fs.unlinkSync(s)})),e.push("tailwindcss","autoprefixer","postcss","postcss-cli","cssnano")}updateAnswer.websocket||e.push("chokidar-cli"),updateAnswer.prisma||e.push("prisma","@prisma/client"),e.length>0&&await uninstallDependencies(l,e,!0)}const w=await fetchPackageVersion("create-prisma-php-app"),y=bsConfigUrls(h),g=o.prisma?"src/Lib/Prisma/Classes":"",j={projectName:o.projectName,projectRootPath:u,phpRootPathExe:"D:\\xampp\\php\\php.exe",phpGenerateClassPath:g,bsTarget:y.bsTarget,bsPathRewrite:y.bsPathRewrite,tailwindcss:o.tailwindcss,websocket:o.websocket,prisma:o.prisma,version:w,excludeFiles:null!==(c=null==updateAnswer?void 0:updateAnswer.excludeFiles)&&void 0!==c?c:[]};fs.writeFileSync(path.join(l,"prisma-php.json"),JSON.stringify(j,null,2),{flag:"w"})}catch(e){process.exit(1)}}main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.9.15",
3
+ "version": "1.9.16",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",