Skip to content

Commit

Permalink
feat(app): grunt build now moves all files into a dist folder
Browse files Browse the repository at this point in the history
this creates a cleaner folder structure, and makes it much more clear what files need to be deployed.
this also depricates the heroku task, use grunt build instead. yo angular-fullstack:deploy heroku will also use the dist folder now.

closes #24
  • Loading branch information
DaftMonk committed Jan 10, 2014
1 parent 7e001d3 commit e6eff5d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 58 deletions.
16 changes: 8 additions & 8 deletions deploy/index.js
Expand Up @@ -28,15 +28,15 @@ Generator.prototype.checkInstallation = function checkInstallation() {

Generator.prototype.copyProcfile = function copyProcfile() {
if(this.name.toLowerCase() != "heroku") return;
this.template('../deploy/heroku/Procfile', 'heroku/Procfile');
this.template('../deploy/heroku/Procfile', 'dist/Procfile');
};

Generator.prototype.gruntBuild = function gruntBuild() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();

console.log(chalk.bold('Building heroku folder, please wait...'));
exec('grunt heroku', function (err, stdout) {
console.log(chalk.bold('Building dist folder, please wait...'));
exec('grunt build', function (err, stdout) {
console.log('stdout: ' + stdout);

if (err) {
Expand All @@ -50,7 +50,7 @@ Generator.prototype.gitInit = function gitInit() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();

exec('git init && git add -A && git commit -m "Initial commit"', { cwd: 'heroku' }, function (err) {
exec('git init && git add -A && git commit -m "Initial commit"', { cwd: 'dist' }, function (err) {
if (err) {
this.log.error(err);
}
Expand All @@ -62,15 +62,15 @@ Generator.prototype.herokuCreate = function herokuCreate() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();

exec('heroku apps:create && heroku config:set NODE_ENV=production', { cwd: 'heroku' }, function (err, stdout, stderr) {
exec('heroku apps:create && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
if (err) {
this.log.error(err);
} else {
console.log('stdout: ' + stdout);
console.log(chalk.green('You\'re all set! Now push to heroku with\n\t' + chalk.bold('git push heroku master') +
'\nfrom your new heroku folder'));
console.log(chalk.yellow('After app modification run\n\t' + chalk.bold('grunt heroku') +
'\nthen commit and push the heroku folder'));
'\nfrom your new distribution folder'));
console.log(chalk.yellow('After app modification run\n\t' + chalk.bold('grunt build') +
'\nthen commit and push the dist folder'));
}
done();
}.bind(this));
Expand Down
89 changes: 39 additions & 50 deletions templates/common/Gruntfile.js
@@ -1,4 +1,4 @@
// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %>
// Generated on <%%= (new Date).toISOString().split('T')[0] %> using <%%= pkg.name %> <%%= pkg.version %>
'use strict';

// # Globbing
Expand All @@ -22,8 +22,7 @@ module.exports = function (grunt) {
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'public',
views: 'views'
dist: 'dist'
},
express: {
options: {
Expand All @@ -37,7 +36,7 @@ module.exports = function (grunt) {
},
prod: {
options: {
script: 'server.js',
script: 'dist/server.js',
node_env: 'production'
}
}
Expand Down Expand Up @@ -80,7 +79,7 @@ module.exports = function (grunt) {
},
livereload: {
files: [
'<%%= yeoman.app %>/<%%= yeoman.views %>/{,*//*}*.{html,jade}',
'<%%= yeoman.app %>/views/{,*//*}*.{html,jade}',
'{.tmp,<%%= yeoman.app %>}/styles/{,*//*}*.css',
'{.tmp,<%%= yeoman.app %>}/scripts/{,*//*}*.js',
'<%%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}',
Expand Down Expand Up @@ -133,9 +132,9 @@ module.exports = function (grunt) {
dot: true,
src: [
'.tmp',
'<%%= yeoman.views %>/*',
'<%%= yeoman.dist %>/*',
'!<%%= yeoman.dist %>/.git*'
'<%%= yeoman.dist %>/views/*',
'<%%= yeoman.dist %>/public/*',
'!<%%= yeoman.dist %>/public/.git*',
]
}]
},
Expand Down Expand Up @@ -174,8 +173,8 @@ module.exports = function (grunt) {
html: '<%%= yeoman.app %>/views/index.html',<% } %>
ignorePath: '<%%= yeoman.app %>/'
}
},
<% if (coffee) { %>
},<% if (coffee) { %>

// Compiles CoffeeScript to JavaScript
coffee: {
options: {
Expand All @@ -200,8 +199,8 @@ module.exports = function (grunt) {
ext: '.js'
}]
}
},<% } %>
<% if (compass) { %>
},<% } %><% if (compass) { %>

// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
Expand All @@ -221,7 +220,7 @@ module.exports = function (grunt) {
},
dist: {
options: {
generatedImagesDir: '<%%= yeoman.dist %>/images/generated'
generatedImagesDir: '<%%= yeoman.dist %>/public/images/generated'
}
},
server: {
Expand All @@ -236,10 +235,10 @@ module.exports = function (grunt) {
dist: {
files: {
src: [
'<%%= yeoman.dist %>/scripts/{,*/}*.js',
'<%%= yeoman.dist %>/styles/{,*/}*.css',
'<%%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%%= yeoman.dist %>/styles/fonts/*'
'<%%= yeoman.dist %>/public/scripts/{,*/}*.js',
'<%%= yeoman.dist %>/public/styles/{,*/}*.css',
'<%%= yeoman.dist %>/public/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%%= yeoman.dist %>/public/styles/fonts/*'
]
}
}
Expand All @@ -249,20 +248,20 @@ module.exports = function (grunt) {
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: ['<%%= yeoman.app %>/<%%= yeoman.views %>/index.html',
'<%%= yeoman.app %>/<%%= yeoman.views %>/index.jade'],
html: ['<%%= yeoman.app %>/views/index.html',
'<%%= yeoman.app %>/views/index.jade'],
options: {
dest: '<%%= yeoman.dist %>'
dest: '<%%= yeoman.dist %>/public'
}
},

// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%%= yeoman.views %>/{,*/}*.html',
'<%%= yeoman.views %>/{,*/}*.jade'],
html: ['<%%= yeoman.dist %>/views/{,*/}*.html',
'<%%= yeoman.dist %>/views/{,*/}*.jade'],
css: ['<%%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%%= yeoman.dist %>']
assetsDirs: ['<%%= yeoman.dist %>/public']
}
},

Expand All @@ -273,20 +272,22 @@ module.exports = function (grunt) {
expand: true,
cwd: '<%%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%%= yeoman.dist %>/images'
dest: '<%%= yeoman.dist %>/public/images'
}]
}
},

svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%%= yeoman.dist %>/images'
dest: '<%%= yeoman.dist %>/public/images'
}]
}
},

