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

Read build time for ipa

This commit is contained in:
sunnylqm
2019-11-24 21:58:12 +08:00
parent 737060e962
commit 6b254582b6
6 changed files with 21 additions and 224 deletions

View File

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

View File

@@ -4,7 +4,6 @@
import * as path from 'path';
import * as fs from 'fs-extra';
import ipaReader from './ipaReader';
const AppInfoParser = require('app-info-parser');
var read = require('read');
@@ -52,9 +51,9 @@ export function getRNVersion() {
};
}
export async function getAppInfo(fn) {
const parser = new AppInfoParser(fn);
const { versionName, application } = await parser.parse();
export async function getApkInfo(fn) {
const appInfoParser = new AppInfoParser(fn);
const { versionName, application } = await appInfoParser.parse();
let buildTime = 0;
if (Array.isArray(application.metaData)) {
for (const meta of application.metaData) {
@@ -64,15 +63,19 @@ export async function getAppInfo(fn) {
}
}
if (buildTime == 0) {
throw new Error('Can not get build time for this app.')
throw new Error('Can not get build time for this app.');
}
return { versionName, buildTime };
}
export function getIPAVersion(fn) {
return new Promise((resolve, reject) => {
ipaReader(fn, (err, data) => {
err ? reject(err) : resolve(data.metadata.CFBundleShortVersionString);
});
});
export async function getIpaInfo(fn) {
const appInfoParser = new AppInfoParser(fn);
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
try {
const buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
return { versionName, buildTime };
} catch (e) {
throw new Error('Can not get build time for this app.');
}
}

View File

@@ -1,58 +0,0 @@
// var async = require('async');
var plist = require('simple-plist');
var decompress = require('decompress-zip');
// var provisioning = require('provisioning');
// var entitlements = require('entitlements');
var rimraf = require('rimraf');
var tmp = require('temporary');
var glob = require('glob');
var output = new tmp.Dir();
module.exports = function(file, callback) {
var data = {};
var unzipper = new decompress(file);
unzipper.extract({
path: output.path
});
unzipper.on('error', cleanUp);
unzipper.on('extract', function() {
var path = glob.sync(output.path + '/Payload/*/')[0];
data.metadata = plist.readFileSync(path + 'Info.plist');
cleanUp();
/*
var tasks = [async.apply(provisioning, path + 'embedded.mobileprovision')];
// `entitlements` relies on a OS X only CLI tool called `codesign`
if (process.platform === 'darwin') {
tasks.push(async.apply(entitlements, path));
}
async.parallel(tasks, function(error, results) {
if (error) {
return cleanUp(error);
}
data.provisioning = results[0];
// Hard to serialize and it looks messy in output
delete data.provisioning.DeveloperCertificates;
// Will be undefined on non-OSX platforms
data.entitlements = results[1];
return cleanUp();
});
*/
});
function cleanUp(error) {
rimraf.sync(output.path);
return callback(error, data);
}
};