Skip to content

Commit 45ad9bb

Browse files
authored
Feat/aab (#18)
* cleanup * extractapk # Conflicts: # src/package.ts * use node bundletool * Update version to 2.6.0 in package.json and enhance AAB parsing error messages with localized strings for better user feedback. * Refactor app-info-parser: migrate ApkParser and AppParser to TypeScript, remove deprecated apk.js and app.js files, and update import statements for consistency. * Refactor app-info-parser: migrate utility functions to TypeScript, remove deprecated utils.js, and enhance AAB and APK parsing with improved error handling and resource mapping. * Implement AAB upload functionality: add uploadAab command to handle AAB file uploads, including options for split management and update documentation in README files. Remove deprecated .babelrc configuration. * Enhance AAB parsing: add localized download hint for bundletool and improve error handling in runCommand function. Refactor command execution to support stdio options.
1 parent 59ee357 commit 45ad9bb

File tree

31 files changed

+1352
-1298
lines changed

31 files changed

+1352
-1298
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
contents: read
1515
id-token: write
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
- uses: oven-sh/setup-bun@v2
1919
# Setup .npmrc file to publish to npm
20-
- uses: actions/setup-node@v4
20+
- uses: actions/setup-node@v6
2121
with:
2222
node-version: '24.x'
2323
registry-url: 'https://registry.npmjs.org'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ Each workflow step contains:
223223

224224
- `uploadIpa`: Upload IPA files (supports `--version` to override extracted version)
225225
- `uploadApk`: Upload APK files (supports `--version` to override extracted version)
226+
- `uploadAab`: Upload AAB files (converted to APK, supports `--version`, `--includeAllSplits`, `--splits`)
226227
- `uploadApp`: Upload APP files (supports `--version` to override extracted version)
227228
- `parseApp`: Parse APP file information
228229
- `parseIpa`: Parse IPA file information
229230
- `parseApk`: Parse APK file information
231+
- `extractApk`: Extract a universal APK from an AAB (supports `--output`, `--includeAllSplits`, `--splits`)
230232
- `packages`: List packages
231233

232234
### User Module (`user`)

README.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,12 @@ const workflowResult = await moduleManager.executeWorkflow('my-workflow', {
221221

222222
- `uploadIpa`: 上传 IPA 文件(支持 `--version` 参数覆盖提取的版本)
223223
- `uploadApk`: 上传 APK 文件(支持 `--version` 参数覆盖提取的版本)
224+
- `uploadAab`: 上传 AAB 文件(转换为 APK,支持 `--version``--includeAllSplits``--splits`
224225
- `uploadApp`: 上传 APP 文件(支持 `--version` 参数覆盖提取的版本)
225226
- `parseApp`: 解析 APP 文件信息
226227
- `parseIpa`: 解析 IPA 文件信息
227228
- `parseApk`: 解析 APK 文件信息
229+
- `extractApk`: 从 AAB 提取通用 APK(支持 `--output``--includeAllSplits``--splits`
228230
- `packages`: 列出包
229231

230232
### User 模块 (`user`)

cli.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
}
4646
}
4747
},
48+
"uploadAab": {
49+
"options": {
50+
"version": {
51+
"hasValue": true
52+
},
53+
"includeAllSplits": {
54+
"default": false
55+
},
56+
"splits": {
57+
"hasValue": true
58+
}
59+
}
60+
},
4861
"uploadApp": {
4962
"options": {
5063
"version": {
@@ -56,6 +69,19 @@
5669
"parseIpa": {},
5770
"parseApk": {},
5871
"parseAab": {},
72+
"extractApk": {
73+
"options": {
74+
"output": {
75+
"hasValue": true
76+
},
77+
"includeAllSplits": {
78+
"default": false
79+
},
80+
"splits": {
81+
"hasValue": true
82+
}
83+
}
84+
},
5985
"packages": {
6086
"options": {
6187
"platform": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {

src/api.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@ import FormData from 'form-data';
66
import fetch from 'node-fetch';
77
import ProgressBar from 'progress';
88
import tcpp from 'tcp-ping';
9+
import { getBaseUrl } from 'utils/http-helper';
910
import packageJson from '../package.json';
1011
import type { Package, Session } from './types';
11-
import {
12-
credentialFile,
13-
pricingPageUrl,
14-
} from './utils/constants';
12+
import { credentialFile, pricingPageUrl } from './utils/constants';
1513
import { t } from './utils/i18n';
16-
import { getBaseUrl } from 'utils/http-helper';
1714

1815
const tcpPing = util.promisify(tcpp.ping);
1916

2017
let session: Session | undefined;
2118
let savedSession: Session | undefined;
2219

23-
2420
const userAgent = `react-native-update-cli/${packageJson.version}`;
2521

2622
export const getSession = () => session;

src/locales/en.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ export default {
22
addedToGitignore: 'Added {{line}} to .gitignore',
33
androidCrunchPngsWarning:
44
'The crunchPngs option of android seems not disabled (Please ignore this warning if already disabled), which may cause abnormal consumption of mobile network traffic. Please refer to https://cresc.dev/docs/getting-started#disable-crunchpngs-on-android \n',
5+
aabOpenApksFailed: 'Failed to open generated .apks file',
6+
aabReadUniversalApkFailed: 'Failed to read universal.apk',
7+
aabUniversalApkNotFound: 'universal.apk not found in generated .apks',
8+
aabBundletoolDownloadHint:
9+
'bundletool not found. Downloading node-bundletool via npx (first run may take a while).',
10+
aabManifestNotFound:
11+
"AndroidManifest.xml can't be found in AAB base/manifest/",
12+
aabParseResourcesWarning:
13+
'[Warning] Failed to parse resources.arsc: {{error}}',
14+
aabParseFailed: 'Failed to parse AAB: {{error}}',
15+
aabParseManifestError: 'Parse AndroidManifest.xml error: {{error}}',
16+
aabParseResourcesError: 'Parser resources.arsc error: {{error}}',
517
appId: 'App ID',
618
appIdMismatchApk:
719
'App ID mismatch! Current APK: {{appIdInPkg}}, current update.json: {{appId}}',
@@ -116,10 +128,14 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
116128
usageDiff: 'Usage: cresc {{command}} <origin> <next>',
117129
usageParseApk: 'Usage: cresc parseApk <apk file>',
118130
usageParseAab: 'Usage: cresc parseAab <aab file>',
131+
usageExtractApk:
132+
'Usage: cresc extractApk <aab file> [--output <apk file>] [--includeAllSplits] [--splits <split names>]',
119133
usageParseApp: 'Usage: cresc parseApp <app file>',
120134
usageParseIpa: 'Usage: cresc parseIpa <ipa file>',
121135
usageUnderDevelopment: 'Usage is under development now.',
122136
usageUploadApk: 'Usage: cresc uploadApk <apk file>',
137+
usageUploadAab:
138+
'Usage: cresc uploadAab <aab file> [--includeAllSplits] [--splits <split names>]',
123139
usageUploadApp: 'Usage: cresc uploadApp <app file>',
124140
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
125141
versionBind:
@@ -147,4 +163,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
147163
'This function needs "node-bsdiff". Please run "{{scriptName}} install node-bsdiff" to install',
148164
nodeHdiffpatchRequired:
149165
'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
166+
apkExtracted: 'APK extracted to {{output}}',
150167
};

src/locales/zh.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ export default {
22
addedToGitignore: '已将 {{line}} 添加到 .gitignore',
33
androidCrunchPngsWarning:
44
'android 的 crunchPngs 选项似乎尚未禁用(如已禁用则请忽略此提示),这可能导致热更包体积异常增大,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n',
5+
aabOpenApksFailed: '无法打开生成的 .apks 文件',
6+
aabReadUniversalApkFailed: '无法读取 universal.apk',
7+
aabUniversalApkNotFound: '在生成的 .apks 中未找到 universal.apk',
8+
aabBundletoolDownloadHint:
9+
'未找到 bundletool,正在通过 npx 下载 node-bundletool(首次下载可能需要一些时间)。',
10+
aabManifestNotFound: '在 AAB 的 base/manifest/ 中找不到 AndroidManifest.xml',
11+
aabParseResourcesWarning: '[警告] 解析 resources.arsc 失败:{{error}}',
12+
aabParseFailed: '解析 AAB 失败:{{error}}',
13+
aabParseManifestError: '解析 AndroidManifest.xml 出错:{{error}}',
14+
aabParseResourcesError: '解析 resources.arsc 出错:{{error}}',
515
appId: '应用 id',
616
appIdMismatchApk:
717
'appId不匹配!当前apk: {{appIdInPkg}}, 当前update.json: {{appId}}',
@@ -110,9 +120,13 @@ export default {
110120
usageDiff: '用法:pushy {{command}} <origin> <next>',
111121
usageParseApk: '使用方法: pushy parseApk apk后缀文件',
112122
usageParseAab: '使用方法: pushy parseAab aab后缀文件',
123+
usageExtractApk:
124+
'使用方法: pushy extractApk aab后缀文件 [--output apk文件] [--includeAllSplits] [--splits 分包名列表]',
113125
usageParseApp: '使用方法: pushy parseApp app后缀文件',
114126
usageParseIpa: '使用方法: pushy parseIpa ipa后缀文件',
115127
usageUploadApk: '使用方法: pushy uploadApk apk后缀文件',
128+
usageUploadAab:
129+
'使用方法: pushy uploadAab aab后缀文件 [--includeAllSplits] [--splits 分包名列表]',
116130
usageUploadApp: '使用方法: pushy uploadApp app后缀文件',
117131
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
118132
versionBind:
@@ -138,4 +152,5 @@ export default {
138152
'此功能需要 "node-bsdiff"。请运行 "{{scriptName}} install node-bsdiff" 来安装',
139153
nodeHdiffpatchRequired:
140154
'此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
155+
apkExtracted: 'APK 已提取到 {{output}}',
141156
};

src/modules/version-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CLIModule} from '../types';
1+
import type { CLIModule } from '../types';
22

33
export const versionModule: CLIModule = {
44
name: 'version',

0 commit comments

Comments
 (0)