@oniroproject/oniro-app 0.6.2 → 0.8.1
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 +303 -9
- package/dist/oniro-app.js +499 -17
- package/dist/oniro-app.js.map +1 -1
- package/package.json +4 -3
- package/templates/NativeCpp/AppScope/app.json5 +10 -0
- package/templates/NativeCpp/AppScope/resources/base/element/string.json +8 -0
- package/templates/NativeCpp/AppScope/resources/base/media/background.png +0 -0
- package/templates/NativeCpp/AppScope/resources/base/media/foreground.png +0 -0
- package/templates/NativeCpp/AppScope/resources/base/media/layered_image.json +7 -0
- package/templates/NativeCpp/build-profile.json5 +35 -0
- package/templates/NativeCpp/entry/build-profile.json5 +48 -0
- package/templates/NativeCpp/entry/hvigorfile.ts +6 -0
- package/templates/NativeCpp/entry/obfuscation-rules.txt +23 -0
- package/templates/NativeCpp/entry/oh-package.json5 +12 -0
- package/templates/NativeCpp/entry/src/main/cpp/CMakeLists.txt +15 -0
- package/templates/NativeCpp/entry/src/main/cpp/napi_init.cpp +53 -0
- package/templates/NativeCpp/entry/src/main/cpp/types/libentry/Index.d.ts +1 -0
- package/templates/NativeCpp/entry/src/main/cpp/types/libentry/oh-package.json5 +6 -0
- package/templates/NativeCpp/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
- package/templates/NativeCpp/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
- package/templates/NativeCpp/entry/src/main/ets/pages/Index.ets +26 -0
- package/templates/NativeCpp/entry/src/main/module.json5 +50 -0
- package/templates/NativeCpp/entry/src/main/resources/base/element/color.json +8 -0
- package/templates/NativeCpp/entry/src/main/resources/base/element/float.json +8 -0
- package/templates/NativeCpp/entry/src/main/resources/base/element/string.json +16 -0
- package/templates/NativeCpp/entry/src/main/resources/base/media/background.png +0 -0
- package/templates/NativeCpp/entry/src/main/resources/base/media/foreground.png +0 -0
- package/templates/NativeCpp/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/templates/NativeCpp/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/templates/NativeCpp/entry/src/main/resources/base/profile/backup_config.json +3 -0
- package/templates/NativeCpp/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/templates/NativeCpp/entry/src/main/resources/dark/element/color.json +8 -0
- package/templates/NativeCpp/entry/src/mock/Libentry.mock.ets +7 -0
- package/templates/NativeCpp/entry/src/mock/mock-config.json5 +5 -0
- package/templates/NativeCpp/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/templates/NativeCpp/entry/src/ohosTest/ets/test/List.test.ets +5 -0
- package/templates/NativeCpp/entry/src/ohosTest/module.json5 +11 -0
- package/templates/NativeCpp/entry/src/test/List.test.ets +5 -0
- package/templates/NativeCpp/entry/src/test/LocalUnit.test.ets +33 -0
- package/templates/NativeCpp/hvigor/hvigor-config.json5 +23 -0
- package/templates/NativeCpp/hvigorfile.ts +6 -0
- package/templates/NativeCpp/oh-package.json5 +10 -0
- package/templates/NativeCpp/template.json +6 -0
package/README.md
CHANGED
|
@@ -1,38 +1,332 @@
|
|
|
1
1
|
# @oniroproject/oniro-app
|
|
2
2
|
|
|
3
|
-
Cross-platform
|
|
3
|
+
Cross-platform command-line interface for **Oniro / OpenHarmony** application development. One binary drives the whole inner loop — install the SDK and toolchain, scaffold a project, sign and build it, boot the emulator, then install, launch, and drive the app over `hdc` — on Linux, macOS, and Windows.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It is built for **non-interactive use** (CI, scripts, agents): every command takes explicit flags, results print to **stdout** (plain text, or JSON with `--json`), progress and logs go to **stderr**, and the process exit code reflects success or failure. No prompts, no TTY assumptions.
|
|
6
|
+
|
|
7
|
+
This is the CLI frontend for [`@oniroproject/core`](https://www.npmjs.com/package/@oniroproject/core) — install that package instead if you want to call the same functionality from your own code (see its README for the API).
|
|
6
8
|
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
|
-
Requires Node.js 20
|
|
11
|
+
Requires **Node.js 20+**. For `oniro-app sign` you also need a **JDK** on `PATH` (`java`, `keytool`).
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
14
|
npm install -g @oniroproject/oniro-app
|
|
13
15
|
oniro-app --help
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
Global flags: `--version`, `--help`. Run `oniro-app <command> --help` for the authoritative, up-to-date flags of any command.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
Set up the toolchain, scaffold an app, then build and run it on the emulator:
|
|
17
23
|
|
|
18
24
|
```bash
|
|
25
|
+
# One-time: toolchain + emulator
|
|
19
26
|
oniro-app sdk install 6.1
|
|
20
27
|
oniro-app cmdtools install
|
|
28
|
+
oniro-app emulator install
|
|
29
|
+
|
|
30
|
+
# Per project
|
|
21
31
|
oniro-app create --name HelloOniro --bundle com.example.hello \
|
|
22
32
|
--location ~/projects --sdk 23
|
|
23
33
|
cd ~/projects/HelloOniro
|
|
24
34
|
oniro-app sign
|
|
25
35
|
oniro-app build
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
|
|
37
|
+
# Run it
|
|
38
|
+
oniro-app emulator start --wait-for-hdc 300
|
|
28
39
|
oniro-app app install
|
|
29
40
|
oniro-app app launch
|
|
30
41
|
```
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
Once a device or emulator is connected you can inspect and drive it:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
oniro-app devices --json
|
|
47
|
+
oniro-app screenshot -o shot.jpeg
|
|
48
|
+
oniro-app dump layout --json
|
|
49
|
+
oniro-app input --type click --x 200 --y 400
|
|
50
|
+
oniro-app watch --log 'error|fault' --for 5000 --json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Command reference
|
|
54
|
+
|
|
55
|
+
### Environment & toolchain
|
|
56
|
+
|
|
57
|
+
Install commands are idempotent (they skip when already present); pass `--force` to reinstall.
|
|
58
|
+
|
|
59
|
+
#### `sdk` — manage OpenHarmony SDK installs
|
|
60
|
+
|
|
61
|
+
| Command | Description |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `sdk install <version> [--force]` | Download and install an OpenHarmony SDK (e.g. `6.1`). |
|
|
64
|
+
| `sdk list [--json]` | List known SDK versions; an `*` marks installed ones. |
|
|
65
|
+
| `sdk remove <api>` | Remove an installed SDK by API level (e.g. `18`, `20`). |
|
|
66
|
+
|
|
67
|
+
#### `cmdtools` — manage the OpenHarmony command-line tools (provides `hvigorw`, `ohpm`, `hdc`, `codelinter`)
|
|
68
|
+
|
|
69
|
+
| Command | Description |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `cmdtools install [--from-zip <path>] [--force]` | Install the tools. `--from-zip` installs from a local archive instead of downloading (required on Windows/macOS — see [Configuration](#configuration)). |
|
|
72
|
+
| `cmdtools status [--json]` | Report whether the tools are installed and their version. Exits non-zero when not installed. |
|
|
73
|
+
| `cmdtools remove` | Delete the configured command-line-tools directory. |
|
|
74
|
+
|
|
75
|
+
#### `emulator` — manage the Oniro emulator (QEMU-based)
|
|
76
|
+
|
|
77
|
+
| Command | Description |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `emulator install [--force]` | Download and install the emulator. |
|
|
80
|
+
| `emulator start [options]` | Start the emulator via the bundled launcher and detach, so the CLI can exit while it keeps running. |
|
|
81
|
+
| `emulator stop` | Kill running emulator processes. |
|
|
82
|
+
| `emulator connect [--address <host:port>]` | Attempt an `hdc` connection (default `127.0.0.1:55555`). |
|
|
83
|
+
| `emulator remove` | Delete the configured emulator directory. |
|
|
84
|
+
|
|
85
|
+
`emulator start` options:
|
|
86
|
+
|
|
87
|
+
| Flag | Description |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `--headless` | Launch headless (VNC + telnet serial, no local window). Required in CI. |
|
|
90
|
+
| `--log <path>` | Redirect launcher stdout/stderr to a file (default: discard). |
|
|
91
|
+
| `--wait-for-hdc <seconds>` | Block until `hdc` connects, up to N seconds. `0` (default) returns as soon as the launcher spawns. |
|
|
92
|
+
| `--connect <host:port>` | Override the launcher's hdc port-forward bind address. Pass `0.0.0.0:55555` on hosts where QEMU refuses to bind `127.0.0.1` (some CI runners). |
|
|
93
|
+
|
|
94
|
+
### Project lifecycle
|
|
95
|
+
|
|
96
|
+
#### `create` — scaffold a new app from a template
|
|
97
|
+
|
|
98
|
+
All flags are required except where a default is shown (non-interactive). On success the project path is printed to stdout.
|
|
99
|
+
|
|
100
|
+
| Flag | Description |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| `--name <name>` | Project folder name (letters, digits, `._-`, no slashes). |
|
|
103
|
+
| `--bundle <bundleName>` | Bundle name in reverse-DNS form, e.g. `com.example.myapp`. |
|
|
104
|
+
| `--location <dir>` | Parent directory the new project folder is created in. |
|
|
105
|
+
| `--sdk <api>` | Target SDK API level (e.g. `18`, `20`). |
|
|
106
|
+
| `--template <id>` | Template id (default `EmptyAbility`). |
|
|
107
|
+
| `--module <name>` | Module folder name (defaults to the template default, usually `entry`). |
|
|
108
|
+
| `--overwrite` | Replace the destination if it already exists. |
|
|
109
|
+
|
|
110
|
+
#### `templates` — inspect bundled templates
|
|
111
|
+
|
|
112
|
+
| Command | Description |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `templates list [--json]` | List the project templates shipped with the CLI. |
|
|
115
|
+
|
|
116
|
+
#### `sign` — generate signing keys, certs, and `signingConfigs`
|
|
117
|
+
|
|
118
|
+
`sign [project-dir]` (defaults to the current directory). Requires `java` on `PATH`. Rewrites only the `signingConfigs` block of `build-profile.json5` (other keys are preserved). The generated profile uses the SDK's built-in development cert (`issuer=pki_internal`) and its validity window — **dev/local builds only, not distribution.** See [Signing apps that need system permissions](#signing-apps-that-need-system-permissions) for `--apl` / `--acls`.
|
|
119
|
+
|
|
120
|
+
| Flag | Description |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `--apl <level>` | Ability Privilege Level: `normal` (default), `system_basic`, or `system_core`. |
|
|
123
|
+
| `--app-feature <feature>` | `hos_normal_app` or `hos_system_app`. Defaults follow `--apl`. |
|
|
124
|
+
| `--acls <list>` | Comma-separated permissions to write into the profile's `acls.allowed-acls`. |
|
|
125
|
+
| `--bootstrap` | No-op if signing material is already present; otherwise generate it. |
|
|
126
|
+
| `--store-password <pwd>` / `--key-password <pwd>` | Keystore passwords (default `123456`, the SDK keystore password). |
|
|
127
|
+
|
|
128
|
+
#### `build` — build the app via `hvigorw`
|
|
129
|
+
|
|
130
|
+
`build [project-dir]` (defaults to the current directory). Modules build in parallel by default.
|
|
131
|
+
|
|
132
|
+
| Flag | Description |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `--product <product>` | hvigor product name (default `default`). |
|
|
135
|
+
| `--module <module>` | Restrict the build to a single module. |
|
|
136
|
+
| `--mode <mode>` | hvigor build mode (e.g. `release`, `debug`). |
|
|
137
|
+
| `--task <task>` | hvigor task to run (default `assembleHap`). |
|
|
138
|
+
| `--no-deps` | Skip the automatic `ohpm install --all` when `oh_modules/` is missing. |
|
|
139
|
+
| `--no-parallel` | Build modules serially. |
|
|
140
|
+
| `--json` | Emit the result (discovered HAPs grouped by module, warnings) as JSON. |
|
|
141
|
+
|
|
142
|
+
#### `lint` — run the OpenHarmony codelinter
|
|
143
|
+
|
|
144
|
+
`lint [project-dir]` (defaults to the current directory). Exits with the codelinter's exit code.
|
|
145
|
+
|
|
146
|
+
| Flag | Description |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `--files <globs...>` | Specific files/globs to lint (default: the whole project). |
|
|
149
|
+
| `--json` | Emit findings as JSON. |
|
|
150
|
+
|
|
151
|
+
### Device & app
|
|
152
|
+
|
|
153
|
+
These commands target a connected device or emulator over `hdc`. Most accept `--device <serial>` to address a specific target; omit it to use the single connected device.
|
|
154
|
+
|
|
155
|
+
#### `devices` — list connected hdc devices
|
|
156
|
+
|
|
157
|
+
| Command | Description |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `devices [--json]` | List connected targets (`serial`, connection, status). |
|
|
160
|
+
|
|
161
|
+
#### `app` — install, launch, and manage built apps
|
|
162
|
+
|
|
163
|
+
| Command | Description |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| `app install [project-dir] [--hap <path>]` | Install the signed `.hap` via `hdc`. `--hap` overrides the resolved path. |
|
|
166
|
+
| `app launch [project-dir] [--module <m>] [--ability <name>]` | Launch the app. `--ability` defaults to the module's `mainElement` / first visible ability. |
|
|
167
|
+
| `app apply [project-dir] --bundle <b> [options]` | Install a HAP **and verify the running process took the change** — handles sign-info mismatch, asset-cache invalidation, and persistent-bundle restart. |
|
|
168
|
+
| `app uninstall <bundle> [--device <serial>]` | Uninstall an app by bundle name. |
|
|
169
|
+
| `app stop <bundle> [--device <serial>]` | Force-stop an app by bundle name. |
|
|
170
|
+
|
|
171
|
+
`app apply` options:
|
|
172
|
+
|
|
173
|
+
| Flag | Description |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `--bundle <bundle>` | **Required.** Bundle to apply changes to. |
|
|
176
|
+
| `--module <module>` | Module to resolve the HAP from (multi-module projects). |
|
|
177
|
+
| `--hap <path>` | Explicit `.hap` path (else resolved from the project + module). |
|
|
178
|
+
| `--installed-hap <path>` | Local copy of the currently-installed HAP, to enable the asset-cache reboot diff. |
|
|
179
|
+
| `--system` | Treat as a persistent/system bundle (refuses to uninstall on a sign-info mismatch). |
|
|
180
|
+
| `--allow-uninstall` | Permit uninstalling a system bundle on sign-info mismatch (dangerous). |
|
|
181
|
+
| `--json` | Emit the result (`method`, pre/post-install pid, `cacheCleared`) as JSON. |
|
|
182
|
+
|
|
183
|
+
#### `file` — transfer files to/from the device
|
|
184
|
+
|
|
185
|
+
| Command | Description |
|
|
186
|
+
| --- | --- |
|
|
187
|
+
| `file send <local> <remote> [--device <serial>]` | Push a local file to the device. |
|
|
188
|
+
| `file recv <remote> <local> [--device <serial>]` | Pull a file from the device. |
|
|
189
|
+
|
|
190
|
+
#### `reboot` — reboot the device
|
|
191
|
+
|
|
192
|
+
| Flag | Description |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `--mode <mode>` | `system` (default), `bootloader`, or `recovery`. |
|
|
195
|
+
| `--wait-bundle <bundle>` | After a system reboot, wait until this bundle is running again. |
|
|
196
|
+
| `--timeout <ms>` | Max time to wait for the bundle (default `180000`). |
|
|
197
|
+
| `--device <serial>` | Target device serial. For a TCP target (an emulator at `host:port`), passing this reconnects the session across the reboot. |
|
|
198
|
+
|
|
199
|
+
#### `wait` — wait for a device condition
|
|
200
|
+
|
|
201
|
+
Specify exactly one of `--log`, `--boot`, or `--bundle`.
|
|
202
|
+
|
|
203
|
+
| Flag | Description |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `--log <pattern>` | Resolve when a hilog line (`tag: message`) matches this regex. |
|
|
206
|
+
| `--boot` | Resolve when the device is reachable. |
|
|
207
|
+
| `--bundle <bundle>` | With `--log`: filter to this bundle. Alone: wait until this bundle is running. |
|
|
208
|
+
| `--pid-of <name>` | With `--boot`: also require this process to have a pid. |
|
|
209
|
+
| `--domain <domain>` | With `--log`: hilog domain filter (e.g. `0xD003900`). |
|
|
210
|
+
| `--timeout <ms>` | Max wait (default `30000`). |
|
|
211
|
+
| `--device <serial>` | Target device serial. |
|
|
212
|
+
| `--json` | With `--log`: emit the matched entry as JSON. |
|
|
213
|
+
|
|
214
|
+
#### `watch` — collect matching hilog lines for a fixed duration
|
|
215
|
+
|
|
216
|
+
| Flag | Description |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| `--log <pattern>` | **Required.** Regex tested against each line (`tag: message`). |
|
|
219
|
+
| `--for <ms>` | Duration to watch (default `10000`). |
|
|
220
|
+
| `--bundle <bundle>` | Filter to this bundle. |
|
|
221
|
+
| `--domain <domain>` | hilog domain filter. |
|
|
222
|
+
| `--no-dedup` | Do not collapse consecutive duplicate lines. |
|
|
223
|
+
| `--device <serial>` | Target device serial. |
|
|
224
|
+
| `--json` | Emit the collected entries as JSON. |
|
|
225
|
+
|
|
226
|
+
#### `screenshot` — capture the screen as a JPEG
|
|
227
|
+
|
|
228
|
+
Default: writes the full-resolution raw JPEG. `--grid` reproduces the old MCP screenshot (downscaled + grid overlay). `--contact-sheet` captures a burst (default 8 frames) into one tiled sheet and prints per-frame diffs (0..1) on stdout — one image instead of N, pointing you at the frame where something changed.
|
|
229
|
+
|
|
230
|
+
| Flag | Description |
|
|
231
|
+
| --- | --- |
|
|
232
|
+
| `-o, --output <file>` | Output path (default `screenshot.jpeg`). |
|
|
233
|
+
| `--grid` | Downscale to `--max-dim` and overlay a 10x10 grid (axes 0.0–1.0) for picking tap coordinates. |
|
|
234
|
+
| `--max-dim <px>` | Longest-side cap for `--grid` / `--contact-sheet` (256–4096, default `1024`). On its own, downscales without a grid. |
|
|
235
|
+
| `--contact-sheet` | Capture a burst and composite it into one tiled image with per-frame change diffs. |
|
|
236
|
+
| `--burst <count>` | Capture N frames; writes `<base>-<i><ext>` (or sets the `--contact-sheet` frame count). |
|
|
237
|
+
| `--interval <ms>` | Delay between burst frames (default `50`). |
|
|
238
|
+
| `--json` | With `--contact-sheet`, emit the full result object as JSON on stdout. |
|
|
239
|
+
| `--device <serial>` | Target device serial. |
|
|
240
|
+
|
|
241
|
+
#### `dump` — dump device state as JSON
|
|
242
|
+
|
|
243
|
+
| Command | Description |
|
|
244
|
+
| --- | --- |
|
|
245
|
+
| `dump [layout]` | Dump the on-screen UI layout (the default and currently only target) as a pruned, 0–1-normalized tree to stdout. |
|
|
246
|
+
|
|
247
|
+
| Flag | Description |
|
|
248
|
+
| --- | --- |
|
|
249
|
+
| `--bundle <bundle>` | Filter the layout to a single window/bundle. |
|
|
250
|
+
| `--raw` | Return the unpruned tree. |
|
|
251
|
+
| `--device <serial>` | Target device serial. |
|
|
252
|
+
|
|
253
|
+
#### `input` / `gesture` — inject UI input
|
|
254
|
+
|
|
255
|
+
`input` injects a single event in **pixel** coordinates via `uitest uiInput`:
|
|
256
|
+
|
|
257
|
+
| Flag | Description |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `--type <type>` | **Required.** One of `click`, `doubleClick`, `longClick`, `swipe`, `drag`, `fling`, `keyEvent`, `inputText`. |
|
|
260
|
+
| `--x <px>` / `--y <px>` | Start coordinate (click / swipe start). |
|
|
261
|
+
| `--x2 <px>` / `--y2 <px>` | End coordinate (swipe / drag / fling). |
|
|
262
|
+
| `--speed <px-per-s>` | Velocity for swipe / drag / fling. |
|
|
263
|
+
| `--key <key>` | Key id or symbolic name (`Back` / `Home` / `Power`) for `keyEvent`. |
|
|
264
|
+
| `--text <text>` | Text for `inputText`. |
|
|
265
|
+
| `--device <serial>` | Target device serial. |
|
|
266
|
+
|
|
267
|
+
`gesture` injects a multi-waypoint path:
|
|
268
|
+
|
|
269
|
+
| Flag | Description |
|
|
270
|
+
| --- | --- |
|
|
271
|
+
| `--waypoints <json>` | **Required.** JSON array of pixel waypoints `[{"x":..,"y":..,"t":..}]` (`t` = ms from start). |
|
|
272
|
+
| `--hold-start <ms>` / `--hold-end <ms>` | Hold at the first/last point before moving/lifting (routes via `uinput`). |
|
|
273
|
+
| `--device <serial>` | Target device serial. |
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
oniro-app gesture --waypoints '[{"x":200,"y":600,"t":0},{"x":200,"y":200,"t":400}]'
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Output & exit codes
|
|
280
|
+
|
|
281
|
+
- **Results → stdout.** Plain text by default; `--json` (where supported) writes `JSON.stringify(..., null, 2)`. Read/observe commands (`sdk list`, `cmdtools status`, `templates list`, `devices`, `wait --log`, `watch`, `lint`, `app apply`, `build`) accept `--json` (and `screenshot` with `--contact-sheet`); `dump` always emits JSON; action-only commands do not.
|
|
282
|
+
- **Progress & logs → stderr.** stdout stays clean for machine consumers, so `oniro-app create … > path.txt` or `oniro-app devices --json | jq` work cleanly.
|
|
283
|
+
- **Exit code.** `0` on success, non-zero on failure (the error message is written to stderr). Set `ONIRO_DEBUG=1` to also print full stack traces.
|
|
284
|
+
|
|
285
|
+
## Configuration
|
|
286
|
+
|
|
287
|
+
The CLI reads paths and URLs from environment variables. All are optional; defaults match the layout used historically by this project. `${userHome}` inside any value expands to the current user's home directory.
|
|
288
|
+
|
|
289
|
+
| Variable | Default | Purpose |
|
|
290
|
+
| --- | --- | --- |
|
|
291
|
+
| `ONIRO_SDK_ROOT_DIR` | `~/setup-ohos-sdk` | SDK install root |
|
|
292
|
+
| `ONIRO_CMD_TOOLS_PATH` | `~/command-line-tools` | Command-line tools install root |
|
|
293
|
+
| `ONIRO_EMULATOR_DIR` | `~/oniro-emulator` | Emulator install root |
|
|
294
|
+
| `ONIRO_HAP_PATH` | `entry/build/.../entry-default-signed.hap` | Default `.hap` used by `app install` (relative to the project) |
|
|
295
|
+
| `ONIRO_SDK_URL_BASE` | `https://repo.huaweicloud.com/openharmony/os` | Base URL for SDK downloads (point at a private/CI mirror) |
|
|
296
|
+
| `ONIRO_CMD_TOOLS_URL_LINUX` | Huawei mirror, x64 5.1.0.840 | Override the Linux cmd-tools URL |
|
|
297
|
+
| `ONIRO_CMD_TOOLS_URL_WINDOWS` | (unset) | Self-hosted Windows cmd-tools URL |
|
|
298
|
+
| `ONIRO_CMD_TOOLS_URL_MAC` | (unset) | Self-hosted macOS cmd-tools URL |
|
|
299
|
+
| `ONIRO_EMULATOR_URL` | Latest `oniro_emulator.zip` | Emulator download URL |
|
|
300
|
+
| `ONIRO_APPLICATION_CERT_PATH` | (unset) | External application-cert chain to use when signing system apps |
|
|
301
|
+
| `ONIRO_DEBUG` | (unset) | Set to `1` for full stack traces on error |
|
|
302
|
+
|
|
303
|
+
**Command-line tools on Windows / macOS.** The Huawei mirror only publishes a Linux build of the command-line tools. On Windows and macOS you must either download the ZIP manually from the Huawei developer portal and install it with `oniro-app cmdtools install --from-zip path/to/commandline-tools-<platform>.zip`, or host the archive yourself and set `ONIRO_CMD_TOOLS_URL_WINDOWS` / `ONIRO_CMD_TOOLS_URL_MAC` so `cmdtools install` can fetch it.
|
|
304
|
+
|
|
305
|
+
## Signing apps that need system permissions
|
|
306
|
+
|
|
307
|
+
`oniro-app sign` defaults to `--apl normal` / `--app-feature hos_normal_app`, which is fine for ordinary apps. Apps that request permissions above `normal` (anything with `system_basic` or `system_core` availability — e.g. `ohos.permission.GET_WIFI_INFO_INTERNAL`, `ohos.permission.ACCESS_PIN_AUTH`) need a higher APL, otherwise `bm install` fails with `grant request permissions failed`.
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
oniro-app sign --apl system_basic # implies --app-feature hos_system_app
|
|
311
|
+
oniro-app sign --apl system_core # implies --app-feature hos_system_app
|
|
312
|
+
oniro-app sign --apl system_basic --app-feature hos_normal_app # explicit override
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
When `--apl` is `system_basic` or `system_core`, the HAP signing key automatically switches from `OpenHarmony Application Profile Release` to `OpenHarmony Application Release`, and the profile's `distribution-certificate` is set to the matching CA-signed `OpenHarmony Application Release` leaf (shipped as a code resource — the SDK only bundles the Profile Release chain). This matches the convention used by every preinstalled OpenHarmony system app's `signature/` directory and is required to get past BMS's parse-profile-prop check on install.
|
|
316
|
+
|
|
317
|
+
Some privileged permissions (e.g. `ohos.permission.REBOOT`, `ohos.permission.INJECT_INPUT_EVENT`, `ohos.permission.CAPTURE_SCREEN`) must additionally appear in the profile's `acls.allowed-acls`. Pass them via `--acls`:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
oniro-app sign --apl system_core \
|
|
321
|
+
--acls ohos.permission.REBOOT,ohos.permission.INJECT_INPUT_EVENT
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The `signingConfigs` block written to `build-profile.json5` mirrors the names used by the project's `products[*].signingConfig` (e.g. `applications/standard/systemui` uses `release`, `launcher` uses `default`). If the project has no products section, `default` is used.
|
|
325
|
+
|
|
326
|
+
## Programmatic use
|
|
33
327
|
|
|
34
|
-
|
|
328
|
+
Everything the CLI does is exposed as a library by [`@oniroproject/core`](https://www.npmjs.com/package/@oniroproject/core), so you can embed the same SDK/build/sign/emulator/`hdc` functionality in an editor extension, an MCP server, or your own tooling. See that package's README for the API reference.
|
|
35
329
|
|
|
36
330
|
## License
|
|
37
331
|
|
|
38
|
-
Apache-2.0
|
|
332
|
+
Apache-2.0 — see [LICENSE](https://github.com/eclipse-oniro4openharmony/oniro-app-builder/blob/main/LICENSE).
|