dappbooster 0.2.1 → 0.2.2
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/index.js +11 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
|
-
const os = require("os");
|
|
7
6
|
|
|
8
7
|
const repoUrl = "https://github.com/bootnodedev/dappbooster.git";
|
|
9
8
|
const projectName = process.argv[2];
|
|
@@ -15,21 +14,6 @@ if (!projectName || !/^[a-zA-Z0-9-_]+$/.test(projectName)) {
|
|
|
15
14
|
|
|
16
15
|
cloneRepo(projectName);
|
|
17
16
|
|
|
18
|
-
function execQuiet(command) {
|
|
19
|
-
const options = {
|
|
20
|
-
stdio: "pipe",
|
|
21
|
-
shell: true,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
if (os.platform() === "win32") {
|
|
25
|
-
command = `${command} > nul 2>&1`;
|
|
26
|
-
} else {
|
|
27
|
-
command = `${command} > /dev/null 2>&1`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return execSync(command, options);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
17
|
function getLatestTag() {
|
|
34
18
|
// Get all tags, sorted by version
|
|
35
19
|
const tags = execSync("git tag -l --sort=-v:refname")
|
|
@@ -44,18 +28,25 @@ function getLatestTag() {
|
|
|
44
28
|
function cloneRepo(projectName) {
|
|
45
29
|
const sanitizedProjectName = projectName.replace(/[^a-zA-Z0-9-_]/g, "-");
|
|
46
30
|
const projectDir = path.join(process.cwd(), sanitizedProjectName);
|
|
31
|
+
const execOptions = {
|
|
32
|
+
stdio: "pipe",
|
|
33
|
+
shell: true,
|
|
34
|
+
};
|
|
47
35
|
|
|
48
36
|
try {
|
|
49
37
|
console.log(`Cloning DappBooster...`);
|
|
50
38
|
|
|
51
39
|
// Clone the repository
|
|
52
|
-
|
|
40
|
+
execSync(
|
|
41
|
+
`git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`,
|
|
42
|
+
execOptions
|
|
43
|
+
);
|
|
53
44
|
|
|
54
45
|
// Change to the project directory
|
|
55
46
|
process.chdir(projectDir);
|
|
56
47
|
|
|
57
48
|
// Fetch all tags
|
|
58
|
-
|
|
49
|
+
execSync("git fetch --tags", execOptions);
|
|
59
50
|
|
|
60
51
|
// Get the latest tag
|
|
61
52
|
const latestTag = getLatestTag();
|
|
@@ -65,13 +56,13 @@ function cloneRepo(projectName) {
|
|
|
65
56
|
}
|
|
66
57
|
|
|
67
58
|
// Checkout the latest tag
|
|
68
|
-
|
|
59
|
+
execSync(`git checkout "${latestTag}"`, execOptions);
|
|
69
60
|
|
|
70
61
|
// Remove the .git directory
|
|
71
62
|
fs.rmSync(path.join(projectDir, ".git"), { recursive: true, force: true });
|
|
72
63
|
|
|
73
64
|
// Initialize a new git repository
|
|
74
|
-
|
|
65
|
+
execSync("git init", execOptions);
|
|
75
66
|
|
|
76
67
|
console.log(`DappBooster repository cloned in ${projectDir}`);
|
|
77
68
|
console.log(`Latest version: ${latestTag}`);
|