|
1 | 1 | import { getAllPackages, post, uploadFile, doDelete } from './api'; |
2 | 2 | import { question, saveToLocal } from './utils'; |
3 | | -import { t } from './utils/i18n'; |
4 | 3 |
|
5 | 4 | import { getPlatform, getSelectedApp } from './app'; |
6 | | - |
7 | 5 | import Table from 'tty-table'; |
8 | 6 | import type { Platform } from './types'; |
9 | | -import { getApkInfo, getAppInfo, getIpaInfo, getAabInfo } from './utils'; |
| 7 | +import { getAabInfo, getApkInfo, getAppInfo, getIpaInfo } from './utils'; |
10 | 8 | import { depVersions } from './utils/dep-versions'; |
11 | 9 | import { getCommitInfo } from './utils/git'; |
| 10 | +import AabParser from './utils/app-info-parser/aab'; |
| 11 | +import { t } from './utils/i18n'; |
| 12 | +import path from 'path'; |
12 | 13 |
|
13 | 14 | export async function listPackage(appId: string) { |
14 | 15 | const allPkgs = await getAllPackages(appId) || []; |
@@ -214,6 +215,42 @@ export const packageCommands = { |
214 | 215 | } |
215 | 216 | console.log(await getAabInfo(fn)); |
216 | 217 | }, |
| 218 | + extractApk: async ({ |
| 219 | + args, |
| 220 | + options, |
| 221 | + }: { |
| 222 | + args: string[]; |
| 223 | + options: Record<string, any>; |
| 224 | + }) => { |
| 225 | + const source = args[0]; |
| 226 | + if (!source || !source.endsWith('.aab')) { |
| 227 | + throw new Error(t('usageExtractApk')); |
| 228 | + } |
| 229 | + |
| 230 | + const output = |
| 231 | + options.output || |
| 232 | + path.join( |
| 233 | + path.dirname(source), |
| 234 | + `${path.basename(source, path.extname(source))}.apk`, |
| 235 | + ); |
| 236 | + |
| 237 | + const includeAllSplits = |
| 238 | + options.includeAllSplits === true || options.includeAllSplits === 'true'; |
| 239 | + const splits = options.splits |
| 240 | + ? String(options.splits) |
| 241 | + .split(',') |
| 242 | + .map((item) => item.trim()) |
| 243 | + .filter(Boolean) |
| 244 | + : null; |
| 245 | + |
| 246 | + const parser = new AabParser(source); |
| 247 | + await parser.extractApk(output, { |
| 248 | + includeAllSplits, |
| 249 | + splits, |
| 250 | + }); |
| 251 | + |
| 252 | + console.log(t('apkExtracted', { output })); |
| 253 | + }, |
217 | 254 | packages: async ({ options }: { options: { platform: Platform } }) => { |
218 | 255 | const platform = await getPlatform(options.platform); |
219 | 256 | const { appId } = await getSelectedApp(platform); |
|
0 commit comments