mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-17 21:46:09 +08:00
修复node10的兼容问题
This commit is contained in:
@@ -5,29 +5,34 @@
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import ApkReader from 'node-apk-parser';
|
||||
import ipaMetadata from 'ipa-metadata';
|
||||
import ipaReader from './ipaReader';
|
||||
|
||||
var read = require('read');
|
||||
|
||||
export function question(query, password) {
|
||||
if (NO_INTERACTIVE){
|
||||
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)));
|
||||
return new Promise((resolve, reject) =>
|
||||
read(
|
||||
{
|
||||
prompt: query,
|
||||
silent: password,
|
||||
replace: password ? '*' : undefined
|
||||
},
|
||||
(err, result) => (err ? reject(err) : resolve(result))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function translateOptions(options){
|
||||
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){
|
||||
if (typeof v === 'string') {
|
||||
ret[key] = v.replace(/\$\{(\w+)\}/g, function(v, n) {
|
||||
return options[n] || process.env[n] || v;
|
||||
})
|
||||
});
|
||||
} else {
|
||||
ret[key] = v;
|
||||
}
|
||||
@@ -43,7 +48,7 @@ export function getRNVersion() {
|
||||
return {
|
||||
version,
|
||||
major: match[1] | 0,
|
||||
minor: match[2] | 0,
|
||||
minor: match[2] | 0
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,7 +60,7 @@ export function getApkVersion(fn) {
|
||||
|
||||
export function getIPAVersion(fn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipaMetadata(fn, (err, data) => {
|
||||
ipaReader(fn, (err, data) => {
|
||||
err ? reject(err) : resolve(data.metadata.CFBundleShortVersionString);
|
||||
});
|
||||
});
|
58
local-cli/src/utils/ipaReader.js
Normal file
58
local-cli/src/utils/ipaReader.js
Normal 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);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user