Skip to content

Commit 4067aed

Browse files
committed
Adding generator
1 parent cd07eff commit 4067aed

27 files changed

+631
-2
lines changed

.editorconfig

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

.eslintignore

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

.eslintrc.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"mocha": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"rules": {
9+
"indent": [
10+
"error",
11+
2
12+
],
13+
"linebreak-style": [
14+
"error",
15+
"unix"
16+
],
17+
"quotes": [
18+
"error",
19+
"single"
20+
],
21+
"semi": [
22+
"error",
23+
"always"
24+
]
25+
}
26+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ npm-debug.log*
66
# Coverage directory used by tools like istanbul
77
coverage
88

9+
# nyc test coverage
10+
.nyc_output
11+
912
# Dependency directories
1013
node_modules/
1114

@@ -17,3 +20,6 @@ node_modules/
1720

1821
# Optional REPL history
1922
.node_repl_history
23+
24+
# Demo Project
25+
awesome-project

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact = true

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## 1.0.0
4+
Initial release

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
# generator-oss-project
2-
Yeoman generator for open source projects.
1+
# Project Name
2+
3+
[![License][license-badge]][license-url]
4+
5+
> Yeoman generator for open source projects.
6+
7+
## Author
8+
[Roberto Achar](https://twitter.com/RobertoAchar)
9+
10+
## License
11+
[MIT](https://github.com/robertoachar/node-password-storage/blob/master/LICENSE)
12+
13+
[license-badge]: https://img.shields.io/badge/license-MIT%20License-brightgreen.svg
14+
[license-url]: https://opensource.org/licenses/MIT

generators/app/files.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = [
2+
'src/index.js',
3+
'test/test.js',
4+
'.editorconfig',
5+
'.eslintignore',
6+
'.eslintrc',
7+
'.gitattributes',
8+
'.gitignore',
9+
'.npmrc',
10+
'.travis.yml',
11+
'appveyor.yml',
12+
'CHANGELOG.md',
13+
'circle.yml',
14+
'LICENSE',
15+
'package.json',
16+
'README.md'
17+
];

generators/app/index.js

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const Generator = require('yeoman-generator');
2+
const validate = require('./validate');
3+
4+
module.exports = class extends Generator {
5+
6+
initializing() {
7+
this.log('OSS Project Generator');
8+
this.log();
9+
}
10+
11+
prompting() {
12+
const done = this.async();
13+
const store = true;
14+
15+
const prompts = [
16+
{
17+
type: 'input',
18+
name: 'project',
19+
message: 'What is the name of your project',
20+
default: 'awesome-project'
21+
},
22+
{
23+
type: 'input',
24+
name: 'description',
25+
message: 'What is the description of your project',
26+
default: 'An awesome project'
27+
},
28+
{
29+
type: 'input',
30+
name: 'name',
31+
message: 'What is your name',
32+
validate: validate.validateName,
33+
store: store
34+
},
35+
{
36+
type: 'input',
37+
name: 'email',
38+
message: 'What is your email',
39+
validate: validate.validateEmail,
40+
store: store
41+
},
42+
{
43+
type: 'input',
44+
name: 'username',
45+
message: 'What is your GitHub username',
46+
validate: validate.validateUsername,
47+
store: store
48+
}
49+
];
50+
51+
this.prompt(prompts).then((props) => {
52+
this.props = props;
53+
done();
54+
});
55+
}
56+
57+
writing() {
58+
this.log('Generating project...');
59+
this.log();
60+
61+
const files = require('./files');
62+
63+
const templates = {
64+
project: this.props.project,
65+
description: this.props.description,
66+
name: this.props.name,
67+
email: this.props.email,
68+
username: this.props.username,
69+
year: new Date().getFullYear()
70+
};
71+
72+
files.forEach((file) => {
73+
this.fs.copyTpl(
74+
this.templatePath(file),
75+
this.destinationPath(file),
76+
templates
77+
);
78+
});
79+
}
80+
81+
install() {
82+
this.installDependencies({ bower: false });
83+
}
84+
85+
end() {
86+
this.log();
87+
this.log('Successfully generated!');
88+
}
89+
};
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = off
14+
trim_trailing_whitespace = false
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

generators/app/templates/.eslintrc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"jest": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"rules": {
9+
"indent": [
10+
"error",
11+
2
12+
],
13+
"linebreak-style": [
14+
"error",
15+
"unix"
16+
],
17+
"quotes": [
18+
"error",
19+
"single"
20+
],
21+
"semi": [
22+
"error",
23+
"always"
24+
]
25+
}
26+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.* text=auto eol=lf

generators/app/templates/.gitignore

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env

generators/app/templates/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact = true

generators/app/templates/.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
node_js:
3+
- "6"
4+
install:
5+
- npm install
6+
script:
7+
- npm test
8+
after_script:
9+
- npm run coveralls
10+
notifications:
11+
email:
12+
on_success: never
13+
on_failure: always

generators/app/templates/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## 1.0.0
4+
Initial release

generators/app/templates/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) <%= year%> <%= name%>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)