ember-cli-cordova
Advanced tools
Comparing version 0.0.7 to 0.0.9
@@ -5,2 +5,3 @@ /* jshint node: true */ | ||
var ENV = { | ||
modulePrefix: '<%= modulePrefix %>', | ||
environment: environment, | ||
@@ -22,4 +23,3 @@ baseURL: '/', | ||
cordova: { | ||
rebuildOnChange: false, | ||
rebuildAsync: false, | ||
rebuildOnChange: true, | ||
emulate: false | ||
@@ -38,3 +38,11 @@ } | ||
if (environment === 'test') { | ||
// Testem prefers this... | ||
ENV.baseURL = '/'; | ||
ENV.locationType = 'auto'; | ||
// keep test console output quieter | ||
ENV.APP.LOG_ACTIVE_GENERATION = false; | ||
ENV.APP.LOG_VIEW_LOOKUPS = false; | ||
ENV.APP.rootElement = '#ember-testing'; | ||
} | ||
@@ -41,0 +49,0 @@ |
@@ -6,6 +6,6 @@ var projectWithConfig = require('../../lib/models/project-with-config'); | ||
afterInstall: function(options) { | ||
options.entity.platform = options.entity.platform || 'ios'; | ||
this.options = options; | ||
this.options = options.entity.options; | ||
this.options.platform = this.options.platform || 'ios'; | ||
projectWithConfig(this.project, this.options.entity.name); | ||
projectWithConfig(this.project, options.entity.name); | ||
@@ -25,3 +25,3 @@ var setup = this.setupEmber().then(this.setupCordova.bind(this)); | ||
var createProject = require('../../lib/tasks/create-cordova-project')(this.project); | ||
var addPlatforms = require('../../lib/tasks/add-platforms')(this.project, this.options.entity); | ||
var addPlatforms = require('../../lib/tasks/add-platforms')(this.project, this.options); | ||
var updateConfig = require('../../lib/tasks/update-config-xml')(this.project); | ||
@@ -28,0 +28,0 @@ var linkEnvironment = require('../../lib/tasks/link-environment')(this.project); |
import DS from 'ember-data'; | ||
import config from '../config/environment'; | ||
var ENV = <%= namespace %>ENV; | ||
export default DS.ActiveModelAdapter.extend({ | ||
host: ENV.apiUrl | ||
host: config.apiUrl | ||
}); |
@@ -6,4 +6,3 @@ import Ember from 'ember'; | ||
back: function() { | ||
Ember.AnimatedContainerView.enqueueAnimations({main: 'slideRight'}); | ||
history.go(-1); | ||
history.back(); | ||
}, | ||
@@ -10,0 +9,0 @@ |
/* jshint node: true */ | ||
var os = require('os'); | ||
var ifaces = os.networkInterfaces(); | ||
var addresses = []; | ||
for (var dev in ifaces) { | ||
ifaces[dev].forEach(function(details){ | ||
if(details.family === 'IPv4' && details.address !== '127.0.0.1') { | ||
addresses.push(details.address); | ||
} | ||
}); | ||
} | ||
module.exports = function(environment) { | ||
var ENV = { | ||
modulePrefix: '<%= modulePrefix %>', | ||
environment: environment, | ||
@@ -21,4 +34,3 @@ baseURL: '/', | ||
cordova: { | ||
rebuildOnChange: false, | ||
rebuildAsync: false, | ||
rebuildOnChange: true, | ||
emulate: false | ||
@@ -35,3 +47,3 @@ } | ||
ENV.apiUrl = 'http://localhost:3000/api/v1'; | ||
ENV.apiUrl = 'http://' + addresses[0] + ':3000/api/v1'; | ||
ENV.development = true; | ||
@@ -41,3 +53,11 @@ } | ||
if (environment === 'test') { | ||
// Testem prefers this... | ||
ENV.baseURL = '/'; | ||
ENV.locationType = 'auto'; | ||
// keep test console output quieter | ||
ENV.APP.LOG_ACTIVE_GENERATION = false; | ||
ENV.APP.LOG_VIEW_LOOKUPS = false; | ||
ENV.APP.rootElement = '#ember-testing'; | ||
} | ||
@@ -44,0 +64,0 @@ |
@@ -1,3 +0,6 @@ | ||
var Promise = require('../../lib/ext/promise'); | ||
var path = require('path'); | ||
var chalk = require('chalk'); | ||
var Promise = require('../../lib/ext/promise'); | ||
var stringUtils = require('../../lib/utils/string'); | ||
var runCommand = require('../../lib/utils/run-command'); | ||
@@ -19,8 +22,32 @@ module.exports = { | ||
afterInstall: function(options) { | ||
addPluginToProject: function(name) { | ||
var ui = this.ui; | ||
return runCommand('cordova plugin add ' + name, null, { | ||
cwd: path.join(this.project.root, 'cordova') | ||
})().then(function() { | ||
if (ui) { | ||
ui.writeLine(' ' + chalk.green('install plugin') + ' ' + name); | ||
} | ||
}); | ||
}, | ||
// TODO: this should be cleaned up. I needs to run in series though | ||
addPlugins: function() { | ||
return this.addPluginToProject('org.apache.cordova.file-transfer').then(function() { | ||
this.addPluginToProject('org.apache.cordova.file'); | ||
}.bind(this)).then(function() { | ||
this.addPluginToProject('https://github.com/MobileChromeApps/zip.git'); | ||
}.bind(this)).then(function() { | ||
this.addPluginToProject('https://github.com/floatinghotpot/cordova-httpd.git'); | ||
}.bind(this)); | ||
}, | ||
afterInstall: function() { | ||
return Promise.all([ | ||
this.addPackageToProject('broccoli-sass'), | ||
this.addPackageToProject('ember-animated-outlet-mobile'), | ||
this.addPackageToProject('liquid-fire'), | ||
this.addPlugins() | ||
]); | ||
} | ||
}; |
55
index.js
@@ -7,32 +7,37 @@ 'use strict'; | ||
function EmberCLICordova(project) { | ||
this.project = project; | ||
this.name = 'Ember CLI Cordova'; | ||
this.setConfig(); | ||
} | ||
module.exports = { | ||
name: 'ember-cli-cordova', | ||
EmberCLICordova.prototype.blueprintsPath = function() { | ||
return path.join(__dirname, 'blueprints'); | ||
} | ||
treePaths: { | ||
app: 'app', | ||
styles: 'app/styles', | ||
templates: 'app/templates', | ||
addon: 'addon', | ||
'addon-styles': 'addon/styles', | ||
'addon-templates': 'addon/templates', | ||
vendor: 'vendor', | ||
'test-support': 'test-support', | ||
'public': 'public' | ||
}, | ||
EmberCLICordova.prototype.includedCommands = function() { | ||
return commands; | ||
} | ||
blueprintsPath: function() { | ||
return path.join(__dirname, 'blueprints'); | ||
}, | ||
EmberCLICordova.prototype.setConfig = function(){ | ||
var env = this.project.config('development'); | ||
includedCommands: function() { | ||
return commands; | ||
}, | ||
if(!this.config) { | ||
this.config = {}; | ||
} | ||
cdvConfig: function() { | ||
var config = this.project.config('development'); | ||
if (config.cordova) { | ||
return config.cordova | ||
} | ||
if (env.cordova) { | ||
this.config = env.cordova; | ||
return {}; | ||
}, | ||
postBuild: function() { | ||
return postBuild(this.project, this.cdvConfig())(); | ||
} | ||
} | ||
EmberCLICordova.prototype.postBuild = function() { | ||
return postBuild(this.project, this.config)(); | ||
} | ||
module.exports = EmberCLICordova; | ||
}; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var idRegex = /id=\"([\w\.]+)\"/; | ||
var idRegex = /id=\"([\w\-\.]+)\"/; | ||
var matches = configFile.match(idRegex); | ||
@@ -16,0 +16,0 @@ |
@@ -7,3 +7,2 @@ 'use strict'; | ||
module.exports = function(project, options) { | ||
var command = 'cordova platforms add ' + options.platform; | ||
@@ -10,0 +9,0 @@ |
@@ -9,3 +9,2 @@ 'use strict'; | ||
var chalk = require('chalk'); | ||
var ui = require('../ui'); | ||
var verifyDist = require('./verify-dist'); | ||
@@ -18,8 +17,11 @@ | ||
var emberPath = path.join(project.root, 'dist'); | ||
var wwwPath = path.join(project.root, 'cordova', 'www'); | ||
var cordovaPath = path.join(project.root, 'cordova'); | ||
var wwwPath = path.join(cordovaPath, 'www'); | ||
return function() { | ||
// allows us to do a relative symlink | ||
process.chdir(cordovaPath); | ||
return remove(wwwPath) | ||
.then(symlink.bind(this, emberPath, wwwPath, 'dir')) | ||
.then(symlink.bind(this, '../dist', 'www', 'dir')) | ||
.then(verifyDist(project)); | ||
@@ -26,0 +28,0 @@ }; |
@@ -22,4 +22,3 @@ 'use strict'; | ||
ui.write('\n'); | ||
ui.pleasantProgress.start(chalk.green(message)); | ||
ui.start(chalk.green(message)); | ||
@@ -26,0 +25,0 @@ var xml = fs.readFileSync(configPath, { encoding: 'utf8' }); |
@@ -17,5 +17,3 @@ 'use strict'; | ||
var msg = options.rebuildAsync ? null : 'Rebuilding cordova project'; | ||
return runCommand(command, msg, { | ||
return runCommand(command, null, { | ||
cwd: path.join(project.root, 'cordova') | ||
@@ -33,12 +31,8 @@ }); | ||
if (options.rebuildAsync) { | ||
rebuild.then(function() { | ||
ui.write(chalk.green('Cordova build successful.\n')); | ||
}); | ||
rebuild.then(function() { | ||
ui.write(chalk.green('Cordova build successful.\n')); | ||
}); | ||
return Promise.resolve(); | ||
} | ||
return rebuild; | ||
return Promise.resolve(); | ||
} | ||
}; |
@@ -21,4 +21,3 @@ 'use strict'; | ||
ui.write('\n'); | ||
ui.pleasantProgress.start(chalk.green(message)); | ||
ui.start(chalk.green(message)); | ||
@@ -25,0 +24,0 @@ var file = fs.readFileSync(indexPath, { encoding: 'utf8' }); |
'use strict'; | ||
var PleasantProgress = require('./internals/pleasant-progress'); | ||
var PleasantProgress = require('pleasant-progress'); | ||
module.exports = { | ||
pleasantProgress: new PleasantProgress(), | ||
write: function() { | ||
start: function(msg) { | ||
this.pleasantProgress.stop(true); | ||
process.stdout.write.apply(process.stdout, arguments) | ||
this.pleasantProgress.start(msg) | ||
}, | ||
write: function(msg) { | ||
this.pleasantProgress.stream.write(msg); | ||
} | ||
}; |
@@ -16,4 +16,3 @@ 'use strict'; | ||
if(startedMsg) { | ||
ui.write('\n'); | ||
ui.pleasantProgress.start(chalk.green(startedMsg)); | ||
ui.start(chalk.green(startedMsg)); | ||
} | ||
@@ -25,8 +24,10 @@ | ||
return exec(command, options).catch(error); | ||
return exec(command, options).catch(function(err){ | ||
commandError(command, err); | ||
}); | ||
}; | ||
}; | ||
function error(err) { | ||
ui.write(chalk.red('\nError thrown while running shell command\n\n')); | ||
function commandError(command, err) { | ||
ui.write(chalk.red('\nError thrown while running shell command: "' + command + '"\n')); | ||
if(err.stack) { | ||
@@ -33,0 +34,0 @@ ui.write(err.stack); |
{ | ||
"name": "ember-cli-cordova", | ||
"version": "0.0.7", | ||
"version": "0.0.9", | ||
"description": "A tool for creating hybrid apps using a combination of ember-cli and cordova ", | ||
@@ -22,8 +22,9 @@ "homepage": "https://github.com/poetic/ember-cli-cordova", | ||
"dependencies": { | ||
"chalk": "^0.4.0", | ||
"findup-sync": "^0.1.3", | ||
"fs-extra": "^0.8.1", | ||
"chalk": "^0.4.0", | ||
"lodash": "^2.4.1", | ||
"findup-sync": "^0.1.3", | ||
"pleasant-progress": "^1.0.1", | ||
"recursive-readdir": "^1.1.1", | ||
"rsvp": "^3.0.6", | ||
"recursive-readdir": "^1.1.1", | ||
"underscore.string": "^2.3.3" | ||
@@ -30,0 +31,0 @@ }, |
# ember-cli-cordova [![Build Status](https://travis-ci.org/poetic/ember-cli-cordova.svg?branch=master)](https://travis-ci.org/poetic/ember-cli-cordova) | ||
*requires ember-cli >= 0.0.40* | ||
*requires latest ember-cli* | ||
I will not be focusing on backward compatibility with older ember-cli versions | ||
as it's moving too fast and the API is constantly changing. I will always have | ||
this working with the latest stable release of ember-cli though. | ||
@@ -66,7 +69,17 @@ ## Goals | ||
### Running in the simulator | ||
*with starter kit* | ||
Livereload is baked in by default. After the starter kit generator has run, | ||
simply run `ember serve --proxy http://your-local-ip:4300` and then `ember | ||
cordova emulate platform`(in another tab/split) to start up the app in the | ||
emulator. To find your local ip, reference [this LifeHacker | ||
article](http://lifehacker.com/5833108/how-to-find-your-local-and-external-ip-address) | ||
*without starter kit* | ||
If you do not have rebuildOnChange enabled(described in the configuration | ||
section), after making a change to the ember app, you must run `ember | ||
cordova:build` to update the build to contain those changes. You can then | ||
relaunch the app by building inside of xcode/eclipse or running `cordova emulate | ||
<platform>` | ||
relaunch the app by building inside of xcode/eclipse or running `ember cordova | ||
emulate <platform>` | ||
@@ -88,7 +101,2 @@ ### Configuration | ||
// Don't block the server during the rebuild | ||
// | ||
// default: false | ||
rebuildAsync: true, | ||
// Run the cordova emulate command after the build is finished | ||
@@ -124,3 +132,3 @@ // | ||
+ [cordova](http://cordova.apache.org/docs/en/3.4.0/) | ||
+ [ember-animated-outlet](https://github.com/billysbilling/ember-animated-outlet) | ||
+ [liquid-fire](https://github.com/ef4/liquid-fire) | ||
+ [moment.js](http://momentjs.com/docs/) | ||
@@ -127,0 +135,0 @@ |
Sorry, the diff of this file is not supported yet
44914
77
923
182
8
+ Addedpleasant-progress@^1.0.1
+ Addedpleasant-progress@1.1.0(transitive)