Skip to content

Commit

Permalink
Initial commit from Create Next App
Browse files Browse the repository at this point in the history
  • Loading branch information
willianjusten committed Aug 23, 2020
0 parents commit badbf4a
Show file tree
Hide file tree
Showing 39 changed files with 15,329 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"plugins": [
[
"babel-plugin-styled-components",
{
"ssr": true
}
]
],
"presets": ["next/babel", "@babel/preset-typescript"]
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
indent_style = spaces
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!.storybook
!.jest
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"env": {
"browser": true,
"es2020": true,
"jest": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ci
on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install dependencies
run: yarn install

- name: Linting
run: yarn lint

- name: Test
run: yarn test

- name: Build
run: yarn build
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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

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

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

# sw stuff
public/sw.js
public/workbox-*.js

# storybook
storybook-static
2 changes: 2 additions & 0 deletions .jest/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@testing-library/jest-dom'
import 'jest-styled-components'
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!.storybook
!.jest
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "none",
"semi": false,
"singleQuote": true
}
4 changes: 4 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
stories: ['../src/components/**/stories.tsx'],
addons: ['@storybook/addon-essentials']
}
10 changes: 10 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import GlobalStyles from '../src/styles/global'

export const decorators = [
(Story) => (
<>
<GlobalStyles />
<Story />
</>
)
]
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

![React Avançado](https://raw.githubusercontent.com/React-Avancado/boilerplate/master/public/img/logo-gh.svg)

This is a [Next.js](https://nextjs.org/) boilerplate to be used in a course called [React Avançado](https://reactavancado.com.br/).
![ci](https://github.com/React-Avancado/boilerplate/workflows/ci/badge.svg)
## What is inside?

This project uses lot of stuff as:

- [TypeScript](https://www.typescriptlang.org/)
- [NextJS](https://nextjs.org/)
- [Styled Components](https://styled-components.com/)
- [Jest](https://jestjs.io/)
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
- [Storybook](https://storybook.js.org/)
- [Eslint](https://eslint.org/)
- [Prettier](https://prettier.io/)
- [Husky](https://github.com/typicode/husky)

## Getting Started

First, run the development server:

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

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.

## Commands

- `dev`: runs your application on `localhost:3000`
- `build`: creates the production build version
- `start`: starts a simple server with the build production code
- `lint`: runs the linter in all components and pages
- `test`: runs jest to test all components and pages
- `test:watch`: runs jest in watch mode
- `storybook`: runs storybook on `localhost:6006`
- `build-storybook`: create the build version of storybook

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
34 changes: 34 additions & 0 deletions generators/plopfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = (plop) => {
plop.setGenerator('component', {
description: 'Create a component',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?'
}
],
actions: [
{
type: 'add',
path: '../src/components/{{pascalCase name}}/index.tsx',
templateFile: 'templates/Component.tsx.hbs'
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/styles.ts',
templateFile: 'templates/styles.ts.hbs'
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/stories.tsx',
templateFile: 'templates/stories.tsx.hbs'
},
{
type: 'add',
path: '../src/components/{{pascalCase name}}/test.tsx',
templateFile: 'templates/test.tsx.hbs'
}
]
})
}
9 changes: 9 additions & 0 deletions generators/templates/Component.tsx.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as S from './styles'

const {{pascalCase name}} = () => (
<S.Wrapper>
<h1>{{pascalCase name}}</h1>
</S.Wrapper>
)

export default {{pascalCase name}}
9 changes: 9 additions & 0 deletions generators/templates/stories.tsx.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Story, Meta } from '@storybook/react/types-6-0'
import {{pascalCase name}} from '.'

export default {
title: '{{pascalCase name}}',
component: {{pascalCase name}}
} as Meta

export const Default: Story = () => <{{pascalCase name}} />
3 changes: 3 additions & 0 deletions generators/templates/styles.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styled from 'styled-components'

export const Wrapper = styled.main``
13 changes: 13 additions & 0 deletions generators/templates/test.tsx.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { render, screen } from '@testing-library/react'

import {{pascalCase name}} from '.'

describe('<{{pascalCase name}} />', () => {
it('should render the heading', () => {
const { container } = render(<{{pascalCase name}} />)

expect(screen.getByRole('heading', { name: /{{pascalCase name}}/i })).toBeInTheDocument()

expect(container.firstChild).toMatchSnapshot()
})
})
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/.next/'],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts(x)?', '!src/**/stories.tsx'],
setupFilesAfterEnv: ['<rootDir>/.jest/setup.ts'],
modulePaths: ['<rootDir>/src/']
}
2 changes: 2 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPWA = require('next-pwa')
const isProd = process.env.NODE_ENV === 'production'

module.exports = withPWA({
pwa: {
dest: 'public',
disable: !isProd
}
})
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "react-avancado-boilerplate",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint src --max-warnings=0",
"test": "jest",
"test:watch": "yarn test --watch",
"generate": "yarn plop --plopfile generators/plopfile.js",
"storybook": "start-storybook -s ./public -p 6006",
"build-storybook": "build-storybook -s ./public"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*": [
"yarn lint --fix",
"yarn test --findRelatedTests --bail"
]
},
"dependencies": {
"next": "9.5.2",
"next-pwa": "^3.1.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"styled-components": "^5.1.1"
},
"devDependencies": {
"@babel/core": "^7.11.4",
"@babel/preset-typescript": "^7.10.4",
"@storybook/addon-essentials": "6.0.16",
"@storybook/react": "6.0.16",
"@testing-library/jest-dom": "^5.11.3",
"@testing-library/react": "^10.4.9",
"@types/jest": "^26.0.10",
"@types/node": "^14.6.0",
"@types/react": "^16.9.46",
"@types/styled-components": "^5.1.2",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"babel-loader": "^8.1.0",
"babel-plugin-styled-components": "^1.11.1",
"eslint": "^7.7.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"husky": "^4.2.5",
"jest": "^26.4.1",
"jest-styled-components": "^7.0.3",
"lint-staged": "^10.2.11",
"plop": "^2.7.4",
"prettier": "^2.0.5",
"typescript": "^4.0.2"
}
}
Loading

0 comments on commit badbf4a

Please sign in to comment.