From 7b69fd64a67df0d2e06358cde1be56925f27511f Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Mon, 1 Feb 2016 16:39:42 -0600 Subject: [PATCH] Take options from cli, including option to not run resources during package --- lib/package.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/package.js b/lib/package.js index e4515fd..d931482 100644 --- a/lib/package.js +++ b/lib/package.js @@ -36,25 +36,25 @@ events.on('package-start', function() { }); -Package.buildAndroidDebug = function(appDirectory, jar, appId) { +Package.buildAndroidDebug = function(appDirectory, jar, appId, options) { return build(appDirectory, jar, appId, undefined, { platform: 'android', build_mode: 'debug' - }); + }, options); }; -Package.buildAndroidRelease = function(appDirectory, jar, appId, profile) { +Package.buildAndroidRelease = function(appDirectory, jar, appId, profile, options) { return build(appDirectory, jar, appId, profile, { platform: 'android', build_mode: 'release' - }); + }, options); }; -Package.buildIOS = function(appDirectory, jar, appId, profile, buildMode) { +Package.buildIOS = function(appDirectory, jar, appId, profile, buildMode, options) { return build(appDirectory, jar, appId, profile, { platform: 'ios', build_mode: buildMode - }); + }, options); }; Package.listBuilds = function(appId, jar) { @@ -167,7 +167,7 @@ Package.determineFileExtensionByPlatform = function(platform) { throw new Error('Unknown platform: ' + platform); } -function build(appDirectory, jar, appId, profileTag, formDataExtra) { +function build(appDirectory, jar, appId, profileTag, formDataExtra, options) { events.emit('package-start'); var uploadUrl, @@ -204,7 +204,9 @@ function build(appDirectory, jar, appId, profileTag, formDataExtra) { uploadUrl = upload.url; }) .then(function(url) { - return IonicResources.generate(appDirectory, { default: true, platforms: ['all'] }); + if (typeof options.noresources === 'undefined') { + return IonicResources.generate(appDirectory, { default: true, platforms: ['all'] }); + } }) .then(null, function(err) { if (err !== 'RESOURCES_EXISTS') { @@ -212,10 +214,12 @@ function build(appDirectory, jar, appId, profileTag, formDataExtra) { } }) .then(function(url) { - events.emit('package-post-default-resources'); - logging.logger.info('Preparing your resources...'); - events.emit('package-pre-prepare-resources'); - return IonicResources.generate(appDirectory, { platforms: ['all'] }); + if (typeof options.noresources === 'undefined') { + events.emit('package-post-default-resources'); + logging.logger.info('Preparing your resources...'); + events.emit('package-pre-prepare-resources'); + return IonicResources.generate(appDirectory, { platforms: ['all'] }); + } }) .then(function() { var q = Q.defer(), @@ -280,7 +284,7 @@ function build(appDirectory, jar, appId, profileTag, formDataExtra) { .then(function(body) { projectZipId = body.data.id; - logging.logger.info("Uploading your resources to Ionic..."); + logging.logger.info("Uploading your project to Ionic..."); return uploadProjectZip( body.data.presigned_post.url, @@ -304,14 +308,16 @@ function build(appDirectory, jar, appId, profileTag, formDataExtra) { return sendToPackageService(appId, jar, _.extend(formData, formDataExtra)); }) .then(function(body) { + var buildId = body.data.id; + events.emit('package-post-submit'); logging.logger.info("Your app has been successfully submitted to Ionic Package!".green); - logging.logger.info('Build ID:', body.data.id); + logging.logger.info('Build ID:', buildId); logging.logger.info("We are now packaging your app."); fs.unlinkSync(projectZipPath); - return body.data.id; + return buildId; }); };