create-prisma-php-app 1.6.35 → 1.6.36
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/.env +16 -0
- package/dist/index.js +460 -512
- package/dist/postcss.config.js +7 -0
- package/dist/tailwind.config.js +11 -0
- package/dist/tsconfig.json +109 -0
- package/package.json +1 -1
package/dist/.env
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Environment variables declared in this file are automatically made available to Prisma.
|
|
2
|
+
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
|
3
|
+
|
|
4
|
+
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
5
|
+
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
6
|
+
|
|
7
|
+
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
|
|
8
|
+
|
|
9
|
+
# PHPMailer
|
|
10
|
+
SMTP_HOST=
|
|
11
|
+
SMTP_USERNAME=
|
|
12
|
+
SMTP_PASSWORD=
|
|
13
|
+
SMTP_PORT=
|
|
14
|
+
SMTP_ENCRYPTION=ssl
|
|
15
|
+
MAIL_FROM=
|
|
16
|
+
MAIL_FROM_NAME=""
|
package/dist/index.js
CHANGED
|
@@ -10,40 +10,32 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
let UpdateAnswer = null;
|
|
12
12
|
function configureBrowserSyncCommand(baseDir, projectSettings) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
|
|
40
|
-
const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
|
|
41
|
-
// Correct the relativeWebPath to ensure it does not start with a "/"
|
|
42
|
-
const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
|
|
43
|
-
? cleanRelativeWebPath.substring(1)
|
|
44
|
-
: cleanRelativeWebPath;
|
|
45
|
-
// TypeScript content to write
|
|
46
|
-
const bsConfigTsContent = `
|
|
13
|
+
// Identify the base path dynamically up to and including 'htdocs'
|
|
14
|
+
const htdocsIndex = projectSettings.PROJECT_ROOT_PATH.indexOf("\\htdocs\\");
|
|
15
|
+
if (htdocsIndex === -1) {
|
|
16
|
+
console.error("Invalid PROJECT_ROOT_PATH. The path does not contain \\htdocs\\");
|
|
17
|
+
return ""; // Return an empty string or handle the error as appropriate
|
|
18
|
+
}
|
|
19
|
+
// Extract the path up to and including 'htdocs\\'
|
|
20
|
+
const basePathToRemove = projectSettings.PROJECT_ROOT_PATH.substring(0, htdocsIndex + "\\htdocs\\".length);
|
|
21
|
+
// Escape backslashes for the regex pattern
|
|
22
|
+
const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
|
|
23
|
+
// Remove the base path and replace backslashes with forward slashes for URL compatibility
|
|
24
|
+
const relativeWebPath = projectSettings.PROJECT_ROOT_PATH.replace(new RegExp(`^${escapedBasePathToRemove}`), "").replace(/\\/g, "/");
|
|
25
|
+
// Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
|
|
26
|
+
let proxyUrl = `http://localhost/${relativeWebPath}`;
|
|
27
|
+
// Ensure the proxy URL does not end with a slash before appending '/public'
|
|
28
|
+
proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
|
|
29
|
+
// Clean the URL by replacing "//" with "/" but not affecting "http://"
|
|
30
|
+
// We replace instances of "//" that are not preceded by ":"
|
|
31
|
+
const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
|
|
32
|
+
const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
|
|
33
|
+
// Correct the relativeWebPath to ensure it does not start with a "/"
|
|
34
|
+
const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
|
|
35
|
+
? cleanRelativeWebPath.substring(1)
|
|
36
|
+
: cleanRelativeWebPath;
|
|
37
|
+
// TypeScript content to write
|
|
38
|
+
const bsConfigTsContent = `
|
|
47
39
|
const { createProxyMiddleware } = require("http-proxy-middleware");
|
|
48
40
|
|
|
49
41
|
module.exports = {
|
|
@@ -73,266 +65,245 @@ function configureBrowserSyncCommand(baseDir, projectSettings) {
|
|
|
73
65
|
open: false,
|
|
74
66
|
ghostMode: false,
|
|
75
67
|
};`;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
// Determine the path and write the bs-config.js
|
|
69
|
+
const bsConfigPath = path.join(baseDir, "settings", "bs-config.cjs");
|
|
70
|
+
fs.writeFileSync(bsConfigPath, bsConfigTsContent, "utf8");
|
|
71
|
+
// Return the Browser Sync command string, using the cleaned URL
|
|
72
|
+
return `browser-sync start --config settings/bs-config.cjs`;
|
|
81
73
|
}
|
|
82
74
|
async function updatePackageJson(baseDir, projectSettings, answer) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
updatedScripts["browser-sync"] = browserSyncCommand;
|
|
116
|
-
}
|
|
117
|
-
// Conditionally set the "dev" command
|
|
118
|
-
updatedScripts.dev =
|
|
119
|
-
answersToInclude.length > 0
|
|
120
|
-
? `npm-run-all --parallel browser-sync ${answersToInclude.join(" ")}`
|
|
121
|
-
: browserSyncCommand;
|
|
122
|
-
// Finally, assign the updated scripts back to packageJson
|
|
123
|
-
packageJson.scripts = updatedScripts;
|
|
124
|
-
packageJson.type = "module";
|
|
125
|
-
packageJson.prisma = {
|
|
126
|
-
seed: "node prisma/seed.js",
|
|
127
|
-
};
|
|
128
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
75
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
76
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
77
|
+
// Use the new function to configure the Browser Sync command
|
|
78
|
+
const browserSyncCommand = configureBrowserSyncCommand(baseDir, projectSettings);
|
|
79
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { postinstall: "prisma generate" });
|
|
80
|
+
let answersToInclude = [];
|
|
81
|
+
if (answer.tailwindcss) {
|
|
82
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { tailwind: "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch" });
|
|
83
|
+
answersToInclude.push("tailwind");
|
|
84
|
+
}
|
|
85
|
+
if (answer.websocket) {
|
|
86
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { websocket: "node ./settings/restartWebsocket.cjs" });
|
|
87
|
+
answersToInclude.push("websocket");
|
|
88
|
+
}
|
|
89
|
+
// Initialize with existing scripts
|
|
90
|
+
const updatedScripts = Object.assign({}, packageJson.scripts);
|
|
91
|
+
// Conditionally add "browser-sync" command
|
|
92
|
+
if (answersToInclude.length > 0) {
|
|
93
|
+
updatedScripts["browser-sync"] = browserSyncCommand;
|
|
94
|
+
}
|
|
95
|
+
// Conditionally set the "dev" command
|
|
96
|
+
updatedScripts.dev =
|
|
97
|
+
answersToInclude.length > 0
|
|
98
|
+
? `npm-run-all --parallel browser-sync ${answersToInclude.join(" ")}`
|
|
99
|
+
: browserSyncCommand;
|
|
100
|
+
// Finally, assign the updated scripts back to packageJson
|
|
101
|
+
packageJson.scripts = updatedScripts;
|
|
102
|
+
packageJson.type = "module";
|
|
103
|
+
packageJson.prisma = {
|
|
104
|
+
seed: "node prisma/seed.js",
|
|
105
|
+
};
|
|
106
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
129
107
|
}
|
|
130
108
|
async function updateComposerJson(baseDir, answer) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.log("composer.json updated successfully.");
|
|
109
|
+
if (!answer.websocket)
|
|
110
|
+
return;
|
|
111
|
+
const composerJsonPath = path.join(baseDir, "composer.json");
|
|
112
|
+
let composerJson;
|
|
113
|
+
// Check if the composer.json file exists
|
|
114
|
+
if (fs.existsSync(composerJsonPath)) {
|
|
115
|
+
// Read the current composer.json content
|
|
116
|
+
const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
|
|
117
|
+
composerJson = JSON.parse(composerJsonContent);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.error("composer.json does not exist.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Conditionally add WebSocket dependency
|
|
124
|
+
if (answer.websocket) {
|
|
125
|
+
composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "cboden/ratchet": "^0.4.4" });
|
|
126
|
+
}
|
|
127
|
+
// Write the modified composer.json back to the file
|
|
128
|
+
fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
|
|
129
|
+
console.log("composer.json updated successfully.");
|
|
153
130
|
}
|
|
154
131
|
async function updateIndexJsForWebSocket(baseDir, answer) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
132
|
+
if (!answer.websocket) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
|
|
136
|
+
let indexContent = fs.readFileSync(indexPath, "utf8");
|
|
137
|
+
// WebSocket initialization code to be appended
|
|
138
|
+
const webSocketCode = `
|
|
162
139
|
// WebSocket initialization
|
|
163
140
|
const ws = new WebSocket("ws://localhost:8080");
|
|
164
141
|
`;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
142
|
+
// Append WebSocket code if user chose to use WebSocket
|
|
143
|
+
indexContent += webSocketCode;
|
|
144
|
+
fs.writeFileSync(indexPath, indexContent, "utf8");
|
|
145
|
+
console.log("WebSocket code added to index.js successfully.");
|
|
169
146
|
}
|
|
170
147
|
// This function updates the .gitignore file
|
|
171
148
|
async function createUpdateGitignoreFile(baseDir, additions) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
additions.forEach((addition) => {
|
|
179
|
-
if (!gitignoreContent.includes(addition)) {
|
|
180
|
-
gitignoreContent += `\n${addition}`;
|
|
149
|
+
const gitignorePath = path.join(baseDir, ".gitignore");
|
|
150
|
+
// Check if the .gitignore file exists, create if it doesn't
|
|
151
|
+
let gitignoreContent = "";
|
|
152
|
+
if (fs.existsSync(gitignorePath)) {
|
|
153
|
+
gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
|
|
181
154
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
155
|
+
additions.forEach((addition) => {
|
|
156
|
+
if (!gitignoreContent.includes(addition)) {
|
|
157
|
+
gitignoreContent += `\n${addition}`;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
// Ensure there's no leading newline if the file was just created
|
|
161
|
+
gitignoreContent = gitignoreContent.trimStart();
|
|
162
|
+
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
186
163
|
}
|
|
187
164
|
// Recursive copy function
|
|
188
165
|
function copyRecursiveSync(src, dest) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
166
|
+
const exists = fs.existsSync(src);
|
|
167
|
+
const stats = exists && fs.statSync(src);
|
|
168
|
+
const isDirectory = exists && stats && stats.isDirectory();
|
|
169
|
+
console.log("🚀 ~ copyRecursiveSync ~ isDirectory:", isDirectory);
|
|
170
|
+
if (isDirectory) {
|
|
171
|
+
if (fs.existsSync(dest)) {
|
|
172
|
+
fs.rmSync(dest, { recursive: true, force: true }); // Remove the directory if it exists
|
|
173
|
+
}
|
|
174
|
+
fs.mkdirSync(dest, { recursive: true }); // Recreate the directory
|
|
175
|
+
fs.readdirSync(src).forEach((childItemName) => {
|
|
176
|
+
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
fs.copyFileSync(src, dest); // This line ensures files are overwritten
|
|
196
181
|
}
|
|
197
|
-
fs.mkdirSync(dest, { recursive: true }); // Recreate the directory
|
|
198
|
-
fs.readdirSync(src).forEach((childItemName) => {
|
|
199
|
-
copyRecursiveSync(
|
|
200
|
-
path.join(src, childItemName),
|
|
201
|
-
path.join(dest, childItemName)
|
|
202
|
-
);
|
|
203
|
-
});
|
|
204
|
-
} else {
|
|
205
|
-
fs.copyFileSync(src, dest); // This line ensures files are overwritten
|
|
206
|
-
}
|
|
207
182
|
}
|
|
208
183
|
// Function to execute the recursive copy for entire directories
|
|
209
184
|
async function executeCopy(baseDir, directoriesToCopy) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
185
|
+
directoriesToCopy.forEach(({ srcDir, destDir }) => {
|
|
186
|
+
const sourcePath = path.join(__dirname, srcDir);
|
|
187
|
+
const destPath = path.join(baseDir, destDir);
|
|
188
|
+
copyRecursiveSync(sourcePath, destPath);
|
|
189
|
+
});
|
|
215
190
|
}
|
|
216
191
|
function createOrUpdateTailwindConfig(baseDir) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
);
|
|
232
|
-
fs.writeFileSync(filePath, configData, { flag: "w" });
|
|
233
|
-
console.log(chalk.green("Tailwind configuration updated successfully."));
|
|
192
|
+
console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
|
|
193
|
+
const filePath = path.join(baseDir, "tailwind.config.js");
|
|
194
|
+
const newContent = [
|
|
195
|
+
"./src/app/**/*.{html,js,php}",
|
|
196
|
+
// Add more paths as needed
|
|
197
|
+
];
|
|
198
|
+
let configData = fs.readFileSync(filePath, "utf8");
|
|
199
|
+
console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
|
|
200
|
+
const contentArrayString = newContent
|
|
201
|
+
.map((item) => ` "${item}"`)
|
|
202
|
+
.join(",\n");
|
|
203
|
+
configData = configData.replace(/content: \[\],/g, `content: [\n${contentArrayString}\n],`);
|
|
204
|
+
fs.writeFileSync(filePath, configData, { flag: "w" });
|
|
205
|
+
console.log(chalk.green("Tailwind configuration updated successfully."));
|
|
234
206
|
}
|
|
235
207
|
function modifyPostcssConfig(baseDir) {
|
|
236
|
-
|
|
237
|
-
|
|
208
|
+
const filePath = path.join(baseDir, "postcss.config.js");
|
|
209
|
+
const newContent = `export default {
|
|
238
210
|
plugins: {
|
|
239
211
|
tailwindcss: {},
|
|
240
212
|
autoprefixer: {},
|
|
241
213
|
cssnano: {},
|
|
242
214
|
},
|
|
243
215
|
};`;
|
|
244
|
-
|
|
245
|
-
|
|
216
|
+
fs.writeFileSync(filePath, newContent, { flag: "w" });
|
|
217
|
+
console.log(chalk.green("postcss.config.js updated successfully."));
|
|
246
218
|
}
|
|
247
219
|
function modifyIndexPHP(baseDir, useTailwind) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
)
|
|
265
|
-
);
|
|
266
|
-
} catch (error) {
|
|
267
|
-
console.error(chalk.red("Error modifying index.php:"), error);
|
|
268
|
-
}
|
|
220
|
+
const indexPath = path.join(baseDir, "src", "app", "layout.php");
|
|
221
|
+
try {
|
|
222
|
+
let indexContent = fs.readFileSync(indexPath, "utf8");
|
|
223
|
+
const stylesAndLinks = `\n <link href="<?php echo $baseUrl; ?>css/index.css" rel="stylesheet">\n <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">\n <script src="<?php echo $baseUrl; ?>js/index.js"></script>`;
|
|
224
|
+
// Tailwind CSS link or CDN script
|
|
225
|
+
const tailwindLink = useTailwind
|
|
226
|
+
? ` <link href="<?php echo $baseUrl; ?>css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
|
|
227
|
+
: ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
|
|
228
|
+
// Insert before the closing </head> tag
|
|
229
|
+
indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
|
|
230
|
+
fs.writeFileSync(indexPath, indexContent, { flag: "w" });
|
|
231
|
+
console.log(chalk.green(`index.php modified successfully for ${useTailwind ? "local Tailwind CSS" : "Tailwind CSS CDN"}.`));
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error(chalk.red("Error modifying index.php:"), error);
|
|
235
|
+
}
|
|
269
236
|
}
|
|
270
237
|
// This function updates or creates the .env file
|
|
271
238
|
async function createOrUpdateEnvFile(baseDir, content) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
239
|
+
const envPath = path.join(baseDir, ".env");
|
|
240
|
+
let envContent = fs.existsSync(envPath)
|
|
241
|
+
? fs.readFileSync(envPath, "utf8")
|
|
242
|
+
: "";
|
|
243
|
+
// Check if the content already exists in the .env file
|
|
244
|
+
if (!envContent.includes(content)) {
|
|
245
|
+
envContent += `${envContent !== "" ? "\n\n" : ""}${content}`;
|
|
246
|
+
fs.writeFileSync(envPath, envContent, { flag: "w" });
|
|
247
|
+
}
|
|
281
248
|
}
|
|
282
249
|
async function createDirectoryStructure(baseDir, answer, projectSettings) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
250
|
+
console.log("🚀 ~ baseDir:", baseDir);
|
|
251
|
+
console.log("🚀 ~ answer:", answer);
|
|
252
|
+
console.log("🚀 ~ projectSettings:", projectSettings);
|
|
253
|
+
const filesToCopy = [
|
|
254
|
+
{ src: "/bootstrap.php", dest: "/bootstrap.php" },
|
|
255
|
+
{ src: "/.htaccess", dest: "/.htaccess" },
|
|
256
|
+
{ src: "/../composer.json", dest: "/composer.json" },
|
|
257
|
+
];
|
|
258
|
+
if (UpdateAnswer === null || UpdateAnswer === void 0 ? void 0 : UpdateAnswer.isUpdate) {
|
|
259
|
+
filesToCopy.push({ src: "/dist/.env", dest: "/.env" }, { src: "/dist/postcss.config.js", dest: "/postcss.config.js" }, { src: "/dist/tailwind.config.js", dest: "/tailwind.config.js" }, { src: "/dist/tsconfig.json", dest: "/tsconfig.json" });
|
|
260
|
+
}
|
|
261
|
+
// if (answer.websocket) {
|
|
262
|
+
// filesToCopy.push({
|
|
263
|
+
// src: "/../composer-websocket.lock",
|
|
264
|
+
// dest: "/composer.lock",
|
|
265
|
+
// });
|
|
266
|
+
// } else {
|
|
267
|
+
// filesToCopy.push({ src: "/../composer.lock", dest: "/composer.lock" });
|
|
268
|
+
// }
|
|
269
|
+
const directoriesToCopy = [
|
|
270
|
+
{
|
|
271
|
+
srcDir: "/settings",
|
|
272
|
+
destDir: "/settings",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
srcDir: "/prisma",
|
|
276
|
+
destDir: "/prisma",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
srcDir: "/src",
|
|
280
|
+
destDir: "/src",
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
srcDir: "/../vendor",
|
|
284
|
+
destDir: "/vendor",
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
|
|
288
|
+
filesToCopy.forEach(({ src, dest }) => {
|
|
289
|
+
const sourcePath = path.join(__dirname, src);
|
|
290
|
+
const destPath = path.join(baseDir, dest);
|
|
291
|
+
const code = fs.readFileSync(sourcePath, "utf8");
|
|
292
|
+
fs.writeFileSync(destPath, code, { flag: "w" });
|
|
293
|
+
});
|
|
294
|
+
await executeCopy(baseDir, directoriesToCopy);
|
|
295
|
+
await updatePackageJson(baseDir, projectSettings, answer);
|
|
296
|
+
await updateComposerJson(baseDir, answer);
|
|
297
|
+
await updateIndexJsForWebSocket(baseDir, answer);
|
|
298
|
+
if (answer.tailwindcss) {
|
|
299
|
+
createOrUpdateTailwindConfig(baseDir);
|
|
300
|
+
modifyIndexPHP(baseDir, true);
|
|
301
|
+
modifyPostcssConfig(baseDir);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
modifyIndexPHP(baseDir, false);
|
|
305
|
+
}
|
|
306
|
+
const envContent = `# PHPMailer
|
|
336
307
|
SMTP_HOST=
|
|
337
308
|
SMTP_USERNAME=
|
|
338
309
|
SMTP_PASSWORD=
|
|
@@ -340,71 +311,64 @@ SMTP_PORT=
|
|
|
340
311
|
SMTP_ENCRYPTION=ssl
|
|
341
312
|
MAIL_FROM=
|
|
342
313
|
MAIL_FROM_NAME=""`;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
314
|
+
await createOrUpdateEnvFile(baseDir, envContent);
|
|
315
|
+
// Add vendor to .gitignore
|
|
316
|
+
await createUpdateGitignoreFile(baseDir, ["vendor"]);
|
|
346
317
|
}
|
|
347
318
|
async function getAnswer(predefinedAnswers = {}) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
if (!predefinedAnswers.tailwindcss) {
|
|
360
|
-
questions.push({
|
|
361
|
-
type: "toggle",
|
|
362
|
-
name: "tailwindcss",
|
|
363
|
-
message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
|
|
364
|
-
initial: true,
|
|
365
|
-
active: "Yes",
|
|
366
|
-
inactive: "No",
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
if (!predefinedAnswers.websocket) {
|
|
370
|
-
questions.push({
|
|
371
|
-
type: "toggle",
|
|
372
|
-
name: "websocket",
|
|
373
|
-
message: `Would you like to use ${chalk.blue("Websocket")}?`,
|
|
374
|
-
initial: true,
|
|
375
|
-
active: "Yes",
|
|
376
|
-
inactive: "No",
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
console.log("🚀 ~ questions:", questions);
|
|
380
|
-
const onCancel = () => {
|
|
381
|
-
return false;
|
|
382
|
-
};
|
|
383
|
-
try {
|
|
384
|
-
const response = await prompts(questions, { onCancel });
|
|
385
|
-
console.log("🚀 ~ response:", response);
|
|
386
|
-
if (Object.keys(response).length === 0 && !predefinedAnswers.projectName) {
|
|
387
|
-
return null;
|
|
319
|
+
var _a, _b, _c;
|
|
320
|
+
console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
|
|
321
|
+
const questions = [];
|
|
322
|
+
if (!predefinedAnswers.projectName) {
|
|
323
|
+
questions.push({
|
|
324
|
+
type: "text",
|
|
325
|
+
name: "projectName",
|
|
326
|
+
message: "What is your project named?",
|
|
327
|
+
initial: "my-app",
|
|
328
|
+
});
|
|
388
329
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
(
|
|
401
|
-
|
|
402
|
-
|
|
330
|
+
if (!predefinedAnswers.tailwindcss) {
|
|
331
|
+
questions.push({
|
|
332
|
+
type: "toggle",
|
|
333
|
+
name: "tailwindcss",
|
|
334
|
+
message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
|
|
335
|
+
initial: true,
|
|
336
|
+
active: "Yes",
|
|
337
|
+
inactive: "No",
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (!predefinedAnswers.websocket) {
|
|
341
|
+
questions.push({
|
|
342
|
+
type: "toggle",
|
|
343
|
+
name: "websocket",
|
|
344
|
+
message: `Would you like to use ${chalk.blue("Websocket")}?`,
|
|
345
|
+
initial: true,
|
|
346
|
+
active: "Yes",
|
|
347
|
+
inactive: "No",
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
console.log("🚀 ~ questions:", questions);
|
|
351
|
+
const onCancel = () => {
|
|
352
|
+
return false;
|
|
403
353
|
};
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
354
|
+
try {
|
|
355
|
+
const response = await prompts(questions, { onCancel });
|
|
356
|
+
console.log("🚀 ~ response:", response);
|
|
357
|
+
if (Object.keys(response).length === 0 && !predefinedAnswers.projectName) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
projectName: response.projectName
|
|
362
|
+
? String(response.projectName).trim().replace(/ /g, "-")
|
|
363
|
+
: (_a = predefinedAnswers.projectName) !== null && _a !== void 0 ? _a : "my-app",
|
|
364
|
+
tailwindcss: (_b = response.tailwindcss) !== null && _b !== void 0 ? _b : predefinedAnswers.tailwindcss,
|
|
365
|
+
websocket: (_c = response.websocket) !== null && _c !== void 0 ? _c : predefinedAnswers.websocket,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.error(chalk.red("Prompt error:"), error);
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
408
372
|
}
|
|
409
373
|
/**
|
|
410
374
|
* Install dependencies in the specified directory.
|
|
@@ -413,212 +377,196 @@ async function getAnswer(predefinedAnswers = {}) {
|
|
|
413
377
|
* @param {boolean} [isDev=false] - Whether to install the dependencies as devDependencies.
|
|
414
378
|
*/
|
|
415
379
|
async function installDependencies(baseDir, dependencies, isDev = false) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
380
|
+
console.log("Initializing new Node.js project...");
|
|
381
|
+
// Initialize a package.json if it doesn't exist
|
|
382
|
+
if (!fs.existsSync(path.join(baseDir, "package.json")))
|
|
383
|
+
execSync("npm init -y", {
|
|
384
|
+
stdio: "inherit",
|
|
385
|
+
cwd: baseDir,
|
|
386
|
+
});
|
|
387
|
+
// Log the dependencies being installed
|
|
388
|
+
console.log(`${isDev ? "Installing development dependencies" : "Installing dependencies"}:`);
|
|
389
|
+
dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
|
|
390
|
+
// Prepare the npm install command with the appropriate flag for dev dependencies
|
|
391
|
+
const npmInstallCommand = `npm install ${isDev ? "--save-dev" : ""} ${dependencies.join(" ")}`;
|
|
392
|
+
// Execute the npm install command
|
|
393
|
+
execSync(npmInstallCommand, {
|
|
394
|
+
stdio: "inherit",
|
|
395
|
+
cwd: baseDir,
|
|
422
396
|
});
|
|
423
|
-
// Log the dependencies being installed
|
|
424
|
-
console.log(
|
|
425
|
-
`${
|
|
426
|
-
isDev ? "Installing development dependencies" : "Installing dependencies"
|
|
427
|
-
}:`
|
|
428
|
-
);
|
|
429
|
-
dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
|
|
430
|
-
// Prepare the npm install command with the appropriate flag for dev dependencies
|
|
431
|
-
const npmInstallCommand = `npm install ${
|
|
432
|
-
isDev ? "--save-dev" : ""
|
|
433
|
-
} ${dependencies.join(" ")}`;
|
|
434
|
-
// Execute the npm install command
|
|
435
|
-
execSync(npmInstallCommand, {
|
|
436
|
-
stdio: "inherit",
|
|
437
|
-
cwd: baseDir,
|
|
438
|
-
});
|
|
439
397
|
}
|
|
440
398
|
function fetchPackageVersion(packageName) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
399
|
+
return new Promise((resolve, reject) => {
|
|
400
|
+
https
|
|
401
|
+
.get(`https://registry.npmjs.org/${packageName}`, (res) => {
|
|
402
|
+
let data = "";
|
|
403
|
+
res.on("data", (chunk) => (data += chunk));
|
|
404
|
+
res.on("end", () => {
|
|
405
|
+
try {
|
|
406
|
+
const parsed = JSON.parse(data);
|
|
407
|
+
resolve(parsed["dist-tags"].latest);
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
reject(new Error("Failed to parse JSON response"));
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
})
|
|
414
|
+
.on("error", (err) => reject(err));
|
|
415
|
+
});
|
|
457
416
|
}
|
|
458
417
|
async function main() {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
// Create settings file
|
|
549
|
-
const settingsPath = path.join(
|
|
550
|
-
projectPath,
|
|
551
|
-
"settings",
|
|
552
|
-
"project-settings.js"
|
|
553
|
-
);
|
|
554
|
-
const settingsCode = `export const projectSettings = {
|
|
418
|
+
try {
|
|
419
|
+
const args = process.argv.slice(2);
|
|
420
|
+
let projectName = args[0];
|
|
421
|
+
console.log("🚀 ~ main ~ projectName:", projectName);
|
|
422
|
+
let answer = null;
|
|
423
|
+
if (projectName) {
|
|
424
|
+
let useTailwind = args.includes("--tailwindcss");
|
|
425
|
+
let useWebsocket = args.includes("--websocket");
|
|
426
|
+
const predefinedAnswers = {
|
|
427
|
+
projectName,
|
|
428
|
+
tailwindcss: useTailwind,
|
|
429
|
+
websocket: useWebsocket,
|
|
430
|
+
};
|
|
431
|
+
answer = await getAnswer(predefinedAnswers);
|
|
432
|
+
UpdateAnswer = {
|
|
433
|
+
projectName,
|
|
434
|
+
tailwindcss: useTailwind,
|
|
435
|
+
websocket: useWebsocket,
|
|
436
|
+
isUpdate: true,
|
|
437
|
+
};
|
|
438
|
+
console.log("🚀 ~ main ~ answer:", answer);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
answer = await getAnswer();
|
|
442
|
+
}
|
|
443
|
+
if (answer === null) {
|
|
444
|
+
console.log(chalk.red("Installation cancelled."));
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
// execSync(`npm install -g create-prisma-php-app`, { stdio: "inherit" }); // TODO: Uncomment this line before publishing the package
|
|
448
|
+
execSync(`npm install -g create-prisma-php-app@alpha-update-command`, {
|
|
449
|
+
stdio: "inherit",
|
|
450
|
+
}); // TODO: Uncomment this line before publishing the package
|
|
451
|
+
// Support for browser-sync
|
|
452
|
+
execSync(`npm install -g browser-sync`, { stdio: "inherit" });
|
|
453
|
+
// Create the project directory
|
|
454
|
+
if (!projectName)
|
|
455
|
+
fs.mkdirSync(answer.projectName);
|
|
456
|
+
const currentDir = process.cwd();
|
|
457
|
+
console.log("🚀 ~ main ~ currentDir:", currentDir);
|
|
458
|
+
let projectPath = projectName
|
|
459
|
+
? currentDir
|
|
460
|
+
: path.join(currentDir, answer.projectName);
|
|
461
|
+
console.log("🚀 ~ main ~ projectPath:", projectPath);
|
|
462
|
+
if (!projectName)
|
|
463
|
+
process.chdir(answer.projectName);
|
|
464
|
+
const dependencies = [
|
|
465
|
+
"prisma",
|
|
466
|
+
"@prisma/client",
|
|
467
|
+
"typescript",
|
|
468
|
+
"@types/node",
|
|
469
|
+
"ts-node",
|
|
470
|
+
"http-proxy-middleware",
|
|
471
|
+
];
|
|
472
|
+
if (answer.tailwindcss) {
|
|
473
|
+
dependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
|
|
474
|
+
}
|
|
475
|
+
if (answer.websocket) {
|
|
476
|
+
dependencies.push("chokidar-cli");
|
|
477
|
+
}
|
|
478
|
+
if (answer.tailwindcss || answer.websocket) {
|
|
479
|
+
dependencies.push("npm-run-all");
|
|
480
|
+
}
|
|
481
|
+
await installDependencies(projectPath, dependencies, true);
|
|
482
|
+
if (!projectName) {
|
|
483
|
+
execSync(`npx prisma init`, { stdio: "inherit" });
|
|
484
|
+
execSync(`npx tsc --init`, { stdio: "inherit" });
|
|
485
|
+
}
|
|
486
|
+
if (answer.tailwindcss) {
|
|
487
|
+
execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
|
|
488
|
+
}
|
|
489
|
+
const projectSettings = {
|
|
490
|
+
PROJECT_NAME: answer.projectName,
|
|
491
|
+
PROJECT_ROOT_PATH: projectPath.replace(/\\/g, "\\\\"),
|
|
492
|
+
PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
|
|
493
|
+
PHP_GENERATE_CLASS_PATH: "src/lib/prisma/classes",
|
|
494
|
+
};
|
|
495
|
+
await createDirectoryStructure(projectPath, answer, projectSettings);
|
|
496
|
+
// if (answer.tailwindcss) {
|
|
497
|
+
// execSync(
|
|
498
|
+
// `npx tailwindcss -i ./src/app/css/tailwind.css -o ./src/app/css/styles.css --minify`,
|
|
499
|
+
// { stdio: "inherit" }
|
|
500
|
+
// );
|
|
501
|
+
// }
|
|
502
|
+
// execSync(`composer install`, { stdio: "inherit" });
|
|
503
|
+
// execSync(`composer dump-autoload`, { stdio: "inherit" });
|
|
504
|
+
// Create settings file
|
|
505
|
+
const settingsPath = path.join(projectPath, "settings", "project-settings.js");
|
|
506
|
+
const settingsCode = `export const projectSettings = {
|
|
555
507
|
PROJECT_NAME: "${answer.projectName}",
|
|
556
508
|
PROJECT_ROOT_PATH: "${projectPath.replace(/\\/g, "\\\\")}",
|
|
557
509
|
PHP_ROOT_PATH_EXE: "D:\\\\xampp\\\\php\\\\php.exe",
|
|
558
510
|
PHP_GENERATE_CLASS_PATH: "src/lib/prisma/classes",
|
|
559
511
|
};`;
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
if (!answer.tailwindcss) {
|
|
566
|
-
const cssPath = path.join(projectPath, "src", "app", "css");
|
|
567
|
-
const tailwindFiles = ["tailwind.css", "styles.css"];
|
|
568
|
-
tailwindFiles.forEach((file) => {
|
|
569
|
-
const filePath = path.join(cssPath, file);
|
|
570
|
-
if (fs.existsSync(filePath)) {
|
|
571
|
-
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
572
|
-
console.log(`${file} was deleted successfully.`);
|
|
573
|
-
} else {
|
|
574
|
-
console.log(`${file} does not exist.`);
|
|
512
|
+
fs.writeFileSync(settingsPath, settingsCode, { flag: "w" });
|
|
513
|
+
const publicDirPath = path.join(projectPath, "public");
|
|
514
|
+
if (!fs.existsSync(publicDirPath)) {
|
|
515
|
+
fs.mkdirSync(publicDirPath);
|
|
575
516
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
517
|
+
if (!answer.tailwindcss) {
|
|
518
|
+
const cssPath = path.join(projectPath, "src", "app", "css");
|
|
519
|
+
const tailwindFiles = ["tailwind.css", "styles.css"];
|
|
520
|
+
tailwindFiles.forEach((file) => {
|
|
521
|
+
const filePath = path.join(cssPath, file);
|
|
522
|
+
if (fs.existsSync(filePath)) {
|
|
523
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
524
|
+
console.log(`${file} was deleted successfully.`);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
console.log(`${file} does not exist.`);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
// Update websocket if not chosen by the user
|
|
532
|
+
if (!answer.websocket) {
|
|
533
|
+
const wsPath = path.join(projectPath, "src", "lib", "websocket");
|
|
534
|
+
// Check if the websocket directory exists
|
|
535
|
+
if (fs.existsSync(wsPath)) {
|
|
536
|
+
// Use fs.rmSync with recursive option set to true to delete the directory and its contents
|
|
537
|
+
fs.rmSync(wsPath, { recursive: true, force: true }); // force option is not necessary but can be used to ensure deletion
|
|
538
|
+
console.log("Websocket directory was deleted successfully.");
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
console.log("Websocket directory does not exist.");
|
|
542
|
+
}
|
|
543
|
+
// Update settings directory if websocket is not chosen
|
|
544
|
+
const settingsPath = path.join(projectPath, "settings");
|
|
545
|
+
const websocketFiles = ["restartWebsocket.cjs", "restart_websocket.bat"];
|
|
546
|
+
websocketFiles.forEach((file) => {
|
|
547
|
+
const filePath = path.join(settingsPath, file);
|
|
548
|
+
if (fs.existsSync(filePath)) {
|
|
549
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
550
|
+
console.log(`${file} was deleted successfully.`);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
console.log(`${file} does not exist.`);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
599
556
|
}
|
|
600
|
-
|
|
557
|
+
const version = await fetchPackageVersion("create-prisma-php-app");
|
|
558
|
+
const prismaPhpConfig = {
|
|
559
|
+
projectName: answer.projectName,
|
|
560
|
+
tailwindcss: answer.tailwindcss,
|
|
561
|
+
websocket: answer.websocket,
|
|
562
|
+
version,
|
|
563
|
+
};
|
|
564
|
+
fs.writeFileSync(path.join(projectPath, "prisma-php.json"), JSON.stringify(prismaPhpConfig, null, 2), { flag: "w" });
|
|
565
|
+
console.log(`${chalk.green("Success!")} Prisma PHP project successfully created in ${answer.projectName}!`);
|
|
566
|
+
}
|
|
567
|
+
catch (error) {
|
|
568
|
+
console.error("Error while creating the project:", error);
|
|
569
|
+
process.exit(1);
|
|
601
570
|
}
|
|
602
|
-
const version = await fetchPackageVersion("create-prisma-php-app");
|
|
603
|
-
const prismaPhpConfig = {
|
|
604
|
-
projectName: answer.projectName,
|
|
605
|
-
tailwindcss: answer.tailwindcss,
|
|
606
|
-
websocket: answer.websocket,
|
|
607
|
-
version,
|
|
608
|
-
};
|
|
609
|
-
fs.writeFileSync(
|
|
610
|
-
path.join(projectPath, "prisma-php.json"),
|
|
611
|
-
JSON.stringify(prismaPhpConfig, null, 2),
|
|
612
|
-
{ flag: "w" }
|
|
613
|
-
);
|
|
614
|
-
console.log(
|
|
615
|
-
`${chalk.green("Success!")} Prisma PHP project successfully created in ${
|
|
616
|
-
answer.projectName
|
|
617
|
-
}!`
|
|
618
|
-
);
|
|
619
|
-
} catch (error) {
|
|
620
|
-
console.error("Error while creating the project:", error);
|
|
621
|
-
process.exit(1);
|
|
622
|
-
}
|
|
623
571
|
}
|
|
624
572
|
main();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
+
|
|
76
|
+
/* Interop Constraints */
|
|
77
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
+
|
|
84
|
+
/* Type Checking */
|
|
85
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
+
|
|
105
|
+
/* Completeness */
|
|
106
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
+
}
|
|
109
|
+
}
|