mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-18 10:20:39 +08:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3db4f803e2 | ||
![]() |
56d44b8c85 | ||
![]() |
ecd951265f | ||
![]() |
62d455ac07 | ||
![]() |
acfc2dd65b | ||
![]() |
7f062f681a | ||
![]() |
7f5b9fd7fd | ||
![]() |
13b21c49c1 | ||
![]() |
85db61704c | ||
![]() |
57ddfc5d7d | ||
![]() |
16b1cc3ed4 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.1.17",
|
"version": "1.2.3",
|
||||||
"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": {
|
||||||
@@ -32,18 +32,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
|
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"app-info-parser": "^0.3.9",
|
"app-info-parser": "^1.0.0",
|
||||||
"cli-arguments": "^0.2.1",
|
"cli-arguments": "^0.2.1",
|
||||||
"filesize-parser": "^1.5.0",
|
"filesize-parser": "^1.5.0",
|
||||||
"fs-extra": "8",
|
"fs-extra": "8",
|
||||||
"gradle-to-js": "^2.0.0",
|
"gradle-to-js": "^2.0.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.1",
|
||||||
"progress": "^2.0.3",
|
"progress": "^2.0.3",
|
||||||
"read": "^1.0.7",
|
"read": "^1.0.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"
|
||||||
},
|
},
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
let host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api';
|
const defaultEndpoint = 'http://u.reactnative.cn/api'
|
||||||
|
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
import request from 'request';
|
import request from 'request';
|
||||||
import ProgressBar from 'progress';
|
import ProgressBar from 'progress';
|
||||||
@@ -59,7 +60,7 @@ exports.closeSession = function() {
|
|||||||
savedSession = undefined;
|
savedSession = undefined;
|
||||||
}
|
}
|
||||||
session = undefined;
|
session = undefined;
|
||||||
host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api';
|
host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function query(url, options) {
|
async function query(url, options) {
|
||||||
@@ -147,6 +148,10 @@ async function uploadFile(fn, key) {
|
|||||||
realUrl,
|
realUrl,
|
||||||
{
|
{
|
||||||
formData,
|
formData,
|
||||||
|
headers: {
|
||||||
|
'User-Agent': userAgent,
|
||||||
|
'X-AccessToken': session ? session.token : '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
(err, resp, body) => {
|
(err, resp, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@@ -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,31 +136,36 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (enableHermes) {
|
return {
|
||||||
console.log(`Hermes enabled, now compiling to hermes bytecode:\n`);
|
enableHermes,
|
||||||
const hermesPackage = fs.existsSync('node_modules/hermes-engine')
|
crunchPngs,
|
||||||
? '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' },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function compileHermesByteCode(bundleName, outputFolder) {
|
||||||
|
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()}`;
|
||||||
|
|
||||||
|
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' },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function pack(dir, output) {
|
async function pack(dir, output) {
|
||||||
console.log('Packing');
|
console.log('Packing');
|
||||||
fs.ensureDirSync(path.dirname(output));
|
fs.ensureDirSync(path.dirname(output));
|
||||||
|
36
yarn.lock
36
yarn.lock
@@ -72,10 +72,10 @@ anymatch@^1.3.0:
|
|||||||
micromatch "^2.1.5"
|
micromatch "^2.1.5"
|
||||||
normalize-path "^2.0.0"
|
normalize-path "^2.0.0"
|
||||||
|
|
||||||
app-info-parser@^0.3.9:
|
app-info-parser@^1.0.0:
|
||||||
version "0.3.9"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/app-info-parser/-/app-info-parser-0.3.9.tgz#adc60c9d4d4aca4e529f21a6da1279b74ddaf62b"
|
resolved "https://registry.yarnpkg.com/app-info-parser/-/app-info-parser-1.0.0.tgz#38da83c167b436b485246a2c81ab28833ac12b6e"
|
||||||
integrity sha512-vIzO1OZSMnEz+OdGkhmSTS0y4PaQmXdF1YmzUBb7wsKR21JF1eXMnciARkUj6T+CLb9caoDSN+w5eSoGatRbcA==
|
integrity sha512-l8fNzGZFTNCloUm5imfOQYjlBLQfu3DB9rkKgi7TWAjtCU2s0NMLetOw0TFmHye65NcdenAQawvLNLtyo1L//w==
|
||||||
dependencies:
|
dependencies:
|
||||||
bplist-parser "^0.2.0"
|
bplist-parser "^0.2.0"
|
||||||
bytebuffer "^5.0.1"
|
bytebuffer "^5.0.1"
|
||||||
@@ -1476,9 +1476,9 @@ is-glob@^2.0.0, is-glob@^2.0.1:
|
|||||||
is-extglob "^1.0.0"
|
is-extglob "^1.0.0"
|
||||||
|
|
||||||
is-installed-globally@^0.3.1:
|
is-installed-globally@^0.3.1:
|
||||||
version "0.3.1"
|
version "0.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.1.tgz#679afef819347a72584617fd19497f010b8ed35f"
|
resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.2.tgz#fd3efa79ee670d1187233182d5b0a1dd00313141"
|
||||||
integrity sha512-oiEcGoQbGc+3/iijAijrK2qFpkNoNjsHOm/5V5iaeydyrS/hnwaRCEgH5cpW0P3T1lSjV5piB7S5b5lEugNLhg==
|
integrity sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g==
|
||||||
dependencies:
|
dependencies:
|
||||||
global-dirs "^2.0.1"
|
global-dirs "^2.0.1"
|
||||||
is-path-inside "^3.0.1"
|
is-path-inside "^3.0.1"
|
||||||
@@ -1885,10 +1885,10 @@ nanomatch@^1.2.9:
|
|||||||
snapdragon "^0.8.1"
|
snapdragon "^0.8.1"
|
||||||
to-regex "^3.0.1"
|
to-regex "^3.0.1"
|
||||||
|
|
||||||
node-fetch@^2.6.0:
|
node-fetch@^2.6.1:
|
||||||
version "2.6.0"
|
version "2.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
|
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
|
||||||
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
|
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||||
|
|
||||||
normalize-path@^2.0.0, normalize-path@^2.0.1:
|
normalize-path@^2.0.0, normalize-path@^2.0.1:
|
||||||
version "2.1.1"
|
version "2.1.1"
|
||||||
@@ -2116,9 +2116,9 @@ punycode@^2.1.0, punycode@^2.1.1:
|
|||||||
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
||||||
|
|
||||||
pupa@^2.0.1:
|
pupa@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726"
|
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62"
|
||||||
integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA==
|
integrity sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==
|
||||||
dependencies:
|
dependencies:
|
||||||
escape-goat "^2.0.0"
|
escape-goat "^2.0.0"
|
||||||
|
|
||||||
@@ -2694,10 +2694,10 @@ unset-value@^1.0.0:
|
|||||||
has-value "^0.3.1"
|
has-value "^0.3.1"
|
||||||
isobject "^3.0.0"
|
isobject "^3.0.0"
|
||||||
|
|
||||||
update-notifier@^4.1.0:
|
update-notifier@^4.1.1:
|
||||||
version "4.1.0"
|
version "4.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3"
|
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.3.tgz#be86ee13e8ce48fb50043ff72057b5bd598e1ea3"
|
||||||
integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew==
|
integrity sha512-Yld6Z0RyCYGB6ckIjffGOSOmHXj1gMeE7aROz4MG+XMkmixBX4jUngrGXNYz7wPKBmtoD4MnBa2Anu7RSKht/A==
|
||||||
dependencies:
|
dependencies:
|
||||||
boxen "^4.2.0"
|
boxen "^4.2.0"
|
||||||
chalk "^3.0.0"
|
chalk "^3.0.0"
|
||||||
|
Reference in New Issue
Block a user