[android] add sign task
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const {StringWritable} = require('./tail');
|
||||
@@ -89,12 +90,16 @@ class Android extends Sdk {
|
||||
});
|
||||
}
|
||||
|
||||
aapt(args) {
|
||||
buildTool(name) {
|
||||
let buildToolsVersion = null;
|
||||
fs.readdirSync(path.join(this.path, 'build-tools')).forEach(file => {
|
||||
buildToolsVersion = file;
|
||||
});
|
||||
const aaptBin = path.join(this.path, 'build-tools', buildToolsVersion, 'aapt');
|
||||
return path.join(this.path, 'build-tools', buildToolsVersion, name);
|
||||
}
|
||||
|
||||
aapt(args) {
|
||||
const aaptBin = this.buildTool('aapt');
|
||||
return exec('.', [aaptBin].concat(args).join(' '));
|
||||
}
|
||||
|
||||
@@ -191,6 +196,27 @@ class Android extends Sdk {
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
sign(keystore, keypass) {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
self.log.i('sign *%s*', file.path);
|
||||
const filename = path.join(os.tmpdir(), 'tmp.apk');
|
||||
fs.writeFileSync(filename, file.contents);
|
||||
const cmd = [
|
||||
self.buildTool('apksigner'),
|
||||
'sign',
|
||||
'--ks', keystore,
|
||||
'--ks-pass', `pass:${keypass}`,
|
||||
filename
|
||||
].join(' ');
|
||||
exec('.', cmd).then(() => {
|
||||
file.contents = fs.readFileSync(filename);
|
||||
this.push(file);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Android.ID = 'android';
|
||||
|
||||
Reference in New Issue
Block a user