jh5_app_build 1.0.19 → 1.0.20

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.
Files changed (2) hide show
  1. package/lib/build_std.js +13 -6
  2. package/package.json +1 -1
package/lib/build_std.js CHANGED
@@ -3,6 +3,7 @@ let archiver = require('archiver');
3
3
  let jutils = require('base_parts');
4
4
 
5
5
  let fs = require('fs');
6
+ let path = require('path');
6
7
  let os = require('os');
7
8
  let AdmZip = require('adm-zip');
8
9
  let child_process = require('child_process');
@@ -162,13 +163,17 @@ module.exports = async (cmd, buildCfg) => {
162
163
  console.log(`not find keystore,making ...`);
163
164
  let jreCwd = "C:\\jdev_develop\\jre\\bin";
164
165
  let keyStoreFile = `${buildCfg.rootPath}/sigin/apk_cert.keystore`;
166
+ try {
167
+ fs.mkdirSync(path.dirname(keyStoreFile));
168
+ } catch (error) {
169
+ }
165
170
  if (!fs.existsSync(keyStoreFile)) {
166
171
  // 生成签名
167
172
  child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\keytool.exe", [
168
173
  "-genkey",
169
174
  "-storepass", "123456",
170
175
  "-keypass", "123456",
171
- "-alias", "apk_cert.keystore",
176
+ "-alias", "apk_cert",
172
177
  "-keyalg", "RSA",
173
178
  "-validity", "20000",
174
179
  "-keystore", keyStoreFile,
@@ -180,28 +185,30 @@ module.exports = async (cmd, buildCfg) => {
180
185
 
181
186
  // 签名
182
187
  console.log(`sign apk ...`);
188
+ var singApkTmp = buildCfg.outpath + "_sign.apk";
183
189
  child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\jarsigner.exe", [
184
190
  "-verbose",
185
191
  "-storepass", "123456",
186
192
  "-keypass", "123456",
187
- "-keystore", "apk_cert.keystore",
188
- "-signedjar", buildCfg.outpath + "_sign.apk",
193
+ "-keystore", keyStoreFile,
194
+ "-signedjar", singApkTmp,
189
195
  buildCfg.outpath,
190
- keyStoreFile
196
+ "apk_cert"
191
197
  ], {
192
198
  cwd: jreCwd
193
199
  });
200
+ fs.unlinkSync(buildCfg.outpath); // 删除未签名的
194
201
 
195
202
  // 对齐apk
196
203
  console.log(`zip align ...`);
197
- fs.unlinkSync(buildCfg.outpath);
198
204
  child_process.execFileSync("C:\\jdev_develop\\jre\\bin\\zipalign.exe", [
199
205
  "-v", "4",
200
- buildCfg.outpath + "_sign.apk",
206
+ singApkTmp,
201
207
  buildCfg.outpath
202
208
  ], {
203
209
  cwd: jreCwd
204
210
  });
211
+ fs.unlinkSync(singApkTmp); // 删除未对齐的
205
212
 
206
213
  // 完成
207
214
  console.log(`build success:${buildCfg.outpath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jh5_app_build",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "jaskle jh5_app_build",
5
5
  "main": "./bin/jh5_app_build.js",
6
6
  "registry": true,