dappbooster 0.0.1 → 0.1.0

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 +41 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,54 +1,77 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { execSync } = require("child_process");
4
- const fs = require("fs");
4
+ // const fs = require("fs");
5
5
  const path = require("path");
6
- const readline = require("readline");
6
+ // const readline = require("readline");
7
7
 
8
8
  const repoUrl = "https://github.com/bootnodedev/dappbooster.git";
9
+ const projectName = process.argv[2];
9
10
 
10
- const rl = readline.createInterface({
11
- input: process.stdin,
12
- output: process.stdout,
13
- });
11
+ // const rl = readline.createInterface({
12
+ // input: process.stdin,
13
+ // output: process.stdout,
14
+ // });
14
15
 
15
- rl.question("Enter the project name: ", (projectName) => {
16
- rl.close();
16
+ try {
17
+ /^[a-zA-Z0-9-_]+/.test(projectName);
18
+ cloneRepo(projectName);
19
+ return;
20
+ } catch (error) {
21
+ console.error("Invalid directory name. Please enter a valid project name.");
22
+ process.exit(1);
23
+ }
17
24
 
25
+ // request project name to continue
26
+ // rl.question("Enter the project name: ", (projectName) => {
27
+ // rl.close();
28
+ // cloneRepo(projectName);
29
+ // });
30
+
31
+ function cloneRepo(projectName) {
18
32
  // Sanitize the project name to create a valid directory name
19
33
  const sanitizedProjectName = projectName.replace(/[^a-zA-Z0-9-_]/g, "-");
20
34
  const projectDir = path.join(process.cwd(), sanitizedProjectName);
21
35
 
22
36
  try {
23
- console.log(`Cloning DappBooster repository into ${projectDir}...`);
37
+ console.log(`cloning DappBooster...`);
24
38
 
25
39
  // Clone the repository with minimum history
26
- execSync(`git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}"`, {
27
- stdio: "inherit",
28
- });
40
+ execSync(
41
+ `git clone --depth 1 --no-checkout "${repoUrl}" "${projectDir}" > /dev/null 2>&1`,
42
+ {
43
+ stdio: "inherit",
44
+ }
45
+ );
29
46
 
30
47
  // Change to the project directory
31
48
  process.chdir(projectDir);
32
49
 
33
50
  // Fetch all tags
34
- execSync("git fetch --tags", { stdio: "inherit" });
51
+ execSync("git fetch --tags > /dev/null 2>&1", { stdio: "inherit" });
35
52
 
36
53
  // Get the latest tag
37
54
  const latestTag = execSync(
38
- "git describe --tags $(git rev-list --tags --max-count=1)"
55
+ "git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null"
39
56
  )
40
57
  .toString()
41
58
  .trim();
42
59
 
43
60
  // Checkout the latest tag
44
- execSync(`git checkout "${latestTag}"`, { stdio: "inherit" });
61
+ execSync(`git checkout "${latestTag}" > /dev/null 2>&1`, {
62
+ stdio: "inherit",
63
+ });
45
64
 
46
- // Print the checked out tag
47
- console.log(`Cloned DappBooster repository at tag: ${latestTag}`);
65
+ process.chdir(projectDir);
66
+
67
+ execSync("rm -rf .git", { stdio: "inherit" });
48
68
 
69
+ execSync("git init > /dev/null 2>&1", { stdio: "inherit" });
70
+
71
+ // Print the checked out tag
49
72
  console.log(`DappBooster repository cloned in ${projectDir}`);
50
73
  } catch (error) {
51
74
  console.error("An error occurred:", error.message);
52
75
  process.exit(1);
53
76
  }
54
- });
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dappbooster",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Script to easily start your project with dAppBooster",
5
5
  "main": "index.js",
6
6
  "bin": {