rn-update-cli 1.0.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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/README.zh-CN.md +167 -0
  4. package/cli.json +525 -0
  5. package/lib/api.d.ts +56 -0
  6. package/lib/api.js +671 -0
  7. package/lib/app.d.ts +107 -0
  8. package/lib/app.js +329 -0
  9. package/lib/auto-update.d.ts +35 -0
  10. package/lib/auto-update.js +507 -0
  11. package/lib/bin.d.ts +2 -0
  12. package/lib/bin.js +133 -0
  13. package/lib/bundle-pack.d.ts +6 -0
  14. package/lib/bundle-pack.js +91 -0
  15. package/lib/bundle-runner.d.ts +168 -0
  16. package/lib/bundle-runner.js +1305 -0
  17. package/lib/bundle.d.ts +45 -0
  18. package/lib/bundle.js +226 -0
  19. package/lib/cache.d.ts +10 -0
  20. package/lib/cache.js +25 -0
  21. package/lib/commands.d.ts +11 -0
  22. package/lib/commands.js +72 -0
  23. package/lib/diff.d.ts +18 -0
  24. package/lib/diff.js +690 -0
  25. package/lib/exports.d.ts +11 -0
  26. package/lib/exports.js +20 -0
  27. package/lib/install.d.ts +9 -0
  28. package/lib/install.js +51 -0
  29. package/lib/locales/en.d.ts +187 -0
  30. package/lib/locales/en.js +194 -0
  31. package/lib/locales/zh.d.ts +187 -0
  32. package/lib/locales/zh.js +194 -0
  33. package/lib/native-package.d.ts +21 -0
  34. package/lib/native-package.js +298 -0
  35. package/lib/package.d.ts +68 -0
  36. package/lib/package.js +487 -0
  37. package/lib/provider.d.ts +24 -0
  38. package/lib/provider.js +244 -0
  39. package/lib/standalone-publish.d.ts +17 -0
  40. package/lib/standalone-publish.js +433 -0
  41. package/lib/symbolicate.d.ts +35 -0
  42. package/lib/symbolicate.js +130 -0
  43. package/lib/types.d.ts +152 -0
  44. package/lib/types.js +2 -0
  45. package/lib/user.d.ts +8 -0
  46. package/lib/user.js +50 -0
  47. package/lib/utils/add-gitignore.d.ts +6 -0
  48. package/lib/utils/add-gitignore.js +44 -0
  49. package/lib/utils/app-info-parser/aab.d.ts +27 -0
  50. package/lib/utils/app-info-parser/aab.js +256 -0
  51. package/lib/utils/app-info-parser/apk.d.ts +19 -0
  52. package/lib/utils/app-info-parser/apk.js +95 -0
  53. package/lib/utils/app-info-parser/app.d.ts +9 -0
  54. package/lib/utils/app-info-parser/app.js +15 -0
  55. package/lib/utils/app-info-parser/index.d.ts +21 -0
  56. package/lib/utils/app-info-parser/index.js +51 -0
  57. package/lib/utils/app-info-parser/ipa.d.ts +19 -0
  58. package/lib/utils/app-info-parser/ipa.js +101 -0
  59. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  60. package/lib/utils/app-info-parser/resource-finder.js +429 -0
  61. package/lib/utils/app-info-parser/utils.d.ts +36 -0
  62. package/lib/utils/app-info-parser/utils.js +140 -0
  63. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +61 -0
  64. package/lib/utils/app-info-parser/xml-parser/binary.js +577 -0
  65. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +15 -0
  66. package/lib/utils/app-info-parser/xml-parser/manifest.js +207 -0
  67. package/lib/utils/app-info-parser/zip.d.ts +29 -0
  68. package/lib/utils/app-info-parser/zip.js +97 -0
  69. package/lib/utils/check-lockfile.d.ts +6 -0
  70. package/lib/utils/check-lockfile.js +93 -0
  71. package/lib/utils/check-plugin.d.ts +12 -0
  72. package/lib/utils/check-plugin.js +36 -0
  73. package/lib/utils/command-result.d.ts +8 -0
  74. package/lib/utils/command-result.js +27 -0
  75. package/lib/utils/constants.d.ts +10 -0
  76. package/lib/utils/constants.js +39 -0
  77. package/lib/utils/dep-versions.d.ts +20 -0
  78. package/lib/utils/dep-versions.js +129 -0
  79. package/lib/utils/git.d.ts +14 -0
  80. package/lib/utils/git.js +64 -0
  81. package/lib/utils/hbcTransform.d.ts +111 -0
  82. package/lib/utils/hbcTransform.js +561 -0
  83. package/lib/utils/hermes-base.d.ts +227 -0
  84. package/lib/utils/hermes-base.js +1287 -0
  85. package/lib/utils/hermes-literals.d.ts +64 -0
  86. package/lib/utils/hermes-literals.js +260 -0
  87. package/lib/utils/http-helper.d.ts +10 -0
  88. package/lib/utils/http-helper.js +150 -0
  89. package/lib/utils/i18n.d.ts +22 -0
  90. package/lib/utils/i18n.js +46 -0
  91. package/lib/utils/index.d.ts +67 -0
  92. package/lib/utils/index.js +545 -0
  93. package/lib/utils/latest-version/index.d.ts +154 -0
  94. package/lib/utils/latest-version/index.js +331 -0
  95. package/lib/utils/options.d.ts +10 -0
  96. package/lib/utils/options.js +68 -0
  97. package/lib/utils/plugin-config.d.ts +14 -0
  98. package/lib/utils/plugin-config.js +66 -0
  99. package/lib/utils/runtime.d.ts +54 -0
  100. package/lib/utils/runtime.js +263 -0
  101. package/lib/utils/slim-sourcemap.d.ts +28 -0
  102. package/lib/utils/slim-sourcemap.js +106 -0
  103. package/lib/utils/zip-entries.d.ts +10 -0
  104. package/lib/utils/zip-entries.js +211 -0
  105. package/lib/utils/zip-options.d.ts +17 -0
  106. package/lib/utils/zip-options.js +190 -0
  107. package/lib/utils/zip-range.d.ts +148 -0
  108. package/lib/utils/zip-range.js +581 -0
  109. package/lib/utils/zip-raw-writer.d.ts +52 -0
  110. package/lib/utils/zip-raw-writer.js +209 -0
  111. package/lib/version-operations.d.ts +21 -0
  112. package/lib/version-operations.js +320 -0
  113. package/lib/versions.d.ts +66 -0
  114. package/lib/versions.js +402 -0
  115. package/package.json +113 -0
  116. package/proto/Configuration.proto +183 -0
  117. package/proto/Resources.proto +569 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yoghourt Technology(BeiJing) Company Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # rn-update-cli · Pakta
