codeweaver 1.0.11 → 1.0.14

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/LICENSE CHANGED
@@ -1,7 +1,5 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Ehsan-Afzali-2024
4
-
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
4
  of this software and associated documentation files (the "Software"), to deal
7
5
  in the Software without restriction, including without limitation the rights
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
- git clone https://github.com/@js-code-crafter/codeweaver.git
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,75 @@
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
- console.log(
15
- `Successfully cloned codeweaver into ${path.resolve(projectName)}`
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 command.js file
54
+ exec(`rm -f ${path.join(projectName, "command.js")}`, (rmError) => {
55
+ if (rmError) {
56
+ console.error(`Error removing command.js file: ${rmError.message}`);
57
+ return;
58
+ }
59
+
60
+ // Remove the .git folder
61
+ exec(`rm -rf ${path.join(projectName, ".git")}`, (rm2Error) => {
62
+ if (rm2Error) {
63
+ console.error(`Error removing .git folder: ${rm2Error.message}`);
64
+ return;
65
+ }
66
+
67
+ console.log(
68
+ `Successfully cloned codeweaver into ${path.resolve(projectName)}`
69
+ );
70
+ });
71
+ });
72
+ }
73
+ );
74
+ });
17
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeweaver",
3
- "version": "1.0.11",
3
+ "version": "1.0.14",
4
4
  "main": "src/app.ts",
5
5
  "bin": {
6
6
  "create-codeweaver-app": "./command.js"