mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 18:06:10 +08:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
25cb724921 | ||
![]() |
a7b79a30e8 | ||
![]() |
11799dd0c1 | ||
![]() |
2ab0cad7e5 | ||
![]() |
ec8d6a767b | ||
![]() |
fa8290fcbf | ||
![]() |
46d308c7c2 | ||
![]() |
9e721e1858 | ||
![]() |
c30454976c | ||
![]() |
3d73b95140 | ||
![]() |
32cafd92bf | ||
![]() |
ea10cd7828 | ||
![]() |
574a52b126 | ||
![]() |
c00a7a72fe | ||
![]() |
0e8e3aa420 | ||
![]() |
7426e93647 | ||
![]() |
b6fb2e7d2a | ||
![]() |
7f1dcbb571 | ||
![]() |
59fad93832 | ||
![]() |
3db4f803e2 | ||
![]() |
56d44b8c85 | ||
![]() |
ecd951265f | ||
![]() |
62d455ac07 | ||
![]() |
acfc2dd65b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -104,3 +104,4 @@ dist
|
|||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
lib/
|
lib/
|
||||||
|
.DS_Store
|
||||||
|
37
cli.json
37
cli.json
@@ -106,11 +106,11 @@
|
|||||||
"hasValue": true
|
"hasValue": true
|
||||||
},
|
},
|
||||||
"intermediaDir": {
|
"intermediaDir": {
|
||||||
"default": "build/intermedia/${platform}",
|
"default": ".pushy/intermedia/${platform}",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"default": "build/output/${platform}.${time}.ppk",
|
"default": ".pushy/output/${platform}.${time}.ppk",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
},
|
},
|
||||||
"verbose": {}
|
"verbose": {}
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
"description": "Create diff patch",
|
"description": "Create diff patch",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": "build/output/diff",
|
"default": ".pushy/output/diff",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
"description": "Create diff patch from a Android package(.apk)",
|
"description": "Create diff patch from a Android package(.apk)",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": "build/output/diff-${time}.apk-patch",
|
"default": ".pushy/output/diff-${time}.apk-patch",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,34 @@
|
|||||||
"description": "Create diff patch from a iOS package(.ipa)",
|
"description": "Create diff patch from a iOS package(.ipa)",
|
||||||
"options": {
|
"options": {
|
||||||
"output": {
|
"output": {
|
||||||
"default": "build/output/diff-${time}.ipa-patch",
|
"default": ".pushy/output/diff-${time}.ipa-patch",
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hdiff": {
|
||||||
|
"description": "Create hdiff patch",
|
||||||
|
"options": {
|
||||||
|
"output": {
|
||||||
|
"default": ".pushy/output/hdiff",
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hdiffFromApk": {
|
||||||
|
"description": "Create hdiff patch from a Android package(.apk)",
|
||||||
|
"options": {
|
||||||
|
"output": {
|
||||||
|
"default": ".pushy/output/hdiff-${time}.apk-patch",
|
||||||
|
"hasValue": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hdiffFromIpa": {
|
||||||
|
"description": "Create hdiff patch from a iOS package(.ipa)",
|
||||||
|
"options": {
|
||||||
|
"output": {
|
||||||
|
"default": ".pushy/output/hdiff-${time}.ipa-patch",
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "1.2.1",
|
"version": "1.4.2",
|
||||||
"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,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"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.13",
|
"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",
|
||||||
|
22
src/api.js
22
src/api.js
@@ -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,12 +60,19 @@ 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) {
|
||||||
const resp = await fetch(url, options);
|
const resp = await fetch(url, options);
|
||||||
const json = await resp.json();
|
const text = await resp.text();
|
||||||
|
let json;
|
||||||
|
try {
|
||||||
|
json = JSON.parse(text);
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(`Server error: ${text}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
throw Object.assign(new Error(json.message || json.error), {
|
throw Object.assign(new Error(json.message || json.error), {
|
||||||
status: resp.status,
|
status: resp.status,
|
||||||
@@ -106,7 +114,7 @@ exports.doDelete = queryWithBody('DELETE');
|
|||||||
|
|
||||||
async function uploadFile(fn, key) {
|
async function uploadFile(fn, key) {
|
||||||
const { url, backupUrl, formData, maxSize } = await exports.post('/upload', {
|
const { url, backupUrl, formData, maxSize } = await exports.post('/upload', {
|
||||||
ext: path.extname(fn)
|
ext: path.extname(fn),
|
||||||
});
|
});
|
||||||
let realUrl = url;
|
let realUrl = url;
|
||||||
|
|
||||||
@@ -125,7 +133,11 @@ async function uploadFile(fn, key) {
|
|||||||
|
|
||||||
const fileSize = fs.statSync(fn).size;
|
const fileSize = fs.statSync(fn).size;
|
||||||
if (maxSize && fileSize > filesizeParser(maxSize)) {
|
if (maxSize && fileSize > filesizeParser(maxSize)) {
|
||||||
throw new Error(`此文件大小超出上限${maxSize}。您可以考虑升级付费业务以提升此限制。详情请访问:${pricingPageUrl}`)
|
throw new Error(
|
||||||
|
`此文件大小${(fileSize / 1048576).toFixed(
|
||||||
|
1,
|
||||||
|
)}m, 超出当前额度${maxSize}。您可以考虑升级付费业务以提升此额度。详情请访问:${pricingPageUrl}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
|
||||||
|
55
src/app.js
55
src/app.js
@@ -4,12 +4,9 @@
|
|||||||
|
|
||||||
import { question } from './utils';
|
import { question } from './utils';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
const Table = require('tty-table');
|
||||||
|
|
||||||
const {
|
const { post, get, doDelete } = require('./api');
|
||||||
post,
|
|
||||||
get,
|
|
||||||
doDelete,
|
|
||||||
} = require('./api');
|
|
||||||
|
|
||||||
const validPlatforms = {
|
const validPlatforms = {
|
||||||
ios: 1,
|
ios: 1,
|
||||||
@@ -20,28 +17,42 @@ export function checkPlatform(platform) {
|
|||||||
if (!validPlatforms[platform]) {
|
if (!validPlatforms[platform]) {
|
||||||
throw new Error(`Invalid platform '${platform}'`);
|
throw new Error(`Invalid platform '${platform}'`);
|
||||||
}
|
}
|
||||||
return platform
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectedApp(platform) {
|
export function getSelectedApp(platform) {
|
||||||
checkPlatform(platform);
|
checkPlatform(platform);
|
||||||
|
|
||||||
if (!fs.existsSync('update.json')) {
|
if (!fs.existsSync('update.json')) {
|
||||||
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
throw new Error(
|
||||||
|
`App not selected. run 'pushy selectApp --platform ${platform}' first!`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
const updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
||||||
if (!updateInfo[platform]) {
|
if (!updateInfo[platform]) {
|
||||||
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
throw new Error(
|
||||||
|
`App not selected. run 'pushy selectApp --platform ${platform}' first!`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return updateInfo[platform];
|
return updateInfo[platform];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listApp(platform) {
|
export async function listApp(platform) {
|
||||||
const { data } = await get('/app/list');
|
const { data } = await get('/app/list');
|
||||||
const list = platform?data.filter(v=>v.platform===platform):data;
|
const list = platform ? data.filter((v) => v.platform === platform) : data;
|
||||||
|
|
||||||
|
const header = [
|
||||||
|
{ value: 'App Id' },
|
||||||
|
{ value: 'App Name' },
|
||||||
|
{ value: 'Platform' },
|
||||||
|
];
|
||||||
|
const rows = [];
|
||||||
for (const app of list) {
|
for (const app of list) {
|
||||||
console.log(`${app.id}) ${app.name}(${app.platform})`);
|
rows.push([app.id, app.name, app.platform]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(Table(header, rows).render());
|
||||||
|
|
||||||
if (platform) {
|
if (platform) {
|
||||||
console.log(`\nTotal ${list.length} ${platform} apps`);
|
console.log(`\nTotal ${list.length} ${platform} apps`);
|
||||||
} else {
|
} else {
|
||||||
@@ -55,7 +66,7 @@ export async function chooseApp(platform) {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const id = await question('Enter appId:');
|
const id = await question('Enter appId:');
|
||||||
const app = list.find(v=>v.id === (id|0));
|
const app = list.find((v) => v.id === (id | 0));
|
||||||
if (app) {
|
if (app) {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
@@ -64,9 +75,11 @@ export async function chooseApp(platform) {
|
|||||||
|
|
||||||
export const commands = {
|
export const commands = {
|
||||||
createApp: async function ({ options }) {
|
createApp: async function ({ options }) {
|
||||||
const name = options.name || await question('App Name:');
|
const name = options.name || (await question('App Name:'));
|
||||||
const { downloadUrl } = options;
|
const { downloadUrl } = options;
|
||||||
const platform = checkPlatform(options.platform || await question('Platform(ios/android):'));
|
const platform = checkPlatform(
|
||||||
|
options.platform || (await question('Platform(ios/android):')),
|
||||||
|
);
|
||||||
const { id } = await post('/app/create', { name, platform });
|
const { id } = await post('/app/create', { name, platform });
|
||||||
console.log(`Created app ${id}`);
|
console.log(`Created app ${id}`);
|
||||||
await this.selectApp({
|
await this.selectApp({
|
||||||
@@ -88,7 +101,9 @@ export const commands = {
|
|||||||
listApp(platform);
|
listApp(platform);
|
||||||
},
|
},
|
||||||
selectApp: async function ({ args, options }) {
|
selectApp: async function ({ args, options }) {
|
||||||
const platform = checkPlatform(options.platform || await question('Platform(ios/android):'));
|
const platform = checkPlatform(
|
||||||
|
options.platform || (await question('Platform(ios/android):')),
|
||||||
|
);
|
||||||
const id = args[0] || (await chooseApp(platform)).id;
|
const id = args[0] || (await chooseApp(platform)).id;
|
||||||
|
|
||||||
let updateInfo = {};
|
let updateInfo = {};
|
||||||
@@ -96,7 +111,9 @@ export const commands = {
|
|||||||
try {
|
try {
|
||||||
updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to parse file `update.json`. Try to remove it manually.');
|
console.error(
|
||||||
|
'Failed to parse file `update.json`. Try to remove it manually.',
|
||||||
|
);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,6 +122,10 @@ export const commands = {
|
|||||||
appId: id,
|
appId: id,
|
||||||
appKey,
|
appKey,
|
||||||
};
|
};
|
||||||
fs.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
fs.writeFileSync(
|
||||||
|
'update.json',
|
||||||
|
JSON.stringify(updateInfo, null, 4),
|
||||||
|
'utf8',
|
||||||
|
);
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
130
src/bundle.js
130
src/bundle.js
@@ -13,20 +13,14 @@ const { spawn, spawnSync } = require('child_process');
|
|||||||
const g2js = require('gradle-to-js/lib/parser');
|
const g2js = require('gradle-to-js/lib/parser');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
var diff;
|
var bsdiff, hdiff, diff;
|
||||||
try {
|
try {
|
||||||
var bsdiff = require('node-bsdiff');
|
bsdiff = require('node-bsdiff').diff;
|
||||||
diff = typeof bsdiff != 'function' ? bsdiff.diff : bsdiff;
|
} catch (e) {}
|
||||||
} catch (e) {
|
|
||||||
diff = function () {
|
try {
|
||||||
console.warn(
|
hdiff = require('node-hdiffpatch').diff;
|
||||||
'This function needs "node-bsdiff". Please run "npm i node-bsdiff" from your project directory first!',
|
} catch (e) {}
|
||||||
);
|
|
||||||
throw new Error(
|
|
||||||
'This function needs module "node-bsdiff". Please install it first.',
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runReactNativeBundleCommand(
|
async function runReactNativeBundleCommand(
|
||||||
bundleName,
|
bundleName,
|
||||||
@@ -40,9 +34,9 @@ async function runReactNativeBundleCommand(
|
|||||||
let gradleConfig = {};
|
let gradleConfig = {};
|
||||||
if (platform === 'android') {
|
if (platform === 'android') {
|
||||||
gradleConfig = await checkGradleConfig();
|
gradleConfig = await checkGradleConfig();
|
||||||
if (gradleConfig.crunchPngs !== false) {
|
// 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')
|
// 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 = [];
|
||||||
@@ -125,7 +119,6 @@ async function checkGradleConfig() {
|
|||||||
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') &&
|
||||||
@@ -135,11 +128,12 @@ async function checkGradleConfig() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
return {
|
return {
|
||||||
enableHermes,
|
enableHermes,
|
||||||
crunchPngs,
|
crunchPngs,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function compileHermesByteCode(bundleName, outputFolder) {
|
async function compileHermesByteCode(bundleName, outputFolder) {
|
||||||
@@ -482,6 +476,42 @@ function enumZipEntries(zipFn, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function diffArgsCheck(args, options, diffFn) {
|
||||||
|
const [origin, next] = args;
|
||||||
|
|
||||||
|
if (!origin || !next) {
|
||||||
|
console.error(`Usage: pushy ${diffFn} <origin> <next>`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diffFn.startsWith('hdiff')) {
|
||||||
|
if (!hdiff) {
|
||||||
|
console.error(
|
||||||
|
`This function needs "node-hdiffpatch".
|
||||||
|
Please run "npm i node-hdiffpatch" to install`,
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
diff = hdiff;
|
||||||
|
} else {
|
||||||
|
if (!bsdiff) {
|
||||||
|
console.error(
|
||||||
|
`This function needs "node-bsdiff".
|
||||||
|
Please run "npm i node-bsdiff" to install`,
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
diff = bsdiff;
|
||||||
|
}
|
||||||
|
const { output } = options;
|
||||||
|
|
||||||
|
return {
|
||||||
|
origin,
|
||||||
|
next,
|
||||||
|
realOutput: output.replace(/\$\{time\}/g, '' + Date.now()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const commands = {
|
export const commands = {
|
||||||
bundle: async function ({ options }) {
|
bundle: async function ({ options }) {
|
||||||
const platform = checkPlatform(
|
const platform = checkPlatform(
|
||||||
@@ -535,30 +565,41 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async diff({ args, options }) {
|
async diff({ args, options }) {
|
||||||
const [origin, next] = args;
|
const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
|
||||||
const { output } = options;
|
|
||||||
|
|
||||||
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
||||||
|
console.log(`${realOutput} generated.`);
|
||||||
|
},
|
||||||
|
|
||||||
if (!origin || !next) {
|
async hdiff({ args, options }) {
|
||||||
console.error('pushy diff <origin> <next>');
|
const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
await diffFromPPK(origin, next, realOutput, 'index.bundlejs');
|
||||||
console.log(`${realOutput} generated.`);
|
console.log(`${realOutput} generated.`);
|
||||||
},
|
},
|
||||||
|
|
||||||
async diffFromApk({ args, options }) {
|
async diffFromApk({ args, options }) {
|
||||||
const [origin, next] = args;
|
const { origin, next, realOutput } = diffArgsCheck(
|
||||||
const { output } = options;
|
args,
|
||||||
|
options,
|
||||||
|
'diffFromApk',
|
||||||
|
);
|
||||||
|
|
||||||
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
await diffFromPackage(
|
||||||
|
origin,
|
||||||
|
next,
|
||||||
|
realOutput,
|
||||||
|
'assets/index.android.bundle',
|
||||||
|
);
|
||||||
|
console.log(`${realOutput} generated.`);
|
||||||
|
},
|
||||||
|
|
||||||
if (!origin || !next) {
|
async hdiffFromApk({ args, options }) {
|
||||||
console.error('pushy diffFromApk <origin> <next>');
|
const { origin, next, realOutput } = diffArgsCheck(
|
||||||
process.exit(1);
|
args,
|
||||||
}
|
options,
|
||||||
|
'hdiffFromApk',
|
||||||
|
);
|
||||||
|
|
||||||
await diffFromPackage(
|
await diffFromPackage(
|
||||||
origin,
|
origin,
|
||||||
@@ -570,15 +611,26 @@ export const commands = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async diffFromIpa({ args, options }) {
|
async diffFromIpa({ args, options }) {
|
||||||
const [origin, next] = args;
|
const { origin, next, realOutput } = diffArgsCheck(
|
||||||
const { output } = options;
|
args,
|
||||||
|
options,
|
||||||
|
'diffFromIpa',
|
||||||
|
);
|
||||||
|
|
||||||
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
|
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
||||||
|
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
||||||
|
return m && m[1];
|
||||||
|
});
|
||||||
|
|
||||||
if (!origin || !next) {
|
console.log(`${realOutput} generated.`);
|
||||||
console.error('pushy diffFromIpa <origin> <next>');
|
},
|
||||||
process.exit(1);
|
|
||||||
}
|
async hdiffFromIpa({ args, options }) {
|
||||||
|
const { origin, next, realOutput } = diffArgsCheck(
|
||||||
|
args,
|
||||||
|
options,
|
||||||
|
'hdiffFromIpa',
|
||||||
|
);
|
||||||
|
|
||||||
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v) => {
|
||||||
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
|
||||||
|
@@ -52,8 +52,25 @@ export const commands = {
|
|||||||
if (!fn || !fn.endsWith('.ipa')) {
|
if (!fn || !fn.endsWith('.ipa')) {
|
||||||
throw new Error('Usage: pushy uploadIpa <ipaFile>');
|
throw new Error('Usage: pushy uploadIpa <ipaFile>');
|
||||||
}
|
}
|
||||||
const { versionName, buildTime } = await getIpaInfo(fn);
|
const {
|
||||||
const { appId } = await getSelectedApp('ios');
|
versionName,
|
||||||
|
buildTime,
|
||||||
|
appId: appIdInPkg,
|
||||||
|
appKey: appKeyInPkg,
|
||||||
|
} = await getIpaInfo(fn);
|
||||||
|
const { appId, appKey } = await getSelectedApp('ios');
|
||||||
|
|
||||||
|
if (appIdInPkg && appIdInPkg !== appId) {
|
||||||
|
throw new Error(
|
||||||
|
`appId不匹配!当前ipa:${appIdInPkg}, 当前update.json:${appId}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
||||||
|
throw new Error(
|
||||||
|
`appKey不匹配!当前ipa:${appKeyInPkg}, 当前update.json:${appKey}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
@@ -70,8 +87,25 @@ export const commands = {
|
|||||||
if (!fn || !fn.endsWith('.apk')) {
|
if (!fn || !fn.endsWith('.apk')) {
|
||||||
throw new Error('Usage: pushy uploadApk <apkFile>');
|
throw new Error('Usage: pushy uploadApk <apkFile>');
|
||||||
}
|
}
|
||||||
const { versionName, buildTime } = await getApkInfo(fn);
|
const {
|
||||||
const { appId } = await getSelectedApp('android');
|
versionName,
|
||||||
|
buildTime,
|
||||||
|
appId: appIdInPkg,
|
||||||
|
appKey: appKeyInPkg,
|
||||||
|
} = await getApkInfo(fn);
|
||||||
|
const { appId, appKey } = await getSelectedApp('android');
|
||||||
|
|
||||||
|
if (appIdInPkg && appIdInPkg !== appId) {
|
||||||
|
throw new Error(
|
||||||
|
`appId不匹配!当前apk:${appIdInPkg}, 当前update.json:${appId}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
||||||
|
throw new Error(
|
||||||
|
`appKey不匹配!当前apk:${appKeyInPkg}, 当前update.json:${appKey}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const { hash } = await uploadFile(fn);
|
const { hash } = await uploadFile(fn);
|
||||||
|
|
||||||
|
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