1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-11-24 09:13:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Feat/deps (#10)

* init

* add deps

* sort key
This commit is contained in:
Sunny Luo
2025-03-14 13:44:47 +08:00
committed by GitHub
parent 613f39a59e
commit d0495fb271
8 changed files with 125 additions and 65 deletions

View File

@@ -10,6 +10,7 @@ import { checkPlugins } from './check-plugin';
import { read } from 'read';
import { tempDir } from './constants';
import { depVersions } from './dep-versions';
export async function question(query: string, password?: boolean) {
if (NO_INTERACTIVE) {
@@ -38,26 +39,6 @@ export function translateOptions(options: Record<string, string>) {
return ret;
}
export function getRNVersion() {
const version = JSON.parse(
fs
.readFileSync(
require.resolve('react-native/package.json', {
paths: [process.cwd()],
}),
)
.toString(),
).version;
const [, major, minor] = /^(\d+)\.(\d+)\./.exec(version) || [];
return {
version,
major: Number(major),
minor: Number(minor),
};
}
export async function getApkInfo(fn: string) {
const appInfoParser = new AppInfoParser(fn);
const bundleFile = await appInfoParser.parser.getEntry(
@@ -198,21 +179,11 @@ export async function printVersionCommand() {
`react-native-update-cli: ${pkg.version}${latestPushyCliVersion}`,
);
let pushyVersion = '';
try {
const PACKAGE_JSON_PATH = require.resolve(
'react-native-update/package.json',
{
paths: [process.cwd()],
},
);
pushyVersion = require(PACKAGE_JSON_PATH).version;
latestPushyVersion = latestPushyVersion
? ` (最新:${chalk.green(latestPushyVersion)}`
: '';
console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
} catch (e) {
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
}
pushyVersion = depVersions['react-native-update'];
latestPushyVersion = latestPushyVersion
? ` (最新:${chalk.green(latestPushyVersion)}`
: '';
console.log(`react-native-update: ${pushyVersion}${latestPushyVersion}`);
if (pushyVersion) {
if (semverSatisfies(pushyVersion, '<8.5.2')) {
console.warn(
@@ -229,6 +200,8 @@ export async function printVersionCommand() {
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
);
}
} else {
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
}
}