react-native-update-cli 2.17.0 → 2.19.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.
Files changed (57) hide show
  1. package/lib/api.d.ts +1 -1
  2. package/lib/api.js +140 -134
  3. package/lib/app.d.ts +2 -2
  4. package/lib/app.js +60 -107
  5. package/lib/bin.js +38 -35
  6. package/lib/bundle-pack.js +57 -77
  7. package/lib/bundle-runner.js +249 -312
  8. package/lib/bundle.js +71 -89
  9. package/lib/diff.js +224 -198
  10. package/lib/exports.js +14 -37
  11. package/lib/index.js +16 -17
  12. package/lib/install.js +24 -37
  13. package/lib/locales/en.d.ts +1 -0
  14. package/lib/locales/en.js +4 -11
  15. package/lib/locales/zh.d.ts +1 -0
  16. package/lib/locales/zh.js +4 -11
  17. package/lib/package.js +164 -218
  18. package/lib/provider.js +85 -107
  19. package/lib/types.js +1 -3
  20. package/lib/user.d.ts +1 -1
  21. package/lib/user.js +26 -39
  22. package/lib/utils/add-gitignore.js +16 -29
  23. package/lib/utils/app-info-parser/aab.js +133 -157
  24. package/lib/utils/app-info-parser/apk.js +42 -39
  25. package/lib/utils/app-info-parser/app.js +5 -11
  26. package/lib/utils/app-info-parser/index.js +21 -31
  27. package/lib/utils/app-info-parser/ipa.js +35 -35
  28. package/lib/utils/app-info-parser/resource-finder.js +84 -71
  29. package/lib/utils/app-info-parser/utils.js +52 -77
  30. package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
  31. package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
  32. package/lib/utils/app-info-parser/zip.js +43 -51
  33. package/lib/utils/check-lockfile.js +28 -37
  34. package/lib/utils/check-plugin.js +16 -32
  35. package/lib/utils/command-result.js +7 -20
  36. package/lib/utils/constants.js +23 -63
  37. package/lib/utils/dep-versions.js +21 -27
  38. package/lib/utils/git.js +20 -64
  39. package/lib/utils/hbcTransform.js +133 -246
  40. package/lib/utils/http-helper.js +33 -44
  41. package/lib/utils/i18n.js +17 -26
  42. package/lib/utils/index.js +137 -179
  43. package/lib/utils/latest-version/index.js +128 -137
  44. package/lib/utils/options.js +13 -34
  45. package/lib/utils/plugin-config.js +43 -56
  46. package/lib/utils/runtime.js +50 -108
  47. package/lib/utils/zip-entries.js +70 -97
  48. package/lib/utils/zip-options.js +80 -181
  49. package/lib/versions.js +231 -265
  50. package/package.json +19 -20
  51. package/src/api.ts +44 -3
  52. package/src/diff.ts +129 -2
  53. package/src/locales/en.ts +2 -0
  54. package/src/locales/zh.ts +2 -0
  55. package/src/package.ts +1 -1
  56. package/src/user.ts +1 -1
  57. package/src/versions.ts +1 -1
package/lib/utils/i18n.js CHANGED
@@ -1,38 +1,29 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "t", {
6
- enumerable: true,
7
- get: function() {
8
- return t;
9
- }
10
- });
11
- const _i18next = /*#__PURE__*/ _interop_require_default(require("i18next"));
12
- const _en = /*#__PURE__*/ _interop_require_default(require("../locales/en"));
13
- const _zh = /*#__PURE__*/ _interop_require_default(require("../locales/zh"));
14
- const _constants = require("./constants");
15
- function _interop_require_default(obj) {
16
- return obj && obj.__esModule ? obj : {
17
- default: obj
18
- };
19
- }
20
- _i18next.default.init({
21
- lng: _constants.IS_CRESC ? 'en' : 'zh',
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.t = t;
7
+ const i18next_1 = __importDefault(require("i18next"));
8
+ const en_1 = __importDefault(require("../locales/en"));
9
+ const zh_1 = __importDefault(require("../locales/zh"));
10
+ const constants_1 = require("./constants");
11
+ i18next_1.default.init({
12
+ lng: constants_1.IS_CRESC ? 'en' : 'zh',
22
13
  // debug: process.env.NODE_ENV !== 'production',
23
14
  // debug: true,
24
15
  resources: {
25
16
  en: {
26
- translation: _en.default
17
+ translation: en_1.default,
27
18
  },
28
19
  zh: {
29
- translation: _zh.default
30
- }
20
+ translation: zh_1.default,
21
+ },
31
22
  },
32
23
  interpolation: {
33
- escapeValue: false
34
- }
24
+ escapeValue: false,
25
+ },
35
26
  });
