Skip to content

Commit

Permalink
use configurated platform as default platform, ios still fallback
Browse files Browse the repository at this point in the history
Closes poetic#166
  • Loading branch information
Duke committed Aug 17, 2015
1 parent 69d2791 commit 1ce3670
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
5 changes: 3 additions & 2 deletions blueprints/cordova-init/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var projectWithConfig = require('../../lib/models/project-with-config');
var Promise = require('../../lib/ext/promise');
var stringUtils = require('../../lib/utils/string');
var defaultPlatform = require('../../lib/utils/default-platform');

module.exports = {
locals: function(options) {
Expand All @@ -13,8 +14,8 @@ module.exports = {
},

afterInstall: function(options) {
this.options = options.entity.options;
this.options.platform = options.platform || 'ios';
this.options = options.entity.options;
this.options.platform = options.platform || defaultPlatform(this.project);

projectWithConfig(this.project, options.entity.name);

Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Getting Started

This guide will walk you through setting up your first app with
ember-cli-cordova.
ember-cli-cordova.

## Prerequisites

Expand All @@ -22,9 +22,9 @@ After that's set up, we need to add the ember-cli-cordova addon to the applicati
npm install --save-dev ember-cli-cordova
```

Ember cli-cordova requires cordova. If you don't have cordova, use this line to install it.
Ember cli-cordova requires cordova. If you don't have cordova, use this line to install it.

```
```
npm install -g cordova
```

Expand All @@ -33,7 +33,7 @@ ember-cli-cordova. You pass in the com domain identifier that you want to use
with your app. It can be anything you like as long as it's unique. This matters
if you plan on releasing it to the app stores. It takes an optional `platform`
argument that defaults to `ios`. If you want to generate an android project you
would pass in `--platform=android` at the end.
would pass in `--platform=android` at the end or set your default platform in [cordova configuration](https://github.com/poetic/ember-cli-cordova/blob/master/docs/configuration.md).

```sh
ember generate cordova-init com.poeticsystems.hello
Expand Down
10 changes: 6 additions & 4 deletions lib/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

var path = require('path');
var chalk = require('chalk');
var path = require('path');
var chalk = require('chalk');
var defaultPlatform = require('../utils/default-platform');

module.exports = {
name: 'cordova:build',
Expand All @@ -11,10 +12,11 @@ module.exports = {

availableOptions: [
{ name: 'environment', type: String, default: 'development' },
{ name: 'platform', type: String, default: 'ios' }
{ name: 'platform', type: String }
],

run: function(options) {
return require('../tasks/build')(options.environment, options.platform, this.project)();
var platform = options.platform || defaultPlatform(this.project);
return require('../tasks/build')(options.environment, platform, this.project)();
}
};
8 changes: 5 additions & 3 deletions lib/commands/open.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var path = require('path');
var path = require('path');
var defaultPlatform = require('../utils/default-platform');

module.exports = {
name: 'cordova:open',
Expand All @@ -9,11 +10,12 @@ module.exports = {
works: 'insideProject',

availableOptions: [
{ name: 'platform', type: String, default: 'ios' },
{ name: 'platform', type: String },
{ name: 'application', type: String}
],

run: function(options) {
return require('../tasks/open')(this.project, options.platform, options.application)();
var platform = options.platform || defaultPlatform(this.project);
return require('../tasks/open')(this.project, platform, options.application)();
}
};
4 changes: 2 additions & 2 deletions lib/tasks/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var path = require('path');
var runCommand = require('../utils/run-command');
var Promise = require('../ext/promise');
var defaultPlatform = require('../utils/default-platform');

module.exports = function(version, options, project) {
var config = project.cordovaConfig;
Expand All @@ -13,10 +14,9 @@ module.exports = function(version, options, project) {
updateXml = require('./update-config-xml-version')(version, project);
}

var platform = options.platform || 'ios';
var platform = options.platform || defaultPlatform(project);
var build = require('./build')(options.environment, platform, project);


if(platform === 'ios') {
var iosPath = path.join(project.root, 'cordova', 'platforms/ios');
var archiveCommand = 'xcodebuild -scheme ' + config.name + ' archive';
Expand Down
15 changes: 8 additions & 7 deletions lib/tasks/post-build.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

var runCommand = require('../utils/run-command');
var path = require('path');
var chalk = require('chalk');
var ui = require('../ui');
var Promise = require('../ext/promise');
var runCommand = require('../utils/run-command');
var defaultPlatform = require('../utils/default-platform');
var path = require('path');
var chalk = require('chalk');
var ui = require('../ui');
var Promise = require('../ext/promise');

function createCommand(project, options) {
var platform = options.platform || 'ios';
var command = 'cordova build ' + platform;
var platform = options.platform || defaultPlatform(this.project);
var command = 'cordova build ' + platform;

if (options.emulate) {
command += ' && cordova emulate ' + platform;
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/default-platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function defaultPlatform(project) {
var config = project.config().cordova || {}
return config.platform || 'ios';
}

0 comments on commit 1ce3670

Please sign in to comment.