From 0979df8b45fe95d83f57e41a8e644fb3e7d44b0f Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Mon, 13 Jan 2014 19:24:43 +0800 Subject: [PATCH 01/13] Docs: add init option --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8c97652..d94f492 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ yo assemble #### Options +* `-i` alias `--init` + + Force to prompt question and re-initialize `.yo-rc.json`. + * `-s` alias `--skip-install` Skips the automatic execution of `bower` and `npm` after scaffolding has finished. From 65cc9a5a74328312119a78e7b2d093fb7cf31273 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Mon, 13 Jan 2014 19:25:38 +0800 Subject: [PATCH 02/13] Rename to plugins --- app/index.js | 6 +++--- app/templates/Gruntfile.js | 6 +++--- app/templates/_package.json | 8 ++++---- test/test-creation.js | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/index.js b/app/index.js index 6bd0a8e..3c039ab 100644 --- a/app/index.js +++ b/app/index.js @@ -109,7 +109,7 @@ AssembleGenerator.prototype.askFor = function askFor() { }); questions.push({ - name : "plugin", + name : "plugins", type : "checkbox", message : "Which plugins would you like to include?", choices : [ @@ -130,8 +130,8 @@ AssembleGenerator.prototype.askFor = function askFor() { this.projectName = answers.projectName || this.config.get("projectName"); this.projectDesc = answers.projectDesc || this.config.get("projectDesc"); this.authorLogin = answers.githubUser || this.config.get("githubUser"); - this.plugin = answers.plugin; - this.authorName = this.config.get("author").name; + this.plugins = answers.plugins; + this.authorName = this.config.get("author").name; this.authorEmail = this.config.get("author").email; //save config to .yo-rc.json diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index db7d754..9e32520 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -69,9 +69,9 @@ module.exports = function(grunt) { assets: '<%%= config.dist %>/assets', layout: '<%%= config.src %>/templates/layouts/default.hbs', data: '<%%= config.src %>/data/*.{json,yml}', - partials: '<%%= config.src %>/templates/partials/*.hbs'<% if(plugin && plugin.length > 0){ %>, - plugins: [<% if(typeof plugin === 'object'){ _.each(plugin, function(name, i) { %>'<%= name %>'<% if(i < (plugin.length - 1)) { %>,<% } }); } else { %>'<%= name %>'<%} %>],<%} - _.each(plugin, function(name, i) { if(name == 'permalinks') { %> + partials: '<%%= config.src %>/templates/partials/*.hbs'<% if(plugins && plugins.length > 0){ %>, + plugins: [<% if(typeof plugins === 'object'){ _.each(plugins, function(name, i) { %>'<%= name %>'<% if(i < (plugins.length - 1)) { %>,<% } }); } else { %>'<%= name %>'<%} %>],<%} + _.each(plugins, function(name, i) { if(name == 'permalinks') { %> permalinks: { preset: 'pretty' },<% } diff --git a/app/templates/_package.json b/app/templates/_package.json index a7ca1c2..e92fcf8 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -27,11 +27,11 @@ "grunt-contrib-connect": "~0.6.0", "grunt-contrib-watch": "~0.5.3", "load-grunt-tasks": "~0.2.1", - "time-grunt": "~0.2.7"<% if(plugin && plugin.length > 0){ %>, - <% if(typeof plugin === 'object'){ _.each(plugin, function(name, i) { %> - "<%= name %>": "*"<% if(i < (plugin.length - 1)) { %>,<% } %> + "time-grunt": "~0.2.7"<% if(plugins && plugins.length > 0){ %>, + <% if(typeof plugins === 'object'){ _.each(plugins, function(name, i) { %> + "<%= name %>": "*"<% if(i < (plugins.length - 1)) { %>,<% } %> <% }); } else { %> - "<%= plugin %>": "*" + "<%= plugins %>": "*" <%} } %> }, "licenses": [ diff --git a/test/test-creation.js b/test/test-creation.js index 1233a79..f774ae6 100644 --- a/test/test-creation.js +++ b/test/test-creation.js @@ -47,7 +47,7 @@ describe('Assemble generator', function () { helpers.mockPrompt(this.app, { projectName: 'assemble', githubUser: 'assemble', - plugin: ['permalinks', 'sitemap'] + plugins: ['permalinks', 'sitemap'] }); this.app.run({}, function () { From 6638aa565071a120e96d49d67662feba2a6bf239 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Mon, 13 Jan 2014 19:43:31 +0800 Subject: [PATCH 03/13] Add boilerplate directory structure --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index d94f492..3686511 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,39 @@ yo assemble Skips app welcome message. +## Boilerplate +The following directory structure do you get after run `yo assemble`: + + . + ├── .editorconfig + ├── .gitignore + ├── .yo-rc.json + ├── AUTHORS + ├── CHANGELOG + ├── Gruntfile.js + ├── LICENSE-MIT + ├── package.json + ├── README.md + ├── dist + │ ├── assets + │ │ ├── assemble.css + │ │ ├── github.css + │ │ └── highlight.js + ├── src + │ ├── content + │ │ └── markdown.md + │ ├── data + │ │ └── site.yml + │ └── templates + │ ├── layouts + │ │ └── default.md + │ ├── pages + │ │ ├── index.hbs + │ │ └── blog.hbs + │ └── partials + │ └── navbar-fixed-top.hbs + └── node_modules + ## Alternative * [grunt-init-assemble](https://github.com/assemble/grunt-init-assemble) From 2357f39947f655b799f42ddba16d68b735148299 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Mon, 13 Jan 2014 20:50:17 +0800 Subject: [PATCH 04/13] Fix assemle plugins missing from package.json When user run `yo assemble` again, question is not prompt which cause all plugins removed from package.json. Also run `grunt build` after successful npm/bower install --- app/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/index.js b/app/index.js index 3c039ab..74aa95f 100644 --- a/app/index.js +++ b/app/index.js @@ -28,7 +28,10 @@ var AssembleGenerator = module.exports = function AssembleGenerator(args, option this.on('end', function () { this.installDependencies({ skipInstall: options['skip-install'] || options['s'], - skipMessage: options['skip-welcome-message'] || options['w'] + skipMessage: options['skip-welcome-message'] || options['w'], + callback: function () { + this.spawnCommand('grunt', ['build']); + }.bind(this) // only run grunt build after succesful npm/bower install }); }); @@ -130,7 +133,7 @@ AssembleGenerator.prototype.askFor = function askFor() { this.projectName = answers.projectName || this.config.get("projectName"); this.projectDesc = answers.projectDesc || this.config.get("projectDesc"); this.authorLogin = answers.githubUser || this.config.get("githubUser"); - this.plugins = answers.plugins; + this.plugins = answers.plugins || this.config.get("plugins"); this.authorName = this.config.get("author").name; this.authorEmail = this.config.get("author").email; From 17ace65fad16e4d32d9d0b740c710226540a5aff Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Tue, 14 Jan 2014 16:05:23 +0800 Subject: [PATCH 05/13] Borrow project description from from github description --- README.md | 2 +- app/index.js | 5 ++--- package.json | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d94f492..93286d6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## Usage -### Assemble app scaffolds. +Creates an Assemble boilerplate projects. ```bash mkdir project && cd $_ diff --git a/app/index.js b/app/index.js index 74aa95f..9fbab0c 100644 --- a/app/index.js +++ b/app/index.js @@ -12,7 +12,8 @@ var AssembleGenerator = module.exports = function AssembleGenerator(args, option yeoman.generators.Base.apply(this, arguments); - this.description = 'Creates a default Assemble boilerplate'; + this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); + this.description = this.pkg.description; // Not required but need to show when user command `yo assemble -h` this.option('init', { @@ -37,8 +38,6 @@ var AssembleGenerator = module.exports = function AssembleGenerator(args, option this.files = this.expandFiles('**/*', { cwd: this.sourceRoot(), dot: true }); - this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); - this.dotFiles = [ 'gitignore', 'gitattributes', diff --git a/package.json b/package.json index 48780b7..cb0e062 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "generator-assemble", "version": "0.4.6", - "description": "The scaffolding for Assemble", + "description": "Assemble, the static site generator built on Grunt.js. Kickstart new Assemble projects in just a few seconds, including templates, data, layouts, and a theme.", "keywords": [ "yeoman-generator", "assemble", From 2ebe2787160caf6f27a554009773fca97cc8903d Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Tue, 14 Jan 2014 23:25:07 +0800 Subject: [PATCH 06/13] Make plugin listing more dynamic and checked from previous choice --- app/index.js | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/app/index.js b/app/index.js index 9fbab0c..df1c79c 100644 --- a/app/index.js +++ b/app/index.js @@ -47,8 +47,18 @@ var AssembleGenerator = module.exports = function AssembleGenerator(args, option this.pkgFiles = ['_package.json']; + this.defaultPlugins = { + "assemble-contrib-anchors": true, + "assemble-contrib-permalinks": true, + "assemble-contrib-sitemap": true, + "assemble-contrib-toc": true, + "assemble-markdown-data": false, + "assemble-related-pages": false + }; + this.config.defaults({ projectName : "", + projectDesc : "The best project ever.", githubUser : "assemble", installPlugin : true, author: { @@ -110,18 +120,43 @@ AssembleGenerator.prototype.askFor = function askFor() { default : this.config.get("installPlugin") }); + // for first time/re-init, make new list of defaultPlugins + if(!this.config.get("installPlugin") || force) { + + var plugins = this.config.get("plugins"); + + // if we have previous plugin choice + if (plugins instanceof Array) { + var defaultPlugins = {}; + + // convert it to object and assign checked + plugins.forEach(function(plugin) { + defaultPlugins[plugin] = true; + }); + + // concat with defautPlugins + for (var key in defaultPlugins) { + this.defaultPlugins[key] = defaultPlugins[key]; + } + } + + } + + var choices = []; + var pluginObj = this.defaultPlugins; + + // make choice more dynamic and checked from previous choice + for (var plugin in pluginObj) { + if(pluginObj.hasOwnProperty(plugin)){ + choices.push({ name: plugin, checked: pluginObj[plugin] }); + } + } + questions.push({ name : "plugins", type : "checkbox", message : "Which plugins would you like to include?", - choices : [ - { name: "assemble-contrib-anchors", checked: true }, - { name: "assemble-contrib-permalinks", checked: true }, - { name: "assemble-contrib-sitemap", checked: true }, - { name: "assemble-contrib-toc", checked: true }, - { name: "assemble-markdown-data" }, - { name: "assemble-related-pages" }, - ], + choices : choices, when: function( answers ) { return answers.installPlugin; } From 1ab592f84977be013d960c7304a4246ecd3c0798 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Wed, 15 Jan 2014 11:11:07 +0800 Subject: [PATCH 07/13] Remove support for Node < 0.10 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2cdacaf..244b7e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ language: node_js node_js: - '0.10' - - '0.8' From 74a7ebc569c907f1426bac1089587242266bf4cb Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Wed, 15 Jan 2014 12:08:08 +0800 Subject: [PATCH 08/13] Docs: what include in boilerplate --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e75bd5b..5674954 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,16 @@ yo assemble Skips app welcome message. + +## Include in boilerplate +* time-grunt +* grunt-contrib-clean +* grunt-contrib-connect +* grunt-contrib-watch + + ## Boilerplate -The following directory structure do you get after run `yo assemble`: +The following directory structure generated after run `yo assemble`: . ├── .editorconfig From 99dd738902aa85aac137ba0f665642c07fbef1f6 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Wed, 15 Jan 2014 12:21:09 +0800 Subject: [PATCH 09/13] Fix package description. Add plugin and helper to related generator --- README.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5674954..e1c946c 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,10 @@ The following directory structure generated after run `yo assemble`: │ └── navbar-fixed-top.hbs └── node_modules -## Alternative +## Related + * [Helper generator for Assemble](https://github.com/assemble/generator-helper). + * [Plugin generator for Assemble](https://github.com/assemble/generator-plugin) * [grunt-init-assemble](https://github.com/assemble/grunt-init-assemble) diff --git a/package.json b/package.json index cb0e062..d9773e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "generator-assemble", "version": "0.4.6", - "description": "Assemble, the static site generator built on Grunt.js. Kickstart new Assemble projects in just a few seconds, including templates, data, layouts, and a theme.", + "description": "Yeoman generator for Assemble, the static site generator built on Grunt.js. Kickstart new Assemble projects in just a few seconds, including templates, data, layouts, and a theme.", "keywords": [ "yeoman-generator", "assemble", From a0bbd412231887a1b32f7138a2204cff26d6bcf0 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Thu, 16 Jan 2014 15:22:24 +0800 Subject: [PATCH 10/13] Remove support for node 0.8 --- app/USAGE | 5 +++-- package.json | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/USAGE b/app/USAGE index d6037a9..e35c366 100644 --- a/app/USAGE +++ b/app/USAGE @@ -1,3 +1,4 @@ Example: - yo assemble --init --skip-install --skip-welcome-message - yo assemble -i -s -w (alias) + yo assemble + yo assemble [--init] [--skip-install] [--skip-welcome-message] + yo assemble [-i] [-s] [-w] diff --git a/package.json b/package.json index d9773e2..ef44e29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "generator-assemble", "version": "0.4.6", - "description": "Yeoman generator for Assemble, the static site generator built on Grunt.js. Kickstart new Assemble projects in just a few seconds, including templates, data, layouts, and a theme.", + "description": "Creates an Assemble boilerplate projects.", "keywords": [ "yeoman-generator", "assemble", @@ -11,8 +11,7 @@ "bugs": "https://github.com/assemble/generator-assemble/issues", "author": { "name": "Hariadi Hinta", - "email": "diperakui@yahoo.com", - "url": "http://hariadi.org" + "email": "diperakui@yahoo.com" }, "main": "app/index.js", "repository": { @@ -29,10 +28,10 @@ "mocha": "*" }, "peerDependencies": { - "yo": ">=1.0.4" + "yo": ">=1.0.0" }, "engines": { - "node": ">=0.8.0", + "node": ">=0.10.0", "npm": ">=1.2.10" }, "licenses": [ From 1820f3fb3f06ab08084601e7d76aa126d50824c9 Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Thu, 16 Jan 2014 17:16:27 +0800 Subject: [PATCH 11/13] Updating docs --- .gitattributes | 6 ------ .gitignore | 1 - README.md | 4 ++-- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1c2ab0f..6e36f63 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,3 @@ -# Set default behaviour, in case users don't have core.autocrlf set. * text=lf * text eol=lf *.* eol=lf - -*.jpg binary -*.gif binary -*.png binary -*.jpeg binary diff --git a/.gitignore b/.gitignore index 608c2bb..dc0d794 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ node_modules/ temp/ *.sublime-project *.sublime-workspace -.jshintrc diff --git a/README.md b/README.md index e1c946c..448ecaf 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ The following directory structure generated after run `yo assemble`: ## Related - * [Helper generator for Assemble](https://github.com/assemble/generator-helper). - * [Plugin generator for Assemble](https://github.com/assemble/generator-plugin) + * [Assemble Helper generator](https://github.com/assemble/generator-helper) + * [Assemble Plugin generator](https://github.com/assemble/generator-plugin) * [grunt-init-assemble](https://github.com/assemble/grunt-init-assemble) From eadfb8b3208b0c6b9dc71d0d58e245234486852f Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Sat, 18 Jan 2014 21:24:48 +0800 Subject: [PATCH 12/13] Use underscore --- app/index.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/index.js b/app/index.js index df1c79c..25b32ff 100644 --- a/app/index.js +++ b/app/index.js @@ -76,7 +76,6 @@ util.inherits(AssembleGenerator, yeoman.generators.Base); * Command prompt questions * Extend defaults and options based on user answers */ - AssembleGenerator.prototype.askFor = function askFor() { var done = this.async(); @@ -122,30 +121,26 @@ AssembleGenerator.prototype.askFor = function askFor() { // for first time/re-init, make new list of defaultPlugins if(!this.config.get("installPlugin") || force) { - var plugins = this.config.get("plugins"); - // if we have previous plugin choice - if (plugins instanceof Array) { + if (this._.isArray(plugins)) { var defaultPlugins = {}; - // convert it to object and assign checked plugins.forEach(function(plugin) { defaultPlugins[plugin] = true; }); - // concat with defautPlugins for (var key in defaultPlugins) { this.defaultPlugins[key] = defaultPlugins[key]; } } - } var choices = []; var pluginObj = this.defaultPlugins; // make choice more dynamic and checked from previous choice + // TODO: fetch from npm with "assembleplugin" keyword for (var plugin in pluginObj) { if(pluginObj.hasOwnProperty(plugin)){ choices.push({ name: plugin, checked: pluginObj[plugin] }); @@ -182,7 +177,6 @@ AssembleGenerator.prototype.askFor = function askFor() { * TODO: Separate file generated with their own function. See test-creation.js * Copy boilerplate main code */ - AssembleGenerator.prototype.app = function app() { var files = this.files; @@ -205,7 +199,6 @@ AssembleGenerator.prototype.app = function app() { /** * Stringify an object and normalize whitespace with project preferences. */ - AssembleGenerator.prototype.normalizeJSON = function() { var pkgFile = path.join(this.destinationRoot(process.cwd()), 'package.json'); var pkgObj = this.read(pkgFile); From 3c480a74930c1893e4f4e2b1c096c316fee7c42a Mon Sep 17 00:00:00 2001 From: Hariadi Hinta Date: Mon, 20 Jan 2014 14:18:55 +0800 Subject: [PATCH 13/13] v0.4.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef44e29..ae45602 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-assemble", - "version": "0.4.6", + "version": "0.4.7", "description": "Creates an Assemble boilerplate projects.", "keywords": [ "yeoman-generator",