diff --git a/Gruntfile.js b/Gruntfile.js index 50ad644..ae5974f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -31,7 +31,8 @@ module.exports = function (grunt) { }, cordovacli: { options: { - path: 'myHybridAppFolder' + path: 'myHybridAppFolder', + cli: 'cordova' }, cordova: { options: { @@ -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', diff --git a/README.md b/README.md index 15d1f6a..d82a466 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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: { @@ -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'` diff --git a/package.json b/package.json index d3788a0..88d38eb 100644 --- a/package.json +++ b/package.json @@ -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", @@ -28,8 +28,9 @@ "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", @@ -37,7 +38,8 @@ }, "peerDependencies": { "grunt": "^0.4.5", - "cordova": "^4.2.0" + "cordova": "^4.2.0", + "cca": "^0.5.1" }, "keywords": [ "gruntplugin", diff --git a/tasks/cordovacli.js b/tasks/cordovacli.js index e06d6be..272af68 100644 --- a/tasks/cordovacli.js +++ b/tasks/cordovacli.js @@ -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', @@ -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, @@ -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) { @@ -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