@deveco-test/hmos-deveco-cli 0.2.1 → 0.3.0-TD.1.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 +68 -1
- package/SKILL.md +51 -1
- package/THIRD-PARTY-LICENSES +536 -4
- package/dist/cli.js +161 -100
- package/dist/internal/doc-init-background.js +8 -8
- package/index.zip +0 -0
- package/package.json +9 -2
- package/scripts/install-jieba-wasm.mjs +47 -0
- package/scripts/lib/jieba-wasm-vendor.mjs +102 -0
- package/scripts/postinstall.mjs +9 -0
- package/src/resources/aclPermission/aclPermissionsInfo.json +311 -0
package/README.md
CHANGED
|
@@ -91,12 +91,14 @@ devecocli init --path .\work\ARKTS\NewData
|
|
|
91
91
|
| ------------------------- | ----------------------------------------- |
|
|
92
92
|
| `devecocli create` | 创建新的 HarmonyOS 项目 |
|
|
93
93
|
| `devecocli build` | 构建项目并产出 `.hap` / `.hsp` / `.har` / `.app` |
|
|
94
|
+
| `devecocli check lint` | 检查代码规范并输出实践建议与报告 |
|
|
94
95
|
| `devecocli run` | 安装并运行应用 |
|
|
95
96
|
| `devecocli device list` | 查看当前连接设备 |
|
|
96
97
|
| `devecocli log` | 查看 `hilog` 或崩溃日志 |
|
|
97
98
|
| `devecocli docs search` | 搜索本地 HarmonyOS 文档 |
|
|
98
99
|
| `devecocli init` | 安装内置技能或配置 `MCP` |
|
|
99
100
|
| `devecocli skills` | 管理 HarmonyOS 技能市场中的技能 |
|
|
101
|
+
| `devecocli signature generate` | 自动生成调试签名材料并配置到项目 |
|
|
100
102
|
|
|
101
103
|
## 命令集
|
|
102
104
|
|
|
@@ -131,6 +133,8 @@ Commands:
|
|
|
131
133
|
init [options] Install the deveco-cli skill or configure the deveco-mcp server into AI agents
|
|
132
134
|
serve Host bundled auxiliary protocol servers
|
|
133
135
|
docs [options] Search and read HarmonyOS documentation from local docs directory
|
|
136
|
+
check Run DevEco project checks
|
|
137
|
+
signature Generate application signature
|
|
134
138
|
help [command] display help for command
|
|
135
139
|
```
|
|
136
140
|
|
|
@@ -312,6 +316,29 @@ devecocli build --product oversea --modules entry --build-mode release
|
|
|
312
316
|
devecocli build clean
|
|
313
317
|
```
|
|
314
318
|
|
|
319
|
+
### `check lint`
|
|
320
|
+
|
|
321
|
+
检查代码规范并输出实践建议与报告。
|
|
322
|
+
|
|
323
|
+
**命令格式:**
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
devecocli check lint [path]
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**参数:**
|
|
330
|
+
|
|
331
|
+
| 参数名 | 说明 |
|
|
332
|
+
| ---------------------------- | --------------------------------------------------------------------- |
|
|
333
|
+
| `[path]` | 可选,待检查的文件或目录;默认使用 `build-profile.json5` 所在的项目根目录,否则使用当前目录 |
|
|
334
|
+
| `--config-path <path>` | Code Linter 配置文件路径,仅支持 `.json` 或 `.json5`;默认使用待检查项目根目录下的 `code-linter.json5`,显式指定时必须与待检查路径属于同一项目 |
|
|
335
|
+
| `--fix` | 自动修复可修复的问题 |
|
|
336
|
+
| `--incremental` | 仅检查 Git 未提交文件 |
|
|
337
|
+
| `--product <name>` | `build-profile.json5` 中定义的 product,默认为 `default` |
|
|
338
|
+
| `--format <default\|json>` | 完整报告格式;`default` 输出 Markdown,`json` 输出 JSON |
|
|
339
|
+
| `--output-path <path>` | 完整报告文件或目录;目录形式会自动生成带时间戳的报告文件 |
|
|
340
|
+
| `--limit <number>` | 未指定 `--output-path` 时,限制终端显示的问题数量 |
|
|
341
|
+
|
|
315
342
|
### `device list`
|
|
316
343
|
|
|
317
344
|
查询所有已连接的设备
|
|
@@ -353,7 +380,7 @@ devecocli device view -t "My Device Name"
|
|
|
353
380
|
**命令格式:**
|
|
354
381
|
|
|
355
382
|
```bash
|
|
356
|
-
devecocli run --module <module> --device <device> --product <product> --build-mode <mode> --ability <ability> --uninstall --skip-build
|
|
383
|
+
devecocli run --module <module> --device <device> --product <product> --build-mode <mode> --ability <ability> --uninstall --skip-build --apply <txtFile>
|
|
357
384
|
```
|
|
358
385
|
|
|
359
386
|
**参数:**
|
|
@@ -367,6 +394,7 @@ devecocli run --module <module> --device <device> --product <product> --build-mo
|
|
|
367
394
|
| --ability | 可选,待启动的 `Ability` ,默认:模块 `module.json5` 中的`mainElement` |
|
|
368
395
|
| --uninstall | 可选,安装前先卸载已有应用 |
|
|
369
396
|
| --skip-build | 可选,跳过构建操作,直接安装应用 。\*\*说明:\*\*使用该参数时,需确保对应模块已有构建产物 |
|
|
397
|
+
| --apply \<fileName\> | 可选,**快速增量部署**:仅重编改动文件 → signed hqf → `bm quickfix -a -f -o` 安装 → 重启,比全量 `run` 快。`<fileName>` 是工程 `.hvigor/` 目录下的**纯文件名**(调用方把清单写到此目录,文件名做安全校验防穿越);内容为本轮改动的源文件路径清单(每行一个相对工程根路径;`#`/空行忽略;`.ets`/`.ts`/`.cpp`/资源文件;changeFileList 增量累积,只需列本轮改的,历史文件自动保留)。模块从清单路径自动识别(无需 `--module`)。**前提**:先 `devecocli run` 全量构建部署一次(生成 buildConfig.json 缓存);**没生效排查**:检查 `<module>/build/config/buildConfig.json` 有无内容(空/无 = 没跑过 `devecocli run`);**失败兜底**:直接 `devecocli run` |
|
|
370
398
|
|
|
371
399
|
**示例:**
|
|
372
400
|
|
|
@@ -377,6 +405,7 @@ devecocli run --module library@phone --device 127.0.0.1:5555
|
|
|
377
405
|
devecocli run --product oversea --module entry --ability EntryAbility
|
|
378
406
|
devecocli run --build-mode release
|
|
379
407
|
devecocli run --uninstall
|
|
408
|
+
devecocli run --apply changes.txt
|
|
380
409
|
```
|
|
381
410
|
|
|
382
411
|
### `log`
|
|
@@ -539,6 +568,44 @@ devecocli skills remove --skill skillname --agent agentname # skillname需替
|
|
|
539
568
|
}
|
|
540
569
|
```
|
|
541
570
|
|
|
571
|
+
### `signature generate`
|
|
572
|
+
|
|
573
|
+
自动生成调试签名材料(包括p12密钥库、csr证书请求文件、p7b配置文件、cer证书文件),并将签名配置写入项目的 `build-profile.json5` 中。
|
|
574
|
+
|
|
575
|
+
**命令格式:**
|
|
576
|
+
|
|
577
|
+
```bash
|
|
578
|
+
devecocli signature generate --product <product> --team-id <team-id> --force --help
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
**参数:**
|
|
582
|
+
|
|
583
|
+
| 参数名 | 说明 |
|
|
584
|
+
|-----------------------|-----------------------------------------|
|
|
585
|
+
| --product \<product\> | 可选,指定product生成签名,默认为 `default` |
|
|
586
|
+
| --team-id \<team-id\> | 可选,指定生效的team-id,默认使用自身作为团队信息 |
|
|
587
|
+
| --force | 可选,强制覆盖已存在的证书文件 |
|
|
588
|
+
| --help,--h | 可选,查看帮助信息 |
|
|
589
|
+
|
|
590
|
+
**示例:**
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
# 自动生成签名并写入工程配置
|
|
594
|
+
devecocli signature generate
|
|
595
|
+
|
|
596
|
+
# 指定product
|
|
597
|
+
devecocli signature generate --product default
|
|
598
|
+
|
|
599
|
+
# 指定team-id
|
|
600
|
+
devecocli signature generate --team-id 1222
|
|
601
|
+
|
|
602
|
+
# 强制覆盖已存在的证书文件
|
|
603
|
+
devecocli signature generate --force
|
|
604
|
+
|
|
605
|
+
# 查询帮助信息
|
|
606
|
+
devecocli signature generate --help
|
|
607
|
+
```
|
|
608
|
+
|
|
542
609
|
## 常见问题
|
|
543
610
|
|
|
544
611
|
### 如何本地推包运行
|
package/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
- ❌ `hvigorw` directly → ✅ `devecocli build`
|
|
14
14
|
- ❌ `hdc` directly (when a `devecocli` wrapper exists) → ✅ `devecocli device` / `devecocli log` / `devecocli run`
|
|
15
15
|
|
|
16
|
-
Available commands: `build`, `run`, `update`, `device`, `skills`, `log`, `create`, `init`, `serve`, `docs`.
|
|
16
|
+
Available commands: `build`, `check`, `run`, `update`, `device`, `skills`, `log`, `create`, `init`, `serve`, `docs`, `auth`.
|
|
17
17
|
|
|
18
18
|
**Sandbox Rule**: Commands tagged `[Outside sandbox]` must be run outside the sandbox.
|
|
19
19
|
|
|
@@ -36,6 +36,11 @@ Compile and package project/modules. (Defaults: `--product default`, `--build-mo
|
|
|
36
36
|
| Whole product bundle (.app) | `devecocli build --product <name>` |
|
|
37
37
|
| Clean build outputs | `devecocli build clean` |
|
|
38
38
|
|
|
39
|
+
### `devecocli check lint`
|
|
40
|
+
Run DevEco Code Linter checks for TS/ArkTS code.
|
|
41
|
+
- `[path]`: File or directory to lint. Defaults to the project root from `build-profile.json5`, otherwise the current directory.
|
|
42
|
+
- Options: `--config-path <file>`, `--fix`, `--incremental`, `--product <name>`, `--format <default|json>`, `--output-path <path>`, `--limit <number>`.
|
|
43
|
+
|
|
39
44
|
### `devecocli docs`
|
|
40
45
|
Search/read local HarmonyOS docs.
|
|
41
46
|
- `search <keywords...>`: Match any keyword. Opts: `--catalog <name>`, `--format <default|json>`, `--limit <n>`.
|
|
@@ -54,6 +59,11 @@ Build, install, and launch.
|
|
|
54
59
|
- `--ability <ability>`: Default from `module.json5`.
|
|
55
60
|
- `--uninstall`: Uninstall existing app first (Fixes signing key issues).
|
|
56
61
|
- `--skip-build`: Deploy existing artifacts.
|
|
62
|
+
- `--apply <fileName>`: **Fast incremental deploy** — rebuilds only changed files into a signed hqf, installs via `bm quickfix -a -f -o`, then restarts the app. Much faster than a full `devecocli run` for iterating on code changes. Modules are auto-detected from the file paths in `<fileName>` (no `--module` needed).
|
|
63
|
+
- `<fileName>`: a plain file name (no path separators) under the project's `.hvigor/` directory; the caller writes the changed-file list there. File name is sanitized to prevent path traversal. Content: list of **source file paths changed this round** (one per line, relative to project root or absolute; `#` comments and blank lines ignored; typically `.ets`/`.ts`/`.cpp`/resource files). The changeFileList is **incrementally merged** — only list files changed since the last apply; previously listed files are retained automatically.
|
|
64
|
+
- **Prereq**: run `devecocli run` once first (full build + deploy + generates the `buildConfig.json` cache that `--apply` reuses).
|
|
65
|
+
- **If changes don't take effect**: check `<module>/build/config/buildConfig.json` has content — empty/missing means `devecocli run` wasn't run; on any apply failure, fall back to a full `devecocli run`.
|
|
66
|
+
*Ex*: `devecocli run` → edit code → write `.hvigor/changes.txt` → `devecocli run --apply changes.txt`
|
|
57
67
|
- **Previewer mode** (auto-detected from `--device`): When `--device` value matches previewer product names (e.g. `"Pura 90 Pro"`, `"MatePad 11.5'S"`, `phone`, `pad`), the CLI launches the DevEco Studio **previewer** instead of installing/running the app. Comma-separated names → multi-previewer (count = list length). When `--device` is a serial/IP:port/unmatched value, normal run mode is used. Omitting `--device` → normal run. Ensures the DevEco Studio desktop process is running first (throws immediately if not — does NOT auto-start Studio on any platform), then `hdc shell aa start -a DevEcoViewerAbility -b com.huawei.devecostudio -m DevEcoViewer --pi instanceId <pid> --ps paramJson <JSON with double-quotes escaped>` with project info (`bundleName` / `abilityName` / `moduleName` / `productName` / `productType` / `subProductType` / `instanceId` / `launchDeviceIndex` / `launchFlag` / `isCustom` / `nativeDebuggable` / `appDebuggable`). `instanceId` = CLI process.pid; `launchDeviceIndex` = -1 for single previewer, 0-based for multi. Skips build/install (except multi-previewer needs build+install with multiAppMode). **Smart matching**: case/whitespace/punctuation insensitive; accepts aliases (`phone`, `tablet`/`pad`, `fold`/`foldable`, `widefold`/`wide`, `triplefold`/`triple`) and short forms; substring match and Levenshtein ≤ 2 fallback. Ambiguous matches report candidates. Supported products: `Pura 90 Pro`, `MatePad 11.5'S`, `Mate X7`, `Pura X`, `Mate XT`.
|
|
58
68
|
- **Windows/macOS**: uses DevEco Studio's bundled hdc, auto-detects Studio install path via ToolProvider. hdc target device is auto-selected via `selectDevice` (previewer mode does not use `--device` as hdc target).
|
|
59
69
|
- **HarmonyOS native (2in1 PC)**: hdc does NOT auto-discover the local device — self-connect required. In previewer mode, `--device` is the product name (not hdc target). The CLI checks `hdc list targets` for a `127.0.0.1:<port>` entry: if found, uses it directly; if not found, warns `hdc 未自联` and fallbacks to `connectLocalDevice` (resolution: `DEVECO_HDC_PORT` env var → existing `hdc list targets` → interactive prompt → error). DevEco Studio is a system app there; local `pgrep` cannot see Studio's process due to UID isolation, so the CLI detects Studio via `hdc shell ps -ef | grep com.huawei.devecostudio` (hdcd runs as root) — requires hdc self-connect first. The CLI does NOT auto-start Studio on any platform.
|
|
@@ -68,6 +78,31 @@ Fetch hilog or crash logs. Req `--device <name|serial>` on multi-device hosts.
|
|
|
68
78
|
- `--tail <num>` / `--follow`: Keep last N lines / stream real-time (no `--to`).
|
|
69
79
|
*Ex*: `devecocli log --crash --bundle-name com.example.app`, `devecocli log --level E --from 5m --tail 200`
|
|
70
80
|
|
|
81
|
+
### `devecocli ui`
|
|
82
|
+
Inspect UI on a connected device. All subcommands accept `--device <name|serial>` (Req on multi-device hosts).
|
|
83
|
+
|
|
84
|
+
| Subcommand | Description | Key Options |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `layout` | Dump ArkUI accessibility layout tree — **visible area only** (on-screen nodes) | `--id <id>`, `--window <windowId>`, `--all-windows`, `--depth <n>` (0=unlimited, 1=root only, 2=root+children), `--format default\|json`, `--mode full\|simplified` |
|
|
87
|
+
| `window list` | List active windows | `--format default\|json`, `--all` (include system windows) |
|
|
88
|
+
| `screenshot` | Capture a screenshot of the device screen | `--display <displayId>`, required `--path <path>` (existing directory or PNG file path; relative paths supported; writable destination; no overwrite) |
|
|
89
|
+
| `click [x] [y]` | Tap at the specified coordinates or node | `--id <id>` (auto-resolves to center), `--window <windowId>` (used with `--id`) |
|
|
90
|
+
| `doubleclick [x] [y]` | Double-tap at the specified coordinates or node | `--id <id>`, `--window <windowId>` |
|
|
91
|
+
| `longclick [x] [y]` | Long-press at the specified coordinates or node | `--id <id>`, `--window <windowId>` |
|
|
92
|
+
| `swipe <x1> <y1> <x2> <y2>` | Swipe from one point to another (precise coordinates, custom speed) | `--speed <n>` (200–40000, px/s) |
|
|
93
|
+
| `fling <x1> <y1> <x2> <y2>` | Fling from one point to another | `--speed <n>` (200–40000, px/s) |
|
|
94
|
+
| `drag <x1> <y1> <x2> <y2>` | Drag from one point to another | `--speed <n>` (200–40000, px/s) |
|
|
95
|
+
| `dircfling <direction>` | Quick directional fling (system default speed, ideal for scrolling) | `direction`: `up`, `down`, `left`, `right` |
|
|
96
|
+
| `text <text> [x] [y]` | Input text at a target location or the currently focused field | `--id <id>` (auto-resolves to center), `--window <windowId>` (used with `--id`) |
|
|
97
|
+
|
|
98
|
+
- **Coordinates vs `--id`**: Mutually exclusive. Provide either `x y` or `--id <id>`. For `text`, if neither is given, text goes to the currently focused field.
|
|
99
|
+
- **`--window`**: May only be used together with `--id`. Default is focused window. Secondary display operations via `--id` + `--window` are not supported.
|
|
100
|
+
- **`swipe` vs `dircfling`**: `swipe` requires exact start/end coordinates and supports `--speed`; `dircfling` only needs a direction (`up/down/left/right`) and uses system default speed (ideal for page/list scrolling).
|
|
101
|
+
- **Text encoding**: Special characters in `text` are Base64-encoded internally to safely pass through device shell.
|
|
102
|
+
- `--format json` pairs well with `jq`.
|
|
103
|
+
- `--mode full`: full layout tree, no filtering.
|
|
104
|
+
- `--mode simplified` (default): folds meaningless wrapper containers (non-root, no `id`, no text, not interactive) by lifting their surviving children up. `--depth` truncates after folding.
|
|
105
|
+
|
|
71
106
|
## 2. Setup
|
|
72
107
|
|
|
73
108
|
### `devecocli init`
|
|
@@ -81,6 +116,19 @@ MUTUALLY EXCLUSIVE modes for setup:
|
|
|
81
116
|
- `-f, --force`: Overwrite existing config.
|
|
82
117
|
*MCP Rules*: Global MCP (no `--project`) only supports `opencode` and `cursor`. Others require `--project`.
|
|
83
118
|
|
|
119
|
+
### `devecocli auth login`
|
|
120
|
+
Sign in to your Huawei Developer account. Opens a browser for OAuth authentication. Required before `signature generate`.
|
|
121
|
+
*Ex*: `devecocli auth login`
|
|
122
|
+
|
|
123
|
+
### `devecocli auth logout`
|
|
124
|
+
Sign out and clear locally stored credentials.
|
|
125
|
+
|
|
126
|
+
### `devecocli auth status`
|
|
127
|
+
Show the current logged-in user.
|
|
128
|
+
|
|
129
|
+
### `devecocli auth team list`
|
|
130
|
+
List team accounts the current user has joined.
|
|
131
|
+
|
|
84
132
|
### `devecocli skills`
|
|
85
133
|
Manage HarmonyOS skills in AI agents/projects.
|
|
86
134
|
- `list [-l|--long]` / `find <keyword>`: List or search skills.
|
|
@@ -105,6 +153,8 @@ Manage HarmonyOS skills in AI agents/projects.
|
|
|
105
153
|
`devecocli log --crash --bundle-name <bundle>`
|
|
106
154
|
- **Release build**:
|
|
107
155
|
`devecocli build --product oversea --build-mode release`
|
|
156
|
+
- **First-time signing setup**:
|
|
157
|
+
`devecocli login` -> `devecocli signature generate --product default` -> `devecocli build` -> `devecocli run`
|
|
108
158
|
|
|
109
159
|
## Troubleshooting
|
|
110
160
|
|