mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-10-07 11:05:15 +08:00
seperate key name
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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,
|
||||
|
@@ -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:') || '(未命名)',
|
||||
|
Reference in New Issue
Block a user