Skip to content

Commit

Permalink
Adds cca cli supports Fixes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
csantanapr committed Jan 28, 2015
1 parent 1680b3e commit b9aa55a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 21 deletions.
10 changes: 9 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module.exports = function (grunt) {
},
cordovacli: {
options: {
path: 'myHybridAppFolder'
path: 'myHybridAppFolder',
cli: 'cordova'
},
cordova: {
options: {
Expand Down Expand Up @@ -67,6 +68,13 @@ module.exports = function (grunt) {
platforms: ['ios', 'android'] //valid platforms for command platform are ios, android, blackberry10, wp8, wp7
}
},
add_platforms_android: {
options: {
command: 'platform',
action: 'add', //valid actions for command platform are add , remove, rm
platforms: ['android'] //valid platforms for command platform are ios, android, blackberry10, wp8, wp7
}
},
add_platforms_ios: {
options: {
command: 'platform',
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# grunt-cordovacli [![Build Status](https://secure.travis-ci.org/csantanapr/grunt-cordovacli.png?branch=master)](https://travis-ci.org/csantanapr/grunt-cordovacli)

> "Wraps a web application as a hybrid app with [Apache Cordova CLI](http://cordova.io)"
More information about the new [Apache Cordova Command-line Interface](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface)
> "Wraps a web application as a hybrid app with [Apache Cordova CLI](http://cordova.io) or [Crome Cordova Apps CLI](https://github.com/MobileChromeApps/mobile-chrome-apps)"
More information about [Apache Cordova Command-line Interface](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface)
More information about [Chrome Apps for Mobile](https://github.com/MobileChromeApps/mobile-chrome-apps)

## Getting Started
This plugin requires Grunt `^0.4.5`
NPM module cordova-cli needs to be install locally or globally
NPM module `cordova-cli` or `cca` needs to be install locally or globally

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Expand All @@ -34,6 +34,7 @@ In your project's Gruntfile, add a section named `cordovacli` to the data object
cordovacli: {
options: {
path: 'myHybridAppFolder'
cli: 'cca'
},
cordova: {
options: {
Expand Down Expand Up @@ -109,6 +110,13 @@ cordovacli: {

### Options

#### options.cli
Type: `String`
Default value: `'cordova'`
Valid values for String: `'cordova'` `'cca'`
Specify the cli to use


#### options.command
Type: `String` or `Array`
Valid values for String: `'create'` `'platform'` `'plugin'` `'build'` `'emulate'` `'prepare'` `'compile'` `'run'` `'serve'`
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-cordovacli",
"description": "Wraps a web application as a hybrid app with Apache Cordova CLI 3.x",
"version": "0.6.1",
"version": "0.7.0",
"homepage": "https://github.com/csantanapr/grunt-cordovacli",
"author": {
"name": "Carlos Santana",
Expand All @@ -28,16 +28,18 @@
"test": "grunt test"
},
"devDependencies": {
"grunt": "^0.4.5",
"cca": "^0.5.1",
"cordova": "^4.2.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-nodeunit": "^0.4.1"
},
"peerDependencies": {
"grunt": "^0.4.5",
"cordova": "^4.2.0"
"cordova": "^4.2.0",
"cca": "^0.5.1"
},
"keywords": [
"gruntplugin",
Expand Down
46 changes: 33 additions & 13 deletions tasks/cordovacli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ module.exports = function (grunt) {
runPlugin,
isPlatformExists,
isPluginExists,
cordova_path = path.dirname(require.resolve('cordova')),
cordova_json = path.join(cordova_path,'package.json'),
cordova_pkg = grunt.file.readJSON(cordova_json),
cordova_path,
cordova_json,
cordova_pkg,
cordova_bin,
cordova_cli,
cordova_plugins_map = {
'battery-status': 'org.apache.cordova.battery-status',
'camera': 'org.apache.cordova.camera',
Expand Down Expand Up @@ -63,7 +65,7 @@ module.exports = function (grunt) {
runCordova = function (args, opts, done) {
var cordova_cli, spawn_cmd;

cordova_cli = path.join(cordova_path, cordova_pkg.bin.cordova);
cordova_cli = path.join(cordova_path, cordova_bin);
opts.stdio = 'inherit';
spawn_cmd = {
"cmd": cordova_cli,
Expand Down Expand Up @@ -167,7 +169,12 @@ module.exports = function (grunt) {
tasks.push(f);
}
});
runCordovaParallel(tasks, done);
if ( cordova_cli === 'cca'){
runCordovaSeries(tasks, done);
} else {
runCordovaParallel(tasks, done);
}

};

isPluginExists = function(p, cordovaRootPath) {
Expand Down Expand Up @@ -239,20 +246,33 @@ module.exports = function (grunt) {
grunt.registerMultiTask('cordovacli', '"Wraps a web application as a hybrid app with Cordova CLI"', function () {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
path: 'HelloCordova',
name: 'HelloCordova',
id: 'io.cordova.hellocordova',
args: []

}),
path: 'HelloCordova',
name: 'HelloCordova',
id: 'io.cordova.hellocordova',
cli: 'cordova',
args: []
}),
done = this.async(),
msg = '',
args = [],
cmd_opts = {},
tasks = [],
i;
i,
cordova_relative_path;
cordova_cli = options.cli

if ( cordova_cli === 'cca'){
cordova_relative_path = '..';
} else {
cordova_relative_path = '';
}

cordova_path = path.join(path.dirname(require.resolve(options.cli)),cordova_relative_path);
cordova_json = path.join(cordova_path,'package.json');
cordova_pkg = grunt.file.readJSON(cordova_json);
cordova_bin = cordova_pkg.bin[Object.keys(cordova_pkg.bin)[0]];

grunt.log.writeln('Using cordova CLI version (' + cordova_pkg.version + ') ');
grunt.log.writeln('Using '+cordova_cli+' CLI version (' + cordova_pkg.version + ') ');

if (grunt.util.kindOf(options.command) === 'array'){
// full cordova lifecycle
Expand Down

0 comments on commit b9aa55a

Please sign in to comment.