create-fullstack-boilerplate 2.1.1 → 2.1.2
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/lib/copyProject.js +33 -8
- package/lib/utils.js +29 -5
- package/package.json +1 -1
package/lib/copyProject.js
CHANGED
|
@@ -1,27 +1,52 @@
|
|
|
1
1
|
const { log } = require("./utils");
|
|
2
|
-
// const fs = ensure("fs-extra");
|
|
3
2
|
const fs = require("fs-extra");
|
|
4
|
-
|
|
5
3
|
const path = require("path");
|
|
6
4
|
|
|
7
5
|
module.exports = async function copyProject(src, dest) {
|
|
6
|
+
// Normalize paths to handle Windows paths with spaces
|
|
7
|
+
const normalizedSrc = path.normalize(src);
|
|
8
|
+
const normalizedDest = path.normalize(dest);
|
|
9
|
+
|
|
8
10
|
// Check if destination already exists
|
|
9
|
-
if (await fs.pathExists(
|
|
10
|
-
throw new Error(`Directory '${path.basename(
|
|
11
|
+
if (await fs.pathExists(normalizedDest)) {
|
|
12
|
+
throw new Error(`Directory '${path.basename(normalizedDest)}' already exists. Please choose a different project name.`);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
// Check if source template exists
|
|
14
|
-
if (!await fs.pathExists(
|
|
15
|
-
throw new Error(`Template directory not found
|
|
16
|
+
if (!await fs.pathExists(normalizedSrc)) {
|
|
17
|
+
throw new Error(`Template directory not found at: ${normalizedSrc}`);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
log("Creating project directory...");
|
|
21
|
+
|
|
19
22
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
// Ensure destination directory exists first
|
|
24
|
+
await fs.ensureDir(normalizedDest);
|
|
25
|
+
|
|
26
|
+
// Copy with error handling
|
|
27
|
+
await fs.copy(normalizedSrc, normalizedDest, {
|
|
28
|
+
overwrite: false,
|
|
29
|
+
errorOnExist: false,
|
|
30
|
+
filter: (item) => {
|
|
31
|
+
// Filter out node_modules
|
|
32
|
+
return !item.includes("node_modules");
|
|
33
|
+
}
|
|
22
34
|
});
|
|
35
|
+
|
|
36
|
+
// Verify the copy was successful by checking if backend exists
|
|
37
|
+
const backendPath = path.join(normalizedDest, "backend");
|
|
38
|
+
if (!await fs.pathExists(backendPath)) {
|
|
39
|
+
throw new Error(`Copy verification failed: backend folder not found at ${backendPath}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
console.log("✅ Files copied successfully.");
|
|
24
43
|
} catch (err) {
|
|
44
|
+
// Clean up on failure
|
|
45
|
+
try {
|
|
46
|
+
await fs.remove(normalizedDest);
|
|
47
|
+
} catch (cleanupErr) {
|
|
48
|
+
// Ignore cleanup errors
|
|
49
|
+
}
|
|
25
50
|
throw new Error(`Failed to copy project files: ${err.message}`);
|
|
26
51
|
}
|
|
27
52
|
};
|
package/lib/utils.js
CHANGED
|
@@ -81,10 +81,23 @@ function assertDependency(depName, cwd) {
|
|
|
81
81
|
|
|
82
82
|
// ------------------ Run npm install ------------------
|
|
83
83
|
async function runInstall(cwd) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
// Normalize path for Windows
|
|
85
|
+
const normalizedCwd = path.normalize(cwd);
|
|
86
|
+
|
|
87
|
+
// Verify directory exists
|
|
88
|
+
if (!await fs.pathExists(normalizedCwd)) {
|
|
89
|
+
throw new Error(`Directory does not exist: ${normalizedCwd}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await execa("npm", ["install"], {
|
|
94
|
+
cwd: normalizedCwd,
|
|
95
|
+
stdio: "inherit",
|
|
96
|
+
shell: true // Use shell for Windows compatibility
|
|
97
|
+
});
|
|
98
|
+
} catch (err) {
|
|
99
|
+
throw new Error(`npm install failed in ${normalizedCwd}: ${err.message}`);
|
|
100
|
+
}
|
|
88
101
|
}
|
|
89
102
|
|
|
90
103
|
// ------------------ Installing Dynamic DB Drivers ----------------
|
|
@@ -96,8 +109,19 @@ async function installDBDriver(targetDir, dialect) {
|
|
|
96
109
|
if (dialect === "postgres") pkg = "pg";
|
|
97
110
|
if (!pkg) return;
|
|
98
111
|
|
|
112
|
+
// Normalize path for Windows
|
|
113
|
+
const normalizedDir = path.normalize(targetDir);
|
|
114
|
+
|
|
99
115
|
console.log(`➡️ Installing ${pkg}...`);
|
|
100
|
-
|
|
116
|
+
try {
|
|
117
|
+
await execa("npm", ["install", pkg], {
|
|
118
|
+
cwd: normalizedDir,
|
|
119
|
+
stdio: "inherit",
|
|
120
|
+
shell: true // Use shell for Windows compatibility
|
|
121
|
+
});
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.warn(`Warning: Failed to install ${pkg}: ${err.message}`);
|
|
124
|
+
}
|
|
101
125
|
}
|
|
102
126
|
|
|
103
127
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fullstack-boilerplate",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
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": {
|