1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-17 21:46:09 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
tdzl2003
2016-04-05 00:48:22 +08:00
parent 2b39280f50
commit 28a11bc19e
5 changed files with 44 additions and 16 deletions

View File

@@ -12,6 +12,7 @@ import * as fs from 'fs';
import {ZipFile} from 'yazl';
import {open as openZipFile} from 'yauzl';
import {diff} from 'node-bsdiff';
import { question } from './utils';
import crypto from 'crypto';
@@ -28,8 +29,7 @@ function mkdir(dir){
}
async function pack(dir, output){
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
await mkdir(path.dirname(realOutput));
await mkdir(path.dirname(output));
await new Promise((resolve, reject) => {
var zipfile = new ZipFile();
@@ -57,13 +57,13 @@ async function pack(dir, output){
addDirectory(dir, '');
zipfile.outputStream.on('error', err => reject(err));
zipfile.outputStream.pipe(fs.createWriteStream(realOutput))
zipfile.outputStream.pipe(fs.createWriteStream(output))
.on("close", function() {
resolve();
});
zipfile.end();
});
console.log('Bundled saved to: ' + realOutput);
console.log('Bundled saved to: ' + output);
}
function readEntire(entry, zipFile) {
@@ -94,6 +94,8 @@ function basename(fn) {
}
async function diffWithPPK(origin, next, output) {
await mkdir(path.dirname(output));
const originEntries = {};
const originMap = {};
@@ -208,6 +210,8 @@ async function diffWithPPK(origin, next, output) {
}
async function diffWithPackage(origin, next, output, originBundleName, transformPackagePath = v=>v) {
await mkdir(path.dirname(output));
const originEntries = {};
const originMap = {};
@@ -320,6 +324,7 @@ export const commands = {
dev,
verbose
} = translateOptions(options);
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
if (!platform) {
throw new Error('Platform must be specified.');
@@ -359,7 +364,14 @@ export const commands = {
console.log('Packing');
await pack(intermediaDir, output);
await pack(intermediaDir, realOutput);
const v = await question('Would you like to publish it?(Y/N)');
if (v.toLowerCase() === 'y') {
await this.publish({args: [realOutput], options: {
platform,
}})
}
},
async diff({args, options}) {
@@ -374,6 +386,7 @@ export const commands = {
}
await diffWithPPK(origin, next, realOutput, 'index.bundlejs');
console.log(`${realOutput} generated.`);
},
async diffFromApk({args, options}) {

View File

@@ -57,7 +57,6 @@ async function chooseVersion(appId) {
case 'B': offset = 0; break;
default:
{
console.log(data.find(v=>v.id === (cmd | 0)));
const v = data.find(v=>v.id === (cmd | 0));
if (v) {
return v;
@@ -79,16 +78,16 @@ export const commands = {
const { hash } = await uploadFile(fn);
const { id } = await post(`/app/${appId}/version/create`, {
name,
name: name || await question('Enter version name:') || '(未命名)',
hash,
description,
metaInfo,
description: description || await question('Enter description:'),
metaInfo: metaInfo || await question('Enter meta info:'),
});
console.log('Ok.');
const v = await question('Would you like to bind packages to this version?(Y/N)');
if (v.toLowerCase() === 'y') {
await this.update({args:[], options:{packageId: id, }});
await this.update({args:[], options:{packageId: id, platform}});
}
},
versions: async function({options}) {