Skip to content

Commit d3ee908

Browse files
committed
warn version
1 parent 5302c89 commit d3ee908

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const commands = {
2828
};
2929

3030
function run() {
31+
printVersionCommand();
3132
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
32-
printVersionCommand();
3333
process.exit();
3434
}
3535

src/utils/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import os from 'os';
33
import path from 'path';
44
import pkg from '../../package.json';
55
import AppInfoParser from './app-info-parser';
6+
import semverLt from 'semver/functions/lt';
67

78
import read from 'read';
89

@@ -83,7 +84,7 @@ export async function getApkInfo(fn) {
8384
}
8485
if (buildTime == 0) {
8586
throw new Error(
86-
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。',
87+
'无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
8788
);
8889
}
8990
return { versionName, buildTime, ...appCredential };
@@ -119,7 +120,7 @@ export async function getIpaInfo(fn) {
119120
}
120121
if (!buildTimeTxtBuffer) {
121122
throw new Error(
122-
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。',
123+
'无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
123124
);
124125
}
125126
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
@@ -137,17 +138,31 @@ export function saveToLocal(originPath, destName) {
137138

138139
export function printVersionCommand() {
139140
console.log('react-native-update-cli: ' + pkg.version);
141+
let pushyVersion = '';
140142
try {
141143
const PACKAGE_JSON_PATH = require.resolve(
142144
'react-native-update/package.json',
143145
{
144146
paths: [process.cwd()],
145147
},
146148
);
147-
console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version);
149+
pushyVersion = require(PACKAGE_JSON_PATH).version;
150+
console.log('react-native-update: ' + pushyVersion);
148151
} catch (e) {
149152
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
150153
}
154+
if (pushyVersion) {
155+
if (semverLt(pushyVersion, '8.5.1')) {
156+
console.warn(
157+
'当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8',
158+
);
159+
}
160+
if (semverLt(pushyVersion, '9.2.1')) {
161+
console.warn(
162+
'当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动): npm i react-native-update@9',
163+
);
164+
}
165+
}
151166
}
152167

153168
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';

0 commit comments

Comments
 (0)