Skip to content

Commit

Permalink
feat(gen): add automatic demo releases with grunt task
Browse files Browse the repository at this point in the history
grunt demo when properly set up will generate and push a new version of fullstack demo. Also added grunt buildcontrol to the app to automate deployment to heroku.
  • Loading branch information
DaftMonk committed Aug 15, 2014
1 parent 2e1f118 commit 4485223
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
59 changes: 49 additions & 10 deletions Gruntfile.js
Expand Up @@ -5,6 +5,7 @@ var _s = require('underscore.string');
var shell = require('shelljs');
var process = require('child_process');
var Q = require('q');
var helpers = require('yeoman-generator').test;

module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
Expand Down Expand Up @@ -33,6 +34,21 @@ module.exports = function (grunt) {
files: ['CHANGELOG.md']
}
},
buildcontrol: {
options: {
dir: 'demo',
commit: true,
push: true,
connectCommits: false,
message: 'Built using Angular Fullstack v<%= pkg.version %> from commit %sourceCommit%'
},
release: {
options: {
remote: 'origin',
branch: 'master'
}
}
},
jshint: {
options: {
curly: false,
Expand All @@ -46,6 +62,7 @@ module.exports = function (grunt) {
dot: true,
src: [
'<%= config.demo %>/*',
'!<%= config.demo %>/.git',
'!<%= config.demo %>/dist'
]
}]
Expand Down Expand Up @@ -88,6 +105,7 @@ module.exports = function (grunt) {

Q()
.then(generateDemo)
.then(gruntBuild)
.then(gruntRelease)
.catch(function(msg){
grunt.fail.warn(msg || 'failed to generate demo')
Expand All @@ -96,25 +114,38 @@ module.exports = function (grunt) {

function generateDemo() {
var deferred = Q.defer();
var generator = shell.exec('yo angular-fullstack', {async:true});
var options = {
script: 'js',
markup: 'html',
stylesheet: 'sass',
router: 'uirouter',
mongoose: true,
auth: true,
oauth: ['googleAuth', 'twitterAuth'],
socketio: true
};

generator.stdout.on('data', function (data) {
if(_s.include(data, '[?]')) {
generator.stdin.write('\n');
}
grunt.verbose.writeln(data);
});
var deps = [
'../app',
[
helpers.createDummyGenerator(),
'ng-component:app'
]
];

var gen = helpers.createGenerator('angular-fullstack:app', deps);

generator.on('close', function (code) {
helpers.mockPrompt(gen, options);
gen.run({}, function () {
deferred.resolve();
});

return deferred.promise;
}

function gruntRelease() {
function run(cmd) {
var deferred = Q.defer();
var generator = shell.exec('grunt build', {async:true});
var generator = shell.exec(cmd, {async:true});
generator.stdout.on('data', function (data) {
grunt.verbose.writeln(data);
});
Expand All @@ -124,6 +155,14 @@ module.exports = function (grunt) {

return deferred.promise;
}

function gruntBuild() {
return run('grunt');
}

function gruntRelease() {
return run('grunt buildcontrol');
}
});

grunt.registerTask('demo', [
Expand Down
4 changes: 2 additions & 2 deletions app/templates/Gruntfile.js
Expand Up @@ -414,13 +414,13 @@ module.exports = function (grunt) {
dir: 'dist',
commit: true,
push: true,
connectCommits: false,
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
},
heroku: {
options: {
remote: 'heroku',
branch: 'master',
tag: '<%%= pkg.version %>'
branch: 'master'
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion app/templates/client/app/main/main(html).html
Expand Up @@ -31,7 +31,8 @@ <h1 class="page-header">Features:</h1>

<footer class="footer">
<div class="container">
<p><a href="https://twitter.com/tyhenkel">@tyhenkel</a> |
<p>Angular Fullstack v<%= pkg.version %> |
<a href="https://twitter.com/tyhenkel">@tyhenkel</a> |
<a href="https://github.com/DaftMonk/generator-angular-fullstack/issues?state=open">Issues</a></p>
</div>
</footer>
2 changes: 2 additions & 0 deletions app/templates/client/app/main/main(jade).jade
Expand Up @@ -26,6 +26,8 @@ header#banner.hero-unit
footer.footer
.container
p
| Angular Fullstack v<%= pkg.version %>
= ' | '
a(href='https://twitter.com/tyhenkel') @tyhenkel
= ' | '
a(href='https://github.com/DaftMonk/generator-angular-fullstack/issues?state=open') Issues
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -41,6 +41,7 @@
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-conventional-changelog": "~1.0.0",
"grunt-build-control": "DaftMonk/grunt-build-control",
"grunt-release": "~0.6.0",
"load-grunt-tasks": "~0.2.0",
"marked": "~0.2.8",
Expand Down

0 comments on commit 4485223

Please sign in to comment.