|
1 | 1 | var fs = require('fs'), |
2 | 2 | path = require('path'), |
3 | | - expandTilde = require('expand-tilde'), |
4 | 3 | _ = require('underscore'), |
5 | 4 | Q = require('q'), |
6 | 5 | moment = require('moment'), |
7 | | - ProgressBar = require('progress'), |
8 | 6 | IonicAppLib = require('ionic-app-lib'), |
9 | 7 | Utils = IonicAppLib.utils, |
10 | 8 | Login = IonicAppLib.login, |
11 | 9 | Package = IonicAppLib.package, |
12 | 10 | LoginTask = require('./login'), |
13 | | - Prompt = require('./prompt'), |
14 | 11 | Table = require('./table'), |
15 | 12 | Task = require('./task').Task; |
16 | 13 |
|
@@ -83,96 +80,24 @@ function packageBuild(ionic, argv, dir, project, appId) { |
83 | 80 | return jar; |
84 | 81 | }) |
85 | 82 | .then(function(j) { |
86 | | - var q = Q.defer(); |
87 | | - |
88 | 83 | jar = j; |
89 | 84 |
|
90 | 85 | if (platform === 'android') { |
91 | 86 | if (buildMode === 'debug') { |
92 | | - q.resolve({}); |
| 87 | + return Package.buildAndroidDebug(dir, jar, appId); |
93 | 88 | } 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'); |
104 | 91 | } |
105 | 92 |
|
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) |
124 | 94 | } |
125 | 95 | } 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'); |
136 | 98 | } |
137 | 99 |
|
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) |
176 | 101 | } |
177 | 102 |
|
178 | 103 | return Q.reject('Unrecognized platform/build mode.'); |
@@ -368,7 +293,7 @@ function packageDownload(ionic, argv, dir, project, appId) { |
368 | 293 | } |
369 | 294 |
|
370 | 295 | console.log('Wrote:', filename); |
371 | | - console.log('Done!'.green); |
| 296 | + console.success('Done!'.green); |
372 | 297 | }, null, function(state) { |
373 | 298 | if (typeof bar === 'undefined') { |
374 | 299 | bar = new ProgressBar('Downloading... [:bar] :percent :etas', { |
|
0 commit comments