mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 18:06:10 +08:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2cfe451db5 | ||
![]() |
c7d0aadbf2 | ||
![]() |
2e37d6f1c7 | ||
![]() |
6e7d5de82e | ||
![]() |
3266f09644 | ||
![]() |
848f528625 | ||
![]() |
18d772b1bc |
3
bun.lock
3
bun.lock
@@ -10,6 +10,7 @@
|
|||||||
"chalk": "4",
|
"chalk": "4",
|
||||||
"cli-arguments": "^0.2.1",
|
"cli-arguments": "^0.2.1",
|
||||||
"commander": "^13",
|
"commander": "^13",
|
||||||
|
"compare-versions": "^6.1.1",
|
||||||
"filesize-parser": "^1.5.1",
|
"filesize-parser": "^1.5.1",
|
||||||
"form-data": "^4.0.2",
|
"form-data": "^4.0.2",
|
||||||
"fs-extra": "8",
|
"fs-extra": "8",
|
||||||
@@ -278,6 +279,8 @@
|
|||||||
|
|
||||||
"commander": ["commander@13.1.0", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
|
"commander": ["commander@13.1.0", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
|
||||||
|
|
||||||
|
"compare-versions": ["compare-versions@6.1.1", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],
|
||||||
|
|
||||||
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
|
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
|
||||||
|
|
||||||
"content-disposition": ["content-disposition@0.5.4", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ=="],
|
"content-disposition": ["content-disposition@0.5.4", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ=="],
|
||||||
|
47
cli.json
47
cli.json
@@ -57,6 +57,27 @@
|
|||||||
},
|
},
|
||||||
"metaInfo": {
|
"metaInfo": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageId": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"minPackageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"maxPackageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageVersionRange": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"rollout": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"dryRun": {
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -87,11 +108,14 @@
|
|||||||
"maxPackageVersion": {
|
"maxPackageVersion": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
},
|
},
|
||||||
"semverRange": {
|
"packageVersionRange": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
},
|
},
|
||||||
"rollout": {
|
"rollout": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"dryRun": {
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -172,6 +196,27 @@
|
|||||||
"metaInfo": {
|
"metaInfo": {
|
||||||
"hasValue": true,
|
"hasValue": true,
|
||||||
"description": "Meta information for publishing"
|
"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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.45.1",
|
"version": "1.46.0",
|
||||||
"description": "command line tool for react-native-update (remote updates for react native)",
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
"chalk": "4",
|
"chalk": "4",
|
||||||
"cli-arguments": "^0.2.1",
|
"cli-arguments": "^0.2.1",
|
||||||
"commander": "^13",
|
"commander": "^13",
|
||||||
|
"compare-versions": "^6.1.1",
|
||||||
"filesize-parser": "^1.5.1",
|
"filesize-parser": "^1.5.1",
|
||||||
"form-data": "^4.0.2",
|
"form-data": "^4.0.2",
|
||||||
"fs-extra": "8",
|
"fs-extra": "8",
|
||||||
|
@@ -8,9 +8,9 @@ import {
|
|||||||
type ZipFile as YauzlZipFile,
|
type ZipFile as YauzlZipFile,
|
||||||
} from 'yauzl';
|
} from 'yauzl';
|
||||||
import { question, checkPlugins } from './utils';
|
import { question, checkPlugins } from './utils';
|
||||||
import { checkPlatform, getPlatform } from './app';
|
import { getPlatform } from './app';
|
||||||
import { spawn, spawnSync } from 'child_process';
|
import { spawn, spawnSync } from 'child_process';
|
||||||
import semverSatisfies from 'semver/functions/satisfies';
|
import { satisfies } from 'compare-versions';
|
||||||
const g2js = require('gradle-to-js/lib/parser');
|
const g2js = require('gradle-to-js/lib/parser');
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
const properties = require('properties');
|
const properties = require('properties');
|
||||||
@@ -19,7 +19,7 @@ import { t } from './utils/i18n';
|
|||||||
import { tempDir } from './utils/constants';
|
import { tempDir } from './utils/constants';
|
||||||
import { checkLockFiles } from './utils/check-lockfile';
|
import { checkLockFiles } from './utils/check-lockfile';
|
||||||
import { addGitIgnore } from './utils/add-gitignore';
|
import { addGitIgnore } from './utils/add-gitignore';
|
||||||
import { commands as versionCommands } from './versions';
|
import { versionCommands } from './versions';
|
||||||
|
|
||||||
type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
|
type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ async function runReactNativeBundleCommand({
|
|||||||
.toString(),
|
.toString(),
|
||||||
).version;
|
).version;
|
||||||
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
|
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
|
||||||
if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
|
if (satisfies(expoCliVersion, '>= 0.10.17')) {
|
||||||
usingExpo = true;
|
usingExpo = true;
|
||||||
} else {
|
} else {
|
||||||
cliPath = undefined;
|
cliPath = undefined;
|
||||||
@@ -149,6 +149,14 @@ async function runReactNativeBundleCommand({
|
|||||||
const bundleParams = await checkPlugins();
|
const bundleParams = await checkPlugins();
|
||||||
const isSentry = bundleParams.sentry;
|
const isSentry = bundleParams.sentry;
|
||||||
|
|
||||||
|
if (isSentry) {
|
||||||
|
if (platform === 'ios') {
|
||||||
|
process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
|
||||||
|
} else if (platform === 'android') {
|
||||||
|
process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let bundleCommand = 'bundle';
|
let bundleCommand = 'bundle';
|
||||||
if (usingExpo) {
|
if (usingExpo) {
|
||||||
bundleCommand = 'export:embed';
|
bundleCommand = 'export:embed';
|
||||||
@@ -918,6 +926,13 @@ export const commands = {
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
metaInfo,
|
metaInfo,
|
||||||
|
packageId,
|
||||||
|
packageVersion,
|
||||||
|
minPackageVersion,
|
||||||
|
maxPackageVersion,
|
||||||
|
packageVersionRange,
|
||||||
|
rollout,
|
||||||
|
dryRun,
|
||||||
} = translateOptions({
|
} = translateOptions({
|
||||||
...options,
|
...options,
|
||||||
tempDir,
|
tempDir,
|
||||||
@@ -966,6 +981,13 @@ export const commands = {
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
metaInfo,
|
metaInfo,
|
||||||
|
packageId,
|
||||||
|
packageVersion,
|
||||||
|
minPackageVersion,
|
||||||
|
maxPackageVersion,
|
||||||
|
packageVersionRange,
|
||||||
|
rollout,
|
||||||
|
dryRun: Boolean(dryRun),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|||||||
rnuVersionNotFound:
|
rnuVersionNotFound:
|
||||||
'react-native-update: Cannot get the version number. Please run the command in the project directory',
|
'react-native-update: Cannot get the version number. Please run the command in the project directory',
|
||||||
rolloutConfigSet:
|
rolloutConfigSet:
|
||||||
'Set {{rollout}}% rollout for version {{version}} on native version(s) {{versions}}',
|
'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
|
||||||
rolloutRangeError: 'rollout must be an integer between 1-100',
|
rolloutRangeError: 'rollout must be an integer between 1-100',
|
||||||
runningHermesc: 'Running hermesc: {{- command}} {{- args}}',
|
runningHermesc: 'Running hermesc: {{- command}} {{- args}}',
|
||||||
sentryCliNotFound:
|
sentryCliNotFound:
|
||||||
@@ -122,11 +122,12 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|||||||
usageUploadApp: 'Usage: cresc uploadApp <app file>',
|
usageUploadApp: 'Usage: cresc uploadApp <app file>',
|
||||||
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
|
usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
|
||||||
versionBind:
|
versionBind:
|
||||||
'Bound version {{version}} to native version {{nativeVersion}} (id: {{id}})',
|
'Bound hot update {{version}} to native version {{nativeVersion}} (id: {{id}})',
|
||||||
welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
|
welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
|
||||||
versionNameQuestion: 'Enter version name:',
|
versionNameQuestion: 'Enter OTA update name:',
|
||||||
versionDescriptionQuestion: 'Enter version description:',
|
versionDescriptionQuestion: 'Enter OTA update description:',
|
||||||
versionMetaInfoQuestion: 'Enter custom meta info:',
|
versionMetaInfoQuestion: 'Enter custom meta info:',
|
||||||
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
|
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
|
||||||
unnamed: '(Unnamed)',
|
unnamed: '(Unnamed)',
|
||||||
|
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
|
||||||
};
|
};
|
||||||
|
@@ -96,7 +96,7 @@ export default {
|
|||||||
rnuVersionNotFound:
|
rnuVersionNotFound:
|
||||||
'react-native-update: 无法获取版本号。请在项目目录中运行命令',
|
'react-native-update: 无法获取版本号。请在项目目录中运行命令',
|
||||||
rolloutConfigSet:
|
rolloutConfigSet:
|
||||||
'已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更版本 {{version}}',
|
'已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
|
||||||
rolloutRangeError: 'rollout 必须是 1-100 的整数',
|
rolloutRangeError: 'rollout 必须是 1-100 的整数',
|
||||||
runningHermesc: '运行 hermesc:{{- command}} {{- args}}',
|
runningHermesc: '运行 hermesc:{{- command}} {{- args}}',
|
||||||
sentryCliNotFound: '无法找到 Sentry CLI 工具,请确保已正确安装 @sentry/cli',
|
sentryCliNotFound: '无法找到 Sentry CLI 工具,请确保已正确安装 @sentry/cli',
|
||||||
@@ -115,11 +115,12 @@ export default {
|
|||||||
usageUploadApp: '使用方法: pushy uploadApp app后缀文件',
|
usageUploadApp: '使用方法: pushy uploadApp app后缀文件',
|
||||||
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
|
usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
|
||||||
versionBind:
|
versionBind:
|
||||||
'已将热更版本 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
|
'已将热更包 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
|
||||||
welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
|
welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
|
||||||
versionNameQuestion: '输入版本名称:',
|
versionNameQuestion: '输入版本名称:',
|
||||||
versionDescriptionQuestion: '输入版本描述:',
|
versionDescriptionQuestion: '输入版本描述:',
|
||||||
versionMetaInfoQuestion: '输入自定义的 meta info:',
|
versionMetaInfoQuestion: '输入自定义的 meta info:',
|
||||||
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
|
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
|
||||||
unnamed: '(未命名)',
|
unnamed: '(未命名)',
|
||||||
|
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
|
||||||
};
|
};
|
||||||
|
@@ -2,7 +2,7 @@ import { get, getAllPackages, post, uploadFile } from './api';
|
|||||||
import { question, saveToLocal } from './utils';
|
import { question, saveToLocal } from './utils';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
|
|
||||||
import { checkPlatform, getPlatform, getSelectedApp } from './app';
|
import { getPlatform, getSelectedApp } from './app';
|
||||||
|
|
||||||
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
|
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
|
||||||
import Table from 'tty-table';
|
import Table from 'tty-table';
|
||||||
|
@@ -3,7 +3,7 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import pkg from '../../package.json';
|
import pkg from '../../package.json';
|
||||||
import AppInfoParser from './app-info-parser';
|
import AppInfoParser from './app-info-parser';
|
||||||
import semverSatisfies from 'semver/functions/satisfies';
|
import { satisfies } from 'compare-versions';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import latestVersion from '../utils/latest-version';
|
import latestVersion from '../utils/latest-version';
|
||||||
import { checkPlugins } from './check-plugin';
|
import { checkPlugins } from './check-plugin';
|
||||||
@@ -189,24 +189,24 @@ export async function printVersionCommand() {
|
|||||||
: '';
|
: '';
|
||||||
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
|
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
|
||||||
if (IS_CRESC) {
|
if (IS_CRESC) {
|
||||||
if (semverSatisfies(rnuVersion, '<10.27.0')) {
|
if (satisfies(rnuVersion, '<10.27.0')) {
|
||||||
console.error(
|
console.error(
|
||||||
'Unsupported version, please update to the latest version: npm i react-native-update@latest',
|
'Unsupported version, please update to the latest version: npm i react-native-update@latest',
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (semverSatisfies(rnuVersion, '<8.5.2')) {
|
if (satisfies(rnuVersion, '<8.5.2')) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
||||||
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
||||||
);
|
);
|
||||||
} else if (semverSatisfies(rnuVersion, '9.0.0 - 9.2.1')) {
|
} else if (satisfies(rnuVersion, '9.0.0 - 9.2.1')) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
|
`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
|
||||||
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
||||||
);
|
);
|
||||||
} else if (semverSatisfies(rnuVersion, '10.0.0 - 10.17.0')) {
|
} else if (satisfies(rnuVersion, '10.0.0 - 10.17.0')) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
|
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
|
||||||
);
|
);
|
||||||
|
111
src/versions.ts
111
src/versions.ts
@@ -7,9 +7,11 @@ import { choosePackage } from './package';
|
|||||||
import { depVersions } from './utils/dep-versions';
|
import { depVersions } from './utils/dep-versions';
|
||||||
import { getCommitInfo } from './utils/git';
|
import { getCommitInfo } from './utils/git';
|
||||||
import type { Package, Platform, Version } from 'types';
|
import type { Package, Platform, Version } from 'types';
|
||||||
import semverSatisfies from 'semver/functions/satisfies';
|
import { satisfies } from 'compare-versions';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
interface CommandOptions {
|
interface VersionCommandOptions {
|
||||||
|
appId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
metaInfo?: string;
|
metaInfo?: string;
|
||||||
@@ -19,8 +21,9 @@ interface CommandOptions {
|
|||||||
packageVersion?: string;
|
packageVersion?: string;
|
||||||
minPackageVersion?: string;
|
minPackageVersion?: string;
|
||||||
maxPackageVersion?: string;
|
maxPackageVersion?: string;
|
||||||
semverRange?: string;
|
packageVersionRange?: string;
|
||||||
rollout?: string;
|
rollout?: string;
|
||||||
|
dryRun?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showVersion(appId: string, offset: number) {
|
async function showVersion(appId: string, offset: number) {
|
||||||
@@ -107,22 +110,29 @@ export const bindVersionToPackages = async ({
|
|||||||
versionId,
|
versionId,
|
||||||
pkgs,
|
pkgs,
|
||||||
rollout,
|
rollout,
|
||||||
|
dryRun,
|
||||||
}: {
|
}: {
|
||||||
appId: string;
|
appId: string;
|
||||||
versionId: string;
|
versionId: string;
|
||||||
pkgs: Package[];
|
pkgs: Package[];
|
||||||
rollout?: number;
|
rollout?: number;
|
||||||
|
dryRun?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
if (dryRun) {
|
||||||
|
console.log(chalk.yellow(t('dryRun')));
|
||||||
|
}
|
||||||
if (rollout !== undefined) {
|
if (rollout !== undefined) {
|
||||||
const rolloutConfig: Record<string, number> = {};
|
const rolloutConfig: Record<string, number> = {};
|
||||||
for (const pkg of pkgs) {
|
for (const pkg of pkgs) {
|
||||||
rolloutConfig[pkg.name] = rollout;
|
rolloutConfig[pkg.name] = rollout;
|
||||||
}
|
}
|
||||||
await put(`/app/${appId}/version/${versionId}`, {
|
if (!dryRun) {
|
||||||
config: {
|
await put(`/app/${appId}/version/${versionId}`, {
|
||||||
rollout: rolloutConfig,
|
config: {
|
||||||
},
|
rollout: rolloutConfig,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
console.log(
|
console.log(
|
||||||
`${t('rolloutConfigSet', {
|
`${t('rolloutConfigSet', {
|
||||||
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
||||||
@@ -131,9 +141,11 @@ export const bindVersionToPackages = async ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const pkg of pkgs) {
|
for (const pkg of pkgs) {
|
||||||
await put(`/app/${appId}/package/${pkg.id}`, {
|
if (!dryRun) {
|
||||||
versionId,
|
await put(`/app/${appId}/package/${pkg.id}`, {
|
||||||
});
|
versionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
console.log(
|
console.log(
|
||||||
`${t('versionBind', {
|
`${t('versionBind', {
|
||||||
version: versionId,
|
version: versionId,
|
||||||
@@ -145,13 +157,13 @@ export const bindVersionToPackages = async ({
|
|||||||
console.log(t('operationComplete', { count: pkgs.length }));
|
console.log(t('operationComplete', { count: pkgs.length }));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const commands = {
|
export const versionCommands = {
|
||||||
publish: async function ({
|
publish: async function ({
|
||||||
args,
|
args,
|
||||||
options,
|
options,
|
||||||
}: {
|
}: {
|
||||||
args: string[];
|
args: string[];
|
||||||
options: CommandOptions;
|
options: VersionCommandOptions;
|
||||||
}) {
|
}) {
|
||||||
const fn = args[0];
|
const fn = args[0];
|
||||||
const { name, description, metaInfo } = options;
|
const { name, description, metaInfo } = options;
|
||||||
@@ -170,7 +182,8 @@ export const commands = {
|
|||||||
const { id } = await post(`/app/${appId}/version/create`, {
|
const { id } = await post(`/app/${appId}/version/create`, {
|
||||||
name: versionName,
|
name: versionName,
|
||||||
hash,
|
hash,
|
||||||
description: description || (await question(t('versionDescriptionQuestion'))),
|
description:
|
||||||
|
description || (await question(t('versionDescriptionQuestion'))),
|
||||||
metaInfo: metaInfo || (await question(t('versionMetaInfoQuestion'))),
|
metaInfo: metaInfo || (await question(t('versionMetaInfoQuestion'))),
|
||||||
deps: depVersions,
|
deps: depVersions,
|
||||||
commit: await getCommitInfo(),
|
commit: await getCommitInfo(),
|
||||||
@@ -179,26 +192,52 @@ export const commands = {
|
|||||||
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
|
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
|
||||||
console.log(t('packageUploadSuccess', { id }));
|
console.log(t('packageUploadSuccess', { id }));
|
||||||
|
|
||||||
const v = await question(t('updateNativePackageQuestion'));
|
const {
|
||||||
if (v.toLowerCase() === 'y') {
|
packageId,
|
||||||
await this.update({ args: [], options: { versionId: id, platform } });
|
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;
|
return versionName;
|
||||||
},
|
},
|
||||||
versions: async ({ options }: { options: CommandOptions }) => {
|
versions: async ({ options }: { options: VersionCommandOptions }) => {
|
||||||
const platform = await getPlatform(options.platform);
|
const platform = await getPlatform(options.platform);
|
||||||
const { appId } = await getSelectedApp(platform);
|
const { appId } = await getSelectedApp(platform);
|
||||||
await listVersions(appId);
|
await listVersions(appId);
|
||||||
},
|
},
|
||||||
update: async ({
|
update: async ({ options }: { options: VersionCommandOptions }) => {
|
||||||
args,
|
|
||||||
options,
|
|
||||||
}: {
|
|
||||||
args: string[];
|
|
||||||
options: CommandOptions;
|
|
||||||
}) => {
|
|
||||||
const platform = await getPlatform(options.platform);
|
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;
|
let versionId = options.versionId || (await chooseVersion(appId)).id;
|
||||||
if (versionId === 'null') {
|
if (versionId === 'null') {
|
||||||
versionId = undefined;
|
versionId = undefined;
|
||||||
@@ -208,7 +247,7 @@ export const commands = {
|
|||||||
let pkgVersion = options.packageVersion;
|
let pkgVersion = options.packageVersion;
|
||||||
let minPkgVersion = options.minPackageVersion;
|
let minPkgVersion = options.minPackageVersion;
|
||||||
let maxPkgVersion = options.maxPackageVersion;
|
let maxPkgVersion = options.maxPackageVersion;
|
||||||
let semverRange = options.semverRange;
|
let packageVersionRange = options.packageVersionRange;
|
||||||
let rollout: number | undefined = undefined;
|
let rollout: number | undefined = undefined;
|
||||||
|
|
||||||
if (options.rollout !== undefined) {
|
if (options.rollout !== undefined) {
|
||||||
@@ -233,7 +272,7 @@ export const commands = {
|
|||||||
if (minPkgVersion) {
|
if (minPkgVersion) {
|
||||||
minPkgVersion = String(minPkgVersion).trim();
|
minPkgVersion = String(minPkgVersion).trim();
|
||||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||||
semverSatisfies(pkg.name, `>=${minPkgVersion}`),
|
satisfies(pkg.name, `>=${minPkgVersion}`),
|
||||||
);
|
);
|
||||||
if (pkgsToBind.length === 0) {
|
if (pkgsToBind.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -243,7 +282,7 @@ export const commands = {
|
|||||||
} else if (maxPkgVersion) {
|
} else if (maxPkgVersion) {
|
||||||
maxPkgVersion = String(maxPkgVersion).trim();
|
maxPkgVersion = String(maxPkgVersion).trim();
|
||||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||||
semverSatisfies(pkg.name, `<=${maxPkgVersion}`),
|
satisfies(pkg.name, `<=${maxPkgVersion}`),
|
||||||
);
|
);
|
||||||
if (pkgsToBind.length === 0) {
|
if (pkgsToBind.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -260,14 +299,14 @@ export const commands = {
|
|||||||
t('nativeVersionNotFoundMatch', { version: pkgVersion }),
|
t('nativeVersionNotFoundMatch', { version: pkgVersion }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (semverRange) {
|
} else if (packageVersionRange) {
|
||||||
semverRange = semverRange.trim();
|
packageVersionRange = packageVersionRange.trim();
|
||||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||||
semverSatisfies(pkg.name, semverRange!),
|
satisfies(pkg.name, packageVersionRange!),
|
||||||
);
|
);
|
||||||
if (pkgsToBind.length === 0) {
|
if (pkgsToBind.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
t('nativeVersionNotFoundMatch', { version: semverRange }),
|
t('nativeVersionNotFoundMatch', { version: packageVersionRange }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -293,15 +332,13 @@ export const commands = {
|
|||||||
versionId,
|
versionId,
|
||||||
pkgs: pkgsToBind,
|
pkgs: pkgsToBind,
|
||||||
rollout,
|
rollout,
|
||||||
|
dryRun: options.dryRun,
|
||||||
});
|
});
|
||||||
console.log(t('operationSuccess'));
|
|
||||||
},
|
},
|
||||||
updateVersionInfo: async ({
|
updateVersionInfo: async ({
|
||||||
args,
|
|
||||||
options,
|
options,
|
||||||
}: {
|
}: {
|
||||||
args: string[];
|
options: VersionCommandOptions;
|
||||||
options: CommandOptions;
|
|
||||||
}) => {
|
}) => {
|
||||||
const platform = await getPlatform(options.platform);
|
const platform = await getPlatform(options.platform);
|
||||||
const { appId } = await getSelectedApp(platform);
|
const { appId } = await getSelectedApp(platform);
|
||||||
|
Reference in New Issue
Block a user