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

Compare commits

..

10 Commits

Author SHA1 Message Date
sunnylqm
0e8e3aa420 v1.3.0 2021-01-20 23:30:26 +08:00
sunnylqm
7426e93647 Update gitignore 2021-01-20 23:30:04 +08:00
sunnylqm
b6fb2e7d2a Check does appId/appKey match 2021-01-20 23:29:53 +08:00
sunnylqm
7f1dcbb571 Use table for listApp 2021-01-20 23:29:31 +08:00
sunnylqm
59fad93832 Change local build foler name 2021-01-11 14:06:14 +08:00
sunnylqm
3db4f803e2 v1.2.3 2021-01-05 21:54:04 +08:00
sunnylqm
56d44b8c85 Update defaultEndpoint 2021-01-05 21:53:46 +08:00
sunnylqm
ecd951265f v1.2.2 2020-12-15 13:30:19 +08:00
sunnylqm
62d455ac07 Update app-info-parser 2020-12-15 13:30:04 +08:00
sunnylqm
acfc2dd65b v1.2.1 2020-11-04 14:48:03 +08:00
7 changed files with 116 additions and 59 deletions

1
.gitignore vendored
View File

@@ -104,3 +104,4 @@ dist
.tern-port
lib/
.DS_Store

View File

@@ -106,11 +106,11 @@
"hasValue": true
},
"intermediaDir": {
"default": "build/intermedia/${platform}",
"default": ".pushy/intermedia/${platform}",
"hasValue": true
},
"output": {
"default": "build/output/${platform}.${time}.ppk",
"default": ".pushy/output/${platform}.${time}.ppk",
"hasValue": true
},
"verbose": {}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update-cli",
"version": "1.2.1",
"version": "1.3.0",
"description": "Command tools for javaScript updater with `pushy` service for react native apps.",
"main": "index.js",
"bin": {
@@ -32,7 +32,7 @@
},
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
"dependencies": {
"app-info-parser": "^0.3.13",
"app-info-parser": "^1.0.0",
"cli-arguments": "^0.2.1",
"filesize-parser": "^1.5.0",
"fs-extra": "8",

View File

@@ -3,7 +3,8 @@
*/
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');
import request from 'request';
import ProgressBar from 'progress';
@@ -59,7 +60,7 @@ exports.closeSession = function() {
savedSession = undefined;
}
session = undefined;
host = process.env.PUSHY_REGISTRY || 'https://update.reactnative.cn/api';
host = process.env.PUSHY_REGISTRY || defaultEndpoint;
};
async function query(url, options) {

View File

@@ -2,14 +2,11 @@
* Created by tdzl2003 on 2/13/16.
*/
import {question} from './utils';
import { question } from './utils';
import fs from 'fs';
const Table = require('tty-table');
const {
post,
get,
doDelete,
} = require('./api');
const { post, get, doDelete } = require('./api');
const validPlatforms = {
ios: 1,
@@ -20,28 +17,42 @@ export function checkPlatform(platform) {
if (!validPlatforms[platform]) {
throw new Error(`Invalid platform '${platform}'`);
}
return platform
return platform;
}
export function getSelectedApp(platform) {
checkPlatform(platform);
if (!fs.existsSync('update.json')){
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
if (!fs.existsSync('update.json')) {
throw new Error(
`App not selected. run 'pushy selectApp --platform ${platform}' first!`,
);
}
const updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
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];
}
export async function listApp(platform){
const {data} = await get('/app/list');
const list = platform?data.filter(v=>v.platform===platform):data;
export async function listApp(platform) {
const { data } = await get('/app/list');
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) {
console.log(`${app.id}) ${app.name}(${app.platform})`);
rows.push([app.id, app.name, app.platform]);
}
console.log(Table(header, rows).render());
if (platform) {
console.log(`\nTotal ${list.length} ${platform} apps`);
} else {
@@ -55,7 +66,7 @@ export async function chooseApp(platform) {
while (true) {
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) {
return app;
}
@@ -63,19 +74,21 @@ export async function chooseApp(platform) {
}
export const commands = {
createApp: async function ({options}) {
const name = options.name || await question('App Name:');
const {downloadUrl} = options;
const platform = checkPlatform(options.platform || await question('Platform(ios/android):'));
const {id} = await post('/app/create', {name, platform});
createApp: async function ({ options }) {
const name = options.name || (await question('App Name:'));
const { downloadUrl } = options;
const platform = checkPlatform(
options.platform || (await question('Platform(ios/android):')),
);
const { id } = await post('/app/create', { name, platform });
console.log(`Created app ${id}`);
await this.selectApp({
args: [id],
options: {platform, downloadUrl},
options: { platform, downloadUrl },
});
},
deleteApp: async function ({args, options}) {
const {platform} = options;
deleteApp: async function ({ args, options }) {
const { platform } = options;
const id = args[0] || chooseApp(platform);
if (!id) {
console.log('Canceled');
@@ -83,12 +96,14 @@ export const commands = {
await doDelete(`/app/${id}`);
console.log('Ok.');
},
apps: async function ({options}){
const {platform} = options;
apps: async function ({ options }) {
const { platform } = options;
listApp(platform);
},
selectApp: async function({args, options}) {
const platform = checkPlatform(options.platform || await question('Platform(ios/android):'));
selectApp: async function ({ args, options }) {
const platform = checkPlatform(
options.platform || (await question('Platform(ios/android):')),
);
const id = args[0] || (await chooseApp(platform)).id;
let updateInfo = {};
@@ -96,15 +111,21 @@ export const commands = {
try {
updateInfo = JSON.parse(fs.readFileSync('update.json', 'utf8'));
} 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;
}
}
const {appKey} = await get(`/app/${id}`);
const { appKey } = await get(`/app/${id}`);
updateInfo[platform] = {
appId: id,
appKey,
};
fs.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
fs.writeFileSync(
'update.json',
JSON.stringify(updateInfo, null, 4),
'utf8',
);
},
}
};

View File

@@ -52,8 +52,25 @@ export const commands = {
if (!fn || !fn.endsWith('.ipa')) {
throw new Error('Usage: pushy uploadIpa <ipaFile>');
}
const { versionName, buildTime } = await getIpaInfo(fn);
const { appId } = await getSelectedApp('ios');
const {
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);
@@ -70,8 +87,25 @@ export const commands = {
if (!fn || !fn.endsWith('.apk')) {
throw new Error('Usage: pushy uploadApk <apkFile>');
}
const { versionName, buildTime } = await getApkInfo(fn);
const { appId } = await getSelectedApp('android');
const {
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);

View File

@@ -72,10 +72,10 @@ anymatch@^1.3.0:
micromatch "^2.1.5"
normalize-path "^2.0.0"
app-info-parser@^0.3.9:
version "0.3.9"
resolved "https://registry.yarnpkg.com/app-info-parser/-/app-info-parser-0.3.9.tgz#adc60c9d4d4aca4e529f21a6da1279b74ddaf62b"
integrity sha512-vIzO1OZSMnEz+OdGkhmSTS0y4PaQmXdF1YmzUBb7wsKR21JF1eXMnciARkUj6T+CLb9caoDSN+w5eSoGatRbcA==
app-info-parser@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/app-info-parser/-/app-info-parser-1.0.0.tgz#38da83c167b436b485246a2c81ab28833ac12b6e"
integrity sha512-l8fNzGZFTNCloUm5imfOQYjlBLQfu3DB9rkKgi7TWAjtCU2s0NMLetOw0TFmHye65NcdenAQawvLNLtyo1L//w==
dependencies:
bplist-parser "^0.2.0"
bytebuffer "^5.0.1"
@@ -1476,9 +1476,9 @@ is-glob@^2.0.0, is-glob@^2.0.1:
is-extglob "^1.0.0"
is-installed-globally@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.1.tgz#679afef819347a72584617fd19497f010b8ed35f"
integrity sha512-oiEcGoQbGc+3/iijAijrK2qFpkNoNjsHOm/5V5iaeydyrS/hnwaRCEgH5cpW0P3T1lSjV5piB7S5b5lEugNLhg==
version "0.3.2"
resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.2.tgz#fd3efa79ee670d1187233182d5b0a1dd00313141"
integrity sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g==
dependencies:
global-dirs "^2.0.1"
is-path-inside "^3.0.1"
@@ -1885,10 +1885,10 @@ nanomatch@^1.2.9:
snapdragon "^0.8.1"
to-regex "^3.0.1"
node-fetch@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
normalize-path@^2.0.0, normalize-path@^2.0.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==
pupa@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726"
integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA==
version "2.1.1"
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62"
integrity sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==
dependencies:
escape-goat "^2.0.0"
@@ -2694,10 +2694,10 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"
update-notifier@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3"
integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew==
update-notifier@^4.1.1:
version "4.1.3"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.3.tgz#be86ee13e8ce48fb50043ff72057b5bd598e1ea3"
integrity sha512-Yld6Z0RyCYGB6ckIjffGOSOmHXj1gMeE7aROz4MG+XMkmixBX4jUngrGXNYz7wPKBmtoD4MnBa2Anu7RSKht/A==
dependencies:
boxen "^4.2.0"
chalk "^3.0.0"