1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-17 18:06:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

..

9 Commits

Author SHA1 Message Date
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
sunnylqm
0f8cf3c399 v1.16.0 2024-01-30 17:50:32 +08:00
sunnylqm
6a0d82c7a5 fix: rndir path 2024-01-30 17:50:09 +08:00
sunnylqm
eed19992d8 v1.15.0 2024-01-30 12:43:48 +08:00
sunnylqm
1b5078831c fix: require path 2024-01-30 12:43:31 +08:00
sunnylqm
bc9aff343a v1.14.0 2024-01-29 19:11:06 +08:00
3 changed files with 42 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update-cli", "name": "react-native-update-cli",
"version": "1.14.0-beta.0", "version": "1.18.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": {

View File

@@ -49,9 +49,21 @@ async function runReactNativeBundleCommand(
fs.emptyDirSync(outputFolder); fs.emptyDirSync(outputFolder);
let cliPath = require.resolve('react-native/local-cli/cli.js', {
paths: [process.cwd()],
});
try {
cliPath = require.resolve('@expo/cli', {
paths: [process.cwd()],
});
} catch (e) {}
const bundleCommand = cliPath.includes('@expo/cli')
? 'export:embed'
: 'bundle';
Array.prototype.push.apply(reactNativeBundleArgs, [ Array.prototype.push.apply(reactNativeBundleArgs, [
require.resolve('react-native/local-cli/cli.js'), // 'react-native' package may be symlinked cliPath,
'bundle', bundleCommand,
'--assets-dest', '--assets-dest',
outputFolder, outputFolder,
'--bundle-output', '--bundle-output',
@@ -171,7 +183,16 @@ async function compileHermesByteCode(
) { ) {
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`); console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
// >= rn 0.69 // >= rn 0.69
let hermesCommand = require.resolve(`react-native/sdks/hermesc/${getHermesOSBin()}/hermesc`); const rnDir = path.dirname(
require.resolve('react-native', {
paths: [process.cwd()],
}),
);
const hermesCommand = path.join(
rnDir,
`/sdks/hermesc/${getHermesOSBin()}/hermesc`,
);
// < rn 0.69 // < rn 0.69
if (!fs.existsSync(hermesCommand)) { if (!fs.existsSync(hermesCommand)) {
const hermesPackage = fs.existsSync('node_modules/hermes-engine') const hermesPackage = fs.existsSync('node_modules/hermes-engine')
@@ -193,7 +214,10 @@ async function compileHermesByteCode(
if (sourcemapOutput) { if (sourcemapOutput) {
args.push('-output-source-map'); 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', stdio: 'ignore',
}); });
} }

View File

@@ -43,7 +43,11 @@ export function translateOptions(options) {
export function getRNVersion() { export function getRNVersion() {
const version = JSON.parse( const version = JSON.parse(
fs.readFileSync(require.resolve('react-native/package.json')), fs.readFileSync(
require.resolve('react-native/package.json', {
paths: [process.cwd()],
}),
),
).version; ).version;
// We only care about major and minor version. // We only care about major and minor version.
@@ -106,9 +110,8 @@ export async function getIpaInfo(fn) {
if (updateJsonFile) { if (updateJsonFile) {
appCredential = JSON.parse(updateJsonFile.toString()).ios; appCredential = JSON.parse(updateJsonFile.toString()).ios;
} }
const { const { CFBundleShortVersionString: versionName } =
CFBundleShortVersionString: versionName, await appInfoParser.parse();
} = await appInfoParser.parse();
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry( let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(
/payload\/.+?\.app\/pushy_build_time.txt/, /payload\/.+?\.app\/pushy_build_time.txt/,
); );
@@ -139,7 +142,12 @@ 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);
try { try {
const PACKAGE_JSON_PATH = require.resolve('react-native-update/package.json'); const PACKAGE_JSON_PATH = require.resolve(
'react-native-update/package.json',
{
paths: [process.cwd()],
},
);
console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version); console.log('react-native-update: ' + require(PACKAGE_JSON_PATH).version);
} catch (e) { } catch (e) {
console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令'); console.log('react-native-update: 无法获取版本号,请在项目目录中运行命令');