UNPKG

1.64 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const path = require("path");
4const docker_1 = require("./docker");
5const fs_1 = require("./fs");
6const datauri_1 = require("./datauri");
7async function cordovaPlatformAdd(ctx, image, platform) {
8 await docker_1.prettyUserCommand(ctx, image, ['cordova', 'platform', 'add', platform, '--no-fetch']);
9}
10exports.cordovaPlatformAdd = cordovaPlatformAdd;
11async function cordovaBuildAndroid(ctx, image, { credentials }) {
12 const cordovaArgs = ['cordova', 'build', 'android'];
13 if (credentials) {
14 const keystoreFile = credentials.keystore_file;
15 const keystorePassword = credentials.keystore_password;
16 const keyAlias = credentials.key_alias;
17 const keyPassword = credentials.key_password ? credentials.key_password : credentials.keystore_password;
18 const keystore = datauri_1.datauri(keystoreFile).body;
19 const keystoreFilename = 'android.keystore';
20 const keystorePath = path.resolve(ctx.codedir, keystoreFilename);
21 await fs_1.fsWriteFile(keystorePath, keystore);
22 if (ctx.env.get('BUILD_TYPE') === 'release') {
23 cordovaArgs.push('--release');
24 }
25 cordovaArgs.push('--');
26 cordovaArgs.push(`--keystore=${keystoreFilename}`);
27 cordovaArgs.push([`--storePassword=${keystorePassword}`, '--storePassword=*****']);
28 cordovaArgs.push(`--alias=${keyAlias}`);
29 cordovaArgs.push([`--password=${keyPassword}`, '--password=*****']);
30 }
31 await docker_1.prettyUserCommand(ctx, image, cordovaArgs);
32}
33exports.cordovaBuildAndroid = cordovaBuildAndroid;