Skip to content

Commit 63b2854

Browse files
committed
use security profiles for package
1 parent c5fd5ad commit 63b2854

2 files changed

Lines changed: 9 additions & 90 deletions

File tree

lib/ionic/package.js

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
var fs = require('fs'),
22
path = require('path'),
3-
expandTilde = require('expand-tilde'),
43
_ = require('underscore'),
54
Q = require('q'),
65
moment = require('moment'),
7-
ProgressBar = require('progress'),
86
IonicAppLib = require('ionic-app-lib'),
97
Utils = IonicAppLib.utils,
108
Login = IonicAppLib.login,
119
Package = IonicAppLib.package,
1210
LoginTask = require('./login'),
13-
Prompt = require('./prompt'),
1411
Table = require('./table'),
1512
Task = require('./task').Task;
1613

@@ -83,96 +80,24 @@ function packageBuild(ionic, argv, dir, project, appId) {
8380
return jar;
8481
})
8582
.then(function(j) {
86-
var q = Q.defer();
87-
8883
jar = j;
8984

9085
if (platform === 'android') {
9186
if (buildMode === 'debug') {
92-
q.resolve({});
87+
return Package.buildAndroidDebug(dir, jar, appId);
9388
} else if (buildMode === 'release') {
94-
if (typeof argv.s !== 'undefined') {
95-
argv['keystore'] = argv.s;
96-
}
97-
98-
if (typeof argv.p !== 'undefined') {
99-
argv['keystore-password'] = argv.p;
100-
}
101-
102-
if (typeof argv.k !== 'undefined') {
103-
argv['key-alias'] = argv.k;
89+
if (typeof argv.profile === 'undefined') {
90+
return Utils.fail("Must specify security profile for android release builds (--profile <tag>).", 'package');
10491
}
10592

106-
if (typeof argv.w !== 'undefined') {
107-
argv['key-password'] = argv.w;
108-
}
109-
110-
Prompt.prompt([
111-
{ name: 'keystore', description: 'Keystore File:'.prompt, required: true },
112-
{ name: 'keystore-password', description: 'Keystore Password:'.prompt, hidden: true, required: true },
113-
{ name: 'key-alias', description: 'Key Alias:'.prompt, required: true },
114-
{ name: 'key-password', description: 'Key Password:'.prompt, hidden: true, required: true }
115-
], argv)
116-
.then(function(result) {
117-
q.resolve(result);
118-
})
119-
.catch(function(ex) {
120-
q.reject(ex);
121-
});
122-
} else {
123-
q.reject('Unrecognized build mode: ' + buildMode);
93+
return Package.buildAndroidRelease(dir, jar, appId, argv.profile)
12494
}
12595
} else if (platform === 'ios') {
126-
if (typeof argv.c !== 'undefined') {
127-
argv['cert'] = argv.c;
128-
}
129-
130-
if (typeof argv.p !== 'undefined') {
131-
argv['cert-password'] = argv.p;
132-
}
133-
134-
if (typeof argv.r !== 'undefined') {
135-
argv['provisioning-profile'] = argv.r;
96+
if (typeof argv.profile === 'undefined') {
97+
return Utils.fail("Must specify security profile for ios builds (--profile <tag>).", 'package');
13698
}
13799

138-
Prompt.prompt([
139-
{ name: 'cert', description: 'Certificate File:'.prompt, required: true },
140-
{ name: 'cert-password', description: 'Certificate Password:'.prompt, hidden: true, required: true },
141-
{ name: 'provisioning-profile', description: 'Provisioning Profile:'.prompt, required: true }
142-
], argv)
143-
.then(function(result) {
144-
q.resolve(result);
145-
})
146-
.catch(function(ex) {
147-
q.reject(ex);
148-
});
149-
} else {
150-
q.reject('Unrecognized platform: ' + platform);
151-
}
152-
153-
return q.promise;
154-
})
155-
.then(function(result) {
156-
if (platform === 'android') {
157-
if (buildMode === 'debug') {
158-
return Package.buildAndroidDebug(dir, jar, appId);
159-
} else if (buildMode === 'release') {
160-
var keystoreFilePath = path.resolve(expandTilde(result['keystore'])),
161-
keystorePassword = path.resolve(expandTilde(result['keystore-password'])),
162-
keyAlias = result['key-alias'],
163-
keyPassword = result['key-password'],
164-
keystoreFileStream = fs.createReadStream(keystoreFilePath);
165-
166-
return Package.buildAndroidRelease(dir, jar, appId, keystoreFileStream, keystorePassword, keyAlias, keyPassword)
167-
}
168-
} else if (platform === 'ios') {
169-
var certificateFilePath = path.resolve(expandTilde(result['cert'])),
170-
certificatePassword = result['cert-password'],
171-
provisioningProfileFilePath = path.resolve(expandTilde(result['provisioning-profile'])),
172-
certificateFileStream = fs.createReadStream(certificateFilePath),
173-
provisioningProfileFileStream = fs.createReadStream(provisioningProfileFilePath);
174-
175-
return Package.buildIOS(dir, jar, appId, buildMode, certificateFileStream, certificatePassword, provisioningProfileFileStream)
100+
return Package.buildIOS(dir, jar, appId, argv.profile, buildMode)
176101
}
177102

178103
return Q.reject('Unrecognized platform/build mode.');
@@ -368,7 +293,7 @@ function packageDownload(ionic, argv, dir, project, appId) {
368293
}
369294

370295
console.log('Wrote:', filename);
371-
console.log('Done!'.green);
296+
console.success('Done!'.green);
372297
}, null, function(state) {
373298
if (typeof bar === 'undefined') {
374299
bar = new ProgressBar('Downloading... [:bar] :percent :etas', {

lib/tasks/cliTasks.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,7 @@ var TASKS = [
331331
},
332332
options: {
333333
'--release': '(' + 'build <platform>'.yellow + ') Mark this build as a release',
334-
'--keystore|-s <path>': '(' + 'build android --release'.yellow + ') Specify the location of your keystore file',
335-
'--keystore-password|-p <password>': '(' + 'build android --release'.yellow + ') Specify your keystore password (exclude for prompt)',
336-
'--key-alias|-k <alias>': '(' + 'build android --release'.yellow + ') Specify your key alias for this app',
337-
'--key-password|-w <password>': '(' + 'build android --release'.yellow + ') Specify your key password for this app (exclude for prompt)',
338-
'--cert|-c <path>': '(' + 'build ios [--release]'.yellow + ') Specify the location of your .p12 file',
339-
'--cert-password|-p <password>': '(' + 'build ios [--release]'.yellow + ') Specify your certificate password (exclude for prompt)',
340-
'--provisioning-profile|-r <path>': '(' + 'build ios [--release]'.yellow + ') Specify the location of your .mobileprovision file',
334+
'--profile|-p <tag>': '(' + 'build <platform>'.yellow + ') Specify the Security Profile to use with this build',
341335
'--destination|-d <path>': '(' + 'download'.yellow + ') Specify the destination directory to download your packaged app.'
342336
},
343337
module: './ionic/package'

0 commit comments

Comments
 (0)