create-fullstack-boilerplate 2.1.2 → 2.1.3

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/lib/copyProject.js +49 -21
  2. package/package.json +1 -1
@@ -3,47 +3,75 @@ const fs = require("fs-extra");
3
3
  const path = require("path");
4
4
 
5
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);
6
+ // Resolve absolute paths
7
+ const resolvedSrc = path.resolve(src);
8
+ const resolvedDest = path.resolve(dest);
9
9
 
10
10
  // Check if destination already exists
11
- if (await fs.pathExists(normalizedDest)) {
12
- throw new Error(`Directory '${path.basename(normalizedDest)}' already exists. Please choose a different project name.`);
11
+ if (await fs.pathExists(resolvedDest)) {
12
+ throw new Error(`Directory '${path.basename(resolvedDest)}' already exists. Please choose a different project name.`);
13
13
  }
14
14
 
15
15
  // Check if source template exists
16
- if (!await fs.pathExists(normalizedSrc)) {
17
- throw new Error(`Template directory not found at: ${normalizedSrc}`);
16
+ if (!await fs.pathExists(resolvedSrc)) {
17
+ throw new Error(`Template directory not found at: ${resolvedSrc}`);
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}`);
18
24
  }
19
25
 
20
26
  log("Creating project directory...");
21
27
 
22
28
  try {
23
- // Ensure destination directory exists first
24
- await fs.ensureDir(normalizedDest);
29
+ // Create destination directory
30
+ await fs.ensureDir(resolvedDest);
31
+
32
+ // Copy backend
33
+ console.log("Copying backend...");
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
+ );
25
47
 
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");
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));
33
55
  }
34
- });
56
+ }
57
+
58
+ // Verify the copy was successful
59
+ const backendPath = path.join(resolvedDest, "backend");
60
+ const frontendPath = path.join(resolvedDest, "frontend");
35
61
 
36
- // Verify the copy was successful by checking if backend exists
37
- const backendPath = path.join(normalizedDest, "backend");
38
62
  if (!await fs.pathExists(backendPath)) {
39
- throw new Error(`Copy verification failed: backend folder not found at ${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}`);
40
68
  }
41
69
 
42
70
  console.log("✅ Files copied successfully.");
43
71
  } catch (err) {
44
72
  // Clean up on failure
45
73
  try {
46
- await fs.remove(normalizedDest);
74
+ await fs.remove(resolvedDest);
47
75
  } catch (cleanupErr) {
48
76
  // Ignore cleanup errors
49
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fullstack-boilerplate",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
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": {