Skip to content

Commit 4485223

Browse files
committed
feat(gen): add automatic demo releases with grunt task
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.
1 parent 2e1f118 commit 4485223

File tree

5 files changed

+56
-13
lines changed

5 files changed

+56
-13
lines changed

Gruntfile.js

+49-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var _s = require('underscore.string');
55
var shell = require('shelljs');
66
var process = require('child_process');
77
var Q = require('q');
8+
var helpers = require('yeoman-generator').test;
89

910
module.exports = function (grunt) {
1011
require('load-grunt-tasks')(grunt);
@@ -33,6 +34,21 @@ module.exports = function (grunt) {
3334
files: ['CHANGELOG.md']
3435
}
3536
},
37+
buildcontrol: {
38+
options: {
39+
dir: 'demo',
40+
commit: true,
41+
push: true,
42+
connectCommits: false,
43+
message: 'Built using Angular Fullstack v<%= pkg.version %> from commit %sourceCommit%'
44+
},
45+
release: {
46+
options: {
47+
remote: 'origin',
48+
branch: 'master'
49+
}
50+
}
51+
},
3652
jshint: {
3753
options: {
3854
curly: false,
@@ -46,6 +62,7 @@ module.exports = function (grunt) {
4662
dot: true,
4763
src: [
4864
'<%= config.demo %>/*',
65+
'!<%= config.demo %>/.git',
4966
'!<%= config.demo %>/dist'
5067
]
5168
}]
@@ -88,6 +105,7 @@ module.exports = function (grunt) {
88105

89106
Q()
90107
.then(generateDemo)
108+
.then(gruntBuild)
91109
.then(gruntRelease)
92110
.catch(function(msg){
93111
grunt.fail.warn(msg || 'failed to generate demo')
@@ -96,25 +114,38 @@ module.exports = function (grunt) {
96114

97115
function generateDemo() {
98116
var deferred = Q.defer();
99-
var generator = shell.exec('yo angular-fullstack', {async:true});
117+
var options = {
118+
script: 'js',
119+
markup: 'html',
120+
stylesheet: 'sass',
121+
router: 'uirouter',
122+
mongoose: true,
123+
auth: true,
124+
oauth: ['googleAuth', 'twitterAuth'],
125+
socketio: true
126+
};
100127

101-
generator.stdout.on('data', function (data) {
102-
if(_s.include(data, '[?]')) {
103-
generator.stdin.write('\n');
104-
}
105-
grunt.verbose.writeln(data);
106-
});
128+
var deps = [
129+
'../app',
130+
[
131+
helpers.createDummyGenerator(),
132+
'ng-component:app'
133+
]
134+
];
135+
136+
var gen = helpers.createGenerator('angular-fullstack:app', deps);
107137

108-
generator.on('close', function (code) {
138+
helpers.mockPrompt(gen, options);
139+
gen.run({}, function () {
109140
deferred.resolve();
110141
});
111142

112143
return deferred.promise;
113144
}
114145

115-
function gruntRelease() {
146+
function run(cmd) {
116147
var deferred = Q.defer();
117-
var generator = shell.exec('grunt build', {async:true});
148+
var generator = shell.exec(cmd, {async:true});
118149
generator.stdout.on('data', function (data) {
119150
grunt.verbose.writeln(data);
120151
});
@@ -124,6 +155,14 @@ module.exports = function (grunt) {
124155

125156
return deferred.promise;
126157
}
158+
159+
function gruntBuild() {
160+
return run('grunt');
161+
}
162+
163+
function gruntRelease() {
164+
return run('grunt buildcontrol');
165+
}
127166
});
128167

129168
grunt.registerTask('demo', [

app/templates/Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ module.exports = function (grunt) {
414414
dir: 'dist',
415415
commit: true,
416416
push: true,
417+
connectCommits: false,
417418
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
418419
},
419420
heroku: {
420421
options: {
421422
remote: 'heroku',
422-
branch: 'master',
423-
tag: '<%%= pkg.version %>'
423+
branch: 'master'
424424
}
425425
}
426426
},

app/templates/client/app/main/main(html).html

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ <h1 class="page-header">Features:</h1>
3131

3232
<footer class="footer">
3333
<div class="container">
34-
<p><a href="https://twitter.com/tyhenkel">@tyhenkel</a> |
34+
<p>Angular Fullstack v<%= pkg.version %> |
35+
<a href="https://twitter.com/tyhenkel">@tyhenkel</a> |
3536
<a href="https://github.com/DaftMonk/generator-angular-fullstack/issues?state=open">Issues</a></p>
3637
</div>
3738
</footer>

app/templates/client/app/main/main(jade).jade

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ header#banner.hero-unit
2626
footer.footer
2727
.container
2828
p
29+
| Angular Fullstack v<%= pkg.version %>
30+
= ' | '
2931
a(href='https://twitter.com/tyhenkel') @tyhenkel
3032
= ' | '
3133
a(href='https://github.com/DaftMonk/generator-angular-fullstack/issues?state=open') Issues

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"grunt-contrib-clean": "^0.6.0",
4242
"grunt-contrib-jshint": "^0.10.0",
4343
"grunt-conventional-changelog": "~1.0.0",
44+
"grunt-build-control": "DaftMonk/grunt-build-control",
4445
"grunt-release": "~0.6.0",
4546
"load-grunt-tasks": "~0.2.0",
4647
"marked": "~0.2.8",

0 commit comments

Comments
 (0)