htmlmin: {
dist: {
options: {
Expand All @@ -297,9 +298,9 @@ module.exports = function (grunt) {
},
files: [{
expand: true,
cwd: '<%%= yeoman.app %>/<%%= yeoman.views %>',
cwd: '<%%= yeoman.app %>/views',
src: ['*.html', 'partials/*.html'],
dest: '<%%= yeoman.views %>'
dest: '<%%= yeoman.dist %>/views'
}]
}
},
Expand All @@ -320,7 +321,7 @@ module.exports = function (grunt) {
// Replace Google CDN references
cdnify: {
dist: {
html: ['<%%= yeoman.views %>/*.html']
html: ['<%%= yeoman.dist %>/views/*.html']
}
},

Expand All @@ -331,7 +332,7 @@ module.exports = function (grunt) {
expand: true,
dot: true,
cwd: '<%%= yeoman.app %>',
dest: '<%%= yeoman.dist %>',
dest: '<%%= yeoman.dist %>/public',
src: [
'*.{ico,png,txt}',
'.htaccess',
Expand All @@ -342,28 +343,17 @@ module.exports = function (grunt) {
}, {
expand: true,
dot: true,
cwd: '<%%= yeoman.app %>/<%%= yeoman.views %>',
dest: '<%%= yeoman.views %>',
src: '**/*.jade',
cwd: '<%%= yeoman.app %>/views',
dest: '<%%= yeoman.dist %>/views',
src: '**/*.jade'
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%%= yeoman.dist %>/images',
dest: '<%%= yeoman.dist %>/public/images',
src: ['generated/*']
}]
},
heroku: {
files: [{
expand: true,
dot: true,
dest: 'heroku',
src: [
'<%%= yeoman.dist %>/**',
'<%%= yeoman.views %>/**'
]
}, {
expand: true,
dest: 'heroku',
dest: '<%%= yeoman.dist %>',
src: [
'package.json',
'server.js',
Expand Down Expand Up @@ -484,11 +474,10 @@ module.exports = function (grunt) {
'usemin'
]);

grunt.registerTask('heroku', [
'build',
'clean:heroku',
'copy:heroku'
]);
grunt.registerTask('heroku', function () {
grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
grunt.task.run(['build']);
});

grunt.registerTask('default', [
'newer:jshint',
Expand Down
1 change: 1 addition & 0 deletions templates/common/gitignore
Expand Up @@ -5,3 +5,4 @@ public
app/bower_components
heroku
/views
dist

0 comments on commit e6eff5d

Please sign in to comment.