1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
lvbingru 2016-04-02 14:24:40 +08:00
commit 325d23e50a
2 changed files with 40 additions and 6 deletions

View File

@ -70,6 +70,15 @@
"hasValue": true "hasValue": true
} }
} }
},
"diffWithIpa": {
"description": "Create diff patch from a iOS package(.ipa)",
"options": {
"output": {
"default": "build/output/diff-${time}.ipa-patch",
"hasValue": true
}
}
} }
}, },
"globalOptions":{ "globalOptions":{

View File

@ -207,7 +207,7 @@ async function diffWithPPK(origin, next, output) {
await writePromise; await writePromise;
} }
async function diffWithPackage(origin, next, output, originBundleName) { async function diffWithPackage(origin, next, output, originBundleName, transformPackagePath = v=>v) {
const originEntries = {}; const originEntries = {};
const originMap = {}; const originMap = {};
@ -215,11 +215,16 @@ async function diffWithPackage(origin, next, output, originBundleName) {
await enumZipEntries(origin, (entry, zipFile) => { await enumZipEntries(origin, (entry, zipFile) => {
if (!/\/$/.test(entry.fileName)) { if (!/\/$/.test(entry.fileName)) {
// isFile const fn = transformPackagePath(entry.filename);
originEntries[entry.fileName] = entry.crc32; if (!fn) {
originMap[entry.crc32] = entry.fileName; return;
}
if (entry.fileName === originBundleName) { // isFile
originEntries[fn] = entry.crc32;
originMap[entry.crc32] = fn;
if (fn === originBundleName) {
// This is source. // This is source.
return readEntire(entry, zipFile).then(v=>originSource = v); return readEntire(entry, zipFile).then(v=>originSource = v);
} }
@ -381,6 +386,26 @@ export const commands = {
process.exit(1); process.exit(1);
} }
await diffWithPackage(origin, next, realOutput, 'assets/index.android.bundle'); await diffWithPackage(origin, next, realOutput, 'assets/index.android.bundle', v=>{
const m = /^res\/(.+)$/.exec(v);
return m && m[1];
});
},
async diffWithIpa({args, options}) {
const [origin, next] = args;
const {output} = options;
const realOutput = output.replace(/\$\{time\}/g, '' + Date.now());
if (!origin || !next) {
console.error('pushy diffWithIpa <origin> <next>');
process.exit(1);
}
await diffWithPackage(origin, next, realOutput, 'index.ios.bundle', v=>{
const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
return m && m[1];
});
}, },
}; };