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

Save to local after upload

This commit is contained in:
sunnylqm
2020-02-26 00:32:08 +08:00
parent 772929837f
commit d63ba619ba
2 changed files with 25 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
*/
const { get, post, uploadFile } = require('./api');
import { question } from './utils';
import { question, saveToLocal } from './utils';
import { checkPlatform, getSelectedApp } from './app';
@@ -60,6 +60,7 @@ export const commands = {
hash,
buildTime,
});
saveToLocal(fn, `${appId}/${id}.ipa`);
console.log(`Ipa uploaded: ${id}`);
},
uploadApk: async function({ args }) {
@@ -77,6 +78,7 @@ export const commands = {
hash,
buildTime,
});
saveToLocal(fn, `${appId}/${id}.apk`);
console.log(`Apk uploaded: ${id}`);
},
packages: async function({ options }) {

View File

@@ -4,6 +4,8 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import os from 'os';
import path from 'path';
const AppInfoParser = require('app-info-parser');
var read = require('read');
@@ -40,7 +42,9 @@ export function translateOptions(options) {
}
export function getRNVersion() {
const version = JSON.parse(fs.readFileSync(path.resolve('node_modules/react-native/package.json'))).version;
const version = JSON.parse(
fs.readFileSync(path.resolve('node_modules/react-native/package.json')),
).version;
// We only care about major and minor version.
const match = /^(\d+)\.(\d+)\./.exec(version);
@@ -70,11 +74,17 @@ export async function getApkInfo(fn) {
export async function getIpaInfo(fn) {
const appInfoParser = new AppInfoParser(fn);
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
const {
CFBundleShortVersionString: versionName,
} = await appInfoParser.parse();
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(
/payload\/.+?\.app\/pushy_build_time.txt/,
);
if (!buildTimeTxtBuffer) {
// Not in root bundle when use `use_frameworks`
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(
/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/,
);
}
if (!buildTimeTxtBuffer) {
throw new Error('Can not get build time for this app.');
@@ -82,3 +92,11 @@ export async function getIpaInfo(fn) {
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
return { versionName, buildTime };
}
const localDir = path.resolve(os.homedir(), '.pushy');
fs.ensureDirSync(localDir);
export function saveToLocal(originPath, destName) {
const destPath = path.join(localDir, destName);
fs.ensureDirSync(path.dirname(destPath));
fs.copyFileSync(originPath, destPath);
}