@semaphore-protocol/cli 0.2.0 → 0.3.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.
- package/README.md +23 -9
- package/dist/index.js +19 -9
- package/package.json +2 -2
- package/src/index.ts +22 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<h1 align="center">
|
|
3
3
|
Semaphore CLI
|
|
4
4
|
</h1>
|
|
5
|
-
<p align="center">A command line tool to set up your Semaphore project and
|
|
5
|
+
<p align="center">A command line tool to set up your Semaphore project and get group data.</p>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
@@ -46,23 +46,37 @@
|
|
|
46
46
|
</h4>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
49
|
+
| Setting up a project, although not particularly complex, can be a lengthy process for some people. A command line to initialize a Semaphore project can reduce the set-up time from a few minutes to a few seconds. In addition, the Semaphore CLI can also be used to obtain on-chain group data. |
|
|
50
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
51
|
|
|
52
52
|
## 🛠 Install
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Install the `@semaphore-protocol/cli` package with npm:
|
|
54
|
+
Install the `@semaphore-protocol/cli` package globally:
|
|
57
55
|
|
|
58
56
|
```bash
|
|
59
|
-
npm i @semaphore-protocol/cli
|
|
57
|
+
npm i -g @semaphore-protocol/cli
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
or
|
|
60
|
+
or run specific commands with `npx`:
|
|
63
61
|
|
|
64
62
|
```bash
|
|
65
|
-
|
|
63
|
+
npx @semaphore-protocol/cli init my-app
|
|
66
64
|
```
|
|
67
65
|
|
|
68
66
|
## 📜 Usage
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
Usage: semaphore [options] [command]
|
|
70
|
+
|
|
71
|
+
A command line tool to set up your Semaphore project and get group data.
|
|
72
|
+
|
|
73
|
+
Options:
|
|
74
|
+
-v, --version Show Semaphore CLI version.
|
|
75
|
+
-h, --help Display this help.
|
|
76
|
+
|
|
77
|
+
Commands:
|
|
78
|
+
init <project-directory> Initialize a Semaphore project with a supported template.
|
|
79
|
+
get-groups [options] Get the list of groups from a supported network (Goerli or Arbitrum).
|
|
80
|
+
get-group [options] <group-id> Get the data of a group from a supported network (Goerli or Arbitrum).
|
|
81
|
+
help [command] Display help for a specific command.
|
|
82
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module @semaphore-protocol/cli
|
|
5
|
-
* @version 0.
|
|
6
|
-
* @file A command line tool to set up your Semaphore project and
|
|
5
|
+
* @version 0.3.0
|
|
6
|
+
* @file A command line tool to set up your Semaphore project and get group data.
|
|
7
7
|
* @copyright Ethereum Foundation 2022
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli}
|
|
@@ -38,10 +38,10 @@ class Spinner {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const packagePath = `${dirname(fileURLToPath(import.meta.url))}/..`;
|
|
41
|
-
const { version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"));
|
|
41
|
+
const { description, version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"));
|
|
42
42
|
program
|
|
43
43
|
.name("semaphore")
|
|
44
|
-
.description(
|
|
44
|
+
.description(description)
|
|
45
45
|
.version(version, "-v, --version", "Show Semaphore CLI version.")
|
|
46
46
|
.addHelpText("before", `${figlet.textSync("Semaphore")}\n`)
|
|
47
47
|
.addHelpText("after", "\r")
|
|
@@ -58,18 +58,28 @@ program
|
|
|
58
58
|
.argument("<project-directory>", "Directory of the project.")
|
|
59
59
|
// .option("-t, --template <template-name>", "Supported Semaphore template.", "hardhat")
|
|
60
60
|
.action(async (projectDirectory) => {
|
|
61
|
-
|
|
62
|
-
const spinner = new Spinner(`Creating
|
|
61
|
+
const currentDirectory = process.cwd();
|
|
62
|
+
const spinner = new Spinner(`Creating your project in ${chalk.green(`./${projectDirectory}`)}`);
|
|
63
63
|
const templateURL = `https://registry.npmjs.org/@semaphore-protocol/cli-template-hardhat/-/cli-template-hardhat-${version}.tgz`;
|
|
64
64
|
if (existsSync(projectDirectory)) {
|
|
65
65
|
console.info(`\n ${logSymbols.error}`, `error: the '${projectDirectory}' folder already exists\n`);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
spinner.start();
|
|
69
|
-
await download(templateURL,
|
|
70
|
-
renameSync(
|
|
69
|
+
await download(templateURL, currentDirectory, { extract: true });
|
|
70
|
+
renameSync(`${currentDirectory}/package`, `${currentDirectory}/${projectDirectory}`);
|
|
71
71
|
spinner.stop();
|
|
72
|
-
console.info(` ${logSymbols.success}`, `Your
|
|
72
|
+
console.info(` ${logSymbols.success}`, `Your project is ready!\n`);
|
|
73
|
+
console.info(` Please, install your dependencies by running:\n`);
|
|
74
|
+
console.info(` ${chalk.cyan("cd")} ${projectDirectory}`);
|
|
75
|
+
console.info(` ${chalk.cyan("npm i")}\n`);
|
|
76
|
+
const { scripts } = JSON.parse(readFileSync(`${currentDirectory}/${projectDirectory}/package.json`, "utf8"));
|
|
77
|
+
if (scripts) {
|
|
78
|
+
console.info(` Available scripts:\n`);
|
|
79
|
+
console.info(`${Object.keys(scripts)
|
|
80
|
+
.map((s) => ` ${chalk.cyan(`npm run ${s}`)}`)
|
|
81
|
+
.join("\n")}\n`);
|
|
82
|
+
}
|
|
73
83
|
});
|
|
74
84
|
program
|
|
75
85
|
.command("get-groups")
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "A command line tool to set up your Semaphore project and
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "A command line tool to set up your Semaphore project and get group data.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
8
8
|
"semaphore": "dist/index.js"
|
package/src/index.ts
CHANGED
|
@@ -10,11 +10,11 @@ import { fileURLToPath } from "url"
|
|
|
10
10
|
import Spinner from "./spinner.js"
|
|
11
11
|
|
|
12
12
|
const packagePath = `${dirname(fileURLToPath(import.meta.url))}/..`
|
|
13
|
-
const { version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"))
|
|
13
|
+
const { description, version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"))
|
|
14
14
|
|
|
15
15
|
program
|
|
16
16
|
.name("semaphore")
|
|
17
|
-
.description(
|
|
17
|
+
.description(description)
|
|
18
18
|
.version(version, "-v, --version", "Show Semaphore CLI version.")
|
|
19
19
|
.addHelpText("before", `${figlet.textSync("Semaphore")}\n`)
|
|
20
20
|
.addHelpText("after", "\r")
|
|
@@ -32,8 +32,8 @@ program
|
|
|
32
32
|
.argument("<project-directory>", "Directory of the project.")
|
|
33
33
|
// .option("-t, --template <template-name>", "Supported Semaphore template.", "hardhat")
|
|
34
34
|
.action(async (projectDirectory) => {
|
|
35
|
-
|
|
36
|
-
const spinner = new Spinner(`Creating
|
|
35
|
+
const currentDirectory = process.cwd()
|
|
36
|
+
const spinner = new Spinner(`Creating your project in ${chalk.green(`./${projectDirectory}`)}`)
|
|
37
37
|
const templateURL = `https://registry.npmjs.org/@semaphore-protocol/cli-template-hardhat/-/cli-template-hardhat-${version}.tgz`
|
|
38
38
|
|
|
39
39
|
if (existsSync(projectDirectory)) {
|
|
@@ -43,13 +43,28 @@ program
|
|
|
43
43
|
|
|
44
44
|
spinner.start()
|
|
45
45
|
|
|
46
|
-
await download(templateURL,
|
|
46
|
+
await download(templateURL, currentDirectory, { extract: true })
|
|
47
47
|
|
|
48
|
-
renameSync(
|
|
48
|
+
renameSync(`${currentDirectory}/package`, `${currentDirectory}/${projectDirectory}`)
|
|
49
49
|
|
|
50
50
|
spinner.stop()
|
|
51
51
|
|
|
52
|
-
console.info(` ${logSymbols.success}`, `Your
|
|
52
|
+
console.info(` ${logSymbols.success}`, `Your project is ready!\n`)
|
|
53
|
+
console.info(` Please, install your dependencies by running:\n`)
|
|
54
|
+
console.info(` ${chalk.cyan("cd")} ${projectDirectory}`)
|
|
55
|
+
console.info(` ${chalk.cyan("npm i")}\n`)
|
|
56
|
+
|
|
57
|
+
const { scripts } = JSON.parse(readFileSync(`${currentDirectory}/${projectDirectory}/package.json`, "utf8"))
|
|
58
|
+
|
|
59
|
+
if (scripts) {
|
|
60
|
+
console.info(` Available scripts:\n`)
|
|
61
|
+
|
|
62
|
+
console.info(
|
|
63
|
+
`${Object.keys(scripts)
|
|
64
|
+
.map((s) => ` ${chalk.cyan(`npm run ${s}`)}`)
|
|
65
|
+
.join("\n")}\n`
|
|
66
|
+
)
|
|
67
|
+
}
|
|
53
68
|
})
|
|
54
69
|
|
|
55
70
|
program
|