├── app
├── templates
│ ├── gitattributes
│ ├── site.yml
│ ├── AUTHORS
│ ├── blog.hbs
│ ├── _bower.json
│ ├── gitignore
│ ├── CHANGELOG
│ ├── editorconfig
│ ├── theme.css
│ ├── index.hbs
│ ├── README.md
│ ├── LICENSE-MIT
│ ├── markdown.md
│ ├── layout.hbs
│ ├── _package.json
│ ├── inc-navbar-fixed-top.hbs
│ └── Gruntfile.js
├── USAGE
└── index.js
├── .gitattributes
├── .travis.yml
├── .gitignore
├── .npmignore
├── .editorconfig
├── test
├── test-load.js
└── test-creation.js
├── package.json
└── README.md
/app/templates/gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=lf
2 | * text eol=lf
3 | *.* eol=lf
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '0.10'
4 |
--------------------------------------------------------------------------------
/app/templates/site.yml:
--------------------------------------------------------------------------------
1 | title: <%= _.capitalize(projectName) %>
2 |
--------------------------------------------------------------------------------
/app/templates/AUTHORS:
--------------------------------------------------------------------------------
1 | <%= authorName %> (https://github.com/<%= authorLogin %>)
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | temp/
3 | *.sublime-project
4 | *.sublime-workspace
5 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .npmignore
2 | .editorconfig
3 | .travis.yml
4 | .jshintrc
5 | .gitattributes
6 | test
7 | src/
8 | .jshintrc
9 |
--------------------------------------------------------------------------------
/app/USAGE:
--------------------------------------------------------------------------------
1 | Example:
2 | yo assemble
3 | yo assemble [--init] [--skip-install] [--skip-welcome-message]
4 | yo assemble [-i] [-s] [-w]
5 |
--------------------------------------------------------------------------------
/app/templates/blog.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: Blog
3 | posts: ['README.md']
4 | ---
5 |
Posts
6 | {{#each posts}}
7 | {{md this}}
8 | {{/each}}
9 |
--------------------------------------------------------------------------------
/app/templates/_bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(projectName) %>",
3 | "version": "0.1.0",
4 | "dependencies": {
5 | "bootstrap": "~3.2.0"
6 | },
7 | "private": true
8 | }
9 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/app/templates/gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 | *.yo-rc.json
10 |
11 | pids
12 | logs
13 | results
14 |
15 | npm-debug.log
16 | node_modules
17 |
18 | *.sublime-*
19 |
--------------------------------------------------------------------------------
/app/templates/CHANGELOG:
--------------------------------------------------------------------------------
1 | v0.1.0:
2 | date: "<%= (new Date).toISOString().split('T')[0] %>"
3 | changes:
4 | - Generated by the [Yeoman Generator](https://github.com/assemble/generator-assemble) for [Assemble](http://assemble.io)
5 |
--------------------------------------------------------------------------------
/test/test-load.js:
--------------------------------------------------------------------------------
1 | /*global describe, beforeEach, it*/
2 | 'use strict';
3 |
4 | var assert = require('assert');
5 |
6 | describe('Assemble generator', function () {
7 | it('creates expected files with basic option', function () {
8 | var assemble = require('../app');
9 | assert(assemble !== undefined);
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/app/templates/editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 |
3 | root = true
4 |
5 | [*]
6 | indent_style = space
7 | indent_size = 2
8 | end_of_line = lf
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 |
13 | # Trailing whitespace is significant in markdown files.
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/app/templates/theme.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 70px;
3 | padding-bottom: 30px;
4 | }
5 |
6 | .theme-dropdown .dropdown-menu {
7 | position: static;
8 | display: block;
9 | margin-bottom: 20px;
10 | }
11 |
12 | .theme-showcase > p > .btn {
13 | margin: 5px 0;
14 | }
15 |
16 | .theme-showcase .navbar .container {
17 | width: auto;
18 | }
19 |
--------------------------------------------------------------------------------
/app/templates/index.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: Home
3 | heading: 'Yo, Assemble!'
4 | lead: Welcome to my blog!
5 | ---
6 |
7 |
{{ heading }}
8 |
This is a Assemble Generator template using Bootstrap . It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.
9 |
Learn more »
10 |
11 |
--------------------------------------------------------------------------------
/app/templates/README.md:
--------------------------------------------------------------------------------
1 | # <%= _.slugify(projectName) %>
2 |
3 | > <%= _.capitalize(projectDesc) %>.
4 |
5 | ## [Assemble](http://assemble.io/)
6 |
7 | Assemble is a component and static site generator that makes it dead simple to build modular sites, documentation and components from reusable templates and data.
8 |
9 | * Documentation
10 | * Plugins - Plugins extend the core functionality of Assemble.
11 | * Helpers - Documentation for the helpers in the [handlebars-helpers](http://github.com/assemble/handlebars-helpers) library.
12 |
13 | ## Contributing
14 | All contributions are welcome! The simplest way to show your support for this project is to **"star" it**. Please see [Contributing to Assemble](http://assemble.io/contributing) for more information.
15 |
16 | ## Release History
17 | * <%= (new Date).toISOString().split('T')[0] %> v0.1.0 Generated by the [Yeoman Generator](https://github.com/assemble/generator-assemble) for [Assemble](http://assemble.io)
18 |
--------------------------------------------------------------------------------
/app/templates/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Copyright (c) <%= (new Date).getFullYear() %> <%= pkg.author.name %>, contributors.
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-assemble",
3 | "version": "0.5.0",
4 | "description": "Create new Assemble projects.",
5 | "author": {
6 | "name": "Hariadi Hinta",
7 | "url": "https://github.com/hariadi",
8 | "email": "diperakui@yahoo.com"
9 | },
10 | "licenses": [
11 | {
12 | "type": "MIT",
13 | "url": "https://github.com/assemble/assemble/blob/master/LICENSE-MIT"
14 | }
15 | ],
16 | "homepage": "https://github.com/assemble/generator-assemble",
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/assemble/generator-assemble.git"
20 | },
21 | "bugs": {
22 | "url": "https://github.com/assemble/generator-assemble/issues"
23 | },
24 | "main": "app/index.js",
25 | "scripts": {
26 | "test": "mocha --reporter spec"
27 | },
28 | "dependencies": {
29 | "yeoman-generator": "^0.17.5"
30 | },
31 | "devDependencies": {
32 | "mocha": "*"
33 | },
34 | "peerDependencies": {
35 | "yo": ">=1.0.0"
36 | },
37 | "engines": {
38 | "node": ">=0.10.0",
39 | "npm": ">=1.2.10"
40 | },
41 | "keywords": [
42 | "yeoman-generator",
43 | "assemble",
44 | "generator",
45 | "boilerplate",
46 | "grunt"
47 | ]
48 | }
49 |
--------------------------------------------------------------------------------
/app/templates/markdown.md:
--------------------------------------------------------------------------------
1 | [test]: http://google.com/ "Google"
2 |
3 | # A heading
4 |
5 | Just a note, I've found that I can't test my markdown parser vs others.
6 | For example, both markdown.js and showdown code blocks in lists wrong. They're
7 | also completely [inconsistent][test] with regards to paragraphs in list items.
8 |
9 | A link. Not anymore.
10 |
11 | This will make me fail the test because
12 | markdown.js doesnt acknowledge arbitrary html blocks =/
13 |
14 | * List Item 1
15 |
16 | * List Item 2
17 | * New List Item 1
18 | Hi, this is a list item.
19 | * New List Item 2
20 | Another item
21 | Code goes here.
22 | Lots of it...
23 | * New List Item 3
24 | The last item
25 |
26 | * List Item 3
27 | The final item.
28 |
29 | * List Item 4
30 | The real final item.
31 |
32 | Paragraph.
33 |
34 | > * bq Item 1
35 | > * bq Item 2
36 | > * New bq Item 1
37 | > * New bq Item 2
38 | > Text here
39 |
40 | * * *
41 |
42 | > Another blockquote!
43 | > I really need to get
44 | > more creative with
45 | > mockup text..
46 | > markdown.js breaks here again
47 |
48 | Another Heading
49 | -------------
50 |
51 | Hello *world*. Here is a [link](//hello).
52 | And an image .
53 |
54 | Code goes here.
55 | Lots of it...
56 |
--------------------------------------------------------------------------------
/test/test-creation.js:
--------------------------------------------------------------------------------
1 | /*global describe, beforeEach, it*/
2 | 'use strict';
3 |
4 | var path = require('path');
5 | var assert = require('yeoman-generator').assert;
6 | var helpers = require('yeoman-generator').test;
7 |
8 | describe('Assemble generator', function () {
9 | before(function (done) {
10 | helpers.run(path.join(__dirname, '../app'))
11 | .inDir(path.join(__dirname, './temp'))
12 | .withOptions({
13 | 'skip-install-message': true,
14 | 'skip-install': true,
15 | 'skip-welcome-message': true,
16 | 'skip-message': true
17 | })
18 | .withPrompt({
19 | projectName: 'assemble',
20 | projectDesc: 'assemble',
21 | authorLogin: 'assemble',
22 | plugins: [
23 | 'assemble-contrib-permalinks',
24 | 'assemble-contrib-sitemap']
25 | })
26 | .on('end', done);
27 | });
28 |
29 | it('creates files', function () {
30 | assert.file([
31 | 'AUTHORS',
32 | 'CHANGELOG',
33 | 'Gruntfile.js',
34 | 'LICENSE-MIT',
35 | 'README.md',
36 | 'package.json',
37 | '.gitignore',
38 | '.editorconfig',
39 | 'src/content/markdown.md',
40 | 'src/data/site.yml',
41 | 'src/templates/layouts/default.hbs',
42 | 'src/templates/pages/blog.hbs',
43 | 'src/templates/pages/index.hbs',
44 | 'src/templates/partials/navbar-fixed-top.hbs',
45 | 'src/assets/theme.css'
46 | ]);
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/app/templates/layout.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{title}} | {{site.title}}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 | {{> navbar-fixed-top }}
27 |
28 |
29 |
30 | {{> body }}
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/templates/_package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(projectName) %>",
3 | "description": "<%= _.capitalize(projectDesc) %>.",
4 | "version": "0.1.0",
5 | "homepage": "https://github.com/<%= authorLogin %>/<%= _.slugify(projectName) %>",
6 | "author": {
7 | "name": "<%= authorName %>",
8 | "url": "http://github.com/<%= authorLogin %>/"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git://github.com/<%= authorLogin %>/<%= _.slugify(projectName) %>.git"
13 | },
14 | "bugs": {
15 | "url": "https://github.com/<%= authorLogin %>/<%= _.slugify(projectName) %>/issues"
16 | },
17 | "engines": {
18 | "node": ">=0.10"
19 | },
20 | "scripts": {
21 | "test": "grunt assemble"
22 | },
23 | "devDependencies": {
24 | "assemble": "^0.4.42",
25 | "grunt": "^0.4.5",
26 | "grunt-contrib-clean": "^0.6.0",
27 | "grunt-contrib-connect": "^0.8.0",
28 | "grunt-contrib-watch": "^0.6.1",
29 | "grunt-contrib-copy": "^0.5.0",
30 | "load-grunt-tasks": "^0.6.0",
31 | "time-grunt": "^1.0.0"<% if(plugins && plugins.length > 0){ %>,<% if(typeof plugins === 'object'){ _.each(plugins, function(name, i) { %>
32 | "<%= name %>": "*"<% if(i < (plugins.length - 1)) { %>,<% } %><% }); } else { %>"<%= plugins %>": "*"<%} } %>
33 | },
34 | "licenses": [
35 | {
36 | "type": "MIT",
37 | "url": "https://github.com/<%= authorLogin %>/<%= _.slugify(projectName) %>/blob/master/LICENSE-MIT"
38 | }
39 | ],
40 | "keywords": [
41 | "assemble",
42 | "templates",
43 | "handlebars",
44 | "site generator",
45 | "site builder",
46 | "grunt"
47 | ]
48 | }
49 |
--------------------------------------------------------------------------------
/app/templates/inc-navbar-fixed-top.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | component: navbar
3 | ---
4 |
5 |
6 |
7 |
16 |
17 |
25 |
26 |
27 | Github
28 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Assemble generator [](https://travis-ci.org/assemble/generator-assemble)
2 |
3 | > [Yeoman][yeoman] generator for [Assemble][assemble].
4 |
5 | ## Getting started
6 |
7 | Install the generator from [npm](npmjs.org):
8 |
9 | ``` bash
10 | npm i -g generator-assemble
11 | ```
12 |
13 | ## Usage
14 |
15 | Generate a new Assemble project:
16 |
17 | ```bash
18 | yo assemble
19 | ```
20 |
21 | _Do not initialize your project in a sub folder next to `.yo-rc.json` because your files will land here and not in your subfolder from where you are initializing project._
22 |
23 | #### Generator options
24 |
25 | * `-i` alias `--init`
26 |
27 | Force to prompt question and re-initialize `.yo-rc.json`.
28 |
29 | * `-s` alias `--skip-install`
30 |
31 | Skips the automatic execution of `bower` and `npm` after scaffolding has finished.
32 |
33 | * `-w` alias `--skip-welcome-message`
34 |
35 | Skips app welcome message.
36 |
37 |
38 | ## Included Grunt tasks
39 |
40 | * grunt-contrib-clean
41 | * grunt-contrib-connect
42 | * grunt-contrib-watch
43 | * time-grunt
44 |
45 |
46 | ## Boilerplate
47 |
48 | The following directory structure is generated after running `yo assemble`:
49 |
50 | .
51 | ├── .editorconfig
52 | ├── .gitignore
53 | ├── .yo-rc.json
54 | ├── AUTHORS
55 | ├── CHANGELOG
56 | ├── Gruntfile.js
57 | ├── LICENSE-MIT
58 | ├── package.json
59 | ├── README.md
60 | ├── dist
61 | │ └── assets
62 | │ ├── css
63 | │ │ ├── bootstrap.css
64 | │ │ ├── bootstrap.min.css
65 | │ │ └── theme.css
66 | │ ├── js
67 | │ │ └── bootstrap.min.js
68 | │ └── fonts
69 | │ ├── glyphicons-halflings-regular.eot
70 | │ ├── glyphicons-halflings-regular.svg
71 | │ ├── glyphicons-halflings-regular.ttf
72 | │ └── glyphicons-halflings-regular.woff
73 | ├── src
74 | │ ├── content
75 | │ │ └── markdown.md
76 | │ ├── data
77 | │ │ └── site.yml
78 | │ └── templates
79 | │ ├── layouts
80 | │ │ └── default.md
81 | │ ├── pages
82 | │ │ ├── index.hbs
83 | │ │ └── blog.hbs
84 | │ └── partials
85 | │ └── navbar-fixed-top.hbs
86 | └── node_modules
87 |
88 |
89 | ## Related
90 |
91 | * [Assemble Helper generator](https://github.com/assemble/generator-helper)
92 | * [Assemble Plugin generator](https://github.com/assemble/generator-plugin)
93 |
94 | ## License
95 | [MIT License](http://en.wikipedia.org/wiki/MIT_License)
96 |
97 | [yeoman]: http://yeoman.io/
98 | [assemble]: http://assemble.io
99 |
--------------------------------------------------------------------------------
/app/templates/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Generated on <%= (new Date).toISOString().split('T')[0] %>
3 | * <%= pkg.name %> v<%= pkg.version %>
4 | * <%= pkg.homepage %>
5 | *
6 | * Copyright (c) <%= (new Date).getFullYear() %> <%= pkg.author.name %>
7 | * Licensed under the MIT license.
8 | */
9 |
10 | 'use strict';
11 |
12 | // # Globbing
13 | // for performance reasons we're only matching one level down:
14 | // '<%%= config.src %>/templates/pages/{,*/}*.hbs'
15 | // use this if you want to match all subfolders:
16 | // '<%%= config.src %>/templates/pages/**/*.hbs'
17 |
18 | module.exports = function(grunt) {
19 |
20 | require('time-grunt')(grunt);
21 | require('load-grunt-tasks')(grunt);
22 |
23 | // Project configuration.
24 | grunt.initConfig({
25 |
26 | config: {
27 | src: 'src',
28 | dist: 'dist'
29 | },
30 |
31 | watch: {
32 | assemble: {
33 | files: ['<%%= config.src %>/{content,data,templates}/{,*/}*.{md,hbs,yml}'],
34 | tasks: ['assemble']
35 | },
36 | livereload: {
37 | options: {
38 | livereload: '<%%= connect.options.livereload %>'
39 | },
40 | files: [
41 | '<%%= config.dist %>/{,*/}*.html',
42 | '<%%= config.dist %>/assets/{,*/}*.css',
43 | '<%%= config.dist %>/assets/{,*/}*.js',
44 | '<%%= config.dist %>/assets/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
45 | ]
46 | }
47 | },
48 |
49 | connect: {
50 | options: {
51 | port: 9000,
52 | livereload: 35729,
53 | // change this to '0.0.0.0' to access the server from outside
54 | hostname: 'localhost'
55 | },
56 | livereload: {
57 | options: {
58 | open: true,
59 | base: [
60 | '<%%= config.dist %>'
61 | ]
62 | }
63 | }
64 | },
65 |
66 | assemble: {
67 | pages: {
68 | options: {
69 | flatten: true,
70 | assets: '<%%= config.dist %>/assets',
71 | layout: '<%%= config.src %>/templates/layouts/default.hbs',
72 | data: '<%%= config.src %>/data/*.{json,yml}',
73 | partials: '<%%= config.src %>/templates/partials/*.hbs'<% if(plugins && plugins.length > 0){ %>,
74 | plugins: [<% if(typeof plugins === 'object'){ _.each(plugins, function(name, i) { %>'<%= name %>'<% if(i < (plugins.length - 1)) { %>,<% } }); } else { %>'<%= name %>'<%} %>],<%}
75 | _.each(plugins, function(name, i) { if(name == 'permalinks') { %>
76 | permalinks: {
77 | preset: 'pretty'
78 | },<% }
79 | if(name == 'assemble-contrib-contextual') { %>
80 | contextual: {
81 | dest: 'tmp/'
82 | },<% }
83 | }); %>
84 | },
85 | files: {
86 | '<%%= config.dist %>/': ['<%%= config.src %>/templates/pages/*.hbs']
87 | }
88 | }
89 | },
90 |
91 | copy: {
92 | bootstrap: {
93 | expand: true,
94 | cwd: 'bower_components/bootstrap/dist/',
95 | src: '**',
96 | dest: '<%%= config.dist %>/assets/'
97 | },
98 | theme: {
99 | expand: true,
100 | cwd: 'src/assets/',
101 | src: '**',
102 | dest: '<%%= config.dist %>/assets/css/'
103 | }
104 | },
105 |
106 | // Before generating any new files,
107 | // remove any previously-created files.
108 | clean: ['<%%= config.dist %>/**/*.{html,xml}']
109 |
110 | });
111 |
112 | grunt.loadNpmTasks('assemble');
113 |
114 | grunt.registerTask('server', [
115 | 'build',
116 | 'connect:livereload',
117 | 'watch'
118 | ]);
119 |
120 | grunt.registerTask('build', [
121 | 'clean',
122 | 'copy',
123 | 'assemble'
124 | ]);
125 |
126 | grunt.registerTask('default', [
127 | 'build'
128 | ]);
129 |
130 | };
131 |
--------------------------------------------------------------------------------
/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 |
5 | /**
6 | * Module exports Assemble Generator constructor
7 | * Extend Yeoman base generator
8 | */
9 |
10 | var AssembleGenerator = yeoman.generators.Base.extend({
11 |
12 | initializing: function () {
13 | this.pkg = require('../package.json');
14 | this.description = this.pkg.description;
15 |
16 | this.option('init', {
17 | alias: 'i',
18 | desc: 'Force to prompt question and re-initialize of .yo-rc.json',
19 | type: String,
20 | defaults: false,
21 | required: false
22 | });
23 |
24 | this.init = this.options['init'] || this.options['i'] || false;
25 |
26 | this.defaultPlugins = {
27 | "assemble-middleware-anchors": false,
28 | "assemble-middleware-permalinks": true,
29 | "assemble-middleware-sitemap": true,
30 | "assemble-middleware-toc": false,
31 | };
32 |
33 | this.config.defaults({
34 | projectName : "",
35 | projectDesc : "The best project ever.",
36 | authorLogin : "assemble",
37 | installPlugin : true,
38 | author: {
39 | name : this.user.git.name() || process.env.user || process.env.username,
40 | login : "assemble",
41 | email : this.user.git.email()
42 | }
43 | });
44 |
45 | }, // initializing
46 |
47 | prompting: function () {
48 | var done = this.async();
49 |
50 | var force = false;
51 |
52 | if (!this.config.existed || this.init) {
53 | force = true;
54 | }
55 |
56 | if (!this.options['skip-welcome-message']) {
57 | console.log(this.yeoman);
58 | }
59 |
60 | var questions = [];
61 |
62 | (!this.config.get("projectName") || force) && questions.push({
63 | type : "input",
64 | name : "projectName",
65 | message : "Your project name",
66 | default : this.appname || this.config.get("projectName")
67 | });
68 |
69 | (!this.config.get("projectDesc") || force) && questions.push({
70 | type : "input",
71 | name : "projectDesc",
72 | message : "Your project description",
73 | default : this.config.get("projectDesc")
74 | });
75 |
76 | (!this.config.get("author").login || !this.config.get("authorLogin") || force) && questions.push({
77 | type : "input",
78 | name : "authorLogin",
79 | message : "Would you mind telling me your username on Github?",
80 | default : this.config.get("author").login || this.config.get("authorLogin")
81 | });
82 |
83 | questions.push({
84 | type : "confirm",
85 | name : "installPlugin",
86 | message : "Do you want to install Assemble plugins?",
87 | default : this.config.get("installPlugin")
88 | });
89 |
90 | // for first time/re-init, make new list of defaultPlugins
91 | if(!this.config.get("installPlugin") || force) {
92 | var plugins = this.config.get("plugins");
93 | // if we have previous plugin choice
94 | if (this._.isArray(plugins)) {
95 | var defaultPlugins = {};
96 | // convert it to object and assign checked
97 | plugins.forEach(function(plugin) {
98 | defaultPlugins[plugin] = true;
99 | });
100 | // concat with defautPlugins
101 | for (var key in defaultPlugins) {
102 | this.defaultPlugins[key] = defaultPlugins[key];
103 | }
104 | }
105 | }
106 |
107 | var choices = [];
108 | var pluginObj = this.defaultPlugins;
109 |
110 | // make choice more dynamic and checked from previous choice
111 | // TODO: fetch from npm with "assembleplugin" keyword
112 | for (var plugin in pluginObj) {
113 | if(pluginObj.hasOwnProperty(plugin)){
114 | choices.push({ name: plugin, checked: pluginObj[plugin] });
115 | }
116 | }
117 |
118 | questions.push({
119 | name : "plugins",
120 | type : "checkbox",
121 | message : "Which plugins would you like to include?",
122 | choices : choices,
123 | when: function( answers ) {
124 | return answers.installPlugin;
125 | }
126 | });
127 |
128 | this.prompt(questions, function (answers) {
129 |
130 | this.projectName = answers.projectName || this.config.get("projectName");
131 | this.projectDesc = answers.projectDesc || this.config.get("projectDesc");
132 | this.authorLogin = answers.authorLogin || this.config.get("authorLogin");
133 | this.plugins = answers.plugins;
134 | this.authorName = this.config.get("author").name;
135 | this.authorEmail = this.config.get("author").email;
136 |
137 | //save config to .yo-rc.json
138 | this.config.set(answers);
139 |
140 | done();
141 | }.bind(this));
142 | }, // prompting
143 |
144 | writing: {
145 |
146 | projectfiles: function () {
147 | this.template('AUTHORS');
148 | this.template('CHANGELOG');
149 | this.template('LICENSE-MIT');
150 | this.template('Gruntfile.js');
151 | this.template('_package.json', 'package.json');
152 | this.template('editorconfig', '.editorconfig');
153 | this.template('README.md');
154 | },
155 |
156 | gitfiles: function () {
157 | this.copy('gitignore', '.gitignore');
158 | this.copy('gitattributes', '.gitattributes');
159 | },
160 |
161 | bower: function () {
162 | this.template('_bower.json', 'bower.json');
163 | },
164 |
165 | src: function () {
166 | this.mkdir('src/data');
167 | this.mkdir('src/content');
168 | this.mkdir('src/templates/pages');
169 | this.mkdir('src/templates/assets');
170 | this.mkdir('src/templates/layouts');
171 | this.mkdir('src/templates/partials');
172 | this.copy('site.yml', 'src/data/site.yml');
173 | this.copy('theme.css', 'src/assets/theme.css');
174 | this.copy('markdown.md', 'src/content/markdown.md');
175 | this.copy('blog.hbs', 'src/templates/pages/blog.hbs');
176 | this.copy('index.hbs', 'src/templates/pages/index.hbs');
177 | this.copy('layout.hbs', 'src/templates/layouts/default.hbs');
178 | this.copy('inc-navbar-fixed-top.hbs', 'src/templates/partials/navbar-fixed-top.hbs');
179 | }
180 | }, // writing
181 |
182 | install: function() {
183 | this.installDependencies({
184 | skipInstall: this.options['skip-install'] || this.options['s'],
185 | skipMessage: this.options['skip-welcome-message'] || this.options['w']
186 | });
187 | }, // install
188 |
189 | });
190 |
191 | module.exports = AssembleGenerator;
192 |
--------------------------------------------------------------------------------