36
27
  function t(key, options) {
37
- return _i18next.default.t(key, options);
28
+ return i18next_1.default.t(key, options);
38
29
  }
@@ -1,99 +1,69 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get checkPlugins () {
13
- return _checkplugin.checkPlugins;
14
- },
15
- get getAabInfo () {
16
- return getAabInfo;
17
- },
18
- get getApkInfo () {
19
- return getApkInfo;
20
- },
21
- get getAppInfo () {
22
- return getAppInfo;
23
- },
24
- get getIpaInfo () {
25
- return getIpaInfo;
26
- },
27
- get isNonInteractive () {
28
- return isNonInteractive;
29
- },
30
- get printVersionCommand () {
31
- return printVersionCommand;
32
- },
33
- get question () {
34
- return question;
35
- },
36
- get translateOptions () {
37
- return translateOptions;
38
- }
39
- });
40
- const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
41
- const _compareversions = require("compare-versions");
42
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
43
- const _read = require("read");
44
- const _yauzl = require("yauzl");
45
- const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../package.json"));
46
- const _latestversion = /*#__PURE__*/ _interop_require_default(require("./latest-version"));
47
- const _appinfoparser = /*#__PURE__*/ _interop_require_default(require("./app-info-parser"));
48
- const _checkplugin = require("./check-plugin");
49
- const _constants = require("./constants");
50
- const _depversions = require("./dep-versions");
51
- const _i18n = require("./i18n");
52
- function _interop_require_default(obj) {
53
- return obj && obj.__esModule ? obj : {
54
- default: obj
55
- };
56
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkPlugins = void 0;
7
+ exports.isNonInteractive = isNonInteractive;
8
+ exports.question = question;
9
+ exports.translateOptions = translateOptions;
10
+ exports.getApkInfo = getApkInfo;
11
+ exports.getAppInfo = getAppInfo;
12
+ exports.getIpaInfo = getIpaInfo;
13
+ exports.getAabInfo = getAabInfo;
14
+ exports.printVersionCommand = printVersionCommand;
15
+ const chalk_1 = __importDefault(require("chalk"));
16
+ const compare_versions_1 = require("compare-versions");
17
+ const path_1 = __importDefault(require("path"));
18
+ const read_1 = require("read");
19
+ const yauzl_1 = require("yauzl");
20
+ const package_json_1 = __importDefault(require("../../package.json"));
21
+ const latest_version_1 = __importDefault(require("../utils/latest-version"));
22
+ const app_info_parser_1 = __importDefault(require("./app-info-parser"));
23
+ const check_plugin_1 = require("./check-plugin");
24
+ Object.defineProperty(exports, "checkPlugins", { enumerable: true, get: function () { return check_plugin_1.checkPlugins; } });
25
+ const constants_1 = require("./constants");
26
+ const dep_versions_1 = require("./dep-versions");
27
+ const i18n_1 = require("./i18n");
57
28
  function isNonInteractive() {
58
- var _process_env_NO_INTERACTIVE;
59
- const envValue = (_process_env_NO_INTERACTIVE = process.env.NO_INTERACTIVE) == null ? void 0 : _process_env_NO_INTERACTIVE.toLowerCase();
60
- return global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1';
29
+ const envValue = process.env.NO_INTERACTIVE?.toLowerCase();
30
+ return (global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1');
61
31
  }
62
32
  async function question(query, password) {
63
33
  if (isNonInteractive()) {
64
34
  return '';
65
35
  }
66
- return (0, _read.read)({
36
+ return (0, read_1.read)({
67
37
  prompt: query,
68
38
  silent: password,
69
- replace: password ? '*' : undefined
39
+ replace: password ? '*' : undefined,
70
40
  });
71
41
  }
72
42
  function translateOptions(options, map) {
73
43
  if (!map) {
74
44
  // Existing logic for template replacement if no map is provided
75
45
  const ret = {};
76
- for(const key in options){
46
+ for (const key in options) {
77
47
  const value = options[key];
78
48
  if (typeof value === 'string') {
79
- ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name)=>{
80
- var _options_name;
81
- const replacement = (_options_name = options[name]) != null ? _options_name : process.env[name];
82
- if (typeof replacement === 'string' || typeof replacement === 'number' || typeof replacement === 'boolean') {
49
+ ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name) => {
50
+ const replacement = options[name] ?? process.env[name];
51
+ if (typeof replacement === 'string' ||
52
+ typeof replacement === 'number' ||
53
+ typeof replacement === 'boolean') {
83
54
  return String(replacement);
84
55
  }
85
56
  return placeholder;
86
57
  });
87
- } else {
58
+ }
59
+ else {
88
60
  ret[key] = value;
89
61
  }
90
62
  }
91
63
  return ret;
92
64
  }
93
- const result = {
94
- ...options
95
- };
96
- for (const [key, value] of Object.entries(map)){
65
+ const result = { ...options };
66
+ for (const [key, value] of Object.entries(map)) {
97
67
  if (result[key] !== undefined) {
98
68
  result[value] = result[key];
99
69
  delete result[key];
@@ -104,17 +74,17 @@ function translateOptions(options, map) {
104
74
  const ApkBundleFileName = /assets\/index.android.bundle/;
105
75
  const ApkUpdateJsonName = /res\/raw\/update.json/;
106
76
  async function getApkInfo(fn) {
107
- const appInfoParser = new _appinfoparser.default(fn);
77
+ const appInfoParser = new app_info_parser_1.default(fn);
108
78
  // read both entries in a single scan over the archive
109
79
  const entries = await appInfoParser.parser.getEntries([
110
80
  ApkBundleFileName,
111
- ApkUpdateJsonName
81
+ ApkUpdateJsonName,
112
82
  ]);
113
83
  const bundleFile = entries[String(ApkBundleFileName)];
114
84
  if (!bundleFile) {
115
- throw new Error((0, _i18n.t)('bundleNotFound', {
85
+ throw new Error((0, i18n_1.t)('bundleNotFound', {
116
86
  packageType: 'apk',
117
- entryFile: 'index.android.bundle'
87
+ entryFile: 'index.android.bundle',
118
88
  }));
119
89
  }
120
90
  const updateJsonFile = entries[String(ApkUpdateJsonName)];
@@ -125,38 +95,35 @@ async function getApkInfo(fn) {
125
95
  const { versionName, application } = await appInfoParser.parse();
126
96
  let buildTime = 0;
127
97
  if (Array.isArray(application.metaData)) {
128
- for (const meta of application.metaData){
98
+ for (const meta of application.metaData) {
129
99
  if (meta.name === 'pushy_build_time') {
130
100
  if (Array.isArray(meta.value)) {
131
101
  const firstValue = meta.value[0];
132
102
  buildTime = Number(firstValue);
133
- } else if (meta.value !== undefined) {
103
+ }
104
+ else if (meta.value !== undefined) {
134
105
  buildTime = Number(meta.value);
135
106
  }
136
107
  }
137
108
  }
138
109
  }
139
110
  if (!Number.isFinite(buildTime) || buildTime === 0) {
140
- throw new Error((0, _i18n.t)('buildTimeNotFound'));
111
+ throw new Error((0, i18n_1.t)('buildTimeNotFound'));
141
112
  }
142
- return {
143
- versionName,
144
- buildTime,
145
- ...appCredential
146
- };
113
+ return { versionName, buildTime, ...appCredential };
147
114
  }
148
115
  async function getAppInfo(fn) {
149
- const appInfoParser = new _appinfoparser.default(fn);
116
+ const appInfoParser = new app_info_parser_1.default(fn);
150
117
  // single scan (and single nested .hap extraction) for all three entries
151
118
  const [bundleFile, updateJsonFile, metaJsonFile] = await appInfoParser.parser.getEntriesFromHarmonyApp([
152
119
  /rawfile\/bundle.harmony.js/,
153
120
  /rawfile\/update.json/,
154
- /rawfile\/meta.json/
121
+ /rawfile\/meta.json/,
155
122
  ]);
156
123
  if (!bundleFile) {
157
- throw new Error((0, _i18n.t)('bundleNotFound', {
124
+ throw new Error((0, i18n_1.t)('bundleNotFound', {
158
125
  packageType: 'app',
159
- entryFile: 'bundle.harmony.js'
126
+ entryFile: 'bundle.harmony.js',
160
127
  }));
161
128
  }
162
129
  let appCredential = {};
@@ -173,13 +140,9 @@ async function getAppInfo(fn) {
173
140
  buildTime = Number(pushy_build_time);
174
141
  }
175
142
  if (!Number.isFinite(buildTime) || buildTime === 0) {
176
- throw new Error((0, _i18n.t)('buildTimeNotFound'));
143
+ throw new Error((0, i18n_1.t)('buildTimeNotFound'));
177
144
  }
178
- return {
179
- versionName,
180
- buildTime,
181
- ...appCredential
182
- };
145
+ return { versionName, buildTime, ...appCredential };
183
146
  }
184
147
  const IpaBundleFileName = /payload\/.+?\.app\/main.jsbundle/;
185
148
  const IpaUpdateJsonName = /payload\/.+?\.app\/assets\/update.json/;
@@ -187,20 +150,19 @@ const IpaBuildTimeName = /payload\/.+?\.app\/pushy_build_time.txt/;
187
150
  // Not in root bundle when use `use_frameworks`
188
151
  const IpaBuildTimeFrameworkName = /payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/;
189
152
  async function getIpaInfo(fn) {
190
- var _entries_String;
191
- const appInfoParser = new _appinfoparser.default(fn);
153
+ const appInfoParser = new app_info_parser_1.default(fn);
192
154
  // read all four entries in a single scan over the archive
193
155
  const entries = await appInfoParser.parser.getEntries([
194
156
  IpaBundleFileName,
195
157
  IpaUpdateJsonName,
196
158
  IpaBuildTimeName,
197
- IpaBuildTimeFrameworkName
159
+ IpaBuildTimeFrameworkName,
198
160
  ]);
199
161
  const bundleFile = entries[String(IpaBundleFileName)];
200
162
  if (!bundleFile) {
201
- throw new Error((0, _i18n.t)('bundleNotFound', {
163
+ throw new Error((0, i18n_1.t)('bundleNotFound', {
202
164
  packageType: 'ipa',
203
- entryFile: 'main.jsbundle'
165
+ entryFile: 'main.jsbundle',
204
166
  }));
205
167
  }
206
168
  const updateJsonFile = entries[String(IpaUpdateJsonName)];
@@ -209,20 +171,17 @@ async function getIpaInfo(fn) {
209
171
  appCredential = JSON.parse(updateJsonFile.toString()).ios;
210
172
  }
211
173
  const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
212
- const buildTimeTxtBuffer = (_entries_String = entries[String(IpaBuildTimeName)]) != null ? _entries_String : entries[String(IpaBuildTimeFrameworkName)];
174
+ const buildTimeTxtBuffer = entries[String(IpaBuildTimeName)] ??
175
+ entries[String(IpaBuildTimeFrameworkName)];
213
176
  if (!buildTimeTxtBuffer) {
214
- throw new Error((0, _i18n.t)('buildTimeNotFound'));
177
+ throw new Error((0, i18n_1.t)('buildTimeNotFound'));
215
178
  }
216
179
  const buildTime = buildTimeTxtBuffer.toString().trim();
217
- return {
218
- versionName,
219
- buildTime,
220
- ...appCredential
221
- };
180
+ return { versionName, buildTime, ...appCredential };
222
181
  }
223
182
  async function getAabInfo(fn) {
224
183
  const protobuf = require('protobufjs');
225
- const root = await protobuf.load(_path.default.join(__dirname, '../../proto/Resources.proto'));
184
+ const root = await protobuf.load(path_1.default.join(__dirname, '../../proto/Resources.proto'));
226
185
  const XmlNode = root.lookupType('aapt.pb.XmlNode');
227
186
  const buffer = await readZipEntry(fn, 'base/manifest/AndroidManifest.xml');
228
187
  const message = XmlNode.decode(buffer);
@@ -231,14 +190,14 @@ async function getAabInfo(fn) {
231
190
  longs: String,
232
191
  bytes: String,
233
192
  defaults: true,
234
- arrays: true
193
+ arrays: true,
235
194
  });
236
195
  const manifestElement = object.element;
237
196
  if (manifestElement.name !== 'manifest') {
238
- throw new Error((0, _i18n.t)('invalidManifest'));
197
+ throw new Error((0, i18n_1.t)('invalidManifest'));
239
198
  }
240
199
  let versionName = '';
241
- for (const attr of manifestElement.attribute){
200
+ for (const attr of manifestElement.attribute) {
242
201
  if (attr.name === 'versionName') {
243
202
  versionName = attr.value;
244
203
  }
@@ -246,17 +205,11 @@ async function getAabInfo(fn) {
246
205
  let buildTime = 0;
247
206
  const appCredential = {};
248
207
  // Find application node
249
- const applicationNode = manifestElement.child.find((child)=>{
250
- var _child_element;
251
- return ((_child_element = child.element) == null ? void 0 : _child_element.name) === 'application';
252
- });
253
- const applicationElement = applicationNode == null ? void 0 : applicationNode.element;
208
+ const applicationNode = manifestElement.child.find((child) => child.element?.name === 'application');
209
+ const applicationElement = applicationNode?.element;
254
210
  if (applicationElement) {
255
- const metaDataNodes = applicationElement.child.filter((child)=>{
256
- var _child_element;
257
- return ((_child_element = child.element) == null ? void 0 : _child_element.name) === 'meta-data';
258
- });
259
- for (const meta of metaDataNodes){
211
+ const metaDataNodes = applicationElement.child.filter((child) => child.element?.name === 'meta-data');
212
+ for (const meta of metaDataNodes) {
260
213
  let name = '';
261
214
  let value = '';
262
215
  let resourceId = 0;
@@ -264,16 +217,16 @@ async function getAabInfo(fn) {
264
217
  if (!metaElement) {
265
218
  continue;
266
219
  }
267
- for (const attr of metaElement.attribute){
220
+ for (const attr of metaElement.attribute) {
268
221
  if (attr.name === 'name') {
269
222
  name = attr.value;
270
223
  }
271
224
  if (attr.name === 'value') {
272
- var _attr_compiledItem_ref, _attr_compiledItem, _attr_compiledItem_prim, _attr_compiledItem1;
273
225
  value = attr.value;
274
- if ((_attr_compiledItem = attr.compiledItem) == null ? void 0 : (_attr_compiledItem_ref = _attr_compiledItem.ref) == null ? void 0 : _attr_compiledItem_ref.id) {
226
+ if (attr.compiledItem?.ref?.id) {
275
227
  resourceId = attr.compiledItem.ref.id;
276
- } else if ((_attr_compiledItem1 = attr.compiledItem) == null ? void 0 : (_attr_compiledItem_prim = _attr_compiledItem1.prim) == null ? void 0 : _attr_compiledItem_prim.intDecimalValue) {
228
+ }
229
+ else if (attr.compiledItem?.prim?.intDecimalValue) {
277
230
  value = attr.compiledItem.prim.intDecimalValue.toString();
278
231
  }
279
232
  }
@@ -290,59 +243,55 @@ async function getAabInfo(fn) {
290
243
  }
291
244
  }
292
245
  if (!Number.isFinite(buildTime) || buildTime === 0) {
293
- throw new Error((0, _i18n.t)('buildTimeNotFound'));
246
+ throw new Error((0, i18n_1.t)('buildTimeNotFound'));
294
247
  }
295
- return {
296
- versionName,
297
- buildTime,
298
- ...appCredential
299
- };
248
+ return { versionName, buildTime, ...appCredential };
300
249
  }
301
250
  async function readZipEntry(fn, entryName) {
302
- return new Promise((resolve, reject)=>{
303
- (0, _yauzl.open)(fn, {
304
- lazyEntries: true
305
- }, (err, zipfile)=>{
251
+ return new Promise((resolve, reject) => {
252
+ (0, yauzl_1.open)(fn, { lazyEntries: true }, (err, zipfile) => {
306
253
  if (err || !zipfile) {
307
- reject(err != null ? err : new Error('Failed to open zip file'));
254
+ reject(err ?? new Error('Failed to open zip file'));
308
255
  return;
309
256
  }
310
257
  let found = false;
311
258
  zipfile.readEntry();
312
- zipfile.on('entry', (entry)=>{
259
+ zipfile.on('entry', (entry) => {
313
260
  if (entry.fileName === entryName) {
314
261
  found = true;
315
- zipfile.openReadStream(entry, (streamError, readStream)=>{
262
+ zipfile.openReadStream(entry, (streamError, readStream) => {
316
263
  if (streamError || !readStream) {
317
264
  zipfile.close();
318
- reject(streamError != null ? streamError : new Error('Failed to read zip entry'));
265
+ reject(streamError ?? new Error('Failed to read zip entry'));
319
266
  return;
320
267
  }
321
268
  const chunks = [];
322
- readStream.on('data', (chunk)=>chunks.push(chunk));
323
- readStream.on('end', ()=>{
269
+ readStream.on('data', (chunk) => chunks.push(chunk));
270
+ readStream.on('end', () => {
324
271
  zipfile.close();
325
272
  resolve(Buffer.concat(chunks));
326
273
  });
327
- readStream.on('error', (error)=>{
274
+ readStream.on('error', (error) => {
328
275
  zipfile.close();
329
276
  reject(error);
330
277
  });
331
278
  });
332
- } else {
279
+ }
280
+ else {
333
281
  zipfile.readEntry();
334
282
  }
335
283
  });
336
- zipfile.on('end', ()=>{
337
- if (!found) reject(new Error(`${entryName} not found in AAB`));
284
+ zipfile.on('end', () => {
285
+ if (!found)
286
+ reject(new Error(`${entryName} not found in AAB`));
338
287
  });
339
288
  zipfile.on('error', reject);
340
289
  });
341
290
  });
342
291
  }
343
292
  async function resolveResource(fn, resourceId, root) {
344
- const pkgId = resourceId >> 24 & 0xff;
345
- const typeId = resourceId >> 16 & 0xff;
293
+ const pkgId = (resourceId >> 24) & 0xff;
294
+ const typeId = (resourceId >> 16) & 0xff;
346
295
  const entryId = resourceId & 0xffff;
347
296
  try {
348
297
  const buffer = await readZipEntry(fn, 'base/resources.pb');
@@ -353,73 +302,82 @@ async function resolveResource(fn, resourceId, root) {
353
302
  longs: String,
354
303
  bytes: String,
355
304
  defaults: true,
356
- arrays: true
305
+ arrays: true,
357
306
  });
358
307
  // Find package
359
- const pkg = object.package.find((pkgItem)=>pkgItem.packageId === pkgId);
360
- if (!pkg) return null;
308
+ const pkg = object.package.find((pkgItem) => pkgItem.packageId === pkgId);
309
+ if (!pkg)
310
+ return null;
361
311
  // Find type
362
- const type = pkg.type.find((typeItem)=>typeItem.typeId === typeId);
363
- if (!type) return null;
312
+ const type = pkg.type.find((typeItem) => typeItem.typeId === typeId);
313
+ if (!type)
314
+ return null;
364
315
  // Find entry
365
- const entry = type.entry.find((entryItem)=>entryItem.entryId === entryId);
366
- if (!entry) return null;
316
+ const entry = type.entry.find((entryItem) => entryItem.entryId === entryId);
317
+ if (!entry)
318
+ return null;
367
319
  // Get value from configValue
368
320
  if (entry.configValue && entry.configValue.length > 0) {
369
- var _entry_configValue_, _val_item_str, _val_item;
370
- const val = (_entry_configValue_ = entry.configValue[0]) == null ? void 0 : _entry_configValue_.value;
371
- const stringValue = val == null ? void 0 : (_val_item = val.item) == null ? void 0 : (_val_item_str = _val_item.str) == null ? void 0 : _val_item_str.value;
321
+ const val = entry.configValue[0]?.value;
322
+ const stringValue = val?.item?.str?.value;
372
323
  if (typeof stringValue === 'string') {
373
324
  return stringValue;
374
325
  }
375
326
  }
376
- } catch (e) {
377
- console.warn((0, _i18n.t)('failedToResolveResource', {
378
- error: e
379
- }));
327
+ }
328
+ catch (e) {
329
+ console.warn((0, i18n_1.t)('failedToResolveResource', { error: e }));
380
330
  }
381
331
  return null;
382
332
  }
383
333
  async function getLatestVersion(pkgNames) {
384
- return (0, _latestversion.default)(pkgNames, {
334
+ return (0, latest_version_1.default)(pkgNames, {
385
335
  // useCache: true,
386
336
  requestOptions: {
387
- timeout: 2000
388
- }
389
- }).then((pkgs)=>pkgs.map((pkg)=>pkg.latest)).catch(()=>[]);
337
+ timeout: 2000,
338
+ },
339
+ })
340
+ .then((pkgs) => pkgs.map((pkg) => pkg.latest))
341
+ .catch(() => []);
390
342
  }
391
343
  async function printVersionCommand() {
392
344
  let [latestRnuCliVersion, latestRnuVersion] = await getLatestVersion([
393
345
  'react-native-update-cli',
394
- 'react-native-update'
346
+ 'react-native-update',
395
347
  ]);
396
- latestRnuCliVersion = latestRnuCliVersion ? ` ${(0, _i18n.t)('latestVersionTag', {
397
- version: _chalk.default.green(latestRnuCliVersion)
398
- })}` : '';
399
- console.log(`react-native-update-cli: ${_packagejson.default.version}${latestRnuCliVersion}`);
400
- const rnuVersion = _depversions.depVersions['react-native-update'];
348
+ latestRnuCliVersion = latestRnuCliVersion
349
+ ? ` ${(0, i18n_1.t)('latestVersionTag', {
350
+ version: chalk_1.default.green(latestRnuCliVersion),
351
+ })}`
352
+ : '';
353
+ console.log(`react-native-update-cli: ${package_json_1.default.version}${latestRnuCliVersion}`);
354
+ const rnuVersion = dep_versions_1.depVersions['react-native-update'];
401
355
  if (rnuVersion) {
402
- latestRnuVersion = latestRnuVersion ? ` ${(0, _i18n.t)('latestVersionTag', {
403
- version: _chalk.default.green(latestRnuVersion)
404
- })}` : '';
356
+ latestRnuVersion = latestRnuVersion
357
+ ? ` ${(0, i18n_1.t)('latestVersionTag', { version: chalk_1.default.green(latestRnuVersion) })}`
358
+ : '';
405
359
  console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
406
- if (_constants.IS_CRESC) {
407
- if ((0, _compareversions.satisfies)(rnuVersion, '<10.27.0')) {
360
+ if (constants_1.IS_CRESC) {
361
+ if ((0, compare_versions_1.satisfies)(rnuVersion, '<10.27.0')) {
408
362
  console.error('Unsupported version, please update to the latest version: npm i react-native-update@latest');
409
363
  process.exit(1);
410
364
  }
411
- } else {
412
- if ((0, _compareversions.satisfies)(rnuVersion, '<8.5.2')) {
365
+ }
366
+ else {
367
+ if ((0, compare_versions_1.satisfies)(rnuVersion, '<8.5.2')) {
413
368
  console.warn(`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
414
369
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
415
- } else if ((0, _compareversions.satisfies)(rnuVersion, '9.0.0 - 9.2.1')) {
370
+ }
371
+ else if ((0, compare_versions_1.satisfies)(rnuVersion, '9.0.0 - 9.2.1')) {
416
372
  console.warn(`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
417
373
  如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`);
418
- } else if ((0, _compareversions.satisfies)(rnuVersion, '10.0.0 - 10.17.0')) {
374
+ }
375
+ else if ((0, compare_versions_1.satisfies)(rnuVersion, '10.0.0 - 10.17.0')) {
419
376
  console.warn('当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10');
420
377
  }
421
378
  }
422
- } else {
423
- console.log((0, _i18n.t)('rnuVersionNotFound'));
379
+ }
380
+ else {
381
+ console.log((0, i18n_1.t)('rnuVersionNotFound'));
424
382
  }
425
383
  }