mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-18 02:16:11 +08:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
387a879d4b | ||
![]() |
1372a30ea3 | ||
![]() |
d51ef37a62 | ||
![]() |
90a59cfe7b | ||
![]() |
ffcc6c9c96 | ||
![]() |
b00b3144a3 | ||
![]() |
d3ee908227 | ||
![]() |
5302c8968f | ||
![]() |
5740a3315c | ||
![]() |
4a11a4118f | ||
![]() |
feb1128748 | ||
![]() |
8fd74d76b1 | ||
![]() |
209a989a48 | ||
![]() |
aab9ea6b98 | ||
![]() |
5f45a66aad | ||
![]() |
67f6aeef02 |
6
cli.json
6
cli.json
@@ -84,6 +84,12 @@
|
|||||||
|
|
||||||
"packageVersion": {
|
"packageVersion": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"minPackageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"maxPackageVersion": {
|
||||||
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.22.0",
|
"version": "1.30.3",
|
||||||
"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",
|
||||||
|
3722
pnpm-lock.yaml
generated
3722
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -166,7 +166,9 @@ export async function uploadFile(fn, key) {
|
|||||||
}
|
}
|
||||||
if (resp.statusCode > 299) {
|
if (resp.statusCode > 299) {
|
||||||
return reject(
|
return reject(
|
||||||
Object.assign(new Error(body), { status: resp.statusCode }),
|
Object.assign(new Error(JSON.stringify(body)), {
|
||||||
|
status: resp.statusCode,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
resolve({ hash: formData.key });
|
resolve({ hash: formData.key });
|
||||||
|
@@ -51,9 +51,21 @@ async function runReactNativeBundleCommand(
|
|||||||
|
|
||||||
fs.emptyDirSync(outputFolder);
|
fs.emptyDirSync(outputFolder);
|
||||||
|
|
||||||
let cliPath = require.resolve('react-native/local-cli/cli.js', {
|
let cliPath;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// rn >= 0.75
|
||||||
|
cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
|
||||||
paths: [process.cwd()],
|
paths: [process.cwd()],
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// rn < 0.75
|
||||||
|
cliPath = require.resolve('react-native/local-cli/cli.js', {
|
||||||
|
paths: [process.cwd()],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let usingExpo = false;
|
||||||
try {
|
try {
|
||||||
require.resolve('expo-router', {
|
require.resolve('expo-router', {
|
||||||
paths: [process.cwd()],
|
paths: [process.cwd()],
|
||||||
@@ -64,10 +76,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,
|
||||||
|
@@ -28,8 +28,8 @@ const commands = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
||||||
printVersionCommand();
|
printVersionCommand();
|
||||||
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 semverSatisfies from 'semver/functions/satisfies';
|
||||||
|
|
||||||
import read from 'read';
|
import read from 'read';
|
||||||
|
|
||||||
@@ -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,22 @@ 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 (semverSatisfies(pushyVersion, '<8.5.1')) {
|
||||||
|
console.warn(
|
||||||
|
'当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8',
|
||||||
|
);
|
||||||
|
} else if (semverSatisfies(pushyVersion, '9.0.0 - 9.2.0')) {
|
||||||
|
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';
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user