mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 09:41:38 +08:00
check latest version
This commit is contained in:
17
package.json
17
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.33.0",
|
"version": "1.34.0",
|
||||||
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
|
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
|
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@badisi/latest-version": "^7.0.10",
|
||||||
"bplist-parser": "^0.3.2",
|
"bplist-parser": "^0.3.2",
|
||||||
"bytebuffer": "^5.0.1",
|
"bytebuffer": "^5.0.1",
|
||||||
"cgbi-to-png": "^1.0.7",
|
"cgbi-to-png": "^1.0.7",
|
||||||
@@ -53,17 +54,17 @@
|
|||||||
"tty-table": "4.2",
|
"tty-table": "4.2",
|
||||||
"update-notifier": "^5.1.0",
|
"update-notifier": "^5.1.0",
|
||||||
"yauzl": "^3.2.0",
|
"yauzl": "^3.2.0",
|
||||||
"yazl": "3.3.0"
|
"yazl": "3.3.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@swc/cli": "^0.5.0",
|
"@swc/cli": "^0.5.1",
|
||||||
"@swc/core": "^1.9.2",
|
"@swc/core": "^1.9.3",
|
||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.9.3",
|
||||||
"oxlint": "^0.11.1",
|
"oxlint": "^0.13.1",
|
||||||
"typescript": "^5.6.3"
|
"typescript": "^5.7.2"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
|
"packageManager": "yarn@1.22.22"
|
||||||
}
|
}
|
||||||
|
@@ -31,8 +31,8 @@ const commands = {
|
|||||||
help: printUsage,
|
help: printUsage,
|
||||||
};
|
};
|
||||||
|
|
||||||
function run() {
|
async function run() {
|
||||||
printVersionCommand();
|
await printVersionCommand();
|
||||||
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@ import path from 'node: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 semverSatisfies from 'semver/functions/satisfies';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import latestVersion from '@badisi/latest-version';
|
||||||
|
|
||||||
import { read } from 'read';
|
import { read } from 'read';
|
||||||
|
|
||||||
@@ -131,8 +133,23 @@ export function saveToLocal(originPath, destName) {
|
|||||||
// fs.copyFileSync(originPath, destPath);
|
// fs.copyFileSync(originPath, destPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printVersionCommand() {
|
async function getLatestVersion(pkgName) {
|
||||||
console.log('react-native-update-cli: ' + pkg.version);
|
return Promise.race([
|
||||||
|
latestVersion(pkgName)
|
||||||
|
.then((p) => p.latest)
|
||||||
|
.catch(() => ''),
|
||||||
|
new Promise((resolve) => setTimeout(() => resolve(''), 2000)),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function printVersionCommand() {
|
||||||
|
let latestPushyCliVersion = await getLatestVersion('react-native-update-cli');
|
||||||
|
latestPushyCliVersion = latestPushyCliVersion
|
||||||
|
? ` (最新:${chalk.green(latestPushyCliVersion)})`
|
||||||
|
: '';
|
||||||
|
console.log(
|
||||||
|
`react-native-update-cli: ${pkg.version}${latestPushyCliVersion}`,
|
||||||
|
);
|
||||||
let pushyVersion = '';
|
let pushyVersion = '';
|
||||||
try {
|
try {
|
||||||
const PACKAGE_JSON_PATH = require.resolve(
|
const PACKAGE_JSON_PATH = require.resolve(
|
||||||
@@ -142,21 +159,29 @@ export function printVersionCommand() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
pushyVersion = require(PACKAGE_JSON_PATH).version;
|
pushyVersion = require(PACKAGE_JSON_PATH).version;
|
||||||
console.log('react-native-update: ' + pushyVersion);
|
let latestPushyVersion = await getLatestVersion('react-native-update');
|
||||||
|
latestPushyVersion = latestPushyVersion
|
||||||
|
? ` (最新:${chalk.green(latestPushyVersion)})`
|
||||||
|
: '';
|
||||||
|
console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
|
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
|
||||||
}
|
}
|
||||||
if (pushyVersion) {
|
if (pushyVersion) {
|
||||||
if (semverSatisfies(pushyVersion, '<8.5.1')) {
|
if (semverSatisfies(pushyVersion, '<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(pushyVersion, '9.0.0 - 9.2.0')) {
|
} else if (semverSatisfies(pushyVersion, '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(pushyVersion, '10.0.0 - 10.15.2')) {
|
||||||
|
console.warn(
|
||||||
|
`当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user