create-prisma-php-app 1.11.601 → 1.12.1

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
@@ -1,784 +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(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
- );
19
- return {
20
- bsTarget: "",
21
- bsPathRewrite: {},
22
- };
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
- }
54
- function configureBrowserSyncCommand(baseDir) {
55
- // TypeScript content to write
56
- const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
57
- const fs = require("fs");
58
-
59
- const jsonData = fs.readFileSync("prisma-php.json", "utf8");
60
- const config = JSON.parse(jsonData);
61
-
62
- module.exports = {
63
- proxy: "http://localhost:3000",
64
- middleware: [
65
- (req, res, next) => {
66
- res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
67
- res.setHeader("Pragma", "no-cache");
68
- res.setHeader("Expires", "0");
69
- next();
70
- },
71
- createProxyMiddleware({
72
- target: config.bsTarget,
73
- changeOrigin: true,
74
- pathRewrite: config.bsPathRewrite,
75
- }),
76
- ],
77
- files: "src/**/*.*",
78
- notify: false,
79
- open: false,
80
- ghostMode: false,
81
- };`;
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`;
87
- }
88
- 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
- // Initialize with existing scripts
122
- const updatedScripts = Object.assign({}, packageJson.scripts);
123
- // Conditionally add "browser-sync" command
124
- updatedScripts["browser-sync"] = browserSyncCommand;
125
- // Conditionally set the "dev" command
126
- updatedScripts.dev =
127
- answersToInclude.length > 0
128
- ? `npm-run-all --parallel projectName browser-sync ${answersToInclude.join(
129
- " "
130
- )}`
131
- : `npm-run-all --parallel projectName browser-sync`;
132
- // Finally, assign the updated scripts back to packageJson
133
- packageJson.scripts = updatedScripts;
134
- packageJson.type = "module";
135
- if (answer.prisma)
136
- packageJson.prisma = {
137
- seed: "node prisma/seed.js",
138
- };
139
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
140
- }
141
- async function updateComposerJson(baseDir, answer) {
142
- const composerJsonPath = path.join(baseDir, "composer.json");
143
- if (checkExcludeFiles(composerJsonPath)) return;
144
- let composerJson;
145
- // Check if the composer.json file exists
146
- if (fs.existsSync(composerJsonPath)) {
147
- // Read the current composer.json content
148
- const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
149
- composerJson = JSON.parse(composerJsonContent);
150
- } else {
151
- console.error("composer.json does not exist.");
152
- return;
153
- }
154
- // Conditionally add WebSocket dependency
155
- if (answer.websocket) {
156
- composerJson.require = Object.assign(
157
- Object.assign({}, composerJson.require),
158
- { "cboden/ratchet": "^0.4.4" }
159
- );
160
- }
161
- if (answer.prisma) {
162
- composerJson.require = Object.assign(
163
- Object.assign({}, composerJson.require),
164
- { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" }
165
- );
166
- }
167
- // Write the modified composer.json back to the file
168
- fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
169
- console.log("composer.json updated successfully.");
170
- }
171
- async function updateIndexJsForWebSocket(baseDir, answer) {
172
- if (!answer.websocket) {
173
- return;
174
- }
175
- const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
176
- if (checkExcludeFiles(indexPath)) return;
177
- let indexContent = fs.readFileSync(indexPath, "utf8");
178
- // WebSocket initialization code to be appended
179
- const webSocketCode = `
180
- // WebSocket initialization
181
- const ws = new WebSocket("ws://localhost:8080");
182
- `;
183
- // Append WebSocket code if user chose to use WebSocket
184
- indexContent += webSocketCode;
185
- fs.writeFileSync(indexPath, indexContent, "utf8");
186
- console.log("WebSocket code added to index.js successfully.");
187
- }
188
- // This function updates the .gitignore file
189
- async function createUpdateGitignoreFile(baseDir, additions) {
190
- const gitignorePath = path.join(baseDir, ".gitignore");
191
- if (checkExcludeFiles(gitignorePath)) return;
192
- let gitignoreContent = "";
193
- additions.forEach((addition) => {
194
- if (!gitignoreContent.includes(addition)) {
195
- gitignoreContent += `\n${addition}`;
196
- }
197
- });
198
- // Ensure there's no leading newline if the file was just created
199
- gitignoreContent = gitignoreContent.trimStart();
200
- fs.writeFileSync(gitignorePath, gitignoreContent);
201
- }
202
- // Recursive copy function
203
- function copyRecursiveSync(src, dest, answer) {
204
- var _a;
205
- console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
206
- console.log("🚀 ~ copyRecursiveSync ~ src:", src);
207
- const exists = fs.existsSync(src);
208
- const stats = exists && fs.statSync(src);
209
- const isDirectory = exists && stats && stats.isDirectory();
210
- if (isDirectory) {
211
- const destLower = dest.toLowerCase();
212
- if (!answer.websocket && destLower.includes("src\\lib\\websocket")) return;
213
- if (!answer.prisma && destLower.includes("src\\lib\\prisma")) return;
214
- const destModified = dest.replace(/\\/g, "/");
215
- if (
216
- (_a =
217
- updateAnswer === null || updateAnswer === void 0
218
- ? void 0
219
- : updateAnswer.excludeFilePath) === null || _a === void 0
220
- ? void 0
221
- : _a.includes(destModified)
222
- )
223
- return;
224
- if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
225
- fs.readdirSync(src).forEach((childItemName) => {
226
- copyRecursiveSync(
227
- path.join(src, childItemName),
228
- path.join(dest, childItemName),
229
- answer
230
- );
231
- });
232
- } else {
233
- if (checkExcludeFiles(dest)) return;
234
- if (
235
- !answer.tailwindcss &&
236
- (dest.includes("tailwind.css") || dest.includes("styles.css"))
237
- )
238
- return;
239
- if (
240
- !answer.websocket &&
241
- (dest.includes("restart-websocket.cjs") ||
242
- dest.includes("restart-websocket.bat"))
243
- )
244
- return;
245
- fs.copyFileSync(src, dest, 0);
246
- }
247
- }
248
- // Function to execute the recursive copy for entire directories
249
- async function executeCopy(baseDir, directoriesToCopy, answer) {
250
- directoriesToCopy.forEach(({ srcDir, destDir }) => {
251
- const sourcePath = path.join(__dirname, srcDir);
252
- const destPath = path.join(baseDir, destDir);
253
- copyRecursiveSync(sourcePath, destPath, answer);
254
- });
255
- }
256
- function createOrUpdateTailwindConfig(baseDir) {
257
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
258
- const filePath = path.join(baseDir, "tailwind.config.js");
259
- if (checkExcludeFiles(filePath)) return;
260
- const newContent = [
261
- "./src/app/**/*.{html,js,php}",
262
- // Add more paths as needed
263
- ];
264
- let configData = fs.readFileSync(filePath, "utf8");
265
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
266
- const contentArrayString = newContent
267
- .map((item) => ` "${item}"`)
268
- .join(",\n");
269
- configData = configData.replace(
270
- /content: \[\],/g,
271
- `content: [\n${contentArrayString}\n],`
272
- );
273
- fs.writeFileSync(filePath, configData, { flag: "w" });
274
- console.log(chalk.green("Tailwind configuration updated successfully."));
275
- }
276
- function modifyPostcssConfig(baseDir) {
277
- const filePath = path.join(baseDir, "postcss.config.js");
278
- if (checkExcludeFiles(filePath)) return;
279
- const newContent = `export default {
280
- plugins: {
281
- tailwindcss: {},
282
- autoprefixer: {},
283
- cssnano: {},
284
- },
285
- };`;
286
- fs.writeFileSync(filePath, newContent, { flag: "w" });
287
- console.log(chalk.green("postcss.config.js updated successfully."));
288
- }
289
- function modifyLayoutPHP(baseDir, useTailwind) {
290
- const layoutPath = path.join(baseDir, "src", "app", "layout.php");
291
- if (checkExcludeFiles(layoutPath)) return;
292
- try {
293
- let indexContent = fs.readFileSync(layoutPath, "utf8");
294
- 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">`;
295
- // Tailwind CSS link or CDN script
296
- const tailwindLink = useTailwind
297
- ? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
298
- : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
299
- // Insert before the closing </head> tag
300
- indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
301
- fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
302
- console.log(
303
- chalk.green(
304
- `index.php modified successfully for ${
305
- useTailwind ? "local Tailwind CSS" : "Tailwind CSS CDN"
306
- }.`
307
- )
308
- );
309
- } catch (error) {
310
- console.error(chalk.red("Error modifying index.php:"), error);
311
- }
312
- }
313
- // This function updates or creates the .env file
314
- async function createOrUpdateEnvFile(baseDir, content) {
315
- const envPath = path.join(baseDir, ".env");
316
- if (checkExcludeFiles(envPath)) return;
317
- console.log("🚀 ~ content:", content);
318
- fs.writeFileSync(envPath, content, { flag: "w" });
319
- }
320
- function checkExcludeFiles(destPath) {
321
- var _a, _b;
322
- if (
323
- !(updateAnswer === null || updateAnswer === void 0
324
- ? void 0
325
- : updateAnswer.isUpdate)
326
- )
327
- return false;
328
- return (_b =
329
- (_a =
330
- updateAnswer === null || updateAnswer === void 0
331
- ? void 0
332
- : updateAnswer.excludeFilePath) === null || _a === void 0
333
- ? void 0
334
- : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0
335
- ? _b
336
- : false;
337
- }
338
- async function createDirectoryStructure(baseDir, answer) {
339
- console.log("🚀 ~ baseDir:", baseDir);
340
- console.log("🚀 ~ answer:", answer);
341
- const filesToCopy = [
342
- { src: "/bootstrap.php", dest: "/bootstrap.php" },
343
- { src: "/.htaccess", dest: "/.htaccess" },
344
- { src: "/../composer.json", dest: "/composer.json" },
345
- ];
346
- if (
347
- updateAnswer === null || updateAnswer === void 0
348
- ? void 0
349
- : updateAnswer.isUpdate
350
- ) {
351
- filesToCopy.push({ src: "/tsconfig.json", dest: "/tsconfig.json" });
352
- if (updateAnswer.tailwindcss) {
353
- filesToCopy.push(
354
- { src: "/postcss.config.js", dest: "/postcss.config.js" },
355
- { src: "/tailwind.config.js", dest: "/tailwind.config.js" }
356
- );
357
- }
358
- }
359
- const directoriesToCopy = [
360
- {
361
- srcDir: "/settings",
362
- destDir: "/settings",
363
- },
364
- {
365
- srcDir: "/src",
366
- destDir: "/src",
367
- },
368
- ];
369
- if (answer.prisma) {
370
- directoriesToCopy.push({
371
- srcDir: "/prisma",
372
- destDir: "/prisma",
373
- });
374
- }
375
- console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
376
- filesToCopy.forEach(({ src, dest }) => {
377
- const sourcePath = path.join(__dirname, src);
378
- const destPath = path.join(baseDir, dest);
379
- if (checkExcludeFiles(destPath)) return;
380
- const code = fs.readFileSync(sourcePath, "utf8");
381
- fs.writeFileSync(destPath, code, { flag: "w" });
382
- });
383
- await executeCopy(baseDir, directoriesToCopy, answer);
384
- await updatePackageJson(baseDir, answer);
385
- await updateComposerJson(baseDir, answer);
386
- await updateIndexJsForWebSocket(baseDir, answer);
387
- if (answer.tailwindcss) {
388
- createOrUpdateTailwindConfig(baseDir);
389
- modifyLayoutPHP(baseDir, true);
390
- modifyPostcssConfig(baseDir);
391
- } else {
392
- modifyLayoutPHP(baseDir, false);
393
- }
394
- const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
395
- AUTH_SECRET=uxsjXVPHN038DEYls2Kw0QUgBcXKUyrjv416nIFWPY4=
396
-
397
- # PHPMailer
398
- # SMTP_HOST=smtp.gmail.com or your SMTP host
399
- # SMTP_USERNAME=john.doe@gmail.com or your SMTP username
400
- # SMTP_PASSWORD=123456
401
- # SMTP_PORT=587 for TLS, 465 for SSL or your SMTP port
402
- # SMTP_ENCRYPTION=ssl or tls
403
- # MAIL_FROM=john.doe@gmail.com
404
- # MAIL_FROM_NAME="John Doe"`;
405
- if (answer.prisma) {
406
- const prismaEnvContent = `# Environment variables declared in this file are automatically made available to Prisma.
407
- # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
408
-
409
- # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
410
- # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
411
-
412
- DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"`;
413
- const envContent = `${prismaEnvContent}\n\n${prismaPHPEnvContent}`;
414
- await createOrUpdateEnvFile(baseDir, envContent);
415
- } else {
416
- await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
417
- }
418
- // Add vendor to .gitignore
419
- await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
420
- }
421
- async function getAnswer(predefinedAnswers = {}) {
422
- var _a, _b, _c, _d;
423
- console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
424
- const questionsArray = [];
425
- if (!predefinedAnswers.projectName) {
426
- questionsArray.push({
427
- type: "text",
428
- name: "projectName",
429
- message: "What is your project named?",
430
- initial: "my-app",
431
- });
432
- }
433
- if (!predefinedAnswers.tailwindcss) {
434
- questionsArray.push({
435
- type: "toggle",
436
- name: "tailwindcss",
437
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
438
- initial: true,
439
- active: "Yes",
440
- inactive: "No",
441
- });
442
- }
443
- if (!predefinedAnswers.websocket) {
444
- questionsArray.push({
445
- type: "toggle",
446
- name: "websocket",
447
- message: `Would you like to use ${chalk.blue("Websocket")}?`,
448
- initial: true,
449
- active: "Yes",
450
- inactive: "No",
451
- });
452
- }
453
- if (!predefinedAnswers.prisma) {
454
- questionsArray.push({
455
- type: "toggle",
456
- name: "prisma",
457
- message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
458
- initial: true,
459
- active: "Yes",
460
- inactive: "No",
461
- });
462
- }
463
- const questions = questionsArray;
464
- console.log("🚀 ~ questions:", questions);
465
- if (questions.length === 0 && predefinedAnswers.projectName) {
466
- return predefinedAnswers;
467
- }
468
- const onCancel = () => {
469
- console.log(chalk.red("Operation cancelled by the user."));
470
- process.exit(0);
471
- };
472
- try {
473
- const response = await prompts(questions, { onCancel });
474
- console.log("🚀 ~ response:", response);
475
- if (Object.keys(response).length === 0) {
476
- return null;
477
- }
478
- return {
479
- projectName: response.projectName
480
- ? String(response.projectName).trim().replace(/ /g, "-")
481
- : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
482
- ? _a
483
- : "my-app",
484
- tailwindcss:
485
- (_b = response.tailwindcss) !== null && _b !== void 0
486
- ? _b
487
- : predefinedAnswers.tailwindcss,
488
- websocket:
489
- (_c = response.websocket) !== null && _c !== void 0
490
- ? _c
491
- : predefinedAnswers.websocket,
492
- prisma:
493
- (_d = response.prisma) !== null && _d !== void 0
494
- ? _d
495
- : predefinedAnswers.prisma,
496
- };
497
- } catch (error) {
498
- console.error(chalk.red("Prompt error:"), error);
499
- return null;
500
- }
501
- }
502
- /**
503
- * Install dependencies in the specified directory.
504
- * @param {string} baseDir - The base directory where to install the dependencies.
505
- * @param {string[]} dependencies - The list of dependencies to install.
506
- * @param {boolean} [isDev=false] - Whether to install the dependencies as devDependencies.
507
- */
508
- async function installDependencies(baseDir, dependencies, isDev = false) {
509
- console.log("Initializing new Node.js project...");
510
- // Initialize a package.json if it doesn't exist
511
- if (!fs.existsSync(path.join(baseDir, "package.json")))
512
- execSync("npm init -y", {
513
- stdio: "inherit",
514
- cwd: baseDir,
515
- });
516
- // Log the dependencies being installed
517
- console.log(
518
- `${
519
- isDev ? "Installing development dependencies" : "Installing dependencies"
520
- }:`
521
- );
522
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
523
- // Prepare the npm install command with the appropriate flag for dev dependencies
524
- const npmInstallCommand = `npm install ${
525
- isDev ? "--save-dev" : ""
526
- } ${dependencies.join(" ")}`;
527
- // Execute the npm install command
528
- execSync(npmInstallCommand, {
529
- stdio: "inherit",
530
- cwd: baseDir,
531
- });
532
- }
533
- async function uninstallDependencies(baseDir, dependencies, isDev = false) {
534
- console.log("Uninstalling dependencies:");
535
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
536
- // Prepare the npm uninstall command with the appropriate flag for dev dependencies
537
- const npmUninstallCommand = `npm uninstall ${
538
- isDev ? "--save-dev" : "--save"
539
- } ${dependencies.join(" ")}`;
540
- // Execute the npm uninstall command
541
- execSync(npmUninstallCommand, {
542
- stdio: "inherit",
543
- cwd: baseDir,
544
- });
545
- }
546
- function fetchPackageVersion(packageName) {
547
- return new Promise((resolve, reject) => {
548
- https
549
- .get(`https://registry.npmjs.org/${packageName}`, (res) => {
550
- let data = "";
551
- res.on("data", (chunk) => (data += chunk));
552
- res.on("end", () => {
553
- try {
554
- const parsed = JSON.parse(data);
555
- resolve(parsed["dist-tags"].latest);
556
- } catch (error) {
557
- reject(new Error("Failed to parse JSON response"));
558
- }
559
- });
560
- })
561
- .on("error", (err) => reject(err));
562
- });
563
- }
564
- const readJsonFile = (filePath) => {
565
- const jsonData = fs.readFileSync(filePath, "utf8");
566
- return JSON.parse(jsonData);
567
- };
568
- async function main() {
569
- var _a, _b, _c, _d, _e, _f;
570
- try {
571
- const args = process.argv.slice(2);
572
- let projectName = args[0];
573
- let answer = null;
574
- if (projectName) {
575
- let useTailwind = args.includes("--tailwindcss");
576
- let useWebsocket = args.includes("--websocket");
577
- let usePrisma = args.includes("--prisma");
578
- const predefinedAnswers = {
579
- projectName,
580
- tailwindcss: useTailwind,
581
- websocket: useWebsocket,
582
- prisma: usePrisma,
583
- };
584
- console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
585
- answer = await getAnswer(predefinedAnswers);
586
- if (answer === null) {
587
- console.log(chalk.red("Installation cancelled."));
588
- return;
589
- }
590
- const currentDir = process.cwd();
591
- const configPath = path.join(currentDir, "prisma-php.json");
592
- const localSettings = readJsonFile(configPath);
593
- let excludeFiles = [];
594
- (_a = localSettings.excludeFiles) === null || _a === void 0
595
- ? void 0
596
- : _a.map((file) => {
597
- const filePath = path.join(currentDir, file);
598
- if (fs.existsSync(filePath))
599
- excludeFiles.push(filePath.replace(/\\/g, "/"));
600
- });
601
- updateAnswer = {
602
- projectName,
603
- tailwindcss:
604
- (_b =
605
- answer === null || answer === void 0
606
- ? void 0
607
- : answer.tailwindcss) !== null && _b !== void 0
608
- ? _b
609
- : false,
610
- websocket:
611
- (_c =
612
- answer === null || answer === void 0
613
- ? void 0
614
- : answer.websocket) !== null && _c !== void 0
615
- ? _c
616
- : false,
617
- prisma:
618
- (_d =
619
- answer === null || answer === void 0 ? void 0 : answer.prisma) !==
620
- null && _d !== void 0
621
- ? _d
622
- : false,
623
- isUpdate: true,
624
- excludeFiles:
625
- (_e = localSettings.excludeFiles) !== null && _e !== void 0 ? _e : [],
626
- excludeFilePath:
627
- excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
628
- filePath: currentDir,
629
- };
630
- } else {
631
- answer = await getAnswer();
632
- }
633
- if (answer === null) {
634
- console.log(chalk.red("Installation cancelled."));
635
- return;
636
- }
637
- execSync(`npm uninstall -g create-prisma-php-app`, { stdio: "inherit" });
638
- execSync(`npm install -g create-prisma-php-app@test-update`, {
639
- stdio: "inherit",
640
- }); // TODO: Uncomment this line before publishing the package
641
- // Support for browser-sync
642
- execSync(`npm install -g browser-sync`, { stdio: "inherit" });
643
- // Create the project directory
644
- if (!projectName) fs.mkdirSync(answer.projectName);
645
- const currentDir = process.cwd();
646
- let projectPath = projectName
647
- ? currentDir
648
- : path.join(currentDir, answer.projectName);
649
- if (!projectName) process.chdir(answer.projectName);
650
- const dependencies = [
651
- "typescript",
652
- "@types/node",
653
- "ts-node",
654
- "http-proxy-middleware@^3.0.0",
655
- "npm-run-all",
656
- ];
657
- if (answer.tailwindcss) {
658
- dependencies.push(
659
- "tailwindcss",
660
- "autoprefixer",
661
- "postcss",
662
- "postcss-cli",
663
- "cssnano"
664
- );
665
- }
666
- if (answer.websocket) {
667
- dependencies.push("chokidar-cli");
668
- }
669
- if (answer.prisma) {
670
- dependencies.push("prisma", "@prisma/client");
671
- }
672
- await installDependencies(projectPath, dependencies, true);
673
- if (!projectName) {
674
- execSync(`npx tsc --init`, { stdio: "inherit" });
675
- }
676
- if (answer.tailwindcss)
677
- execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
678
- if (answer.prisma) {
679
- if (!fs.existsSync(path.join(projectPath, "prisma")))
680
- execSync(`npx prisma init`, { stdio: "inherit" });
681
- }
682
- await createDirectoryStructure(projectPath, answer);
683
- const publicDirPath = path.join(projectPath, "public");
684
- if (!fs.existsSync(publicDirPath)) {
685
- fs.mkdirSync(publicDirPath);
686
- }
687
- if (
688
- updateAnswer === null || updateAnswer === void 0
689
- ? void 0
690
- : updateAnswer.isUpdate
691
- ) {
692
- const updateUninstallDependencies = [];
693
- if (!updateAnswer.tailwindcss) {
694
- const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
695
- tailwindFiles.forEach((file) => {
696
- const filePath = path.join(projectPath, file);
697
- if (fs.existsSync(filePath)) {
698
- fs.unlinkSync(filePath); // Delete each file if it exists
699
- console.log(`${file} was deleted successfully.`);
700
- } else {
701
- console.log(`${file} does not exist.`);
702
- }
703
- });
704
- updateUninstallDependencies.push(
705
- "tailwindcss",
706
- "autoprefixer",
707
- "postcss",
708
- "postcss-cli",
709
- "cssnano"
710
- );
711
- }
712
- if (!updateAnswer.websocket) {
713
- updateUninstallDependencies.push("chokidar-cli");
714
- }
715
- if (!updateAnswer.prisma) {
716
- updateUninstallDependencies.push("prisma", "@prisma/client");
717
- }
718
- if (updateUninstallDependencies.length > 0) {
719
- await uninstallDependencies(
720
- projectPath,
721
- updateUninstallDependencies,
722
- true
723
- );
724
- }
725
- }
726
- const version = await fetchPackageVersion("create-prisma-php-app");
727
- const projectPathModified = projectPath.replace(/\\/g, "\\");
728
- const bsConfig = bsConfigUrls(projectPathModified);
729
- const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
730
- const prismaPhpConfig = {
731
- projectName: answer.projectName,
732
- projectRootPath: projectPathModified,
733
- phpEnvironment: "XAMPP",
734
- phpRootPathExe: "C:\\xampp\\php\\php.exe",
735
- phpGenerateClassPath,
736
- bsTarget: bsConfig.bsTarget,
737
- bsPathRewrite: bsConfig.bsPathRewrite,
738
- tailwindcss: answer.tailwindcss,
739
- websocket: answer.websocket,
740
- prisma: answer.prisma,
741
- version,
742
- excludeFiles:
743
- (_f =
744
- updateAnswer === null || updateAnswer === void 0
745
- ? void 0
746
- : updateAnswer.excludeFiles) !== null && _f !== void 0
747
- ? _f
748
- : [],
749
- };
750
- fs.writeFileSync(
751
- path.join(projectPath, "prisma-php.json"),
752
- JSON.stringify(prismaPhpConfig, null, 2),
753
- { flag: "w" }
754
- );
755
- if (
756
- updateAnswer === null || updateAnswer === void 0
757
- ? void 0
758
- : updateAnswer.isUpdate
759
- ) {
760
- execSync(
761
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`,
762
- {
763
- stdio: "inherit",
764
- }
765
- );
766
- } else {
767
- execSync(
768
- `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`,
769
- {
770
- stdio: "inherit",
771
- }
772
- );
773
- }
774
- console.log(
775
- `${chalk.green("Success!")} Prisma PHP project successfully created in ${
776
- answer.projectName
777
- }!`
778
- );
779
- } catch (error) {
780
- console.error("Error while creating the project:", error);
781
- process.exit(1);
782
- }
783
- }
784
- 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.indexOf("\\htdocs\\");if(-1===s)return{bsTarget:"",bsPathRewrite:{}};const t=e.substring(0,s+"\\htdocs\\".length).replace(/\\/g,"\\\\"),n=e.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){const s=path.join(e,"settings","bs-config.cjs");return fs.writeFileSync(s,'const { createProxyMiddleware } = require("http-proxy-middleware");\nconst fs = require("fs");\n\nconst jsonData = fs.readFileSync("prisma-php.json", "utf8");\nconst config = JSON.parse(jsonData);\n\nmodule.exports = {\n proxy: "http://localhost:3000",\n middleware: [\n (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 createProxyMiddleware({\n target: config.bsTarget,\n changeOrigin: true,\n pathRewrite: config.bsPathRewrite,\n }),\n ],\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){const t=path.join(e,"package.json");if(checkExcludeFiles(t))return;const n=JSON.parse(fs.readFileSync(t,"utf8")),i=configureBrowserSyncCommand(e);n.scripts=Object.assign(Object.assign({},n.scripts),{projectName:"node settings/project-name.cjs"});let c=[];s.tailwindcss&&(n.scripts=Object.assign(Object.assign({},n.scripts),{tailwind:"postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch"}),c.push("tailwind")),s.websocket&&(n.scripts=Object.assign(Object.assign({},n.scripts),{websocket:"node ./settings/restart-websocket.cjs"}),c.push("websocket")),s.docker&&(n.scripts=Object.assign(Object.assign({},n.scripts),{docker:"docker-compose up"}),c.push("docker"));const r=Object.assign({},n.scripts);r["browser-sync"]=i,r.dev=c.length>0?`npm-run-all --parallel projectName browser-sync ${c.join(" ")}`:"npm-run-all --parallel projectName browser-sync",n.scripts=r,n.type="module",s.prisma&&(n.prisma={seed:"node prisma/seed.js"}),fs.writeFileSync(t,JSON.stringify(n,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="";s.forEach((e=>{n.includes(e)||(n+=`\n${e}`)})),n=n.trimStart(),fs.writeFileSync(t,n)}function copyRecursiveSync(e,s,t){var n;const i=fs.existsSync(e),c=i&&fs.statSync(e);if(i&&c&&c.isDirectory()){const i=s.toLowerCase();if(!t.websocket&&i.includes("src\\lib\\websocket"))return;if(!t.prisma&&i.includes("src\\lib\\prisma"))return;const c=s.replace(/\\/g,"/");if(null===(n=null==updateAnswer?void 0:updateAnswer.excludeFilePath)||void 0===n?void 0:n.includes(c))return;fs.existsSync(s)||fs.mkdirSync(s,{recursive:!0}),fs.readdirSync(e).forEach((n=>{copyRecursiveSync(path.join(e,n),path.join(s,n),t)}))}else{if(checkExcludeFiles(s))return;if(!t.tailwindcss&&(s.includes("tailwind.css")||s.includes("styles.css")))return;if(!t.websocket&&(s.includes("restart-websocket.cjs")||s.includes("restart-websocket.bat")))return;if(!t.docker&&(s.includes(".dockerignore")||s.includes("docker-compose.yml")||s.includes("Dockerfile")||s.includes("apache.conf")))return;fs.copyFileSync(e,s,0)}}async function executeCopy(e,s,t){s.forEach((({srcDir:s,destDir:n})=>{copyRecursiveSync(path.join(__dirname,s),path.join(e,n),t)}))}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");checkExcludeFiles(t)||fs.writeFileSync(t,s,{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){const t=[{src:"/bootstrap.php",dest:"/bootstrap.php"},{src:"/.htaccess",dest:"/.htaccess"},{src:"/../composer.json",dest:"/composer.json"}];(null==updateAnswer?void 0:updateAnswer.isUpdate)&&(t.push({src:"/tsconfig.json",dest:"/tsconfig.json"}),updateAnswer.tailwindcss&&t.push({src:"/postcss.config.js",dest:"/postcss.config.js"},{src:"/tailwind.config.js",dest:"/tailwind.config.js"}));const n=[{srcDir:"/settings",destDir:"/settings"},{srcDir:"/src",destDir:"/src"}];s.prisma&&n.push({srcDir:"/prisma",destDir:"/prisma"}),s.docker&&n.push({srcDir:"/.dockerignore",destDir:"/.dockerignore"},{srcDir:"/docker-compose.yml",destDir:"/docker-compose.yml"},{srcDir:"/Dockerfile",destDir:"/Dockerfile"},{srcDir:"/apache.conf",destDir:"/apache.conf"}),t.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,n,s),await updatePackageJson(e,s),await updateComposerJson(e,s),await updateIndexJsForWebSocket(e,s),s.tailwindcss?(createOrUpdateTailwindConfig(e),modifyLayoutPHP(e,!0),modifyPostcssConfig(e)):modifyLayoutPHP(e,!1);const i='# Prisma PHP Auth Secret Key For development only - Change this in production\nAUTH_SECRET=uxsjXVPHN038DEYls2Kw0QUgBcXKUyrjv416nIFWPY4= \n \n# 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"';if(s.prisma){const s=`${'# Environment variables declared in this file are automatically made available to Prisma.\n# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema\n\n# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.\n# See the documentation for all the connection string options: https://pris.ly/d/connection-strings\n\nDATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"'}\n\n${i}`;await createOrUpdateEnvFile(e,s)}else await createOrUpdateEnvFile(e,i);await createUpdateGitignoreFile(e,["vendor",".env","node_modules"])}async function getAnswer(e={}){var s,t,n,i,c;const r=[];e.projectName||r.push({type:"text",name:"projectName",message:"What is your project named?",initial:"my-app"}),e.tailwindcss||r.push({type:"toggle",name:"tailwindcss",message:`Would you like to use ${chalk.blue("Tailwind CSS")}?`,initial:!0,active:"Yes",inactive:"No"}),e.websocket||r.push({type:"toggle",name:"websocket",message:`Would you like to use ${chalk.blue("Websocket")}?`,initial:!0,active:"Yes",inactive:"No"}),e.prisma||r.push({type:"toggle",name:"prisma",message:`Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,initial:!0,active:"Yes",inactive:"No"}),e.docker||r.push({type:"toggle",name:"docker",message:`Would you like to use ${chalk.blue("Docker")}?`,initial:!1,active:"Yes",inactive:"No"});const o=r;if(0===o.length&&e.projectName)return e;const a=()=>{process.exit(0)};try{const r=await prompts(o,{onCancel:a});return 0===Object.keys(r).length?null:{projectName:r.projectName?String(r.projectName).trim().replace(/ /g,"-"):null!==(s=e.projectName)&&void 0!==s?s:"my-app",tailwindcss:null!==(t=r.tailwindcss)&&void 0!==t?t:e.tailwindcss,websocket:null!==(n=r.websocket)&&void 0!==n?n:e.websocket,prisma:null!==(i=r.prisma)&&void 0!==i?i:e.prisma,docker:null!==(c=r.docker)&&void 0!==c?c:e.docker}}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,r;try{const o=process.argv.slice(2);let a=o[0],l=null;if(a){const r={projectName:a,tailwindcss:o.includes("--tailwindcss"),websocket:o.includes("--websocket"),prisma:o.includes("--prisma"),docker:o.includes("--docker")};if(l=await getAnswer(r),null===l)return;const p=process.cwd(),d=path.join(p,"prisma-php.json"),u=readJsonFile(d);let h=[];null===(e=u.excludeFiles)||void 0===e||e.map((e=>{const s=path.join(p,e);fs.existsSync(s)&&h.push(s.replace(/\\/g,"/"))})),updateAnswer={projectName:a,tailwindcss:null!==(s=null==l?void 0:l.tailwindcss)&&void 0!==s&&s,websocket:null!==(t=null==l?void 0:l.websocket)&&void 0!==t&&t,prisma:null!==(n=null==l?void 0:l.prisma)&&void 0!==n&&n,docker:null!==(i=null==l?void 0:l.docker)&&void 0!==i&&i,isUpdate:!0,excludeFiles:null!==(c=u.excludeFiles)&&void 0!==c?c:[],excludeFilePath:null!=h?h:[],filePath:p}}else l=await getAnswer();if(null===l)return;execSync("npm uninstall -g create-prisma-php-app",{stdio:"inherit"}),execSync("npm install -g create-prisma-php-app",{stdio:"inherit"}),execSync("npm uninstall -g browser-sync",{stdio:"inherit"}),execSync("npm install -g browser-sync",{stdio:"inherit"}),a||fs.mkdirSync(l.projectName);const p=process.cwd();let d=a?p:path.join(p,l.projectName);a||process.chdir(l.projectName);const u=["typescript","@types/node","ts-node","http-proxy-middleware@^3.0.0","npm-run-all"];l.tailwindcss&&u.push("tailwindcss","autoprefixer","postcss","postcss-cli","cssnano"),l.websocket&&u.push("chokidar-cli"),l.prisma&&u.push("prisma","@prisma/client"),await installDependencies(d,u,!0),a||execSync("npx tsc --init",{stdio:"inherit"}),l.tailwindcss&&execSync("npx tailwindcss init -p",{stdio:"inherit"}),l.prisma&&(fs.existsSync(path.join(d,"prisma"))||execSync("npx prisma init",{stdio:"inherit"})),await createDirectoryStructure(d,l);const h=path.join(d,"public");if(fs.existsSync(h)||fs.mkdirSync(h),null==updateAnswer?void 0:updateAnswer.isUpdate){const e=[];if(!updateAnswer.tailwindcss){["postcss.config.js","tailwind.config.js"].forEach((e=>{const s=path.join(d,e);fs.existsSync(s)&&fs.unlinkSync(s)})),e.push("tailwindcss","autoprefixer","postcss","postcss-cli","cssnano")}if(updateAnswer.websocket||e.push("chokidar-cli"),updateAnswer.prisma||e.push("prisma","@prisma/client"),!updateAnswer.docker){[".dockerignore","docker-compose.yml","Dockerfile","apache.conf"].forEach((e=>{const s=path.join(d,e);fs.existsSync(s)&&fs.unlinkSync(s)}))}e.length>0&&await uninstallDependencies(d,e,!0)}const m=await fetchPackageVersion("create-prisma-php-app"),f=d.replace(/\\/g,"\\"),w=bsConfigUrls(f),y=l.prisma?"src/Lib/Prisma/Classes":"",g={projectName:l.projectName,projectRootPath:f,phpEnvironment:"XAMPP",phpRootPathExe:"C:\\xampp\\php\\php.exe",phpGenerateClassPath:y,bsTarget:w.bsTarget,bsPathRewrite:w.bsPathRewrite,tailwindcss:l.tailwindcss,websocket:l.websocket,prisma:l.prisma,docker:l.docker,version:m,excludeFiles:null!==(r=null==updateAnswer?void 0:updateAnswer.excludeFiles)&&void 0!==r?r:[]};fs.writeFileSync(path.join(d,"prisma-php.json"),JSON.stringify(g,null,2),{flag:"w"}),(null==updateAnswer?void 0:updateAnswer.isUpdate)?execSync("C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update",{stdio:"inherit"}):execSync("C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install",{stdio:"inherit"})}catch(e){process.exit(1)}}main();