@icyouo/evt-cli 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.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # evt-cli
2
+
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ evt-cli is a general-purpose HTTP CLI for running YAML-defined APIs and workflows. It uses YAML for endpoint and flow definitions, and JSON profiles for base URLs, headers, tokens, fixtures, and cache configuration. After installation, use the `evt` command.
6
+
7
+ ## Principles
8
+
9
+ - Runtime endpoints come only from `apis/*.yaml`.
10
+ - Flows come only from `flows/*.yaml`.
11
+ - Environments, base URLs, headers, and test fixtures come only from `profiles/*.json`.
12
+ - The scanner is only for coverage comparison and generating missing YAML skeletons. It is not a runtime data source.
13
+ - The default data directory is bundled with the CLI package. You can also point to your own project data directory with `--config-root` or `EVT_CLI_ROOT`.
14
+
15
+ ## Quick Start
16
+
17
+ Install:
18
+
19
+ ```bash
20
+ npm install -g @icyouo/evt-cli
21
+ ```
22
+
23
+ Run the bundled example data:
24
+
25
+ ```bash
26
+ evt profile list
27
+ evt api list
28
+ evt validate
29
+ evt api call todo.list --profile local --dry-run
30
+ ```
31
+
32
+ During local development, run the entry file directly:
33
+
34
+ ```bash
35
+ node bin/evt.js profile list
36
+ node bin/evt.js api list
37
+ node bin/evt.js validate
38
+ node bin/evt.js api call todo.list --profile local --dry-run
39
+ ```
40
+
41
+ Use your own project data directory:
42
+
43
+ ```bash
44
+ evt validate --config-root /path/to/project/cli
45
+ evt api list --config-root /path/to/project/cli
46
+ evt flow run login --config-root /path/to/project/cli --profile dev
47
+ ```
48
+
49
+ Or set an environment variable:
50
+
51
+ ```bash
52
+ export EVT_CLI_ROOT=/path/to/project/cli
53
+ evt validate
54
+ ```
55
+
56
+ ## Data Layout
57
+
58
+ Recommended project data layout:
59
+
60
+ ```text
61
+ cli/
62
+ data/
63
+ apis/
64
+ *.yaml
65
+ *.example.yaml
66
+ flows/
67
+ *.yaml
68
+ *.example.yaml
69
+ profiles/
70
+ *.json
71
+ *.example.json
72
+ scanner.json
73
+ scanner.example.json
74
+ ```
75
+
76
+ evt-cli ships with `data/**/*.example.*` for validation and reference. Real projects can maintain `data/apis/*.yaml`, `data/flows/*.yaml`, `data/profiles/*.json`, and `data/scanner.json`.
77
+
78
+ For compatibility with existing projects, evt also reads `apis/`, `flows/`, `profiles/`, and `scanner.config.json` directly under `--config-root` when those paths exist.
79
+
80
+ ## Local Check And Package
81
+
82
+ ```bash
83
+ npm run ci:local
84
+ ```
85
+
86
+ This runs:
87
+
88
+ - `npm test`
89
+ - `npm run check`
90
+ - `node bin/evt.js validate`
91
+ - `npm run coverage:api`
92
+ - `node scripts/build-package.js`
93
+
94
+ Local package artifacts:
95
+
96
+ - `dist/evt-cli/`
97
+ - `dist/evt-cli-<version>-<platform>-<arch>.tar.gz`
98
+
99
+ The local package directory contains only:
100
+
101
+ - `evt`
102
+ - `data/`
103
+ - `README.md`
104
+ - `README.zh-CN.md`
105
+
106
+ It does not include `src/`, `scripts/`, `test/`, or `package.json`.
107
+
108
+ ## API Definitions
109
+
110
+ Inspect an endpoint:
111
+
112
+ ```bash
113
+ evt api show auth.login
114
+ ```
115
+
116
+ Example API YAML:
117
+
118
+ ```yaml
119
+ namespace: todo
120
+
121
+ endpoints:
122
+ list:
123
+ method: "GET"
124
+ path: "/api/todos"
125
+ auth: true
126
+ schema:
127
+ query:
128
+ page:
129
+ type: "integer"
130
+ default: 1
131
+ response:
132
+ envelope: "Resp"
133
+ data:
134
+ type: "object"
135
+ model: "TodoList"
136
+ ```
137
+
138
+ Each endpoint should include:
139
+
140
+ - `method`
141
+ - `path`
142
+ - `auth`
143
+ - `bodyType`
144
+ - `service`
145
+ - `schema`
146
+ - `response`
147
+ - `dangerous: true` when the endpoint is destructive or sensitive
148
+
149
+ ## Scan And Coverage
150
+
151
+ Scan source code for candidate endpoints:
152
+
153
+ ```bash
154
+ evt api scan --scan-config ./scanner.config.json
155
+ ```
156
+
157
+ Check endpoint coverage:
158
+
159
+ ```bash
160
+ npm run coverage:api -- --config-root /path/to/project/cli
161
+ ```
162
+
163
+ Generate missing YAML skeletons:
164
+
165
+ ```bash
166
+ npm run sync:api -- --config-root /path/to/project/cli
167
+ ```
168
+
169
+ The scanner supports `kotlin`, `swift`, `js`, and `dart`. It also supports external skill or AST scanner commands:
170
+
171
+ ```json
172
+ {
173
+ "root": ".",
174
+ "targets": [
175
+ {
176
+ "language": "kotlin",
177
+ "paths": ["shared/src/commonMain/kotlin"],
178
+ "include": ["**/*Service.kt"]
179
+ },
180
+ {
181
+ "language": "skill",
182
+ "name": "ast-scanner",
183
+ "command": "node",
184
+ "args": ["tools/scan-endpoints.js"]
185
+ }
186
+ ]
187
+ }
188
+ ```
189
+
190
+ An external scanner can output a JSON array or `{ "endpoints": [] }`. Each endpoint should include at least:
191
+
192
+ ```json
193
+ {
194
+ "id": "auth.login",
195
+ "namespace": "auth",
196
+ "functionName": "login",
197
+ "method": "POST",
198
+ "path": "/api/login"
199
+ }
200
+ ```
201
+
202
+ This JSON is used only for scanning, coverage, and sync. Runtime execution still reads YAML.
203
+
204
+ ## Common Commands
205
+
206
+ ```bash
207
+ evt profile list
208
+ evt api list
209
+ evt api call todo.list --dry-run
210
+ evt flow run login --profile local
211
+ evt cache show
212
+ evt cache clear
213
+ evt api test-all --profile local
214
+ ```
@@ -0,0 +1,214 @@
1
+ # evt-cli
2
+
3
+ 简体中文 | [English](./README.md)
4
+
5
+ evt-cli 是一个通用 HTTP CLI,用 YAML 定义接口、用 YAML 定义 flow、用 profile 管理 base URL/header/token/cache。它适合把客户端接口整理成可执行、可测试、可打包的命令行工具。安装后使用 `evt` 命令。
6
+
7
+ ## 核心原则
8
+
9
+ - 运行时端点只来自 `apis/*.yaml`。
10
+ - flow 只来自 `flows/*.yaml`。
11
+ - 环境、base URL、headers、测试 fixtures 只来自 `profiles/*.json`。
12
+ - 扫描器只用于覆盖率对比和生成缺失 YAML 骨架,不是运行时数据源。
13
+ - 默认数据目录是当前 CLI 包内目录;也可以通过 `--config-root` 或 `EVT_CLI_ROOT` 指向项目自己的数据目录。
14
+
15
+ ## 快速开始
16
+
17
+ 安装:
18
+
19
+ ```bash
20
+ npm install -g @icyouo/evt-cli
21
+ ```
22
+
23
+ 安装后直接运行自带 example 数据:
24
+
25
+ ```bash
26
+ evt profile list
27
+ evt api list
28
+ evt validate
29
+ evt api call todo.list --profile local --dry-run
30
+ ```
31
+
32
+ 仓库内开发时也可以直接运行:
33
+
34
+ ```bash
35
+ node bin/evt.js profile list
36
+ node bin/evt.js api list
37
+ node bin/evt.js validate
38
+ node bin/evt.js api call todo.list --profile local --dry-run
39
+ ```
40
+
41
+ 使用项目自己的数据目录:
42
+
43
+ ```bash
44
+ evt validate --config-root /path/to/project/cli
45
+ evt api list --config-root /path/to/project/cli
46
+ evt flow run login --config-root /path/to/project/cli --profile dev
47
+ ```
48
+
49
+ 也可以设置环境变量:
50
+
51
+ ```bash
52
+ export EVT_CLI_ROOT=/path/to/project/cli
53
+ evt validate
54
+ ```
55
+
56
+ ## 数据目录
57
+
58
+ 项目数据目录结构:
59
+
60
+ ```text
61
+ cli/
62
+ data/
63
+ apis/
64
+ *.yaml
65
+ *.example.yaml
66
+ flows/
67
+ *.yaml
68
+ *.example.yaml
69
+ profiles/
70
+ *.json
71
+ *.example.json
72
+ scanner.json
73
+ scanner.example.json
74
+ ```
75
+
76
+ evt-cli 自带 `data/**/*.example.*`,用于开箱验证和复制参考。真实项目可以维护 `data/apis/*.yaml`、`data/flows/*.yaml`、`data/profiles/*.json` 和 `data/scanner.json`。
77
+
78
+ 为了兼容已有项目,`--config-root` 下直接存在 `apis/`、`flows/`、`profiles/`、`scanner.config.json` 时也会被读取。
79
+
80
+ ## 本地校验和打包
81
+
82
+ ```bash
83
+ npm run ci:local
84
+ ```
85
+
86
+ 执行内容:
87
+
88
+ - `npm test`
89
+ - `npm run check`
90
+ - `node bin/evt.js validate`
91
+ - `npm run coverage:api`
92
+ - `node scripts/build-package.js`
93
+
94
+ 产物:
95
+
96
+ - `dist/evt-cli/`
97
+ - `dist/evt-cli-<version>-<platform>-<arch>.tar.gz`
98
+
99
+ 打包目录只包含:
100
+
101
+ - `evt`
102
+ - `data/`
103
+ - `README.md`
104
+ - `README.zh-CN.md`
105
+
106
+ 不会包含 `src/`、`scripts/`、`test/`、`package.json`。
107
+
108
+ ## 接口定义
109
+
110
+ 查看接口:
111
+
112
+ ```bash
113
+ evt api show auth.login
114
+ ```
115
+
116
+ 接口 YAML 示例:
117
+
118
+ ```yaml
119
+ namespace: todo
120
+
121
+ endpoints:
122
+ list:
123
+ method: "GET"
124
+ path: "/api/todos"
125
+ auth: true
126
+ schema:
127
+ query:
128
+ page:
129
+ type: "integer"
130
+ default: 1
131
+ response:
132
+ envelope: "Resp"
133
+ data:
134
+ type: "object"
135
+ model: "TodoList"
136
+ ```
137
+
138
+ 每个 endpoint 应包含:
139
+
140
+ - `method`
141
+ - `path`
142
+ - `auth`
143
+ - `bodyType`
144
+ - `service`
145
+ - `schema`
146
+ - `response`
147
+ - 必要时标记 `dangerous: true`
148
+
149
+ ## 扫描和覆盖率
150
+
151
+ 扫描源码候选 endpoint:
152
+
153
+ ```bash
154
+ evt api scan --scan-config ./scanner.config.json
155
+ ```
156
+
157
+ 覆盖率检查:
158
+
159
+ ```bash
160
+ npm run coverage:api -- --config-root /path/to/project/cli
161
+ ```
162
+
163
+ 同步缺失 YAML 骨架:
164
+
165
+ ```bash
166
+ npm run sync:api -- --config-root /path/to/project/cli
167
+ ```
168
+
169
+ 扫描器支持 `kotlin`、`swift`、`js`、`dart`,也支持外部 skill/AST 扫描命令:
170
+
171
+ ```json
172
+ {
173
+ "root": ".",
174
+ "targets": [
175
+ {
176
+ "language": "kotlin",
177
+ "paths": ["shared/src/commonMain/kotlin"],
178
+ "include": ["**/*Service.kt"]
179
+ },
180
+ {
181
+ "language": "skill",
182
+ "name": "ast-scanner",
183
+ "command": "node",
184
+ "args": ["tools/scan-endpoints.js"]
185
+ }
186
+ ]
187
+ }
188
+ ```
189
+
190
+ 外部 scanner 输出 JSON 数组,或 `{ "endpoints": [] }`。每个 endpoint 至少包含:
191
+
192
+ ```json
193
+ {
194
+ "id": "auth.login",
195
+ "namespace": "auth",
196
+ "functionName": "login",
197
+ "method": "POST",
198
+ "path": "/api/login"
199
+ }
200
+ ```
201
+
202
+ 这个 JSON 只参与扫描/覆盖率/sync,最终运行仍然读取 YAML。
203
+
204
+ ## 常用命令
205
+
206
+ ```bash
207
+ evt profile list
208
+ evt api list
209
+ evt api call todo.list --dry-run
210
+ evt flow run login --profile local
211
+ evt cache show
212
+ evt cache clear
213
+ evt api test-all --profile local
214
+ ```
package/bin/evt.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { run } = require("../src");
4
+
5
+ run(process.argv.slice(2)).catch((error) => {
6
+ console.error(error && error.message ? error.message : String(error));
7
+ process.exitCode = 1;
8
+ });
@@ -0,0 +1,44 @@
1
+ namespace: auth
2
+
3
+ endpoints:
4
+ login:
5
+ method: "POST"
6
+ path: "/api/login"
7
+ auth: false
8
+ bodyType: "json"
9
+ schema:
10
+ body:
11
+ email:
12
+ type: "string"
13
+ required: true
14
+ example: "user@example.com"
15
+ password:
16
+ type: "string"
17
+ required: true
18
+ example: "Password123."
19
+ response:
20
+ envelope: "Resp"
21
+ data:
22
+ type: "object"
23
+ model: "LoginData"
24
+ fields:
25
+ token: "string"
26
+ user:
27
+ type: "object"
28
+ model: "User"
29
+ fields:
30
+ id: "string"
31
+ email: "string"
32
+
33
+ logout:
34
+ method: "POST"
35
+ path: "/api/logout"
36
+ auth: true
37
+ dangerous: true
38
+ bodyType: "json"
39
+ schema: {}
40
+ response:
41
+ envelope: "Resp"
42
+ data:
43
+ type: "unit"
44
+ model: "Unit"
@@ -0,0 +1,52 @@
1
+ namespace: todo
2
+
3
+ endpoints:
4
+ list:
5
+ method: "GET"
6
+ path: "/api/todos"
7
+ auth: true
8
+ schema:
9
+ query:
10
+ page:
11
+ type: "integer"
12
+ default: 1
13
+ pageSize:
14
+ type: "integer"
15
+ default: 20
16
+ response:
17
+ envelope: "Resp"
18
+ data:
19
+ type: "object"
20
+ model: "TodoList"
21
+ fields:
22
+ total: "integer"
23
+ items:
24
+ type: "array"
25
+ items:
26
+ type: "object"
27
+ model: "Todo"
28
+
29
+ create:
30
+ method: "POST"
31
+ path: "/api/todos"
32
+ auth: true
33
+ dangerous: true
34
+ bodyType: "json"
35
+ schema:
36
+ body:
37
+ title:
38
+ type: "string"
39
+ required: true
40
+ example: "Example todo"
41
+ done:
42
+ type: "boolean"
43
+ default: false
44
+ response:
45
+ envelope: "Resp"
46
+ data:
47
+ type: "object"
48
+ model: "Todo"
49
+ fields:
50
+ id: "string"
51
+ title: "string"
52
+ done: "boolean"
@@ -0,0 +1,26 @@
1
+ name: login
2
+ description: Login and save session token.
3
+
4
+ inputs:
5
+ email:
6
+ prompt: Email
7
+ type: string
8
+ required: true
9
+ password:
10
+ prompt: Password
11
+ type: password
12
+ required: true
13
+
14
+ steps:
15
+ - id: login
16
+ call: auth.login
17
+ body:
18
+ email: "{{inputs.email}}"
19
+ password: "{{inputs.password}}"
20
+
21
+ save:
22
+ cache:
23
+ token: "{{steps.login.response.data.token}}"
24
+ user: "{{steps.login.response.data.user}}"
25
+ required:
26
+ - cache.token
@@ -0,0 +1,9 @@
1
+ name: smoke
2
+ description: Example smoke flow.
3
+
4
+ steps:
5
+ - id: todos
6
+ call: todo.list
7
+ query:
8
+ page: 1
9
+ pageSize: 20
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "local",
3
+ "env": "example",
4
+ "platform": "CLI",
5
+ "baseUrls": {
6
+ "default": "https://api.example.com"
7
+ },
8
+ "auth": {
9
+ "header": "Authorization",
10
+ "scheme": "bearer"
11
+ },
12
+ "headers": {
13
+ "Accept": "application/json",
14
+ "Content-Type": "application/json",
15
+ "X-Client": "evt-cli"
16
+ },
17
+ "inputs": {
18
+ "email": "user@example.com",
19
+ "password": "Password123."
20
+ },
21
+ "fixtures": {
22
+ "defaults": {
23
+ "page": 1,
24
+ "pageSize": 20,
25
+ "title": "Example todo",
26
+ "done": false
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "root": ".",
3
+ "targets": [
4
+ {
5
+ "language": "kotlin",
6
+ "paths": [
7
+ "shared/src/commonMain/kotlin"
8
+ ],
9
+ "include": [
10
+ "**/*Service.kt"
11
+ ]
12
+ },
13
+ {
14
+ "language": "swift",
15
+ "paths": [
16
+ "ios/App/Services"
17
+ ]
18
+ },
19
+ {
20
+ "language": "js",
21
+ "paths": [
22
+ "src/services"
23
+ ]
24
+ },
25
+ {
26
+ "language": "dart",
27
+ "paths": [
28
+ "lib/services"
29
+ ]
30
+ },
31
+ {
32
+ "language": "skill",
33
+ "name": "ast-scanner",
34
+ "command": "node",
35
+ "args": [
36
+ "tools/scan-endpoints.js"
37
+ ]
38
+ }
39
+ ]
40
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@icyouo/evt-cli",
3
+ "version": "0.1.0",
4
+ "description": "Run YAML-defined HTTP APIs and interactive workflows from your terminal.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Icyoung/everything-cli.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/Icyoung/everything-cli/issues"
12
+ },
13
+ "homepage": "https://github.com/Icyoung/everything-cli#readme",
14
+ "bin": {
15
+ "evt": "./bin/evt.js"
16
+ },
17
+ "files": [
18
+ "bin/",
19
+ "src/",
20
+ "data/",
21
+ "README.md",
22
+ "README.zh-CN.md"
23
+ ],
24
+ "scripts": {
25
+ "ci:local": "node scripts/local-ci.js",
26
+ "test": "node --test",
27
+ "check": "node --check bin/evt.js && node --check src/index.js && node --check src/api/liveTester.js && node --check scripts/sync-api-coverage.js && node --check scripts/check-api-coverage.js && node --check scripts/local-ci.js && node --check scripts/build-package.js",
28
+ "package:local": "node scripts/build-package.js",
29
+ "sync:api": "node scripts/sync-api-coverage.js",
30
+ "coverage:api": "node scripts/check-api-coverage.js"
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ }
35
+ }