Skip to content

Commit

Permalink
Merge pull request #2 from gameclub000/feature-initialize
Browse files Browse the repository at this point in the history
构建基础项目框架
  • Loading branch information
gameclub000 authored Sep 16, 2020
2 parents 5dc76c0 + 1a8395b commit 9e805ae
Show file tree
Hide file tree
Showing 33 changed files with 7,949 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"env": {
"test": {
"presets": ["@babel/preset-env", "@babel/react", "next/babel"]
},
"development": {
"presets": ["next/babel"]
},
"production": {
"presets": ["next/babel"]
}
}
}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* 构建基础项目框架
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:14.9.0

WORKDIR /app

COPY ./ /app

RUN yarn install

RUN yarn build

CMD ["yarn", "start"]
9 changes: 9 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:14.9.0

WORKDIR /app

COPY ./ /app

RUN yarn install

CMD ["yarn", "dev"]
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
# Bill
# Bill

一个简易的记账本应用程序

## System Requirements

|Env| MacOS:Docker | Ubuntu |
| ------ | ------ |------ |
|Memory|2 GB RAM|2 GB RAM|
|Free space|10 GB|10 GB|

## Getting Started

请根据以下指示运行项目:

### MacOS(Docker)

1. 安装 [Docker](https://docs.docker.com/get-docker/)
2. 检查端口`3000`是否被占用
3. 在根目录打开命令行工具
4. 运行以下命令启动项目
```shell
docker-compose -f docker-compose.yml up
```

### Ubuntu

1. 安装 [Node.js](https://nodejs.org/en/download/)

2. 安装依赖

```bash
npm install
# or
yarn install
```
3. 运行以下命令启动项目

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
3 changes: 3 additions & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// __mocks__/fileMock.js

module.exports = 'test-file-stub';
3 changes: 3 additions & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// __mocks__/styleMock.js

module.exports = {};
1 change: 1 addition & 0 deletions components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 组件
1 change: 1 addition & 0 deletions components/base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 组建-基础组件
3 changes: 3 additions & 0 deletions components/base/Title/Title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const Title = ({ label }) => <h1>{label}</h1>;

export default Title;
12 changes: 12 additions & 0 deletions components/base/Title/Title.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { mount } from 'enzyme';

import Title from './title';

/** @test {Title Component} */
describe('Title Component', () => {
it('should render without crashing', () => {
const wrapper = mount(<Title label="test" />);

expect(wrapper.find('h1')).toHaveLength(1);
});
});
1 change: 1 addition & 0 deletions components/common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 组建-公用组件
1 change: 1 addition & 0 deletions components/containers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 组建-容器组件
1 change: 1 addition & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 配置文件
13 changes: 13 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.5'

services:
bill_dev:
container_name: 'bill_dev'
ports:
- 3000:3000
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app
- /app/node_modules
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.5'

services:
bill:
command: yarn start
container_name: 'bill'
ports:
- 3000:3000
build:
context: .
dockerfile: Dockerfile
35 changes: 35 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
collectCoverageFrom: [
'**/*.{js,jsx}',
'!**/node_modules/**',
'!**/tests/**',
'!**/coverage/**',
'!jest.config.js'
],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
},
moduleNameMapper: {
'\\.(css|less|scss)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'@/(.*)$': '<rootDir>/$1'
},
setupFiles: ['<rootDir>/tests/setup.js'],
setupFilesAfterEnv: ['<rootDir>/tests/setupAfterEnv.js'],
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'/.next/',
'/node_modules/',
'/tests/',
'/coverage/'
],
transform: {
'^.+\\.jsx?$': 'babel-jest'
}
};
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "bill",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
},
"dependencies": {
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"@reduxjs/toolkit": "^1.4.0",
"babel-jest": "^26.3.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.4",
"jest": "^26.4.2",
"next": "^9.5.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.1"
}
}
13 changes: 13 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '../styles/globals.css';
import { Provider } from 'react-redux';
import store from '../store';

function MyApp({ Component, pageProps }) {
return (
<Provider store={store}>
<Component {...pageProps} />
</Provider>
);
}

export default MyApp;
6 changes: 6 additions & 0 deletions pages/api/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

export default (req, res) => {
res.statusCode = 200
res.json({ name: 'John Doe' })
}
65 changes: 65 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Head from 'next/head'
import styles from '../styles/Home.module.css'

export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>

<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>

<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.js</code>
</p>

<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
<h3>Documentation &rarr;</h3>
<p>Find in-depth information about Next.js features and API.</p>
</a>

<a href="https://nextjs.org/learn" className={styles.card}>
<h3>Learn &rarr;</h3>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>

<a
href="https://github.com/vercel/next.js/tree/master/examples"
className={styles.card}
>
<h3>Examples &rarr;</h3>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>

<a
href="https://vercel.com/import?filter=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h3>Deploy &rarr;</h3>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
</a>
</footer>
</div>
)
}
36 changes: 36 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// prettier.config.js or .prettierrc.js
module.exports = {
// 一行最多 100 字符
printWidth: 100,
// 使用 4 个空格缩进
tabWidth: 4,
// 不使用缩进符,而使用空格
useTabs: false,
// 行尾需要有分号
semi: true,
// 使用单引号
singleQuote: true,
// jsx 不使用单引号,而使用双引号
jsxSingleQuote: false,
// 末尾不需要逗号
trailingComma: 'none',
// 大括号内的首尾需要空格
bracketSpacing: true,
// jsx 标签的反尖括号需要换行
jsxBracketSameLine: false,
// 箭头函数,只有一个参数的时候,也需要括号
arrowParens: 'always',
// 每个文件格式化的范围是文件的全部内容
rangeStart: 0,
rangeEnd: Infinity,
// 不需要写文件开头的 @prettier
requirePragma: false,
// 不需要自动在文件开头插入 @prettier
insertPragma: false,
// 使用默认的折行标准
proseWrap: 'preserve',
// 根据显示样式决定 html 要不要折行
htmlWhitespaceSensitivity: 'css',
// 换行符使用 lf
endOfLine: 'lf'
};
8 changes: 8 additions & 0 deletions public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 静态资源目录

Next.js 默认以`public`为静态资源目录:

* https://nextjs.org/learn/basics/assets-metadata-css/assets

> Next.js can serve static files, like images, under the top-level public directory. Files inside public can be referenced from the root of the application similar to pages.
Binary file added public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added store/README.md
Empty file.
6 changes: 6 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { configureStore } from '@reduxjs/toolkit';

export default configureStore({
reducer: {
}
});
Loading

0 comments on commit 9e805ae

Please sign in to comment.