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

Compare commits

..

8 Commits

Author SHA1 Message Date
sunnylqm
ffcc6c9c96 v1.30.0 2024-09-24 21:20:18 +08:00
sunnylqm
b00b3144a3 v1.29.0 2024-09-22 17:45:10 +08:00
sunnylqm
d3ee908227 warn version 2024-09-22 17:44:31 +08:00
sunnylqm
5302c8968f fix expo cli on windows 2024-08-22 17:15:17 +08:00
sunnylqm
5740a3315c v1.28.0 2024-08-22 17:15:04 +08:00
sunnylqm
4a11a4118f add min/max packageverion 2024-07-21 23:12:15 +08:00
sunnylqm
feb1128748 v1.26.0 2024-07-10 09:48:06 +08:00
sunnylqm
8fd74d76b1 v1.25.1 2024-07-05 10:34:18 +08:00
7 changed files with 2163 additions and 1792 deletions

View File

@@ -84,6 +84,12 @@
"packageVersion": { "packageVersion": {
"hasValue": true "hasValue": true
},
"minPackageVersion": {
"hasValue": true
},
"maxPackageVersion": {
"hasValue": true
} }
} }
}, },

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update-cli", "name": "react-native-update-cli",
"version": "1.25.0", "version": "1.30.0",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.", "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"main": "index.js", "main": "index.js",
"bin": { "bin": {
@@ -12,7 +12,7 @@
"cli.json" "cli.json"
], ],
"scripts": { "scripts": {
"prepublish": "babel src --out-dir lib" "prepublish": "babel src --out-dir lib && chmod +x lib/index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -36,6 +36,7 @@
"cgbi-to-png": "^1.0.7", "cgbi-to-png": "^1.0.7",
"cli-arguments": "^0.2.1", "cli-arguments": "^0.2.1",
"commander": "^7.2.0", "commander": "^7.2.0",
"compare-versions": "^6.1.1",
"filesize-parser": "^1.5.0", "filesize-parser": "^1.5.0",
"fs-extra": "8", "fs-extra": "8",
"gradle-to-js": "^2.0.1", "gradle-to-js": "^2.0.1",

3874
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -54,6 +54,7 @@ async function runReactNativeBundleCommand(
let cliPath = require.resolve('react-native/local-cli/cli.js', { let cliPath = require.resolve('react-native/local-cli/cli.js', {
paths: [process.cwd()], paths: [process.cwd()],
}); });
let usingExpo = false;
try { try {
require.resolve('expo-router', { require.resolve('expo-router', {
paths: [process.cwd()], paths: [process.cwd()],
@@ -64,10 +65,9 @@ async function runReactNativeBundleCommand(
cliPath = require.resolve('@expo/cli', { cliPath = require.resolve('@expo/cli', {
paths: [process.cwd()], paths: [process.cwd()],
}); });
usingExpo = true;
} catch (e) {} } catch (e) {}
const bundleCommand = cliPath.includes('@expo/cli') const bundleCommand = usingExpo ? 'export:embed' : 'bundle';
? 'export:embed'
: 'bundle';
Array.prototype.push.apply(reactNativeBundleArgs, [ Array.prototype.push.apply(reactNativeBundleArgs, [
cliPath, cliPath,
@@ -204,7 +204,7 @@ async function compileHermesByteCode(
} }
const hermesCommand = `${hermesPath}/hermesc`; const hermesCommand = `${hermesPath}/hermesc`;
const args = [ const args = [
'-emit-binary', '-emit-binary',
'-out', '-out',

View File

@@ -28,8 +28,8 @@ const commands = {
}; };
function run() { function run() {
printVersionCommand();
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') { if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
printVersionCommand();
process.exit(); process.exit();
} }

View File

@@ -3,6 +3,7 @@ import os from 'os';
import path from 'path'; import path from 'path';
import pkg from '../../package.json'; import pkg from '../../package.json';
import AppInfoParser from './app-info-parser'; import AppInfoParser from './app-info-parser';
import semverLt from 'semver/functions/lt';
import read from 'read'; import read from 'read';
@@ -83,7 +84,7 @@ export async function getApkInfo(fn) {
} }
if (buildTime == 0) { if (buildTime == 0) {
throw new Error( throw new Error(
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。', '无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
); );
} }
return { versionName, buildTime, ...appCredential }; return { versionName, buildTime, ...appCredential };
@@ -119,7 +120,7 @@ export async function getIpaInfo(fn) {
} }
if (!buildTimeTxtBuffer) { if (!buildTimeTxtBuffer) {
throw new Error( throw new Error(
'无法获取此包的编译时间戳。请更新react-native-update到最新版本后重新打包上传。', '无法获取此包的编译时间戳。请更新 react-native-update 到最新版本后重新打包上传。',
); );
} }
const buildTime = buildTimeTxtBuffer.toString().replace('\n', ''); const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
@@ -137,6 +138,7 @@ export function saveToLocal(originPath, destName) {
export function printVersionCommand() { export function printVersionCommand() {
console.log('react-native-update-cli: ' + pkg.version); console.log('react-native-update-cli: ' + pkg.version);
let pushyVersion = '';
try { try {
const PACKAGE_JSON_PATH = require.resolve( const PACKAGE_JSON_PATH = require.resolve(
'react-native-update/package.json', 'react-native-update/package.json',
@@ -144,10 +146,23 @@ export function printVersionCommand() {
paths: [process.cwd()], paths: [process.cwd()],
}, },
); );
console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version); pushyVersion = require(PACKAGE_JSON_PATH).version;
console.log('react-native-update: ' + pushyVersion);
} catch (e) { } catch (e) {
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令'); console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');
} }
if (pushyVersion) {
if (semverLt(pushyVersion, '8.5.1')) {
console.warn(
'当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8',
);
}
if (semverLt(pushyVersion, '9.2.1')) {
console.warn(
'当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动): npm i react-native-update@9',
);
}
}
} }
export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html'; export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';

View File

@@ -3,6 +3,7 @@ import { question, saveToLocal } from './utils';
import { checkPlatform, getSelectedApp } from './app'; import { checkPlatform, getSelectedApp } from './app';
import { choosePackage } from './package'; import { choosePackage } from './package';
import { compare } from 'compare-versions';
async function showVersion(appId, offset) { async function showVersion(appId, offset) {
const { data, count } = await get(`/app/${appId}/version/list`); const { data, count } = await get(`/app/${appId}/version/list`);
@@ -127,6 +128,8 @@ export const commands = {
let pkgId; let pkgId;
let pkgVersion = options.packageVersion; let pkgVersion = options.packageVersion;
let minPkgVersion = options.minPackageVersion;
let maxPkgVersion = options.maxPackageVersion;
if (pkgVersion) { if (pkgVersion) {
pkgVersion = pkgVersion.trim(); pkgVersion = pkgVersion.trim();
const { data } = await get(`/app/${appId}/package/list?limit=1000`); const { data } = await get(`/app/${appId}/package/list?limit=1000`);
@@ -137,6 +140,42 @@ export const commands = {
throw new Error(`未查询到匹配原生版本:${pkgVersion}`); throw new Error(`未查询到匹配原生版本:${pkgVersion}`);
} }
} }
if (minPkgVersion) {
minPkgVersion = String(minPkgVersion).trim();
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
const pkgs = data.filter((d) => compare(d.name, minPkgVersion, '>='));
if (pkgs.length === 0) {
throw new Error(
`未查询到 >= ${minPkgVersion} 的原生版本`,
);
}
for (const pkg of pkgs) {
await put(`/app/${appId}/package/${pkg.id}`, {
versionId,
});
console.log(`已将版本 ${versionId} 绑定到原生版本 ${pkg.name}`);
}
console.log(`操作完成,共已绑定 ${pkgs.length} 个原生版本`);
return;
}
if (maxPkgVersion) {
maxPkgVersion = String(maxPkgVersion).trim();
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
const pkgs = data.filter((d) => compare(d.name, maxPkgVersion, '<='));
if (pkgs.length === 0) {
throw new Error(
`未查询到 <= ${maxPkgVersion} 的原生版本`,
);
}
for (const pkg of pkgs) {
await put(`/app/${appId}/package/${pkg.id}`, {
versionId,
});
console.log(`已将版本 ${versionId} 绑定到原生版本 ${pkg.name}`);
}
console.log(`操作完成,共已绑定 ${pkgs.length} 个原生版本`);
return;
}
if (!pkgId) { if (!pkgId) {
pkgId = options.packageId || (await choosePackage(appId)).id; pkgId = options.packageId || (await choosePackage(appId)).id;
} }