-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create boilerplate for seeding thelma elements
- Loading branch information
0 parents
commit 7411dcf
Showing
22 changed files
with
492 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"node": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 2, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "single", | ||
"undef": true, | ||
"unused": true, | ||
"strict": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
before_install: | ||
- currentfolder=${PWD##*/} | ||
- if [ "$currentfolder" != 'generator-thelma' ]; then cd .. && eval "mv $currentfolder generator-thelma" && cd generator-thelma; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# generator-thelma [](https://travis-ci.org/nishacodes/generator-thelma) | ||
|
||
> [Yeoman](http://yeoman.io) generator | ||
|
||
## Getting Started | ||
|
||
### What is Yeoman? | ||
|
||
Trick question. It's not a thing. It's this guy: | ||
|
||
 | ||
|
||
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. | ||
|
||
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.* | ||
|
||
```bash | ||
npm install -g yo | ||
``` | ||
|
||
### Yeoman Generators | ||
|
||
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. | ||
|
||
To install generator-thelma from npm, run: | ||
|
||
```bash | ||
npm install -g generator-thelma | ||
``` | ||
|
||
Finally, initiate the generator: | ||
|
||
```bash | ||
yo thelma | ||
``` | ||
|
||
### Getting To Know Yeoman | ||
|
||
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. | ||
|
||
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). | ||
|
||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "generator-thelma", | ||
"version": "0.0.0", | ||
"description": "Yeoman generator", | ||
"license": "MIT", | ||
"main": "app/index.js", | ||
"repository": "nishacodes/generator-thelma", | ||
"author": { | ||
"name": "Nisha Batra", | ||
"email": "", | ||
"url": "https://github.com/nishacodes" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"app" | ||
], | ||
"keywords": [ | ||
"yeoman-generator" | ||
], | ||
"dependencies": { | ||
"yeoman-generator": "^0.18.0", | ||
"chalk": "^0.5.0", | ||
"lodash": "^2.4.1", | ||
"yosay": "^0.3.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
}, | ||
"peerDependencies": { | ||
"yo": ">=1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
'use strict'; | ||
var _ = require('lodash'); | ||
var yeoman = require('yeoman-generator'); | ||
var chalk = require('chalk'); | ||
var yosay = require('yosay'); | ||
var path = require('path'); | ||
|
||
var ThelmaGenerator = yeoman.generators.Base.extend({ | ||
initializing: function () { | ||
this.pkg = require('../package.json'); | ||
}, | ||
constructor: function () { | ||
yeoman.generators.Base.apply(this, arguments); | ||
|
||
this.argument('element-name', { | ||
desc: 'Tag name of the element and directory to generate.', | ||
required: true, | ||
}); | ||
|
||
this.option('skip-install', { | ||
desc: 'Whether bower dependencies should be installed', | ||
defaults: false, | ||
}); | ||
|
||
this.option('skip-install-message', { | ||
desc: 'Whether commands run should be shown', | ||
defaults: false, | ||
}); | ||
|
||
}, | ||
validate: function () { | ||
this.elementName = this['element-name']; | ||
if (this.elementName.indexOf('-') === -1) { | ||
this.emit('error', new Error( | ||
'Element name must contain a dash "-"\n' + | ||
'ex: yo thelma:seed my-element' | ||
)); | ||
} | ||
}, | ||
checkForDanger: function () { | ||
var done = this.async(); | ||
|
||
// Because the element installs its dependencies as siblings, we want to | ||
// make it clear to the user that it is potentially dangerous to generate | ||
// their element from workspace containing other directories. | ||
var entries = this.expand('*'); | ||
var bowerEntries = _.map(this.expand('*/bower.json'), path.dirname); | ||
var nonComponents = _.difference(entries, bowerEntries); | ||
|
||
// Whew, everything looks like a bower component! | ||
if (nonComponents.length === 0) { | ||
done(); | ||
return; | ||
} | ||
|
||
console.warn( | ||
'You are generating your element in a workspace that appears to contain data\n' + | ||
'other than web components. This is potentially dangerous, as your element\'s\n' + | ||
'dependencies will be installed in the current directory. Bower will\n' + | ||
'overwrite any conflicting directories.\n' | ||
); | ||
|
||
var prompts = [{ | ||
name: 'livesDangerously', | ||
message: 'Are you ok with that?', | ||
default: 'no', | ||
}]; | ||
|
||
this.prompt(prompts, function (props) { | ||
if (props.livesDangerously[0] !== 'n') { | ||
done(); | ||
} | ||
}.bind(this)); | ||
}, | ||
prompting: function () { | ||
var done = this.async(); | ||
|
||
// Have Yeoman greet the user. | ||
this.log(yosay( | ||
'Welcome to the ' + chalk.red('Thelma') + ' custom web component generator!' | ||
)); | ||
|
||
var prompts = [{ | ||
name: 'ghUser', | ||
message: 'What is your GitHub username?' | ||
},{ | ||
type: 'confirm', | ||
name: 'd3chart', | ||
message: 'Will your component require the D3 JavaScript library?', | ||
default: false | ||
},{ | ||
type: 'confirm', | ||
name: 'animated', | ||
message: 'Will your component contain any animation?', | ||
default: true | ||
}]; | ||
|
||
this.prompt(prompts, function (props) { | ||
this.ghUser = props.ghUser; | ||
this.d3chart = props.d3chart; | ||
this.animated = props.animated; | ||
|
||
done(); | ||
}.bind(this)); | ||
}, | ||
seed: function () { | ||
// Construct the element as a subdirectory. | ||
this.destinationRoot(this.elementName); | ||
this.copy('_gitignore', '.gitignore'); | ||
this.copy('_gitattributes', '.gitattributes'); | ||
this.copy('_bowerrc', '.bowerrc'); | ||
this.copy('_jshintrc', '.jshintrc'); | ||
this.copy('_editorconfig', '.editorconfig'); | ||
this.template('_bower.json', 'bower.json'); | ||
this.template('_README.md', 'README.md'); | ||
this.template('_element-name.css', this.elementName + '.css'); | ||
this.template('_element-name.html', this.elementName + '.html'); | ||
this.template('_demo.html', 'demo.html'); | ||
}, | ||
|
||
install: function () { | ||
this.installDependencies({ | ||
npm: false, | ||
skipInstall: this.options['skip-install'], | ||
skipMessage: this.options['skip-install-message'] | ||
}); | ||
} | ||
}); | ||
|
||
|
||
|
||
module.exports = ThelmaGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# <%= elementName %> | ||
|
||
See the [component page](http://<%= ghUser %>.github.io/<%= elementName %>) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "<%= elementName %>", | ||
"version": "0.0.0", | ||
"keywords": "thelma, polymer, web-components", | ||
"main": "<%= elementName %>.html", | ||
"dependencies": {<% if(d3chart){ %> | ||
"th-d3-chart": "thelmanews/th-d3-chart#master", <% } else if(animated) { %> | ||
"th-animated": "thelmanews/th-animated#master", <% } %> | ||
"th-theme": "thelmanews/th-theme", | ||
"polymer": "Polymer/polymer#~0.5.1" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "../" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<title><%= elementName %> Demo</title> | ||
<script src="../webcomponentsjs/webcomponents.js"></script> | ||
<link rel="import" href="<%= elementName %>.html"> | ||
</head> | ||
<body unresolved> | ||
|
||
<p>An example of `<%= elementName %>` looks like this:</p> | ||
<<%= elementName %>></<%= elementName %>> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
:host { | ||
display: inline-block; | ||
color: black; | ||
width: 300px; | ||
height: 300px; | ||
} |
Oops, something went wrong.