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

修复node10的兼容问题

This commit is contained in:
sunny.luo
2018-07-20 17:01:12 +08:00
parent ccbc17d255
commit 43d062d288
6 changed files with 188 additions and 241 deletions

View File

@@ -0,0 +1,67 @@
/**
* Created by tdzl2003 on 2/13/16.
*/
import * as path from 'path';
import * as fs from 'fs';
import ApkReader from 'node-apk-parser';
import ipaReader from './ipaReader';
var read = require('read');
export function question(query, password) {
if (NO_INTERACTIVE) {
return Promise.resolve('');
}
return new Promise((resolve, reject) =>
read(
{
prompt: query,
silent: password,
replace: password ? '*' : undefined
},
(err, result) => (err ? reject(err) : resolve(result))
)
);
}
export function translateOptions(options) {
const ret = {};
for (let key in options) {
const v = options[key];
if (typeof v === 'string') {
ret[key] = v.replace(/\$\{(\w+)\}/g, function(v, n) {
return options[n] || process.env[n] || v;
});
} else {
ret[key] = v;
}
}
return ret;
}
export function getRNVersion() {
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);
return {
version,
major: match[1] | 0,
minor: match[2] | 0
};
}
export function getApkVersion(fn) {
const reader = ApkReader.readFile(fn);
const manifest = reader.readManifestSync();
return Promise.resolve(manifest.versionName);
}
export function getIPAVersion(fn) {
return new Promise((resolve, reject) => {
ipaReader(fn, (err, data) => {
err ? reject(err) : resolve(data.metadata.CFBundleShortVersionString);
});
});
}

View File

@@ -0,0 +1,58 @@
// 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);
}
};