Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
gulp config --setVersion/setBuild/setBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Grupp committed Nov 6, 2014
1 parent bcd2d3f commit 3d930e1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ cordova build/run
# also injects appropriate cordova.js
```

**gulp config** - manage project configuration
```
gulp config --setVersion=1.1.0 --setBuild=12 --setBundle=com.new.bundle
```

## sub-generators
```
yo m:controller <name>
Expand Down
35 changes: 35 additions & 0 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

var minimist = require('minimist');
var fs = require('fs');
var xml2js = require('xml2js');

// options
var options = minimist(process.argv.slice(2));
Expand Down Expand Up @@ -190,6 +193,7 @@ gulp.task('build', ['jshint', 'jscs', 'app', 'images'], function () {
return gulp.src(options.distPath + '/**/*').pipe($.size({title: 'build', gzip: true}));
});
// CORDOVA
// TODO: find better solution for cordova CLI integration
gulp.task('default', function () {
if (options.cordovaBuild) {
Expand All @@ -213,3 +217,34 @@ gulp.task('cordova-build', ['build'], function () {
'node_modules/cordova/bin/cordova ' + options.cordova
]));
});

// CONFIG for project
gulp.task('config', function () {
var parser = new xml2js.Parser();
var builder = new xml2js.Builder({
renderOp: {
pretty: true,
indent: ' '
},
xmldec: {
version: '1.0',
encoding: 'utf-8'
}
});
var xmlFile = fs.readFileSync(__dirname + '/config.xml');
parser.parseString(xmlFile, function (err, result) {
// actual processing
if (options.setVersion) {
result.widget.$.version = options.setVersion;
}
if (options.setBuild) {
result.widget.$.version = result.widget.$.version + '.' + options.setBuild;
}
if (options.setBundle) {
result.widget.$.id = options.setBundle;
}

var xml = builder.buildObject(result);
fs.writeFileSync(__dirname + '/config.xml', xml);
});
});
7 changes: 4 additions & 3 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"gulp-livereload": "^2.0.0",
"gulp-load-plugins": "^0.5.0",
"gulp-ng-annotate": "^0.3.3",<% if (answers.includeSass) { %>
"gulp-ruby-sass": "^0.5.0",
"gulp-plumber": "^0.6.3",<% } %>
"gulp-plumber": "^0.6.3",
"gulp-ruby-sass": "^0.5.0",<% } %>
"gulp-shell": "^0.2.9",
"gulp-size": "^0.4.0",
"gulp-uglify": "^0.3.0",
Expand All @@ -35,6 +35,7 @@
"opn": "^0.1.1",
"serve-index": "^1.1.4",
"serve-static": "^1.4.0",
"wiredep": "^1.4.3"
"wiredep": "^1.4.3",
"xml2js": "^0.4.4"
}
}

0 comments on commit 3d930e1

Please sign in to comment.