From 2cfe451db56c433d32a3b9ee06cda8648cf46ddd Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Fri, 20 Jun 2025 20:32:06 +0800 Subject: [PATCH] one in all command --- cli.json | 42 ++++++++++++++++++++++++++++++++++ package.json | 2 +- src/bundle.ts | 16 ++++++++++++- src/versions.ts | 61 ++++++++++++++++++++++++++++++++++--------------- 4 files changed, 101 insertions(+), 20 deletions(-) diff --git a/cli.json b/cli.json index f309961..1244446 100644 --- a/cli.json +++ b/cli.json @@ -57,6 +57,27 @@ }, "metaInfo": { "hasValue": true + }, + "packageId": { + "hasValue": true + }, + "packageVersion": { + "hasValue": true + }, + "minPackageVersion": { + "hasValue": true + }, + "maxPackageVersion": { + "hasValue": true + }, + "packageVersionRange": { + "hasValue": true + }, + "rollout": { + "hasValue": true + }, + "dryRun": { + "default": false } } }, @@ -175,6 +196,27 @@ "metaInfo": { "hasValue": true, "description": "Meta information for publishing" + }, + "packageId": { + "hasValue": true + }, + "packageVersion": { + "hasValue": true + }, + "minPackageVersion": { + "hasValue": true + }, + "maxPackageVersion": { + "hasValue": true + }, + "packageVersionRange": { + "hasValue": true + }, + "rollout": { + "hasValue": true + }, + "dryRun": { + "default": false } } }, diff --git a/package.json b/package.json index cdae967..0903626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update-cli", - "version": "1.45.6", + "version": "1.46.0", "description": "command line tool for react-native-update (remote updates for react native)", "main": "index.js", "bin": { diff --git a/src/bundle.ts b/src/bundle.ts index 63bab63..2becaf9 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -19,7 +19,7 @@ import { t } from './utils/i18n'; import { tempDir } from './utils/constants'; import { checkLockFiles } from './utils/check-lockfile'; import { addGitIgnore } from './utils/add-gitignore'; -import { commands as versionCommands } from './versions'; +import { versionCommands } from './versions'; type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer; @@ -926,6 +926,13 @@ export const commands = { name, description, metaInfo, + packageId, + packageVersion, + minPackageVersion, + maxPackageVersion, + packageVersionRange, + rollout, + dryRun, } = translateOptions({ ...options, tempDir, @@ -974,6 +981,13 @@ export const commands = { name, description, metaInfo, + packageId, + packageVersion, + minPackageVersion, + maxPackageVersion, + packageVersionRange, + rollout, + dryRun: Boolean(dryRun), }, }); diff --git a/src/versions.ts b/src/versions.ts index 4e459b3..d04fb34 100644 --- a/src/versions.ts +++ b/src/versions.ts @@ -10,7 +10,8 @@ import type { Package, Platform, Version } from 'types'; import { satisfies } from 'compare-versions'; import chalk from 'chalk'; -interface CommandOptions { +interface VersionCommandOptions { + appId?: string; name?: string; description?: string; metaInfo?: string; @@ -156,13 +157,13 @@ export const bindVersionToPackages = async ({ console.log(t('operationComplete', { count: pkgs.length })); }; -export const commands = { +export const versionCommands = { publish: async function ({ args, options, }: { args: string[]; - options: CommandOptions; + options: VersionCommandOptions; }) { const fn = args[0]; const { name, description, metaInfo } = options; @@ -191,26 +192,52 @@ export const commands = { saveToLocal(fn, `${appId}/ppk/${id}.ppk`); console.log(t('packageUploadSuccess', { id })); - const v = await question(t('updateNativePackageQuestion')); - if (v.toLowerCase() === 'y') { - await this.update({ args: [], options: { versionId: id, platform } }); + const { + packageId, + packageVersion, + packageVersionRange, + minPackageVersion, + maxPackageVersion, + rollout, + dryRun, + } = options; + + if ( + packageId || + packageVersion || + packageVersionRange || + minPackageVersion || + maxPackageVersion + ) { + await this.update({ + options: { + versionId: id, + platform, + packageId, + packageVersion, + packageVersionRange, + minPackageVersion, + maxPackageVersion, + rollout, + dryRun, + }, + }); + } else { + const q = await question(t('updateNativePackageQuestion')); + if (q.toLowerCase() === 'y') { + await this.update({ options: { versionId: id, platform } }); + } } return versionName; }, - versions: async ({ options }: { options: CommandOptions }) => { + versions: async ({ options }: { options: VersionCommandOptions }) => { const platform = await getPlatform(options.platform); const { appId } = await getSelectedApp(platform); await listVersions(appId); }, - update: async ({ - args, - options, - }: { - args: string[]; - options: CommandOptions; - }) => { + update: async ({ options }: { options: VersionCommandOptions }) => { const platform = await getPlatform(options.platform); - const { appId } = await getSelectedApp(platform); + const appId = options.appId || (await getSelectedApp(platform)).appId; let versionId = options.versionId || (await chooseVersion(appId)).id; if (versionId === 'null') { versionId = undefined; @@ -309,11 +336,9 @@ export const commands = { }); }, updateVersionInfo: async ({ - args, options, }: { - args: string[]; - options: CommandOptions; + options: VersionCommandOptions; }) => { const platform = await getPlatform(options.platform); const { appId } = await getSelectedApp(platform);