react-native-update-cli 1.41.0-beta.1 → 1.41.0

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.
@@ -80,13 +80,12 @@ function getRNVersion() {
80
80
  paths: [
81
81
  process.cwd()
82
82
  ]
83
- }))).version;
84
- // We only care about major and minor version.
85
- const match = /^(\d+)\.(\d+)\./.exec(version);
83
+ })).toString()).version;
84
+ const [, major, minor] = /^(\d+)\.(\d+)\./.exec(version) || [];
86
85
  return {
87
86
  version,
88
- major: match[1] | 0,
89
- minor: match[2] | 0
87
+ major: Number(major),
88
+ minor: Number(minor)
90
89
  };
91
90
  }
92
91
  async function getApkInfo(fn) {
@@ -183,14 +182,19 @@ function saveToLocal(originPath, destName) {
183
182
  // fs.ensureDirSync(path.dirname(destPath));
184
183
  // fs.copyFileSync(originPath, destPath);
185
184
  }
186
- async function getLatestVersion(pkgName) {
187
- return Promise.race([
188
- (0, _latestversion.default)(pkgName).then((p)=>p.latest).catch(()=>''),
189
- new Promise((resolve)=>setTimeout(()=>resolve(''), 2000))
190
- ]);
185
+ async function getLatestVersion(pkgNames) {
186
+ return (0, _latestversion.default)(pkgNames, {
187
+ useCache: true,
188
+ requestOptions: {
189
+ timeout: 2000
190
+ }
191
+ }).then((pkgs)=>pkgs.map((pkg)=>pkg.latest)).catch(()=>[]);
191
192
  }
192
193
  async function printVersionCommand() {
193
- let latestPushyCliVersion = await getLatestVersion('react-native-update-cli');
194
+ let [latestPushyCliVersion, latestPushyVersion] = await getLatestVersion([
195
+ 'react-native-update-cli',
196
+ 'react-native-update'
197
+ ]);
194
198
  latestPushyCliVersion = latestPushyCliVersion ? ` (最新:${_chalk.default.green(latestPushyCliVersion)})` : '';
195
199
  console.log(`react-native-update-cli: ${_packagejson.default.version}${latestPushyCliVersion}`);
196
200
  let pushyVersion = '';
@@ -201,7 +205,6 @@ async function printVersionCommand() {
201
205
  ]
202
206
  });
203
207
  pushyVersion = require(PACKAGE_JSON_PATH).version;
204
- let latestPushyVersion = await getLatestVersion('react-native-update');
205
208
  latestPushyVersion = latestPushyVersion ? ` (最新:${_chalk.default.green(latestPushyVersion)})` : '';
206
209
  console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
207
210
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.41.0-beta.1",
3
+ "version": "1.41.0",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -76,7 +76,8 @@
76
76
  "@types/semver": "^7.5.8",
77
77
  "@types/tcp-ping": "^0.1.6",
78
78
  "@types/update-notifier": "^6.0.8",
79
+ "@types/yauzl": "^2.10.3",
80
+ "@types/yazl": "^2.4.6",
79
81
  "typescript": "^5.7.2"
80
- },
81
- "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
82
+ }
82
83
  }
@@ -23,7 +23,7 @@ export async function question(query: string, password?: boolean) {
23
23
  }
24
24
 
25
25
  export function translateOptions(options: Record<string, string>) {
26
- const ret = {};
26
+ const ret: Record<string, string> = {};
27
27
  for (const key in options) {
28
28
  const v = options[key];
29
29
  if (typeof v === 'string') {
@@ -40,19 +40,21 @@ export function translateOptions(options: Record<string, string>) {
40
40
 
41
41
  export function getRNVersion() {
42
42
  const version = JSON.parse(
43
- fs.readFileSync(
44
- require.resolve('react-native/package.json', {
45
- paths: [process.cwd()],
46
- }),
47
- ),
43
+ fs
44
+ .readFileSync(
45
+ require.resolve('react-native/package.json', {
46
+ paths: [process.cwd()],
47
+ }),
48
+ )
49
+ .toString(),
48
50
  ).version;
49
51
 
50
- // We only care about major and minor version.
51
- const match = /^(\d+)\.(\d+)\./.exec(version);
52
+ const [, major, minor] = /^(\d+)\.(\d+)\./.exec(version) || [];
53
+
52
54
  return {
53
55
  version,
54
- major: match[1] | 0,
55
- minor: match[2] | 0,
56
+ major: Number(major),
57
+ minor: Number(minor),
56
58
  };
57
59
  }
58
60
 
@@ -173,17 +175,22 @@ export function saveToLocal(originPath: string, destName: string) {
173
175
  // fs.copyFileSync(originPath, destPath);
174
176
  }
175
177
 
176
- async function getLatestVersion(pkgName: string) {
177
- return Promise.race([
178
- latestVersion(pkgName)
179
- .then((p) => p.latest)
180
- .catch(() => ''),
181
- new Promise((resolve) => setTimeout(() => resolve(''), 2000)),
182
- ]);
178
+ async function getLatestVersion(pkgNames: string[]) {
179
+ return latestVersion(pkgNames, {
180
+ useCache: true,
181
+ requestOptions: {
182
+ timeout: 2000,
183
+ },
184
+ })
185
+ .then((pkgs) => pkgs.map((pkg) => pkg.latest))
186
+ .catch(() => []);
183
187
  }
184
188
 
185
189
  export async function printVersionCommand() {
186
- let latestPushyCliVersion = await getLatestVersion('react-native-update-cli');
190
+ let [latestPushyCliVersion, latestPushyVersion] = await getLatestVersion([
191
+ 'react-native-update-cli',
192
+ 'react-native-update',
193
+ ]);
187
194
  latestPushyCliVersion = latestPushyCliVersion
188
195
  ? ` (最新:${chalk.green(latestPushyCliVersion)})`
189
196
  : '';
@@ -199,7 +206,6 @@ export async function printVersionCommand() {
199
206
  },
200
207
  );
201
208
  pushyVersion = require(PACKAGE_JSON_PATH).version;
202
- let latestPushyVersion = await getLatestVersion('react-native-update');
203
209
  latestPushyVersion = latestPushyVersion
204
210
  ? ` (最新:${chalk.green(latestPushyVersion)})`
205
211
  : '';
@@ -226,6 +232,4 @@ export async function printVersionCommand() {
226
232
  }
227
233
  }
228
234
 
229
-
230
-
231
235
  export { checkPlugins };
package/src/.DS_Store DELETED
Binary file
Binary file