react-native-update-cli 1.44.2 → 1.44.5

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.
@@ -41,7 +41,7 @@ const _packagejson = /*#__PURE__*/ _interop_require_default(require("../../packa
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
43
  const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
44
- const _latestversion = /*#__PURE__*/ _interop_require_default(require("@badisi/latest-version"));
44
+ const _latestversion = /*#__PURE__*/ _interop_require_default(require("../utils/latest-version"));
45
45
  const _checkplugin = require("./check-plugin");
46
46
  const _read = require("read");
47
47
  const _constants = require("./constants");
@@ -194,13 +194,12 @@ async function printVersionCommand() {
194
194
  version: _chalk.default.green(latestRnuCliVersion)
195
195
  })}` : '';
196
196
  console.log(`react-native-update-cli: ${_packagejson.default.version}${latestRnuCliVersion}`);
197
- let rnuVersion = '';
198
- rnuVersion = _depversions.depVersions['react-native-update'];
199
- latestRnuVersion = latestRnuVersion ? ` ${(0, _i18n.t)('latestVersionTag', {
200
- version: _chalk.default.green(latestRnuVersion)
201
- })}` : '';
202
- console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
197
+ const rnuVersion = _depversions.depVersions['react-native-update'];
203
198
  if (rnuVersion) {
199
+ latestRnuVersion = latestRnuVersion ? ` ${(0, _i18n.t)('latestVersionTag', {
200
+ version: _chalk.default.green(latestRnuVersion)
201
+ })}` : '';
202
+ console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
204
203
  if (_constants.IS_CRESC) {
205
204
  if ((0, _satisfies.default)(rnuVersion, '<10.27.0')) {
206
205
  console.error('Unsupported version, please update to the latest version: npm i react-native-update@latest');
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _safe = require("@colors/colors/safe");
6
+ const _nodefs = require("node:fs");
7
+ const _nodepath = require("node:path");
8
+ const _ = /*#__PURE__*/ _interop_require_default(require("."));
9
+ const _major = /*#__PURE__*/ _interop_require_default(require("semver/functions/major"));
10
+ const _diff = /*#__PURE__*/ _interop_require_default(require("semver/functions/diff"));
11
+ function _interop_require_default(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ function _getRequireWildcardCache(nodeInterop) {
17
+ if (typeof WeakMap !== "function") return null;
18
+ var cacheBabelInterop = new WeakMap();
19
+ var cacheNodeInterop = new WeakMap();
20
+ return (_getRequireWildcardCache = function(nodeInterop) {
21
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
+ })(nodeInterop);
23
+ }
24
+ function _interop_require_wildcard(obj, nodeInterop) {
25
+ if (!nodeInterop && obj && obj.__esModule) {
26
+ return obj;
27
+ }
28
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
29
+ return {
30
+ default: obj
31
+ };
32
+ }
33
+ var cache = _getRequireWildcardCache(nodeInterop);
34
+ if (cache && cache.has(obj)) {
35
+ return cache.get(obj);
36
+ }
37
+ var newObj = {
38
+ __proto__: null
39
+ };
40
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
41
+ for(var key in obj){
42
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
43
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
44
+ if (desc && (desc.get || desc.set)) {
45
+ Object.defineProperty(newObj, key, desc);
46
+ } else {
47
+ newObj[key] = obj[key];
48
+ }
49
+ }
50
+ }
51
+ newObj.default = obj;
52
+ if (cache) {
53
+ cache.set(obj, newObj);
54
+ }
55
+ return newObj;
56
+ }
57
+ const colorizeDiff = (from, to)=>{
58
+ const toParts = to.split('.');
59
+ const diffIndex = from.split('.').findIndex((part, i)=>part !== toParts[i]);
60
+ if (diffIndex !== -1) {
61
+ let color = _safe.magenta;
62
+ if (toParts[0] !== '0') {
63
+ color = diffIndex === 0 ? _safe.red : diffIndex === 1 ? _safe.cyan : _safe.green;
64
+ }
65
+ const start = toParts.slice(0, diffIndex).join('.');
66
+ const mid = diffIndex === 0 ? '' : '.';
67
+ const end = color(toParts.slice(diffIndex).join('.'));
68
+ return `${start}${mid}${end}`;
69
+ }
70
+ return to;
71
+ };
72
+ const columnCellRenderer = (column, row)=>{
73
+ let text = row[column.attrName];
74
+ const gap = text.length < column.maxLength ? ' '.repeat(column.maxLength - text.length) : '';
75
+ switch(column.attrName){
76
+ case 'name':
77
+ text = (0, _safe.yellow)(text);
78
+ break;
79
+ case 'installed':
80
+ case 'separator':
81
+ text = (0, _safe.blue)(text);
82
+ break;
83
+ case 'location':
84
+ case 'tagOrRange':
85
+ text = (0, _safe.gray)(text);
86
+ break;
87
+ case 'wanted':
88
+ text = colorizeDiff(row.installed, text);
89
+ break;
90
+ case 'latest':
91
+ if (text !== row.wanted) {
92
+ text = colorizeDiff(row.installed, text);
93
+ }
94
+ break;
95
+ default:
96
+ break;
97
+ }
98
+ return column.align === 'right' ? `${gap}${text}` : `${text}${gap}`;
99
+ };
100
+ const columnHeaderRenderer = (column)=>{
101
+ const text = column.label;
102
+ const gap = text.length < column.maxLength ? ' '.repeat(column.maxLength - text.length) : '';
103
+ return column.align === 'right' ? `${gap}${(0, _safe.underline)(text)}` : `${(0, _safe.underline)(text)}${gap}`;
104
+ };
105
+ const drawBox = (lines, color = _safe.yellow, horizontalPadding = 3)=>{
106
+ const maxLineWidth = lines.reduce((max, row)=>Math.max(max, (0, _safe.strip)(row).length), 0);
107
+ console.log(color(`┌${'─'.repeat(maxLineWidth + horizontalPadding * 2)}┐`));
108
+ lines.forEach((row)=>{
109
+ const padding = ' '.repeat(horizontalPadding);
110
+ const fullRow = `${row}${' '.repeat(maxLineWidth - (0, _safe.strip)(row).length)}`;
111
+ console.log(`${color('│')}${padding}${(0, _safe.reset)(fullRow)}${padding}${color('│')}`);
112
+ });
113
+ console.log(color(`└${'─'.repeat(maxLineWidth + horizontalPadding * 2)}┘`));
114
+ };
115
+ const getTableColumns = (rows)=>{
116
+ const columns = [
117
+ {
118
+ label: 'Package',
119
+ attrName: 'name',
120
+ align: 'left',
121
+ maxLength: 0,
122
+ items: []
123
+ },
124
+ {
125
+ label: 'Location',
126
+ attrName: 'location',
127
+ align: 'left',
128
+ maxLength: 0,
129
+ items: []
130
+ },
131
+ {
132
+ label: 'Installed',
133
+ attrName: 'installed',
134
+ align: 'right',
135
+ maxLength: 0,
136
+ items: []
137
+ },
138
+ {
139
+ label: '',
140
+ attrName: 'separator',
141
+ align: 'center',
142
+ maxLength: 0,
143
+ items: []
144
+ },
145
+ {
146
+ label: 'Range',
147
+ attrName: 'tagOrRange',
148
+ align: 'right',
149
+ maxLength: 0,
150
+ items: []
151
+ },
152
+ {
153
+ label: '',
154
+ attrName: 'separator',
155
+ align: 'center',
156
+ maxLength: 0,
157
+ items: []
158
+ },
159
+ {
160
+ label: 'Wanted',
161
+ attrName: 'wanted',
162
+ align: 'right',
163
+ maxLength: 0,
164
+ items: []
165
+ },
166
+ {
167
+ label: 'Latest',
168
+ attrName: 'latest',
169
+ align: 'right',
170
+ maxLength: 0,
171
+ items: []
172
+ }
173
+ ];
174
+ rows.forEach((row)=>{
175
+ columns.forEach((column)=>{
176
+ column.maxLength = Math.max(column.label.length, column.maxLength, row[column.attrName].length || 0);
177
+ });
178
+ });
179
+ return columns;
180
+ };
181
+ const getTableRows = (updates)=>{
182
+ return updates.reduce((all, pkg)=>{
183
+ const { name, latest, local, globalNpm, globalYarn, wantedTagOrRange, updatesAvailable } = pkg;
184
+ const getGroup = (a, b)=>{
185
+ if (b && (0, _major.default)(b) === 0) {
186
+ return 'majorVersionZero';
187
+ } else if (a && b) {
188
+ var _semverDiff;
189
+ const releaseType = (_semverDiff = (0, _diff.default)(a, b)) != null ? _semverDiff : '';
190
+ if ([
191
+ 'major',
192
+ 'premajor',
193
+ 'prerelease'
194
+ ].includes(releaseType)) {
195
+ return 'major';
196
+ } else if ([
197
+ 'minor',
198
+ 'preminor'
199
+ ].includes(releaseType)) {
200
+ return 'minor';
201
+ } else if ([
202
+ 'patch',
203
+ 'prepatch'
204
+ ].includes(releaseType)) {
205
+ return 'patch';
206
+ }
207
+ }
208
+ return 'unknown';
209
+ };
210
+ const add = (group, location, installed, wanted)=>all.push({
211
+ name: ' ' + name,
212
+ location,
213
+ installed: installed != null ? installed : 'unknown',
214
+ latest: latest != null ? latest : 'unknown',
215
+ tagOrRange: wantedTagOrRange != null ? wantedTagOrRange : 'unknown',
216
+ separator: '→',
217
+ wanted: wanted != null ? wanted : 'unknown',
218
+ group
219
+ });
220
+ if (updatesAvailable) {
221
+ if (updatesAvailable.local) {
222
+ add(getGroup(local, updatesAvailable.local), 'local', local, updatesAvailable.local);
223
+ }
224
+ if (updatesAvailable.globalNpm) {
225
+ add(getGroup(globalNpm, updatesAvailable.globalNpm), 'NPM global', globalNpm, updatesAvailable.globalNpm);
226
+ }
227
+ if (updatesAvailable.globalYarn) {
228
+ add(getGroup(globalYarn, updatesAvailable.globalYarn), 'YARN global', globalYarn, updatesAvailable.globalYarn);
229
+ }
230
+ } else {
231
+ if (local && local !== latest) {
232
+ add(getGroup(local, latest), 'local', local, pkg.wanted);
233
+ }
234
+ if (globalNpm && globalNpm !== latest) {
235
+ add(getGroup(globalNpm, latest), 'NPM global', globalNpm, pkg.wanted);
236
+ }
237
+ if (globalYarn && globalYarn !== latest) {
238
+ add(getGroup(globalYarn, latest), 'YARN global', globalYarn, pkg.wanted);
239
+ }
240
+ if (!local && !globalNpm && !globalYarn) {
241
+ add('unknown', 'unknown', 'unknown', pkg.wanted);
242
+ }
243
+ }
244
+ return all;
245
+ }, []);
246
+ };
247
+ const displayTable = (latestVersionPackages)=>{
248
+ const updates = latestVersionPackages.filter((pkg)=>pkg.updatesAvailable);
249
+ if (updates.length) {
250
+ const rows = getTableRows(updates);
251
+ const hasUpdates = rows.some((row)=>row.installed !== 'unknown');
252
+ const columns = getTableColumns(rows);
253
+ const columnGap = 2;
254
+ const getGroupLines = (groupType, color, title, description)=>{
255
+ const items = rows.filter((row)=>row.group === groupType).sort((a, b)=>a.name > b.name ? 1 : -1);
256
+ return !items.length ? [] : [
257
+ '',
258
+ color(`${(0, _safe.bold)(title)} ${(0, _safe.italic)(`(${description})`)}`),
259
+ ...items.map((row)=>columns.map((column)=>columnCellRenderer(column, row)).join(' '.repeat(columnGap)))
260
+ ];
261
+ };
262
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
263
+ drawBox([
264
+ '',
265
+ hasUpdates ? (0, _safe.yellow)('Important updates are available.') : undefined,
266
+ hasUpdates ? '' : undefined,
267
+ columns.map(columnHeaderRenderer).join(' '.repeat(columnGap)),
268
+ ...getGroupLines('patch', _safe.green, 'Patch', 'backwards-compatible bug fixes'),
269
+ ...getGroupLines('minor', _safe.cyan, 'Minor', 'backwards-compatible features'),
270
+ ...getGroupLines('major', _safe.red, 'Major', 'potentially breaking API changes'),
271
+ ...getGroupLines('majorVersionZero', _safe.magenta, 'Major version zero', 'not stable, anything may change'),
272
+ ...getGroupLines('unknown', _safe.blue, 'Missing', 'not installed'),
273
+ ''
274
+ ].filter((line)=>line !== undefined));
275
+ } else {
276
+ console.log((0, _safe.green)('🎉 Packages are up-to-date'));
277
+ }
278
+ };
279
+ const checkVersions = async (packages, skipMissing, options = {
280
+ useCache: true
281
+ })=>{
282
+ const ora = (await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("ora")))).default;
283
+ const spinner = ora({
284
+ text: (0, _safe.cyan)('Checking versions...')
285
+ });
286
+ spinner.start();
287
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
288
+ // @ts-ignore
289
+ let latestVersionPackages = await (0, _.default)(packages, options);
290
+ if (skipMissing) {
291
+ latestVersionPackages = latestVersionPackages.filter((pkg)=>{
292
+ var _pkg_local, _ref;
293
+ return (_ref = (_pkg_local = pkg.local) != null ? _pkg_local : pkg.globalNpm) != null ? _ref : pkg.globalYarn;
294
+ });
295
+ }
296
+ spinner.stop();
297
+ displayTable(latestVersionPackages);
298
+ };
299
+ void (async ()=>{
300
+ let args = process.argv.slice(2);
301
+ const skipMissing = args.includes('--skip-missing');
302
+ // Remove any options from the arguments
303
+ args = args.filter((arg)=>!arg.startsWith('-'));
304
+ // If argument is a package.json file
305
+ if (args.length === 1 && args[0].endsWith('package.json')) {
306
+ if ((0, _nodefs.existsSync)(args[0])) {
307
+ process.chdir((0, _nodepath.dirname)(args[0]));
308
+ await checkVersions(JSON.parse((0, _nodefs.readFileSync)(args[0]).toString()), skipMissing);
309
+ } else {
310
+ console.log((0, _safe.cyan)('No package.json file were found'));
311
+ }
312
+ } else {
313
+ // Check if a local package.json file exists
314
+ let localPkgJson;
315
+ if ((0, _nodefs.existsSync)('package.json')) {
316
+ localPkgJson = JSON.parse((0, _nodefs.readFileSync)('package.json').toString());
317
+ }
318
+ // Check given arguments
319
+ if (args.length) {
320
+ // Map arguments with any range that could be found in local package.json
321
+ args = args.map((arg)=>{
322
+ var _localPkgJson_dependencies, _localPkgJson_devDependencies, _localPkgJson_peerDependencies;
323
+ if (localPkgJson == null ? void 0 : (_localPkgJson_dependencies = localPkgJson.dependencies) == null ? void 0 : _localPkgJson_dependencies[arg]) {
324
+ var _localPkgJson_dependencies1;
325
+ return `${arg}@${(_localPkgJson_dependencies1 = localPkgJson.dependencies) == null ? void 0 : _localPkgJson_dependencies1[arg]}`;
326
+ }
327
+ if (localPkgJson == null ? void 0 : (_localPkgJson_devDependencies = localPkgJson.devDependencies) == null ? void 0 : _localPkgJson_devDependencies[arg]) {
328
+ var _localPkgJson_devDependencies1;
329
+ return `${arg}@${(_localPkgJson_devDependencies1 = localPkgJson.devDependencies) == null ? void 0 : _localPkgJson_devDependencies1[arg]}`;
330
+ }
331
+ if (localPkgJson == null ? void 0 : (_localPkgJson_peerDependencies = localPkgJson.peerDependencies) == null ? void 0 : _localPkgJson_peerDependencies[arg]) {
332
+ var _localPkgJson_peerDependencies1;
333
+ return `${arg}@${(_localPkgJson_peerDependencies1 = localPkgJson.peerDependencies) == null ? void 0 : _localPkgJson_peerDependencies1[arg]}`;
334
+ }
335
+ return arg;
336
+ });
337
+ await checkVersions(args, skipMissing);
338
+ } else if (localPkgJson) {
339
+ await checkVersions(localPkgJson, skipMissing);
340
+ } else {
341
+ console.log((0, _safe.cyan)('No packages were found'));
342
+ }
343
+ }
344
+ })();
@@ -0,0 +1,261 @@
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: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ ONE_DAY: function() {
13
+ return ONE_DAY;
14
+ },
15
+ default: function() {
16
+ return _default;
17
+ }
18
+ });
19
+ const _nodefs = require("node:fs");
20
+ const _nodepath = require("node:path");
21
+ const _globaldirs = require("global-dirs");
22
+ const _nodeos = require("node:os");
23
+ const _nodeurl = require("node:url");
24
+ const _registryurl = /*#__PURE__*/ _interop_require_default(require("registry-auth-token/registry-url"));
25
+ const _registryauthtoken = /*#__PURE__*/ _interop_require_default(require("registry-auth-token"));
26
+ const _maxsatisfying = /*#__PURE__*/ _interop_require_default(require("semver/ranges/max-satisfying"));
27
+ const _gt = /*#__PURE__*/ _interop_require_default(require("semver/functions/gt"));
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ const ONE_DAY = 1000 * 60 * 60 * 24; // eslint-disable-line @typescript-eslint/naming-convention
34
+ const isPackageJson = (obj)=>{
35
+ return obj.dependencies !== undefined || obj.devDependencies !== undefined || obj.peerDependencies !== undefined;
36
+ };
37
+ const downloadMetadata = (pkgName, options)=>{
38
+ return new Promise((resolve, reject)=>{
39
+ const i = pkgName.indexOf('/');
40
+ const pkgScope = i !== -1 ? pkgName.slice(0, i) : '';
41
+ var _options_registryUrl;
42
+ const registryUrl = (_options_registryUrl = options == null ? void 0 : options.registryUrl) != null ? _options_registryUrl : (0, _registryurl.default)(pkgScope);
43
+ const pkgUrl = new _nodeurl.URL(encodeURIComponent(pkgName).replace(/^%40/, '@'), registryUrl);
44
+ let requestOptions = {
45
+ headers: {
46
+ accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
47
+ },
48
+ host: pkgUrl.hostname,
49
+ path: pkgUrl.pathname,
50
+ port: pkgUrl.port
51
+ };
52
+ const authInfo = (0, _registryauthtoken.default)(pkgUrl.toString(), {
53
+ recursive: true
54
+ });
55
+ if (authInfo && requestOptions.headers) {
56
+ requestOptions.headers.authorization = `${authInfo.type} ${authInfo.token}`;
57
+ }
58
+ if (options == null ? void 0 : options.requestOptions) {
59
+ requestOptions = {
60
+ ...requestOptions,
61
+ ...options.requestOptions
62
+ };
63
+ }
64
+ const { get } = require(pkgUrl.protocol === 'https:' ? 'https' : 'http');
65
+ const request = get(requestOptions, (res)=>{
66
+ if (res.statusCode === 200) {
67
+ let rawData = '';
68
+ res.setEncoding('utf8');
69
+ res.on('data', (chunk)=>rawData += chunk);
70
+ res.once('error', (err)=>{
71
+ res.removeAllListeners();
72
+ reject(`Request error (${err.message}): ${pkgUrl}`);
73
+ });
74
+ res.once('end', ()=>{
75
+ res.removeAllListeners();
76
+ try {
77
+ const pkgMetadata = JSON.parse(rawData);
78
+ resolve({
79
+ name: pkgName,
80
+ lastUpdateDate: Date.now(),
81
+ versions: Object.keys(pkgMetadata.versions),
82
+ distTags: pkgMetadata['dist-tags']
83
+ });
84
+ return;
85
+ } catch (err) {
86
+ reject(err);
87
+ return;
88
+ }
89
+ });
90
+ } else {
91
+ res.removeAllListeners();
92
+ res.resume(); // consume response data to free up memory
93
+ reject(`Request error (${res.statusCode}): ${pkgUrl}`);
94
+ return;
95
+ }
96
+ });
97
+ const abort = (error)=>{
98
+ request.destroy();
99
+ reject(error);
100
+ };
101
+ request.once('timeout', ()=>{
102
+ abort(`Request timed out: ${pkgUrl}`);
103
+ });
104
+ request.once('error', (err)=>{
105
+ abort(err);
106
+ });
107
+ request.on('close', ()=>{
108
+ request.removeAllListeners();
109
+ });
110
+ });
111
+ };
112
+ const getCacheDir = (name = '@badisi/latest-version')=>{
113
+ const homeDir = (0, _nodeos.homedir)();
114
+ switch(process.platform){
115
+ case 'darwin':
116
+ return (0, _nodepath.join)(homeDir, 'Library', 'Caches', name);
117
+ case 'win32':
118
+ var _process_env_LOCALAPPDATA;
119
+ return (0, _nodepath.join)((_process_env_LOCALAPPDATA = process.env.LOCALAPPDATA) != null ? _process_env_LOCALAPPDATA : (0, _nodepath.join)(homeDir, 'AppData', 'Local'), name, 'Cache');
120
+ default:
121
+ var _process_env_XDG_CACHE_HOME;
122
+ return (0, _nodepath.join)((_process_env_XDG_CACHE_HOME = process.env.XDG_CACHE_HOME) != null ? _process_env_XDG_CACHE_HOME : (0, _nodepath.join)(homeDir, '.cache'), name);
123
+ }
124
+ };
125
+ const saveMetadataToCache = (pkg)=>{
126
+ const filePath = (0, _nodepath.join)(getCacheDir(), `${pkg.name}.json`);
127
+ if (!(0, _nodefs.existsSync)((0, _nodepath.dirname)(filePath))) {
128
+ (0, _nodefs.mkdirSync)((0, _nodepath.dirname)(filePath), {
129
+ recursive: true
130
+ });
131
+ }
132
+ (0, _nodefs.writeFileSync)(filePath, JSON.stringify(pkg));
133
+ };
134
+ const getMetadataFromCache = (pkgName, options)=>{
135
+ var _options_cacheMaxAge;
136
+ const maxAge = (_options_cacheMaxAge = options == null ? void 0 : options.cacheMaxAge) != null ? _options_cacheMaxAge : ONE_DAY;
137
+ if (maxAge !== 0) {
138
+ const pkgCacheFilePath = (0, _nodepath.join)(getCacheDir(), `${pkgName}.json`);
139
+ if ((0, _nodefs.existsSync)(pkgCacheFilePath)) {
140
+ const pkg = JSON.parse((0, _nodefs.readFileSync)(pkgCacheFilePath).toString());
141
+ if (Date.now() - pkg.lastUpdateDate < maxAge) {
142
+ return pkg;
143
+ }
144
+ }
145
+ }
146
+ return undefined; // invalidates cache
147
+ };
148
+ const getRegistryVersions = async (pkgName, tagOrRange, options)=>{
149
+ let pkgMetadata;
150
+ if (pkgName.length && (options == null ? void 0 : options.useCache)) {
151
+ pkgMetadata = getMetadataFromCache(pkgName, options);
152
+ if (!pkgMetadata) {
153
+ pkgMetadata = await downloadMetadata(pkgName, options);
154
+ saveMetadataToCache(pkgMetadata);
155
+ }
156
+ } else if (pkgName.length) {
157
+ pkgMetadata = await downloadMetadata(pkgName, options);
158
+ }
159
+ const versions = {
160
+ latest: pkgMetadata == null ? void 0 : pkgMetadata.distTags.latest,
161
+ next: pkgMetadata == null ? void 0 : pkgMetadata.distTags.next
162
+ };
163
+ if (tagOrRange && (pkgMetadata == null ? void 0 : pkgMetadata.distTags[tagOrRange])) {
164
+ versions.wanted = pkgMetadata.distTags[tagOrRange];
165
+ } else if (tagOrRange && (pkgMetadata == null ? void 0 : pkgMetadata.versions.length)) {
166
+ var _maxSatisfying;
167
+ versions.wanted = (_maxSatisfying = (0, _maxsatisfying.default)(pkgMetadata.versions, tagOrRange)) != null ? _maxSatisfying : undefined;
168
+ }
169
+ return versions;
170
+ };
171
+ const getInstalledVersion = (pkgName, location = 'local')=>{
172
+ try {
173
+ if (location === 'globalNpm') {
174
+ var _require;
175
+ return (_require = require((0, _nodepath.join)(_globaldirs.npm.packages, pkgName, 'package.json'))) == null ? void 0 : _require.version;
176
+ } else if (location === 'globalYarn') {
177
+ var _yarnGlobalPkg_dependencies, _require1;
178
+ // Make sure package is globally installed by Yarn
179
+ const yarnGlobalPkg = require((0, _nodepath.resolve)(_globaldirs.yarn.packages, '..', 'package.json'));
180
+ if (!(yarnGlobalPkg == null ? void 0 : (_yarnGlobalPkg_dependencies = yarnGlobalPkg.dependencies) == null ? void 0 : _yarnGlobalPkg_dependencies[pkgName])) {
181
+ return undefined;
182
+ }
183
+ return (_require1 = require((0, _nodepath.join)(_globaldirs.yarn.packages, pkgName, 'package.json'))) == null ? void 0 : _require1.version;
184
+ } else {
185
+ /**
186
+ * Compute the local paths manually as require.resolve() and require.resolve.paths()
187
+ * cannot be trusted anymore.
188
+ * @see https://github.com/nodejs/node/issues/33460
189
+ * @see https://github.com/nodejs/loaders/issues/26
190
+ */ const { root } = (0, _nodepath.parse)(process.cwd());
191
+ let path = process.cwd();
192
+ const localPaths = [
193
+ (0, _nodepath.join)(path, 'node_modules')
194
+ ];
195
+ while(path !== root){
196
+ path = (0, _nodepath.dirname)(path);
197
+ localPaths.push((0, _nodepath.join)(path, 'node_modules'));
198
+ }
199
+ for (const localPath of localPaths){
200
+ const pkgPath = (0, _nodepath.join)(localPath, pkgName, 'package.json');
201
+ if ((0, _nodefs.existsSync)(pkgPath)) {
202
+ var _require2;
203
+ return (_require2 = require(pkgPath)) == null ? void 0 : _require2.version;
204
+ }
205
+ }
206
+ }
207
+ return undefined;
208
+ } catch (e) {
209
+ return undefined;
210
+ }
211
+ };
212
+ const getInfo = async (pkg, options)=>{
213
+ const i = pkg.lastIndexOf('@');
214
+ let pkgInfo = {
215
+ name: i > 1 ? pkg.slice(0, i) : pkg,
216
+ wantedTagOrRange: i > 1 ? pkg.slice(i + 1) : 'latest',
217
+ updatesAvailable: false
218
+ };
219
+ try {
220
+ pkgInfo = {
221
+ ...pkgInfo,
222
+ local: getInstalledVersion(pkgInfo.name, 'local'),
223
+ globalNpm: getInstalledVersion(pkgInfo.name, 'globalNpm'),
224
+ globalYarn: getInstalledVersion(pkgInfo.name, 'globalYarn'),
225
+ ...await getRegistryVersions(pkgInfo.name, pkgInfo.wantedTagOrRange, options)
226
+ };
227
+ const local = pkgInfo.local && pkgInfo.wanted ? (0, _gt.default)(pkgInfo.wanted, pkgInfo.local) ? pkgInfo.wanted : false : false;
228
+ const globalNpm = pkgInfo.globalNpm && pkgInfo.wanted ? (0, _gt.default)(pkgInfo.wanted, pkgInfo.globalNpm) ? pkgInfo.wanted : false : false;
229
+ const globalYarn = pkgInfo.globalYarn && pkgInfo.wanted ? (0, _gt.default)(pkgInfo.wanted, pkgInfo.globalYarn) ? pkgInfo.wanted : false : false;
230
+ pkgInfo.updatesAvailable = local || globalNpm || globalYarn ? {
231
+ local,
232
+ globalNpm,
233
+ globalYarn
234
+ } : false;
235
+ } catch (err) {
236
+ var _err_message;
237
+ pkgInfo.error = (_err_message = err == null ? void 0 : err.message) != null ? _err_message : err;
238
+ }
239
+ return pkgInfo;
240
+ };
241
+ const latestVersion = async (arg, options)=>{
242
+ const pkgs = [];
243
+ if (typeof arg === 'string') {
244
+ pkgs.push(arg);
245
+ } else if (Array.isArray(arg)) {
246
+ pkgs.push(...arg);
247
+ } else if (isPackageJson(arg)) {
248
+ const addDeps = (deps)=>{
249
+ if (deps) {
250
+ pkgs.push(...Object.keys(deps).map((key)=>`${key}@${deps[key]}`));
251
+ }
252
+ };
253
+ addDeps(arg.dependencies);
254
+ addDeps(arg.devDependencies);
255
+ addDeps(arg.peerDependencies);
256
+ }
257
+ const jobs = await Promise.allSettled(pkgs.map((pkg)=>getInfo(pkg, options)));
258
+ const results = jobs.map((jobResult)=>jobResult.value);
259
+ return typeof arg === 'string' ? results[0] : results;
260
+ };
261
+ const _default = latestVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.44.2",
3
+ "version": "1.44.5",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "swc src -d lib --strip-leading-paths",
17
- "prepare": "npm run build && chmod +x lib/index.js",
17
+ "prepublishOnly": "npm run build && chmod +x lib/index.js",
18
18
  "lint": "tsc --noEmit & biome check --write ."
19
19
  },
20
20
  "repository": {
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
37
37
  "dependencies": {
38
- "@badisi/latest-version": "^7.0.13",
38
+ "@colors/colors": "^1.6.0",
39
39
  "bplist-parser": "^0.3.2",
40
40
  "bytebuffer": "^5.0.1",
41
41
  "cgbi-to-png": "^1.0.7",
@@ -46,6 +46,7 @@
46
46
  "filesize-parser": "^1.5.1",
47
47
  "form-data": "^4.0.2",
48
48
  "fs-extra": "8",
49
+ "global-dirs": "^4.0.0",
49
50
  "gradle-to-js": "^2.0.1",
50
51
  "i18next": "^24.2.3",
51
52
  "isomorphic-git": "^1.30.1",
@@ -55,6 +56,7 @@
55
56
  "progress": "^2.0.3",
56
57
  "properties": "^1.2.1",
57
58
  "read": "^4.1.0",
59
+ "registry-auth-token": "^5.1.0",
58
60
  "semver": "^7.7.1",
59
61
  "tcp-ping": "^0.1.1",
60
62
  "tty-table": "4.2",
@@ -66,8 +68,8 @@
66
68
  },
67
69
  "devDependencies": {
68
70
  "@biomejs/biome": "^1.9.4",
69
- "@swc/cli": "^0.7.2",
70
- "@swc/core": "^1.11.21",
71
+ "@swc/cli": "0.7.3",
72
+ "@swc/core": "^1.11.24",
71
73
  "@types/filesize-parser": "^1.5.3",
72
74
  "@types/fs-extra": "^11.0.4",
73
75
  "@types/node": "^22.14.1",