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

working on android

This commit is contained in:
tdzl2003
2016-03-31 16:22:47 +08:00
parent 2765d2f4be
commit dbe1f9b26d
20 changed files with 375 additions and 168 deletions

View File

@@ -42,7 +42,7 @@
"hasValue": true
},
"output": {
"default": "build/output/${platform}.${hash}.ppk",
"default": "build/output/${platform}.${time}.ppk",
"hasValue": true
},
"verbose": {

View File

@@ -26,38 +26,9 @@ function mkdir(dir){
});
}
function calcMd5ForFile(fn) {
return new Promise((resolve, reject) => {
var hash = crypto.createHash('md5'),
stream = fs.createReadStream(fn);
stream.on('data', (data) => hash.update(data, 'utf8'));
stream.on('end', () => resolve(hash.digest('hex')));
stream.on('error', err => reject(err));
})
}
async function calcMd5ForDirectory(dir) {
const childs = fs.readdirSync(dir).sort();
const result = {};
for (const name of childs) {
const fullPath = path.join(dir, name);
const stat = fs.statSync(fullPath);
if (stat.isFile()) {
result[name] = 'file:' + await calcMd5ForFile(fullPath);
} else {
result[name] = 'directory:' + await calcMd5ForDirectory(fullPath);
}
}
var hash = crypto.createHash('md5');
hash.update(JSON.stringify(result), 'md5');
return hash.digest('hex');
}
async function pack(dir, output){
const hash = await calcMd5ForDirectory(dir);
const realOutput = output.replace(/\$\{hash\}/g, hash);
await mkdir(path.dirname(realOutput))
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
await mkdir(path.dirname(realOutput));
await new Promise((resolve, reject) => {
var zipfile = new ZipFile();
@@ -91,7 +62,7 @@ async function pack(dir, output){
});
zipfile.end();
});
console.log('Bundled with hash: ' + hash);
console.log('Bundled saved to: ' + realOutput);
}
function enumZipEntries(zipFn, callback) {
@@ -207,20 +178,15 @@ export const commands = {
} else {
// If same file.
if (originEntries[entry.fileName] === entry.crc32) {
console.log('keep:', entry.fileName);
copies[entry.fileName] = 1;
return;
}
// If moved from other place
if (originMap[entry.crc32]){
console.log('move:' + originMap[entry.crc32] + '->' + entry.fileName);
copies[entry.fileName] = originMap[entry.crc32];
return;
}
// TODO: test diff
console.log('add:' + entry.fileName);
return new Promise((resolve, reject)=>{
nextZipfile.openReadStream(entry, function(err, readStream) {
if (err){