netcore-blueprint 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +29 -20
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -8,32 +8,41 @@ if (!projectName) {
8
8
  }
9
9
 
10
10
  const destinationPath = path.join(process.cwd(), projectName);
11
- const templateFolders = ["MainProject", "WorkerProject1", "WorkerProject2"];
12
-
13
- function copyFolder(src, dest) {
14
- fs.mkdirSync(dest, { recursive: true });
15
- const entries = fs.readdirSync(src, { withFileTypes: true });
16
-
17
- for (let entry of entries) {
18
- const srcPath = path.join(src, entry.name);
19
- const destPath = path.join(dest, entry.name);
20
-
21
- if (entry.isDirectory()) {
22
- copyFolder(srcPath, destPath);
23
- } else {
24
- fs.copyFileSync(srcPath, destPath);
11
+ const templateItems = ["Blueprint.API.sln", "Blueprint.API", ".gitignore"];
12
+
13
+ function copyItem(src, dest) {
14
+ if (fs.lstatSync(src).isDirectory()) {
15
+ fs.mkdirSync(dest, { recursive: true });
16
+ const entries = fs.readdirSync(src, { withFileTypes: true });
17
+ for (let entry of entries) {
18
+ const srcPath = path.join(src, entry.name);
19
+ const destPath = path.join(dest, entry.name);
20
+ copyItem(srcPath, destPath);
25
21
  }
22
+ } else {
23
+ fs.copyFileSync(src, dest);
26
24
  }
27
25
  }
28
26
 
27
+ // Check if the destination path already exists
28
+ if (fs.existsSync(destinationPath)) {
29
+ console.error(`Project directory "${projectName}" already exists.`);
30
+ process.exit(1);
31
+ }
32
+
29
33
  // Create the destination directory
30
34
  fs.mkdirSync(destinationPath, { recursive: true });
31
35
 
32
- // Copy each template folder into the new project directory
33
- templateFolders.forEach(folder => {
34
- const srcFolderPath = path.join(__dirname, folder);
35
- const destFolderPath = path.join(destinationPath, folder);
36
- copyFolder(srcFolderPath, destFolderPath);
36
+ // Copy each template item into the new project directory
37
+ templateItems.forEach(item => {
38
+ const srcPath = path.join(__dirname, item);
39
+ const destPath = path.join(destinationPath, item);
40
+
41
+ if (fs.existsSync(srcPath)) { // Check if the source item exists
42
+ copyItem(srcPath, destPath);
43
+ } else {
44
+ console.warn(`Source item "${srcPath}" does not exist and will be skipped.`);
45
+ }
37
46
  });
38
47
 
39
- console.log(`Project ${projectName} created at ${destinationPath}`);
48
+ console.log(`Project "${projectName}" created at ${destinationPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netcore-blueprint",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -10,7 +10,7 @@
10
10
  "license": "ISC",
11
11
  "description": "",
12
12
  "bin": {
13
- "truongdx8-netcore-blueprint": "./index.js"
13
+ "netcore-blueprint": "./index.js"
14
14
  },
15
15
  "files": [
16
16
  "index.js",