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 +1 -1
- package/lib/setupMainDB.js +3 -1
- package/lib/utils.js +27 -8
- package/package.json +1 -1
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
|
|
package/lib/setupMainDB.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
data =
|
|
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
|
-
|
|
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.
|
|
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": {
|