create-fullstack-boilerplate 2.1.3 → 2.1.4
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 +4 -4
- package/lib/addDB.js +1 -1
- package/lib/addRoute.js +1 -1
- package/lib/copyProject.js +11 -54
- package/lib/setupExtraDB.js +1 -1
- package/lib/setupMainDB.js +1 -1
- package/lib/testDBConnection.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
await copyProject(templateDir, targetDir);
|
|
59
59
|
await setupMainDB(targetDir, answers.dbDialect);
|
|
60
60
|
console.log("➡️ Installing backend dependencies...");
|
|
61
|
-
await runInstall(path.join(targetDir, "
|
|
61
|
+
await runInstall(path.join(targetDir, "Backend"));
|
|
62
62
|
|
|
63
63
|
console.log("➡️ Installing frontend dependencies...");
|
|
64
|
-
await runInstall(path.join(targetDir, "
|
|
64
|
+
await runInstall(path.join(targetDir, "Frontend"));
|
|
65
65
|
|
|
66
66
|
console.log("➡️ Installing Your Db Dialect: ", answers.dbDialect)
|
|
67
|
-
await installDBDriver(path.join(targetDir, "
|
|
67
|
+
await installDBDriver(path.join(targetDir, "Backend"), answers.dbDialect);
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
if (answers.addExtraDB) {
|
|
71
71
|
const extraDB = await extraDBPrompts();
|
|
72
72
|
console.log(`\n🔍 Testing connection for ${extraDB.dbKey}...`);
|
|
73
|
-
await installDBDriver(path.join(targetDir, "
|
|
73
|
+
await installDBDriver(path.join(targetDir, "Backend"), extraDB.dialect);
|
|
74
74
|
const ok = await testDBConnection(targetDir, extraDB);
|
|
75
75
|
|
|
76
76
|
if (ok) {
|
package/lib/addDB.js
CHANGED
|
@@ -11,7 +11,7 @@ module.exports = async function addDB() {
|
|
|
11
11
|
console.log(`\n➕ Add New Database to Existing Project\n`);
|
|
12
12
|
|
|
13
13
|
const targetDir = process.cwd();
|
|
14
|
-
const backendDir = path.join(targetDir, "
|
|
14
|
+
const backendDir = path.join(targetDir, "Backend");
|
|
15
15
|
const dbDir = path.join(backendDir, "DB");
|
|
16
16
|
const modelsDir = path.join(backendDir, "Models");
|
|
17
17
|
|
package/lib/addRoute.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = async function addRoute() {
|
|
|
9
9
|
console.log(`\n➕ Add New Route to Backend\n`);
|
|
10
10
|
|
|
11
11
|
const targetDir = process.cwd();
|
|
12
|
-
const backendDir = path.join(targetDir, "
|
|
12
|
+
const backendDir = path.join(targetDir, "Backend");
|
|
13
13
|
const routesDir = path.join(backendDir, "routes");
|
|
14
14
|
const servicesDir = path.join(backendDir, "services");
|
|
15
15
|
|
package/lib/copyProject.js
CHANGED
|
@@ -3,75 +3,32 @@ const fs = require("fs-extra");
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
|
|
5
5
|
module.exports = async function copyProject(src, dest) {
|
|
6
|
-
// Resolve absolute paths
|
|
7
|
-
const resolvedSrc = path.resolve(src);
|
|
8
|
-
const resolvedDest = path.resolve(dest);
|
|
9
|
-
|
|
10
6
|
// Check if destination already exists
|
|
11
|
-
if (await fs.pathExists(
|
|
12
|
-
throw new Error(`Directory '${path.basename(
|
|
7
|
+
if (await fs.pathExists(dest)) {
|
|
8
|
+
throw new Error(`Directory '${path.basename(dest)}' already exists. Please choose a different project name.`);
|
|
13
9
|
}
|
|
14
10
|
|
|
15
11
|
// Check if source template exists
|
|
16
|
-
if (!await fs.pathExists(
|
|
17
|
-
throw new Error(`Template directory not found at: ${
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Verify backend exists in source
|
|
21
|
-
const srcBackend = path.join(resolvedSrc, "backend");
|
|
22
|
-
if (!await fs.pathExists(srcBackend)) {
|
|
23
|
-
throw new Error(`Template is missing backend folder at: ${srcBackend}`);
|
|
12
|
+
if (!await fs.pathExists(src)) {
|
|
13
|
+
throw new Error(`Template directory not found at: ${src}`);
|
|
24
14
|
}
|
|
25
15
|
|
|
26
16
|
log("Creating project directory...");
|
|
27
17
|
|
|
28
18
|
try {
|
|
29
|
-
//
|
|
30
|
-
await fs.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await fs.copy(
|
|
35
|
-
path.join(resolvedSrc, "backend"),
|
|
36
|
-
path.join(resolvedDest, "backend"),
|
|
37
|
-
{ filter: (src) => !src.includes("node_modules") }
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Copy frontend
|
|
41
|
-
console.log("Copying frontend...");
|
|
42
|
-
await fs.copy(
|
|
43
|
-
path.join(resolvedSrc, "frontend"),
|
|
44
|
-
path.join(resolvedDest, "frontend"),
|
|
45
|
-
{ filter: (src) => !src.includes("node_modules") }
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Copy root files if any (like .gitignore, README, etc.)
|
|
49
|
-
const rootFiles = await fs.readdir(resolvedSrc);
|
|
50
|
-
for (const file of rootFiles) {
|
|
51
|
-
const srcPath = path.join(resolvedSrc, file);
|
|
52
|
-
const stat = await fs.stat(srcPath);
|
|
53
|
-
if (stat.isFile()) {
|
|
54
|
-
await fs.copy(srcPath, path.join(resolvedDest, file));
|
|
19
|
+
// Copy entire template directory (Backend and Frontend folders will be copied with their exact names)
|
|
20
|
+
await fs.copy(src, dest, {
|
|
21
|
+
filter: (srcPath) => {
|
|
22
|
+
// Filter out node_modules
|
|
23
|
+
return !srcPath.includes("node_modules");
|
|
55
24
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Verify the copy was successful
|
|
59
|
-
const backendPath = path.join(resolvedDest, "backend");
|
|
60
|
-
const frontendPath = path.join(resolvedDest, "frontend");
|
|
61
|
-
|
|
62
|
-
if (!await fs.pathExists(backendPath)) {
|
|
63
|
-
throw new Error(`Backend folder not copied to: ${backendPath}`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!await fs.pathExists(frontendPath)) {
|
|
67
|
-
throw new Error(`Frontend folder not copied to: ${frontendPath}`);
|
|
68
|
-
}
|
|
25
|
+
});
|
|
69
26
|
|
|
70
27
|
console.log("✅ Files copied successfully.");
|
|
71
28
|
} catch (err) {
|
|
72
29
|
// Clean up on failure
|
|
73
30
|
try {
|
|
74
|
-
await fs.remove(
|
|
31
|
+
await fs.remove(dest);
|
|
75
32
|
} catch (cleanupErr) {
|
|
76
33
|
// Ignore cleanup errors
|
|
77
34
|
}
|
package/lib/setupExtraDB.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require("fs-extra"); // no assert needed
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
module.exports = async function setupExtraDB(targetDir, dbConfig) {
|
|
8
|
-
const backendDir = path.join(targetDir, "
|
|
8
|
+
const backendDir = path.join(targetDir, "Backend");
|
|
9
9
|
const modelsDir = path.join(backendDir, "Models");
|
|
10
10
|
const dbDir = path.join(backendDir, "DB");
|
|
11
11
|
|
package/lib/setupMainDB.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require("path");
|
|
|
3
3
|
|
|
4
4
|
module.exports = async function setupMainDB(targetDir, dialect) {
|
|
5
5
|
log("Configuring main DB in backend...");
|
|
6
|
-
const backendDir = path.join(targetDir, "
|
|
6
|
+
const backendDir = path.join(targetDir, "Backend");
|
|
7
7
|
await replaceInFiles(backendDir, {
|
|
8
8
|
"__DB_DIALECT__": dialect
|
|
9
9
|
});
|
package/lib/testDBConnection.js
CHANGED
|
@@ -36,7 +36,7 @@ const path = require("path");
|
|
|
36
36
|
const { assertDependency } = require("./utils");
|
|
37
37
|
|
|
38
38
|
async function testDBConnection(targetDir, dbConfig) {
|
|
39
|
-
const backendDir = path.join(targetDir, "
|
|
39
|
+
const backendDir = path.join(targetDir, "Backend");
|
|
40
40
|
|
|
41
41
|
let driver;
|
|
42
42
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fullstack-boilerplate",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
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": {
|