babyclara 0.0.2 → 0.0.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/index.js +44 -27
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,49 +4,66 @@ const fs = require("fs");
4
4
  const path = require("path");
5
5
  const { execSync } = require("child_process");
6
6
 
7
- // Folders in your npm package to copy
8
- // key = folder in CLI package
9
- // value = destination folder name inside user's project
10
7
  const foldersToCopy = [
11
- { from: "template", to: "." }, // copy into root
12
- { from: "data", to: "data" } // copy into ./data
8
+ { from: "template", to: "." },
9
+ { from: "data", to: "data" }
13
10
  ];
14
11
 
15
- // Target folder (user directory)
16
12
  const targetDir = process.cwd();
17
13
 
18
- // Reusable recursive copy function
14
+ // Recursive folder copy
19
15
  function copyFolder(src, dest) {
20
- if (!fs.existsSync(dest)) {
21
- fs.mkdirSync(dest, { recursive: true });
22
- }
16
+ if (!fs.existsSync(dest)) {
17
+ fs.mkdirSync(dest, { recursive: true });
18
+ }
23
19
 
24
- const items = fs.readdirSync(src);
25
- if (items.length === 0) return;
20
+ const items = fs.readdirSync(src);
21
+ if (items.length === 0) return;
26
22
 
27
- items.forEach(item => {
28
- const from = path.join(src, item);
29
- const to = path.join(dest, item);
23
+ items.forEach(item => {
24
+ const from = path.join(src, item);
25
+ const to = path.join(dest, item);
30
26
 
31
- if (fs.lstatSync(from).isDirectory()) {
32
- copyFolder(from, to);
33
- } else {
34
- fs.copyFileSync(from, to);
35
- }
36
- });
27
+ if (fs.lstatSync(from).isDirectory()) {
28
+ copyFolder(from, to);
29
+ } else {
30
+ fs.copyFileSync(from, to);
31
+ }
32
+ });
37
33
  }
38
34
 
39
35
  console.log("Generating Work Station...");
40
36
 
41
- // Copy template and data folders
42
37
  foldersToCopy.forEach(folder => {
43
- const src = path.join(__dirname, folder.from);
44
- const dest = path.join(targetDir, folder.to);
45
- copyFolder(src, dest);
38
+ const src = path.join(__dirname, folder.from);
39
+ const dest = path.join(targetDir, folder.to);
40
+ copyFolder(src, dest);
46
41
  });
47
42
 
48
- // Install gkrane inside the generated workspace
43
+ // Install gkrane
49
44
  console.log("Installing Dependencies...");
50
- execSync("npm install gkrane", { cwd: targetDir, stdio: "inherit" });
45
+ execSync("npm install gkrane chokidar", { cwd: targetDir, stdio: "inherit" });
46
+
47
+ // Modify package.json
48
+ const pkgPath = path.join(targetDir, "package.json");
49
+
50
+ if (fs.existsSync(pkgPath)) {
51
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
52
+
53
+ pkg.scripts = pkg.scripts || {};
54
+
55
+ // Add or override your scripts
56
+ pkg.scripts.start =
57
+ "npx chokidar '**/*' '!apps/**' '!games/**' -c 'node ./node_modules/gkrane/core/index.js'";
58
+
59
+ pkg.scripts.dev =
60
+ "node ./node_modules/gkrane/core/dev.js";
61
+
62
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
63
+
64
+ console.log("Updated package.json scripts successfully.");
65
+ } else {
66
+ console.warn("⚠️ No package.json found — cannot add scripts.");
67
+ }
51
68
 
52
69
  console.log("Done!");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babyclara",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A Vue.Js Work Station",
5
5
  "main": "index.js",
6
6
  "author": "Augment Chinedu",