mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-18 18:30:39 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7f062f681a | ||
![]() |
7f5b9fd7fd | ||
![]() |
13b21c49c1 | ||
![]() |
16b1cc3ed4 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.1.18",
|
"version": "1.2.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": {
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"tcp-ping": "^0.1.1",
|
"tcp-ping": "^0.1.1",
|
||||||
"tty-table": "4.1",
|
"tty-table": "4.1",
|
||||||
"update-notifier": "^4.1.0",
|
"update-notifier": "^4.1.1",
|
||||||
"yauzl": "^2.10.0",
|
"yauzl": "^2.10.0",
|
||||||
"yazl": "2.5.1"
|
"yazl": "2.5.1"
|
||||||
},
|
},
|
||||||
|
@@ -37,6 +37,14 @@ async function runReactNativeBundleCommand(
|
|||||||
sourcemapOutput,
|
sourcemapOutput,
|
||||||
config,
|
config,
|
||||||
) {
|
) {
|
||||||
|
let gradleConfig = {};
|
||||||
|
if (platform === 'android') {
|
||||||
|
gradleConfig = await checkGradleConfig();
|
||||||
|
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')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let reactNativeBundleArgs = [];
|
let reactNativeBundleArgs = [];
|
||||||
|
|
||||||
let envArgs = process.env.PUSHY_ENV_ARGS;
|
let envArgs = process.env.PUSHY_ENV_ARGS;
|
||||||
@@ -96,7 +104,7 @@ async function runReactNativeBundleCommand(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (platform === 'android') {
|
if (gradleConfig.enableHermes) {
|
||||||
await compileHermesByteCode(bundleName, outputFolder);
|
await compileHermesByteCode(bundleName, outputFolder);
|
||||||
}
|
}
|
||||||
resolve(null);
|
resolve(null);
|
||||||
@@ -111,11 +119,13 @@ function getHermesOSBin() {
|
|||||||
if (os.platform() === 'linux') return 'linux64-bin';
|
if (os.platform() === 'linux') return 'linux64-bin';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function compileHermesByteCode(bundleName, outputFolder) {
|
async function checkGradleConfig() {
|
||||||
let enableHermes = false;
|
let enableHermes = false;
|
||||||
|
let crunchPngs;
|
||||||
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') &&
|
||||||
@@ -126,7 +136,13 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (enableHermes) {
|
return {
|
||||||
|
enableHermes,
|
||||||
|
crunchPngs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function compileHermesByteCode(bundleName, outputFolder) {
|
||||||
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
||||||
const hermesPackage = fs.existsSync('node_modules/hermes-engine')
|
const hermesPackage = fs.existsSync('node_modules/hermes-engine')
|
||||||
? 'node_modules/hermes-engine' // 0.2+
|
? 'node_modules/hermes-engine' // 0.2+
|
||||||
@@ -148,7 +164,6 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|||||||
],
|
],
|
||||||
{ stdio: 'ignore' },
|
{ stdio: 'ignore' },
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pack(dir, output) {
|
async function pack(dir, output) {
|
||||||
|
Reference in New Issue
Block a user