Skip to content

Commit 5d6cd89

Browse files
committed
initialize
1 parent 6d95467 commit 5d6cd89

27 files changed

+3775
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
node_modules
3+
*.log

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# template-react-app
2+
3+
> React template for web app, powered by [Poi](https://poi.js.org/).
4+
5+
- [x] prettier + eslint
6+
- [x] PWA
7+
8+
## Usage
9+
10+
Install [SAO](https://github.com/egoist/sao) first.
11+
12+
```bash
13+
yarn global add sao
14+
# or
15+
npm i -g sao
16+
```
17+
18+
### From npm
19+
20+
```bash
21+
sao react-app my-project
22+
```
23+
24+
### From git
25+
26+
```bash
27+
sao dwarvesf/template-react-app my-project
28+
```
29+
30+
## License
31+
32+
MIT © [dwarvesf](github.com/dwarvesf)

circle.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/project
5+
docker:
6+
- image: circleci/node:latest
7+
branches:
8+
ignore:
9+
- gh-pages # list of branches to ignore
10+
- /release\/.*/ # or ignore regexes
11+
steps:
12+
- checkout
13+
- restore_cache:
14+
key: dependency-cache-{{ checksum "yarn.lock" }}
15+
- run:
16+
name: install dependences
17+
command: yarn install
18+
- save_cache:
19+
key: dependency-cache-{{ checksum "yarn.lock" }}
20+
paths:
21+
- ./node_modules
22+
- run:
23+
name: test
24+
command: yarn test

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "template-react-app",
3+
"version": "0.0.0",
4+
"description": "React template for web app",
5+
"repository": {
6+
"url": "dwarvesf/template-react-app",
7+
"type": "git"
8+
},
9+
"author": "dwarvesf <gnhuy91@gmail.com> (github.com/dwarvesf)",
10+
"license": "MIT",
11+
"files": [
12+
"sao.js",
13+
"template"
14+
],
15+
"scripts": {
16+
"test": "ava"
17+
},
18+
"devDependencies": {
19+
"ava": "^0.21.0",
20+
"sao": "^0.22.1"
21+
}
22+
}

sao.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
prompts: {
3+
name: {
4+
message: 'What is the name of the new project?',
5+
default: ':folderName:',
6+
},
7+
description: {
8+
message: 'How would you descripe the new project?',
9+
default: 'my web project',
10+
},
11+
pwa: {
12+
message: 'PWA support?',
13+
type: 'confirm',
14+
default: true,
15+
},
16+
},
17+
data({ username }) {
18+
return {
19+
website: `github.com/dwarvesf`,
20+
};
21+
},
22+
filters: {
23+
'static/manifest.json': 'pwa',
24+
},
25+
move: {
26+
gitignore: '.gitignore',
27+
},
28+
showTip: true,
29+
gitInit: true,
30+
installDependencies: true,
31+
post(context, stream) {
32+
console.log(context)
33+
console.log(stream)
34+
},
35+
};

template/.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["poi"],
3+
"plugins": [
4+
"react-hot-loader/babel"
5+
]
6+
}

template/.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

template/.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
parser: 'babel-eslint',
3+
extends: [
4+
'standard',
5+
'plugin:react/recommended',
6+
'prettier',
7+
'prettier/react',
8+
'prettier/standard',
9+
],
10+
plugins: ['react', 'prettier', 'standard'],
11+
parserOptions: {
12+
sourceType: 'module',
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
env: {
18+
browser: true,
19+
es6: true,
20+
jest: true,
21+
},
22+
rules: {
23+
'prettier/prettier': [
24+
'error',
25+
{
26+
printWidth: 80,
27+
tabWidth: 2,
28+
useTabs: false,
29+
semi: true,
30+
singleQuote: true,
31+
trailingComma: 'all',
32+
bracketSpacing: true,
33+
},
34+
],
35+
'react/prop-types': 'off',
36+
camelcase: 'off',
37+
},
38+
};

template/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

template/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Dwarves Foundation (github.com/dwarvesf)
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
13+
all 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
21+
THE SOFTWARE.

