Skip to content

Commit 09d7fff

Browse files
committed
feature: add generator
1 parent 16daaa0 commit 09d7fff

16 files changed

+308
-5
lines changed

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ build/Release
3636
node_modules/
3737
jspm_packages/
3838

39-
# Typescript v1 declaration files
39+
# TypeScript v1 declaration files
4040
typings/
4141

4242
# Optional npm cache directory
@@ -56,3 +56,18 @@ typings/
5656

5757
# dotenv environment variables file
5858
.env
59+
60+
# parcel-bundler cache (https://parceljs.org/)
61+
.cache
62+
63+
# next.js build output
64+
.next
65+
66+
# nuxt.js build output
67+
.nuxt
68+
69+
# vuepress build output
70+
.vuepress/dist
71+
72+
# Serverless directories
73+
.serverless

generators/app/files.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = [
2+
{ template: 'src/index.js.template', destination: 'src/index.js' },
3+
{ template: 'CHANGELOG.md.template', destination: 'CHANGELOG.md' },
4+
{ template: 'editorconfig.template', destination: '.editorconfig' },
5+
{ template: 'eslintignore.template', destination: '.eslintignore' },
6+
{ template: 'eslintrc.json.template', destination: '.eslintrc.json' },
7+
{ template: 'gitattributes.template', destination: '.gitattributes' },
8+
{ template: 'gitignore.template', destination: '.gitignore' },
9+
{ template: 'LICENSE.template', destination: 'LICENSE' },
10+
{ template: 'npmrc.template', destination: '.npmrc' },
11+
{ template: 'package.json.template', destination: 'package.json' },
12+
{ template: 'prettierrc.template', destination: '.prettierrc' },
13+
{ template: 'README.md.template', destination: 'README.md' }
14+
];

generators/app/index.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const Generator = require('yeoman-generator');
2+
3+
const files = require('./files');
4+
5+
module.exports = class extends Generator {
6+
initializing() {
7+
this.log('Statik Project Generator');
8+
this.log('Made with ❤️ by Statik');
9+
this.log();
10+
}
11+
12+
prompting() {
13+
const done = this.async();
14+
15+
const prompts = [
16+
{
17+
type: 'input',
18+
name: 'project',
19+
message: 'What is the name of your project?',
20+
default: 'statik-project'
21+
},
22+
{
23+
type: 'input',
24+
name: 'description',
25+
message: 'What is the description of your project?',
26+
default: 'A statik project'
27+
}
28+
];
29+
30+
this.prompt(prompts).then((props) => {
31+
this.props = props;
32+
33+
console.log(props);
34+
done();
35+
});
36+
}
37+
38+
writing() {
39+
this.log();
40+
this.log('🚀 Generating project...');
41+
this.log();
42+
43+
const { project, description } = this.props;
44+
45+
const templates = {
46+
project,
47+
description,
48+
year: new Date().getFullYear()
49+
};
50+
51+
files.forEach((file) => {
52+
this.fs.copyTpl(
53+
this.templatePath(file.template),
54+
this.destinationPath(file.destination),
55+
templates
56+
);
57+
});
58+
}
59+
60+
install() {
61+
this.log();
62+
this.log('📦 Installing dependencies...');
63+
this.log();
64+
65+
this.npmInstall(
66+
[
67+
'eslint',
68+
'eslint-config-prettier',
69+
'eslint-plugin-prettier',
70+
'prettier'
71+
],
72+
{ 'save-dev': true }
73+
);
74+
}
75+
76+
end() {
77+
this.log();
78+
this.log('🎉 Successfully generated!');
79+
}
80+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 1.0.0
4+
5+
* Initial release
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) <%= year %> Statik
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.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# <%= project %>
2+
3+
Generated by [Statik Project Generator](https://github.com/statikstack/generator-statikstack).
4+
5+
[![License][license-badge]][license-url]
6+
7+
> <%= description %>
8+
9+
# Development
10+
11+
* Cloning the repo
12+
13+
```bash
14+
$ git clone https://github.com/statikstack/<%= project %>.git
15+
```
16+
17+
* Installing dependencies
18+
19+
```bash
20+
$ npm install
21+
```
22+
23+
* Running scripts
24+
25+
| Action | Usage |
26+
| ------------------------- | -------------- |
27+
| Starting development mode | `npm start` |
28+
| Linting code | `npm run lint` |
29+
30+
# Author
31+
32+
[Statik](https://twitter.com/statikstack)
33+
34+
# License
35+
36+
[MIT](https://github.com/statikstack/<%= project %>/blob/master/LICENSE)
37+
38+
[license-badge]: https://img.shields.io/github/license/statikstack/<%= project %>.svg
39+
[license-url]: https://opensource.org/licenses/MIT
Lines changed: 14 additions & 0 deletions
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["plugin:prettier/recommended"],
3+
"env": {
4+
"es6": true
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

0 commit comments

Comments
 (0)