react-native-update-cli 1.33.0 → 1.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -33,8 +33,8 @@ const commands = {
33
33
  ...require('./versions').commands,
34
34
  help: printUsage
35
35
  };
36
- function run() {
37
- (0, _index.printVersionCommand)();
36
+ async function run() {
37
+ await (0, _index.printVersionCommand)();
38
38
  if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
39
39
  process.exit();
40
40
  }
@@ -40,6 +40,8 @@ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
40
40
  const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../package.json"));
41
41
  const _appinfoparser = /*#__PURE__*/ _interop_require_default(require("./app-info-parser"));
42
42
  const _satisfies = /*#__PURE__*/ _interop_require_default(require("semver/functions/satisfies"));
43
+ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
44
+ const _latestversion = /*#__PURE__*/ _interop_require_default(require("@badisi/latest-version"));
43
45
  const _read = require("read");
44
46
  function _interop_require_default(obj) {
45
47
  return obj && obj.__esModule ? obj : {
@@ -148,8 +150,16 @@ function saveToLocal(originPath, destName) {
148
150
  // fs.ensureDirSync(path.dirname(destPath));
149
151
  // fs.copyFileSync(originPath, destPath);
150
152
  }
151
- function printVersionCommand() {
152
- console.log('react-native-update-cli: ' + _packagejson.default.version);
153
+ async function getLatestVersion(pkgName) {
154
+ return Promise.race([
155
+ (0, _latestversion.default)(pkgName).then((p)=>p.latest).catch(()=>''),
156
+ new Promise((resolve)=>setTimeout(()=>resolve(''), 2000))
157
+ ]);
158
+ }
159
+ async function printVersionCommand() {
160
+ let latestPushyCliVersion = await getLatestVersion('react-native-update-cli');
161
+ latestPushyCliVersion = latestPushyCliVersion ? ` (最新:${_chalk.default.green(latestPushyCliVersion)})` : '';
162
+ console.log(`react-native-update-cli: ${_packagejson.default.version}${latestPushyCliVersion}`);
153
163
  let pushyVersion = '';
154
164
  try {
155
165
  const PACKAGE_JSON_PATH = require.resolve('react-native-update/package.json', {
@@ -158,17 +168,21 @@ function printVersionCommand() {
158
168
  ]
159
169
  });
160
170
  pushyVersion = require(PACKAGE_JSON_PATH).version;
161
- console.log('react-native-update: ' + pushyVersion);
171
+ let latestPushyVersion = await getLatestVersion('react-native-update');
172
+ latestPushyVersion = latestPushyVersion ? ` (最新:${_chalk.default.green(latestPushyVersion)})` : '';
173
+ console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
162
174
  } catch (e) {
163
175
  console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
164
176
  }
165
177
  if (pushyVersion) {
166
- if ((0, _satisfies.default)(pushyVersion, '<8.5.1')) {
178
+ if ((0, _satisfies.default)(pushyVersion, '<8.5.2')) {
167
179
  console.warn(`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
168
180
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
169
- } else if ((0, _satisfies.default)(pushyVersion, '9.0.0 - 9.2.0')) {
170
- console.warn(`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动): npm i react-native-update@9 .
181
+ } else if ((0, _satisfies.default)(pushyVersion, '9.0.0 - 9.2.1')) {
182
+ console.warn(`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
171
183
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
184
+ } else if ((0, _satisfies.default)(pushyVersion, '10.0.0 - 10.15.2')) {
185
+ console.warn(`当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10`);
172
186
  }
173
187
  }
174
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.33.0",
3
+ "version": "1.34.1",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -32,9 +32,11 @@
32
32
  },
33
33
  "homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
34
34
  "dependencies": {
35
+ "@badisi/latest-version": "^7.0.10",
35
36
  "bplist-parser": "^0.3.2",
36
37
  "bytebuffer": "^5.0.1",
37
38
  "cgbi-to-png": "^1.0.7",
39
+ "chalk": "4",
38
40
  "cli-arguments": "^0.2.1",
39
41
  "commander": "^12.1.0",
40
42
  "compare-versions": "^6.1.1",
@@ -53,17 +55,17 @@
53
55
  "tty-table": "4.2",
54
56
  "update-notifier": "^5.1.0",
55
57
  "yauzl": "^3.2.0",
56
- "yazl": "3.3.0"
58
+ "yazl": "3.3.1"
57
59
  },
58
60
  "engines": {
59
61
  "node": ">= 10"
60
62
  },
61
63
  "devDependencies": {
62
- "@swc/cli": "^0.5.0",
63
- "@swc/core": "^1.9.2",
64
- "@types/node": "^22.9.0",
65
- "oxlint": "^0.11.1",
66
- "typescript": "^5.6.3"
64
+ "@swc/cli": "^0.5.1",
65
+ "@swc/core": "^1.9.3",
66
+ "@types/node": "^22.9.3",
67
+ "oxlint": "^0.13.1",
68
+ "typescript": "^5.7.2"
67
69
  },
68
- "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
70
+ "packageManager": "yarn@1.22.22"
69
71
  }
package/src/index.ts CHANGED
@@ -31,8 +31,8 @@ const commands = {
31
31
  help: printUsage,
32
32
  };
33
33
 
34
- function run() {
35
- printVersionCommand();
34
+ async function run() {
35
+ await printVersionCommand();
36
36
  if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
37
37
  process.exit();
38
38
  }
@@ -4,6 +4,8 @@ import path from 'node:path';
4
4
  import pkg from '../../package.json';
5
5
  import AppInfoParser from './app-info-parser';
6
6
  import semverSatisfies from 'semver/functions/satisfies';
7
+ import chalk from 'chalk';
8
+ import latestVersion from '@badisi/latest-version';
7
9
 
8
10
  import { read } from 'read';
9
11
 
@@ -131,8 +133,23 @@ export function saveToLocal(originPath, destName) {
131
133
  // fs.copyFileSync(originPath, destPath);
132
134
  }
133
135
 
134
- export function printVersionCommand() {
135
- console.log('react-native-update-cli: ' + pkg.version);
136
+ async function getLatestVersion(pkgName) {
137
+ return Promise.race([
138
+ latestVersion(pkgName)
139
+ .then((p) => p.latest)
140
+ .catch(() => ''),
141
+ new Promise((resolve) => setTimeout(() => resolve(''), 2000)),
142
+ ]);
143
+ }
144
+
145
+ export async function printVersionCommand() {
146
+ let latestPushyCliVersion = await getLatestVersion('react-native-update-cli');
147
+ latestPushyCliVersion = latestPushyCliVersion
148
+ ? ` (最新:${chalk.green(latestPushyCliVersion)})`
149
+ : '';
150
+ console.log(
151
+ `react-native-update-cli: ${pkg.version}${latestPushyCliVersion}`,
152
+ );
136
153
  let pushyVersion = '';
137
154
  try {
138
155
  const PACKAGE_JSON_PATH = require.resolve(
@@ -142,21 +159,29 @@ export function printVersionCommand() {
142
159
  },
143
160
  );
144
161
  pushyVersion = require(PACKAGE_JSON_PATH).version;
145
- console.log('react-native-update: ' + pushyVersion);
162
+ let latestPushyVersion = await getLatestVersion('react-native-update');
163
+ latestPushyVersion = latestPushyVersion
164
+ ? ` (最新:${chalk.green(latestPushyVersion)})`
165
+ : '';
166
+ console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
146
167
  } catch (e) {
147
168
  console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
148
169
  }
149
170
  if (pushyVersion) {
150
- if (semverSatisfies(pushyVersion, '<8.5.1')) {
171
+ if (semverSatisfies(pushyVersion, '<8.5.2')) {
151
172
  console.warn(
152
173
  `当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
153
174
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
154
175
  );
155
- } else if (semverSatisfies(pushyVersion, '9.0.0 - 9.2.0')) {
176
+ } else if (semverSatisfies(pushyVersion, '9.0.0 - 9.2.1')) {
156
177
  console.warn(
157
- `当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动): npm i react-native-update@9 .
178
+ `当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
158
179
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
159
180
  );
181
+ } else if (semverSatisfies(pushyVersion, '10.0.0 - 10.15.2')) {
182
+ console.warn(
183
+ `当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10`,
184
+ );
160
185
  }
161
186
  }
162
187
  }