@tronscanteam/cli 1.0.1 → 1.0.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/README.md +3 -26
- package/README_CN.md +3 -26
- package/package.json +1 -1
- package/src/api.js +1 -1
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -14,49 +14,26 @@ Two ways to use: **`ts` in the terminal** (after global install) and **natural l
|
|
|
14
14
|
npm install -g @tronscanteam/cli
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
This registers the global command **`ts`** for use in any directory. Run `ts help` to see all commands.
|
|
17
|
+
This registers the global command **`ts`** for use in any directory. Run `ts setup` to configure your API Key, and `ts help` to see all commands.
|
|
18
18
|
|
|
19
19
|
**API Key**:
|
|
20
20
|
|
|
21
21
|
Get your API Key: https://docs.tronscan.org/zh/api/api-keys
|
|
22
22
|
|
|
23
|
-
**Method A: `ts setup`**
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
ts setup YOUR_API_KEY
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
**Method B: environment variable**
|
|
30
|
-
|
|
31
|
-
Persist it in your shell config, then `source` once. zsh example:
|
|
32
|
-
|
|
33
23
|
```bash
|
|
34
|
-
|
|
35
|
-
source ~/.zshrc
|
|
24
|
+
ts setup YOUR_API_KEY # replace with your actual API Key
|
|
36
25
|
```
|
|
37
26
|
|
|
38
|
-
For bash, use `~/.bashrc` or `~/.bash_profile` instead of `~/.zshrc`.
|
|
39
|
-
|
|
40
27
|
### 2. Install from source (clone)
|
|
41
28
|
|
|
42
29
|
```bash
|
|
43
30
|
git clone https://github.com/sshnii/tronscan-cli.git
|
|
44
31
|
cd tronscan-cli
|
|
45
32
|
npm install
|
|
46
|
-
cp .env.example .env
|
|
47
|
-
# Edit .env and set TRONSCAN_API_KEY
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Register **`ts`** on your machine:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
33
|
npm link
|
|
54
|
-
#
|
|
55
|
-
npm install -g .
|
|
34
|
+
ts setup YOUR_API_KEY # replace with your actual API Key
|
|
56
35
|
```
|
|
57
36
|
|
|
58
|
-
The CLI reads `.env` from the **cloned project root** (next to `package.json`). After that, run `ts` from any working directory.
|
|
59
|
-
|
|
60
37
|
## Usage
|
|
61
38
|
|
|
62
39
|
### 1. In the terminal
|
package/README_CN.md
CHANGED
|
@@ -14,49 +14,26 @@
|
|
|
14
14
|
npm install -g @tronscanteam/cli
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
安装后即可在任意目录使用全局命令 **`ts`**,输入 `ts help` 查看全部命令。
|
|
17
|
+
安装后即可在任意目录使用全局命令 **`ts`**,输入 `ts setup` 设置 API Key,输入 `ts help` 查看全部命令。
|
|
18
18
|
|
|
19
19
|
**配置 API Key**:
|
|
20
20
|
|
|
21
21
|
API Key 申请:https://docs.tronscan.org/zh/api/api-keys
|
|
22
22
|
|
|
23
|
-
**方式 A:`ts setup`**
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
ts setup YOUR_API_KEY
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
**方式 B:环境变量**
|
|
30
|
-
|
|
31
|
-
长期生效:把密钥写进 shell 配置文件,保存后执行一次 `source`。zsh 示例:
|
|
32
|
-
|
|
33
23
|
```bash
|
|
34
|
-
|
|
35
|
-
source ~/.zshrc
|
|
24
|
+
ts setup YOUR_API_KEY # 替换为你的真实 API Key
|
|
36
25
|
```
|
|
37
26
|
|
|
38
|
-
使用 bash 时,将 `~/.zshrc` 换成 `~/.bashrc` 或 `~/.bash_profile`。
|
|
39
|
-
|
|
40
27
|
### 二、从源码克隆安装
|
|
41
28
|
|
|
42
29
|
```bash
|
|
43
30
|
git clone https://github.com/sshnii/tronscan-cli.git
|
|
44
31
|
cd tronscan-cli
|
|
45
32
|
npm install
|
|
46
|
-
cp .env.example .env
|
|
47
|
-
# 编辑 .env,设置 TRONSCAN_API_KEY
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
在本机注册全局命令 **`ts`**:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
33
|
npm link
|
|
54
|
-
#
|
|
55
|
-
npm install -g .
|
|
34
|
+
ts setup YOUR_API_KEY # 替换为你的真实 API Key
|
|
56
35
|
```
|
|
57
36
|
|
|
58
|
-
CLI 会从**克隆下来的项目根目录**(与 `package.json` 同级)读取 `.env`;配置好后在任意工作目录都可执行 `ts`。
|
|
59
|
-
|
|
60
37
|
## 使用方式
|
|
61
38
|
|
|
62
39
|
### 一、在终端中使用
|
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -9,7 +9,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = dirname(__filename);
|
|
10
10
|
export const PROJECT_ROOT = resolve(__dirname, '..');
|
|
11
11
|
|
|
12
|
-
export const VERSION = '1.0.
|
|
12
|
+
export const VERSION = '1.0.2';
|
|
13
13
|
const BASE_URL = 'https://apilist.tronscanapi.com';
|
|
14
14
|
|
|
15
15
|
let apiKey = process.env.TRONSCAN_API_KEY || '';
|
package/src/index.js
CHANGED
|
@@ -93,9 +93,9 @@ if (cmd === 'setup') {
|
|
|
93
93
|
|
|
94
94
|
console.log(bold('TronScan CLI 配置向导\n'));
|
|
95
95
|
console.log(` 1. 申请 API Key: ${bold('https://tronscan.org/#/developer/api')}`);
|
|
96
|
-
console.log(` 2. 运行: ${bold('ts setup
|
|
96
|
+
console.log(` 2. 运行: ${bold('ts setup YOUR_API_KEY')}`);
|
|
97
97
|
console.log(` 或手动编辑: ${dim(envPath)}`);
|
|
98
|
-
console.log(`\n 也可设置环境变量: ${bold('export TRONSCAN_API_KEY
|
|
98
|
+
console.log(`\n 也可设置环境变量: ${bold('export TRONSCAN_API_KEY=YOUR_API_KEY')}`);
|
|
99
99
|
process.exit(0);
|
|
100
100
|
}
|
|
101
101
|
|