2
+
3
+ [简体中文](./README.zh-CN.md) · [Website](https://pakta.site) · [SDK](https://github.com/pakta-team/rn-update)
4
+
5
+ The command-line and CI publishing tool for Pakta. Register native builds, create OTA artifacts, deploy by channel and symbolicate stacks for Android, iOS and HarmonyOS.
6
+
7
+ ## Install
8
+
9
+ Requires Node.js 18.17+ and your platform build toolchain. Install the CLI globally and invoke `pakta` directly:
10
+
11
+ ```bash
12
+ npm install -g rn-update-cli
13
+ pakta help
14
+ pakta list
15
+ ```
16
+
17
+ ## Connect and select an app
18
+
19
+ The website is [pakta.site](https://pakta.site). These examples assume that domain proxies the repository’s Go service at `/admin/api/v1`; otherwise substitute your actual API URL. The CLI adds the management API prefix. Legacy defaults remain in the code, so explicitly set `RNU_SERVICE_URL` for your own service.
20
+
21
+ Bash / Zsh:
22
+
23
+ ```bash
24
+ export RNU_SERVICE_URL=https://pakta.site
25
+ ```
26
+
27
+ PowerShell:
28
+
29
+ ```powershell
30
+ $env:RNU_SERVICE_URL = 'https://pakta.site'
31
+ ```
32
+
33
+ After registering and verifying your email in the dashboard, run from your React Native project root:
34
+
35
+ ```bash
36
+ pakta login
37
+ pakta apps --platform android
38
+ pakta selectApp --platform android
39
+ ```
40
+
41
+ Create an app with `pakta createApp --platform android --name MyApp` if needed. Select an app separately for each platform. `selectApp` writes app information to `update.json` for subsequent commands. Credentials are scoped by service URL.
42
+
43
+ ## Publish your first update
44
+
45
+ Complete SDK native integration, then upload your distributed release binary as the baseline:
46
+
47
+ ```bash
48
+ pakta uploadApk ./app-release.apk
49
+ ```
50
+
51
+ For other formats use `uploadAab`, `uploadIpa` or HarmonyOS `uploadApp`. After changing JavaScript, bundle and publish:
52
+
53
+ ```bash
54
+ pakta bundle --platform android --output .pakta/output/android.ppk --no-interactive
55
+ pakta publish .pakta/output/android.ppk --platform android --name fix-001 --channel default --packageVersion 1.0.0 --rollout 10 --sourcemap .pakta/intermedia/android/index.bundlejs.map
56
+ ```
57
+
58
+ Replace `default` and `1.0.0` with the registered channel and native version. `--rollout 10` deploys to 10%; the default is 100%. Explicit `--output` avoids guessing the default timestamped filename. Add `--expo` for Expo bundles.
59
+
60
+ Interactive publishing without a target asks whether to bind a native build after upload; declining only stores the package. Non-interactive publishing requires `--targets`, `--packageId` or `--packageVersion`. `bundle --name ...` triggers publishing; omit `--name` to build only.
61
+
62
+ ## Channels and CI
63
+
64
+ Channel identity comes from native metadata, defaulting to `default`. Upload `--channel` asserts identity without changing it. Standalone uploads/publishes create missing channels. One channel/native-version pair cannot have conflicting JS fingerprints; `buildTime` remains an opaque string.
65
+
66
+ Create `targets.json`, with one independent deployment per entry:
67
+
68
+ ```json
69
+ [
70
+ { "channel": "default", "packageVersion": "1.0.0", "rollout": 10 },
71
+ { "channel": "huawei", "packageVersion": "1.0.0", "rollout": 30 }
72
+ ]
73
+ ```
74
+
75
+ Set `RNU_SERVICE_URL` in CI and inject `PAKTA_API_TOKEN` from your secret store, using a personal token created in account settings. Validate the built artifact’s targets, then publish:
76
+
77
+ ```bash
78
+ pakta publish .pakta/output/android.ppk --platform android --targets targets.json --dryRun --no-interactive
79
+ pakta publish .pakta/output/android.ppk --platform android --targets targets.json --name fix-001 --sourcemap .pakta/intermedia/android/index.bundlejs.map --no-interactive
80
+ ```
81
+
82
+ `--dryRun` does not upload, create channels or write packages/deployments. A target’s `rollout` overrides the global value, falling back to 100%. Save the returned `packageId` and `deploymentIds` for exact retries:
83
+
84
+ ```bash
85
+ pakta publish --deploymentIds DEPLOYMENT_ID_1,DEPLOYMENT_ID_2 --platform android --no-interactive
86
+ ```
87
+
88
+ ## Command reference
89
+
90
+ | Purpose | Commands |
91
+ | --- | --- |
92
+ | Account | `login`, `logout`, `me` |
93
+ | Apps | `createApp`, `apps`, `selectApp`, `deleteApp` |
94
+ | Channels | `channels`, `createChannel`, `updateChannel`, `deleteChannel` |
95
+ | Native builds | `uploadApk`, `uploadAab`, `uploadIpa`, `uploadApp`, `packages`, `deletePackage` |
96
+ | Inspect | `parseApk`, `parseAab`, `parseIpa`, `parseApp`, `extractApk` |
97
+ | OTA | `bundle`, `publish`, `versions`, `update`, `updateVersionInfo`, `deleteVersion` |
98
+ | Patches | `hdiff`, `hdiffFromApk`, `hdiffFromIpa`, `hdiffFromApp`, `registerPdiff` |
99
+ | Diagnostics | `symbolicate`, `cache`, `cache clean` |
100
+
101
+ Local `hdiff*` commands only generate patches; register exact native-build patches separately with `registerPdiff`. Full options: [cli.json](./cli.json).
102
+
103
+ ## Hermes & sourcemaps
104
+
105
+ `bundle` generates sourcemaps by default and composes the final Hermes map. Archive it with `publish --sourcemap`, then symbolicate:
106
+
107
+ ```bash
108
+ pakta symbolicate stack.txt --platform android --hash UPDATE_HASH
109
+ ```
110
+
111
+ The hash comes from the SDK’s `getUpdateMetadata().currentVersion`. Alternatively use `--versionId`, or `-` to read the stack from stdin.
112
+
113
+ Hermes defaults to `--hermesBase auto`; use `none` to disable it or pass a `.hbc/.ppk/.apk/.ipa` path. Failed equivalence checks fall back to plain compilation; patch size depends on your build. See [Hermes base verification](./docs/hermes-base-verification.md).
114
+
115
+ For Sentry, configure platform `sentry.properties`, use `@sentry/react-native/metro` for matching bundle/map Debug IDs, and use the `bundle` publishing flow for automatic uploads. Legacy Sentry accepts explicit `--sentry-release` and `--sentry-dist`, matching runtime values.
116
+
117
+ ## Provider API
118
+
119
+ Install a development dependency when importing the API in build scripts:
120
+
121
+ ```bash
122
+ npm install --save-dev rn-update-cli
123
+ ```
124
+
125
+ Configure service and authentication first. Place this in an async function or a module supporting top-level await:
126
+
127
+ ```typescript
128
+ import { CLIProviderImpl } from 'rn-update-cli';
129
+
130
+ const provider = new CLIProviderImpl();
131
+ const bundle = await provider.bundle({
132
+ platform: 'android',
133
+ output: '.pakta/output/android.ppk',
134
+ sourcemap: true,
135
+ });
136
+ if (!bundle.success) throw new Error(bundle.error);
137
+
138
+ const release = await provider.publish({
139
+ filePath: '.pakta/output/android.ppk',
140
+ sourcemap: '.pakta/intermedia/android/index.bundlejs.map',
141
+ platform: 'android',
142
+ name: 'fix-001',
143
+ targets: 'targets.json',
144
+ });
145
+ if (!release.success) throw new Error(release.error);
146
+ ```
147
+
148
+ Methods return `CommandResult`; check `success` before consuming `data`. Full interfaces: [src/types.ts](./src/types.ts).
149
+
150
+ ## Environment and automatic updates
151
+
152
+ | Variable | Purpose |
153
+ | --- | --- |
154
+ | `RNU_SERVICE_URL` | Standalone service URL |
155
+ | `PAKTA_API_TOKEN` | Personal access token for CI |
156
+ | `NO_INTERACTIVE=true` | Disables prompts |
157
+ | `RNU_LANG` | `zh` (default) or `en` |
158
+ | `RNU_DEBUG=1` | Prints error stacks |
159
+ | `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` | Proxies; lowercase names supported |
160
+ | `PAKTA_CACHE_DIR` | Hermes base cache directory |
161
+ | `RNU_AUTO_UPDATE=0` | Disables background updates |
162
+
163
+ Global installations can update in the background after a successful command, retaining their package manager, registry, authentication, proxy and global prefix. CI, local dependencies and npx installs are not modified. Alternatively set `RNU_DISABLE_AUTO_UPDATE=1`, or select npm, pnpm, yarn or bun with `RNU_AUTO_UPDATE_PACKAGE_MANAGER`.
164
+
165
+ License: [MIT](./LICENSE).
166
+
167
+ Copyright (c) 2026 Yoghourt Technology(BeiJing) Company Limited.
@@ -0,0 +1,167 @@
1
+ # rn-update-cli · Pakta
2
+
3
+ [English](./README.md) · [官网](https://pakta.site) · [SDK](https://github.com/pakta-team/rn-update)
4
+
5
+ Pakta 的命令行与 CI 发布工具。通过 `pakta` 为 Android、iOS 和 HarmonyOS 登记原生包、生成 OTA 制品、按渠道发布更新并还原错误堆栈。
6
+
7
+ ## 安装
8
+
9
+ 需要 Node.js 18.17+ 和目标平台的构建工具链。命令行全局安装,直接使用 `pakta`:
10
+
11
+ ```bash
12
+ npm install -g rn-update-cli
13
+ pakta help
14
+ pakta list
15
+ ```
16
+
17
+ ## 连接服务与选择应用
18
+
19
+ 官网为 [pakta.site](https://pakta.site)。以下假设该域名已代理本仓库 Go 服务的 `/admin/api/v1`;否则请替换为实际 API 地址。CLI 会自动补充管理 API 前缀。当前默认端点仍为历史服务,必须显式设置 `RNU_SERVICE_URL` 才能连接自己的服务。
20
+
21
+ Bash / Zsh:
22
+
23
+ ```bash
24
+ export RNU_SERVICE_URL=https://pakta.site
25
+ ```
26
+
27
+ PowerShell:
28
+
29
+ ```powershell
30
+ $env:RNU_SERVICE_URL = 'https://pakta.site'
31
+ ```
32
+
33
+ 在控制台注册并验证邮箱后,从 React Native 工程根目录执行:
34
+
35
+ ```bash
36
+ pakta login
37
+ pakta apps --platform android
38
+ pakta selectApp --platform android
39
+ ```
40
+
41
+ 没有应用时先运行 `pakta createApp --platform android --name MyApp`。各平台分别选择应用;`selectApp` 把应用信息写入 `update.json`,供后续命令使用。登录凭据按服务地址隔离。
42
+
43
+ ## 发布第一条更新
44
+
45
+ 先完成 SDK 原生接入,上传实际分发的 Release 原生包作为基线:
46
+
47
+ ```bash
48
+ pakta uploadApk ./app-release.apk
49
+ ```
50
+
51
+ 其他格式使用 `uploadAab`、`uploadIpa` 或 HarmonyOS 的 `uploadApp`。修改 JavaScript 后,先打包再发布:
52
+
53
+ ```bash
54
+ pakta bundle --platform android --output .pakta/output/android.ppk --no-interactive
55
+ pakta publish .pakta/output/android.ppk --platform android --name fix-001 --channel default --packageVersion 1.0.0 --rollout 10 --sourcemap .pakta/intermedia/android/index.bundlejs.map
56
+ ```
57
+
58
+ 把 `default`、`1.0.0` 换成已登记原生包的渠道和版本。`--rollout 10` 表示 10% 投放,省略时默认 100%。固定 `--output` 避免误用带时间戳的默认文件名。Expo 打包增加 `--expo`。
59
+
60
+ 交互发布未指定目标时,上传后会询问是否绑定原生包;选择否只保存更新包。非交互发布必须提供 `--targets`、`--packageId` 或 `--packageVersion`。`bundle --name ...` 会触发发布,只打包时不要传 `--name`。
61
+
62
+ ## 多渠道与 CI
63
+
64
+ 渠道来自原生包元数据,缺省为 `default`;上传的 `--channel` 只做断言,不改写身份。独立服务上传/发布会自动创建缺失渠道。同渠道同原生版本不能登记不同 JS 指纹;`buildTime` 按原始字符串透传。
65
+
66
+ 创建 `targets.json`,每项是一条独立投放:
67
+
68
+ ```json
69
+ [
70
+ { "channel": "default", "packageVersion": "1.0.0", "rollout": 10 },
71
+ { "channel": "huawei", "packageVersion": "1.0.0", "rollout": 30 }
72
+ ]
73
+ ```
74
+
75
+ CI 中设置 `RNU_SERVICE_URL`,通过密钥管理注入账号设置生成的个人令牌 `PAKTA_API_TOKEN`。对已生成的制品先预检,再发布:
76
+
77
+ ```bash
78
+ pakta publish .pakta/output/android.ppk --platform android --targets targets.json --dryRun --no-interactive
79
+ pakta publish .pakta/output/android.ppk --platform android --targets targets.json --name fix-001 --sourcemap .pakta/intermedia/android/index.bundlejs.map --no-interactive
80
+ ```
81
+
82
+ `--dryRun` 不上传、不创建渠道、不写更新包或投放。每项 `rollout` 优先于全局参数,两者均省略则为 100%。保存返回的 `packageId` 与 `deploymentIds`,失败后按准确投放 ID 重试:
83
+
84
+ ```bash
85
+ pakta publish --deploymentIds DEPLOYMENT_ID_1,DEPLOYMENT_ID_2 --platform android --no-interactive
86
+ ```
87
+
88
+ ## 命令速查
89
+
90
+ | 用途 | 命令 |
91
+ | --- | --- |
92
+ | 账号 | `login`, `logout`, `me` |
93
+ | 应用 | `createApp`, `apps`, `selectApp`, `deleteApp` |
94
+ | 渠道 | `channels`, `createChannel`, `updateChannel`, `deleteChannel` |
95
+ | 原生包 | `uploadApk`, `uploadAab`, `uploadIpa`, `uploadApp`, `packages`, `deletePackage` |
96
+ | 解析 | `parseApk`, `parseAab`, `parseIpa`, `parseApp`, `extractApk` |
97
+ | OTA | `bundle`, `publish`, `versions`, `update`, `updateVersionInfo`, `deleteVersion` |
98
+ | 差分 | `hdiff`, `hdiffFromApk`, `hdiffFromIpa`, `hdiffFromApp`, `registerPdiff` |
99
+ | 诊断 | `symbolicate`, `cache`, `cache clean` |
100
+
101
+ 本地 `hdiff*` 只生成补丁,精确原生构建补丁需另行通过 `registerPdiff` 登记。完整选项见 [cli.json](./cli.json).
102
+
103
+ ## Hermes & sourcemaps
104
+
105
+ `bundle` 默认生成 sourcemap,Hermes 工程会合成最终映射。用 `publish --sourcemap` 归档后还原错误堆栈:
106
+
107
+ ```bash
108
+ pakta symbolicate stack.txt --platform android --hash UPDATE_HASH
109
+ ```
110
+
111
+ hash 来自 SDK 的 `getUpdateMetadata().currentVersion`;也可使用 `--versionId`,`-` 表示从 stdin 读取堆栈。
112
+
113
+ Hermes 默认 `--hermesBase auto` 复用历史基线,`none` 关闭,也可传 `.hbc/.ppk/.apk/.ipa` 路径。默认等价校验失败时回退普通编译;补丁大小取决于实际构建。详见 [Hermes base verification](./docs/hermes-base-verification.md).
114
+
115
+ Sentry 需配置平台的 `sentry.properties`,通过 `@sentry/react-native/metro` 保持 bundle/map Debug ID 一致,并使用 `bundle` 发布流程自动上传。旧版 Sentry 可指定 `--sentry-release`、`--sentry-dist`,与运行时保持一致。
116
+
117
+ ## Provider API
118
+
119
+ 仅构建脚本导入 API 时,安装项目开发依赖:
120
+
121
+ ```bash
122
+ npm install --save-dev rn-update-cli
123
+ ```
124
+
125
+ 先配置服务和认证。下面代码放入 async 函数或支持顶层 await 的模块:
126
+
127
+ ```typescript
128
+ import { CLIProviderImpl } from 'rn-update-cli';
129
+
130
+ const provider = new CLIProviderImpl();
131
+ const bundle = await provider.bundle({
132
+ platform: 'android',
133
+ output: '.pakta/output/android.ppk',
134
+ sourcemap: true,
135
+ });
136
+ if (!bundle.success) throw new Error(bundle.error);
137
+
138
+ const release = await provider.publish({
139
+ filePath: '.pakta/output/android.ppk',
140
+ sourcemap: '.pakta/intermedia/android/index.bundlejs.map',
141
+ platform: 'android',
142
+ name: 'fix-001',
143
+ targets: 'targets.json',
144
+ });
145
+ if (!release.success) throw new Error(release.error);
146
+ ```
147
+
148
+ 返回 `CommandResult`,消费 `data` 前检查 `success`。完整接口见 [src/types.ts](./src/types.ts).
149
+
150
+ ## 环境与自动更新
151
+
152
+ | 变量 | 用途 |
153
+ | --- | --- |
154
+ | `RNU_SERVICE_URL` | 独立服务地址 |
155
+ | `PAKTA_API_TOKEN` | CI 个人访问令牌 |
156
+ | `NO_INTERACTIVE=true` | 关闭交互 |
157
+ | `RNU_LANG` | `zh`(默认)或 `en` |
158
+ | `RNU_DEBUG=1` | 输出错误堆栈 |
159
+ | `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` | 代理,支持小写形式 |
160
+ | `PAKTA_CACHE_DIR` | Hermes base 缓存目录 |
161
+ | `RNU_AUTO_UPDATE=0` | 关闭后台自动更新 |
162
+
163
+ 全局 CLI 在成功执行后可通过原包管理器后台更新,沿用 registry、认证、代理和全局目录配置。CI、本地依赖和 npx 安装不会被修改。也可设置 `RNU_DISABLE_AUTO_UPDATE=1` 关闭,或用 `RNU_AUTO_UPDATE_PACKAGE_MANAGER` 指定 npm、pnpm、yarn、bun。
164
+
165
+ 许可证:[MIT](./LICENSE)。
166
+
167
+ Copyright (c) 2026 Yoghourt Technology(BeiJing) Company Limited.