codeweaver 1.0.11 → 1.0.13
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/README.md +2 -9
- package/command.js +64 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,16 +28,9 @@ To get started with the project, follow these steps:
|
|
|
28
28
|
|
|
29
29
|
1. **Clone the repository**:
|
|
30
30
|
|
|
31
|
-
You can either use:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npx create-codeweaver-app
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
or manually run:
|
|
38
|
-
|
|
39
31
|
```bash
|
|
40
|
-
|
|
32
|
+
npx create-codeweaver-app my-app
|
|
33
|
+
cd my-app
|
|
41
34
|
```
|
|
42
35
|
|
|
43
36
|
2. **Install dependencies**:
|
package/command.js
CHANGED
|
@@ -1,17 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const fs = require("fs");
|
|
3
4
|
const { exec } = require("child_process");
|
|
4
5
|
const path = require("path");
|
|
6
|
+
const { version } = require("os");
|
|
5
7
|
|
|
8
|
+
// Get the project name from command-line arguments or use a default name
|
|
9
|
+
const projectName = process.argv[2] || "my-app";
|
|
10
|
+
|
|
11
|
+
// Set the URL of the GitHub repository
|
|
6
12
|
const repoUrl = "https://github.com/js-code-crafter/codeweaver.git";
|
|
7
|
-
const projectName = process.argv[2] || "codeweaver"; // Allow project name as an argument
|
|
8
13
|
|
|
14
|
+
// Clone the repository into the specified project name
|
|
9
15
|
exec(`git clone ${repoUrl} ${projectName}`, (error) => {
|
|
10
16
|
if (error) {
|
|
11
17
|
console.error(`Error cloning repository: ${error.message}`);
|
|
12
18
|
return;
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
20
|
+
|
|
21
|
+
// Path to the cloned package.json file
|
|
22
|
+
const packageJsonPath = path.join(projectName, "package.json");
|
|
23
|
+
|
|
24
|
+
// Update the package.json file
|
|
25
|
+
fs.readFile(packageJsonPath, "utf8", (readError, data) => {
|
|
26
|
+
if (readError) {
|
|
27
|
+
console.error(`Error reading package.json: ${readError.message}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Parse the package.json content and update the name
|
|
32
|
+
const {
|
|
33
|
+
bin,
|
|
34
|
+
name = projectName,
|
|
35
|
+
version = "1.0.0",
|
|
36
|
+
description = "",
|
|
37
|
+
keywords = "",
|
|
38
|
+
author = "",
|
|
39
|
+
license = "",
|
|
40
|
+
...packageJson
|
|
41
|
+
} = JSON.parse(data);
|
|
42
|
+
|
|
43
|
+
// Write the updated package.json back to the file
|
|
44
|
+
fs.writeFile(
|
|
45
|
+
packageJsonPath,
|
|
46
|
+
JSON.stringify(packageJson, null, 2),
|
|
47
|
+
(writeError) => {
|
|
48
|
+
if (writeError) {
|
|
49
|
+
console.error(`Error writing package.json: ${writeError.message}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Remove the .git folder
|
|
54
|
+
exec(`rm -rf ${path.join(projectName, ".git")}`, (rmError) => {
|
|
55
|
+
if (rmError) {
|
|
56
|
+
console.error(`Error removing .git folder: ${rmError.message}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exec(`rm -f ${path.join(projectName, "command.js")}`, (rm2Error) => {
|
|
61
|
+
if (rm2Error) {
|
|
62
|
+
console.error(
|
|
63
|
+
`Error removing command.js file: ${rm2Error.message}`
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log(
|
|
69
|
+
`Successfully cloned codeweaver into ${path.resolve(projectName)}`
|
|
70
|
+
);
|
|
71
|
+
console.log(`The project name is set to "${projectName}".`);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
});
|
|
17
77
|
});
|