From e6eff5d56bf2a784feb3de6218e74b5390df319f Mon Sep 17 00:00:00 2001 From: Tyler Henkel Date: Fri, 10 Jan 2014 04:53:05 -0500 Subject: [PATCH] feat(app): grunt build now moves all files into a dist folder 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 --- deploy/index.js | 16 +++---- templates/common/Gruntfile.js | 89 +++++++++++++++-------------------- templates/common/gitignore | 1 + 3 files changed, 48 insertions(+), 58 deletions(-) diff --git a/deploy/index.js b/deploy/index.js index 6a7a46f89..79080ec65 100644 --- a/deploy/index.js +++ b/deploy/index.js @@ -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) { @@ -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); } @@ -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)); diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index 342833457..e4da158a5 100644 --- a/templates/common/Gruntfile.js +++ b/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 @@ -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: { @@ -37,7 +36,7 @@ module.exports = function (grunt) { }, prod: { options: { - script: 'server.js', + script: 'dist/server.js', node_env: 'production' } } @@ -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}', @@ -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*', ] }] }, @@ -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: { @@ -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: { @@ -221,7 +220,7 @@ module.exports = function (grunt) { }, dist: { options: { - generatedImagesDir: '<%%= yeoman.dist %>/images/generated' + generatedImagesDir: '<%%= yeoman.dist %>/public/images/generated' } }, server: { @@ -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/*' ] } } @@ -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'] } }, @@ -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: { @@ -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' }] } }, @@ -320,7 +321,7 @@ module.exports = function (grunt) { // Replace Google CDN references cdnify: { dist: { - html: ['<%%= yeoman.views %>/*.html'] + html: ['<%%= yeoman.dist %>/views/*.html'] } }, @@ -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', @@ -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', @@ -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', diff --git a/templates/common/gitignore b/templates/common/gitignore index 66a5aed74..5d573ad51 100644 --- a/templates/common/gitignore +++ b/templates/common/gitignore @@ -5,3 +5,4 @@ public app/bower_components heroku /views +dist \ No newline at end of file