Pages can be written in HTML and compiled via Swig. This allows for automatically templating. HTML supports front-matter, allowing for variables to be defined and passed in to a file when compiled.
8 |
9 |
17 |
18 |
19 |
20 | {% block content %}{% endblock %}
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-watson",
3 | "version": "1.0.0",
4 | "description": "Yeoman generator",
5 | "license": "MIT",
6 | "main": "app/index.js",
7 | "repository": "Snugug/generator-watson",
8 | "author": {
9 | "name": "Sam Richard",
10 | "email": "",
11 | "url": "https://github.com/Snugug"
12 | },
13 | "scripts": {
14 | "test": "mocha"
15 | },
16 | "files": [
17 | "generators"
18 | ],
19 | "keywords": [
20 | "yeoman-generator"
21 | ],
22 | "dependencies": {
23 | "chalk": "^1.0.0",
24 | "lodash": "^3.10.0",
25 | "underscore.string": "^3.1.1",
26 | "yeoman-generator": "^0.19.0",
27 | "yosay": "^1.0.2"
28 | },
29 | "devDependencies": {
30 | "chai": "^3.0.0",
31 | "mocha": "*"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ## Documentation
2 |
3 | Watson Design Guide documentation by International Business Machines Corporation is licensed under a Creative Commons Attribution 4.0 International License. Based on a work at https://github.com/IBM-Watson/design-library.
4 |
5 | ## Code
6 |
7 | Copyright (c) 2015 International Business Machines Corporation.
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License");
10 | you may not use this file except in compliance with the License.
11 | You may obtain a copy of the License at
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Unless required by applicable law or agreed to in writing, software
16 | distributed under the License is distributed on an "AS IS" BASIS,
17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | See the License for the specific language governing permissions and
19 | limitations under the License.
20 |
--------------------------------------------------------------------------------
/test/test-app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path'),
4 | assert = require('yeoman-generator').assert,
5 | chai = require('chai').assert,
6 | helpers = require('yeoman-generator').test,
7 | fs = require('fs'),
8 | os = require('os');
9 |
10 | describe('Watson:app', function () {
11 | before(function (done) {
12 | helpers.run(path.join(__dirname, '../generators/app'))
13 | .withOptions({ skipInstall: true })
14 | .withPrompts({ project: 'Hello World' })
15 | .on('end', done);
16 | });
17 |
18 | it('creates files', function () {
19 | assert.file([
20 | 'bower.json',
21 | 'package.json',
22 | '.editorconfig',
23 | 'Gulpfile.js',
24 | '.eslintrc',
25 | '.gitignore',
26 | '.nvmrc',
27 | 'js/app.js',
28 | 'images/.gitkeep',
29 | 'audio/.gitkeep',
30 | 'videos/.gitkeep',
31 | 'fonts/.gitkeep',
32 | 'templates/_layout.html',
33 | 'pages/index.html',
34 | 'pages/markdown.md'
35 | ]);
36 | });
37 |
38 |
39 | it('templates files', function () {
40 | var bowerJSON = fs.readFileSync('bower.json', 'utf-8'),
41 | packageJSON = fs.readFileSync('package.json', 'utf-8'),
42 | indexHTML = fs.readFileSync('templates/_layout.html', 'utf-8');
43 |
44 |
45 | chai.include(bowerJSON, '"name": "hello-world",', '`bower.json` contains templated project slug');
46 | chai.include(packageJSON, '"name": "hello-world",', '`package.json` contains templated project slug');
47 | chai.include(indexHTML, '{% if title %}{{ title }} | {% endif %}Hello World', '`index.html` contains templated project name ')
48 | });
49 | });
50 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Generator Watson [](https://circleci.com/gh/IBM-Watson/generator-watson) [](http://badge.fury.io/js/generator-watson)
2 |
3 | > [Yeoman](http://yeoman.io) generator
4 |
5 | The Watson Yeoman generator is a tool for getting quickly up and running with the [Watson Design Guide](http://watsondesign.guide/)
6 |
7 | ## Getting Started
8 |
9 | ### What is Yeoman?
10 |
11 | Trick question. It's not a thing. It's this guy:
12 |
13 | 
14 |
15 | Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
16 |
17 | Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*
18 |
19 | ```bash
20 | npm install -g yo
21 | ```
22 |
23 | ### Yeoman Generators
24 |
25 | Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
26 |
27 | To install generator-watson from npm, run:
28 |
29 | ```bash
30 | npm install -g generator-watson
31 | ```
32 |
33 | Finally, initiate the generator:
34 |
35 | ```bash
36 | yo watson
37 | ```
38 |
39 | ### Getting To Know Yeoman
40 |
41 | Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
42 |
43 | If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
44 |
45 |
46 | ## License
47 |
48 | MIT
49 |
--------------------------------------------------------------------------------
/generators/app/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var yeoman = require('yeoman-generator'),
3 | chalk = require('chalk'),
4 | path = require('path'),
5 | _ = require('lodash'),
6 | _s = require('underscore.string'),
7 | yosay = require('yosay');
8 |
9 | module.exports = yeoman.generators.Base.extend({
10 | prompting: function () {
11 | var done = this.async();
12 |
13 | // Have Yeoman greet the user.
14 | this.log(yosay(
15 | 'Welcome to the terrific ' + chalk.red('Watson') + ' generator!'
16 | ));
17 |
18 | var prompts = [{
19 | type: 'string',
20 | name: 'project',
21 | message: 'What is your project\'s name?',
22 | validate: function (input) {
23 | if (input === '') {
24 | return 'Please enter a project name';
25 | }
26 | else {
27 | return true;
28 | }
29 | }
30 | }];
31 |
32 | this.prompt(prompts, function (props) {
33 | this.props = props;
34 | this.appname = _s.slugify(props.project);
35 | // To access props later use this.props.someOption;
36 |
37 | done();
38 | }.bind(this));
39 | },
40 |
41 | configuring: {
42 | enforceFolderName: function () {
43 | if (this.appname !== _.last(this.destinationRoot().split(path.sep))) {
44 | this.destinationRoot(this.appname);
45 | }
46 |
47 | this.config.save();
48 | }
49 | },
50 |
51 | writing: {
52 | app: function () {
53 | // NVMRC
54 | this.fs.copy(
55 | this.templatePath('nvmrc'),
56 | this.destinationPath('.nvmrc')
57 | );
58 | // Package.json
59 | this.fs.copyTpl(
60 | this.templatePath('_package.json'),
61 | this.destinationPath('package.json'),
62 | {
63 | 'name': this.appname
64 | }
65 | );
66 | // Bower.json
67 | this.fs.copyTpl(
68 | this.templatePath('_bower.json'),
69 | this.destinationPath('bower.json'),
70 | {
71 | 'name': this.appname
72 | }
73 | );
74 | // Gulpfile
75 | this.fs.copy(
76 | this.templatePath('Gulpfile.js'),
77 | this.destinationPath('Gulpfile.js')
78 | );
79 | },
80 |
81 | dotfiles: function () {
82 | // Editor Config
83 | this.fs.copy(
84 | this.templatePath('editorconfig'),
85 | this.destinationPath('.editorconfig')
86 | );
87 | // ESLint RC
88 | this.fs.copy(
89 | this.templatePath('eslintrc'),
90 | this.destinationPath('.eslintrc')
91 | );
92 | // Gitignore
93 | this.fs.copy(
94 | this.templatePath('gitignore'),
95 | this.destinationPath('.gitignore')
96 | );
97 | },
98 |
99 | projectfiles: function () {
100 | var folders = [
101 | 'images',
102 | 'audio',
103 | 'videos',
104 | 'fonts'
105 | ],
106 | _this = this;
107 |
108 | // Starter pages
109 | this.fs.copy(
110 | this.templatePath('pages/**'),
111 | this.destinationPath('pages')
112 | );
113 | // Index file
114 | this.fs.copyTpl(
115 | this.templatePath('_layout.html'),
116 | this.destinationPath('templates/_layout.html'),
117 | {
118 | 'name': this.props.project
119 | }
120 | );
121 | // JavaScript and Sass Files
122 | this.fs.copy(
123 | this.templatePath('js/**'),
124 | this.destinationPath('js')
125 | );
126 | this.fs.copy(
127 | this.templatePath('sass/**'),
128 | this.destinationPath('sass')
129 | );
130 |
131 | // Gitkeep Folders
132 | folders.forEach(function (folder) {
133 | _this.fs.copy(
134 | _this.templatePath('gitkeep'),
135 | _this.destinationPath(folder + '/.gitkeep')
136 | );
137 | });
138 | }
139 | },
140 |
141 | install: function () {
142 | this.installDependencies();
143 | }
144 | });
145 |
--------------------------------------------------------------------------------
/generators/app/templates/eslintrc:
--------------------------------------------------------------------------------
1 | env:
2 | # Browser global variables.
3 | browser: true
4 | # Defines require() and define() as global variables as per the amd spec.
5 | # amd: true
6 | # Adds all of the Jasmine testing global variables for version 1.3 and 2.0.
7 | # jasmine: true
8 |
9 | # globals:
10 | #########################
11 | ## Only add globals if you're absolutely certain they need to be globals
12 | ##########################
13 | # console: true
14 |
15 | #########################
16 | ## set to 0 to allow
17 | ## set to 1 to disallow as warning
18 | ## set to 2 to disallow as error
19 | #########################
20 | rules:
21 | #########################
22 | ## Optional Rules
23 | #########################
24 | # Disallow use of `console`
25 | no-console: 2
26 |
27 | # Disallow warning comments
28 | no-warning-comments:
29 | - 1
30 | - terms:
31 | - todo
32 | - fixme
33 | location: anywhere
34 |
35 | # Warns when variables are defined but never used
36 | no-unused-vars: 1
37 |
38 | # Enforces comma style (first or last)
39 | comma-style:
40 | - 2
41 | - last
42 |
43 | # Enforces one true `this` variable
44 | consistent-this:
45 | - 2
46 | - self
47 | # Allows dangling underscores in identifiers
48 | no-underscore-dangle: 2
49 |
50 | # Enforces function expressions to have a name
51 | func-names: 0
52 |
53 | # Set maximum depth of nested callbacks
54 | max-nested-callbacks:
55 | - 1
56 | - 3
57 |
58 | #########################
59 | ## Core Rules
60 | ##########################
61 | # Enforces camel case names
62 | camelcase: 2
63 |
64 | # Prohibit use of == and != in favor of === and !==
65 | eqeqeq: 2
66 |
67 | # Suppresses warnings about == null comparisons
68 | no-eq-null: 2
69 |
70 | # No mixing tabs and spaces, with 2 spaces only
71 | no-mixed-spaces-and-tabs: 2
72 |
73 | # Prohibits use of a variable before it is defined
74 | no-use-before-define: 2
75 |
76 | # Requires capitalized names for constructor functions
77 | new-cap: 2
78 |
79 | # Prohibits use of explicitly undeclared variables
80 | no-undef: 2
81 |
82 | # Enforces Use Strict at the top of function scope
83 | strict: 2
84 | # Prohibits global Use Strict
85 | global-strict: 2
86 |
87 | # Requires variable declarations to be at the top
88 | vars-on-top: 2
89 |
90 | # Enforce curly braces around blocks in loops and conditionals
91 | curly: 2
92 |
93 | # Prohibits the use of immediate function invocations w/o wrapping in parentheses
94 | wrap-iife: 2
95 |
96 | # Prohibits `argument.caller` and `argument.callee`
97 | no-caller: 2
98 |
99 | # Requires all `for in` loops to filter object's items
100 | guard-for-in: 2
101 |
102 | # Prohibits comparing a variable against itself
103 | no-self-compare: 2
104 |
105 | # Prohibits use of `undefined` variable
106 | no-undefined: 0
107 |
108 | # Prohibits nested ternaries
109 | no-nested-ternary: 2
110 |
111 | # Enforces space following unary word operators
112 | space-unary-ops:
113 | - 2
114 | - words: true
115 | nonwords: false
116 |
117 | # Enforces a space before blocks
118 | space-before-blocks:
119 | - 2
120 | - always
121 |
122 | # Enforces spaces following keywords
123 | space-after-keywords:
124 | - 2
125 | - always
126 |
127 | # Enforces quoted property names
128 | quote-props:
129 | - 2
130 | - always
131 |
132 | # Enforces padded blocks
133 | padded-blocks:
134 | - 1
135 | - never
136 |
137 | # Enforce functions as expressions
138 | func-style:
139 | - 2
140 | - expression
141 |
142 | # Require brace style
143 | brace-style:
144 | - 2
145 | - stroustrup
146 |
147 | # Prohibits Yoda conditions
148 | yoda:
149 | - 2
150 | - never
151 |
152 | # Enforce use of single quotation marks for strings.
153 | quotes:
154 | - 2
155 | - single
156 |
157 | # Enforces space inside of brackets (except property name)
158 | space-in-brackets:
159 | - 2
160 | - always
161 | - propertyName: false
162 | singleValue: false
163 |
164 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to the IBM Watson Yeoman Generator
2 |
3 | The Watson Yeoman Generator is allows you to get quickly up and running using the [Watson Design Guide](http://watsondesign.guide/) and is a child project of the Design Guide. Please refer to it for full contributing guidelines.
4 |
5 | _**Heads Up!** We love open source, but the Watson Yeoman Generator and Watson Design Guide is unlikely to add new guidelines or features that are not in-line with the work we're doing or won't be used at IBM Watson. Inclusion is at the discretion of the Watson Design team. We really love to share, though, so hopefully that means we're still friends :blue_heart:_
6 |
7 | ## Submitting Issues
8 |
9 | * Before creating a new issue, perform a [cursory search](https://github.com/issues?utf8=%E2%9C%93&q=is%3Aissue+user%3Aibm-watson+) to see if a similar issue has already been submitted.
10 | * Can create an issue [here](https://github.com/IBM-Watson/generator-watson/issues). Please include as many details as possible when filing an issue.
11 | * Issue titles should be descriptive, explaining at the high level what it is about, and should be written in the same style as [Git commit messages](#git-commit-messages).
12 | * Please include the version of the Design Guide being used or viewed
13 | * Do not open a [pull request](#pull-requests) to resolve an issue without first receiving feedback from a `collaborator` or `owner` and having them agree on a solution forward.
14 | * Include screenshots and animated GIFs whenever possible; they are immensely helpful.
15 | * When submitting a browser bug, please include the browser, version, operating system, and operating system version.
16 | * When submitting an update to or a new feature, pattern, guideline, etc… we prefer to see user research associated with the suggestion including testing methods, results, and sample size, whenever possible. This allows us to make more user-centered decisions and cut through assumptions and individual preferences.
17 | * Issues that have a number of sub-items that need to be complete should use [task lists](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) to track the sub-items in the main issue comment.
18 |
19 |
20 | ## Pull Requests
21 |
22 | * **DO NOT ISSUE A PULL REQUEST WITHOUT FIRST [SUBMITTING AN ISSUE](#submitting-issues)**
23 | * **ALL PULL REQUESTS MUST INCLUDE A [DEVELOPER CERTIFICATE OF ORIGIN](#developer-certificate-of-origin)**
24 | * Pull requests should reference their related issues. If the pull request closes an issue, [please reference its closing from a commit messages](https://help.github.com/articles/closing-issues-via-commit-messages/). Pull requests not referencing any issues will be closed.
25 | * Pull request titles should be descriptive, explaining at the high level what it is doing, and should be written in the same style as [Git commit messages](#git-commit-messages).
26 | * Update the [CHANGELOG](#maintaining-thechangelog) with the changes made by the pull request, making sure to use the proper [Emoji](#emoji-cheatsheet).
27 | * Follow our JavaScript and CSS styleguides. We have linters set up to catch most of it.
28 | * Ensure that [EditorConfig](http://editorconfig.org/) installed in the editor used to work on the site and that it is functioning properly.
29 | * Do not squash or rebase commits when submitting a Pull Request. It makes it much harder to follow work and make incremental changes.
30 | * Ensure no Emoji tags are used in the title of the Pull Request
31 |
32 | ### Developer Certificate of Origin
33 |
34 | All contributions to the Watson Design Guideline must be accompanied by acknowledgment of, and agreement to, the [Developer Certificate of Origin](http://elinux.org/Developer_Certificate_Of_Origin), reproduced below. Acknowledgment of and agreement to the Developer Certificate of Origin _must_ be included in the comment section of each contribution and _must_ take the form of `DCO 1.1 Signed-off-by: {{Full Name}} <{{email address}}>` (without the `{}`). Contributions without this acknowledgment will be required to add it before being accepted. If a contributor is unable or unwilling to agree to the Developer Certificate of Origin, their contribution will not be included.
35 |
36 | ```
37 | Developer Certificate of Origin
38 | Version 1.1
39 |
40 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
41 | 660 York Street, Suite 102,
42 | San Francisco, CA 94110 USA
43 |
44 | Everyone is permitted to copy and distribute verbatim copies of this
45 | license document, but changing it is not allowed.
46 |
47 | Developer's Certificate of Origin 1.1
48 |
49 | By making a contribution to this project, I certify that:
50 |
51 | (a) The contribution was created in whole or in part by me and I
52 | have the right to submit it under the open source license
53 | indicated in the file; or
54 |
55 | (b) The contribution is based upon previous work that, to the best
56 | of my knowledge, is covered under an appropriate open source
57 | license and I have the right under that license to submit that
58 | work with modifications, whether created in whole or in part
59 | by me, under the same open source license (unless I am
60 | permitted to submit under a different license), as indicated
61 | in the file; or
62 |
63 | (c) The contribution was provided directly to me by some other
64 | person who certified (a), (b) or (c) and I have not modified
65 | it.
66 |
67 | (d) I understand and agree that this project and the contribution
68 | are public and that a record of the contribution (including all
69 | personal information I submit with it, including my sign-off) is
70 | maintained indefinitely and may be redistributed consistent with
71 | this project or the open source license(s) involved.
72 | ```
73 |
74 | ### Git Commit Messages
75 |
76 | * Use the present tense (`"Add feature"` not `"Added Feature"`)
77 | * Use the imperative mood (`"Move cursor to…"` not `"Moves cursor to…"`)
78 | * Limit the first line to 72 characters or less
79 | * Include relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet)
80 |
81 | ### Branching Model
82 |
83 | * Branches must be made off of the most current `master` branch from `git@github.com:IBM-Watson/generator-watson.git`
84 | * Branch names should be descriptive, describing what is being done in that branch
85 | * Pull requests must be made into our [watson](https://github.com/IBM-Watson/generator-watson/tree/master) branch.
86 | * The following branch prefixes should be used when creating a new branch:
87 | * `hotfix/` - bug fixes that got through and need to be squashed
88 | * `release/` - for releases
89 | * `feature/` - update to or new feature
90 |
91 | ## Creating a New Version
92 |
93 | Versioning is done through [SEMVER](http://semver.org/). When creating a new version, issue a [pull request](#pull-requests) from `develop` into `master` and create new release branch off of `master` with the version's name, and create a new tag with `v` prefixed with the version's name from that branch.
94 |
95 | For instance, when creating version `1.1.0`, start by merging `develop` into `master`, create a branch `release/1.1.0` from `master`, and create a tag `v1.1.0` from branch `release/1.1.0`.
96 |
97 | ### Maintaining the Changelog
98 |
99 | The Changelog should have a list of changes made for each version. They should be organized so additions come first, changes come second, and deletions come third. Version numbers should be 2nd level headers with the `v` in front (like a tag) and the date of the version's most recent update should be underneath in italics.
100 |
101 | Changelog messages do not need to cover each individual commit made, but rather should have individual summaries of the changes made. Changelog messages should be written in the same style as [Git commit messages](#git-commit-messages).
102 |
103 | ## Emoji Cheatsheet
104 |
105 | When creating creating commits or updating the CHANGELOG, please **start** the commit message or update with one of the following applicable Emoji. Emoji should not be used at the start of issue or pull request titles.
106 |
107 | * :art: `:art:` when improving the format/structure of the code
108 | * :racehorse: `:racehorse:` when improving performance
109 | * :memo: `:memo:` when writing long-form text (documentation, guidelines, principles, etc…)
110 | * :bug: `:bug:` when fixing a bug
111 | * :fire: `:fire:` when removing code or files
112 | * :green_heart: `:green_heart:` when fixing the CI build
113 | * :white_check_mark: `:white_check_mark:` when adding tests
114 | * :lock: `:lock:` when dealing with security
115 | * :arrow_up: `:arrow_up:` when upgrading dependencies
116 | * :arrow_down: `:arrow_down:` when downgrading dependencies
117 | * :shirt: `:shirt:` when removing linter warnings
118 | * :shipit: `:shipit:` when creating a new release
119 |
--------------------------------------------------------------------------------