Skip to content

Commit

Permalink
updated test deps, improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-s-g committed Dec 25, 2017
1 parent 45a49cb commit 5c4a714
Show file tree
Hide file tree
Showing 23 changed files with 1,116 additions and 581 deletions.
2 changes: 1 addition & 1 deletion .nycrc
Expand Up @@ -2,6 +2,6 @@
"plugins": ["transform-decorators-legacy"],
"require": [
"babel-register",
"/react/test/testHelpers/requireSources.js"
"./test/testHelpers/requireSources.js"
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -4,7 +4,7 @@ MAINTAINER mac <mac.gainor@gmail.com>
# install the node modules at container build time
RUN mkdir -p /react
ADD package.json /react/package.json
RUN cd /react && npm install --silent
RUN cd /react && npm install --save-dev --silent

# Now add our project code
ADD . /react
Expand Down
48 changes: 20 additions & 28 deletions README.md
Expand Up @@ -108,40 +108,32 @@ The following object will be passed to your method:
Returning `false` from a callback method will prevent the src from being affected.

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

Your source code will be mounted inside the docker container. The container is built on the latest `Node:slim` image.
```bash
# clone this repository
git clone git@github.com:mac-s-g/react-json-view.git && cd react-json-view
# install dependencies
npm install --save-dev
# run the dev server with hot reloading
npm run dev
```
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.

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

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).
```bash
# run the build (note: you may need to use `sudo` priveledges to run the build successfully)
npm run build
```
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`.

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).
#### Docker Tools

#### Standard Workflow
Development workflow is setup for linux users with Docker installed. You can contribute with other configurations but I have not tested them.
I recommend using docker for development because it enforces environmental consistency.

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).

1. Clone this repo
2. Install npm dependencies
```
cd react-json-view
npm install --save-dev
```
3. Run webpack to start webpack-dev-server with hot-reloading enabled
* `npm run dev:hot`
4. Open port 2000 in your browser
* navigate to localhost:2000

### Inspiration
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!
Expand Down
13 changes: 4 additions & 9 deletions demo/dist/main.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions docker/README.md
Expand Up @@ -68,3 +68,32 @@ running the app inside a container ensures that environmental inconsistencies li
#### more examples

[github-help-wanted](https://github.com/mac-s-g/github-help-wanted) is a newer project that has a simpler docker workflow.

### Contrubiting to this Project
#### Run the Dev Server
To use Docker to run the source code in a local development environment:
1. Clone this repo
2. Build the docker image
* `cd react-json-view`
* `./docker/build-container.sh`
* *note:* you may need to use `sudo` to run docker commands
3. Run the docker container on port 2000. This will run the webpack-dev-server with hot-reloading enabled.
* `./docker/dev-server.sh`
* *note:* you may need to use `sudo` to run the server file
4. Open port 2000 in your browser
* navigate to localhost:2000

Your source code will be mounted inside the docker container. The container is built on the latest `Node:slim` image.

Webpack-dev-server is running in the container and hot-reloading when changes are made locally.

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).

#### Run the Production Build
```bash
cd react-json-view
# build the rjv container
./docker/build-container.sh
# run the build within your docker container
./docker/build-dist.sh
```
2 changes: 1 addition & 1 deletion docker/build-dist.sh
Expand Up @@ -20,5 +20,5 @@ docker run \
-v $(pwd)/docker:/react/docker \
--name=react-json-view \
-e NODE_ENV=$NODE_ENV \
--entrypoint=/react/docker/entrypoints/publish.sh \
--entrypoint=/react/docker/entrypoints/build.sh \
-t react-json-view
13 changes: 12 additions & 1 deletion docker/entrypoints/build.sh
Expand Up @@ -3,8 +3,19 @@

export NODE_ENV=${NODE_ENV:-production}

echo Building react app...
echo Building RJV Distribution...

# remove dist files if they exist,
# otherwise create the dist directory
if [ -d /react/dist/main.js ]; then
echo Removing existing dist artifacts
rm /react/dist/main.js
fi

# now, build the app
cd /react
npm run build

# ... and copy files for dist
cp -a /react/dist /dist
echo Copied distribution to /dist
3 changes: 0 additions & 3 deletions docker/entrypoints/coverage.sh
Expand Up @@ -3,9 +3,6 @@ echo Running Coverage Report

cd /react

echo Installing Test Dependencies
sh ./docker/entrypoints/install-test-dependencies.sh

echo Running: npm run unit_test
npm run test

Expand Down
3 changes: 0 additions & 3 deletions docker/entrypoints/debug.sh
Expand Up @@ -2,9 +2,6 @@

cd /react

echo Installing Test Dependencies
sh ./docker/entrypoints/install-test-dependencies.sh

echo getting source tree..
npm run modules:tree > debug/tree.json

Expand Down
3 changes: 0 additions & 3 deletions docker/entrypoints/demo.sh
Expand Up @@ -5,9 +5,6 @@ export NODE_ENV=${NODE_ENV:-production}

echo Building RJV Demo...

npm install --silent \
react-select@1.0.0-rc.5

# remove dist files if they exist,
# otherwise create the dist directory
if [ -d /react/demo/dist/main.js ]; then
Expand Down
3 changes: 0 additions & 3 deletions docker/entrypoints/install-test-dependencies.sh

This file was deleted.

21 changes: 0 additions & 21 deletions docker/entrypoints/publish.sh

This file was deleted.

3 changes: 0 additions & 3 deletions docker/entrypoints/test-travis.sh
Expand Up @@ -2,7 +2,4 @@
echo Running Tests
cd /react

echo Installing Test Dependencies
sh ./docker/entrypoints/install-test-dependencies.sh

exec npm run test
3 changes: 0 additions & 3 deletions docker/entrypoints/test.sh
Expand Up @@ -2,7 +2,4 @@
echo Running Tests
cd /react

echo Installing Test Dependencies
sh ./docker/entrypoints/install-test-dependencies.sh

exec npm run test:watch

0 comments on commit 5c4a714

Please sign in to comment.