create-prisma-php-app 1.9.19 → 1.9.21

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