Skip to content

Commit bab72dd

Browse files
committed
Merge pull request #13 from infomofo/grunt-cordovacli
#11: add the use of grunt-cordovacli
2 parents 1039a22 + d239fa4 commit bab72dd

File tree

3 files changed

+68
-54
lines changed

3 files changed

+68
-54
lines changed

Gruntfile.js

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module.exports = function (grunt) {
2020
app: require('./bower.json').appPath || 'app',
2121
dist: 'dist',
2222
cordova: 'cordova',
23-
appName: 'YoAngularCordova'
23+
appName: 'YoAngularCordova',
24+
appPackage: 'com.sample.YoAngularCordova'
2425
};
2526

2627
// Define the configuration for all the tasks
@@ -369,61 +370,76 @@ module.exports = function (grunt) {
369370
singleRun: true
370371
}
371372
},
372-
373-
shell: {
374-
cordovaClean: {
375-
command: 'rm -Rf <%= yeoman.cordova %>'
373+
cordovacli: {
374+
options: {
375+
path: '<%= yeoman.cordova %>',
376+
id: '<%= yeoman.appPackage %>',
377+
name: '<%= yeoman.appName %>',
378+
platforms: ['ios', 'android']
376379
},
377-
cordovaCreate: {
378-
command: 'cordova create <%= yeoman.cordova %> com.sample.<%= yeoman.appName %> "<%= yeoman.appName %>" --copy-from=<%= yeoman.dist %>'
380+
cordova: {
381+
options: {
382+
command: ['create','platform','plugin','build'],
383+
}
379384
},
380-
cordovaPrepare: {
381-
command: 'cordova prepare',
382-
options: {
383-
stderr: false,
384-
execOptions: {
385-
cwd: '<%= yeoman.cordova %>'
386-
}
387-
}
385+
create: {
386+
options: {
387+
command: 'create',
388+
args: ['--copy-from=<%= yeoman.dist %>']
389+
}
388390
},
389-
cordovaInstallPlugins: {
390-
command: 'cordova plugin add https://github.com/j-mcnally/cordova-statusTap',
391+
addPlatforms: {
391392
options: {
392-
stderr: false,
393-
execOptions: {
394-
cwd: '<%= yeoman.cordova %>'
395-
}
393+
command: 'platform',
394+
action: 'add'
396395
}
397396
},
398-
cordovaPlatformInstallAndroid: {
399-
command: 'cordova platform add android',
400-
options: {
401-
stderr: false,
402-
execOptions: {
403-
cwd: '<%= yeoman.cordova %>'
404-
}
405-
}
397+
addPlugins: {
398+
options: {
399+
command: 'plugin',
400+
action: 'add',
401+
plugins: [
402+
'https://github.com/j-mcnally/cordova-statusTap'
403+
]
404+
}
406405
},
407-
cordovaPlatformInstallIos: {
408-
command: 'cordova platform add ios',
406+
build: {
409407
options: {
410-
stderr: false,
411-
execOptions: {
412-
cwd: '<%= yeoman.cordova %>'
413-
}
408+
command: 'build'
414409
}
415410
},
416-
cordovaBuild: {
417-
command: 'cordova build',
411+
emulateAndroid: {
418412
options: {
419-
stderr: false,
420-
execOptions: {
421-
cwd: '<%= yeoman.cordova %>'
422-
}
413+
command: 'emulate',
414+
platforms: ['android']
415+
}
416+
},
417+
emulateIos: {
418+
options: {
419+
command: 'emulate',
420+
platforms: ['ios']
423421
}
422+
},
423+
runAndroid: {
424+
options: {
425+
command: 'run',
426+
platforms: ['android']
427+
}
428+
},
429+
runIos: {
430+
options: {
431+
command: 'run',
432+
platforms: ['ios']
433+
}
434+
}
435+
},
436+
shell: {
437+
cordovaClean: {
438+
command: 'rm -Rf <%= yeoman.cordova %>'
424439
}
425440
}
426441
});
442+
grunt.loadNpmTasks('grunt-cordovacli');
427443

428444
//var xpath = require('xpath');
429445
var DOMParser = require('xmldom').DOMParser;
@@ -530,11 +546,10 @@ module.exports = function (grunt) {
530546
[
531547
'build',
532548
'shell:cordovaClean',
533-
'shell:cordovaCreate',
549+
'cordovacli:create',
534550
'addCordovaPreferences',
535-
'shell:cordovaPlatformInstallAndroid',
536-
'shell:cordovaPlatformInstallIos',
537-
'shell:cordovaInstallPlugins',
538-
'shell:cordovaBuild'
551+
'cordovacli:addPlatforms',
552+
'cordovacli:addPlugins',
553+
'cordovacli:build'
539554
]);
540555
};

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,22 @@ To build a cordova app
2525
---------------------
2626

2727
1. npm install
28-
2. bower install
29-
3. grunt cordova
28+
2. grunt
3029

3130
To run on android
3231
-----------------
3332

34-
1. cd cordova
35-
2. cordova run android
33+
grunt cordovacli:runAndroid
3634

3735
To emulate on ios
3836
-----------------
3937

40-
1. cd cordova
41-
2. cordova emulate ios
38+
grunt cordovacli:emulateIos
4239

4340
To run on ios
4441
-------------
4542

46-
1. cd cordova
47-
2. cordova run ios
43+
grunt cordovacli:runIos
4844

4945
Directory Structure
5046
-------------------

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "0.0.0",
44
"dependencies": {},
55
"devDependencies": {
6+
"cca": "^0.5.1",
7+
"cordova": "^4.2.0",
68
"grunt": "^0.4.1",
79
"grunt-autoprefixer": "^0.7.3",
810
"grunt-bower-task": "^0.4.0",
@@ -17,6 +19,7 @@
1719
"grunt-contrib-jshint": "^0.10.0",
1820
"grunt-contrib-uglify": "^0.4.0",
1921
"grunt-contrib-watch": "^0.6.1",
22+
"grunt-cordovacli": "^0.7.0",
2023
"grunt-filerev": "^0.2.1",
2124
"grunt-google-cdn": "^0.4.0",
2225
"grunt-karma": "^0.9.0",

0 commit comments

Comments
 (0)