create-prisma-php-app 1.22.501 → 1.22.503
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 +786 -990
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,62 +10,57 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
let updateAnswer = null;
|
|
12
12
|
const nonBackendFiles = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"favicon.ico",
|
|
14
|
+
"\\src\\app\\index.php",
|
|
15
|
+
"metadata.php",
|
|
16
|
+
"not-found.php",
|
|
17
17
|
];
|
|
18
18
|
const dockerFiles = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
".dockerignore",
|
|
20
|
+
"docker-compose.yml",
|
|
21
|
+
"Dockerfile",
|
|
22
|
+
"apache.conf",
|
|
23
23
|
];
|
|
24
24
|
function bsConfigUrls(projectRootPath) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// Identify the base path dynamically up to and including 'htdocs'
|
|
26
|
+
const htdocsIndex = projectRootPath.indexOf("\\htdocs\\");
|
|
27
|
+
if (htdocsIndex === -1) {
|
|
28
|
+
console.error("Invalid PROJECT_ROOT_PATH. The path does not contain \\htdocs\\");
|
|
29
|
+
return {
|
|
30
|
+
bsTarget: "",
|
|
31
|
+
bsPathRewrite: {},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// Extract the path up to and including 'htdocs\\'
|
|
35
|
+
const basePathToRemove = projectRootPath.substring(0, htdocsIndex + "\\htdocs\\".length);
|
|
36
|
+
// Escape backslashes for the regex pattern
|
|
37
|
+
const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
|
|
38
|
+
// Remove the base path and replace backslashes with forward slashes for URL compatibility
|
|
39
|
+
const relativeWebPath = projectRootPath
|
|
40
|
+
.replace(new RegExp(`^${escapedBasePathToRemove}`), "")
|
|
41
|
+
.replace(/\\/g, "/");
|
|
42
|
+
// Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
|
|
43
|
+
let proxyUrl = `http://localhost/${relativeWebPath}`;
|
|
44
|
+
// Ensure the proxy URL does not end with a slash before appending '/public'
|
|
45
|
+
proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
|
|
46
|
+
// Clean the URL by replacing "//" with "/" but not affecting "http://"
|
|
47
|
+
// We replace instances of "//" that are not preceded by ":"
|
|
48
|
+
const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
|
|
49
|
+
const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
|
|
50
|
+
// Correct the relativeWebPath to ensure it does not start with a "/"
|
|
51
|
+
const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
|
|
52
|
+
? cleanRelativeWebPath.substring(1)
|
|
53
|
+
: cleanRelativeWebPath;
|
|
31
54
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
55
|
+
bsTarget: `${cleanUrl}/`,
|
|
56
|
+
bsPathRewrite: {
|
|
57
|
+
"^/": `/${adjustedRelativeWebPath}/`,
|
|
58
|
+
},
|
|
34
59
|
};
|
|
35
|
-
}
|
|
36
|
-
// Extract the path up to and including 'htdocs\\'
|
|
37
|
-
const basePathToRemove = projectRootPath.substring(
|
|
38
|
-
0,
|
|
39
|
-
htdocsIndex + "\\htdocs\\".length
|
|
40
|
-
);
|
|
41
|
-
// Escape backslashes for the regex pattern
|
|
42
|
-
const escapedBasePathToRemove = basePathToRemove.replace(/\\/g, "\\\\");
|
|
43
|
-
// Remove the base path and replace backslashes with forward slashes for URL compatibility
|
|
44
|
-
const relativeWebPath = projectRootPath
|
|
45
|
-
.replace(new RegExp(`^${escapedBasePathToRemove}`), "")
|
|
46
|
-
.replace(/\\/g, "/");
|
|
47
|
-
// Construct the Browser Sync command with the correct proxy URL, being careful not to affect the protocol part
|
|
48
|
-
let proxyUrl = `http://localhost/${relativeWebPath}`;
|
|
49
|
-
// Ensure the proxy URL does not end with a slash before appending '/public'
|
|
50
|
-
proxyUrl = proxyUrl.endsWith("/") ? proxyUrl.slice(0, -1) : proxyUrl;
|
|
51
|
-
// Clean the URL by replacing "//" with "/" but not affecting "http://"
|
|
52
|
-
// We replace instances of "//" that are not preceded by ":"
|
|
53
|
-
const cleanUrl = proxyUrl.replace(/(?<!:)(\/\/+)/g, "/");
|
|
54
|
-
const cleanRelativeWebPath = relativeWebPath.replace(/\/\/+/g, "/");
|
|
55
|
-
// Correct the relativeWebPath to ensure it does not start with a "/"
|
|
56
|
-
const adjustedRelativeWebPath = cleanRelativeWebPath.startsWith("/")
|
|
57
|
-
? cleanRelativeWebPath.substring(1)
|
|
58
|
-
: cleanRelativeWebPath;
|
|
59
|
-
return {
|
|
60
|
-
bsTarget: `${cleanUrl}/`,
|
|
61
|
-
bsPathRewrite: {
|
|
62
|
-
"^/": `/${adjustedRelativeWebPath}/`,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
60
|
}
|
|
66
61
|
function configureBrowserSyncCommand(baseDir) {
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
// TypeScript content to write
|
|
63
|
+
const bsConfigTsContent = `const { createProxyMiddleware } = require("http-proxy-middleware");
|
|
69
64
|
const fs = require("fs");
|
|
70
65
|
const chokidar = require("chokidar");
|
|
71
66
|
const { execSync } = require("child_process");
|
|
@@ -75,7 +70,7 @@ const config = JSON.parse(jsonData);
|
|
|
75
70
|
|
|
76
71
|
// Watch for file changes (create, delete, save)
|
|
77
72
|
const watcher = chokidar.watch("src/**/*", {
|
|
78
|
-
ignored: /(^|[
|
|
73
|
+
ignored: /(^|[\\\\/\\\\])\\\\../,
|
|
79
74
|
persistent: true,
|
|
80
75
|
usePolling: true,
|
|
81
76
|
interval: 1000,
|
|
@@ -117,379 +112,318 @@ module.exports = {
|
|
|
117
112
|
interval: 1000,
|
|
118
113
|
},
|
|
119
114
|
};`;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
// Determine the path and write the bs-config.js
|
|
116
|
+
const bsConfigPath = path.join(baseDir, "settings", "bs-config.cjs");
|
|
117
|
+
fs.writeFileSync(bsConfigPath, bsConfigTsContent, "utf8");
|
|
118
|
+
// Return the Browser Sync command string, using the cleaned URL
|
|
119
|
+
return `browser-sync start --config settings/bs-config.cjs`;
|
|
125
120
|
}
|
|
126
121
|
async function updatePackageJson(baseDir, answer) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
projectName: "node settings/project-name.cjs"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
packageJson.scripts =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
let updatedScripts = Object.assign({}, packageJson.scripts);
|
|
175
|
-
// Conditionally add "browser-sync" command
|
|
176
|
-
updatedScripts.browserSync = browserSyncCommand;
|
|
177
|
-
updatedScripts.npmRunAll =
|
|
178
|
-
answersToInclude.length > 0
|
|
179
|
-
? `npm-run-all -p ${answersToInclude.join(" ")}`
|
|
180
|
-
: 'echo "No additional scripts to run"';
|
|
181
|
-
updatedScripts.dev = `node settings/start-dev.js`;
|
|
182
|
-
// Finally, assign the updated scripts back to packageJson
|
|
183
|
-
packageJson.scripts = updatedScripts;
|
|
184
|
-
packageJson.type = "module";
|
|
185
|
-
if (answer.prisma)
|
|
186
|
-
packageJson.prisma = {
|
|
187
|
-
seed: "node prisma/seed.js",
|
|
188
|
-
};
|
|
189
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
122
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
123
|
+
if (checkExcludeFiles(packageJsonPath))
|
|
124
|
+
return;
|
|
125
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
126
|
+
// Use the new function to configure the Browser Sync command
|
|
127
|
+
const browserSyncCommand = configureBrowserSyncCommand(baseDir);
|
|
128
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { projectName: "node settings/project-name.cjs" });
|
|
129
|
+
let answersToInclude = [];
|
|
130
|
+
if (answer.tailwindcss) {
|
|
131
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { tailwind: "postcss ./src/app/css/tailwind.css -o ./src/app/css/styles.css --watch" });
|
|
132
|
+
answersToInclude.push("tailwind");
|
|
133
|
+
}
|
|
134
|
+
if (answer.websocket) {
|
|
135
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { websocket: "node ./settings/restart-websocket.cjs" });
|
|
136
|
+
answersToInclude.push("websocket");
|
|
137
|
+
}
|
|
138
|
+
// if (answer.prisma) {
|
|
139
|
+
// packageJson.scripts = {
|
|
140
|
+
// ...packageJson.scripts,
|
|
141
|
+
// postinstall: "prisma generate",
|
|
142
|
+
// };
|
|
143
|
+
// }
|
|
144
|
+
if (answer.docker) {
|
|
145
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { docker: "docker-compose up" });
|
|
146
|
+
answersToInclude.push("docker");
|
|
147
|
+
}
|
|
148
|
+
if (answer.swaggerDocs) {
|
|
149
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { "create-swagger-docs": "node settings/swagger-setup.js" });
|
|
150
|
+
answersToInclude.push("create-swagger-docs");
|
|
151
|
+
}
|
|
152
|
+
// Initialize with existing scripts
|
|
153
|
+
let updatedScripts = Object.assign({}, packageJson.scripts);
|
|
154
|
+
// Conditionally add "browser-sync" command
|
|
155
|
+
updatedScripts.browserSync = browserSyncCommand;
|
|
156
|
+
updatedScripts.npmRunAll =
|
|
157
|
+
answersToInclude.length > 0
|
|
158
|
+
? `npm-run-all -p ${answersToInclude.join(" ")}`
|
|
159
|
+
: 'echo "No additional scripts to run"';
|
|
160
|
+
updatedScripts.dev = `node settings/start-dev.js`;
|
|
161
|
+
// Finally, assign the updated scripts back to packageJson
|
|
162
|
+
packageJson.scripts = updatedScripts;
|
|
163
|
+
packageJson.type = "module";
|
|
164
|
+
if (answer.prisma)
|
|
165
|
+
packageJson.prisma = {
|
|
166
|
+
seed: "node prisma/seed.js",
|
|
167
|
+
};
|
|
168
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
190
169
|
}
|
|
191
170
|
async function updateComposerJson(baseDir, answer) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
// Write the modified composer.json back to the file
|
|
218
|
-
fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
|
|
219
|
-
console.log("composer.json updated successfully.");
|
|
171
|
+
const composerJsonPath = path.join(baseDir, "composer.json");
|
|
172
|
+
if (checkExcludeFiles(composerJsonPath))
|
|
173
|
+
return;
|
|
174
|
+
let composerJson;
|
|
175
|
+
// Check if the composer.json file exists
|
|
176
|
+
if (fs.existsSync(composerJsonPath)) {
|
|
177
|
+
// Read the current composer.json content
|
|
178
|
+
const composerJsonContent = fs.readFileSync(composerJsonPath, "utf8");
|
|
179
|
+
composerJson = JSON.parse(composerJsonContent);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
console.error("composer.json does not exist.");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Conditionally add WebSocket dependency
|
|
186
|
+
if (answer.websocket) {
|
|
187
|
+
composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "cboden/ratchet": "^0.4.4" });
|
|
188
|
+
}
|
|
189
|
+
if (answer.prisma) {
|
|
190
|
+
composerJson.require = Object.assign(Object.assign({}, composerJson.require), { "ramsey/uuid": "5.x-dev", "hidehalo/nanoid-php": "1.x-dev" });
|
|
191
|
+
}
|
|
192
|
+
// Write the modified composer.json back to the file
|
|
193
|
+
fs.writeFileSync(composerJsonPath, JSON.stringify(composerJson, null, 2));
|
|
194
|
+
console.log("composer.json updated successfully.");
|
|
220
195
|
}
|
|
221
196
|
async function updateIndexJsForWebSocket(baseDir, answer) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
197
|
+
if (!answer.websocket) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const indexPath = path.join(baseDir, "src", "app", "js", "index.js");
|
|
201
|
+
if (checkExcludeFiles(indexPath))
|
|
202
|
+
return;
|
|
203
|
+
let indexContent = fs.readFileSync(indexPath, "utf8");
|
|
204
|
+
// WebSocket initialization code to be appended
|
|
205
|
+
const webSocketCode = `
|
|
230
206
|
// WebSocket initialization
|
|
231
207
|
const ws = new WebSocket("ws://localhost:8080");
|
|
232
208
|
`;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
209
|
+
// Append WebSocket code if user chose to use WebSocket
|
|
210
|
+
indexContent += webSocketCode;
|
|
211
|
+
fs.writeFileSync(indexPath, indexContent, "utf8");
|
|
212
|
+
console.log("WebSocket code added to index.js successfully.");
|
|
237
213
|
}
|
|
238
214
|
// This function updates the .gitignore file
|
|
239
215
|
async function createUpdateGitignoreFile(baseDir, additions) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
216
|
+
const gitignorePath = path.join(baseDir, ".gitignore");
|
|
217
|
+
if (checkExcludeFiles(gitignorePath))
|
|
218
|
+
return;
|
|
219
|
+
let gitignoreContent = "";
|
|
220
|
+
additions.forEach((addition) => {
|
|
221
|
+
if (!gitignoreContent.includes(addition)) {
|
|
222
|
+
gitignoreContent += `\n${addition}`;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
// Ensure there's no leading newline if the file was just created
|
|
226
|
+
gitignoreContent = gitignoreContent.trimStart();
|
|
227
|
+
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
251
228
|
}
|
|
252
229
|
// Recursive copy function
|
|
253
230
|
function copyRecursiveSync(src, dest, answer) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
)
|
|
280
|
-
return;
|
|
281
|
-
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
282
|
-
fs.readdirSync(src).forEach((childItemName) => {
|
|
283
|
-
copyRecursiveSync(
|
|
284
|
-
path.join(src, childItemName),
|
|
285
|
-
path.join(dest, childItemName),
|
|
286
|
-
answer
|
|
287
|
-
);
|
|
288
|
-
});
|
|
289
|
-
} else {
|
|
290
|
-
if (checkExcludeFiles(dest)) return;
|
|
291
|
-
if (
|
|
292
|
-
!answer.tailwindcss &&
|
|
293
|
-
(dest.includes("tailwind.css") || dest.includes("styles.css"))
|
|
294
|
-
)
|
|
295
|
-
return;
|
|
296
|
-
if (
|
|
297
|
-
!answer.websocket &&
|
|
298
|
-
(dest.includes("restart-websocket.cjs") ||
|
|
299
|
-
dest.includes("restart-websocket.bat"))
|
|
300
|
-
)
|
|
301
|
-
return;
|
|
302
|
-
if (!answer.docker && dockerFiles.some((file) => dest.includes(file))) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
if (
|
|
306
|
-
answer.backendOnly &&
|
|
307
|
-
nonBackendFiles.some((file) => dest.includes(file))
|
|
308
|
-
) {
|
|
309
|
-
return;
|
|
231
|
+
var _a;
|
|
232
|
+
console.log("🚀 ~ copyRecursiveSync ~ dest:", dest);
|
|
233
|
+
console.log("🚀 ~ copyRecursiveSync ~ src:", src);
|
|
234
|
+
const exists = fs.existsSync(src);
|
|
235
|
+
const stats = exists && fs.statSync(src);
|
|
236
|
+
const isDirectory = exists && stats && stats.isDirectory();
|
|
237
|
+
if (isDirectory) {
|
|
238
|
+
const destLower = dest.toLowerCase();
|
|
239
|
+
if (!answer.websocket && destLower.includes("src\\lib\\websocket"))
|
|
240
|
+
return;
|
|
241
|
+
if (!answer.prisma && destLower.includes("src\\lib\\prisma"))
|
|
242
|
+
return;
|
|
243
|
+
if ((answer.backendOnly && destLower.includes("src\\app\\js")) ||
|
|
244
|
+
(answer.backendOnly && destLower.includes("src\\app\\css")))
|
|
245
|
+
return;
|
|
246
|
+
if (!answer.swaggerDocs && destLower.includes("src\\app\\swagger-docs"))
|
|
247
|
+
return;
|
|
248
|
+
const destModified = dest.replace(/\\/g, "/");
|
|
249
|
+
if ((_a = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFilePath) === null || _a === void 0 ? void 0 : _a.includes(destModified))
|
|
250
|
+
return;
|
|
251
|
+
if (!fs.existsSync(dest))
|
|
252
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
253
|
+
fs.readdirSync(src).forEach((childItemName) => {
|
|
254
|
+
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName), answer);
|
|
255
|
+
});
|
|
310
256
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
257
|
+
else {
|
|
258
|
+
if (checkExcludeFiles(dest))
|
|
259
|
+
return;
|
|
260
|
+
if (!answer.tailwindcss &&
|
|
261
|
+
(dest.includes("tailwind.css") || dest.includes("styles.css")))
|
|
262
|
+
return;
|
|
263
|
+
if (!answer.websocket &&
|
|
264
|
+
(dest.includes("restart-websocket.cjs") ||
|
|
265
|
+
dest.includes("restart-websocket.bat")))
|
|
266
|
+
return;
|
|
267
|
+
if (!answer.docker && dockerFiles.some((file) => dest.includes(file))) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (answer.backendOnly &&
|
|
271
|
+
nonBackendFiles.some((file) => dest.includes(file))) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!answer.backendOnly && dest.includes("route.php"))
|
|
275
|
+
return;
|
|
276
|
+
if (!answer.swaggerDocs && dest.includes("swagger-setup.js")) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
fs.copyFileSync(src, dest, 0);
|
|
314
280
|
}
|
|
315
|
-
fs.copyFileSync(src, dest, 0);
|
|
316
|
-
}
|
|
317
281
|
}
|
|
318
282
|
// Function to execute the recursive copy for entire directories
|
|
319
283
|
async function executeCopy(baseDir, directoriesToCopy, answer) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
284
|
+
directoriesToCopy.forEach(({ srcDir, destDir }) => {
|
|
285
|
+
const sourcePath = path.join(__dirname, srcDir);
|
|
286
|
+
const destPath = path.join(baseDir, destDir);
|
|
287
|
+
copyRecursiveSync(sourcePath, destPath, answer);
|
|
288
|
+
});
|
|
325
289
|
}
|
|
326
290
|
function createOrUpdateTailwindConfig(baseDir) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
/content: \[\],/g,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
fs.writeFileSync(filePath, configData, { flag: "w" });
|
|
344
|
-
console.log(chalk.green("Tailwind configuration updated successfully."));
|
|
291
|
+
console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
|
|
292
|
+
const filePath = path.join(baseDir, "tailwind.config.js");
|
|
293
|
+
if (checkExcludeFiles(filePath))
|
|
294
|
+
return;
|
|
295
|
+
const newContent = [
|
|
296
|
+
"./src/**/*.{html,js,php}",
|
|
297
|
+
// Add more paths as needed
|
|
298
|
+
];
|
|
299
|
+
let configData = fs.readFileSync(filePath, "utf8");
|
|
300
|
+
console.log("🚀 ~ createOrUpdateTailwindConfig ~ configData:", configData);
|
|
301
|
+
const contentArrayString = newContent
|
|
302
|
+
.map((item) => ` "${item}"`)
|
|
303
|
+
.join(",\n");
|
|
304
|
+
configData = configData.replace(/content: \[\],/g, `content: [\n${contentArrayString}\n],`);
|
|
305
|
+
fs.writeFileSync(filePath, configData, { flag: "w" });
|
|
306
|
+
console.log(chalk.green("Tailwind configuration updated successfully."));
|
|
345
307
|
}
|
|
346
308
|
function modifyPostcssConfig(baseDir) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
309
|
+
const filePath = path.join(baseDir, "postcss.config.js");
|
|
310
|
+
if (checkExcludeFiles(filePath))
|
|
311
|
+
return;
|
|
312
|
+
const newContent = `export default {
|
|
350
313
|
plugins: {
|
|
351
314
|
tailwindcss: {},
|
|
352
315
|
autoprefixer: {},
|
|
353
316
|
cssnano: {},
|
|
354
317
|
},
|
|
355
318
|
};`;
|
|
356
|
-
|
|
357
|
-
|
|
319
|
+
fs.writeFileSync(filePath, newContent, { flag: "w" });
|
|
320
|
+
console.log(chalk.green("postcss.config.js updated successfully."));
|
|
358
321
|
}
|
|
359
322
|
function modifyLayoutPHP(baseDir, answer) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
323
|
+
const layoutPath = path.join(baseDir, "src", "app", "layout.php");
|
|
324
|
+
if (checkExcludeFiles(layoutPath))
|
|
325
|
+
return;
|
|
326
|
+
try {
|
|
327
|
+
let indexContent = fs.readFileSync(layoutPath, "utf8");
|
|
328
|
+
let stylesAndLinks = "";
|
|
329
|
+
if (!answer.backendOnly) {
|
|
330
|
+
stylesAndLinks = `\n <link href="<?= $baseUrl; ?>/css/index.css" rel="stylesheet">\n <script src="<?= $baseUrl; ?>/js/index.js"></script>`;
|
|
331
|
+
}
|
|
332
|
+
// Tailwind CSS link or CDN script
|
|
333
|
+
let tailwindLink = "";
|
|
334
|
+
if (!answer.backendOnly) {
|
|
335
|
+
tailwindLink = answer.tailwindcss
|
|
336
|
+
? ` <link href="<?= $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
|
|
337
|
+
: ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
|
|
338
|
+
}
|
|
339
|
+
// Insert before the closing </head> tag
|
|
340
|
+
const breakLine = tailwindLink.length > 0 ? "\n" : "";
|
|
341
|
+
indexContent = indexContent.replace("</head>", `${tailwindLink}${breakLine} <!-- Dynamic Head -->
|
|
342
|
+
<?= implode("\\n", $mainLayoutHead); ?>
|
|
343
|
+
</head>`);
|
|
344
|
+
fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
|
|
345
|
+
console.log(chalk.green(`layout.php modified successfully for ${answer.tailwindcss ? "local Tailwind CSS" : "Tailwind CSS CDN"}.`));
|
|
367
346
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (!answer.backendOnly) {
|
|
371
|
-
tailwindLink = answer.tailwindcss
|
|
372
|
-
? ` <link href="<?= $baseUrl; ?>/css/styles.css" rel="stylesheet"> ${stylesAndLinks}`
|
|
373
|
-
: ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
|
|
347
|
+
catch (error) {
|
|
348
|
+
console.error(chalk.red("Error modifying layout.php:"), error);
|
|
374
349
|
}
|
|
375
|
-
// Insert before the closing </head> tag
|
|
376
|
-
const breakLine = tailwindLink.length > 0 ? "\n" : "";
|
|
377
|
-
indexContent = indexContent.replace(
|
|
378
|
-
"</head>",
|
|
379
|
-
`${tailwindLink}${breakLine} <!-- Dynamic Head -->
|
|
380
|
-
<?= implode("\\n", $mainLayoutHead); ?>
|
|
381
|
-
</head>`
|
|
382
|
-
);
|
|
383
|
-
fs.writeFileSync(layoutPath, indexContent, { flag: "w" });
|
|
384
|
-
console.log(
|
|
385
|
-
chalk.green(
|
|
386
|
-
`layout.php modified successfully for ${
|
|
387
|
-
answer.tailwindcss ? "local Tailwind CSS" : "Tailwind CSS CDN"
|
|
388
|
-
}.`
|
|
389
|
-
)
|
|
390
|
-
);
|
|
391
|
-
} catch (error) {
|
|
392
|
-
console.error(chalk.red("Error modifying layout.php:"), error);
|
|
393
|
-
}
|
|
394
350
|
}
|
|
395
351
|
// This function updates or creates the .env file
|
|
396
352
|
async function createOrUpdateEnvFile(baseDir, content) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
353
|
+
const envPath = path.join(baseDir, ".env");
|
|
354
|
+
if (checkExcludeFiles(envPath))
|
|
355
|
+
return;
|
|
356
|
+
console.log("🚀 ~ content:", content);
|
|
357
|
+
fs.writeFileSync(envPath, content, { flag: "w" });
|
|
401
358
|
}
|
|
402
359
|
function checkExcludeFiles(destPath) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
: updateAnswer.isUpdate)
|
|
408
|
-
)
|
|
409
|
-
return false;
|
|
410
|
-
return (_b =
|
|
411
|
-
(_a =
|
|
412
|
-
updateAnswer === null || updateAnswer === void 0
|
|
413
|
-
? void 0
|
|
414
|
-
: updateAnswer.excludeFilePath) === null || _a === void 0
|
|
415
|
-
? void 0
|
|
416
|
-
: _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0
|
|
417
|
-
? _b
|
|
418
|
-
: false;
|
|
360
|
+
var _a, _b;
|
|
361
|
+
if (!(updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate))
|
|
362
|
+
return false;
|
|
363
|
+
return ((_b = (_a = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFilePath) === null || _a === void 0 ? void 0 : _a.includes(destPath.replace(/\\/g, "/"))) !== null && _b !== void 0 ? _b : false);
|
|
419
364
|
}
|
|
420
365
|
async function createDirectoryStructure(baseDir, answer) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
filesToCopy.push({ src: "/tsconfig.json", dest: "/tsconfig.json" });
|
|
434
|
-
if (updateAnswer.tailwindcss) {
|
|
435
|
-
filesToCopy.push(
|
|
436
|
-
{ src: "/postcss.config.js", dest: "/postcss.config.js" },
|
|
437
|
-
{ src: "/tailwind.config.js", dest: "/tailwind.config.js" }
|
|
438
|
-
);
|
|
366
|
+
console.log("🚀 ~ baseDir:", baseDir);
|
|
367
|
+
console.log("🚀 ~ answer:", answer);
|
|
368
|
+
const filesToCopy = [
|
|
369
|
+
{ src: "/bootstrap.php", dest: "/bootstrap.php" },
|
|
370
|
+
{ src: "/.htaccess", dest: "/.htaccess" },
|
|
371
|
+
{ src: "/../composer.json", dest: "/composer.json" },
|
|
372
|
+
];
|
|
373
|
+
if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
|
|
374
|
+
filesToCopy.push({ src: "/tsconfig.json", dest: "/tsconfig.json" });
|
|
375
|
+
if (updateAnswer.tailwindcss) {
|
|
376
|
+
filesToCopy.push({ src: "/postcss.config.js", dest: "/postcss.config.js" }, { src: "/tailwind.config.js", dest: "/tailwind.config.js" });
|
|
377
|
+
}
|
|
439
378
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
379
|
+
const directoriesToCopy = [
|
|
380
|
+
{
|
|
381
|
+
srcDir: "/settings",
|
|
382
|
+
destDir: "/settings",
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
srcDir: "/src",
|
|
386
|
+
destDir: "/src",
|
|
387
|
+
},
|
|
388
|
+
];
|
|
389
|
+
if (answer.backendOnly && answer.swaggerDocs) {
|
|
390
|
+
directoriesToCopy.push({
|
|
391
|
+
srcDir: "/swagger-docs-layout.php",
|
|
392
|
+
destDir: "/src/app/layout.php",
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
if (answer.prisma) {
|
|
396
|
+
directoriesToCopy.push({
|
|
397
|
+
srcDir: "/prisma",
|
|
398
|
+
destDir: "/prisma",
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (answer.docker) {
|
|
402
|
+
directoriesToCopy.push({ srcDir: "/.dockerignore", destDir: "/.dockerignore" }, { srcDir: "/docker-compose.yml", destDir: "/docker-compose.yml" }, { srcDir: "/Dockerfile", destDir: "/Dockerfile" }, { srcDir: "/apache.conf", destDir: "/apache.conf" });
|
|
403
|
+
}
|
|
404
|
+
console.log("🚀 ~ directoriesToCopy:", directoriesToCopy);
|
|
405
|
+
filesToCopy.forEach(({ src, dest }) => {
|
|
406
|
+
const sourcePath = path.join(__dirname, src);
|
|
407
|
+
const destPath = path.join(baseDir, dest);
|
|
408
|
+
if (checkExcludeFiles(destPath))
|
|
409
|
+
return;
|
|
410
|
+
const code = fs.readFileSync(sourcePath, "utf8");
|
|
411
|
+
fs.writeFileSync(destPath, code, { flag: "w" });
|
|
461
412
|
});
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const code = fs.readFileSync(sourcePath, "utf8");
|
|
477
|
-
fs.writeFileSync(destPath, code, { flag: "w" });
|
|
478
|
-
});
|
|
479
|
-
await executeCopy(baseDir, directoriesToCopy, answer);
|
|
480
|
-
await updatePackageJson(baseDir, answer);
|
|
481
|
-
await updateComposerJson(baseDir, answer);
|
|
482
|
-
if (!answer.backendOnly) {
|
|
483
|
-
await updateIndexJsForWebSocket(baseDir, answer);
|
|
484
|
-
}
|
|
485
|
-
if (answer.tailwindcss) {
|
|
486
|
-
createOrUpdateTailwindConfig(baseDir);
|
|
487
|
-
modifyPostcssConfig(baseDir);
|
|
488
|
-
}
|
|
489
|
-
if (answer.tailwindcss || !answer.backendOnly || answer.swaggerDocs) {
|
|
490
|
-
modifyLayoutPHP(baseDir, answer);
|
|
491
|
-
}
|
|
492
|
-
const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
|
|
413
|
+
await executeCopy(baseDir, directoriesToCopy, answer);
|
|
414
|
+
await updatePackageJson(baseDir, answer);
|
|
415
|
+
await updateComposerJson(baseDir, answer);
|
|
416
|
+
if (!answer.backendOnly) {
|
|
417
|
+
await updateIndexJsForWebSocket(baseDir, answer);
|
|
418
|
+
}
|
|
419
|
+
if (answer.tailwindcss) {
|
|
420
|
+
createOrUpdateTailwindConfig(baseDir);
|
|
421
|
+
modifyPostcssConfig(baseDir);
|
|
422
|
+
}
|
|
423
|
+
if (answer.tailwindcss || !answer.backendOnly || answer.swaggerDocs) {
|
|
424
|
+
modifyLayoutPHP(baseDir, answer);
|
|
425
|
+
}
|
|
426
|
+
const prismaPHPEnvContent = `# Prisma PHP Auth Secret Key For development only - Change this in production
|
|
493
427
|
AUTH_SECRET=uxsjXVPHN038DEYls2Kw0QUgBcXKUyrjv416nIFWPY4=
|
|
494
428
|
|
|
495
429
|
# PHPMailer
|
|
@@ -512,200 +446,164 @@ APP_TIMEZONE="UTC"
|
|
|
512
446
|
|
|
513
447
|
# APP ENV - Set your application environment - Default is "development" - Change this in production to "production"
|
|
514
448
|
APP_ENV=development`;
|
|
515
|
-
|
|
516
|
-
|
|
449
|
+
if (answer.prisma) {
|
|
450
|
+
const prismaEnvContent = `# Environment variables declared in this file are automatically made available to Prisma.
|
|
517
451
|
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
|
518
452
|
|
|
519
453
|
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
520
454
|
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
521
455
|
|
|
522
456
|
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"`;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
} else {
|
|
526
|
-
await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
|
|
527
|
-
}
|
|
528
|
-
// Add vendor to .gitignore
|
|
529
|
-
await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
|
|
530
|
-
}
|
|
531
|
-
async function getAnswer(predefinedAnswers = {}) {
|
|
532
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
533
|
-
console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
|
|
534
|
-
const questionsArray = [];
|
|
535
|
-
if (!predefinedAnswers.projectName) {
|
|
536
|
-
questionsArray.push({
|
|
537
|
-
type: "text",
|
|
538
|
-
name: "projectName",
|
|
539
|
-
message: "What is your project named?",
|
|
540
|
-
initial: "my-app",
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
if (!predefinedAnswers.backendOnly) {
|
|
544
|
-
questionsArray.push({
|
|
545
|
-
type: "toggle",
|
|
546
|
-
name: "backendOnly",
|
|
547
|
-
message: "Would you like to create a backend-only project?",
|
|
548
|
-
initial: false,
|
|
549
|
-
active: "Yes",
|
|
550
|
-
inactive: "No",
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
// Execute the initial questionsArray first
|
|
554
|
-
const onCancel = () => {
|
|
555
|
-
console.log(chalk.red("Operation cancelled by the user."));
|
|
556
|
-
process.exit(0);
|
|
557
|
-
};
|
|
558
|
-
const initialResponse = await prompts(questionsArray, { onCancel });
|
|
559
|
-
console.log("🚀 ~ initialResponse:", initialResponse);
|
|
560
|
-
const nonBackendOnlyQuestionsArray = [];
|
|
561
|
-
if (initialResponse.backendOnly || predefinedAnswers.backendOnly) {
|
|
562
|
-
// If it's a backend-only project, skip Tailwind CSS, but ask other questions
|
|
563
|
-
if (!predefinedAnswers.swaggerDocs) {
|
|
564
|
-
nonBackendOnlyQuestionsArray.push({
|
|
565
|
-
type: "toggle",
|
|
566
|
-
name: "swaggerDocs",
|
|
567
|
-
message: `Would you like to use ${chalk.blue("Swagger Docs")}?`,
|
|
568
|
-
initial: false,
|
|
569
|
-
active: "Yes",
|
|
570
|
-
inactive: "No",
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
if (!predefinedAnswers.websocket) {
|
|
574
|
-
nonBackendOnlyQuestionsArray.push({
|
|
575
|
-
type: "toggle",
|
|
576
|
-
name: "websocket",
|
|
577
|
-
message: `Would you like to use ${chalk.blue("Websocket")}?`,
|
|
578
|
-
initial: true,
|
|
579
|
-
active: "Yes",
|
|
580
|
-
inactive: "No",
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
if (!predefinedAnswers.prisma) {
|
|
584
|
-
nonBackendOnlyQuestionsArray.push({
|
|
585
|
-
type: "toggle",
|
|
586
|
-
name: "prisma",
|
|
587
|
-
message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
|
|
588
|
-
initial: true,
|
|
589
|
-
active: "Yes",
|
|
590
|
-
inactive: "No",
|
|
591
|
-
});
|
|
457
|
+
const envContent = `${prismaEnvContent}\n\n${prismaPHPEnvContent}`;
|
|
458
|
+
await createOrUpdateEnvFile(baseDir, envContent);
|
|
592
459
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
type: "toggle",
|
|
596
|
-
name: "docker",
|
|
597
|
-
message: `Would you like to use ${chalk.blue("Docker")}?`,
|
|
598
|
-
initial: false,
|
|
599
|
-
active: "Yes",
|
|
600
|
-
inactive: "No",
|
|
601
|
-
});
|
|
460
|
+
else {
|
|
461
|
+
await createOrUpdateEnvFile(baseDir, prismaPHPEnvContent);
|
|
602
462
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
type: "toggle",
|
|
618
|
-
name: "tailwindcss",
|
|
619
|
-
message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
|
|
620
|
-
initial: true,
|
|
621
|
-
active: "Yes",
|
|
622
|
-
inactive: "No",
|
|
623
|
-
});
|
|
463
|
+
// Add vendor to .gitignore
|
|
464
|
+
await createUpdateGitignoreFile(baseDir, ["vendor", ".env", "node_modules"]);
|
|
465
|
+
}
|
|
466
|
+
async function getAnswer(predefinedAnswers = {}) {
|
|
467
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
468
|
+
console.log("🚀 ~ predefinedAnswers:", predefinedAnswers);
|
|
469
|
+
const questionsArray = [];
|
|
470
|
+
if (!predefinedAnswers.projectName) {
|
|
471
|
+
questionsArray.push({
|
|
472
|
+
type: "text",
|
|
473
|
+
name: "projectName",
|
|
474
|
+
message: "What is your project named?",
|
|
475
|
+
initial: "my-app",
|
|
476
|
+
});
|
|
624
477
|
}
|
|
625
|
-
if (!predefinedAnswers.
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
478
|
+
if (!predefinedAnswers.backendOnly) {
|
|
479
|
+
questionsArray.push({
|
|
480
|
+
type: "toggle",
|
|
481
|
+
name: "backendOnly",
|
|
482
|
+
message: "Would you like to create a backend-only project?",
|
|
483
|
+
initial: false,
|
|
484
|
+
active: "Yes",
|
|
485
|
+
inactive: "No",
|
|
486
|
+
});
|
|
634
487
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
488
|
+
// Execute the initial questionsArray first
|
|
489
|
+
const onCancel = () => {
|
|
490
|
+
console.log(chalk.red("Operation cancelled by the user."));
|
|
491
|
+
process.exit(0);
|
|
492
|
+
};
|
|
493
|
+
const initialResponse = await prompts(questionsArray, { onCancel });
|
|
494
|
+
console.log("🚀 ~ initialResponse:", initialResponse);
|
|
495
|
+
const nonBackendOnlyQuestionsArray = [];
|
|
496
|
+
if (initialResponse.backendOnly || predefinedAnswers.backendOnly) {
|
|
497
|
+
// If it's a backend-only project, skip Tailwind CSS, but ask other questions
|
|
498
|
+
if (!predefinedAnswers.swaggerDocs) {
|
|
499
|
+
nonBackendOnlyQuestionsArray.push({
|
|
500
|
+
type: "toggle",
|
|
501
|
+
name: "swaggerDocs",
|
|
502
|
+
message: `Would you like to use ${chalk.blue("Swagger Docs")}?`,
|
|
503
|
+
initial: false,
|
|
504
|
+
active: "Yes",
|
|
505
|
+
inactive: "No",
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (!predefinedAnswers.websocket) {
|
|
509
|
+
nonBackendOnlyQuestionsArray.push({
|
|
510
|
+
type: "toggle",
|
|
511
|
+
name: "websocket",
|
|
512
|
+
message: `Would you like to use ${chalk.blue("Websocket")}?`,
|
|
513
|
+
initial: true,
|
|
514
|
+
active: "Yes",
|
|
515
|
+
inactive: "No",
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
if (!predefinedAnswers.prisma) {
|
|
519
|
+
nonBackendOnlyQuestionsArray.push({
|
|
520
|
+
type: "toggle",
|
|
521
|
+
name: "prisma",
|
|
522
|
+
message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
|
|
523
|
+
initial: true,
|
|
524
|
+
active: "Yes",
|
|
525
|
+
inactive: "No",
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
if (!predefinedAnswers.docker) {
|
|
529
|
+
nonBackendOnlyQuestionsArray.push({
|
|
530
|
+
type: "toggle",
|
|
531
|
+
name: "docker",
|
|
532
|
+
message: `Would you like to use ${chalk.blue("Docker")}?`,
|
|
533
|
+
initial: false,
|
|
534
|
+
active: "Yes",
|
|
535
|
+
inactive: "No",
|
|
536
|
+
});
|
|
537
|
+
}
|
|
644
538
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
539
|
+
else {
|
|
540
|
+
// If it's not a backend-only project, ask Tailwind CSS as well
|
|
541
|
+
if (!predefinedAnswers.swaggerDocs) {
|
|
542
|
+
nonBackendOnlyQuestionsArray.push({
|
|
543
|
+
type: "toggle",
|
|
544
|
+
name: "swaggerDocs",
|
|
545
|
+
message: `Would you like to use ${chalk.blue("Swagger Docs")}?`,
|
|
546
|
+
initial: false,
|
|
547
|
+
active: "Yes",
|
|
548
|
+
inactive: "No",
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
if (!predefinedAnswers.tailwindcss) {
|
|
552
|
+
nonBackendOnlyQuestionsArray.push({
|
|
553
|
+
type: "toggle",
|
|
554
|
+
name: "tailwindcss",
|
|
555
|
+
message: `Would you like to use ${chalk.blue("Tailwind CSS")}?`,
|
|
556
|
+
initial: true,
|
|
557
|
+
active: "Yes",
|
|
558
|
+
inactive: "No",
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
if (!predefinedAnswers.websocket) {
|
|
562
|
+
nonBackendOnlyQuestionsArray.push({
|
|
563
|
+
type: "toggle",
|
|
564
|
+
name: "websocket",
|
|
565
|
+
message: `Would you like to use ${chalk.blue("Websocket")}?`,
|
|
566
|
+
initial: true,
|
|
567
|
+
active: "Yes",
|
|
568
|
+
inactive: "No",
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (!predefinedAnswers.prisma) {
|
|
572
|
+
nonBackendOnlyQuestionsArray.push({
|
|
573
|
+
type: "toggle",
|
|
574
|
+
name: "prisma",
|
|
575
|
+
message: `Would you like to use ${chalk.blue("Prisma PHP ORM")}?`,
|
|
576
|
+
initial: true,
|
|
577
|
+
active: "Yes",
|
|
578
|
+
inactive: "No",
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
if (!predefinedAnswers.docker) {
|
|
582
|
+
nonBackendOnlyQuestionsArray.push({
|
|
583
|
+
type: "toggle",
|
|
584
|
+
name: "docker",
|
|
585
|
+
message: `Would you like to use ${chalk.blue("Docker")}?`,
|
|
586
|
+
initial: false,
|
|
587
|
+
active: "Yes",
|
|
588
|
+
inactive: "No",
|
|
589
|
+
});
|
|
590
|
+
}
|
|
654
591
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
(
|
|
669
|
-
|
|
670
|
-
: predefinedAnswers.backendOnly) !== null && _c !== void 0
|
|
671
|
-
? _c
|
|
672
|
-
: false,
|
|
673
|
-
swaggerDocs:
|
|
674
|
-
(_e =
|
|
675
|
-
(_d = nonBackendOnlyResponse.swaggerDocs) !== null && _d !== void 0
|
|
676
|
-
? _d
|
|
677
|
-
: predefinedAnswers.swaggerDocs) !== null && _e !== void 0
|
|
678
|
-
? _e
|
|
679
|
-
: false,
|
|
680
|
-
tailwindcss:
|
|
681
|
-
(_g =
|
|
682
|
-
(_f = nonBackendOnlyResponse.tailwindcss) !== null && _f !== void 0
|
|
683
|
-
? _f
|
|
684
|
-
: predefinedAnswers.tailwindcss) !== null && _g !== void 0
|
|
685
|
-
? _g
|
|
686
|
-
: false,
|
|
687
|
-
websocket:
|
|
688
|
-
(_j =
|
|
689
|
-
(_h = nonBackendOnlyResponse.websocket) !== null && _h !== void 0
|
|
690
|
-
? _h
|
|
691
|
-
: predefinedAnswers.websocket) !== null && _j !== void 0
|
|
692
|
-
? _j
|
|
693
|
-
: false,
|
|
694
|
-
prisma:
|
|
695
|
-
(_l =
|
|
696
|
-
(_k = nonBackendOnlyResponse.prisma) !== null && _k !== void 0
|
|
697
|
-
? _k
|
|
698
|
-
: predefinedAnswers.prisma) !== null && _l !== void 0
|
|
699
|
-
? _l
|
|
700
|
-
: false,
|
|
701
|
-
docker:
|
|
702
|
-
(_o =
|
|
703
|
-
(_m = nonBackendOnlyResponse.docker) !== null && _m !== void 0
|
|
704
|
-
? _m
|
|
705
|
-
: predefinedAnswers.docker) !== null && _o !== void 0
|
|
706
|
-
? _o
|
|
707
|
-
: false,
|
|
708
|
-
};
|
|
592
|
+
const nonBackendOnlyResponse = await prompts(nonBackendOnlyQuestionsArray, {
|
|
593
|
+
onCancel,
|
|
594
|
+
});
|
|
595
|
+
console.log("🚀 ~ nonBackendOnlyResponse:", nonBackendOnlyResponse);
|
|
596
|
+
return {
|
|
597
|
+
projectName: initialResponse.projectName
|
|
598
|
+
? String(initialResponse.projectName).trim().replace(/ /g, "-")
|
|
599
|
+
: (_a = predefinedAnswers.projectName) !== null && _a !== void 0 ? _a : "my-app",
|
|
600
|
+
backendOnly: (_c = (_b = initialResponse.backendOnly) !== null && _b !== void 0 ? _b : predefinedAnswers.backendOnly) !== null && _c !== void 0 ? _c : false,
|
|
601
|
+
swaggerDocs: (_e = (_d = nonBackendOnlyResponse.swaggerDocs) !== null && _d !== void 0 ? _d : predefinedAnswers.swaggerDocs) !== null && _e !== void 0 ? _e : false,
|
|
602
|
+
tailwindcss: (_g = (_f = nonBackendOnlyResponse.tailwindcss) !== null && _f !== void 0 ? _f : predefinedAnswers.tailwindcss) !== null && _g !== void 0 ? _g : false,
|
|
603
|
+
websocket: (_j = (_h = nonBackendOnlyResponse.websocket) !== null && _h !== void 0 ? _h : predefinedAnswers.websocket) !== null && _j !== void 0 ? _j : false,
|
|
604
|
+
prisma: (_l = (_k = nonBackendOnlyResponse.prisma) !== null && _k !== void 0 ? _k : predefinedAnswers.prisma) !== null && _l !== void 0 ? _l : false,
|
|
605
|
+
docker: (_o = (_m = nonBackendOnlyResponse.docker) !== null && _m !== void 0 ? _m : predefinedAnswers.docker) !== null && _o !== void 0 ? _o : false,
|
|
606
|
+
};
|
|
709
607
|
}
|
|
710
608
|
/**
|
|
711
609
|
* Install dependencies in the specified directory.
|
|
@@ -714,454 +612,352 @@ async function getAnswer(predefinedAnswers = {}) {
|
|
|
714
612
|
* @param {boolean} [isDev=false] - Whether to install the dependencies as devDependencies.
|
|
715
613
|
*/
|
|
716
614
|
async function installDependencies(baseDir, dependencies, isDev = false) {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
615
|
+
console.log("Initializing new Node.js project...");
|
|
616
|
+
// Initialize a package.json if it doesn't exist
|
|
617
|
+
if (!fs.existsSync(path.join(baseDir, "package.json")))
|
|
618
|
+
execSync("npm init -y", {
|
|
619
|
+
stdio: "inherit",
|
|
620
|
+
cwd: baseDir,
|
|
621
|
+
});
|
|
622
|
+
// Log the dependencies being installed
|
|
623
|
+
console.log(`${isDev ? "Installing development dependencies" : "Installing dependencies"}:`);
|
|
624
|
+
dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
|
|
625
|
+
// Prepare the npm install command with the appropriate flag for dev dependencies
|
|
626
|
+
const npmInstallCommand = `npm install ${isDev ? "--save-dev" : ""} ${dependencies.join(" ")}`;
|
|
627
|
+
// Execute the npm install command
|
|
628
|
+
execSync(npmInstallCommand, {
|
|
629
|
+
stdio: "inherit",
|
|
630
|
+
cwd: baseDir,
|
|
723
631
|
});
|
|
724
|
-
// Log the dependencies being installed
|
|
725
|
-
console.log(
|
|
726
|
-
`${
|
|
727
|
-
isDev ? "Installing development dependencies" : "Installing dependencies"
|
|
728
|
-
}:`
|
|
729
|
-
);
|
|
730
|
-
dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
|
|
731
|
-
// Prepare the npm install command with the appropriate flag for dev dependencies
|
|
732
|
-
const npmInstallCommand = `npm install ${
|
|
733
|
-
isDev ? "--save-dev" : ""
|
|
734
|
-
} ${dependencies.join(" ")}`;
|
|
735
|
-
// Execute the npm install command
|
|
736
|
-
execSync(npmInstallCommand, {
|
|
737
|
-
stdio: "inherit",
|
|
738
|
-
cwd: baseDir,
|
|
739
|
-
});
|
|
740
632
|
}
|
|
741
633
|
async function uninstallDependencies(baseDir, dependencies, isDev = false) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
cwd: baseDir,
|
|
752
|
-
});
|
|
634
|
+
console.log("Uninstalling dependencies:");
|
|
635
|
+
dependencies.forEach((dep) => console.log(`- ${chalk.blue(dep)}`));
|
|
636
|
+
// Prepare the npm uninstall command with the appropriate flag for dev dependencies
|
|
637
|
+
const npmUninstallCommand = `npm uninstall ${isDev ? "--save-dev" : "--save"} ${dependencies.join(" ")}`;
|
|
638
|
+
// Execute the npm uninstall command
|
|
639
|
+
execSync(npmUninstallCommand, {
|
|
640
|
+
stdio: "inherit",
|
|
641
|
+
cwd: baseDir,
|
|
642
|
+
});
|
|
753
643
|
}
|
|
754
644
|
function fetchPackageVersion(packageName) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
645
|
+
return new Promise((resolve, reject) => {
|
|
646
|
+
https
|
|
647
|
+
.get(`https://registry.npmjs.org/${packageName}`, (res) => {
|
|
648
|
+
let data = "";
|
|
649
|
+
res.on("data", (chunk) => (data += chunk));
|
|
650
|
+
res.on("end", () => {
|
|
651
|
+
try {
|
|
652
|
+
const parsed = JSON.parse(data);
|
|
653
|
+
resolve(parsed["dist-tags"].latest);
|
|
654
|
+
}
|
|
655
|
+
catch (error) {
|
|
656
|
+
reject(new Error("Failed to parse JSON response"));
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
})
|
|
660
|
+
.on("error", (err) => reject(err));
|
|
661
|
+
});
|
|
771
662
|
}
|
|
772
663
|
const readJsonFile = (filePath) => {
|
|
773
|
-
|
|
774
|
-
|
|
664
|
+
const jsonData = fs.readFileSync(filePath, "utf8");
|
|
665
|
+
return JSON.parse(jsonData);
|
|
775
666
|
};
|
|
776
667
|
function compareVersions(installedVersion, currentVersion) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
668
|
+
const installedVersionArray = installedVersion.split(".").map(Number);
|
|
669
|
+
const currentVersionArray = currentVersion.split(".").map(Number);
|
|
670
|
+
for (let i = 0; i < installedVersionArray.length; i++) {
|
|
671
|
+
if (installedVersionArray[i] > currentVersionArray[i]) {
|
|
672
|
+
return 1;
|
|
673
|
+
}
|
|
674
|
+
else if (installedVersionArray[i] < currentVersionArray[i]) {
|
|
675
|
+
return -1;
|
|
676
|
+
}
|
|
784
677
|
}
|
|
785
|
-
|
|
786
|
-
return 0;
|
|
678
|
+
return 0;
|
|
787
679
|
}
|
|
788
680
|
function getInstalledPackageVersion(packageName) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
681
|
+
try {
|
|
682
|
+
const output = execSync(`npm list -g ${packageName} --depth=0`).toString();
|
|
683
|
+
const versionMatch = output.match(new RegExp(`${packageName}@(\\d+\\.\\d+\\.\\d+)`));
|
|
684
|
+
if (versionMatch) {
|
|
685
|
+
return versionMatch[1];
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
console.error(`Package ${packageName} is not installed`);
|
|
689
|
+
return null;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
catch (error) {
|
|
693
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
694
|
+
return null;
|
|
799
695
|
}
|
|
800
|
-
} catch (error) {
|
|
801
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
802
|
-
return null;
|
|
803
|
-
}
|
|
804
696
|
}
|
|
805
697
|
async function main() {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
answer === null || answer === void 0
|
|
856
|
-
? void 0
|
|
857
|
-
: answer.swaggerDocs) !== null && _c !== void 0
|
|
858
|
-
? _c
|
|
859
|
-
: false,
|
|
860
|
-
tailwindcss:
|
|
861
|
-
(_d =
|
|
862
|
-
answer === null || answer === void 0
|
|
863
|
-
? void 0
|
|
864
|
-
: answer.tailwindcss) !== null && _d !== void 0
|
|
865
|
-
? _d
|
|
866
|
-
: false,
|
|
867
|
-
websocket:
|
|
868
|
-
(_e =
|
|
869
|
-
answer === null || answer === void 0
|
|
870
|
-
? void 0
|
|
871
|
-
: answer.websocket) !== null && _e !== void 0
|
|
872
|
-
? _e
|
|
873
|
-
: false,
|
|
874
|
-
prisma:
|
|
875
|
-
(_f =
|
|
876
|
-
answer === null || answer === void 0 ? void 0 : answer.prisma) !==
|
|
877
|
-
null && _f !== void 0
|
|
878
|
-
? _f
|
|
879
|
-
: false,
|
|
880
|
-
docker:
|
|
881
|
-
(_g =
|
|
882
|
-
answer === null || answer === void 0 ? void 0 : answer.docker) !==
|
|
883
|
-
null && _g !== void 0
|
|
884
|
-
? _g
|
|
885
|
-
: false,
|
|
886
|
-
isUpdate: true,
|
|
887
|
-
excludeFiles:
|
|
888
|
-
(_h = localSettings.excludeFiles) !== null && _h !== void 0 ? _h : [],
|
|
889
|
-
excludeFilePath:
|
|
890
|
-
excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
|
|
891
|
-
filePath: currentDir,
|
|
892
|
-
};
|
|
893
|
-
} else {
|
|
894
|
-
answer = await getAnswer();
|
|
895
|
-
}
|
|
896
|
-
if (answer === null) {
|
|
897
|
-
console.warn(chalk.red("Installation cancelled."));
|
|
898
|
-
return;
|
|
899
|
-
}
|
|
900
|
-
const latestVersionOfCreatePrismaPhpApp = await fetchPackageVersion(
|
|
901
|
-
"create-prisma-php-app"
|
|
902
|
-
);
|
|
903
|
-
const isCreatePrismaPhpAppInstalled = getInstalledPackageVersion(
|
|
904
|
-
"create-prisma-php-app"
|
|
905
|
-
);
|
|
906
|
-
if (isCreatePrismaPhpAppInstalled) {
|
|
907
|
-
if (
|
|
908
|
-
compareVersions(
|
|
909
|
-
isCreatePrismaPhpAppInstalled,
|
|
910
|
-
latestVersionOfCreatePrismaPhpApp
|
|
911
|
-
) === -1
|
|
912
|
-
) {
|
|
913
|
-
execSync(`npm uninstall -g create-prisma-php-app`, {
|
|
914
|
-
stdio: "inherit",
|
|
915
|
-
});
|
|
916
|
-
execSync(`npm install -g create-prisma-php-app`, {
|
|
917
|
-
stdio: "inherit",
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
} else {
|
|
921
|
-
execSync("npm install -g create-prisma-php-app", { stdio: "inherit" });
|
|
922
|
-
}
|
|
923
|
-
const latestVersionOfBrowserSync = await fetchPackageVersion(
|
|
924
|
-
"browser-sync"
|
|
925
|
-
);
|
|
926
|
-
const isBrowserSyncInstalled = getInstalledPackageVersion("browser-sync");
|
|
927
|
-
if (isBrowserSyncInstalled) {
|
|
928
|
-
if (
|
|
929
|
-
compareVersions(isBrowserSyncInstalled, latestVersionOfBrowserSync) ===
|
|
930
|
-
-1
|
|
931
|
-
) {
|
|
932
|
-
execSync(`npm uninstall -g browser-sync`, {
|
|
933
|
-
stdio: "inherit",
|
|
934
|
-
});
|
|
935
|
-
execSync(`npm install -g browser-sync`, {
|
|
936
|
-
stdio: "inherit",
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
} else {
|
|
940
|
-
execSync("npm install -g browser-sync", { stdio: "inherit" });
|
|
941
|
-
}
|
|
942
|
-
// Create the project directory
|
|
943
|
-
if (!projectName) fs.mkdirSync(answer.projectName);
|
|
944
|
-
const currentDir = process.cwd();
|
|
945
|
-
let projectPath = projectName
|
|
946
|
-
? currentDir
|
|
947
|
-
: path.join(currentDir, answer.projectName);
|
|
948
|
-
if (!projectName) process.chdir(answer.projectName);
|
|
949
|
-
const dependencies = [
|
|
950
|
-
"typescript",
|
|
951
|
-
"@types/node",
|
|
952
|
-
"ts-node",
|
|
953
|
-
"http-proxy-middleware@^3.0.0",
|
|
954
|
-
"chalk",
|
|
955
|
-
"npm-run-all",
|
|
956
|
-
];
|
|
957
|
-
if (answer.swaggerDocs) {
|
|
958
|
-
dependencies.push("swagger-jsdoc");
|
|
959
|
-
}
|
|
960
|
-
if (answer.tailwindcss) {
|
|
961
|
-
dependencies.push(
|
|
962
|
-
"tailwindcss",
|
|
963
|
-
"autoprefixer",
|
|
964
|
-
"postcss",
|
|
965
|
-
"postcss-cli",
|
|
966
|
-
"cssnano"
|
|
967
|
-
);
|
|
968
|
-
}
|
|
969
|
-
if (answer.websocket) {
|
|
970
|
-
dependencies.push("chokidar-cli");
|
|
971
|
-
}
|
|
972
|
-
if (answer.prisma) {
|
|
973
|
-
dependencies.push("prisma", "@prisma/client");
|
|
974
|
-
}
|
|
975
|
-
await installDependencies(projectPath, dependencies, true);
|
|
976
|
-
if (!projectName) {
|
|
977
|
-
execSync(`npx tsc --init`, { stdio: "inherit" });
|
|
978
|
-
}
|
|
979
|
-
if (answer.tailwindcss)
|
|
980
|
-
execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
|
|
981
|
-
if (answer.prisma) {
|
|
982
|
-
if (!fs.existsSync(path.join(projectPath, "prisma")))
|
|
983
|
-
execSync(`npx prisma init`, { stdio: "inherit" });
|
|
984
|
-
}
|
|
985
|
-
await createDirectoryStructure(projectPath, answer);
|
|
986
|
-
const publicDirPath = path.join(projectPath, "public");
|
|
987
|
-
if (!fs.existsSync(publicDirPath)) {
|
|
988
|
-
fs.mkdirSync(publicDirPath);
|
|
989
|
-
}
|
|
990
|
-
if (answer.swaggerDocs) {
|
|
991
|
-
const swaggerDocsPath = path.join(
|
|
992
|
-
projectPath,
|
|
993
|
-
"src",
|
|
994
|
-
"app",
|
|
995
|
-
"swagger-docs"
|
|
996
|
-
);
|
|
997
|
-
// Check if the directory exists, if not, create it
|
|
998
|
-
if (!fs.existsSync(swaggerDocsPath)) {
|
|
999
|
-
fs.mkdirSync(swaggerDocsPath, { recursive: true }); // 'recursive: true' creates parent directories if they don't exist
|
|
1000
|
-
}
|
|
1001
|
-
// Clone the Git repository into the swagger-docs directory
|
|
1002
|
-
execSync(
|
|
1003
|
-
`git clone https://github.com/TheSteelNinjaCode/prisma-php-swagger-docs.git ${swaggerDocsPath}`,
|
|
1004
|
-
{ stdio: "inherit" }
|
|
1005
|
-
);
|
|
1006
|
-
}
|
|
1007
|
-
if (
|
|
1008
|
-
updateAnswer === null || updateAnswer === void 0
|
|
1009
|
-
? void 0
|
|
1010
|
-
: updateAnswer.isUpdate
|
|
1011
|
-
) {
|
|
1012
|
-
const updateUninstallDependencies = [];
|
|
1013
|
-
if (updateAnswer.backendOnly) {
|
|
1014
|
-
nonBackendFiles.forEach((file) => {
|
|
1015
|
-
const filePath = path.join(projectPath, "src", "app", file);
|
|
1016
|
-
if (fs.existsSync(filePath)) {
|
|
1017
|
-
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
1018
|
-
console.log(`${file} was deleted successfully.`);
|
|
1019
|
-
} else {
|
|
1020
|
-
console.log(`${file} does not exist.`);
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
const backendOnlyFolders = ["js", "css"];
|
|
1024
|
-
backendOnlyFolders.forEach((folder) => {
|
|
1025
|
-
const folderPath = path.join(projectPath, "src", "app", folder);
|
|
1026
|
-
if (fs.existsSync(folderPath)) {
|
|
1027
|
-
fs.rmSync(folderPath, { recursive: true, force: true }); // Use fs.rmSync instead of fs.rmdirSync
|
|
1028
|
-
console.log(`${folder} was deleted successfully.`);
|
|
1029
|
-
} else {
|
|
1030
|
-
console.log(`${folder} does not exist.`);
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
}
|
|
1034
|
-
if (!updateAnswer.swaggerDocs) {
|
|
1035
|
-
const swaggerDocsFolder = path.join(
|
|
1036
|
-
projectPath,
|
|
1037
|
-
"src",
|
|
1038
|
-
"app",
|
|
1039
|
-
"swagger-docs"
|
|
1040
|
-
);
|
|
1041
|
-
if (fs.existsSync(swaggerDocsFolder)) {
|
|
1042
|
-
fs.rmSync(swaggerDocsFolder, { recursive: true, force: true }); // Use fs.rmSync instead of fs.rmdirSync
|
|
1043
|
-
console.log(`swagger-docs was deleted successfully.`);
|
|
698
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
699
|
+
try {
|
|
700
|
+
const args = process.argv.slice(2);
|
|
701
|
+
let projectName = args[0];
|
|
702
|
+
let answer = null;
|
|
703
|
+
if (projectName) {
|
|
704
|
+
let useBackendOnly = args.includes("--backend-only");
|
|
705
|
+
let useSwaggerDocs = args.includes("--swagger-docs");
|
|
706
|
+
let useTailwind = args.includes("--tailwindcss");
|
|
707
|
+
let useWebsocket = args.includes("--websocket");
|
|
708
|
+
let usePrisma = args.includes("--prisma");
|
|
709
|
+
let useDocker = args.includes("--docker");
|
|
710
|
+
const predefinedAnswers = {
|
|
711
|
+
projectName,
|
|
712
|
+
backendOnly: useBackendOnly,
|
|
713
|
+
swaggerDocs: useSwaggerDocs,
|
|
714
|
+
tailwindcss: useTailwind,
|
|
715
|
+
websocket: useWebsocket,
|
|
716
|
+
prisma: usePrisma,
|
|
717
|
+
docker: useDocker,
|
|
718
|
+
};
|
|
719
|
+
console.log("🚀 ~ main ~ predefinedAnswers:", predefinedAnswers);
|
|
720
|
+
answer = await getAnswer(predefinedAnswers);
|
|
721
|
+
if (answer === null) {
|
|
722
|
+
console.log(chalk.red("Installation cancelled."));
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const currentDir = process.cwd();
|
|
726
|
+
const configPath = path.join(currentDir, "prisma-php.json");
|
|
727
|
+
const localSettings = readJsonFile(configPath);
|
|
728
|
+
let excludeFiles = [];
|
|
729
|
+
(_a = localSettings.excludeFiles) === null || _a === void 0 ? void 0 : _a.map((file) => {
|
|
730
|
+
const filePath = path.join(currentDir, file);
|
|
731
|
+
if (fs.existsSync(filePath))
|
|
732
|
+
excludeFiles.push(filePath.replace(/\\/g, "/"));
|
|
733
|
+
});
|
|
734
|
+
updateAnswer = {
|
|
735
|
+
projectName,
|
|
736
|
+
backendOnly: (_b = answer === null || answer === void 0 ? void 0 : answer.backendOnly) !== null && _b !== void 0 ? _b : false,
|
|
737
|
+
swaggerDocs: (_c = answer === null || answer === void 0 ? void 0 : answer.swaggerDocs) !== null && _c !== void 0 ? _c : false,
|
|
738
|
+
tailwindcss: (_d = answer === null || answer === void 0 ? void 0 : answer.tailwindcss) !== null && _d !== void 0 ? _d : false,
|
|
739
|
+
websocket: (_e = answer === null || answer === void 0 ? void 0 : answer.websocket) !== null && _e !== void 0 ? _e : false,
|
|
740
|
+
prisma: (_f = answer === null || answer === void 0 ? void 0 : answer.prisma) !== null && _f !== void 0 ? _f : false,
|
|
741
|
+
docker: (_g = answer === null || answer === void 0 ? void 0 : answer.docker) !== null && _g !== void 0 ? _g : false,
|
|
742
|
+
isUpdate: true,
|
|
743
|
+
excludeFiles: (_h = localSettings.excludeFiles) !== null && _h !== void 0 ? _h : [],
|
|
744
|
+
excludeFilePath: excludeFiles !== null && excludeFiles !== void 0 ? excludeFiles : [],
|
|
745
|
+
filePath: currentDir,
|
|
746
|
+
};
|
|
1044
747
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
748
|
+
else {
|
|
749
|
+
answer = await getAnswer();
|
|
750
|
+
}
|
|
751
|
+
if (answer === null) {
|
|
752
|
+
console.warn(chalk.red("Installation cancelled."));
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const latestVersionOfCreatePrismaPhpApp = await fetchPackageVersion("create-prisma-php-app");
|
|
756
|
+
const isCreatePrismaPhpAppInstalled = getInstalledPackageVersion("create-prisma-php-app");
|
|
757
|
+
if (isCreatePrismaPhpAppInstalled) {
|
|
758
|
+
if (compareVersions(isCreatePrismaPhpAppInstalled, latestVersionOfCreatePrismaPhpApp) === -1) {
|
|
759
|
+
execSync(`npm uninstall -g create-prisma-php-app`, {
|
|
760
|
+
stdio: "inherit",
|
|
761
|
+
});
|
|
762
|
+
execSync(`npm install -g create-prisma-php-app`, {
|
|
763
|
+
stdio: "inherit",
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
execSync("npm install -g create-prisma-php-app", { stdio: "inherit" });
|
|
769
|
+
}
|
|
770
|
+
const latestVersionOfBrowserSync = await fetchPackageVersion("browser-sync");
|
|
771
|
+
const isBrowserSyncInstalled = getInstalledPackageVersion("browser-sync");
|
|
772
|
+
if (isBrowserSyncInstalled) {
|
|
773
|
+
if (compareVersions(isBrowserSyncInstalled, latestVersionOfBrowserSync) ===
|
|
774
|
+
-1) {
|
|
775
|
+
execSync(`npm uninstall -g browser-sync`, {
|
|
776
|
+
stdio: "inherit",
|
|
777
|
+
});
|
|
778
|
+
execSync(`npm install -g browser-sync`, {
|
|
779
|
+
stdio: "inherit",
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
execSync("npm install -g browser-sync", { stdio: "inherit" });
|
|
785
|
+
}
|
|
786
|
+
// Create the project directory
|
|
787
|
+
if (!projectName)
|
|
788
|
+
fs.mkdirSync(answer.projectName);
|
|
789
|
+
const currentDir = process.cwd();
|
|
790
|
+
let projectPath = projectName
|
|
791
|
+
? currentDir
|
|
792
|
+
: path.join(currentDir, answer.projectName);
|
|
793
|
+
if (!projectName)
|
|
794
|
+
process.chdir(answer.projectName);
|
|
795
|
+
const dependencies = [
|
|
796
|
+
"typescript",
|
|
797
|
+
"@types/node",
|
|
798
|
+
"ts-node",
|
|
799
|
+
"http-proxy-middleware@^3.0.0",
|
|
800
|
+
"chalk",
|
|
801
|
+
"npm-run-all",
|
|
1088
802
|
];
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
if (fs.existsSync(filePath)) {
|
|
1092
|
-
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
1093
|
-
console.log(`${file} was deleted successfully.`);
|
|
1094
|
-
} else {
|
|
1095
|
-
console.log(`${file} does not exist.`);
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
if (updateUninstallDependencies.length > 0) {
|
|
1100
|
-
await uninstallDependencies(
|
|
1101
|
-
projectPath,
|
|
1102
|
-
updateUninstallDependencies,
|
|
1103
|
-
true
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
1108
|
-
const bsConfig = bsConfigUrls(projectPathModified);
|
|
1109
|
-
const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
|
|
1110
|
-
const prismaPhpConfig = {
|
|
1111
|
-
projectName: answer.projectName,
|
|
1112
|
-
projectRootPath: projectPathModified,
|
|
1113
|
-
phpEnvironment: "XAMPP",
|
|
1114
|
-
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
1115
|
-
phpGenerateClassPath,
|
|
1116
|
-
bsTarget: bsConfig.bsTarget,
|
|
1117
|
-
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
1118
|
-
backendOnly: answer.backendOnly,
|
|
1119
|
-
swaggerDocs: answer.swaggerDocs,
|
|
1120
|
-
tailwindcss: answer.tailwindcss,
|
|
1121
|
-
websocket: answer.websocket,
|
|
1122
|
-
prisma: answer.prisma,
|
|
1123
|
-
docker: answer.docker,
|
|
1124
|
-
version: latestVersionOfCreatePrismaPhpApp,
|
|
1125
|
-
excludeFiles:
|
|
1126
|
-
(_j =
|
|
1127
|
-
updateAnswer === null || updateAnswer === void 0
|
|
1128
|
-
? void 0
|
|
1129
|
-
: updateAnswer.excludeFiles) !== null && _j !== void 0
|
|
1130
|
-
? _j
|
|
1131
|
-
: [],
|
|
1132
|
-
};
|
|
1133
|
-
fs.writeFileSync(
|
|
1134
|
-
path.join(projectPath, "prisma-php.json"),
|
|
1135
|
-
JSON.stringify(prismaPhpConfig, null, 2),
|
|
1136
|
-
{ flag: "w" }
|
|
1137
|
-
);
|
|
1138
|
-
if (
|
|
1139
|
-
updateAnswer === null || updateAnswer === void 0
|
|
1140
|
-
? void 0
|
|
1141
|
-
: updateAnswer.isUpdate
|
|
1142
|
-
) {
|
|
1143
|
-
execSync(
|
|
1144
|
-
`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`,
|
|
1145
|
-
{
|
|
1146
|
-
stdio: "inherit",
|
|
803
|
+
if (answer.swaggerDocs) {
|
|
804
|
+
dependencies.push("swagger-jsdoc");
|
|
1147
805
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
stdio: "inherit",
|
|
806
|
+
if (answer.tailwindcss) {
|
|
807
|
+
dependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
|
|
808
|
+
}
|
|
809
|
+
if (answer.websocket) {
|
|
810
|
+
dependencies.push("chokidar-cli");
|
|
1154
811
|
}
|
|
1155
|
-
|
|
812
|
+
if (answer.prisma) {
|
|
813
|
+
dependencies.push("prisma", "@prisma/client");
|
|
814
|
+
}
|
|
815
|
+
await installDependencies(projectPath, dependencies, true);
|
|
816
|
+
if (!projectName) {
|
|
817
|
+
execSync(`npx tsc --init`, { stdio: "inherit" });
|
|
818
|
+
}
|
|
819
|
+
if (answer.tailwindcss)
|
|
820
|
+
execSync(`npx tailwindcss init -p`, { stdio: "inherit" });
|
|
821
|
+
if (answer.prisma) {
|
|
822
|
+
if (!fs.existsSync(path.join(projectPath, "prisma")))
|
|
823
|
+
execSync(`npx prisma init`, { stdio: "inherit" });
|
|
824
|
+
}
|
|
825
|
+
await createDirectoryStructure(projectPath, answer);
|
|
826
|
+
const publicDirPath = path.join(projectPath, "public");
|
|
827
|
+
if (!fs.existsSync(publicDirPath)) {
|
|
828
|
+
fs.mkdirSync(publicDirPath);
|
|
829
|
+
}
|
|
830
|
+
if (answer.swaggerDocs) {
|
|
831
|
+
const swaggerDocsPath = path.join(projectPath, "src", "app", "swagger-docs");
|
|
832
|
+
// Check if the directory exists, if not, create it
|
|
833
|
+
if (!fs.existsSync(swaggerDocsPath)) {
|
|
834
|
+
fs.mkdirSync(swaggerDocsPath, { recursive: true }); // 'recursive: true' creates parent directories if they don't exist
|
|
835
|
+
}
|
|
836
|
+
// Clone the Git repository into the swagger-docs directory
|
|
837
|
+
execSync(`git clone https://github.com/TheSteelNinjaCode/prisma-php-swagger-docs.git ${swaggerDocsPath}`, { stdio: "inherit" });
|
|
838
|
+
}
|
|
839
|
+
if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
|
|
840
|
+
const updateUninstallDependencies = [];
|
|
841
|
+
if (updateAnswer.backendOnly) {
|
|
842
|
+
nonBackendFiles.forEach((file) => {
|
|
843
|
+
const filePath = path.join(projectPath, "src", "app", file);
|
|
844
|
+
if (fs.existsSync(filePath)) {
|
|
845
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
846
|
+
console.log(`${file} was deleted successfully.`);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
console.log(`${file} does not exist.`);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
const backendOnlyFolders = ["js", "css"];
|
|
853
|
+
backendOnlyFolders.forEach((folder) => {
|
|
854
|
+
const folderPath = path.join(projectPath, "src", "app", folder);
|
|
855
|
+
if (fs.existsSync(folderPath)) {
|
|
856
|
+
fs.rmSync(folderPath, { recursive: true, force: true }); // Use fs.rmSync instead of fs.rmdirSync
|
|
857
|
+
console.log(`${folder} was deleted successfully.`);
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
console.log(`${folder} does not exist.`);
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
if (!updateAnswer.swaggerDocs) {
|
|
865
|
+
const swaggerDocsFolder = path.join(projectPath, "src", "app", "swagger-docs");
|
|
866
|
+
if (fs.existsSync(swaggerDocsFolder)) {
|
|
867
|
+
fs.rmSync(swaggerDocsFolder, { recursive: true, force: true }); // Use fs.rmSync instead of fs.rmdirSync
|
|
868
|
+
console.log(`swagger-docs was deleted successfully.`);
|
|
869
|
+
}
|
|
870
|
+
const swaggerFiles = ["swagger-setup.js"];
|
|
871
|
+
swaggerFiles.forEach((file) => {
|
|
872
|
+
const filePath = path.join(projectPath, "settings", file);
|
|
873
|
+
if (fs.existsSync(filePath)) {
|
|
874
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
875
|
+
console.log(`${file} was deleted successfully.`);
|
|
876
|
+
}
|
|
877
|
+
else {
|
|
878
|
+
console.log(`${file} does not exist.`);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
updateUninstallDependencies.push("swagger-jsdoc");
|
|
882
|
+
}
|
|
883
|
+
if (!updateAnswer.tailwindcss) {
|
|
884
|
+
const tailwindFiles = ["postcss.config.js", "tailwind.config.js"];
|
|
885
|
+
tailwindFiles.forEach((file) => {
|
|
886
|
+
const filePath = path.join(projectPath, file);
|
|
887
|
+
if (fs.existsSync(filePath)) {
|
|
888
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
889
|
+
console.log(`${file} was deleted successfully.`);
|
|
890
|
+
}
|
|
891
|
+
else {
|
|
892
|
+
console.log(`${file} does not exist.`);
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
updateUninstallDependencies.push("tailwindcss", "autoprefixer", "postcss", "postcss-cli", "cssnano");
|
|
896
|
+
}
|
|
897
|
+
if (!updateAnswer.websocket) {
|
|
898
|
+
updateUninstallDependencies.push("chokidar-cli");
|
|
899
|
+
}
|
|
900
|
+
if (!updateAnswer.prisma) {
|
|
901
|
+
updateUninstallDependencies.push("prisma", "@prisma/client");
|
|
902
|
+
}
|
|
903
|
+
if (!updateAnswer.docker) {
|
|
904
|
+
const dockerFiles = [
|
|
905
|
+
".dockerignore",
|
|
906
|
+
"docker-compose.yml",
|
|
907
|
+
"Dockerfile",
|
|
908
|
+
"apache.conf",
|
|
909
|
+
];
|
|
910
|
+
dockerFiles.forEach((file) => {
|
|
911
|
+
const filePath = path.join(projectPath, file);
|
|
912
|
+
if (fs.existsSync(filePath)) {
|
|
913
|
+
fs.unlinkSync(filePath); // Delete each file if it exists
|
|
914
|
+
console.log(`${file} was deleted successfully.`);
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
console.log(`${file} does not exist.`);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
if (updateUninstallDependencies.length > 0) {
|
|
922
|
+
await uninstallDependencies(projectPath, updateUninstallDependencies, true);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
const projectPathModified = projectPath.replace(/\\/g, "\\");
|
|
926
|
+
const bsConfig = bsConfigUrls(projectPathModified);
|
|
927
|
+
const phpGenerateClassPath = answer.prisma ? "src/Lib/Prisma/Classes" : "";
|
|
928
|
+
const prismaPhpConfig = {
|
|
929
|
+
projectName: answer.projectName,
|
|
930
|
+
projectRootPath: projectPathModified,
|
|
931
|
+
phpEnvironment: "XAMPP",
|
|
932
|
+
phpRootPathExe: "C:\\xampp\\php\\php.exe",
|
|
933
|
+
phpGenerateClassPath,
|
|
934
|
+
bsTarget: bsConfig.bsTarget,
|
|
935
|
+
bsPathRewrite: bsConfig.bsPathRewrite,
|
|
936
|
+
backendOnly: answer.backendOnly,
|
|
937
|
+
swaggerDocs: answer.swaggerDocs,
|
|
938
|
+
tailwindcss: answer.tailwindcss,
|
|
939
|
+
websocket: answer.websocket,
|
|
940
|
+
prisma: answer.prisma,
|
|
941
|
+
docker: answer.docker,
|
|
942
|
+
version: latestVersionOfCreatePrismaPhpApp,
|
|
943
|
+
excludeFiles: (_j = updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.excludeFiles) !== null && _j !== void 0 ? _j : [],
|
|
944
|
+
};
|
|
945
|
+
fs.writeFileSync(path.join(projectPath, "prisma-php.json"), JSON.stringify(prismaPhpConfig, null, 2), { flag: "w" });
|
|
946
|
+
if (updateAnswer === null || updateAnswer === void 0 ? void 0 : updateAnswer.isUpdate) {
|
|
947
|
+
execSync(`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar update`, {
|
|
948
|
+
stdio: "inherit",
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
execSync(`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar install`, {
|
|
953
|
+
stdio: "inherit",
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
console.log(`${chalk.green("Success!")} Prisma PHP project successfully created in ${answer.projectName}!`);
|
|
957
|
+
}
|
|
958
|
+
catch (error) {
|
|
959
|
+
console.error("Error while creating the project:", error);
|
|
960
|
+
process.exit(1);
|
|
1156
961
|
}
|
|
1157
|
-
console.log(
|
|
1158
|
-
`${chalk.green("Success!")} Prisma PHP project successfully created in ${
|
|
1159
|
-
answer.projectName
|
|
1160
|
-
}!`
|
|
1161
|
-
);
|
|
1162
|
-
} catch (error) {
|
|
1163
|
-
console.error("Error while creating the project:", error);
|
|
1164
|
-
process.exit(1);
|
|
1165
|
-
}
|
|
1166
962
|
}
|
|
1167
963
|
main();
|