Skip to content

Commit

Permalink
Take options from cli, including option to not run resources during p…
Browse files Browse the repository at this point in the history
…ackage
  • Loading branch information
imhoffd committed Feb 1, 2016
1 parent 90b511d commit 7b69fd6
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -204,18 +204,22 @@ 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') {
return Q.reject(err);
}
})
.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(),
Expand Down Expand Up @@ -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,
Expand All @@ -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;
});
};

Expand Down

0 comments on commit 7b69fd6

Please sign in to comment.