1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-08 11:15:15 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Read build time in local-cli for apk

This commit is contained in:
sunnylqm
2019-11-21 00:02:00 +08:00
parent b848259905
commit 737060e962
7 changed files with 140 additions and 32 deletions

View File

@@ -7,7 +7,7 @@ import { question } from './utils';
import { checkPlatform, getSelectedApp } from './app';
import { getIPAVersion, getApkVersion } from './utils';
import { getIPAVersion, getAppInfo } from './utils';
const Table = require('tty-table');
export async function listPackage(appId) {
@@ -66,14 +66,15 @@ export const commands = {
if (!fn) {
throw new Error('Usage: pushy uploadApk <apkFile>');
}
const name = await getApkVersion(fn);
const { versionName, buildTime } = await getAppInfo(fn);
const { appId } = await getSelectedApp('android');
const { hash } = await uploadFile(fn);
const { id } = await post(`/app/${appId}/package/create`, {
name,
name: versionName,
hash,
buildTime,
});
console.log(`Apk uploaded: ${id}`);
},

View File

@@ -4,8 +4,8 @@
import * as path from 'path';
import * as fs from 'fs-extra';
const ApkReader = require('adbkit-apkreader');
import ipaReader from './ipaReader';
const AppInfoParser = require('app-info-parser');
var read = require('read');
@@ -52,10 +52,21 @@ export function getRNVersion() {
};
}
export async function getApkVersion(fn) {
const reader = await ApkReader.open(fn);
const manifest = await reader.readManifest();
return manifest.versionName;
export async function getAppInfo(fn) {
const parser = new AppInfoParser(fn);
const { versionName, application } = await parser.parse();
let buildTime = 0;
if (Array.isArray(application.metaData)) {
for (const meta of application.metaData) {
if (meta.name === 'pushy_build_time') {
buildTime = meta.value[0];
}
}
}
if (buildTime == 0) {
throw new Error('Can not get build time for this app.')
}
return { versionName, buildTime };
}
export function getIPAVersion(fn) {