Skip to content

Commit 1503b5a

Browse files
committed
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.
1 parent 6e0f50e commit 1503b5a

File tree

8 files changed

+78
-15
lines changed

8 files changed

+78
-15
lines changed

.babelrc

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ 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

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ 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 文件信息

cli.json

Lines changed: 13 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": {

src/locales/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
131131
usageParseIpa: 'Usage: cresc parseIpa <ipa file>',
132132
usageUnderDevelopment: 'Usage is under development now.',
133133
usageUploadApk: 'Usage: cresc uploadApk <apk file>',
134+
usageUploadAab:
135+
'Usage: cresc uploadAab <aab file> [--includeAllSplits] [--splits <split names>]',
134136
usageUploadApp: 'Usage: cresc uploadApp <app file>',
135137
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
136138
versionBind:

src/locales/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export default {
123123
usageParseApp: '使用方法: pushy parseApp app后缀文件',
124124
usageParseIpa: '使用方法: pushy parseIpa ipa后缀文件',
125125
usageUploadApk: '使用方法: pushy uploadApk apk后缀文件',
126+
usageUploadAab:
127+
'使用方法: pushy uploadAab aab后缀文件 [--includeAllSplits] [--splits 分包名列表]',
126128
usageUploadApp: '使用方法: pushy uploadApp app后缀文件',
127129
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
128130
versionBind:

src/package.ts

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import { getAllPackages, post, uploadFile, doDelete } from './api';
2-
import { question, saveToLocal } from './utils';
3-
4-
import { getPlatform, getSelectedApp } from './app';
1+
import os from 'os';
2+
import path from 'path';
3+
import fs from 'fs-extra';
54
import Table from 'tty-table';
5+
import { doDelete, getAllPackages, post, uploadFile } from './api';
6+
import { getPlatform, getSelectedApp } from './app';
67
import type { Platform } from './types';
7-
import { getAabInfo, getApkInfo, getAppInfo, getIpaInfo } from './utils';
8+
import {
9+
getAabInfo,
10+
getApkInfo,
11+
getAppInfo,
12+
getIpaInfo,
13+
question,
14+
saveToLocal,
15+
} from './utils';
16+
import { AabParser } from './utils/app-info-parser/aab';
817
import { depVersions } from './utils/dep-versions';
918
import { getCommitInfo } from './utils/git';
10-
import { AabParser } from './utils/app-info-parser/aab';
1119
import { t } from './utils/i18n';
12-
import path from 'path';
1320

1421
export async function listPackage(appId: string) {
1522
const allPkgs = (await getAllPackages(appId)) || [];
@@ -144,6 +151,48 @@ export const packageCommands = {
144151
saveToLocal(fn, `${appId}/package/${id}.apk`);
145152
console.log(t('apkUploadSuccess', { id, version: versionName, buildTime }));
146153
},
154+
uploadAab: async ({
155+
args,
156+
options,
157+
}: {
158+
args: string[];
159+
options: Record<string, any>;
160+
}) => {
161+
const source = args[0];
162+
if (!source || !source.endsWith('.aab')) {
163+
throw new Error(t('usageUploadAab'));
164+
}
165+
166+
const output = path.join(
167+
os.tmpdir(),
168+
`${path.basename(source, path.extname(source))}-${Date.now()}.apk`,
169+
);
170+
171+
const includeAllSplits =
172+
options.includeAllSplits === true || options.includeAllSplits === 'true';
173+
const splits = options.splits
174+
? String(options.splits)
175+
.split(',')
176+
.map((item) => item.trim())
177+
.filter(Boolean)
178+
: null;
179+
180+
const parser = new AabParser(source);
181+
try {
182+
await parser.extractApk(output, {
183+
includeAllSplits,
184+
splits,
185+
});
186+
await packageCommands.uploadApk({
187+
args: [output],
188+
options,
189+
});
190+
} finally {
191+
if (await fs.pathExists(output)) {
192+
await fs.remove(output);
193+
}
194+
}
195+
},
147196
uploadApp: async ({
148197
args,
149198
options,

src/provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ export class CLIProviderImpl implements CLIProvider {
122122
case 'apk':
123123
await packageCommands.uploadApk(context);
124124
break;
125+
case 'aab':
126+
await packageCommands.uploadAab(context);
127+
break;
125128
case 'app':
126129
await packageCommands.uploadApp(context);
127130
break;

0 commit comments

Comments
 (0)