Skip to content

Commit d22fda9

Browse files
committed
Add prepublish script
1 parent f3fc4a8 commit d22fda9

File tree

3 files changed

+85
-23
lines changed

3 files changed

+85
-23
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
"build": "react-scripts build",
7171
"test": "react-scripts test",
7272
"eject": "react-scripts eject",
73+
"clean-files": "rm -rf ./template/public ./template/src && rm -f ./template/.eslintignore ./template/.eslintrc ./template/.prettierrc ./template/README.md ./template/README_CRA.md ./template/tsconfig.json",
74+
"copy-files": "cp -a ./src/. template/src && cp -a ./public/. template/public && cp .eslintignore .eslintrc .prettierrc tsconfig.json README.md README_CRA.md template/",
75+
"prepublishOnly": "yarn clean-files && yarn copy-files",
7376
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./",
7477
"fix": "eslint --ext .js,.jsx,.ts,.tsx --fix ./"
7578
},

template/README.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# A quick start Redux Create React App template
2+
3+
An opinionated quick start [Create React App](https://github.com/facebook/create-react-app) (CRA) template with **Redux**, **TypeScript**, **React Router**, **Enzyme** and custom ESlint configuration.
4+
5+
Original Create React App README available [here](./README_CRA.md)
6+
7+
## Usage
8+
9+
`npx create-react-app <your-project_name> --template typescript-redux`
10+
11+
Or
12+
13+
`yarn create react-app <your-project_name> --template typescript-redux`
14+
15+
`npx` command installs most recent stable version of CRA from npm. `--template` parameter points to this template, note that `cra-template-` prefix is omitted.
16+
17+
## Motivation
18+
19+
You know the pain. You start a new project and need to configure it again and again. It needs routing, ok you setup Router, then you need Redux - ok, oh. Wait... All of these tools you get used to. Redux boilerplate is taking some much to type. I want just to focus on building amazing projects and not spending hours configuring tools. That's why I've created this template. It's for you to use.
220

321
## Available Scripts
422

523
In the project directory, you can run:
624

7-
### `yarn start`
25+
- `yarn start` - runs the app in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
26+
27+
- `yarn test` - launches the test runner in the interactive watch mode.
828

9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
29+
- `yarn build` - builds the app for production to the `build` folder.
1130

12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
31+
- `yarn eject` - exposes content of `react-script` package
1432

15-
### `yarn test`
33+
- `yarn lint` - lints project files according to eslint rules, see below. Typical use case: continuous integration environments, Travis, CircleCI, etc.
1634

17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
35+
- `yarn fix` - same as `yarn lint`, but also fixes errors, when possible. Typical use case: local development environment, git hooks.
1936

20-
### `yarn build`
37+
Due to CRA template limitations (we can change only `scripts` and `dependencies` inside generated `package.json`) all configuration is done by adding config files where possible. Also no `devDependencies` for now, sorry.
2138

22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
39+
## Redux configuration
2440

25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
41+
Template provides basic Redux configuration with [feature based](https://redux.js.org/style-guide/style-guide/#structure-files-as-feature-folders-or-ducks) folder structure. You can use [Redux devtools browser extension](http://extension.remotedev.io/). Sample feature included in `src/features` folder, note technology agnostic `features` folder name. Based on Redux maintainers recommendation.
2742

28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
43+
## Testing
2944

30-
### `yarn eject`
45+
Snapshot testing done with [Enzyme](https://airbnb.io/enzyme/).
3146

32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
47+
## [Prettier](https://prettier.io/)
3348

34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
49+
I added `prettier` to force consistent formatting. Don't like trailing semicolons? Feel free to [tweak prettier rules](https://prettier.io/docs/en/configuration.html) inside `.prettierrc` file to match your code style.
3550

36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
51+
## Eslint configurations
3752

38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
53+
Template extends CRA eslint rules with custom set, tailored for reasonable and clean development process.
3954

40-
## Learn More
55+
Eslint rules are commented for your convenience feel free to tweak or remove them inside `.eslintrc`. No judgement.
4156

42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
57+
## Thank you
4358

44-
To learn React, check out the [React documentation](https://reactjs.org/).
59+
I hope this template will be helpful for you and you will love using it 💖!

template/README_CRA.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `yarn start`
8+
9+
Runs the app in the development mode.<br />
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br />
13+
You will also see any lint errors in the console.
14+
15+
### `yarn test`
16+
17+
Launches the test runner in the interactive watch mode.<br />
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `yarn build`
21+
22+
Builds the app for production to the `build` folder.<br />
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br />
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `yarn eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).

0 commit comments

Comments
 (0)