dappbooster 0.2.0 → 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.
Files changed (2) hide show
  1. package/index.js +25 -22
  2. 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,54 +14,58 @@ 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
- }
17
+ function getLatestTag() {
18
+ // Get all tags, sorted by version
19
+ const tags = execSync("git tag -l --sort=-v:refname")
20
+ .toString()
21
+ .trim()
22
+ .split("\n");
29
23
 
30
- return execSync(command, options);
24
+ // Return the first (latest) tag
25
+ return tags[0];
31
26
  }
32
27
 
33
28
  function cloneRepo(projectName) {
34
29
  const sanitizedProjectName = projectName.replace(/[^a-zA-Z0-9-_]/g, "-");
35
30
  const projectDir = path.join(process.cwd(), sanitizedProjectName);
31
+ const execOptions = {
32
+ stdio: "pipe",
33
+ shell: true,
34
+ };
36
35
 
37
36
  try {
38
37
  console.log(`Cloning DappBooster...`);
39
38
 
40
39
  // Clone the repository
41
- execQuiet(`git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`);
40
+ execSync(
41
+ `git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`,
42
+ execOptions
43
+ );
42
44
 
43
45
  // Change to the project directory
44
46
  process.chdir(projectDir);
45
47
 
46
48
  // Fetch all tags
47
- execQuiet("git fetch --tags");
49
+ execSync("git fetch --tags", execOptions);
48
50
 
49
51
  // Get the latest tag
50
- const latestTag = execSync(
51
- "git describe --tags $(git rev-list --tags --max-count=1)"
52
- )
53
- .toString()
54
- .trim();
52
+ const latestTag = getLatestTag();
53
+
54
+ if (!latestTag) {
55
+ throw new Error("No tags found in the repository");
56
+ }
55
57
 
56
58
  // Checkout the latest tag
57
- execQuiet(`git checkout "${latestTag}"`);
59
+ execSync(`git checkout "${latestTag}"`, execOptions);
58
60
 
59
61
  // Remove the .git directory
60
62
  fs.rmSync(path.join(projectDir, ".git"), { recursive: true, force: true });
61
63
 
62
64
  // Initialize a new git repository
63
- execQuiet("git init");
65
+ execSync("git init", execOptions);
64
66
 
65
67
  console.log(`DappBooster repository cloned in ${projectDir}`);
68
+ console.log(`Latest version: ${latestTag}`);
66
69
  } catch (error) {
67
70
  console.error("An error occurred:", error.message);
68
71
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dappbooster",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Script to easily start your project with dAppBooster",
5
5
  "main": "index.js",
6
6
  "bin": {