Skip to content

Commit c0866c6

Browse files
committed
Adding initial yo generator output
1 parent d720726 commit c0866c6

14 files changed

+272
-3
lines changed

Diff for: .editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
temp/

Diff for: .jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"node": true,
3+
"esnext": true,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": true,
7+
"eqeqeq": true,
8+
"immed": true,
9+
"indent": 2,
10+
"latedef": true,
11+
"newcap": true,
12+
"noarg": true,
13+
"quotmark": "single",
14+
"regexp": true,
15+
"undef": true,
16+
"unused": true,
17+
"strict": true,
18+
"trailing": true,
19+
"smarttabs": true,
20+
"white": true
21+
}

Diff for: .travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
before_install:
5+
- currentfolder=${PWD##*/}
6+
- if [ "$currentfolder" != 'generator-element' ]; then cd .. && eval "mv $currentfolder generator-element" && cd generator-element; fi
7+

Diff for: README.md

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
1-
generator-element
2-
=================
1+
# generator-element [![Build Status](https://secure.travis-ci.org/webcomponents/generator-element.png?branch=master)](https://travis-ci.org/webcomponents/generator-element)
32

4-
A Yeoman generator for Web Component elements
3+
> [Yeoman](http://yeoman.io) generator
4+
5+
6+
## Getting Started
7+
8+
### What is Yeoman?
9+
10+
Trick question. It's not a thing. It's this guy:
11+
12+
![](http://i.imgur.com/JHaAlBJ.png)
13+
14+
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.
15+
16+
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.*
17+
18+
```
19+
$ npm install -g yo
20+
```
21+
22+
### Yeoman Generators
23+
24+
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.
25+
26+
To install generator-element from npm, run:
27+
28+
```
29+
$ npm install -g generator-element
30+
```
31+
32+
Finally, initiate the generator:
33+
34+
```
35+
$ yo element
36+
```
37+
38+
### Getting To Know Yeoman
39+
40+
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.
41+
42+
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).
43+
44+
45+
## License
46+
47+
MIT

Diff for: app/index.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
var util = require('util');
3+
var path = require('path');
4+
var yeoman = require('yeoman-generator');
5+
var chalk = require('chalk');
6+
7+
8+
var ElementGenerator = yeoman.generators.Base.extend({
9+
init: function () {
10+
this.pkg = yeoman.file.readJSON(path.join(__dirname, '../package.json'));
11+
12+
this.on('end', function () {
13+
if (!this.options['skip-install']) {
14+
this.npmInstall();
15+
}
16+
});
17+
},
18+
19+
askFor: function () {
20+
var done = this.async();
21+
22+
// have Yeoman greet the user
23+
console.log(this.yeoman);
24+
25+
// replace it with a short and sweet description of your generator
26+
console.log(chalk.magenta('You\'re using the fantastic Element generator.'));
27+
28+
var prompts = [{
29+
type: 'confirm',
30+
name: 'someOption',
31+
message: 'Would you like to enable this option?',
32+
default: true
33+
}];
34+
35+
this.prompt(prompts, function (props) {
36+
this.someOption = props.someOption;
37+
38+
done();
39+
}.bind(this));
40+
},
41+
42+
app: function () {
43+
this.mkdir('app');
44+
this.mkdir('app/templates');
45+
46+
this.copy('_package.json', 'package.json');
47+
this.copy('_bower.json', 'bower.json');
48+
},
49+
50+
projectfiles: function () {
51+
this.copy('editorconfig', '.editorconfig');
52+
this.copy('jshintrc', '.jshintrc');
53+
}
54+
});
55+
56+
module.exports = ElementGenerator;

Diff for: app/templates/_bower.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "package",
3+
"version": "0.0.0",
4+
"dependencies": {}
5+
}
6+

Diff for: app/templates/_package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "package",
3+
"version": "0.0.0",
4+
"dependencies": {}
5+
}

Diff for: app/templates/editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

Diff for: app/templates/jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"node": true,
3+
"esnext": true,
4+
"bitwise": true,
5+
"camelcase": true,
6+
"curly": true,
7+
"eqeqeq": true,
8+
"immed": true,
9+
"indent": 2,
10+
"latedef": true,
11+
"newcap": true,
12+
"noarg": true,
13+
"quotmark": "single",
14+
"regexp": true,
15+
"undef": true,
16+
"unused": true,
17+
"strict": true,
18+
"trailing": true,
19+
"smarttabs": true,
20+
"white": true
21+
}

Diff for: package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "generator-element",
3+
"version": "0.0.0",
4+
"description": "Yeoman generator",
5+
"license": "MIT",
6+
"main": "app/index.js",
7+
"repository": "webcomponents/generator-element",
8+
"author": {
9+
"name": "Web Components",
10+
"email": "",
11+
"url": "https://github.com/webcomponents"
12+
},
13+
"engines": {
14+
"node": ">=0.10.0"
15+
},
16+
"scripts": {
17+
"test": "mocha"
18+
},
19+
"files": [
20+
"app"
21+
],
22+
"keywords": [
23+
"yeoman-generator"
24+
],
25+
"dependencies": {
26+
"yeoman-generator": "~0.16.0",
27+
"chalk": "~0.4.0"
28+
},
29+
"devDependencies": {
30+
"mocha": "*"
31+
},
32+
"peerDependencies": {
33+
"yo": ">=1.0.0"
34+
}
35+
}

Diff for: test/test-creation.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*global describe, beforeEach, it */
2+
'use strict';
3+
var path = require('path');
4+
var helpers = require('yeoman-generator').test;
5+
6+
describe('element generator', function () {
7+
beforeEach(function (done) {
8+
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
9+
if (err) {
10+
return done(err);
11+
}
12+
13+
this.app = helpers.createGenerator('element:app', [
14+
'../../app'
15+
]);
16+
done();
17+
}.bind(this));
18+
});
19+
20+
it('creates expected files', function (done) {
21+
var expected = [
22+
// add files you expect to exist here.
23+
'.jshintrc',
24+
'.editorconfig'
25+
];
26+
27+
helpers.mockPrompt(this.app, {
28+
'someOption': true
29+
});
30+
this.app.options['skip-install'] = true;
31+
this.app.run({}, function () {
32+
helpers.assertFile(expected);
33+
done();
34+
});
35+
});
36+
});

Diff for: test/test-load.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*global describe, beforeEach, it*/
2+
'use strict';
3+
var assert = require('assert');
4+
5+
describe('element generator', function () {
6+
it('can be imported without blowing up', function () {
7+
var app = require('../app');
8+
assert(app !== undefined);
9+
});
10+
});

0 commit comments

Comments
 (0)