Skip to content

Commit 4895f50

Browse files
authored
Merge pull request mac-s-g#154 from mac-s-g/imrove-docs
updated tests, improved docs
2 parents 45a49cb + 352e5c3 commit 4895f50

28 files changed

+1132
-594
lines changed

.nycrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"plugins": ["transform-decorators-legacy"],
33
"require": [
44
"babel-register",
5-
"/react/test/testHelpers/requireSources.js"
5+
"./test/testHelpers/requireSources.js"
66
]
77
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ language: node_js
77
node_js:
88
- "8"
99
script:
10-
- ./docker/test-travis.sh
10+
- ./docker/test.sh

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MAINTAINER mac <[email protected]>
44
# install the node modules at container build time
55
RUN mkdir -p /react
66
ADD package.json /react/package.json
7-
RUN cd /react && npm install --silent
7+
RUN cd /react && npm install --save-dev --silent
88

99
# Now add our project code
1010
ADD . /react

README.md

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,40 +108,34 @@ The following object will be passed to your method:
108108
Returning `false` from a callback method will prevent the src from being affected.
109109

110110
### Contributing to the source code
111-
#### Linux and Docker (Recommended)
112-
Use Docker to run the source code in a local development environment:
113-
1. Clone this repo
114-
2. Build the docker image
115-
* `cd react-json-view`
116-
* `./docker/build-container.sh`
117-
* *note:* you may need to use `sudo` to run docker commands
118-
3. Run the docker container on port 2000. This will run the webpack-dev-server with hot-reloading enabled.
119-
* `./docker/dev-server.sh`
120-
* *note:* you may need to use `sudo` to run the server file
121-
4. Open port 2000 in your browser
122-
* navigate to localhost:2000
111+
#### Run the Dev Server
123112

124-
Your source code will be mounted inside the docker container. The container is built on the latest `Node:slim` image.
113+
```bash
114+
# clone this repository
115+
git clone [email protected]:mac-s-g/react-json-view.git && cd react-json-view
116+
# install dependencies
117+
npm install --save-dev
118+
# run the dev server with hot reloading
119+
npm run dev
120+
```
121+
Webpack Dev Server should automatically open up http://localhost:2000 in your web browser. If it does not, open a browser and navigate to port 2000. The hot reloader will automatically reload when files are modified in the `/src/` directory.
125122

126-
Webpack-dev-server is running in the container and hot-reloading when changes are made locally.
123+
#### Run the Production Build
127124

128-
All node modules are installed within the container, so make sure to rebuild your container if you make changes to package.json (see step 2, above).
125+
```bash
126+
# run the build (note: you may need to use `sudo` priveledges to run the build successfully)
127+
npm run build
128+
```
129+
Please add tests for your code before posting a pull request.
129130

130-
For more information about contributing with Docker, see the [README in ./docker](https://github.com/mac-s-g/react-json-view/blob/master/docker/README.md).
131+
You can run the test suite with `npm run test` or `npm run test:watch` to automatically reload when files are modified.
131132

132-
#### Standard Workflow
133-
Development workflow is setup for linux users with Docker installed. You can contribute with other configurations but I have not tested them.
133+
#### Docker Tools
134+
135+
I recommend using docker for development because it enforces environmental consistency.
136+
137+
For information about contributing with Docker, see the [README in ./docker](https://github.com/mac-s-g/react-json-view/blob/master/docker/README.md#contributing-to-this-project-using-docker).
134138

135-
1. Clone this repo
136-
2. Install npm dependencies
137-
```
138-
cd react-json-view
139-
npm install --save-dev
140-
```
141-
3. Run webpack to start webpack-dev-server with hot-reloading enabled
142-
* `npm run dev:hot`
143-
4. Open port 2000 in your browser
144-
* navigate to localhost:2000
145139

146140
### Inspiration
147141
I drew a ton of design ideas from [react-json-tree](https://github.com/alexkuz/react-json-tree). Thanks to the RJT contributors for putting together an awesome component!

demo/dist/main.js

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
### Contributing to this Project Using Docker
2+
#### Run the Dev Server
3+
To use Docker to run the source code in a local development environment:
4+
1. Clone this repo
5+
2. Build the docker image
6+
* `cd react-json-view`
7+
* `./docker/build-container.sh`
8+
* *note:* you may need to use `sudo` to run docker commands
9+
3. Run the docker container on port 2000. This will run the webpack-dev-server with hot-reloading enabled.
10+
* `./docker/dev-server.sh`
11+
* *note:* you may need to use `sudo` to run the server file
12+
4. Open port 2000 in your browser
13+
* navigate to localhost:2000
14+
15+
Your source code will be mounted inside the docker container. The container is built on the latest `Node:slim` image.
16+
17+
Webpack-dev-server is running in the container and hot-reloading when changes are made locally.
18+
19+
All node modules are installed within the container, so make sure to rebuild your container if you make changes to package.json (see step 2, above).
20+
21+
#### Run the Production Build
22+
```bash
23+
cd react-json-view
24+
# build the rjv container
25+
./docker/build-container.sh
26+
# run the build within your docker container
27+
./docker/build-dist.sh
28+
```
29+
30+
131
### Motivation for adding Docker to your Development Stack
232

333
**PSA:** You do not need to use Docker to contribute to this project. If you're not interested in using a container for development, you can ignore this directory.

docker/build-dist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ docker run \
2020
-v $(pwd)/docker:/react/docker \
2121
--name=react-json-view \
2222
-e NODE_ENV=$NODE_ENV \
23-
--entrypoint=/react/docker/entrypoints/publish.sh \
23+
--entrypoint=/react/docker/entrypoints/build.sh \
2424
-t react-json-view

docker/entrypoints/build.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33

44
export NODE_ENV=${NODE_ENV:-production}
55

6-
echo Building react app...
6+
echo Building RJV Distribution...
7+
8+
# remove dist files if they exist,
9+
# otherwise create the dist directory
10+
if [ -d /react/dist/main.js ]; then
11+
echo Removing existing dist artifacts
12+
rm /react/dist/main.js
13+
fi
714

815
# now, build the app
916
cd /react
1017
npm run build
18+
19+
# ... and copy files for dist
20+
cp -a /react/dist /dist
21+
echo Copied distribution to /dist

docker/entrypoints/coverage.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ echo Running Coverage Report
33

44
cd /react
55

6-
echo Installing Test Dependencies
7-
sh ./docker/entrypoints/install-test-dependencies.sh
8-
96
echo Running: npm run unit_test
107
npm run test
118

docker/entrypoints/debug.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
cd /react
44

5-
echo Installing Test Dependencies
6-
sh ./docker/entrypoints/install-test-dependencies.sh
7-
85
echo getting source tree..
96
npm run modules:tree > debug/tree.json
107

0 commit comments

Comments
 (0)