wad-lab 1.0.3 → 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/bin/index.js +25 -2
  2. package/package.json +5 -2
package/bin/index.js CHANGED
@@ -4,6 +4,29 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const readline = require('readline');
6
6
 
7
+ function copyDirRecursive(src, dest) {
8
+ if (typeof fs.cpSync === 'function') {
9
+ fs.cpSync(src, dest, { recursive: true });
10
+ return;
11
+ }
12
+
13
+ if (!fs.existsSync(dest)) {
14
+ fs.mkdirSync(dest, { recursive: true });
15
+ }
16
+
17
+ const entries = fs.readdirSync(src, { withFileTypes: true });
18
+ for (const entry of entries) {
19
+ const srcPath = path.join(src, entry.name);
20
+ const destPath = path.join(dest, entry.name);
21
+
22
+ if (entry.isDirectory()) {
23
+ copyDirRecursive(srcPath, destPath);
24
+ } else {
25
+ fs.copyFileSync(srcPath, destPath);
26
+ }
27
+ }
28
+ }
29
+
7
30
  const templates = [
8
31
  { name: 'all (Unpack All 17 Templates)', value: 'all' },
9
32
  { name: 'html-css-js (Form Validation & DOM)', value: 'html-css-js' },
@@ -76,13 +99,13 @@ function promptFolderName(choices) {
76
99
  }
77
100
 
78
101
  if (isAll) {
79
- fs.cpSync(templatesRoot, destDir, { recursive: true });
102
+ copyDirRecursive(templatesRoot, destDir);
80
103
  console.log('\nSuccessfully unpacked ALL templates into: ' + destDir);
81
104
  } else {
82
105
  choices.forEach(c => {
83
106
  const src = path.join(templatesRoot, c);
84
107
  const dest = path.join(destDir, c);
85
- fs.cpSync(src, dest, { recursive: true });
108
+ copyDirRecursive(src, dest);
86
109
  console.log('Unpacked [' + c + '] into: ' + dest);
87
110
  });
88
111
  console.log('\nSuccessfully unpacked all chosen templates into: ' + destDir);
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "wad-lab",
3
- "version": "1.0.3",
4
- "description": "Interactive CLI for WAD Lab starter templates with multi-select support",
3
+ "version": "1.0.4",
4
+ "description": "Interactive CLI for WAD Lab starter templates compatible with Node 12+",
5
5
  "bin": {
6
6
  "wad-lab": "./bin/index.js"
7
7
  },
8
+ "engines": {
9
+ "node": ">=12.0.0"
10
+ },
8
11
  "keywords": [
9
12
  "wad",
10
13
  "spring-boot",