Skip to content

Commit 89d0f10

Browse files
committed
setup cra for coderoad
1 parent 5e71df7 commit 89d0f10

File tree

17 files changed

+151
-10833
lines changed

17 files changed

+151
-10833
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@
2121
npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
24+
25+
# ignore to avoid merge conflicts in CodeRoad
26+
package-lock.json
27+
yarn.lock

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint", "msjsdiag.debugger-for-chrome"]
5+
}

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
// run Chrome with the VSCode debugger
6+
"name": "Chrome",
7+
"type": "chrome",
8+
"request": "launch",
9+
"url": "http://localhost:3000",
10+
"webRoot": "${workspaceFolder}/src",
11+
"sourceMapPathOverrides": {
12+
"webpack:///src/*": "${webRoot}/*"
13+
}
14+
}
15+
]
16+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.organizeImports": true,
5+
"source.fixAll": true
6+
},
7+
"eslint.validate": [
8+
"javascript",
9+
"javascriptreact",
10+
"typescript",
11+
"typescriptreact"
12+
]
13+
}

README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# CodeRoad Tutorial React Starter
2+
3+
This project is a working starter boilerplate for a React based CodeRoad tutorial.
4+
5+
See [instructions for reverting back](#Revert-to-Create-React-App) to its original [Create React App](https://github.com/facebook/create-react-app) template.
26

37
## Available Scripts
48

@@ -27,16 +31,6 @@ Your app is ready to be deployed!
2731

2832
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
2933

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-
4034
## Learn More
4135

4236
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
@@ -66,3 +60,35 @@ This section has moved here: https://facebook.github.io/create-react-app/docs/de
6660
### `yarn build` fails to minify
6761

6862
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
63+
64+
## Revert to Create-React-App
65+
66+
This project is slightly modified from the original create-react-app config in order to integrate with CodeRoad's testing tools. See react-app-rewired for details on how these modifications are implemented: https://github.com/timarney/react-app-rewired.
67+
68+
If you're done with your CodeRoad course, feel free to revert back. Just follow the instructions below:
69+
70+
1. delete the following file: `config.overrides.js`
71+
2. Remove unused packages by running the following:
72+
73+
```shell
74+
npm uninstall react-app-rewired jest-tap-reporter
75+
```
76+
77+
3. Revert the scripts in package.json back to their original formats:
78+
79+
```json
80+
"scripts": {
81+
"start": "react-scripts start",
82+
"build": "react-scripts build",
83+
"test": "react-scripts test"
84+
},
85+
```
86+
87+
4. Remove the following lines from your `.gitignore` file. These should be enabled when publishing or sharing your application.
88+
89+
```ms
90+
package-lock.json
91+
yarn.lock
92+
```
93+
94+
Happy hacking!

config-overrides.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Config is overwritten for the CodeRoad integration
3+
because of the need to change the Jest reporter on tests.
4+
See the README for details on how to revert back.
5+
*/
6+
7+
module.exports = {
8+
webpack: config => {
9+
return config;
10+
},
11+
devServer: config => {
12+
return config;
13+
},
14+
jest: config => ({
15+
...config,
16+
// stop running tests after `n` failures
17+
bail: 1,
18+
// use jest-tap-reporter with CodeRoad tests
19+
reporters: ["jest-tap-reporter"],
20+
// disable test coverage collection for performance
21+
collectCoverage: false,
22+
collectCoverageFrom: [],
23+
// add a test setup file if need
24+
setupFilesAfterEnv: ["./src/tests/setupTests.js"],
25+
// unused fields with CodeRoad
26+
watchPlugins: []
27+
}),
28+
paths(paths, env) {
29+
return paths;
30+
}
31+
};

package.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
{
2-
"name": "twitter-clone",
2+
"name": "coderoad-react-tutorial-starter",
33
"version": "0.1.0",
44
"private": true,
5-
"dependencies": {
6-
"@testing-library/jest-dom": "^4.2.4",
7-
"@testing-library/react": "^9.3.2",
8-
"@testing-library/user-event": "^7.1.2",
9-
"react": "^16.12.0",
10-
"react-dom": "^16.12.0",
11-
"react-scripts": "3.3.0"
12-
},
135
"scripts": {
14-
"start": "react-scripts start",
15-
"build": "react-scripts build",
16-
"test": "react-scripts test",
17-
"eject": "react-scripts eject"
18-
},
19-
"eslintConfig": {
20-
"extends": "react-app"
6+
"build": "react-app-rewired build",
7+
"start": "react-app-rewired start",
8+
"test": "react-app-rewired test --watchAll=false"
219
},
2210
"browserslist": {
2311
"production": [
@@ -30,5 +18,20 @@
3018
"last 1 firefox version",
3119
"last 1 safari version"
3220
]
21+
},
22+
"eslintConfig": {
23+
"extends": "react-app"
24+
},
25+
"dependencies": {
26+
"@testing-library/jest-dom": "^4.2.4",
27+
"@testing-library/react": "^9.3.2",
28+
"@testing-library/user-event": "^8.0.2",
29+
"react": "^16.12.0",
30+
"react-dom": "^16.12.0",
31+
"react-scripts": "3.3.0"
32+
},
33+
"devDependencies": {
34+
"jest-tap-reporter": "^1.9.0",
35+
"react-app-rewired": "^2.1.5"
3336
}
3437
}

src/App.js

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React from "react";
42

5-
function App() {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
24-
}
3+
const App = () => {
4+
return <div>Welcome to CodeRoad</div>;
5+
};
256

267
export default App;

src/App.test.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/index.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)