create-prisma-php-app 1.11.526 → 1.11.528
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 +72 -93
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ function bsConfigUrls(projectSettings) {
|
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
function configureBrowserSyncCommand(baseDir
|
|
55
|
+
function configureBrowserSyncCommand(baseDir) {
|
|
56
56
|
// TypeScript content to write
|
|
57
57
|
const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
|
|
58
58
|
const fs = require("fs");
|
|
@@ -86,15 +86,12 @@ module.exports = {
|
|
|
86
86
|
// Return the Browser Sync command string, using the cleaned URL
|
|
87
87
|
return `browser-sync start --config settings/bs-config.cjs`;
|
|
88
88
|
}
|
|
89
|
-
async function updatePackageJson(baseDir,
|
|
89
|
+
async function updatePackageJson(baseDir, answer) {
|
|
90
90
|
const packageJsonPath = path.join(baseDir, "package.json");
|
|
91
91
|
if (checkExcludeFiles(packageJsonPath)) return;
|
|
92
92
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
93
93
|
// Use the new function to configure the Browser Sync command
|
|
94
|
-
const browserSyncCommand = configureBrowserSyncCommand(
|
|
95
|
-
baseDir,
|
|
96
|
-
projectSettings
|
|
97
|
-
);
|
|
94
|
+
const browserSyncCommand = configureBrowserSyncCommand(baseDir);
|
|
98
95
|
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), {
|
|
99
96
|
projectName: "node settings/project-name.cjs",
|
|
100
97
|
});
|
|
@@ -208,7 +205,7 @@ async function createUpdateGitignoreFile(baseDir, additions) {
|
|
|
208
205
|
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
209
206
|
}
|
|
210
207
|
// Recursive copy function
|
|
211
|
-
function copyRecursiveSync(src, dest) {
|
|
208
|
+
function copyRecursiveSync(src, dest, answer) {
|
|
212
209
|
console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
|
|
213
210
|
console.log("🚀 ~ copyRecursiveSync ~ src:", src);
|
|
214
211
|
const exists = fs.existsSync(src);
|
|
@@ -219,11 +216,23 @@ function copyRecursiveSync(src, dest) {
|
|
|
219
216
|
fs.readdirSync(src).forEach((childItemName) => {
|
|
220
217
|
copyRecursiveSync(
|
|
221
218
|
path.join(src, childItemName),
|
|
222
|
-
path.join(dest, childItemName)
|
|
219
|
+
path.join(dest, childItemName),
|
|
220
|
+
answer
|
|
223
221
|
);
|
|
224
222
|
});
|
|
225
223
|
} else {
|
|
226
224
|
if (checkExcludeFiles(dest)) return;
|
|
225
|
+
if (
|
|
226
|
+
!answer.tailwindcss &&
|
|
227
|
+
(dest.includes("tailwind.css") || dest.includes("styles.css"))
|
|
228
|
+
)
|
|
229
|
+
return;
|
|
230
|
+
if (
|
|
231
|
+
!answer.websocket &&
|
|
232
|
+
(dest.includes("restart-websocket.cjs") ||
|
|
233
|
+
dest.includes("restart-websocket.bat"))
|
|
234
|
+
)
|
|
235
|
+
return;
|
|
227
236
|
fs.copyFileSync(src, dest, 0);
|
|
228
237
|
}
|
|
229
238
|
}
|
|
@@ -231,9 +240,10 @@ function copyRecursiveSync(src, dest) {
|
|
|
231
240
|
async function executeCopy(baseDir, directoriesToCopy, answer) {
|
|
232
241
|
directoriesToCopy.forEach(({ srcDir, destDir }) => {
|
|
233
242
|
if (!answer.prisma && srcDir === "/prisma-client-php") return;
|
|
243
|
+
if (!answer.websocket && srcDir === "/src/Lib/Websocket") return;
|
|
234
244
|
const sourcePath = path.join(__dirname, srcDir);
|
|
235
245
|
const destPath = path.join(baseDir, destDir);
|
|
236
|
-
copyRecursiveSync(sourcePath, destPath);
|
|
246
|
+
copyRecursiveSync(sourcePath, destPath, answer);
|
|
237
247
|
});
|
|
238
248
|
}
|
|
239
249
|
function createOrUpdateTailwindConfig(baseDir) {
|
|
@@ -326,10 +336,9 @@ function checkExcludeFiles(destPath) {
|
|
|
326
336
|
? _b
|
|
327
337
|
: false;
|
|
328
338
|
}
|
|
329
|
-
async function createDirectoryStructure(baseDir, answer
|
|
339
|
+
async function createDirectoryStructure(baseDir, answer) {
|
|
330
340
|
console.log("🚀 ~ baseDir:", baseDir);
|
|
331
341
|
console.log("🚀 ~ answer:", answer);
|
|
332
|
-
console.log("🚀 ~ projectSettings:", projectSettings);
|
|
333
342
|
const filesToCopy = [
|
|
334
343
|
{ src: "/bootstrap.php", dest: "/bootstrap.php" },
|
|
335
344
|
{ src: "/.htaccess", dest: "/.htaccess" },
|
|
@@ -382,7 +391,7 @@ async function createDirectoryStructure(baseDir, answer, projectSettings) {
|
|
|
382
391
|
fs.writeFileSync(destPath, code, { flag: "w" });
|
|
383
392
|
});
|
|
384
393
|
await executeCopy(baseDir, directoriesToCopy, answer);
|
|
385
|
-
await updatePackageJson(baseDir,
|
|
394
|
+
await updatePackageJson(baseDir, answer);
|
|
386
395
|
await updateComposerJson(baseDir, answer);
|
|
387
396
|
await updateIndexJsForWebSocket(baseDir, answer);
|
|
388
397
|
if (answer.tailwindcss) {
|
|
@@ -675,73 +684,48 @@ async function main() {
|
|
|
675
684
|
if (!fs.existsSync(path.join(projectPath, "prisma")))
|
|
676
685
|
execSync(`npx prisma init`, { stdio: "inherit" });
|
|
677
686
|
}
|
|
678
|
-
|
|
679
|
-
const PHP_GENERATE_CLASS_PATH = answer.prisma
|
|
680
|
-
? "src/Lib/Prisma/Classes"
|
|
681
|
-
: "";
|
|
682
|
-
const projectSettings = {
|
|
683
|
-
PROJECT_NAME: answer.projectName,
|
|
684
|
-
PROJECT_ROOT_PATH: projectPathModified,
|
|
685
|
-
PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
|
|
686
|
-
PHP_GENERATE_CLASS_PATH,
|
|
687
|
-
};
|
|
688
|
-
await createDirectoryStructure(projectPath, answer, projectSettings);
|
|
689
|
-
// execSync(`composer install`, { stdio: "inherit" });
|
|
690
|
-
// execSync(`composer dump-autoload`, { stdio: "inherit" });
|
|
691
|
-
// Create settings file
|
|
692
|
-
// const settingsPath = path.join(
|
|
693
|
-
// projectPath,
|
|
694
|
-
// "settings",
|
|
695
|
-
// "project-settings.js"
|
|
696
|
-
// );
|
|
697
|
-
// const settingsCode = `export const projectSettings = {
|
|
698
|
-
// PROJECT_NAME: "${answer.projectName}",
|
|
699
|
-
// PROJECT_ROOT_PATH: "${projectPath.replace(/\\/g, "\\\\")}",
|
|
700
|
-
// PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
|
|
701
|
-
// PHP_GENERATE_CLASS_PATH: "src/Lib/Prisma/Classes",
|
|
702
|
-
// };`;
|
|
703
|
-
// fs.writeFileSync(settingsPath, settingsCode, { flag: "w" });
|
|
687
|
+
await createDirectoryStructure(projectPath, answer);
|
|
704
688
|
const publicDirPath = path.join(projectPath, "public");
|
|
705
689
|
if (!fs.existsSync(publicDirPath)) {
|
|
706
690
|
fs.mkdirSync(publicDirPath);
|
|
707
691
|
}
|
|
708
|
-
if (!answer.tailwindcss) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
692
|
+
// if (!answer.tailwindcss) {
|
|
693
|
+
// const cssPath = path.join(projectPath, "src", "app", "css");
|
|
694
|
+
// const tailwindFiles = ["tailwind.css", "styles.css"];
|
|
695
|
+
// tailwindFiles.forEach((file) => {
|
|
696
|
+
// const filePath = path.join(cssPath, 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
|
+
// }
|
|
721
705
|
// Update websocket if not chosen by the user
|
|
722
|
-
if (!answer.websocket) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
706
|
+
// if (!answer.websocket) {
|
|
707
|
+
// const wsPath = path.join(projectPath, "src", "Lib", "Websocket");
|
|
708
|
+
// // Check if the websocket directory exists
|
|
709
|
+
// if (fs.existsSync(wsPath)) {
|
|
710
|
+
// // Use fs.rmSync with recursive option set to true to delete the directory and its contents
|
|
711
|
+
// fs.rmSync(wsPath, { recursive: true, force: true }); // force option is not necessary but can be used to ensure deletion
|
|
712
|
+
// console.log("Websocket directory was deleted successfully.");
|
|
713
|
+
// } else {
|
|
714
|
+
// console.log("Websocket directory does not exist.");
|
|
715
|
+
// }
|
|
716
|
+
// // Update settings directory if websocket is not chosen
|
|
717
|
+
// const settingsPath = path.join(projectPath, "settings");
|
|
718
|
+
// const websocketFiles = ["restart-websocket.cjs", "restart-websocket.bat"];
|
|
719
|
+
// websocketFiles.forEach((file) => {
|
|
720
|
+
// const filePath = path.join(settingsPath, file);
|
|
721
|
+
// if (fs.existsSync(filePath)) {
|
|
722
|
+
// fs.unlinkSync(filePath); // Delete each file if it exists
|
|
723
|
+
// console.log(`${file} was deleted successfully.`);
|
|
724
|
+
// } else {
|
|
725
|
+
// console.log(`${file} does not exist.`);
|
|
726
|
+
// }
|
|
727
|
+
// });
|
|
728
|
+
// }
|
|
745
729
|
if (!answer.prisma) {
|
|
746
730
|
const prismaPath = path.join(projectPath, "prisma");
|
|
747
731
|
const prismClassPath = path.join(projectPath, "src", "Lib", "Prisma");
|
|
@@ -802,13 +786,23 @@ async function main() {
|
|
|
802
786
|
}
|
|
803
787
|
}
|
|
804
788
|
const version = await fetchPackageVersion("create-prisma-php-app");
|
|
789
|
+
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
790
|
+
const PHP_GENERATE_CLASS_PATH = answer.prisma
|
|
791
|
+
? "src/Lib/Prisma/Classes"
|
|
792
|
+
: "";
|
|
793
|
+
const projectSettings = {
|
|
794
|
+
PROJECT_NAME: answer.projectName,
|
|
795
|
+
PROJECT_ROOT_PATH: projectPathModified,
|
|
796
|
+
PHP_ROOT_PATH_EXE: "C:\\\\xampp\\\\php\\\\php.exe",
|
|
797
|
+
PHP_GENERATE_CLASS_PATH,
|
|
798
|
+
};
|
|
805
799
|
const bsConfig = bsConfigUrls(projectSettings);
|
|
806
800
|
const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
|
|
807
801
|
const prismaPhpConfig = {
|
|
808
802
|
projectName: answer.projectName,
|
|
809
803
|
projectRootPath: projectPathModified,
|
|
810
804
|
phpEnvironment: "XAMPP",
|
|
811
|
-
phpRootPathExe: "
|
|
805
|
+
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
812
806
|
phpGenerateClassPath,
|
|
813
807
|
bsTarget: bsConfig.bsTarget,
|
|
814
808
|
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
@@ -829,24 +823,9 @@ async function main() {
|
|
|
829
823
|
JSON.stringify(prismaPhpConfig, null, 2),
|
|
830
824
|
{ flag: "w" }
|
|
831
825
|
);
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
// process.chdir(projectPath);
|
|
836
|
-
// console.log("currentDir", process.cwd());
|
|
837
|
-
// execSync(`composer install`, { stdio: "inherit" });
|
|
838
|
-
// execSync(`php composer install`, { stdio: "inherit" });
|
|
839
|
-
// execSync(`D:\\xampp\\php\\php.exe composer install`, { stdio: "inherit" });
|
|
840
|
-
// execSync(`D:\\xampp\\php\\php.exe php composer install`, { stdio: "inherit" });
|
|
841
|
-
// Use the full path to the PHP executable and the Composer.phar
|
|
842
|
-
// execSync(
|
|
843
|
-
// `D:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`,
|
|
844
|
-
// { stdio: "inherit" }
|
|
845
|
-
// );
|
|
846
|
-
// execSync(`php C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`, {
|
|
847
|
-
// stdio: "inherit",
|
|
848
|
-
// });
|
|
849
|
-
execSync(`php composer install`, { stdio: "inherit" });
|
|
826
|
+
execSync(`php C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`, {
|
|
827
|
+
stdio: "inherit",
|
|
828
|
+
});
|
|
850
829
|
console.log(
|
|
851
830
|
`${chalk.green("Success!")} Prisma PHP project successfully created in ${
|
|
852
831
|
answer.projectName
|