jh5_app_build 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build_std.js +51 -6
- package/package.json +1 -1
package/lib/build_std.js
CHANGED
|
@@ -5,11 +5,13 @@ let jutils = require('base_parts');
|
|
|
5
5
|
let fs = require('fs');
|
|
6
6
|
let os = require('os');
|
|
7
7
|
let AdmZip = require('adm-zip');
|
|
8
|
+
let child_process = require('child_process');
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
module.exports = async (cmd, buildCfg) => {
|
|
10
|
-
|
|
12
|
+
// 生成无签名的apk
|
|
13
|
+
await new Promise((resolve, reject) => {
|
|
11
14
|
(async () => {
|
|
12
|
-
|
|
13
15
|
// 建立压缩文件
|
|
14
16
|
console.log(`build file to ${buildCfg.outpath}`);
|
|
15
17
|
let output = fs.createWriteStream(buildCfg.outpath);
|
|
@@ -18,7 +20,6 @@ module.exports = async (cmd, buildCfg) => {
|
|
|
18
20
|
});
|
|
19
21
|
output.on('close', function () {
|
|
20
22
|
console.log(archive.pointer() + ' total bytes');
|
|
21
|
-
console.log(`build success:${buildCfg.outpath}`);
|
|
22
23
|
resolve();
|
|
23
24
|
});
|
|
24
25
|
output.on('end', function () {
|
|
@@ -72,9 +73,6 @@ module.exports = async (cmd, buildCfg) => {
|
|
|
72
73
|
if (!["META-INF/CERT.RSA", "META-INF/CERT.SF", "META-INF/MANIFEST.MF"].includes(zipEntry.entryName.toUpperCase())) {
|
|
73
74
|
archive.append(zipEntry.getData(), { name: zipEntry.entryName });
|
|
74
75
|
}
|
|
75
|
-
else {
|
|
76
|
-
console.error(">>>>>>>>>" + zipEntry);
|
|
77
|
-
}
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
|
|
@@ -160,5 +158,52 @@ module.exports = async (cmd, buildCfg) => {
|
|
|
160
158
|
});
|
|
161
159
|
});
|
|
162
160
|
|
|
161
|
+
// 生成apk签名
|
|
162
|
+
console.log(`not find keystore,making ...`);
|
|
163
|
+
let jreCwd = "C:\\jdev_develop\\jre\\bin";
|
|
164
|
+
let keyStoreFile = `${buildCfg.rootPath}/sigin/apk_cert.keystore`;
|
|
165
|
+
if (!fs.existsSync(keyStoreFile)) {
|
|
166
|
+
// 生成签名
|
|
167
|
+
child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\keytool.exe", [
|
|
168
|
+
"-genkey",
|
|
169
|
+
"-storepass", "123456",
|
|
170
|
+
"-keypass", "123456",
|
|
171
|
+
"-alias", "apk_cert.keystore",
|
|
172
|
+
"-keyalg", "RSA",
|
|
173
|
+
"-validity", "20000",
|
|
174
|
+
"-keystore", keyStoreFile,
|
|
175
|
+
"-dname", "CN=10.10.6.100,OU=utils,O=utils,L=beijing,ST=beijing,c=cn"
|
|
176
|
+
], {
|
|
177
|
+
cwd: jreCwd
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 签名
|
|
182
|
+
console.log(`sign apk ...`);
|
|
183
|
+
child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\jarsigner.exe", [
|
|
184
|
+
"-verbose",
|
|
185
|
+
"-storepass", "123456",
|
|
186
|
+
"-keypass", "123456",
|
|
187
|
+
"-keystore", "apk_cert.keystore",
|
|
188
|
+
"-signedjar", buildCfg.outpath + "_sign.apk",
|
|
189
|
+
buildCfg.outpath,
|
|
190
|
+
keyStoreFile
|
|
191
|
+
], {
|
|
192
|
+
cwd: jreCwd
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// 对齐apk
|
|
196
|
+
console.log(`zip align ...`);
|
|
197
|
+
fs.unlinkSync(buildCfg.outpath);
|
|
198
|
+
child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\zipalign.exe", [
|
|
199
|
+
"-v", "4",
|
|
200
|
+
buildCfg.outpath + "_sign.apk",
|
|
201
|
+
buildCfg.outpath
|
|
202
|
+
], {
|
|
203
|
+
cwd: jreCwd
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// 完成
|
|
207
|
+
console.log(`build success:${buildCfg.outpath}`);
|
|
163
208
|
}
|
|
164
209
|
|