1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-16 01:41:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2025-03-10 22:56:58 +08:00
parent a1231f6a73
commit fbad603d05
4 changed files with 21 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update-cli",
"version": "1.41.0",
"version": "1.42.0",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"main": "index.js",
"bin": {

View File

@@ -5,7 +5,7 @@ import { checkPlatform, getSelectedApp } from './app';
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
import Table from 'tty-table';
import { depVersions } from 'utils/dep-versions';
import { depVersions } from './utils/dep-versions';
export async function listPackage(appId: string) {
const { data } = await get(`/app/${appId}/package/list?limit=1000`);

View File

@@ -1,10 +1,10 @@
import currentPackage from '../../package.json';
const currentPackage = require(`${process.cwd()}/package.json`);
const depKeys = Object.keys(currentPackage.dependencies);
const devDepKeys = Object.keys(currentPackage.devDependencies);
const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
export const depVersions: Record<string, string> = {};
const _depVersions: Record<string, string> = {};
for (const dep of dedupedDeps) {
try {
@@ -12,6 +12,15 @@ for (const dep of dedupedDeps) {
paths: [process.cwd()],
});
const version = require(packageJsonPath).version;
depVersions[dep] = version;
_depVersions[dep] = version;
} catch (e) {}
}
export const depVersions = Object.keys(_depVersions)
.sort() // Sort the keys alphabetically
.reduce((obj, key) => {
obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
return obj;
}, {} as Record<string, string>);
// console.log({ depVersions });

View File

@@ -4,7 +4,7 @@ import { question, saveToLocal } from './utils';
import { checkPlatform, getSelectedApp } from './app';
import { choosePackage } from './package';
import { compare } from 'compare-versions';
import { depVersions } from 'utils/dep-versions';
import { depVersions } from './utils/dep-versions';
async function showVersion(appId: string, offset: number) {
const { data, count } = await get(`/app/${appId}/version/list`);
@@ -14,11 +14,11 @@ async function showVersion(appId: string, offset: number) {
.slice(0, 3)
.map((v) => v.name)
.join(', ');
const count = version.packages.length;
if (count > 3) {
packageInfo += `...and ${count - 3} more`;
const pkgCount = version.packages.length;
if (pkgCount > 3) {
packageInfo += `...and ${pkgCount - 3} more`;
}
if (count === 0) {
if (pkgCount === 0) {
packageInfo = 'no package';
} else {
packageInfo = `[${packageInfo}]`;
@@ -32,7 +32,7 @@ async function showVersion(appId: string, offset: number) {
return data;
}
async function listVersions(appId) {
async function listVersions(appId: string) {
let offset = 0;
while (true) {
await showVersion(appId, offset);
@@ -53,7 +53,7 @@ async function listVersions(appId) {
}
}
async function chooseVersion(appId) {
async function chooseVersion(appId: string) {
let offset = 0;
while (true) {
const data = await showVersion(appId, offset);