template/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# <%= name %>
2+
3+
> <%= description %>
4+
5+
## Usage
6+
7+
Install [SAO](https://github.com/egoist/sao) first.
8+
9+
```bash
10+
yarn global add sao
11+
# or
12+
npm i -g sao
13+
```
14+
15+
### From npm
16+
17+
```bash
18+
sao <%= name.replace('template-', '') %> my-project
19+
```
20+
21+
### From git
22+
23+
```bash
24+
sao <%= username %>/<%= name %> my-project
25+
```
26+
27+
## License
28+
29+
MIT &copy; [<%= username %>](<%= website %>)

template/gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# dependencies
2+
node_modules
3+
4+
# logs
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# production build
10+
/dist
11+
12+
# misc
13+
.DS_Store
14+
.env
15+
.env.*

template/index.ejs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
6+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
7+
<link rel="shortcut icon" href="<%%= htmlWebpackPlugin.files.publicPath %%>favicon.ico">
8+
<title><%%= htmlWebpackPlugin.options.title %%></title>
9+
10+
<% if (pwa) { %>
11+
<link rel="manifest" href="<%%= htmlWebpackPlugin.files.publicPath %%>manifest.json">
12+
<meta name="theme-color" content="#ffffff">
13+
<% } %>
14+
15+
<%% if (htmlWebpackPlugin.options.description) { %%>
16+
<meta name="description" content="<%%= htmlWebpackPlugin.options.description %%>"/>
17+
<%% } %%>
18+
19+
<%% for (var chunk of webpack.chunks) {
20+
for (var file of chunk.files) {
21+
if (file.match(/\.(js|css)$/)) { %%>
22+
<link rel="<%%= chunk.initial?'preload':'prefetch' %%>" href="<%%= htmlWebpackPlugin.files.publicPath + file %%>" as="<%%= file.match(/\.css$/)?'style':'script' %%>">
23+
<%% }}} %%>
24+
</head>
25+
<body>
26+
<noscript>
27+
You need to enable JavaScript to run this app.
28+
</noscript>
29+
<div id="app"></div>
30+
</body>
31+
</html>

template/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "<%= _.folderName %>",
3+
"private": true,
4+
"scripts": {
5+
"dev": "poi",
6+
"build": "poi build"
7+
},
8+
"dependencies": {<% if (pwa) { %>
9+
"offline-plugin": "^5.0.3",<% } %>
10+
"react": "^16.4.0",
11+
"react-dom": "^16.4.0"
12+
},
13+
"devDependencies": {
14+
"@poi/plugin-eslint": "^10.0.2",<% if (pwa) { %>
15+
"@poi/plugin-offline": "^10.0.1",<% } %>
16+
"babel-eslint": "^8.2.3",
17+
"babel-preset-poi": "^10.0.1",
18+
"eslint": "^4.19.1",
19+
"eslint-config-prettier": "^2.9.0",
20+
"eslint-config-standard": "^11.0.0",
21+
"eslint-plugin-import": "^2.9.0",
22+
"eslint-plugin-node": "^6.0.1",
23+
"eslint-plugin-prettier": "^2.6.0",
24+
"eslint-plugin-promise": "^3.7.0",
25+
"eslint-plugin-react": "^7.7.0",
26+
"eslint-plugin-standard": "^3.0.1",
27+
"poi": "^10.2.1",
28+
"react-hot-loader": "^4.2.0"
29+
}
30+
}

template/poi.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
env: true,
5+
entry: 'src/index.js',
6+
plugins: [
7+
require('@poi/plugin-eslint')(),<% if(pwa) { %>
8+
require('@poi/plugin-offline')(),<% } %>
9+
],
10+
}

template/src/App.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
animation: App-logo-spin infinite 20s linear;
7+
height: 80px;
8+
}
9+
10+
.App-header {
11+
background-color: #222;
12+
height: 150px;
13+
padding: 20px;
14+
color: white;
15+
}
16+
17+
.App-title {
18+
font-size: 1.5em;
19+
}
20+
21+
.App-intro {
22+
font-size: large;
23+
}
24+
25+
@keyframes App-logo-spin {
26+
from { transform: rotate(0deg); }
27+
to { transform: rotate(360deg); }
28+
}

template/src/App.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { Component } from 'react';
2+
import { hot } from 'react-hot-loader';
3+
4+
import logo from './logo.svg';
5+
import './App.css';
6+
7+
class App extends Component {
8+
render() {
9+
return (
10+
<div className="App">
11+
<header className="App-header">
12+
<img src={logo} className="App-logo" alt="logo" />
13+
<h1 className="App-title">Welcome to React</h1>
14+
</header>
15+
<p className="App-intro">
16+
To get started, edit <code>src/App.js</code> and save to reload.
17+
</p>
18+
</div>
19+
);
20+
}
21+
}
22+
23+
export default hot(module)(App);

0 commit comments

Comments
 (0)