mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 18:06:10 +08:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d912ace4a7 | ||
![]() |
8af4d314ce | ||
![]() |
f2d5269512 | ||
![]() |
fe24c4ca36 | ||
![]() |
cf61c297a6 | ||
![]() |
f9adc700ed | ||
![]() |
dcff16cbb5 | ||
![]() |
2bb8e83010 | ||
![]() |
0cfc6e4f0d |
4
cli.json
4
cli.json
@@ -140,7 +140,9 @@
|
||||
"default": ".pushy/output/${platform}.${time}.ppk",
|
||||
"hasValue": true
|
||||
},
|
||||
"verbose": {}
|
||||
"sourcemap": {
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update-cli",
|
||||
"version": "1.9.0",
|
||||
"version": "1.13.0",
|
||||
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -36,9 +36,10 @@
|
||||
"cli-arguments": "^0.2.1",
|
||||
"filesize-parser": "^1.5.0",
|
||||
"fs-extra": "8",
|
||||
"gradle-to-js": "^2.0.0",
|
||||
"gradle-to-js": "^2.0.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"progress": "^2.0.3",
|
||||
"properties": "^1.2.1",
|
||||
"read": "^1.0.7",
|
||||
"request": "^2.88.2",
|
||||
"tcp-ping": "^0.1.1",
|
||||
|
1024
pnpm-lock.yaml
generated
1024
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
const fetch = require('node-fetch');
|
||||
const defaultEndpoint = 'http://u.reactnative.cn/api';
|
||||
const defaultEndpoint = 'https://update.reactnative.cn/api';
|
||||
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
||||
const fs = require('fs');
|
||||
import request from 'request';
|
||||
|
105
src/bundle.js
105
src/bundle.js
@@ -8,6 +8,7 @@ import { checkPlatform } from './app';
|
||||
const { spawn, spawnSync } = require('child_process');
|
||||
const g2js = require('gradle-to-js/lib/parser');
|
||||
const os = require('os');
|
||||
const properties = require('properties');
|
||||
|
||||
var bsdiff, hdiff, diff;
|
||||
try {
|
||||
@@ -94,8 +95,39 @@ async function runReactNativeBundleCommand(
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (gradleConfig.enableHermes) {
|
||||
await compileHermesByteCode(bundleName, outputFolder);
|
||||
let hermesEnabled = false;
|
||||
|
||||
if (platform === 'android') {
|
||||
const gradlePropeties = await new Promise((resolve) => {
|
||||
properties.parse(
|
||||
'./android/gradle.properties',
|
||||
{ path: true },
|
||||
function (error, props) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
resolve(null);
|
||||
}
|
||||
|
||||
resolve(props);
|
||||
},
|
||||
);
|
||||
});
|
||||
hermesEnabled = gradlePropeties.hermesEnabled;
|
||||
|
||||
if (typeof hermesEnabled !== 'boolean')
|
||||
hermesEnabled = gradleConfig.enableHermes;
|
||||
} else if (
|
||||
platform === 'ios' &&
|
||||
fs.existsSync('ios/Pods/hermes-engine')
|
||||
) {
|
||||
hermesEnabled = true;
|
||||
}
|
||||
if (hermesEnabled) {
|
||||
await compileHermesByteCode(
|
||||
bundleName,
|
||||
outputFolder,
|
||||
sourcemapOutput,
|
||||
);
|
||||
}
|
||||
resolve(null);
|
||||
}
|
||||
@@ -132,28 +164,38 @@ async function checkGradleConfig() {
|
||||
};
|
||||
}
|
||||
|
||||
async function compileHermesByteCode(bundleName, outputFolder) {
|
||||
async function compileHermesByteCode(
|
||||
bundleName,
|
||||
outputFolder,
|
||||
sourcemapOutput,
|
||||
) {
|
||||
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
||||
const hermesPackage = fs.existsSync('node_modules/hermes-engine')
|
||||
? 'node_modules/hermes-engine' // 0.2+
|
||||
: 'node_modules/hermesvm'; // < 0.2
|
||||
const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
|
||||
// >= rn 0.69
|
||||
let hermesCommand = `node_modules/react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`;
|
||||
// < rn 0.69
|
||||
if (!fs.existsSync(hermesCommand)) {
|
||||
const hermesPackage = fs.existsSync('node_modules/hermes-engine')
|
||||
? 'node_modules/hermes-engine' // 0.2+
|
||||
: 'node_modules/hermesvm'; // < 0.2
|
||||
const hermesPath = `${hermesPackage}/${getHermesOSBin()}`;
|
||||
|
||||
const hermesCommand = fs.existsSync(`${hermesPath}/hermesc`)
|
||||
? `${hermesPath}/hermesc` // 0.5+
|
||||
: `${hermesPath}/hermes`; // < 0.5
|
||||
|
||||
spawnSync(
|
||||
path.join.apply(null, hermesCommand.split('/')),
|
||||
[
|
||||
'-emit-binary',
|
||||
'-out',
|
||||
path.join(outputFolder, bundleName),
|
||||
path.join(outputFolder, bundleName),
|
||||
'-O',
|
||||
],
|
||||
{ stdio: 'ignore' },
|
||||
);
|
||||
hermesCommand = fs.existsSync(`${hermesPath}/hermesc`)
|
||||
? `${hermesPath}/hermesc` // 0.5+
|
||||
: `${hermesPath}/hermes`; // < 0.5
|
||||
}
|
||||
const args = [
|
||||
'-emit-binary',
|
||||
'-out',
|
||||
path.join(outputFolder, bundleName),
|
||||
path.join(outputFolder, bundleName),
|
||||
'-O',
|
||||
];
|
||||
if (sourcemapOutput) {
|
||||
args.push('-output-source-map');
|
||||
}
|
||||
spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
|
||||
stdio: 'ignore',
|
||||
});
|
||||
}
|
||||
|
||||
async function pack(dir, output) {
|
||||
@@ -514,19 +556,13 @@ export const commands = {
|
||||
options.platform || (await question('平台(ios/android):')),
|
||||
);
|
||||
|
||||
let {
|
||||
bundleName,
|
||||
entryFile,
|
||||
intermediaDir,
|
||||
output,
|
||||
dev,
|
||||
verbose,
|
||||
} = translateOptions({
|
||||
...options,
|
||||
platform,
|
||||
});
|
||||
let { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
|
||||
translateOptions({
|
||||
...options,
|
||||
platform,
|
||||
});
|
||||
|
||||
// const sourcemapOutput = path.join(intermediaDir, bundleName + ".map");
|
||||
const sourcemapOutput = path.join(intermediaDir, bundleName + '.map');
|
||||
|
||||
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
||||
|
||||
@@ -545,6 +581,7 @@ export const commands = {
|
||||
entryFile,
|
||||
intermediaDir,
|
||||
platform,
|
||||
sourcemap ? sourcemapOutput : '',
|
||||
);
|
||||
|
||||
await pack(path.resolve(intermediaDir), realOutput);
|
||||
|
@@ -65,7 +65,7 @@ export const commands = {
|
||||
} = await getIpaInfo(fn);
|
||||
const { appId, appKey } = await getSelectedApp('ios');
|
||||
|
||||
if (appIdInPkg && appIdInPkg !== appId) {
|
||||
if (appIdInPkg && appIdInPkg != appId) {
|
||||
throw new Error(
|
||||
`appId不匹配!当前ipa: ${appIdInPkg}, 当前update.json: ${appId}`,
|
||||
);
|
||||
@@ -100,7 +100,7 @@ export const commands = {
|
||||
} = await getApkInfo(fn);
|
||||
const { appId, appKey } = await getSelectedApp('android');
|
||||
|
||||
if (appIdInPkg && appIdInPkg !== appId) {
|
||||
if (appIdInPkg && appIdInPkg != appId) {
|
||||
throw new Error(
|
||||
`appId不匹配!当前apk: ${appIdInPkg}, 当前update.json: ${appId}`,
|
||||
);
|
||||
|
Reference in New Issue
Block a user