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

seperate key name

This commit is contained in:
sunnylqm
2020-03-16 19:10:02 +08:00
parent 15b82b440e
commit a6477b4f0f
5 changed files with 27 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
"request": "^2.88.2",
"tcp-ping": "^0.1.1",
"tty-table": "2.8",
"uid-safe": "^2.1.5",
"update-notifier": "^4.1.0",
"yauzl": "^2.10.0",
"yazl": "2.5.1"

View File

@@ -101,7 +101,7 @@ exports.post = queryWithBody('POST');
exports.put = queryWithBody('PUT');
exports.doDelete = queryWithBody('DELETE');
async function uploadFile(fn) {
async function uploadFile(fn, key) {
const { url, backupUrl, formData } = await exports.post('/upload', {});
let realUrl = url;
@@ -112,7 +112,7 @@ async function uploadFile(fn) {
timeout: 1000,
});
// console.log({pingResult});
if (pingResult.avg > 150) {
if (isNaN(pingResult.avg) || pingResult.avg > 150) {
realUrl = backupUrl;
}
// console.log({realUrl});
@@ -127,6 +127,9 @@ async function uploadFile(fn) {
});
const info = await new Promise((resolve, reject) => {
if (key) {
formData.key = key;
}
formData.file = fs.createReadStream(fn);
formData.file.on('data', function(data) {

View File

@@ -8,6 +8,10 @@ import { question, saveToLocal } from './utils';
import { checkPlatform, getSelectedApp } from './app';
import { getApkInfo, getIpaInfo } from './utils';
import uid from 'uid-safe';
const uidSync = uid.sync;
const Table = require('tty-table');
export async function listPackage(appId) {
@@ -53,7 +57,7 @@ export const commands = {
const { versionName, buildTime } = await getIpaInfo(fn);
const { appId } = await getSelectedApp('ios');
const { hash } = await uploadFile(fn);
const { hash } = await uploadFile(fn, `i/${uidSync(19)}`);
const { id } = await post(`/app/${appId}/package/create`, {
name: versionName,
@@ -71,7 +75,7 @@ export const commands = {
const { versionName, buildTime } = await getApkInfo(fn);
const { appId } = await getSelectedApp('android');
const { hash } = await uploadFile(fn);
const { hash } = await uploadFile(fn, `a/${uidSync(19)}`);
const { id } = await post(`/app/${appId}/package/create`, {
name: versionName,

View File

@@ -12,6 +12,8 @@ import { question, saveToLocal } from './utils';
import { checkPlatform, getSelectedApp } from './app';
import { choosePackage } from './package';
import uid from 'uid-safe';
const uidSync = uid.sync;
async function showVersion(appId, offset) {
const { data, count } = await get(`/app/${appId}/version/list`);
@@ -78,7 +80,7 @@ export const commands = {
const platform = checkPlatform(options.platform || await question('Platform(ios/android):'));
const { appId } = await getSelectedApp(platform);
const { hash } = await uploadFile(fn);
const { hash } = await uploadFile(fn, `v/${uidSync(19)}`);
const { id } = await post(`/app/${appId}/version/create`, {
name: name || await question('Enter version name:') || '(未命名)',

View File

@@ -2174,6 +2174,11 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
random-bytes@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/random-bytes/-/random-bytes-1.0.0.tgz#4f68a1dc0ae58bd3fb95848c30324db75d64360b"
integrity sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=
randomatic@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.1.tgz#b776efc59375984e36c537b2f51a1f0aff0da1ed"
@@ -2694,6 +2699,13 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"
uid-safe@^2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/uid-safe/-/uid-safe-2.1.5.tgz#2b3d5c7240e8fc2e58f8aa269e5ee49c0857bd3a"
integrity sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==
dependencies:
random-bytes "~1.0.0"
union-value@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"