1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-11-07 09:53:39 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Enhance upload commands to support custom versioning and update documentation. Added version option to uploadIpa, uploadApk, and uploadApp commands. Updated README and localization files to reflect changes.

This commit is contained in:
sunnylqm
2025-08-22 10:09:37 +08:00
parent 7e7e555450
commit e6de3eeef3
10 changed files with 361 additions and 213 deletions

View File

@@ -130,4 +130,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
unnamed: '(Unnamed)',
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
usingCustomVersion: 'Using custom version: {{version}}',
};

View File

@@ -123,4 +123,5 @@ export default {
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
unnamed: '(未命名)',
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
usingCustomVersion: '使用自定义版本:{{version}}',
};

View File

@@ -23,9 +23,9 @@ export async function listPackage(appId: string) {
let versionInfo = '';
if (version) {
const versionObj = version as any;
versionInfo = t('boundTo', {
name: versionObj.name || version,
id: versionObj.id || version
versionInfo = t('boundTo', {
name: versionObj.name || version,
id: versionObj.id || version,
});
}
let output = pkg.name;
@@ -57,16 +57,19 @@ export async function choosePackage(appId: string) {
}
export const packageCommands = {
uploadIpa: async ({ args }: { args: string[] }) => {
uploadIpa: async ({
args,
options,
}: {
args: string[];
options: Record<string, any>;
}) => {
const fn = args[0];
if (!fn || !fn.endsWith('.ipa')) {
throw new Error(t('usageUploadIpa'));
}
const ipaInfo = await getIpaInfo(fn);
const {
versionName,
buildTime,
} = ipaInfo;
const { versionName: extractedVersionName, buildTime } = ipaInfo;
const appIdInPkg = (ipaInfo as any).appId;
const appKeyInPkg = (ipaInfo as any).appKey;
const { appId, appKey } = await getSelectedApp('ios');
@@ -79,6 +82,12 @@ export const packageCommands = {
throw new Error(t('appKeyMismatchIpa', { appKeyInPkg, appKey }));
}
// Use custom version if provided, otherwise use extracted version
const versionName = options.version || extractedVersionName;
if (options.version) {
console.log(t('usingCustomVersion', { version: versionName }));
}
const { hash } = await uploadFile(fn);
const { id } = await post(`/app/${appId}/package/create`, {
@@ -89,20 +98,21 @@ export const packageCommands = {
commit: await getCommitInfo(),
});
saveToLocal(fn, `${appId}/package/${id}.ipa`);
console.log(
t('ipaUploadSuccess', { id, version: versionName, buildTime }),
);
console.log(t('ipaUploadSuccess', { id, version: versionName, buildTime }));
},
uploadApk: async ({ args }: { args: string[] }) => {
uploadApk: async ({
args,
options,
}: {
args: string[];
options: Record<string, any>;
}) => {
const fn = args[0];
if (!fn || !fn.endsWith('.apk')) {
throw new Error(t('usageUploadApk'));
}
const apkInfo = await getApkInfo(fn);
const {
versionName,
buildTime,
} = apkInfo;
const { versionName: extractedVersionName, buildTime } = apkInfo;
const appIdInPkg = (apkInfo as any).appId;
const appKeyInPkg = (apkInfo as any).appKey;
const { appId, appKey } = await getSelectedApp('android');
@@ -115,6 +125,12 @@ export const packageCommands = {
throw new Error(t('appKeyMismatchApk', { appKeyInPkg, appKey }));
}
// Use custom version if provided, otherwise use extracted version
const versionName = options.version || extractedVersionName;
if (options.version) {
console.log(t('usingCustomVersion', { version: versionName }));
}
const { hash } = await uploadFile(fn);
const { id } = await post(`/app/${appId}/package/create`, {
@@ -125,20 +141,21 @@ export const packageCommands = {
commit: await getCommitInfo(),
});
saveToLocal(fn, `${appId}/package/${id}.apk`);
console.log(
t('apkUploadSuccess', { id, version: versionName, buildTime }),
);
console.log(t('apkUploadSuccess', { id, version: versionName, buildTime }));
},
uploadApp: async ({ args }: { args: string[] }) => {
uploadApp: async ({
args,
options,
}: {
args: string[];
options: Record<string, any>;
}) => {
const fn = args[0];
if (!fn || !fn.endsWith('.app')) {
throw new Error(t('usageUploadApp'));
}
const appInfo = await getAppInfo(fn);
const {
versionName,
buildTime,
} = appInfo;
const { versionName: extractedVersionName, buildTime } = appInfo;
const appIdInPkg = (appInfo as any).appId;
const appKeyInPkg = (appInfo as any).appKey;
const { appId, appKey } = await getSelectedApp('harmony');
@@ -151,6 +168,12 @@ export const packageCommands = {
throw new Error(t('appKeyMismatchApp', { appKeyInPkg, appKey }));
}
// Use custom version if provided, otherwise use extracted version
const versionName = options.version || extractedVersionName;
if (options.version) {
console.log(t('usingCustomVersion', { version: versionName }));
}
const { hash } = await uploadFile(fn);
const { id } = await post(`/app/${appId}/package/create`, {
@@ -161,9 +184,7 @@ export const packageCommands = {
commit: await getCommitInfo(),
});
saveToLocal(fn, `${appId}/package/${id}.app`);
console.log(
t('appUploadSuccess', { id, version: versionName, buildTime }),
);
console.log(t('appUploadSuccess', { id, version: versionName, buildTime }));
},
parseApp: async ({ args }: { args: string[] }) => {
const fn = args[0];

View File

@@ -110,7 +110,7 @@ export class CLIProviderImpl implements CLIProvider {
const context: CommandContext = {
args: [filePath],
options: { platform, appId },
options: { platform, appId, version: options.version },
};
const { packageCommands } = await import('./package');

View File

@@ -85,6 +85,7 @@ export interface UploadOptions {
platform?: Platform;
filePath: string;
appId?: string;
version?: string;
}
export interface WorkflowStep {