create-prisma-php-app 1.6.32 → 1.6.34

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -187,7 +187,8 @@ async function executeCopy(baseDir, directoriesToCopy) {
187
187
  copyRecursiveSync(sourcePath, destPath);
188
188
  });
189
189
  }
190
- function modifyTailwindConfig(baseDir) {
190
+ function createOrUpdateTailwindConfig(baseDir) {
191
+ console.log("🚀 ~ createOrUpdateTailwindConfig ~ baseDir:", baseDir);
191
192
  const filePath = path.join(baseDir, "tailwind.config.js");
192
193
  const newContent = [
193
194
  "./src/app/**/*.{html,js,php}",
@@ -198,7 +199,7 @@ function modifyTailwindConfig(baseDir) {
198
199
  .map((item) => ` "${item}"`)
199
200
  .join(",\n");
200
201
  configData = configData.replace(/content: \[\],/g, `content: [\n${contentArrayString}\n],`);
201
- fs.writeFileSync(filePath, configData, "utf8");
202
+ fs.writeFileSync(filePath, configData, { flag: "w" });
202
203
  console.log(chalk.green("Tailwind configuration updated successfully."));
203
204
  }
204
205
  function modifyPostcssConfig(baseDir) {
@@ -210,7 +211,7 @@ function modifyPostcssConfig(baseDir) {
210
211
  cssnano: {},
211
212
  },
212
213
  };`;
213
- fs.writeFileSync(filePath, newContent, "utf8");
214
+ fs.writeFileSync(filePath, newContent, { flag: "w" });
214
215
  console.log(chalk.green("postcss.config.js updated successfully."));
215
216
  }
216
217
  function modifyIndexPHP(baseDir, useTailwind) {
@@ -224,7 +225,7 @@ function modifyIndexPHP(baseDir, useTailwind) {
224
225
  : ` <script src="https://cdn.tailwindcss.com"></script> ${stylesAndLinks}`;
225
226
  // Insert before the closing </head> tag
226
227
  indexContent = indexContent.replace("</head>", `${tailwindLink}\n</head>`);
227
- fs.writeFileSync(indexPath, indexContent, "utf8");
228
+ fs.writeFileSync(indexPath, indexContent, { flag: "w" });
228
229
  console.log(chalk.green(`index.php modified successfully for ${useTailwind ? "local Tailwind CSS" : "Tailwind CSS CDN"}.`));
229
230
  }
230
231
  catch (error) {
@@ -232,13 +233,13 @@ function modifyIndexPHP(baseDir, useTailwind) {
232
233
  }
233
234
  }
234
235
  // This function updates or creates the .env file
235
- async function updateOrCreateEnvFile(baseDir, content) {
236
+ async function createOrUpdateEnvFile(baseDir, content) {
236
237
  const envPath = path.join(baseDir, ".env");
237
238
  let envContent = fs.existsSync(envPath)
238
239
  ? fs.readFileSync(envPath, "utf8")
239
240
  : "";
240
241
  envContent += `${envContent !== "" ? "\n\n" : ""}${content}`;
241
- fs.writeFileSync(envPath, envContent);
242
+ fs.writeFileSync(envPath, envContent, { flag: "w" });
242
243
  }
243
244
  async function createDirectoryStructure(baseDir, answer, projectSettings) {
244
245
  console.log("🚀 ~ baseDir:", baseDir);
@@ -287,7 +288,7 @@ async function createDirectoryStructure(baseDir, answer, projectSettings) {
287
288
  await updateComposerJson(baseDir, answer);
288
289
  await updateIndexJsForWebSocket(baseDir, answer);
289
290
  if (answer.tailwindcss) {
290
- modifyTailwindConfig(baseDir);
291
+ createOrUpdateTailwindConfig(baseDir);
291
292
  modifyIndexPHP(baseDir, true);
292
293
  modifyPostcssConfig(baseDir);
293
294
  }
@@ -302,7 +303,7 @@ SMTP_PORT=
302
303
  SMTP_ENCRYPTION=ssl
303
304
  MAIL_FROM=
304
305
  MAIL_FROM_NAME=""`;
305
- await updateOrCreateEnvFile(baseDir, envContent);
306
+ await createOrUpdateEnvFile(baseDir, envContent);
306
307
  // Add vendor to .gitignore
307
308
  await createUpdateGitignoreFile(baseDir, ["vendor"]);
308
309
  }
@@ -344,7 +345,8 @@ async function getAnswer(predefinedAnswers = {}) {
344
345
  };
345
346
  try {
346
347
  const response = await prompts(questions, { onCancel });
347
- if (Object.keys(response).length === 0) {
348
+ console.log("🚀 ~ response:", response);
349
+ if (Object.keys(response).length === 0 && !predefinedAnswers.projectName) {
348
350
  return null;
349
351
  }
350
352
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "1.6.32",
3
+ "version": "1.6.34",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",