create-prisma-php-app 1.22.507 → 1.23.0

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,638 +1,5 @@
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
- const nonBackendFiles = [
13
- "favicon.ico",
14
- "\\src\\app\\index.php",
15
- "metadata.php",
16
- "not-found.php",
17
- ];
18
- const dockerFiles = [
19
- ".dockerignore",
20
- "docker-compose.yml",
21
- "Dockerfile",
22
- "apache.conf",
23
- ];
24
- function bsConfigUrls(projectRootPath) {
25
- // Identify the base path dynamically up to and including 'htdocs'
26
- const htdocsIndex = projectRootPath.indexOf("\\htdocs\\");
27
- if (htdocsIndex === -1) {
28
- console.error(
29
- "Invalid PROJECT_ROOT_PATH. The path does not contain \\htdocs\\"
30
- );
31
- return {
32
- bsTarget: "",
33
- bsPathRewrite: {},
34
- };
35
- }
36
- // Extract the path up to and including 'htdocs\\'
37
- const basePathToRemove = projectRootPath.substring(
38
- 0,
39
- htdocsIndex + "\\htdocs\\".length
40
- );
41
- // Escape backslashes for the regex pattern
42
- const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
43
- // Remove the base path and replace backslashes with forward slashes for URL compatibility
44
- const relativeWebPath = projectRootPath
45
- .replace(new RegExp(`^${escapedBasePathToRemove}`), "")
46
- .replace(/\\/g, "/");
47
- // Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
48
- let proxyUrl = `http://localhost/${relativeWebPath}`;
49
- // Ensure the proxy URL does not end with a slash before appending '/public'
50
- proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
51
- // Clean the URL by replacing "//" with "/" but not affecting "http://"
52
- // We replace instances of "//" that are not preceded by ":"
53
- const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
54
- const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
55
- // Correct the relativeWebPath to ensure it does not start with a "/"
56
- const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
57
- ? cleanRelativeWebPath.substring(1)
58
- : cleanRelativeWebPath;
59
- return {
60
- bsTarget: `${cleanUrl}/`,
61
- bsPathRewrite: {
62
- "^/": `/${adjustedRelativeWebPath}/`,
63
- },
64
- };
65
- }
66
- async function updatePackageJson(baseDir, answer) {
67
- const packageJsonPath = path.join(baseDir, "package.json");
68
- if (checkExcludeFiles(packageJsonPath)) return;
69
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
70
- packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), {
71
- projectName: "node settings/project-name.js",
72
- });
73
- let answersToInclude = [];
74
- if (answer.tailwindcss) {
75
- packageJson.scripts = Object.assign(
76
- Object.assign({}, packageJson.scripts),
77
- {
78
- tailwind:
79
- "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch",
80
- }
81
- );
82
- answersToInclude.push("tailwind");
83
- }
84
- if (answer.websocket) {
85
- packageJson.scripts = Object.assign(
86
- Object.assign({}, packageJson.scripts),
87
- { websocket: "node settings/restart-websocket.js" }
88
- );
89
- answersToInclude.push("websocket");
90
- }
91
- // if (answer.prisma) {
92
- // packageJson.scripts = {
93
- // ...packageJson.scripts,
94
- // postinstall: "prisma generate",
95
- // };
96
- // }
97
- if (answer.docker) {
98
- packageJson.scripts = Object.assign(
99
- Object.assign({}, packageJson.scripts),
100
- { docker: "docker-compose up" }
101
- );
102
- answersToInclude.push("docker");
103
- }
104
- if (answer.swaggerDocs) {
105
- packageJson.scripts = Object.assign(
106
- Object.assign({}, packageJson.scripts),
107
- { "create-swagger-docs": "node settings/swagger-config.js" }
108
- );
109
- answersToInclude.push("create-swagger-docs");
110
- }
111
- // Initialize with existing scripts
112
- let updatedScripts = Object.assign({}, packageJson.scripts);
113
- updatedScripts.browserSync = "node settings/bs-config.js";
114
- updatedScripts.dev = `npm-run-all -s projectName browserSync ${answersToInclude.join(
115
- " "
116
- )}`;
117
- // Finally, assign the updated scripts back to packageJson
118
- packageJson.scripts = updatedScripts;
119
- packageJson.type = "module";
120
- if (answer.prisma)
121
- packageJson.prisma = {
122
- seed: "node prisma/seed.js",
123
- };
124
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
125
- }
126
- async function updateComposerJson(baseDir, answer) {
127
- const composerJsonPath = path.join(baseDir, "composer.json");
128
- if (checkExcludeFiles(composerJsonPath)) return;
129
- let composerJson;
130
- // Check if the composer.json file exists
131
- if (fs.existsSync(composerJsonPath)) {
132
- // Read the current composer.json content
133
- const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
134
- composerJson = JSON.parse(composerJsonContent);
135
- } else {
136
- console.error("composer.json does not exist.");
137
- return;
138
- }
139
- // Conditionally add WebSocket dependency
140
- if (answer.websocket) {
141
- composerJson.require = Object.assign(
142
- Object.assign({}, composerJson.require),
143
- { "cboden/ratchet": "^0.4.4" }
144
- );
145
- }
146
- if (answer.prisma) {
147
- composerJson.require = Object.assign(
148
- Object.assign({}, composerJson.require),
149
- { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" }
150
- );
151
- }
152
- // Write the modified composer.json back to the file
153
- fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
154
- console.log("composer.json updated successfully.");
155
- }
156
- async function updateIndexJsForWebSocket(baseDir, answer) {
157
- if (!answer.websocket) {
158
- return;
159
- }
160
- const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
161
- if (checkExcludeFiles(indexPath)) return;
162
- let indexContent = fs.readFileSync(indexPath, "utf8");
163
- // WebSocket initialization code to be appended
164
- const webSocketCode = `
165
- // WebSocket initialization
166
- const ws = new WebSocket("ws://localhost:8080");
167
- `;
168
- // Append WebSocket code if user chose to use WebSocket
169
- indexContent += webSocketCode;
170
- fs.writeFileSync(indexPath, indexContent, "utf8");
171
- console.log("WebSocket code added to index.js successfully.");
172
- }
173
- // This function updates the .gitignore file
174
- async function createUpdateGitignoreFile(baseDir, additions) {
175
- const gitignorePath = path.join(baseDir, ".gitignore");
176
- if (checkExcludeFiles(gitignorePath)) 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);
186
- }
187
- // Recursive copy function
188
- function copyRecursiveSync(src, dest, answer) {
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")) return;
198
- if (!answer.prisma && destLower.includes("src\\lib\\prisma")) return;
199
- if (
200
- (answer.backendOnly && destLower.includes("src\\app\\js")) ||
201
- (answer.backendOnly && destLower.includes("src\\app\\css"))
202
- )
203
- return;
204
- if (!answer.swaggerDocs && destLower.includes("src\\app\\swagger-docs"))
205
- return;
206
- const destModified = dest.replace(/\\/g, "/");
207
- if (
208
- (_a =
209
- updateAnswer === null || updateAnswer === void 0
210
- ? void 0
211
- : updateAnswer.excludeFilePath) === null || _a === void 0
212
- ? void 0
213
- : _a.includes(destModified)
214
- )
215
- return;
216
- if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
217
- fs.readdirSync(src).forEach((childItemName) => {
218
- copyRecursiveSync(
219
- path.join(src, childItemName),
220
- path.join(dest, childItemName),
221
- answer
222
- );
223
- });
224
- } else {
225
- if (checkExcludeFiles(dest)) return;
226
- if (
227
- !answer.tailwindcss &&
228
- (dest.includes("tailwind.css") || dest.includes("styles.css"))
229
- )
230
- return;
231
- if (
232
- !answer.websocket &&
233
- (dest.includes("restart-websocket.cjs") ||
234
- dest.includes("restart-websocket.bat"))
235
- )
236
- return;
237
- if (!answer.docker && dockerFiles.some((file) => dest.includes(file))) {
238
- return;
239
- }
240
- if (
241
- answer.backendOnly &&
242
- nonBackendFiles.some((file) => dest.includes(file))
243
- ) {
244
- return;
245
- }
246
- if (!answer.backendOnly && dest.includes("route.php")) return;
247
- if (!answer.swaggerDocs && dest.includes("swagger-config.js")) {
248
- return;
249
- }
250
- fs.copyFileSync(src, dest, 0);
251
- }
252
- }
253
- // Function to execute the recursive copy for entire directories
254
- async function executeCopy(baseDir, directoriesToCopy, answer) {
255
- directoriesToCopy.forEach(({ src: srcDir, dest: destDir }) => {
256
- const sourcePath = path.join(__dirname, srcDir);
257
- const destPath = path.join(baseDir, destDir);
258
- copyRecursiveSync(sourcePath, destPath, answer);
259
- });
260
- }
261
- function createOrUpdateTailwindConfig(baseDir) {
262
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
263
- const filePath = path.join(baseDir, "tailwind.config.js");
264
- if (checkExcludeFiles(filePath)) return;
265
- const newContent = [
266
- "./src/**/*.{html,js,php}",
267
- // Add more paths as needed
268
- ];
269
- let configData = fs.readFileSync(filePath, "utf8");
270
- console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
271
- const contentArrayString = newContent
272
- .map((item) => ` "${item}"`)
273
- .join(",\n");
274
- configData = configData.replace(
275
- /content: \[\],/g,
276
- `content: [\n${contentArrayString}\n],`
277
- );
278
- fs.writeFileSync(filePath, configData, { flag: "w" });
279
- console.log(chalk.green("Tailwind configuration updated successfully."));
280
- }
281
- function modifyPostcssConfig(baseDir) {
282
- const filePath = path.join(baseDir, "postcss.config.js");
283
- if (checkExcludeFiles(filePath)) return;
284
- const newContent = `export default {
285
- plugins: {
286
- tailwindcss: {},
287
- autoprefixer: {},
288
- cssnano: {},
289
- },
290
- };`;
291
- fs.writeFileSync(filePath, newContent, { flag: "w" });
292
- console.log(chalk.green("postcss.config.js updated successfully."));
293
- }
294
- function modifyLayoutPHP(baseDir, answer) {
295
- const layoutPath = path.join(baseDir, "src", "app", "layout.php");
296
- if (checkExcludeFiles(layoutPath)) return;
297
- try {
298
- let indexContent = fs.readFileSync(layoutPath, "utf8");
299
- let stylesAndLinks = "";
300
- if (!answer.backendOnly) {
301
- stylesAndLinks = `\n <link href="<?= $baseUrl; ?>/css/index.css" rel="stylesheet">\n <script src="<?= $baseUrl; ?>/js/index.js"></script>`;
302
- }
303
- // Tailwind CSS link or CDN script
304
- let tailwindLink = "";
305
- if (!answer.backendOnly) {
306
- tailwindLink = answer.tailwindcss
307
- ? ` <link href="<?= $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
308
- : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
309
- }
310
- // Insert before the closing </head> tag
311
- const breakLine = tailwindLink.length > 0 ? "\n" : "";
312
- indexContent = indexContent.replace(
313
- "</head>",
314
- `${tailwindLink}${breakLine} <!-- Dynamic Head -->
315
- <?= implode("\\n", $mainLayoutHead); ?>
316
- </head>`
317
- );
318
- fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
319
- console.log(
320
- chalk.green(
321
- `layout.php modified successfully for ${
322
- answer.tailwindcss ? "local Tailwind CSS" : "Tailwind CSS CDN"
323
- }.`
324
- )
325
- );
326
- } catch (error) {
327
- console.error(chalk.red("Error modifying layout.php:"), error);
328
- }
329
- }
330
- // This function updates or creates the .env file
331
- async function createOrUpdateEnvFile(baseDir, content) {
332
- const envPath = path.join(baseDir, ".env");
333
- if (checkExcludeFiles(envPath)) return;
334
- console.log("🚀 ~ content:", content);
335
- fs.writeFileSync(envPath, content, { flag: "w" });
336
- }
337
- function checkExcludeFiles(destPath) {
338
- var _a, _b;
339
- if (
340
- !(updateAnswer === null || updateAnswer === void 0
341
- ? void 0
342
- : updateAnswer.isUpdate)
343
- )
344
- return false;
345
- return (_b =
346
- (_a =
347
- updateAnswer === null || updateAnswer === void 0
348
- ? void 0
349
- : updateAnswer.excludeFilePath) === null || _a === void 0
350
- ? void 0
351
- : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0
352
- ? _b
353
- : false;
354
- }
355
- async function createDirectoryStructure(baseDir, answer) {
356
- console.log("🚀 ~ baseDir:", baseDir);
357
- console.log("🚀 ~ answer:", answer);
358
- const filesToCopy = [
359
- { src: "/bootstrap.php", dest: "/bootstrap.php" },
360
- { src: "/.htaccess", dest: "/.htaccess" },
361
- { src: "/../composer.json", dest: "/composer.json" },
362
- { src: "/tsconfig.json", dest: "/tsconfig.json" },
363
- ];
364
- if (answer.tailwindcss) {
365
- filesToCopy.push(
366
- { src: "/postcss.config.js", dest: "/postcss.config.js" },
367
- { src: "/tailwind.config.js", dest: "/tailwind.config.js" }
368
- );
369
- }
370
- const directoriesToCopy = [
371
- {
372
- src: "/settings",
373
- dest: "/settings",
374
- },
375
- {
376
- src: "/src",
377
- dest: "/src",
378
- },
379
- ];
380
- if (answer.backendOnly && answer.swaggerDocs) {
381
- directoriesToCopy.push({
382
- src: "/swagger-docs-layout.php",
383
- dest: "/src/app/layout.php",
384
- });
385
- }
386
- if (answer.prisma) {
387
- directoriesToCopy.push({
388
- src: "/prisma",
389
- dest: "/prisma",
390
- });
391
- }
392
- if (answer.docker) {
393
- directoriesToCopy.push(
394
- { src: "/.dockerignore", dest: "/.dockerignore" },
395
- { src: "/docker-compose.yml", dest: "/docker-compose.yml" },
396
- { src: "/Dockerfile", dest: "/Dockerfile" },
397
- { src: "/apache.conf", dest: "/apache.conf" }
398
- );
399
- }
400
- console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
401
- filesToCopy.forEach(({ src, dest }) => {
402
- const sourcePath = path.join(__dirname, src);
403
- const destPath = path.join(baseDir, dest);
404
- if (checkExcludeFiles(destPath)) return;
405
- const code = fs.readFileSync(sourcePath, "utf8");
406
- fs.writeFileSync(destPath, code, { flag: "w" });
407
- });
408
- await executeCopy(baseDir, directoriesToCopy, answer);
409
- await updatePackageJson(baseDir, answer);
410
- await updateComposerJson(baseDir, answer);
411
- if (!answer.backendOnly) {
412
- await updateIndexJsForWebSocket(baseDir, answer);
413
- }
414
- if (answer.tailwindcss) {
415
- createOrUpdateTailwindConfig(baseDir);
416
- modifyPostcssConfig(baseDir);
417
- }
418
- if (answer.tailwindcss || !answer.backendOnly || answer.swaggerDocs) {
419
- modifyLayoutPHP(baseDir, answer);
420
- }
421
- const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
422
- AUTH_SECRET=uxsjXVPHN038DEYls2Kw0QUgBcXKUyrjv416nIFWPY4=
423
-
424
- # PHPMailer
425
- # SMTP_HOST=smtp.gmail.com or your SMTP host
426
- # SMTP_USERNAME=john.doe@gmail.com or your SMTP username
427
- # SMTP_PASSWORD=123456
428
- # SMTP_PORT=587 for TLS, 465 for SSL or your SMTP port
429
- # SMTP_ENCRYPTION=ssl or tls
430
- # MAIL_FROM=john.doe@gmail.com
431
- # MAIL_FROM_NAME="John Doe"
432
-
433
- # SHOW ERRORS - Set to true to show errors in the browser for development only - Change this in production to false
434
- SHOW_ERRORS=true
435
-
436
- # APP TIMEZONE - Set your application timezone - Default is "UTC"
437
- APP_TIMEZONE="UTC"
438
-
439
- # APP ENV - Set your application environment - Default is "development" - Change this in production to "production"
440
- APP_ENV=development`;
441
- if (answer.prisma) {
442
- const prismaEnvContent = `# Environment variables declared in this file are automatically made available to Prisma.
443
- # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
444
-
445
- # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
446
- # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
447
-
448
- DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"`;
449
- const envContent = `${prismaEnvContent}\n\n${prismaPHPEnvContent}`;
450
- await createOrUpdateEnvFile(baseDir, envContent);
451
- } else {
452
- await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
453
- }
454
- // Add vendor to .gitignore
455
- await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
456
- }
457
- async function getAnswer(predefinedAnswers = {}) {
458
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
459
- console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
460
- const questionsArray = [];
461
- if (!predefinedAnswers.projectName) {
462
- questionsArray.push({
463
- type: "text",
464
- name: "projectName",
465
- message: "What is your project named?",
466
- initial: "my-app",
467
- });
468
- }
469
- if (!predefinedAnswers.backendOnly) {
470
- questionsArray.push({
471
- type: "toggle",
472
- name: "backendOnly",
473
- message: "Would you like to create a backend-only project?",
474
- initial: false,
475
- active: "Yes",
476
- inactive: "No",
477
- });
478
- }
479
- // Execute the initial questionsArray first
480
- const onCancel = () => {
481
- console.log(chalk.red("Operation cancelled by the user."));
482
- process.exit(0);
483
- };
484
- const initialResponse = await prompts(questionsArray, { onCancel });
485
- console.log("🚀 ~ initialResponse:", initialResponse);
486
- const nonBackendOnlyQuestionsArray = [];
487
- if (initialResponse.backendOnly || predefinedAnswers.backendOnly) {
488
- // If it's a backend-only project, skip Tailwind CSS, but ask other questions
489
- if (!predefinedAnswers.swaggerDocs) {
490
- nonBackendOnlyQuestionsArray.push({
491
- type: "toggle",
492
- name: "swaggerDocs",
493
- message: `Would you like to use ${chalk.blue("Swagger Docs")}?`,
494
- initial: false,
495
- active: "Yes",
496
- inactive: "No",
497
- });
498
- }
499
- if (!predefinedAnswers.websocket) {
500
- nonBackendOnlyQuestionsArray.push({
501
- type: "toggle",
502
- name: "websocket",
503
- message: `Would you like to use ${chalk.blue("Websocket")}?`,
504
- initial: true,
505
- active: "Yes",
506
- inactive: "No",
507
- });
508
- }
509
- if (!predefinedAnswers.prisma) {
510
- nonBackendOnlyQuestionsArray.push({
511
- type: "toggle",
512
- name: "prisma",
513
- message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
514
- initial: true,
515
- active: "Yes",
516
- inactive: "No",
517
- });
518
- }
519
- if (!predefinedAnswers.docker) {
520
- nonBackendOnlyQuestionsArray.push({
521
- type: "toggle",
522
- name: "docker",
523
- message: `Would you like to use ${chalk.blue("Docker")}?`,
524
- initial: false,
525
- active: "Yes",
526
- inactive: "No",
527
- });
528
- }
529
- } else {
530
- // If it's not a backend-only project, ask Tailwind CSS as well
531
- if (!predefinedAnswers.swaggerDocs) {
532
- nonBackendOnlyQuestionsArray.push({
533
- type: "toggle",
534
- name: "swaggerDocs",
535
- message: `Would you like to use ${chalk.blue("Swagger Docs")}?`,
536
- initial: false,
537
- active: "Yes",
538
- inactive: "No",
539
- });
540
- }
541
- if (!predefinedAnswers.tailwindcss) {
542
- nonBackendOnlyQuestionsArray.push({
543
- type: "toggle",
544
- name: "tailwindcss",
545
- message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
546
- initial: true,
547
- active: "Yes",
548
- inactive: "No",
549
- });
550
- }
551
- if (!predefinedAnswers.websocket) {
552
- nonBackendOnlyQuestionsArray.push({
553
- type: "toggle",
554
- name: "websocket",
555
- message: `Would you like to use ${chalk.blue("Websocket")}?`,
556
- initial: true,
557
- active: "Yes",
558
- inactive: "No",
559
- });
560
- }
561
- if (!predefinedAnswers.prisma) {
562
- nonBackendOnlyQuestionsArray.push({
563
- type: "toggle",
564
- name: "prisma",
565
- message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
566
- initial: true,
567
- active: "Yes",
568
- inactive: "No",
569
- });
570
- }
571
- if (!predefinedAnswers.docker) {
572
- nonBackendOnlyQuestionsArray.push({
573
- type: "toggle",
574
- name: "docker",
575
- message: `Would you like to use ${chalk.blue("Docker")}?`,
576
- initial: false,
577
- active: "Yes",
578
- inactive: "No",
579
- });
580
- }
581
- }
582
- const nonBackendOnlyResponse = await prompts(nonBackendOnlyQuestionsArray, {
583
- onCancel,
584
- });
585
- console.log("🚀 ~ nonBackendOnlyResponse:", nonBackendOnlyResponse);
586
- return {
587
- projectName: initialResponse.projectName
588
- ? String(initialResponse.projectName).trim().replace(/ /g, "-")
589
- : (_a = predefinedAnswers.projectName) !== null && _a !== void 0
590
- ? _a
591
- : "my-app",
592
- backendOnly:
593
- (_c =
594
- (_b = initialResponse.backendOnly) !== null && _b !== void 0
595
- ? _b
596
- : predefinedAnswers.backendOnly) !== null && _c !== void 0
597
- ? _c
598
- : false,
599
- swaggerDocs:
600
- (_e =
601
- (_d = nonBackendOnlyResponse.swaggerDocs) !== null && _d !== void 0
602
- ? _d
603
- : predefinedAnswers.swaggerDocs) !== null && _e !== void 0
604
- ? _e
605
- : false,
606
- tailwindcss:
607
- (_g =
608
- (_f = nonBackendOnlyResponse.tailwindcss) !== null && _f !== void 0
609
- ? _f
610
- : predefinedAnswers.tailwindcss) !== null && _g !== void 0
611
- ? _g
612
- : false,
613
- websocket:
614
- (_j =
615
- (_h = nonBackendOnlyResponse.websocket) !== null && _h !== void 0
616
- ? _h
617
- : predefinedAnswers.websocket) !== null && _j !== void 0
618
- ? _j
619
- : false,
620
- prisma:
621
- (_l =
622
- (_k = nonBackendOnlyResponse.prisma) !== null && _k !== void 0
623
- ? _k
624
- : predefinedAnswers.prisma) !== null && _l !== void 0
625
- ? _l
626
- : false,
627
- docker:
628
- (_o =
629
- (_m = nonBackendOnlyResponse.docker) !== null && _m !== void 0
630
- ? _m
631
- : predefinedAnswers.docker) !== null && _o !== void 0
632
- ? _o
633
- : false,
634
- };
635
- }
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;const nonBackendFiles=["favicon.ico","\\src\\app\\index.php","metadata.php","not-found.php"],dockerFiles=[".dockerignore","docker-compose.yml","Dockerfile","apache.conf"];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 c=`http://localhost/${n}`;c=c.endsWith("/")?c.slice(0,-1):c;const i=c.replace(/(?<!:)(\/\/+)/g,"/"),o=n.replace(/\/\/+/g,"/");return{bsTarget:`${i}/`,bsPathRewrite:{"^/":`/${o.startsWith("/")?o.substring(1):o}/`}}}async function updatePackageJson(e,s){const t=path.join(e,"package.json");if(checkExcludeFiles(t))return;const n=JSON.parse(fs.readFileSync(t,"utf8"));n.scripts={...n.scripts,projectName:"tsx settings/project-name.ts"};let c=[];s.tailwindcss&&(n.scripts={...n.scripts,tailwind:"postcss src/app/css/tailwind.css -o src/app/css/styles.css --watch"},c.push("tailwind")),s.websocket&&(n.scripts={...n.scripts,websocket:"tsx settings/restart-websocket.ts"},c.push("websocket")),s.docker&&(n.scripts={...n.scripts,docker:"docker-compose up"},c.push("docker")),s.swaggerDocs&&(n.scripts={...n.scripts,"create-swagger-docs":"tsx settings/swagger-config.ts"},c.push("create-swagger-docs"));let i={...n.scripts};i.browserSync="tsx settings/bs-config.ts",i.dev=`npm-run-all -p projectName browserSync ${c.join(" ")}`,n.scripts=i,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={...n.require,"cboden/ratchet":"^0.4.4"}),s.prisma&&(n.require={...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){const n=fs.existsSync(e),c=n&&fs.statSync(e);if(n&&c&&c.isDirectory()){const n=s.toLowerCase();if(!t.websocket&&n.includes("src\\lib\\websocket"))return;if(!t.prisma&&n.includes("src\\lib\\prisma"))return;if(t.backendOnly&&n.includes("src\\app\\js")||t.backendOnly&&n.includes("src\\app\\css"))return;if(!t.swaggerDocs&&n.includes("src\\app\\swagger-docs"))return;const c=s.replace(/\\/g,"/");if(updateAnswer?.excludeFilePath?.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.ts")||s.includes("restart-websocket.bat")))return;if(!t.docker&&dockerFiles.some((e=>s.includes(e))))return;if(t.backendOnly&&nonBackendFiles.some((e=>s.includes(e))))return;if(!t.backendOnly&&s.includes("route.php"))return;if(!t.swaggerDocs&&s.includes("swagger-config.ts"))return;fs.copyFileSync(e,s,0)}}async function executeCopy(e,s,t){s.forEach((({src:s,dest: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/**/*.{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"),n="";s.backendOnly||(n='\n <link href="<?= $baseUrl; ?>/css/index.css" rel="stylesheet">\n <script src="<?= $baseUrl; ?>/js/index.js"><\/script>');let c="";s.backendOnly||(c=s.tailwindcss?` <link href="<?= $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${n}`:` <script src="https://cdn.tailwindcss.com"><\/script> ${n}`);const i=c.length>0?"\n":"";e=e.replace("</head>",`${c}${i} \x3c!-- Dynamic Head --\x3e\n <?= implode("\\n", $mainLayoutHead); ?>\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){return!!updateAnswer?.isUpdate&&(updateAnswer?.excludeFilePath?.includes(e.replace(/\\/g,"/"))??!1)}async function createDirectoryStructure(e,s){const t=[{src:"/bootstrap.php",dest:"/bootstrap.php"},{src:"/.htaccess",dest:"/.htaccess"},{src:"/../composer.json",dest:"/composer.json"},{src:"/tsconfig.json",dest:"/tsconfig.json"}];s.tailwindcss&&t.push({src:"/postcss.config.js",dest:"/postcss.config.js"},{src:"/tailwind.config.js",dest:"/tailwind.config.js"});const n=[{src:"/settings",dest:"/settings"},{src:"/src",dest:"/src"}];s.backendOnly&&s.swaggerDocs&&n.push({src:"/swagger-docs-layout.php",dest:"/src/app/layout.php"}),s.prisma&&n.push({src:"/prisma",dest:"/prisma"}),s.docker&&n.push({src:"/.dockerignore",dest:"/.dockerignore"},{src:"/docker-compose.yml",dest:"/docker-compose.yml"},{src:"/Dockerfile",dest:"/Dockerfile"},{src:"/apache.conf",dest:"/apache.conf"}),t.forEach((({src:s,dest:t})=>{const n=path.join(__dirname,s),c=path.join(e,t);if(checkExcludeFiles(c))return;const i=fs.readFileSync(n,"utf8");fs.writeFileSync(c,i,{flag:"w"})})),await executeCopy(e,n,s),await updatePackageJson(e,s),await updateComposerJson(e,s),s.backendOnly||await updateIndexJsForWebSocket(e,s),s.tailwindcss&&(createOrUpdateTailwindConfig(e),modifyPostcssConfig(e)),(s.tailwindcss||!s.backendOnly||s.swaggerDocs)&&modifyLayoutPHP(e,s);const c='# 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"\n\n# SHOW ERRORS - Set to true to show errors in the browser for development only - Change this in production to false\nSHOW_ERRORS=true\n\n# APP TIMEZONE - Set your application timezone - Default is "UTC"\nAPP_TIMEZONE="UTC"\n\n# APP ENV - Set your application environment - Default is "development" - Change this in production to "production"\nAPP_ENV=development';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${c}`;await createOrUpdateEnvFile(e,s)}else await createOrUpdateEnvFile(e,c);await createUpdateGitignoreFile(e,["vendor",".env","node_modules"])}async function getAnswer(e={}){const s=[];e.projectName||s.push({type:"text",name:"projectName",message:"What is your project named?",initial:"my-app"}),e.backendOnly||s.push({type:"toggle",name:"backendOnly",message:"Would you like to create a backend-only project?",initial:!1,active:"Yes",inactive:"No"});const t=()=>{process.exit(0)},n=await prompts(s,{onCancel:t}),c=[];n.backendOnly||e.backendOnly?(e.swaggerDocs||c.push({type:"toggle",name:"swaggerDocs",message:`Would you like to use ${chalk.blue("Swagger Docs")}?`,initial:!1,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"}),e.docker||c.push({type:"toggle",name:"docker",message:`Would you like to use ${chalk.blue("Docker")}?`,initial:!1,active:"Yes",inactive:"No"})):(e.swaggerDocs||c.push({type:"toggle",name:"swaggerDocs",message:`Would you like to use ${chalk.blue("Swagger Docs")}?`,initial:!1,active:"Yes",inactive:"No"}),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"}),e.docker||c.push({type:"toggle",name:"docker",message:`Would you like to use ${chalk.blue("Docker")}?`,initial:!1,active:"Yes",inactive:"No"}));const i=await prompts(c,{onCancel:t});return{projectName:n.projectName?String(n.projectName).trim().replace(/ /g,"-"):e.projectName??"my-app",backendOnly:n.backendOnly??e.backendOnly??!1,swaggerDocs:i.swaggerDocs??e.swaggerDocs??!1,tailwindcss:i.tailwindcss??e.tailwindcss??!1,websocket:i.websocket??e.websocket??!1,prisma:i.prisma??e.prisma??!1,docker:i.docker??e.docker??!1}}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)};function compareVersions(e,s){const t=e.split(".").map(Number),n=s.split(".").map(Number);for(let e=0;e<t.length;e++){if(t[e]>n[e])return 1;if(t[e]<n[e])return-1}return 0}function getInstalledPackageVersion(e){try{const s=execSync(`npm list -g ${e} --depth=0`).toString().match(new RegExp(`${e}@(\\d+\\.\\d+\\.\\d+)`));return s?s[1]:null}catch(e){return null}}
636
3
  /**
637
4
  * Install dependencies in the specified directory.
638
5
  * @param {string} baseDir - The base directory where to install the dependencies.
@@ -664,72 +31,7 @@ async function installDependencies(baseDir, dependencies, isDev = false) {
664
31
  cwd: baseDir,
665
32
  });
666
33
  }
667
- async function uninstallDependencies(baseDir, dependencies, isDev = false) {
668
- console.log("Uninstalling dependencies:");
669
- dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
670
- // Prepare the npm uninstall command with the appropriate flag for dev dependencies
671
- const npmUninstallCommand = `npm uninstall ${
672
- isDev ? "--save-dev" : "--save"
673
- } ${dependencies.join(" ")}`;
674
- // Execute the npm uninstall command
675
- execSync(npmUninstallCommand, {
676
- stdio: "inherit",
677
- cwd: baseDir,
678
- });
679
- }
680
- function fetchPackageVersion(packageName) {
681
- return new Promise((resolve, reject) => {
682
- https
683
- .get(`https://registry.npmjs.org/${packageName}`, (res) => {
684
- let data = "";
685
- res.on("data", (chunk) => (data += chunk));
686
- res.on("end", () => {
687
- try {
688
- const parsed = JSON.parse(data);
689
- resolve(parsed["dist-tags"].latest);
690
- } catch (error) {
691
- reject(new Error("Failed to parse JSON response"));
692
- }
693
- });
694
- })
695
- .on("error", (err) => reject(err));
696
- });
697
- }
698
- const readJsonFile = (filePath) => {
699
- const jsonData = fs.readFileSync(filePath, "utf8");
700
- return JSON.parse(jsonData);
701
- };
702
- function compareVersions(installedVersion, currentVersion) {
703
- const installedVersionArray = installedVersion.split(".").map(Number);
704
- const currentVersionArray = currentVersion.split(".").map(Number);
705
- for (let i = 0; i < installedVersionArray.length; i++) {
706
- if (installedVersionArray[i] > currentVersionArray[i]) {
707
- return 1;
708
- } else if (installedVersionArray[i] < currentVersionArray[i]) {
709
- return -1;
710
- }
711
- }
712
- return 0;
713
- }
714
- function getInstalledPackageVersion(packageName) {
715
- try {
716
- const output = execSync(`npm list -g ${packageName} --depth=0`).toString();
717
- const versionMatch = output.match(
718
- new RegExp(`${packageName}@(\\d+\\.\\d+\\.\\d+)`)
719
- );
720
- if (versionMatch) {
721
- return versionMatch[1];
722
- } else {
723
- console.error(`Package ${packageName} is not installed`);
724
- return null;
725
- }
726
- } catch (error) {
727
- console.error(error instanceof Error ? error.message : String(error));
728
- return null;
729
- }
730
- }
731
34
  async function main() {
732
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
733
35
  try {
734
36
  const args = process.argv.slice(2);
735
37
  let projectName = args[0];
@@ -750,7 +52,6 @@ async function main() {
750
52
  prisma: usePrisma,
751
53
  docker: useDocker,
752
54
  };
753
- console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
754
55
  answer = await getAnswer(predefinedAnswers);
755
56
  if (answer === null) {
756
57
  console.log(chalk.red("Installation cancelled."));
@@ -760,60 +61,22 @@ async function main() {
760
61
  const configPath = path.join(currentDir, "prisma-php.json");
761
62
  const localSettings = readJsonFile(configPath);
762
63
  let excludeFiles = [];
763
- (_a = localSettings.excludeFiles) === null || _a === void 0
764
- ? void 0
765
- : _a.map((file) => {
766
- const filePath = path.join(currentDir, file);
767
- if (fs.existsSync(filePath))
768
- excludeFiles.push(filePath.replace(/\\/g, "/"));
769
- });
64
+ localSettings.excludeFiles?.map((file) => {
65
+ const filePath = path.join(currentDir, file);
66
+ if (fs.existsSync(filePath))
67
+ excludeFiles.push(filePath.replace(/\\/g, "/"));
68
+ });
770
69
  updateAnswer = {
771
70
  projectName,
772
- backendOnly:
773
- (_b =
774
- answer === null || answer === void 0
775
- ? void 0
776
- : answer.backendOnly) !== null && _b !== void 0
777
- ? _b
778
- : false,
779
- swaggerDocs:
780
- (_c =
781
- answer === null || answer === void 0
782
- ? void 0
783
- : answer.swaggerDocs) !== null && _c !== void 0
784
- ? _c
785
- : false,
786
- tailwindcss:
787
- (_d =
788
- answer === null || answer === void 0
789
- ? void 0
790
- : answer.tailwindcss) !== null && _d !== void 0
791
- ? _d
792
- : false,
793
- websocket:
794
- (_e =
795
- answer === null || answer === void 0
796
- ? void 0
797
- : answer.websocket) !== null && _e !== void 0
798
- ? _e
799
- : false,
800
- prisma:
801
- (_f =
802
- answer === null || answer === void 0 ? void 0 : answer.prisma) !==
803
- null && _f !== void 0
804
- ? _f
805
- : false,
806
- docker:
807
- (_g =
808
- answer === null || answer === void 0 ? void 0 : answer.docker) !==
809
- null && _g !== void 0
810
- ? _g
811
- : false,
71
+ backendOnly: answer?.backendOnly ?? false,
72
+ swaggerDocs: answer?.swaggerDocs ?? false,
73
+ tailwindcss: answer?.tailwindcss ?? false,
74
+ websocket: answer?.websocket ?? false,
75
+ prisma: answer?.prisma ?? false,
76
+ docker: answer?.docker ?? false,
812
77
  isUpdate: true,
813
- excludeFiles:
814
- (_h = localSettings.excludeFiles) !== null && _h !== void 0 ? _h : [],
815
- excludeFilePath:
816
- excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
78
+ excludeFiles: localSettings.excludeFiles ?? [],
79
+ excludeFilePath: excludeFiles ?? [],
817
80
  filePath: currentDir,
818
81
  };
819
82
  } else {
@@ -856,7 +119,7 @@ async function main() {
856
119
  const dependencies = [
857
120
  "typescript",
858
121
  "@types/node",
859
- "ts-node",
122
+ "tsx",
860
123
  "http-proxy-middleware",
861
124
  "chalk",
862
125
  "npm-run-all",
@@ -912,11 +175,7 @@ async function main() {
912
175
  { stdio: "inherit" }
913
176
  );
914
177
  }
915
- if (
916
- updateAnswer === null || updateAnswer === void 0
917
- ? void 0
918
- : updateAnswer.isUpdate
919
- ) {
178
+ if (updateAnswer?.isUpdate) {
920
179
  const updateUninstallDependencies = [];
921
180
  if (updateAnswer.backendOnly) {
922
181
  nonBackendFiles.forEach((file) => {
@@ -950,7 +209,7 @@ async function main() {
950
209
  fs.rmSync(swaggerDocsFolder, { recursive: true, force: true }); // Use fs.rmSync instead of fs.rmdirSync
951
210
  console.log(`swagger-docs was deleted successfully.`);
952
211
  }
953
- const swaggerFiles = ["swagger-setup.js"];
212
+ const swaggerFiles = ["swagger-config.ts"];
954
213
  swaggerFiles.forEach((file) => {
955
214
  const filePath = path.join(projectPath, "settings", file);
956
215
  if (fs.existsSync(filePath)) {
@@ -983,7 +242,7 @@ async function main() {
983
242
  }
984
243
  if (!updateAnswer.websocket) {
985
244
  const websocketFiles = [
986
- "restart-websocket.js",
245
+ "restart-websocket.ts",
987
246
  "restart-websocket.bat",
988
247
  ];
989
248
  websocketFiles.forEach((file) => {
@@ -1052,26 +311,15 @@ async function main() {
1052
311
  websocket: answer.websocket,
1053
312
  prisma: answer.prisma,
1054
313
  docker: answer.docker,
1055
- ngrok: false,
1056
314
  version: latestVersionOfCreatePrismaPhpApp,
1057
- excludeFiles:
1058
- (_j =
1059
- updateAnswer === null || updateAnswer === void 0
1060
- ? void 0
1061
- : updateAnswer.excludeFiles) !== null && _j !== void 0
1062
- ? _j
1063
- : [],
315
+ excludeFiles: updateAnswer?.excludeFiles ?? [],
1064
316
  };
1065
317
  fs.writeFileSync(
1066
318
  path.join(projectPath, "prisma-php.json"),
1067
319
  JSON.stringify(prismaPhpConfig, null, 2),
1068
320
  { flag: "w" }
1069
321
  );
1070
- if (
1071
- updateAnswer === null || updateAnswer === void 0
1072
- ? void 0
1073
- : updateAnswer.isUpdate
1074
- ) {
322
+ if (updateAnswer?.isUpdate) {
1075
323
  execSync(
1076
324
  `C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`,
1077
325
  {
@@ -1086,11 +334,15 @@ async function main() {
1086
334
  }
1087
335
  );
1088
336
  }
337
+ console.log("\n=========================\n");
1089
338
  console.log(
1090
- `${chalk.green("Success!")} Prisma PHP project successfully created in ${
339
+ `${chalk.green(
340
+ "Success!"
341
+ )} Prisma PHP project successfully created in ${chalk.green(
1091
342
  answer.projectName
1092
- }!`
343
+ )}!`
1093
344
  );
345
+ console.log("\n=========================");
1094
346
  } catch (error) {
1095
347
  console.error("Error while creating the project:", error);
1096
348
  process.exit(1);