mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 09:41:38 +08:00
Save to local after upload
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const { get, post, uploadFile } = require('./api');
|
const { get, post, uploadFile } = require('./api');
|
||||||
import { question } from './utils';
|
import { question, saveToLocal } from './utils';
|
||||||
|
|
||||||
import { checkPlatform, getSelectedApp } from './app';
|
import { checkPlatform, getSelectedApp } from './app';
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ export const commands = {
|
|||||||
hash,
|
hash,
|
||||||
buildTime,
|
buildTime,
|
||||||
});
|
});
|
||||||
|
saveToLocal(fn, `${appId}/${id}.ipa`);
|
||||||
console.log(`Ipa uploaded: ${id}`);
|
console.log(`Ipa uploaded: ${id}`);
|
||||||
},
|
},
|
||||||
uploadApk: async function({ args }) {
|
uploadApk: async function({ args }) {
|
||||||
@@ -77,6 +78,7 @@ export const commands = {
|
|||||||
hash,
|
hash,
|
||||||
buildTime,
|
buildTime,
|
||||||
});
|
});
|
||||||
|
saveToLocal(fn, `${appId}/${id}.apk`);
|
||||||
console.log(`Apk uploaded: ${id}`);
|
console.log(`Apk uploaded: ${id}`);
|
||||||
},
|
},
|
||||||
packages: async function({ options }) {
|
packages: async function({ options }) {
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
const AppInfoParser = require('app-info-parser');
|
const AppInfoParser = require('app-info-parser');
|
||||||
|
|
||||||
var read = require('read');
|
var read = require('read');
|
||||||
@@ -40,7 +42,9 @@ export function translateOptions(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getRNVersion() {
|
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.
|
// We only care about major and minor version.
|
||||||
const match = /^(\d+)\.(\d+)\./.exec(version);
|
const match = /^(\d+)\.(\d+)\./.exec(version);
|
||||||
@@ -70,11 +74,17 @@ export async function getApkInfo(fn) {
|
|||||||
|
|
||||||
export async function getIpaInfo(fn) {
|
export async function getIpaInfo(fn) {
|
||||||
const appInfoParser = new AppInfoParser(fn);
|
const appInfoParser = new AppInfoParser(fn);
|
||||||
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
const {
|
||||||
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
|
CFBundleShortVersionString: versionName,
|
||||||
|
} = await appInfoParser.parse();
|
||||||
|
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(
|
||||||
|
/payload\/.+?\.app\/pushy_build_time.txt/,
|
||||||
|
);
|
||||||
if (!buildTimeTxtBuffer) {
|
if (!buildTimeTxtBuffer) {
|
||||||
// Not in root bundle when use `use_frameworks`
|
// 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) {
|
if (!buildTimeTxtBuffer) {
|
||||||
throw new Error('Can not get build time for this app.');
|
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', '');
|
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
|
||||||
return { versionName, buildTime };
|
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);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user