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

..

6 Commits

Author SHA1 Message Date
sunnylqm
a0dfcb5c4b v1.19.0 2024-02-18 20:04:05 +08:00
sunnylqm
587da8aaf9 Fix android crunchPngs option and add support for expo-router 2024-02-18 20:03:43 +08:00
sunnylqm
724088a810 v1.18.0 2024-02-03 21:28:38 +08:00
sunnylqm
7c20b30c85 feat: support expo 2024-02-03 21:27:47 +08:00
sunnylqm
6a053c6428 v1.17.0 2024-01-30 19:15:15 +08:00
sunnylqm
f202fc590d fix: rndir path 2024-01-30 19:15:00 +08:00
2 changed files with 35 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update-cli",
"version": "1.16.0",
"version": "1.19.0",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"main": "index.js",
"bin": {

View File

@@ -31,9 +31,11 @@ async function runReactNativeBundleCommand(
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')
// }
if (gradleConfig.crunchPngs !== false) {
console.warn(
'android的crunchPngs选项似乎尚未禁用如已禁用则请忽略此提示这可能导致热更包体积异常增大具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n',
);
}
}
let reactNativeBundleArgs = [];
@@ -49,11 +51,27 @@ async function runReactNativeBundleCommand(
fs.emptyDirSync(outputFolder);
Array.prototype.push.apply(reactNativeBundleArgs, [
require.resolve('react-native/local-cli/cli.js', {
let cliPath = require.resolve('react-native/local-cli/cli.js', {
paths: [process.cwd()],
});
try {
require.resolve('expo-router', {
paths: [process.cwd()],
}), // 'react-native' package may be symlinked
'bundle',
});
console.log(`expo-router detected, will use @expo/cli to bundle.\n`);
// if using expo-router, use expo-cli
cliPath = require.resolve('@expo/cli', {
paths: [process.cwd()],
});
} catch (e) {}
const bundleCommand = cliPath.includes('@expo/cli')
? 'export:embed'
: 'bundle';
Array.prototype.push.apply(reactNativeBundleArgs, [
cliPath,
bundleCommand,
'--assets-dest',
outputFolder,
'--bundle-output',
@@ -173,7 +191,11 @@ async function compileHermesByteCode(
) {
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
// >= rn 0.69
const rnDir = path.dirname(require.resolve('react-native'));
const rnDir = path.dirname(
require.resolve('react-native', {
paths: [process.cwd()],
}),
);
const hermesCommand = path.join(
rnDir,
`/sdks/hermesc/${getHermesOSBin()}/hermesc`,
@@ -200,7 +222,10 @@ async function compileHermesByteCode(
if (sourcemapOutput) {
args.push('-output-source-map');
}
spawnSync(path.join.apply(null, hermesCommand.split('/')), args, {
console.log(
'Running hermesc: ' + hermesCommand + ' ' + args.join(' ') + '\n',
);
spawnSync(hermesCommand, args, {
stdio: 'ignore',
});
}