mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 18:06:10 +08:00
Compare commits
1 Commits
v1.5.0
...
v1.4.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f51223a662 |
33
cli.json
33
cli.json
@@ -123,7 +123,7 @@
|
|||||||
"description": "Create diff patch",
|
"description": "Create diff patch",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": ".pushy/output/diff",
|
"default": "build/output/diff",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
"description": "Create diff patch from a Android package(.apk)",
|
"description": "Create diff patch from a Android package(.apk)",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": ".pushy/output/diff-${time}.apk-patch",
|
"default": "build/output/diff-${time}.apk-patch",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,34 +141,7 @@
|
|||||||
"description": "Create diff patch from a iOS package(.ipa)",
|
"description": "Create diff patch from a iOS package(.ipa)",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": ".pushy/output/diff-${time}.ipa-patch",
|
"default": "build/output/diff-${time}.ipa-patch",
|
||||||
"hasValue": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hdiff": {
|
|
||||||
"description": "Create hdiff patch",
|
|
||||||
"options": {
|
|
||||||
"output": {
|
|
||||||
"default": ".pushy/output/hdiff",
|
|
||||||
"hasValue": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hdiffFromApk": {
|
|
||||||
"description": "Create hdiff patch from a Android package(.apk)",
|
|
||||||
"options": {
|
|
||||||
"output": {
|
|
||||||
"default": ".pushy/output/hdiff-${time}.apk-patch",
|
|
||||||
"hasValue": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hdiffFromIpa": {
|
|
||||||
"description": "Create hdiff patch from a iOS package(.ipa)",
|
|
||||||
"options": {
|
|
||||||
"output": {
|
|
||||||
"default": ".pushy/output/hdiff-${time}.ipa-patch",
|
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.5.0",
|
"version": "1.4.0-beta0",
|
||||||
"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": {
|
||||||
|
27
src/api.js
27
src/api.js
@@ -65,14 +65,7 @@ exports.closeSession = function () {
|
|||||||
|
|
||||||
async function query(url, options) {
|
async function query(url, options) {
|
||||||
const resp = await fetch(url, options);
|
const resp = await fetch(url, options);
|
||||||
const text = await resp.text();
|
const json = await resp.json();
|
||||||
let json;
|
|
||||||
try {
|
|
||||||
json = JSON.parse(text);
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(`Server error: ${text}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
throw Object.assign(new Error(json.message || json.error), {
|
throw Object.assign(new Error(json.message || json.error), {
|
||||||
status: resp.status,
|
status: resp.status,
|
||||||
@@ -119,18 +112,14 @@ async function uploadFile(fn, key) {
|
|||||||
let realUrl = url;
|
let realUrl = url;
|
||||||
|
|
||||||
if (backupUrl) {
|
if (backupUrl) {
|
||||||
if (global.USE_ACC_OSS) {
|
const pingResult = await tcpPing({
|
||||||
|
address: url.replace('https://', ''),
|
||||||
|
attempts: 4,
|
||||||
|
timeout: 1000,
|
||||||
|
});
|
||||||
|
// console.log({pingResult});
|
||||||
|
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
|
||||||
realUrl = backupUrl;
|
realUrl = backupUrl;
|
||||||
} else {
|
|
||||||
const pingResult = await tcpPing({
|
|
||||||
address: url.replace('https://', ''),
|
|
||||||
attempts: 4,
|
|
||||||
timeout: 1000,
|
|
||||||
});
|
|
||||||
// console.log({pingResult});
|
|
||||||
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
||||||
realUrl = backupUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// console.log({realUrl});
|
// console.log({realUrl});
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,6 @@ const os = require('os');
|
|||||||
var bsdiff, hdiff, diff;
|
var bsdiff, hdiff, diff;
|
||||||
try {
|
try {
|
||||||
bsdiff = require('node-bsdiff').diff;
|
bsdiff = require('node-bsdiff').diff;
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
hdiff = require('node-hdiffpatch').diff;
|
hdiff = require('node-hdiffpatch').diff;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
@@ -32,12 +29,12 @@ async function runReactNativeBundleCommand(
|
|||||||
config,
|
config,
|
||||||
) {
|
) {
|
||||||
let gradleConfig = {};
|
let gradleConfig = {};
|
||||||
if (platform === 'android') {
|
// if (platform === 'android') {
|
||||||
gradleConfig = await checkGradleConfig();
|
// gradleConfig = await checkGradleConfig();
|
||||||
// if (gradleConfig.crunchPngs !== false) {
|
// if (gradleConfig.crunchPngs !== false) {
|
||||||
// throw new Error('请先禁用android的crunchPngs优化,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8android%E7%9A%84crunch%E4%BC%98%E5%8C%96')
|
// throw new Error('请先禁用android的crunchPngs优化,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8android%E7%9A%84crunch%E4%BC%98%E5%8C%96')
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
let reactNativeBundleArgs = [];
|
let reactNativeBundleArgs = [];
|
||||||
|
|
||||||
@@ -119,6 +116,7 @@ async function checkGradleConfig() {
|
|||||||
try {
|
try {
|
||||||
const gradleConfig = await g2js.parseFile('android/app/build.gradle');
|
const gradleConfig = await g2js.parseFile('android/app/build.gradle');
|
||||||
const projectConfig = gradleConfig['project.ext.react'];
|
const projectConfig = gradleConfig['project.ext.react'];
|
||||||
|
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
||||||
for (const packagerConfig of projectConfig) {
|
for (const packagerConfig of projectConfig) {
|
||||||
if (
|
if (
|
||||||
packagerConfig.includes('enableHermes') &&
|
packagerConfig.includes('enableHermes') &&
|
||||||
@@ -128,7 +126,6 @@ async function checkGradleConfig() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
return {
|
return {
|
||||||
enableHermes,
|
enableHermes,
|
||||||
@@ -476,7 +473,7 @@ function enumZipEntries(zipFn, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function diffArgsCheck(args, options, diffFn) {
|
function diffArgsCheck({ args, options, diffFn }) {
|
||||||
const [origin, next] = args;
|
const [origin, next] = args;
|
||||||
|
|
||||||
if (!origin || !next) {
|
if (!origin || !next) {
|
||||||
@@ -565,25 +562,29 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async diff({ args, options }) {
|
async diff({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
|
const { origin, next, realOutput } = diffArgsCheck({ args, options, diff });
|
||||||
|
|
||||||
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(`${realOutput} generated.`);
|
||||||
},
|
},
|
||||||
|
|
||||||
async hdiff({ args, options }) {
|
async hdiff({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
|
const { origin, next, realOutput } = diffArgsCheck({
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
hdiff,
|
||||||
|
});
|
||||||
|
|
||||||
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(`${realOutput} generated.`);
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromApk({ args, options }) {
|
async diffFromApk({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(
|
const { origin, next, realOutput } = diffArgsCheck({
|
||||||
args,
|
args,
|
||||||
options,
|
options,
|
||||||
'diffFromApk',
|
diffFromApk,
|
||||||
);
|
});
|
||||||
|
|
||||||
await diffFromPackage(
|
await diffFromPackage(
|
||||||
origin,
|
origin,
|
||||||
@@ -595,11 +596,11 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async hdiffFromApk({ args, options }) {
|
async hdiffFromApk({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(
|
const { origin, next, realOutput } = diffArgsCheck({
|
||||||
args,
|
args,
|
||||||
options,
|
options,
|
||||||
'hdiffFromApk',
|
hdiffFromApk,
|
||||||
);
|
});
|
||||||
|
|
||||||
await diffFromPackage(
|
await diffFromPackage(
|
||||||
origin,
|
origin,
|
||||||
@@ -611,11 +612,11 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async diffFromIpa({ args, options }) {
|
async diffFromIpa({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(
|
const { origin, next, realOutput } = diffArgsCheck({
|
||||||
args,
|
args,
|
||||||
options,
|
options,
|
||||||
'diffFromIpa',
|
diffFromIpa,
|
||||||
);
|
});
|
||||||
|
|
||||||
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
||||||
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
||||||
@@ -626,11 +627,11 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async hdiffFromIpa({ args, options }) {
|
async hdiffFromIpa({ args, options }) {
|
||||||
const { origin, next, realOutput } = diffArgsCheck(
|
const { origin, next, realOutput } = diffArgsCheck({
|
||||||
args,
|
args,
|
||||||
options,
|
options,
|
||||||
'hdiffFromIpa',
|
hdiffFromIpa,
|
||||||
);
|
});
|
||||||
|
|
||||||
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
||||||
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
||||||
|
@@ -36,7 +36,6 @@ function run() {
|
|||||||
|
|
||||||
const argv = require('cli-arguments').parse(require('../cli.json'));
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
||||||
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
||||||
global.USE_ACC_OSS = argv.options['acc'];
|
|
||||||
|
|
||||||
loadSession()
|
loadSession()
|
||||||
.then(()=>commands[argv.command](argv))
|
.then(()=>commands[argv.command](argv))
|
||||||
|
Reference in New Issue
Block a user