From dff2a895e4c00e163ad5bdc2d44c41896c248fdb Mon Sep 17 00:00:00 2001 From: Sondre Nilsen Date: Tue, 24 Mar 2015 19:54:22 +0100 Subject: [PATCH] Updated tests, packages and Travis settings Moved to JSCS for checking the JS style to be more consistent and find dumb errors before they are committed. Means that there a bunch of aesthetic changes to them. Also updated the tests to check for the functions that were added as we migrate to Gulp 4. Updated the packages and moved them from peerDeps to devDeps as NPM will apparently stop using peerDeps in NPM 3.0. Updated JShint settings and tests: We're now testing for both node 0.10, 0.12 and iojs as well. However we moved from the default Travis NPM version to the latest NPM version and fixed some minor errors with Travis and how tests are run. --- .jscsrc | 3 + .jshintrc | 33 ++--- .travis.yml | 6 +- README.md | 8 +- app/index.js | 272 ++++++++++++++++++---------------- app/templates/gulpfile.js | 177 +++++++++++----------- gulpfile.js | 70 +++++---- package.json | 25 ++-- test/test-creation-aws.js | 81 +++++----- test/test-creation-ghpages.js | 63 ++++---- test/test-creation-rsync.js | 69 +++++---- test/test-gulp.js | 123 +++++++++------ test/test-jekyll.js | 183 ++++++++++++----------- test/test-load.js | 11 +- test/test-package.js | 51 ++++--- 15 files changed, 610 insertions(+), 565 deletions(-) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..4b5fa83 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,3 @@ +{ + "preset": "google" +} diff --git a/.jshintrc b/.jshintrc index 84da426..3ef3f74 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,21 +1,16 @@ { - "node": true, - "esnext": true, - "bitwise": false, - "camelcase": true, - "curly": false, - "eqeqeq": true, - "immed": true, - "indent": 2, - "latedef": false, - "newcap": true, - "noarg": true, - "quotmark": "double", - "regexp": true, - "undef": true, - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "white": true + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "globalstrict": true, + "immed": true, + "latedef": true, + "mocha": true, + "newcap": true, + "noarg": true, + "node": true, + "strict": true, + "undef": true } diff --git a/.travis.yml b/.travis.yml index d592da3..48ede82 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: node_js node_js: -- '0.10' +- "0.12" +- "0.10" +- iojs +before_install: +- npm install -g npm@'>2.7.0' after_script: - CODECLIMATE_REPO_TOKEN=7b0cbee1382c968a036868d26ec04d0ddc7b7aeef25ceead5ff9ff50a3c2ae8b codeclimate < coverage/lcov.info - rm -rf ./coverage diff --git a/README.md b/README.md index 278f164..6b94c81 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,12 @@ [![NPM version](https://badge.fury.io/js/generator-jekyllized.png)](http://badge.fury.io/js/generator-jekyllized) [![Coverage Status](https://coveralls.io/repos/sondr3/generator-jekyllized/badge.png)](https://coveralls.io/r/sondr3/generator-jekyllized) [![Code Climate](https://codeclimate.com/github/sondr3/generator-jekyllized/badges/gpa.svg)](https://codeclimate.com/github/sondr3/generator-jekyllized) -### Work in progress! Things may or may not work. +### Development is happening on the [beta][beta] branch! + +Waiting for Jekyll 3.0 and Gulp 4.0 to land, take a look if you want to! It's +also published on NPM under a 0.8-beta branch so you can start using it today, +however be warned that Gulp 3.x and Gulp 4.0 does not play nice together right +now! **Stylized and opinionated Jekyll development** @@ -148,6 +153,7 @@ repositories there are some things you need to do: ### [Changelog][changelog] +[beta]: https://github.com/sondr3/generator-jekyllized/tree/beta [jekyll]: https://jekyllrb.com [yeoman]: http://yeoman.io [yo]: https://github.com/yeoman/yo diff --git a/app/index.js b/app/index.js index 299872f..3113729 100644 --- a/app/index.js +++ b/app/index.js @@ -1,60 +1,63 @@ -"use strict"; -var path = require("path"); -var chalk = require("chalk"); -var yeoman = require("yeoman-generator"); -var yosay = require("yosay"); -var shelljs = require("shelljs"); +'use strict'; +var path = require('path'); +var chalk = require('chalk'); +var yeoman = require('yeoman-generator'); +var yosay = require('yosay'); +var shelljs = require('shelljs'); module.exports = yeoman.generators.Base.extend({ - constructor: function () { + constructor: function() { yeoman.generators.Base.apply(this, arguments); - this.option("skip-install", { - desc: "Whether dependencies should be installed", + this.option('skip-install', { + desc: 'Whether dependencies should be installed', defaults: false }); - this.option("skip-install-message", { - desc: "Whether commands run should be shown", + this.option('skip-install-message', { + desc: 'Whether commands run should be shown', defaults: false }); - var dependenciesInstalled = ["bundle", "ruby"].every(function (depend) { + var dependenciesInstalled = ['bundle', 'ruby'].every(function(depend) { return shelljs.which(depend); }); if (!dependenciesInstalled) { - this.log("MISSING DEPENDENCIES:" + - "\nEither " + chalk.white("Ruby") + " or " + chalk.white("Bundler") + " is not installed or missing from $PATH." + - "\nMake sure that they are either installed or added to $PATH."); + this.log('MISSING DEPENDENCIES:' + + '\nEither ' + chalk.white('Ruby') + ' or ' + chalk.white('Bundler') + + ' is not installed or missing from $PATH.' + + '\nMake sure that they are either installed or added to $PATH.'); shelljs.exit(1); } - this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, "../package.json"))); + this.pkg = JSON.parse(this.readFileAsString(path.join + (__dirname, '../package.json'))); }, - projectPrompting: function () { + projectPrompting: function() { var cb = this.async(); - this.log(yosay("Time to supercharge your Jekyll development, time to get Jekyllized!")); + this.log(yosay('Time to supercharge your Jekyll development!')); - this.log(chalk.yellow("\nTell me a little about your project >>")); + this.log(chalk.yellow('\nTell me a little about your project >>')); var prompts = [{ - name: "projectName", - message: "What is the name of your project?" + name: 'projectName', + message: 'What is the name of your project?' }, { - name: "projectDescription", - message: "Describe your project for me:" + name: 'projectDescription', + message: 'Describe your project for me:' }, { - name: "projectTagline", - message: "What is the tagline for your project?" + name: 'projectTagline', + message: 'What is the tagline for your project?' }, { - name: "projectURL", - message: chalk.red("If you are using GitHub Pages use username.github.io") + "\nWhat will the URL for your project be?" + name: 'projectURL', + message: chalk.red('If you are using GH Pages use username.github.io') + + '\nWhat will the URL for your project be?' }]; - this.prompt(prompts, function (props) { + this.prompt(prompts, function(props) { this.projectName = props.projectName; this.projectDescription = props.projectDescription; this.projectTagline = props.projectTagline; @@ -64,26 +67,26 @@ module.exports = yeoman.generators.Base.extend({ }.bind(this)); }, - authorPrompting: function () { + authorPrompting: function() { var cb = this.async(); - this.log(chalk.yellow("\nNow it\"s time to tell me about you. >>")); + this.log(chalk.yellow('\nNow it\'s time to tell me about you. >>')); var prompts = [{ - name: "authorName", - message: "What is your name?", + name: 'authorName', + message: 'What is your name?', }, { - name: "authorEmail", - message: "What is your email?", + name: 'authorEmail', + message: 'What is your email?', }, { - name: "authorBio", - message: "Write a short description of yourself:" + name: 'authorBio', + message: 'Write a short description of yourself:' }, { - name: "authorTwitter", - message: "Your Twitter URL:" + name: 'authorTwitter', + message: 'Your Twitter URL:' }]; - this.prompt(prompts, function (props) { + this.prompt(prompts, function(props) { this.authorName = props.authorName; this.authorEmail = props.authorEmail; this.authorBio = props.authorBio; @@ -93,36 +96,37 @@ module.exports = yeoman.generators.Base.extend({ }.bind(this)); }, - jekyllPrompting: function () { + jekyllPrompting: function() { var cb = this.async(); - this.log(chalk.yellow("\nNow on to set some Jekyll settings: >>") + - chalk.red("\nYou can change all of this later in the _config.yml file")); + this.log(chalk.yellow('\nNow on to set some Jekyll settings: >>') + + chalk.red('\nYou can change all of this later in the _config.yml file')); var prompts = [{ - name: "jekyllPermalinks", - type: "list", - message: "Permalink style" + (chalk.red( - "\n pretty: /:year/:month/:day/:title/" + - "\n date: /:year/:month/:day/:title.html" + - "\n none: /:categories/:title.html")) + "\n", - choices: ["pretty", "date", "none"] + name: 'jekyllPermalinks', + type: 'list', + message: 'Permalink style' + (chalk.red( + '\n pretty: /:year/:month/:day/:title/' + + '\n date: /:year/:month/:day/:title.html' + + '\n none: /:categories/:title.html')) + '\n', + choices: ['pretty', 'date', 'none'] }, { - name: "jekyllPaginate", - message: "How many posts do you want to show on your front page?" + chalk.red("\nMust be a number or all"), + name: 'jekyllPaginate', + message: 'How many posts do you want to show on your front page?' + + chalk.red('\nMust be a number or all'), default: 10, - validate: function (input) { + validate: function(input) { if (/^[0-9]*$/.test(input)) { return true; } if (/^all*$/i.test(input)) { return true; } - return "Must be a number or all"; + return 'Must be a number or all'; } }]; - this.prompt(prompts, function (props) { + this.prompt(prompts, function(props) { this.jekyllPermalinks = props.jekyllPermalinks; this.jekyllPaginate = props.jekyllPaginate; @@ -130,92 +134,97 @@ module.exports = yeoman.generators.Base.extend({ }.bind(this)); }, - uploadPrompting: function () { + uploadPrompting: function() { var cb = this.async(); - this.log(chalk.yellow("\nNow we only need some details about how to upload your site: >>") + - chalk.red("\nNOTE: Take whatever time you need to get these right/fill them in later in eithers credentials file.")); + this.log(chalk.yellow('\nTime to choose how to upload your site: >>') + + chalk.red('\nNOTE: Take whatever time you need to get these ' + + 'right/fill them in later in eithers credentials file.')); var prompts = [{ - name: "uploadChoices", - type: "list", - message: "How would you like to host/upload your site?", + name: 'uploadChoices', + type: 'list', + message: 'How would you like to host/upload your site?', choices: [{ - name: "Amazon S3 + Cloudfront", - value: "amazonCloudfrontS3", + name: 'Amazon S3 + Cloudfront', + value: 'amazonCloudfrontS3', }, { - name: "Rsync", - value: "rsync", + name: 'Rsync', + value: 'rsync', }, { - name: "Github Pages", - value: "githubPages", + name: 'Github Pages', + value: 'githubPages', }, { - name: "None", - value: "noUpload" + name: 'None', + value: 'noUpload' }] }, { - name: "amazonKey", - message: chalk.yellow("\n\nNow we just need to fill out the detailes needed to configure your site for Amazon S3 and Cloudfront: >>") + - chalk.red("\nNOTE: Take your time and get the correct settings from Amazon, or alternatively") + - chalk.red("\njust fill them in blankly and fill out the aws-credentials.json later.") + - "\nWhat is your key to AWS?", - when: function (answers) { - return answers.uploadChoices === "amazonCloudfrontS3"; + name: 'amazonKey', + message: chalk.yellow('\n\nNow we just need to fill out the detailes ' + + 'needed to configure your site for Amazon S3 and Cloudfront: >>') + + chalk.red('\nNOTE: Take your time to correctly fill these out') + + chalk.red('\nOr leave them blank and') + + chalk.red('\nfill them out later in aws-credentials.json.') + + '\nWhat is your key to AWS?', + when: function(answers) { + return answers.uploadChoices === 'amazonCloudfrontS3'; } }, { - name: "amazonSecret", - message: "What is your AWS secret?", - when: function (answers) { - return answers.uploadChoices === "amazonCloudfrontS3"; + name: 'amazonSecret', + message: 'What is your AWS secret?', + when: function(answers) { + return answers.uploadChoices === 'amazonCloudfrontS3'; } }, { - name: "amazonBucket", - message: "What do you want your S3 bucket to be called?", - when: function (answers) { - return answers.uploadChoices === "amazonCloudfrontS3"; + name: 'amazonBucket', + message: 'What do you want your S3 bucket to be called?', + when: function(answers) { + return answers.uploadChoices === 'amazonCloudfrontS3'; } }, { - name: "amazonDistID", - message: "What is the Cloudfront distribution ID?", - when: function (answers) { - return answers.uploadChoices === "amazonCloudfrontS3"; + name: 'amazonDistID', + message: 'What is the Cloudfront distribution ID?', + when: function(answers) { + return answers.uploadChoices === 'amazonCloudfrontS3'; } }, { - name: "rsyncUsername", - message: chalk.yellow("\n\nNow we just need to fill out the detailes needed to upload your site via Rsync: >>") + - chalk.red("\nNOTE: Take your time and get the correct settings for your server, or alternatively") + - chalk.red("\njust fill them in blankly and fill out the rsync-credentials.json later.") + - "\nWhat is the username of the user you will be uploading with?", - when: function (answers) { - return answers.uploadChoices === "rsync"; + name: 'rsyncUsername', + message: chalk.yellow('\n\nNow we just need to fill out the details ' + + 'needed to upload your site via Rsync: >>') + + chalk.red('\nNOTE: Take your time to correctly fill these out') + + chalk.red('\nOr leave them blank and') + + chalk.red('\nfill them out later in rsync-credentials.json.') + + '\nWhat is the username of the user you will be uploading with?', + when: function(answers) { + return answers.uploadChoices === 'rsync'; } }, { - name: "rsyncHostname", - message: chalk.red("\n(eg. example.com or 192.168.1.1)") + - "\nWhat is the hostname?", - when: function (answers) { - return answers.uploadChoices === "rsync"; + name: 'rsyncHostname', + message: chalk.red('\n(eg. example.com or 192.168.1.1)') + + '\nWhat is the hostname?', + when: function(answers) { + return answers.uploadChoices === 'rsync'; } }, { - name: "rsyncDestination", - message: chalk.red("\n(eg. /srv/www/site/public_html)") + - "\nWhere do you want to save the files?", - when: function (answers) { - return answers.uploadChoices === "rsync"; + name: 'rsyncDestination', + message: chalk.red('\n(eg. /srv/www/site/public_html)') + + '\nWhere do you want to save the files?', + when: function(answers) { + return answers.uploadChoices === 'rsync'; } }]; - this.prompt(prompts, function (props) { + this.prompt(prompts, function(props) { var features = props.uploadChoices; - var hasFeature = function (feat) { + var hasFeature = function(feat) { return features.indexOf(feat) !== -1; }; - this.amazonCloudfrontS3 = hasFeature("amazonCloudfrontS3"); - this.rsync = hasFeature("rsync"); - this.githubPages = hasFeature("githubPages"); - this.noUpload = hasFeature("noUpload"); + this.amazonCloudfrontS3 = hasFeature('amazonCloudfrontS3'); + this.rsync = hasFeature('rsync'); + this.githubPages = hasFeature('githubPages'); + this.noUpload = hasFeature('noUpload'); this.amazonKey = props.amazonKey; this.amazonSecret = props.amazonSecret; @@ -230,34 +239,35 @@ module.exports = yeoman.generators.Base.extend({ }.bind(this)); }, - scaffolding: function () { - this.copy("Gemfile", "Gemfile"); - this.copy("bowerrc", ".bowerrc"); - this.copy("_bower.json", "bower.json"); - this.template("_package.json", "package.json"); - this.template("_config.yml", "_config.yml"); - this.template("_config.build.yml", "_config.build.yml"); - this.template("_README.md", "README.md"); - this.template("gulpfile.js", "gulpfile.js"); - this.copy("gulp.config.json", "gulp.config.json"); - this.copy("gitignore", ".gitignore"); - this.copy("gitattributes", ".gitattributes"); - this.copy("jshintrc", ".jshintrc"); - this.copy("editorconfig", ".editorconfig"); - this.directory("app", "src"); + scaffolding: function() { + this.copy('Gemfile', 'Gemfile'); + this.copy('bowerrc', '.bowerrc'); + this.copy('_bower.json', 'bower.json'); + this.template('_package.json', 'package.json'); + this.template('_config.yml', '_config.yml'); + this.template('_config.build.yml', '_config.build.yml'); + this.template('_README.md', 'README.md'); + this.template('gulpfile.js', 'gulpfile.js'); + this.copy('gulp.config.json', 'gulp.config.json'); + this.copy('gitignore', '.gitignore'); + this.copy('gitattributes', '.gitattributes'); + this.copy('jshintrc', '.jshintrc'); + this.copy('editorconfig', '.editorconfig'); + this.directory('app', 'src'); if (this.amazonCloudfrontS3) { - this.template("conditionals/_aws-credentials.json", "aws-credentials.json"); - } - else if (this.rsync) { - this.template("conditionals/_rsync-credentials.json", "rsync-credentials.json"); + this.template('conditionals/_aws-credentials.json', + 'aws-credentials.json'); + } else if (this.rsync) { + this.template('conditionals/_rsync-credentials.json', + 'rsync-credentials.json'); } }, install: function() { this.installDependencies({ - skipInstall: this.options["skip-install"], - skipMessage: this.options["skip-install-message"] + skipInstall: this.options['skip-install'], + skipMessage: this.options['skip-install-message'] }); } }); diff --git a/app/templates/gulpfile.js b/app/templates/gulpfile.js index 6b9de8f..7643154 100755 --- a/app/templates/gulpfile.js +++ b/app/templates/gulpfile.js @@ -1,41 +1,44 @@ -// Generated on <%= (new Date).toISOString().split("T")[0] %> using <%= pkg.name %> <%= pkg.version %> -"use strict"; +// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %> +'use strict'; -var gulp = require("gulp"); +var gulp = require('gulp'); // Load in paths from a external config file for easier changing of paths -var config = require("./gulp.config.json"); +var config = require('./gulp.config.json'); // Loads the plugins without having to list all of them, but you need // to call them as $.pluginname -var $ = require("gulp-load-plugins")({ lasy: true }); -// "trash" is used to clean out directories and such -var trash = require("trash"); +var $ = require('gulp-load-plugins')(); +// 'trash' is used to clean out directories and such +var trash = require('trash'); // Used to run shell commands -var shell = require("shelljs"); +var shell = require('shelljs'); <% if (amazonCloudfrontS3) { %>// Parallelize the uploads when uploading to Amazon S3 -// "fs" is used to read files from the system (used for AWS uploading) -var fs = require("fs"); -var parallelize = require("concurrent-transform"); +// 'fs' is used to read files from the system (used for AWS uploading) +var fs = require('fs'); +var parallelize = require('concurrent-transform'); <% } %>// BrowserSync is used to live-reload your website -var browserSync = require("browser-sync"); +var browserSync = require('browser-sync'); var reload = browserSync.reload; // merge is used to merge the output from two different streams into the same stream -var merge = require("merge-stream"); +var merge = require('merge-stream'); // Deletes the directory that the optimized site is output to -function cleanDist(done) { trash(["dist"]); done(); } -function cleanAssets(done) { trash([".tmp"]); done(); } -function rebuild(done) { trash(["src/.jekyll-metadata"]); done(); } +function cleanDist(done) { trash(['dist']); done(); } +function cleanAssets(done) { trash(['.tmp']); done(); } +function rebuild(done) { trash(['src/.jekyll-metadata']); done(); } // so Jekyll rebuilds the site properly // Runs the build command for Jekyll to compile the site locally // This will build the site with the production settings -function jekyllDev(done) { shell.exec("jekyll build --quiet"); done(); } +function jekyllDev(done) { shell.exec('jekyll build --quiet'); done(); } // Almost identical to the above task, but instead we load in the build configuration // that overwrites some of the settings in the regular configuration so that you // don't end up publishing your drafts or future posts -function jekyllProd(done) { shell.exec("jekyll build --quiet --config _config.yml,_config.build.yml"); done(); } +function jekyllProd(done) { + shell.exec('jekyll build --quiet --config _config.yml,_config.build.yml'); + done(); +} -// Compiles the SASS files and moves them into the "assets/stylesheets" directory +// Compiles the SASS files and moves them into the 'assets/stylesheets' directory function styles() { // Looks at the style.scss file for what to include and creates a style.css file return gulp.src(config.scss.src) @@ -43,13 +46,13 @@ function styles() { .pipe($.sourcemaps.init()) .pipe($.sass({errLogToconsole: true})) // AutoPrefix your CSS so it works between browsers - .pipe($.autoprefixer("last 1 version", { cascade: true })) + .pipe($.autoprefixer('last 1 version', {cascade: true})) // Write the sourcemaps to the directory of the gulp.src stream - .pipe($.sourcemaps.write(".")) + .pipe($.sourcemaps.write('.')) // Directory your CSS file goes to .pipe(gulp.dest(config.scss.dest)) // Outputs the size of the CSS file - .pipe($.size({title: "styles"})) + .pipe($.size({title: 'styles'})) // Injects the CSS changes to your browser since Jekyll doesn't rebuild the CSS .pipe(reload({stream: true})); } @@ -58,13 +61,13 @@ function styles() { function javascript() { return gulp.src(config.javascript.src) .pipe($.sourcemaps.init()) - .pipe($.uglify({compress: false, preserveComments: "all"})) + .pipe($.uglify({compress: false, preserveComments: 'all'})) .pipe($.groupConcat({ - "index.js": config.javascript.src + 'index.js': config.javascript.src })) - .pipe($.sourcemaps.write(".")) + .pipe($.sourcemaps.write('.')) .pipe(gulp.dest(config.javascript.dest)) - .pipe($.size({title: "javascript"})) + .pipe($.size({title: 'javascript'})) .pipe(reload({stream: true})); } @@ -79,25 +82,25 @@ function images() { interlaced: true }))) .pipe(gulp.dest(config.images.dest)) - .pipe($.size({title: "images"})); + .pipe($.size({title: 'images'})); } -// Copy over fonts to the ".tmp" directory +// Copy over fonts to the '.tmp' directory function fonts() { return gulp.src(config.fonts.src) .pipe(gulp.dest(config.fonts.dest)) - .pipe($.size({ title: "fonts" })); + .pipe($.size({title: 'fonts'})); } -// Copy optimized images and (not optimized) fonts to the "dist" folder +// Copy optimized images and (not optimized) fonts to the 'dist' folder function copy() { var images = gulp.src(config.images.dest) .pipe(gulp.dest(config.images.build)) - .pipe($.size({title: "copied images"})); + .pipe($.size({title: 'copied images'})); var fonts = gulp.src(config.fonts.dest) .pipe(gulp.dest(config.fonts.build)) - .pipe($.size({title: "copied fonts"})); + .pipe($.size({title: 'copied fonts'})); return merge(images, fonts); } @@ -109,18 +112,21 @@ function optimize() { return gulp.src(config.assets.html) .pipe(assets) // Concatenate JavaScript files and preserve important comments - .pipe($.if("*.js", $.uglify({preserveComments: "some"}))) + .pipe($.if('*.js', $.uglify({preserveComments: 'some'}))) // Minify CSS - .pipe($.if("*.css", $.minifyCss())) + .pipe($.if('*.css', $.minifyCss())) // Start cache busting the files - .pipe($.revAll({quiet: true, ignore: [".eot", ".svg", ".ttf", ".woff", ".woff2"]})) + .pipe($.revAll({ + quiet: true, + ignore: ['.eot', '.svg', '.ttf', '.woff', '.woff2'] + })) .pipe(assets.restore()) // Conctenate your files based on what you specified in _layout/header.html .pipe($.useref()) // Replace the asset names with their cache busted names .pipe($.revReplace()) // Minify HTML - .pipe($.if("*.html", $.htmlmin({ + .pipe($.if('*.html', $.htmlmin({ removeComments: true, removeCommentsFromCDATA: true, removeCDATASectionsFromCDATA: true, @@ -131,63 +137,59 @@ function optimize() { }))) // Send the output to the correct folder .pipe(gulp.dest(config.assets.dest)) - .pipe($.size({title: "optimizations"})); -} + .pipe($.size({title: 'optimizations'})); +}<% if (amazonCloudfrontS3) { %> -<% if (amazonCloudfrontS3) { %>// Task to deploy your site to Amazon S3 and Cloudfront +// Task to deploy your site to Amazon S3 and Cloudfront function deploy() { - // Generate the needed credentials (bucket, secret key etc) from a "hidden" JSON file - var credentials = JSON.parse(fs.readFileSync("aws-credentials.json", "utf8")); + // Generate the needed credentials (bucket, secret key etc) from a 'hidden' JSON file + var credentials = JSON.parse(fs.readFileSync('aws-credentials.json', 'utf8')); var publisher = $.awspublish.create(credentials); // Give your files the proper headers - var headers = { - "Cache-Control": "max-age=0, no-transform, public", - "Content-Encoding": "gzip" - }; - gulp.src("dist/**/*") + gulp.src('dist/**/*') .pipe($.awspublishRouter({ routes: { - "^assets/(?:.+)\\.(?:js|css)$": { - key: "$&", + '^assets/(?:.+)\\.(?:js|css)$': { + key: '$&', headers: { - "Cache-Control": "max-age=315360000, no-transform, public", - "Content-Encoding": "gzip" + 'Cache-Control': 'max-age=315360000, no-transform, public', + 'Content-Encoding': 'gzip' } }, - "^assets/(?:.+)\\.(?:jpg|png|gif)$": { - key: "$&", + '^assets/(?:.+)\\.(?:jpg|png|gif)$': { + key: '$&', headers: { - "Cache-Control": "max-age=315360000, no-transform, public", - "Content-Encoding": "gzip" + 'Cache-Control': 'max-age=315360000, no-transform, public', + 'Content-Encoding': 'gzip' } }, - "^assets/fonts/(?:.+)\\.(?:eot|svg|ttf|woff)$": { - key: "$&", + '^assets/fonts/(?:.+)\\.(?:eot|svg|ttf|woff)$': { + key: '$&', headers: { - "Cache-Control": "max-age=315360000, no-transform, public" + 'Cache-Control': 'max-age=315360000, no-transform, public' } }, - "^.+\\.html": { - key: "$&", + '^.+\\.html': { + key: '$&', headers: { - "Cache-Control": "max-age=0, no-transform, public", - "Content-Encoding": "gzip" + 'Cache-Control': 'max-age=0, no-transform, public', + 'Content-Encoding': 'gzip' } }, - "^.+$": "$&" + '^.+$': '$&' } })) // Gzip the files for moar speed .pipe($.awspublish.gzip()) // Parallelize the number of concurrent uploads, in this case 30 .pipe(parallelize(publisher.publish(), 30)) - // Have your files in the system cache so you don"t have to recheck all the files every time + // Have your files in the system cache so you don't have to recheck all the files every time .pipe(publisher.cache()) - // Synchronize the contents of the bucket and local (this deletes everything that isn"t in local!) + // Synchronize the contents of the bucket and local (this deletes everything that isn't in local!) .pipe(publisher.sync()) // And print the ouput, glorious .pipe($.awspublish.reporter()) @@ -198,12 +200,12 @@ function deploy() { // Task to upload your site via Rsync to your server function deploy() { // Load in the variables needed for our Rsync synchronization - var secret = require("./rsync-credentials.json"); + var secret = require('./rsync-credentials.json'); - return gulp.src("dist/**") + return gulp.src('dist/**') .pipe($.rsync({ - // This uploads the contenst of "root", instead of the folder - root: "dist", + // This uploads the contenst of 'root', instead of the folder + root: 'dist', // Find your username, hostname and destination from your rsync-credentials.json hostname: secret.hostname, username: secret.username, @@ -214,14 +216,15 @@ function deploy() { progress: true })); }<% } %><% if (githubPages) { %> + // Task to upload your site to your personal GH Pages repo function deploy() { // Deploys your optimized site, you can change the settings in the html task if you want to - return gulp.src("dist/**/*") + return gulp.src('dist/**/*') .pipe($.ghPages({ // Currently only personal GitHub Pages are supported so it will upload to the master // branch and automatically overwrite anything that is in the directory - branch: "master" + branch: 'master' })); }<% } %> @@ -229,13 +232,13 @@ function deploy() { function jslint() { gulp.src(config.javascript.dest) // Checks your JS code quality against your .jshintrc file - .pipe($.jshint(".jshintrc")) + .pipe($.jshint('.jshintrc')) .pipe($.jshint.reporter()); } -// Runs "jekyll doctor" on your site to check for errors with your configuration +// Runs 'jekyll doctor' on your site to check for errors with your configuration // and will check for URL errors a well -function doctor(done) { shell.exec("jekyll doctor"); done(); } +function doctor(done) { shell.exec('jekyll doctor'); done(); } // BrowserSync will serve our site on a local server for us and other devices to use // It will also autoreload across all devices as well as keep the viewport synchronized @@ -256,42 +259,42 @@ function serve() { gulp.watch(config.watch.images, reload); } -// Default task, run when just writing "gulp" in the terminal -gulp.task("default", gulp.series( +// Default task, run when just writing 'gulp' in the terminal +gulp.task('default', gulp.series( gulp.series(jekyllDev), gulp.parallel(styles, javascript, fonts, images), gulp.series(serve) )); -// Builds your site with the "build" command and then runs all the optimizations on -// it and outputs it to "./dist" -gulp.task("optimize", gulp.series( +// Builds your site with the 'build' command and then runs all the optimizations on +// it and outputs it to './dist' +gulp.task('optimize', gulp.series( gulp.series(rebuild, jekyllProd), gulp.parallel(styles, javascript, fonts, images, copy), gulp.series(optimize) )); -gulp.task("build", gulp.series( +gulp.task('build', gulp.series( gulp.series(jekyllDev), gulp.parallel(styles, javascript, fonts, images) ));<% if (!noUpload) { %> // Deploy your site for all to see -gulp.task("deploy", deploy);<% } %> +gulp.task('deploy', deploy);<% } %> // Serves your site locally -gulp.task("serve", serve); +gulp.task('serve', serve); // Clean out your dist and .tmp folder and delete .jekyll-metadata -gulp.task("clean", cleanDist); -gulp.task("clean:assets", cleanAssets); -gulp.task("rebuild", gulp.series(cleanDist, cleanAssets, rebuild)); +gulp.task('clean', cleanDist); +gulp.task('clean:assets', cleanAssets); +gulp.task('rebuild', gulp.series(cleanDist, cleanAssets, rebuild)); // Create your styles and create sourcemaps -gulp.task("styles", styles); +gulp.task('styles', styles); // Create sourcemaps for your JS files -gulp.task("javascript", javascript); +gulp.task('javascript', javascript); // Checks your CSS, JS and Jekyll for errors -gulp.task("check", gulp.series(doctor, jslint)); +gulp.task('check', gulp.series(doctor, jslint)); diff --git a/gulpfile.js b/gulpfile.js index 83f2327..782fc44 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,52 +1,60 @@ -"use strict"; -var path = require("path"); -var gulp = require("gulp"); -var jshint = require("gulp-jshint"); -var istanbul = require("gulp-istanbul"); -var plumber = require("gulp-plumber"); -var mocha = require("gulp-mocha"); -var coveralls = require("gulp-coveralls"); +'use strict'; -var handleErr = function (err) { +var path = require('path'); +var gulp = require('gulp'); +var jscs = require('gulp-jscs'); +var jshint = require('gulp-jshint'); +var istanbul = require('gulp-istanbul'); +var plumber = require('gulp-plumber'); +var mocha = require('gulp-mocha'); +var coveralls = require('gulp-coveralls'); + +var handleErr = function(err) { console.log(err.message); process.exit(1); }; -gulp.task("static", function () { +gulp.task('check', function() { return gulp.src([ - "test/*.js", - "app/index.js", - "gulpfile.js" + 'test/*.js', + 'app/index.js', + 'gulpfile.js', + 'test/temp/test-gulp/gulpfile.js', + 'test/temp/test-jekyll/gulpfile.js', + 'test/temp/test-aws/gulpfile.js', + 'test/temp/test-rsync/gulpfile.js', + 'test/temp/test-pages/gulpfile.js' ]) - .pipe(jshint(".jshintrc")) - .pipe(jshint.reporter("jshint-stylish")) - .pipe(jshint.reporter("fail")) - .on("error", handleErr); + .pipe(jscs()) + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('jshint-stylish')) + .pipe(jshint.reporter('fail')) + .on('error', handleErr); }); -gulp.task("test", function (cb) { - gulp.src([ - "app/index.js" +gulp.task('test', function(done) { + return gulp.src([ + 'app/index.js', + 'gulpfile.js' ]) - .pipe(istanbul({ - includeUntested: true - })) + .pipe(istanbul()) .pipe(istanbul.hookRequire()) - .on("finish", function () { - gulp.src(["test/*.js"]) + .on('finish', function() { + gulp.src(['test/*.js']) .pipe(plumber()) .pipe(mocha({ - reporter: "spec" + reporter: 'spec' })) .pipe(istanbul.writeReports()) - .on("end", cb); + .on('end', done); }); }); -gulp.task("coveralls", ["test"], function () { - if (!process.env.CI) return; - return gulp.src(path.join(__dirname, "coverage/lcov.info")) +gulp.task('coveralls', function() { + if (!process.env.CI) { return; } + return gulp.src(path.join(__dirname, 'coverage/lcov.info')) .pipe(coveralls()); }); -gulp.task("default", ["static", "test", "coveralls"]); +gulp.task('default', gulp.series('check', 'coveralls')); +gulp.task('help', gulp.series('test', 'check', 'coveralls')); diff --git a/package.json b/package.json index e2aaa88..731e0ea 100644 --- a/package.json +++ b/package.json @@ -27,36 +27,33 @@ } ], "scripts": { - "test": "gulp" + "test": "gulp test && gulp" }, "dependencies": { - "chalk": "^0.5.1", + "chalk": "^1.0.0", "globule": "~0.2.0", - "shelljs": "~0.3.0", + "shelljs": "^0.4.0", "yeoman-generator": "^0.18.6", "yosay": "^1.0.2" }, "devDependencies": { "codeclimate-test-reporter": "0.0.4", "coveralls": "^2.11.2", - "gulp": "^3.8.10", + "generator-mocha": ">=0.1.6", + "gulp": "git://github.com:gulpjs/gulp.git#4.0", "gulp-coveralls": "^0.1.3", - "gulp-istanbul": "^0.6.0", + "gulp-istanbul": "^0.7.0", "gulp-jscs": "^1.4.0", "gulp-jshint": "^1.9.0", - "gulp-load-plugins": "^0.8.0", + "gulp-load-plugins": "^0.9.0", "gulp-mocha": "^2.0.0", - "gulp-plumber": "^0.6.6", + "gulp-plumber": "^1.0.0", "istanbul": "~0.3.5", "jshint": "^2.5.11", "jshint-stylish": "^1.0.0", - "mocha": "~2.1.0", - "mocha-lcov-reporter": "0.0.1" - }, - "peerDependencies": { - "generator-mocha": ">=0.1.6", - "yo": ">=1.3.3", - "gulp": ">=3.8.10" + "mocha": "^2.2.1", + "mocha-lcov-reporter": "0.0.2", + "yo": ">=1.4" }, "engines": { "node": ">=0.10", diff --git a/test/test-creation-aws.js b/test/test-creation-aws.js index 3d9f48c..ddfeb67 100755 --- a/test/test-creation-aws.js +++ b/test/test-creation-aws.js @@ -1,62 +1,61 @@ -/*global describe, before, it*/ -"use strict"; - -var path = require("path"); -var helpers = require("yeoman-generator").test; -var assert = require("yeoman-generator").assert; - -describe("Jekyllized generator test when using Amazon AWS", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-aws")) - .withArguments(["--skip-install"]) +'use strict'; + +var path = require('path'); +var helpers = require('yeoman-generator').test; +var assert = require('yeoman-generator').assert; + +describe('Jekyllized generator test when using Amazon AWS', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-aws')) + .withArguments(['--skip-install']) .withPrompt({ - uploadChoices: ["amazonCloudfrontS3"], - amazonKey: ["123123123123123"], - amazonSecret: ["14141414141414"], - amazonBucket: ["135135135135135"], - amazonDistID: ["2121212121212121"] + uploadChoices: ['amazonCloudfrontS3'], + amazonKey: ['123123123123123'], + amazonSecret: ['14141414141414'], + amazonBucket: ['135135135135135'], + amazonDistID: ['2121212121212121'] }) - .on("end", done); + .on('end', done); }); - it("creates expected files", function () { + it('creates expected files', function() { var expected = [ - "bower.json", - "package.json", - "gulpfile.js", - "src/index.html", - "src/robots.txt", - "src/assets/favicon.ico", - "src/assets/scss/style.scss", - "aws-credentials.json" + 'bower.json', + 'package.json', + 'gulpfile.js', + 'src/index.html', + 'src/robots.txt', + 'src/assets/favicon.ico', + 'src/assets/scss/style.scss', + 'aws-credentials.json' ]; - assert.file(expected); + assert.file(expected); }); - it("should contain the correct deploy function", function () { - assert.fileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); + it('should contain the correct deploy function', function() { + assert.fileContent('gulpfile.js', /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); }); - it("should NOT contain either the GH Pages or Rsync function", function () { - assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/); - assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/); + it('should NOT contain either the GH Pages or Rsync function', function() { + assert.noFileContent('gulpfile.js', /\/\/ Task to upload your site via Rsync to your server/); + assert.noFileContent('gulpfile.js', /\/\/ Task to upload your site to your personal GH Pages repo/); }); - it("should contain deploy tasks", function () { - assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/); + it('should contain deploy tasks', function() { + assert.fileContent('gulpfile.js', /gulp.task\(\'deploy\'/); }); - it("should contain the correct packages", function () { + it('should contain the correct packages', function() { var expected = [ - ["package.json", /\"concurrent-transform\"/], - ["package.json", /\"gulp-awspublish\"/], - ["package.json", /\"gulp-awspublish-router\"/], - ["package.json", /\"gulp-cloudfront\"/] + ['package.json', /\"concurrent-transform\"/], + ['package.json', /\"gulp-awspublish\"/], + ['package.json', /\"gulp-awspublish-router\"/], + ['package.json', /\"gulp-cloudfront\"/] ]; - assert.fileContent(expected); + assert.fileContent(expected); }); }); diff --git a/test/test-creation-ghpages.js b/test/test-creation-ghpages.js index d4d5fb6..4365169 100644 --- a/test/test-creation-ghpages.js +++ b/test/test-creation-ghpages.js @@ -1,50 +1,49 @@ -/*global describe, before, it*/ -"use strict"; - -var path = require("path"); -var helpers = require("yeoman-generator").test; -var assert = require("yeoman-generator").assert; - -describe("Jekyllized generator test when using GitHub Pages", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-pages")) - .withArguments(["--skip-install"]) +'use strict'; + +var path = require('path'); +var helpers = require('yeoman-generator').test; +var assert = require('yeoman-generator').assert; + +describe('Jekyllized generator test when using GitHub Pages', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-pages')) + .withArguments(['--skip-install']) .withPrompt({ - uploadChoices: ["githubPages"] + uploadChoices: ['githubPages'] }) - .on("end", done); + .on('end', done); }); - it("creates expected files", function () { + it('creates expected files', function() { var expected = [ - "bower.json", - "package.json", - "gulpfile.js", - "src/index.html", - "src/robots.txt", - "src/assets/favicon.ico", - "src/assets/scss/style.scss" + 'bower.json', + 'package.json', + 'gulpfile.js', + 'src/index.html', + 'src/robots.txt', + 'src/assets/favicon.ico', + 'src/assets/scss/style.scss' ]; - assert.file(expected); + assert.file(expected); }); - it("should contain the correct deploy function", function () { - assert.fileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/); + it('should contain the correct deploy function', function() { + assert.fileContent('gulpfile.js', /\/\/ Task to upload your site to your personal GH Pages repo/); }); - it("should NOT contain either the Amazon or Rsync function", function () { - assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/); - assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); + it('should NOT contain either the Amazon or Rsync function', function() { + assert.noFileContent('gulpfile.js', /\/\/ Task to upload your site via Rsync to your server/); + assert.noFileContent('gulpfile.js', /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); }); - it("should contain deploy tasks", function () { - assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/); + it('should contain deploy tasks', function() { + assert.fileContent('gulpfile.js', /gulp.task\(\'deploy\'/); }); - it("should contain the correct packages", function () { - assert.fileContent("package.json", /\"gulp-gh-pages\"/); + it('should contain the correct packages', function() { + assert.fileContent('package.json', /\"gulp-gh-pages\"/); }); }); diff --git a/test/test-creation-rsync.js b/test/test-creation-rsync.js index a801dfd..efa7aaa 100755 --- a/test/test-creation-rsync.js +++ b/test/test-creation-rsync.js @@ -1,54 +1,53 @@ -/*global describe, before, it*/ -"use strict"; - -var path = require("path"); -var helpers = require("yeoman-generator").test; -var assert = require("yeoman-generator").assert; - -describe("Jekyllized generator test when using Rsync", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-rsync")) - .withArguments(["--skip-install"]) +'use strict'; + +var path = require('path'); +var helpers = require('yeoman-generator').test; +var assert = require('yeoman-generator').assert; + +describe('Jekyllized generator test when using Rsync', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-rsync')) + .withArguments(['--skip-install']) .withPrompt({ - uploadChoices: ["rsync"], - rsyncUsername: ["olanordmann"], - rsyncHostname: ["example.com"], - rsyncDestination: ["/srv/www/example.com/public_html"] + uploadChoices: ['rsync'], + rsyncUsername: ['olanordmann'], + rsyncHostname: ['example.com'], + rsyncDestination: ['/srv/www/example.com/public_html'] }) - .on("end", done); + .on('end', done); }); - it("creates expected files", function () { + it('creates expected files', function() { var expected = [ - "bower.json", - "package.json", - "gulpfile.js", - "src/index.html", - "src/robots.txt", - "src/assets/favicon.ico", - "src/assets/scss/style.scss", - "rsync-credentials.json" + 'bower.json', + 'package.json', + 'gulpfile.js', + 'src/index.html', + 'src/robots.txt', + 'src/assets/favicon.ico', + 'src/assets/scss/style.scss', + 'rsync-credentials.json' ]; assert.file(expected); }); - it("should contain the correct deploy function", function () { - assert.fileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/); + it('should contain the correct deploy function', function() { + assert.fileContent('gulpfile.js', /\/\/ Task to upload your site via Rsync to your server/); }); - it("should NOT contain either the GH Pages or Amazon function", function () { - assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); - assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/); + it('should NOT contain either the GH Pages or Amazon function', function() { + assert.noFileContent('gulpfile.js', /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/); + assert.noFileContent('gulpfile.js', /\/\/ Task to upload your site to your personal GH Pages repo/); }); - it("should contain deploy tasks", function () { - assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/); + it('should contain deploy tasks', function() { + assert.fileContent('gulpfile.js', /gulp.task\(\'deploy\'/); }); - it("should contain the correct packages", function () { - assert.fileContent("package.json", /\"gulp-rsync\"/); + it('should contain the correct packages', function() { + assert.fileContent('package.json', /\"gulp-rsync\"/); }); }); diff --git a/test/test-gulp.js b/test/test-gulp.js index 970f50f..6ca985d 100644 --- a/test/test-gulp.js +++ b/test/test-gulp.js @@ -1,73 +1,98 @@ -/*global describe, before, it*/ -"use strict"; +'use strict'; -var path = require("path"); -var assert = require("assert"); -var helpers = require("yeoman-generator").test; +var path = require('path'); +var assert = require('assert'); +var helpers = require('yeoman-generator').test; -describe("Jekyllized generator test for Gulp tasks without any uploading", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-gulp")) - .withArguments(["--skip-install"]) +describe('Test for Gulp tasks without any uploading', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-gulp')) + .withArguments(['--skip-install']) .withPrompt({ - projectName: ["Mocha Test"], - projectDescription: ["Mocha tests for Jekyllized"], - projectTagline: ["Better hope this doesn\"t blow up"], - projectURL: ["testing.com"], - authorName: ["Ola Nordmann"], - authorEmail: ["ola.nordmann@email.com"], - authorBio: ["Just your average Norwegian"], - authorTwitter: ["olanordmann123123"], - jekyllPermalinks: ["pretty"], - jekyllPaginate: ["10"], - uploadChoices: ["noUpload"] + projectName: ['Mocha Test'], + projectDescription: ['Mocha tests for Jekyllized'], + projectTagline: ['Better hope this doesn\'t blow up'], + projectURL: ['testing.com'], + authorName: ['Ola Nordmann'], + authorEmail: ['ola.nordmann@email.com'], + authorBio: ['Just your average Norwegian'], + authorTwitter: ['olanordmann123123'], + jekyllPermalinks: ['pretty'], + jekyllPaginate: ['10'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("creates expected files", function () { + it('creates expected files', function() { var expected = [ - "bower.json", - "package.json", - "gulp.config.json", - "gulpfile.js", - "src/index.html", - "src/robots.txt", - "src/assets/favicon.ico", - "src/assets/scss/style.scss" + 'bower.json', + 'package.json', + 'gulp.config.json', + 'gulpfile.js', + 'src/index.html', + 'src/robots.txt', + 'src/assets/favicon.ico', + 'src/assets/scss/style.scss' ]; - assert.file(expected); + assert.file(expected); }); - it("does not create unexpected files", function () { + it('does not create unexpected files', function() { var unexpected = [ - "aws-credentials.json", - "rsync-redentials.json" + 'aws-credentials.json', + 'rsync-redentials.json' ]; - assert.noFile(unexpected); + assert.noFile(unexpected); }); - it ("should contain the standard tasks", function () { + it ('should contain the default functions', function() { var expected = [ - ["gulpfile.js", /gulp.task\(\"default\"/], - ["gulpfile.js", /gulp.task\(\"optimize\"/], - ["gulpfile.js", /gulp.task\(\"build\"/], - ["gulpfile.js", /gulp.task\(\"serve\"/], - ["gulpfile.js", /gulp.task\(\"clean\"/], - ["gulpfile.js", /gulp.task\(\"rebuild\"/], - ["gulpfile.js", /gulp.task\(\"styles\"/], - ["gulpfile.js", /gulp.task\(\"javascript\"/], - ["gulpfile.js", /gulp.task\(\"check\"/] + ['gulpfile.js', /function cleanDist\(done\)/], + ['gulpfile.js', /function cleanAssets\(done\)/], + ['gulpfile.js', /function rebuild\(done\)/], + ['gulpfile.js', /function jekyllDev\(done\)/], + ['gulpfile.js', /function jekyllProd\(done\)/], + ['gulpfile.js', /function styles\(\)/], + ['gulpfile.js', /function javascript\(\)/], + ['gulpfile.js', /function images\(\)/], + ['gulpfile.js', /function fonts\(\)/], + ['gulpfile.js', /function copy\(\)/], + ['gulpfile.js', /function optimize\(\)/], + ['gulpfile.js', /function jslint\(\)/], + ['gulpfile.js', /function doctor\(done\)/], + ['gulpfile.js', /function serve\(\)/] ]; - assert.fileContent(expected); + assert.fileContent(expected); }); - it("should NOT contain a deploy task", function () { - assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/); + it ('should contain the default tasks', function() { + var expected = [ + ['gulpfile.js', /gulp.task\(\'default\'/], + ['gulpfile.js', /gulp.task\(\'optimize\'/], + ['gulpfile.js', /gulp.task\(\'build\'/], + ['gulpfile.js', /gulp.task\(\'serve\'/], + ['gulpfile.js', /gulp.task\(\'clean\'/], + ['gulpfile.js', /gulp.task\(\'clean\:assets\'/], + ['gulpfile.js', /gulp.task\(\'rebuild\'/], + ['gulpfile.js', /gulp.task\(\'styles\'/], + ['gulpfile.js', /gulp.task\(\'javascript\'/], + ['gulpfile.js', /gulp.task\(\'check\'/] + ]; + + assert.fileContent(expected); + }); + + it('should NOT contain a deploy function', function() { + assert.noFileContent('gulpfile.js', /function deploy\(\)/); + }); + + it('should NOT contain a deploy task', function() { + assert.noFileContent('gulpfile.js', /gulp.task\(\'deploy\'/); }); }); diff --git a/test/test-jekyll.js b/test/test-jekyll.js index 9199c5f..64ecfb3 100644 --- a/test/test-jekyll.js +++ b/test/test-jekyll.js @@ -1,144 +1,143 @@ -/*global describe, before, it*/ -"use strict"; - -var path = require("path"); -var helpers = require("yeoman-generator").test; -var assert = require("yeoman-generator").assert; - -describe("Jekyllized generator", function () { - describe("test for Jekyll settings", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-jekyll")) - .withArguments(["--skip-install"]) +'use strict'; + +var path = require('path'); +var helpers = require('yeoman-generator').test; +var assert = require('yeoman-generator').assert; + +describe('Jekyllized generator', function() { + describe('test for Jekyll settings', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-jekyll')) + .withArguments(['--skip-install']) .withPrompt({ - projectName: ["Mocha Test"], - projectDescription: ["Mocha tests for Jekyllized"], - projectTagline: ["Better hope this doesn\"t blow up"], - projectURL: ["testing.com"], - authorName: ["Ola Nordmann"], - authorEmail: ["ola.nordmann@email.com"], - authorBio: ["Just your average Norwegian"], - authorTwitter: ["olanordmann123123"], - jekyllPermalinks: ["pretty"], - jekyllPaginate: ["10"], - uploadChoices: ["noUpload"] + projectName: ['Mocha Test'], + projectDescription: ['Mocha tests for Jekyllized'], + projectTagline: ['Better hope this doesn\'t blow up'], + projectURL: ['testing.com'], + authorName: ['Ola Nordmann'], + authorEmail: ['ola.nordmann@email.com'], + authorBio: ['Just your average Norwegian'], + authorTwitter: ['olanordmann123123'], + jekyllPermalinks: ['pretty'], + jekyllPaginate: ['10'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("creates the expected files", function () { + it('creates the expected files', function() { var expected = [ - "src/404.html", - "src/about.md", - "src/feed.xml", - "src/crossdomain.xml", - "src/humans.txt", - "src/index.html", - "src/robots.txt" + 'src/404.html', + 'src/about.md', + 'src/feed.xml', + 'src/crossdomain.xml', + 'src/humans.txt', + 'src/index.html', + 'src/robots.txt' ]; - assert.file(expected); + assert.file(expected); }); - it("gulpfile.js does NOT contain a deploy task", function () { - assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/); + it('gulpfile.js does NOT contain a deploy task', function() { + assert.noFileContent('gulpfile.js', /gulp.task\(\'deploy\'/); }); - it("_config.yml contains the correct settings", function () { + it('_config.yml contains the correct settings', function() { var expected = [ - ["_config.yml", /title\: Mocha Test/], - ["_config.yml", /description\: Mocha tests for Jekyllized/], - ["_config.yml", /tagline\: Better hope this doesn\"t blow up/], - ["_config.yml", /name\: Ola Nordmann/], - ["_config.yml", /email\: ola\.nordmann\@email\.com/], - ["_config.yml", /bio\: Just your average Norwegian/], - ["_config.yml", /twitter\: olanordmann123123/] + ['_config.yml', /title\: Mocha Test/], + ['_config.yml', /description\: Mocha tests for Jekyllized/], + ['_config.yml', /tagline\: Better hope this doesn\'t blow up/], + ['_config.yml', /name\: Ola Nordmann/], + ['_config.yml', /email\: ola\.nordmann\@email\.com/], + ['_config.yml', /bio\: Just your average Norwegian/], + ['_config.yml', /twitter\: olanordmann123123/] ]; - assert.fileContent(expected); + assert.fileContent(expected); }); - it("_config.build.yml contains the correct settings", function () { + it('_config.build.yml contains the correct settings', function() { var expected = [ - ["_config.build.yml", /future\: false/], - ["_config.build.yml", /show_drafts\: false/], - ["_config.build.yml", /lsi\: true/], - ["_config.build.yml", /limit_posts\: 0/], - ["_config.build.yml", /source\: src/], - ["_config.build.yml", /destination\: dist/] + ['_config.build.yml', /future\: false/], + ['_config.build.yml', /show_drafts\: false/], + ['_config.build.yml', /lsi\: true/], + ['_config.build.yml', /limit_posts\: 0/], + ['_config.build.yml', /source\: src/], + ['_config.build.yml', /destination\: dist/] ]; - assert.fileContent(expected); + assert.fileContent(expected); }); }); - describe("test with setting pretty permalinks and 10 posts per page", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-jekyll-pagination")) - .withArguments(["--skip-install"]) + describe('test with pretty permalinks and 10 posts per page', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-jekyll-pagination')) + .withArguments(['--skip-install']) .withPrompt({ - jekyllPermalinks: ["pretty"], - jekyllPaginate: ["10"], - uploadChoices: ["noUpload"] + jekyllPermalinks: ['pretty'], + jekyllPaginate: ['10'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("_config.yml permalink setting is 'pretty'", function () { - assert.fileContent("_config.yml", /permalink\: pretty/); + it('_config.yml permalink setting is "pretty"', function() { + assert.fileContent('_config.yml', /permalink\: pretty/); }); - it("_config.yml pagination is '10' posts per page", function () { - assert.fileContent("_config.yml", /paginate\: 10/); + it('_config.yml pagination is "10" posts per page', function() { + assert.fileContent('_config.yml', /paginate\: 10/); }); }); - describe("test with setting date permalinks and all posts on the same page", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-jekyll-pagination-1")) - .withArguments(["--skip-install"]) + describe('test with date permalinks and all posts together', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-jekyll-pagination-1')) + .withArguments(['--skip-install']) .withPrompt({ - jekyllPermalinks: ["date"], - jekyllPaginate: ["all"], - uploadChoices: ["noUpload"] + jekyllPermalinks: ['date'], + jekyllPaginate: ['all'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("_config.yml permalink setting is 'date'", function () { - assert.fileContent("_config.yml", /permalink\: date/); + it('_config.yml permalink setting is "date"', function() { + assert.fileContent('_config.yml', /permalink\: date/); }); - it("_config.yml pagination is 'all' posts per page", function () { - assert.fileContent("_config.yml", /paginate\: all/); + it('_config.yml pagination is "all" posts per page', function() { + assert.fileContent('_config.yml', /paginate\: all/); }); }); - describe("test with no permalinks setting and 1 post per page", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-jekyll-pagination-2")) - .withArguments(["--skip-install"]) + describe('test with no permalinks setting and 1 post per page', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-jekyll-pagination-2')) + .withArguments(['--skip-install']) .withPrompt({ - jekyllPermalinks: ["none"], - jekyllPaginate: ["1"], - uploadChoices: ["noUpload"] + jekyllPermalinks: ['none'], + jekyllPaginate: ['1'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("_config.yml permalink setting is 'none'", function () { - assert.fileContent("_config.yml", /permalink\: none/); + it('_config.yml permalink setting is "none"', function() { + assert.fileContent('_config.yml', /permalink\: none/); }); - it("_config.yml pagination is '1' posts per page", function () { - assert.fileContent("_config.yml", /paginate\: 1/); + it('_config.yml pagination is "1" posts per page', function() { + assert.fileContent('_config.yml', /paginate\: 1/); }); }); diff --git a/test/test-load.js b/test/test-load.js index 8b49714..dc2b04a 100644 --- a/test/test-load.js +++ b/test/test-load.js @@ -1,11 +1,10 @@ -/*global describe, it*/ -"use strict"; +'use strict'; -var assert = require("assert"); +var assert = require('assert'); -describe("Jekyllized generator", function () { - it("can be imported without blowing up", function () { - var app = require("../app"); +describe('Jekyllized generator', function() { + it('can be imported without blowing up', function() { + var app = require('../app'); assert(app !== undefined); }); }); diff --git a/test/test-package.js b/test/test-package.js index 45f6ccd..75d8154 100644 --- a/test/test-package.js +++ b/test/test-package.js @@ -1,38 +1,37 @@ -/*global describe, before, it*/ -"use strict"; +'use strict'; -var path = require("path"); -var assert = require("assert"); -var helpers = require("yeoman-generator").test; +var path = require('path'); +var assert = require('assert'); +var helpers = require('yeoman-generator').test; -describe("Jekyllized generator test for package.json", function () { - before(function (done) { - helpers.run(path.join(__dirname, "../app")) - .inDir(path.join(__dirname, "./temp/test-package")) - .withArguments(["--skip-install"]) +describe('Jekyllized generator test for package.json', function() { + before(function(done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(__dirname, './temp/test-package')) + .withArguments(['--skip-install']) .withPrompt({ - projectName: ["Package Test"], - projectDescription: ["Package tests for Jekyllized"], - projectTagline: ["Better hope this doesn\"t blow up"], - projectURL: ["testing.com"], - authorName: ["Ola Nordmann"], - authorEmail: ["ola.nordmann@email.com"], - authorBio: ["Just your average Norwegian"], - authorTwitter: ["olanordmann123123"], - jekyllPermalinks: ["pretty"], - jekyllPaginate: ["10"], - uploadChoices: ["noUpload"] + projectName: ['Package Test'], + projectDescription: ['Package tests for Jekyllized'], + projectTagline: ['Better hope this doesn\'t blow up'], + projectURL: ['testing.com'], + authorName: ['Ola Nordmann'], + authorEmail: ['ola.nordmann@email.com'], + authorBio: ['Just your average Norwegian'], + authorTwitter: ['olanordmann123123'], + jekyllPermalinks: ['pretty'], + jekyllPaginate: ['10'], + uploadChoices: ['noUpload'] }) - .on("end", done); + .on('end', done); }); - it("should contain the proper names and version", function () { + it('should contain the proper names and version', function() { var expected = [ - ["package.json", /\"name\"\: \"test-package\"/], - ["package.json", /\"description\"\: \"Yeoman workflow for test package\"/] + ['package.json', /\"name\"\: \"test-package\"/], + ['package.json', /\"description\"\: \"Yeoman workflow for test package\"/] ]; - assert.fileContent(expected); + assert.fileContent(expected); }); });