create-fullstack-boilerplate 2.1.0 → 2.1.1

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/index.js CHANGED
@@ -51,7 +51,7 @@
51
51
  try {
52
52
  console.log("\nšŸŽ›ļø Setting Up Full Stack Project...\n");
53
53
 
54
- const answers = await mainPrompts();
54
+ const answers = await mainPrompts();
55
55
  // const templateDir = path.join(__dirname, "template");
56
56
  const targetDir = path.join(process.cwd(), answers.projectName);
57
57
 
@@ -1,8 +1,10 @@
1
1
  const { replaceInFiles, log } = require("./utils");
2
+ const path = require("path");
2
3
 
3
4
  module.exports = async function setupMainDB(targetDir, dialect) {
4
5
  log("Configuring main DB in backend...");
5
- await replaceInFiles(targetDir, {
6
+ const backendDir = path.join(targetDir, "backend");
7
+ await replaceInFiles(backendDir, {
6
8
  "__DB_DIALECT__": dialect
7
9
  });
8
10
  console.log("āœ… Main DB configured.");
package/lib/utils.js CHANGED
@@ -26,16 +26,35 @@ async function replaceInFiles(base, replacements) {
26
26
  const exts = [".js", ".ts", ".json", ".md", ".env", ".yml"];
27
27
 
28
28
  async function walk(dir) {
29
- for (const item of await fs.readdir(dir)) {
29
+ // Check if directory exists
30
+ if (!await fs.pathExists(dir)) {
31
+ console.warn(`Warning: Directory ${dir} does not exist, skipping...`);
32
+ return;
33
+ }
34
+
35
+ let items;
36
+ try {
37
+ items = await fs.readdir(dir);
38
+ } catch (err) {
39
+ console.warn(`Warning: Could not read directory ${dir}: ${err.message}`);
40
+ return;
41
+ }
42
+
43
+ for (const item of items) {
30
44
  const fullPath = path.join(dir, item);
31
- const stat = await fs.stat(fullPath);
32
- if (stat.isDirectory()) await walk(fullPath);
33
- else if (exts.includes(path.extname(fullPath))) {
34
- let data = await fs.readFile(fullPath, "utf8");
35
- for (const [k, v] of Object.entries(replacements)) {
36
- data = data.replaceAll(k, v);
45
+ try {
46
+ const stat = await fs.stat(fullPath);
47
+ if (stat.isDirectory()) {
48
+ await walk(fullPath);
49
+ } else if (exts.includes(path.extname(fullPath))) {
50
+ let data = await fs.readFile(fullPath, "utf8");
51
+ for (const [k, v] of Object.entries(replacements)) {
52
+ data = data.replaceAll(k, v);
53
+ }
54
+ await fs.writeFile(fullPath, data);
37
55
  }
38
- await fs.writeFile(fullPath, data);
56
+ } catch (err) {
57
+ console.warn(`Warning: Error processing ${fullPath}: ${err.message}`);
39
58
  }
40
59
  }
41
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fullstack-boilerplate",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "A Full Stack Application Comprised of React for Frontend, Express & Sequelize with Node js for Backend to help developers get started on real implementation instead of spending time setting up projects.",
5
5
  "main": "index.js",
6
6
  "bin": {