esa-cli 0.0.2-beta.12 → 0.0.2-beta.13
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/dist/commands/commit/index.js +20 -119
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/routineUtils.js +276 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/helper.js +31 -36
- package/dist/commands/deploy/index.js +78 -165
- package/dist/commands/deployments/delete.js +31 -6
- package/dist/commands/deployments/index.js +3 -3
- package/dist/commands/deployments/list.js +18 -27
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- package/dist/commands/dev/ew2/devPack.js +17 -8
- package/dist/commands/dev/ew2/mock/kv.js +2 -2
- package/dist/commands/dev/ew2/server.js +13 -10
- package/dist/commands/dev/index.js +12 -12
- package/dist/commands/dev/mockWorker/devPack.js +16 -7
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +3 -3
- package/dist/commands/domain/delete.js +3 -3
- package/dist/commands/domain/index.js +3 -3
- package/dist/commands/domain/list.js +7 -7
- package/dist/commands/init/helper.js +59 -9
- package/dist/commands/init/index.js +416 -76
- package/dist/commands/init/template.jsonc +34 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +9 -5
- package/dist/commands/logout.js +6 -6
- package/dist/commands/route/add.js +134 -43
- package/dist/commands/route/delete.js +6 -6
- package/dist/commands/route/index.js +3 -3
- package/dist/commands/route/list.js +4 -4
- package/dist/commands/routine/delete.js +2 -2
- package/dist/commands/routine/index.js +3 -3
- package/dist/commands/routine/list.js +5 -16
- package/dist/commands/site/index.js +2 -2
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +55 -19
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +12 -16
- package/dist/docs/Commands_zh_CN.md +12 -16
- package/dist/docs/eslint-config-en.md +1 -0
- package/dist/docs/eslint-config.md +73 -0
- package/dist/docs/init-command-quick-test.md +208 -0
- package/dist/docs/init-command-test-guide.md +598 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +161 -9
- package/dist/index.js +11 -11
- package/dist/libs/apiService.js +177 -14
- package/dist/libs/git/index.js +8 -4
- package/dist/libs/logger.js +63 -7
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +1 -1
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +3 -17
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +17 -16
- package/dist/utils/checkVersion.js +1 -1
- package/dist/utils/compress.js +80 -0
- package/dist/utils/download.js +5 -5
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +71 -22
- package/dist/utils/installDeno.js +3 -3
- package/dist/utils/installEw2.js +7 -7
- package/dist/utils/openInBrowser.js +1 -1
- package/package.json +9 -3
- package/dist/docs/Dev_en.md +0 -0
- package/dist/docs/Dev_zh_CN.md +0 -0
package/dist/docs/Commands_en.md
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
# Commands
|
|
2
2
|
|
|
3
|
-
- init - Initialize a new project from a template
|
|
4
|
-
- dev - Start a local development server for testing
|
|
5
|
-
- commit - Commit code and create a version
|
|
6
|
-
- deploy - Build and deploy project to the edge routine
|
|
7
|
-
- deployments - Manage deployments
|
|
8
|
-
- routine - Manage edge routine functions
|
|
9
|
-
- site - Manage site settings
|
|
10
|
-
- domain - Configure edge function trigger domain
|
|
11
|
-
- route - Configure edge function trigger routes
|
|
12
|
-
- login - Authenticate via AK/SK to your account
|
|
13
|
-
- logout - Log out current user
|
|
14
|
-
- config - Modify local/global settings
|
|
15
|
-
- lang - Switch CLI interface language
|
|
16
|
-
|
|
17
3
|
### init
|
|
18
4
|
|
|
19
|
-
Initialize a
|
|
5
|
+
Initialize a project using a framework or a template.
|
|
20
6
|
|
|
21
7
|
```bash
|
|
22
8
|
$ esa init [OPTIONS]
|
|
23
9
|
```
|
|
24
10
|
|
|
11
|
+
- -f, --framework `string` `optional`
|
|
12
|
+
- Choose a frontend framework: `react` | `vue` | `next`.
|
|
13
|
+
|
|
14
|
+
- -t, --template `string` `optional`
|
|
15
|
+
- Use an ESA template by name.
|
|
16
|
+
|
|
25
17
|
- -c, --config `boolean` `optional`
|
|
26
|
-
- Generate
|
|
18
|
+
- Generate an `esa.toml` config file in your project.
|
|
19
|
+
|
|
20
|
+
Notes:
|
|
21
|
+
- If neither `--framework` nor `--template` is provided and `--yes` is not used, you will be prompted to choose between “Framework” or “Template”.
|
|
22
|
+
- When a framework is chosen, the official scaffolding tool will be used to create the project, and `esa.toml` will be auto-generated in the project root. The entry file is auto-detected among: `src/index.js`, `src/index.jsx`, `src/index.tsx`, `src/main.js`, `src/main.ts`, `src/main.tsx`, `pages/index.js`, `pages/index.tsx`, `app/page.js`, `app/page.tsx`. The static assets directory is set to the framework’s common build output if available: CRA `build/`, Vite usually `dist/`, Next static export `out/`.
|
|
27
23
|
|
|
28
24
|
### routine [script]
|
|
29
25
|
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
# Commands
|
|
2
2
|
|
|
3
|
-
- init - 使用模板初始化新项目
|
|
4
|
-
- dev - 启动本地开发服务器进行调试
|
|
5
|
-
- commit - 提交代码并创建一个新版本
|
|
6
|
-
- deploy - 部署项目到边缘网络
|
|
7
|
-
- deployments - 管理历史部署版本
|
|
8
|
-
- routine - 管理边缘函数
|
|
9
|
-
- site - 管理站点
|
|
10
|
-
- domain - 管理绑定到边缘函数的域名
|
|
11
|
-
- route - 管理绑定到边缘函数的路由
|
|
12
|
-
- login - 通过AK/SK登录到您的账户
|
|
13
|
-
- logout - 注销当前用户
|
|
14
|
-
- config - 修改本地/全局配置
|
|
15
|
-
- lang - 切换CLI界面语言
|
|
16
|
-
|
|
17
3
|
### init
|
|
18
4
|
|
|
19
|
-
|
|
5
|
+
选择框架或模版初始化项目。
|
|
20
6
|
|
|
21
7
|
```bash
|
|
22
8
|
$ esa init [OPTIONS]
|
|
23
9
|
```
|
|
24
10
|
|
|
11
|
+
- -f, --framework `string` `optional`
|
|
12
|
+
- 选择前端框架初始化项目,支持:`react` | `vue` | `next`。
|
|
13
|
+
|
|
14
|
+
- -t, --template `string` `optional`
|
|
15
|
+
- 指定 ESA 模版名称初始化项目。
|
|
16
|
+
|
|
25
17
|
- -c, --config `boolean` `optional`
|
|
26
|
-
- 在您的项目中生成一个esa.toml配置文件。
|
|
18
|
+
- 在您的项目中生成一个 `esa.toml` 配置文件。
|
|
19
|
+
|
|
20
|
+
说明:
|
|
21
|
+
- 未指定 `--framework` 与 `--template` 且未使用 `--yes` 时,会先询问选择“框架初始化”或“模版初始化”。
|
|
22
|
+
- 选择框架后将调用对应官方脚手架创建项目,并在新项目根目录自动生成 `esa.toml`。入口文件会自动探测,候选包括:`src/index.js`、`src/index.jsx`、`src/index.tsx`、`src/main.js`、`src/main.ts`、`src/main.tsx`、`pages/index.js`、`pages/index.tsx`、`app/page.js`、`app/page.tsx`。静态资源目录会根据框架常规构建输出自动设置,例如 CRA 为 `build/`、Vite 通常为 `dist/`(若存在),Next 静态导出使用 `out/`(若存在)。
|
|
27
23
|
|
|
28
24
|
### routine [script]
|
|
29
25
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ESLint 配置说明
|
|
2
|
+
|
|
3
|
+
本项目已配置ESLint来检查代码质量,包括以下功能:
|
|
4
|
+
|
|
5
|
+
## 已配置的检查规则
|
|
6
|
+
|
|
7
|
+
### 1. Import 排序检查
|
|
8
|
+
|
|
9
|
+
- **规则**: `import/order`
|
|
10
|
+
- **功能**: 自动排序import语句,按照以下顺序:
|
|
11
|
+
1. Node.js 内置模块 (如 `fs`, `path`)
|
|
12
|
+
2. 第三方模块 (如 `react`, `lodash`)
|
|
13
|
+
3. 内部模块 (项目内部文件)
|
|
14
|
+
4. 父级模块 (`../`)
|
|
15
|
+
5. 同级模块 (`./`)
|
|
16
|
+
6. 当前目录的 index 文件
|
|
17
|
+
- **格式**: 每组之间用空行分隔,按字母顺序排列
|
|
18
|
+
|
|
19
|
+
### 2. 引号检查
|
|
20
|
+
|
|
21
|
+
- **规则**: `quotes`, `@typescript-eslint/quotes`
|
|
22
|
+
- **功能**: 强制使用单引号
|
|
23
|
+
- **例外**: 允许在需要转义的情况下使用双引号,支持模板字符串
|
|
24
|
+
|
|
25
|
+
### 3. 多余变量检查
|
|
26
|
+
|
|
27
|
+
- **规则**: `@typescript-eslint/no-unused-vars`
|
|
28
|
+
- **功能**: 检查未使用的变量、参数和导入
|
|
29
|
+
- **例外**: 以 `_` 开头的变量会被忽略(如 `_unusedVariable`)
|
|
30
|
+
|
|
31
|
+
### 4. 其他检查
|
|
32
|
+
|
|
33
|
+
- **重复导入检查**: `import/no-duplicates`
|
|
34
|
+
- **未使用表达式检查**: `no-unused-expressions`
|
|
35
|
+
- **TypeScript类型检查**: 警告使用 `any` 类型
|
|
36
|
+
|
|
37
|
+
## 使用方法
|
|
38
|
+
|
|
39
|
+
### 检查代码
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm run eslint
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 自动修复
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run eslint -- --fix
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 检查特定文件
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx eslint src/commands/example.ts
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 配置说明
|
|
58
|
+
|
|
59
|
+
配置文件位于 `.eslintrc.cjs`,主要包含:
|
|
60
|
+
|
|
61
|
+
- **解析器**: `@typescript-eslint/parser` 用于解析TypeScript代码
|
|
62
|
+
- **插件**:
|
|
63
|
+
- `react` 和 `react-hooks` 用于React相关检查
|
|
64
|
+
- `import` 用于import相关检查
|
|
65
|
+
- `@typescript-eslint` 用于TypeScript特定检查
|
|
66
|
+
- **规则**: 详细的代码质量规则配置
|
|
67
|
+
- **设置**: TypeScript import解析器配置
|
|
68
|
+
|
|
69
|
+
## 注意事项
|
|
70
|
+
|
|
71
|
+
1. 如果遇到TypeScript版本警告,这是正常的,不影响功能
|
|
72
|
+
2. 未使用的变量请以 `_` 开头命名,这样ESLint会忽略它们
|
|
73
|
+
3. 自动修复功能可以解决大部分格式问题,但逻辑问题需要手动修复
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ESA CLI Init 命令快速测试指南
|
|
2
|
+
|
|
3
|
+
## 快速开始
|
|
4
|
+
|
|
5
|
+
### 1. 环境准备
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 确保 ESA CLI 已安装
|
|
9
|
+
esa --version
|
|
10
|
+
|
|
11
|
+
# 创建测试目录
|
|
12
|
+
mkdir init-test && cd init-test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 2. 基础功能测试(5分钟)
|
|
16
|
+
|
|
17
|
+
#### 测试 1: 帮助信息
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
esa init --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**预期结果**: 显示 init 命令的帮助信息
|
|
24
|
+
|
|
25
|
+
#### 测试 2: 项目名称验证
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
esa init A
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**预期结果**: 显示错误信息"项目名称必须至少2个字符"
|
|
32
|
+
|
|
33
|
+
#### 测试 3: 指定项目名称
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
esa init test-project --skip
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**预期结果**: 创建 test-project 目录
|
|
40
|
+
|
|
41
|
+
#### 测试 4: 自动确认模式
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
esa init --yes --skip
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**预期结果**: 自动创建项目(名称格式:edge-routine-<timestamp>)
|
|
48
|
+
|
|
49
|
+
### 3. 交互式测试(10分钟)
|
|
50
|
+
|
|
51
|
+
#### 完整流程测试
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
esa init
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**交互步骤**:
|
|
58
|
+
|
|
59
|
+
1. 输入项目名称(如:my-test-app)
|
|
60
|
+
2. 选择模板
|
|
61
|
+
3. 选择是否初始化 Git(Yes/No)
|
|
62
|
+
4. 选择是否部署(Yes/No)
|
|
63
|
+
|
|
64
|
+
**验证点**:
|
|
65
|
+
|
|
66
|
+
- [ ] 项目目录创建成功
|
|
67
|
+
- [ ] 模板文件复制完成
|
|
68
|
+
- [ ] 依赖安装成功(如果有 package.json)
|
|
69
|
+
- [ ] Git 初始化(如果选择)
|
|
70
|
+
- [ ] 部署成功(如果选择且已登录)
|
|
71
|
+
|
|
72
|
+
### 4. 错误处理测试(5分钟)
|
|
73
|
+
|
|
74
|
+
#### 测试目录冲突
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
mkdir conflict-test
|
|
78
|
+
esa init conflict-test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**预期结果**: 显示"项目已存在"错误
|
|
82
|
+
|
|
83
|
+
#### 测试无效模板
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
esa init test --template invalid-template
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**预期结果**: 显示"模板未找到"错误
|
|
90
|
+
|
|
91
|
+
### 5. 多语言测试(3分钟)
|
|
92
|
+
|
|
93
|
+
#### 中文界面
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
esa lang zh_CN
|
|
97
|
+
esa init --help
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**预期结果**: 显示中文帮助信息
|
|
101
|
+
|
|
102
|
+
#### 英文界面
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
esa lang en
|
|
106
|
+
esa init --help
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**预期结果**: 显示英文帮助信息
|
|
110
|
+
|
|
111
|
+
## 自动化测试
|
|
112
|
+
|
|
113
|
+
### 运行完整测试脚本
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# 给脚本执行权限
|
|
117
|
+
chmod +x scripts/test-init-command.sh
|
|
118
|
+
|
|
119
|
+
# 运行测试
|
|
120
|
+
./scripts/test-init-command.sh
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 测试结果示例
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
==========================================
|
|
127
|
+
ESA CLI Init 命令测试开始
|
|
128
|
+
==========================================
|
|
129
|
+
[INFO] 检查 ESA CLI 是否可用...
|
|
130
|
+
[PASS] ESA CLI 可用
|
|
131
|
+
[INFO] 测试帮助信息...
|
|
132
|
+
[PASS] 帮助信息显示正确
|
|
133
|
+
[INFO] 测试项目名称验证...
|
|
134
|
+
[PASS] 项目名称验证 - 大写字母检测
|
|
135
|
+
[PASS] 项目名称验证 - 单个字符检测
|
|
136
|
+
[PASS] 项目名称验证 - 下划线检测
|
|
137
|
+
[INFO] 测试指定项目名称...
|
|
138
|
+
[PASS] 指定项目名称创建成功
|
|
139
|
+
[INFO] 测试 --yes 选项...
|
|
140
|
+
[PASS] --yes 选项自动生成项目名称
|
|
141
|
+
[INFO] 测试 --skip 选项...
|
|
142
|
+
[PASS] --skip 选项跳过交互
|
|
143
|
+
[INFO] 测试项目目录冲突...
|
|
144
|
+
[PASS] 项目目录冲突检测
|
|
145
|
+
[INFO] 测试模板不存在...
|
|
146
|
+
[PASS] 模板不存在检测
|
|
147
|
+
[INFO] 测试 --config 选项...
|
|
148
|
+
[PASS] --config 选项生成配置文件
|
|
149
|
+
[INFO] 测试多语言支持...
|
|
150
|
+
[PASS] 中文界面支持
|
|
151
|
+
[PASS] 英文界面支持
|
|
152
|
+
==========================================
|
|
153
|
+
测试完成
|
|
154
|
+
==========================================
|
|
155
|
+
通过: 12
|
|
156
|
+
失败: 0
|
|
157
|
+
总计: 12
|
|
158
|
+
所有测试通过!
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 常见问题
|
|
162
|
+
|
|
163
|
+
### Q: 测试时提示"ESA CLI 未安装"
|
|
164
|
+
|
|
165
|
+
**A**: 确保已正确安装 ESA CLI 并在 PATH 中
|
|
166
|
+
|
|
167
|
+
### Q: 测试失败,提示权限错误
|
|
168
|
+
|
|
169
|
+
**A**: 确保有足够的权限创建目录和文件
|
|
170
|
+
|
|
171
|
+
### Q: 网络相关测试失败
|
|
172
|
+
|
|
173
|
+
**A**: 检查网络连接,某些测试需要下载依赖
|
|
174
|
+
|
|
175
|
+
### Q: 模板相关测试失败
|
|
176
|
+
|
|
177
|
+
**A**: 确保模板包已正确安装
|
|
178
|
+
|
|
179
|
+
## 测试报告模板
|
|
180
|
+
|
|
181
|
+
### 快速测试检查清单
|
|
182
|
+
|
|
183
|
+
| 测试项目 | 状态 | 备注 |
|
|
184
|
+
| ------------ | ------------- | ---- |
|
|
185
|
+
| 帮助信息显示 | ☐ 通过 ☐ 失败 | |
|
|
186
|
+
| 项目名称验证 | ☐ 通过 ☐ 失败 | |
|
|
187
|
+
| 指定项目名称 | ☐ 通过 ☐ 失败 | |
|
|
188
|
+
| 自动确认模式 | ☐ 通过 ☐ 失败 | |
|
|
189
|
+
| 交互式流程 | ☐ 通过 ☐ 失败 | |
|
|
190
|
+
| 错误处理 | ☐ 通过 ☐ 失败 | |
|
|
191
|
+
| 多语言支持 | ☐ 通过 ☐ 失败 | |
|
|
192
|
+
|
|
193
|
+
### 问题记录
|
|
194
|
+
|
|
195
|
+
**问题描述**:
|
|
196
|
+
**复现步骤**:
|
|
197
|
+
**预期结果**:
|
|
198
|
+
**实际结果**:
|
|
199
|
+
**环境信息**:
|
|
200
|
+
**解决方案**:
|
|
201
|
+
|
|
202
|
+
## 联系支持
|
|
203
|
+
|
|
204
|
+
如果遇到问题,请:
|
|
205
|
+
|
|
206
|
+
1. 查看完整测试文档:`docs/init-command-test-guide.md`
|
|
207
|
+
2. 检查项目 Issues
|
|
208
|
+
3. 联系开发团队
|