Skip to content

Commit 5c4a714

Browse files
committed
updated test deps, improved docs
1 parent 45a49cb commit 5c4a714

23 files changed

+1116
-581
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
}

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: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,40 +108,32 @@ 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. You can run the test suite in with hot-reloading with `npm run test:watch`.
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+
#### Docker Tools
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+
I recommend using docker for development because it enforces environmental consistency.
134+
135+
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).
134136

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
145137

146138
### Inspiration
147139
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,32 @@ running the app inside a container ensures that environmental inconsistencies li
6868
#### more examples
6969

7070
[github-help-wanted](https://github.com/mac-s-g/github-help-wanted) is a newer project that has a simpler docker workflow.
71+
72+
### Contrubiting to this Project
73+
#### Run the Dev Server
74+
To use Docker to run the source code in a local development environment:
75+
1. Clone this repo
76+
2. Build the docker image
77+
* `cd react-json-view`
78+
* `./docker/build-container.sh`
79+
* *note:* you may need to use `sudo` to run docker commands
80+
3. Run the docker container on port 2000. This will run the webpack-dev-server with hot-reloading enabled.
81+
* `./docker/dev-server.sh`
82+
* *note:* you may need to use `sudo` to run the server file
83+
4. Open port 2000 in your browser
84+
* navigate to localhost:2000
85+
86+
Your source code will be mounted inside the docker container. The container is built on the latest `Node:slim` image.
87+
88+
Webpack-dev-server is running in the container and hot-reloading when changes are made locally.
89+
90+
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).
91+
92+
#### Run the Production Build
93+
```bash
94+
cd react-json-view
95+
# build the rjv container
96+
./docker/build-container.sh
97+
# run the build within your docker container
98+
./docker/build-dist.sh
99+
```

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

docker/entrypoints/demo.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ export NODE_ENV=${NODE_ENV:-production}
55

66
echo Building RJV Demo...
77

8-
npm install --silent \
9-
10-
118
# remove dist files if they exist,
129
# otherwise create the dist directory
1310
if [ -d /react/demo/dist/main.js ]; then

docker/entrypoints/install-test-dependencies.sh

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

docker/entrypoints/publish.sh

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

docker/entrypoints/test-travis.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
echo Running Tests
33
cd /react
44

5-
echo Installing Test Dependencies
6-
sh ./docker/entrypoints/install-test-dependencies.sh
7-
85
exec npm run test

docker/entrypoints/test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
echo Running Tests
33
cd /react
44

5-
echo Installing Test Dependencies
6-
sh ./docker/entrypoints/install-test-dependencies.sh
7-
85
exec npm run test:watch

0 commit comments

Comments
 (0)