dappbooster 0.2.1 → 0.3.1

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 +37 -28
  2. package/package.json +11 -4
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execSync } = require("child_process");
4
- const path = require("path");
5
- const fs = require("fs");
6
- const os = require("os");
3
+ import { execSync } from "child_process";
4
+ import { join } from "path";
5
+ import { rmSync } from "fs";
6
+ import chalk from "chalk";
7
7
 
8
8
  const repoUrl = "https://github.com/bootnodedev/dappbooster.git";
9
9
  const projectName = process.argv[2];
@@ -15,21 +15,6 @@ if (!projectName || !/^[a-zA-Z0-9-_]+$/.test(projectName)) {
15
15
 
16
16
  cloneRepo(projectName);
17
17
 
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
18
  function getLatestTag() {
34
19
  // Get all tags, sorted by version
35
20
  const tags = execSync("git tag -l --sort=-v:refname")
@@ -43,19 +28,26 @@ function getLatestTag() {
43
28
 
44
29
  function cloneRepo(projectName) {
45
30
  const sanitizedProjectName = projectName.replace(/[^a-zA-Z0-9-_]/g, "-");
46
- const projectDir = path.join(process.cwd(), sanitizedProjectName);
31
+ const projectDir = join(process.cwd(), sanitizedProjectName);
32
+ const execOptions = {
33
+ stdio: "pipe",
34
+ shell: true,
35
+ };
47
36
 
48
37
  try {
49
38
  console.log(`Cloning DappBooster...`);
50
39
 
51
40
  // Clone the repository
52
- execQuiet(`git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`);
41
+ execSync(
42
+ `git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`,
43
+ execOptions
44
+ );
53
45
 
54
46
  // Change to the project directory
55
47
  process.chdir(projectDir);
56
48
 
57
49
  // Fetch all tags
58
- execQuiet("git fetch --tags");
50
+ execSync("git fetch --tags", execOptions);
59
51
 
60
52
  // Get the latest tag
61
53
  const latestTag = getLatestTag();
@@ -65,18 +57,35 @@ function cloneRepo(projectName) {
65
57
  }
66
58
 
67
59
  // Checkout the latest tag
68
- execQuiet(`git checkout "${latestTag}"`);
60
+ execSync(`git checkout "${latestTag}"`, execOptions);
69
61
 
70
62
  // Remove the .git directory
71
- fs.rmSync(path.join(projectDir, ".git"), { recursive: true, force: true });
63
+ rmSync(join(projectDir, ".git"), { recursive: true, force: true });
72
64
 
73
65
  // Initialize a new git repository
74
- execQuiet("git init");
66
+ execSync("git init", execOptions);
67
+
68
+ console.log(`DappBooster repository cloned in ${chalk.bold(projectDir)}`);
69
+ console.log(`Latest version: ${chalk.bold(latestTag)}`);
70
+ console.log(`
71
+ ${chalk.green.bold(
72
+ "You can now start your project with the following commands:"
73
+ )}
74
+
75
+ ${chalk.blue("# Change to the project directory")}
76
+ $ ${chalk.cyan(`cd ${sanitizedProjectName}`)}
77
+
78
+ ${chalk.blue("# Install dependencies")}
79
+ $ ${chalk.cyan("pnpm install")}
80
+
81
+ ${chalk.blue("# Copy the example environment file")}
82
+ $ ${chalk.cyan("cp .env.example .env.local")}
75
83
 
76
- console.log(`DappBooster repository cloned in ${projectDir}`);
77
- console.log(`Latest version: ${latestTag}`);
84
+ ${chalk.blue("# Start the development server")}
85
+ $ ${chalk.cyan("pnpm dev")}
86
+ `);
78
87
  } catch (error) {
79
- console.error("An error occurred:", error.message);
88
+ console.error(`${chalk.bold.red("An error occurred:")}`, error.message);
80
89
  process.exit(1);
81
90
  }
82
91
  }
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "dappbooster",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Script to easily start your project with dAppBooster",
5
5
  "main": "index.js",
6
6
  "bin": {
7
- "dappbooster": "./index.js"
7
+ "dappbooster": "index.js"
8
8
  },
9
+ "type": "module",
9
10
  "scripts": {
10
11
  "test": "echo \"Error: no test specified\" && exit 1"
11
12
  },
13
+ "dependencies": {
14
+ "chalk": "^5.3.0"
15
+ },
12
16
  "keywords": [
13
17
  "dappbooster",
14
18
  "bootnode",
@@ -16,6 +20,9 @@
16
20
  "installer",
17
21
  "dapp"
18
22
  ],
19
- "author": "",
20
- "license": "MIT"
23
+ "author": "bootnodedev",
24
+ "license": "MIT",
25
+ "engines": {
26
+ "node": ">=20.0.0"
27
+ }
21
28
  }