Skip to content

Commit

Permalink
Clean up npm scripts (visgl#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Apr 10, 2018
1 parent 9880581 commit 732b72e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ before_script:
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start
- ulimit -c unlimited -S # enable core dumps
script:
- npm run test-ci
- npm run test ci
after_success:
- cat coverage/lcov.info | coveralls
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ using both [webpack2](./examples/hello-world-webpack2) and
so you can choose which setup you prefer or are more familiar with.

```javascript
import DeckGL from 'deck.gl';
import {ArcLayer} from 'deck.gl';
import DeckGL, {ArcLayer} from 'deck.gl';

const flights = new ArcLayer({
id: 'flights',
Expand All @@ -58,30 +57,17 @@ or browse directly the [docs folder](./docs).

The **master** branch is the active development branch.

npm install # or yarn
npm run bootstrap
npm test
npm start # See note below

Note that you will also need to do an npm install in the main example (`examples/layer-browser`)
since the npm start command tries to build and run that example.

cd examples/layer-browser
npm install # or yarn
cd ../..

Note that `npm start` in the main directory actually runs `examples/main`.
You will need to install dependencies in that example first:

cd examples/main
npm install # or yarn
cd ../..
npm start
Note that `npm start` in the main directory actually runs `examples/layer-browser`.


#### Node Version Requirement

Running deck.gl as a dependency in another project (e.g. via `npm i deck.gl`) requires Node `v4` or higher.
Building deck.gl from source has a dependency on Node `v6.4` or higher.
Running deck.gl as a dependency in another project (e.g. via `npm i deck.gl`) requires Node `4.x` or higher.
Building deck.gl from source has a dependency on Node `8.x` or higher.
Either upgrade to a supported version, or install something like
[nvm](https://github.com/creationix/nvm) to manage Node versions.

Expand Down
15 changes: 7 additions & 8 deletions dev-docs/TEST-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ For pre-commit, CI, publish, we want to run everything we got: the linter, run a
That said, for quick iteration of tests during development, it will be frustrating if too many tests are run each time. Since making sure that e.g. CI etc use all tests typically requires adding all the tests to the main package.json "test" script, in many modules we add a separate test-fast script that just runs one copy of the tests:

```
"scripts": {
"test"; "npm run lint && node test/node.js && node test/node-dist.js && .... "
"test-fast" "node test/node.js",
...
}
```
npm run test fast
```
PS - We could possibly relax the pre-commit testing just a little if found too time consuming, but there is no reason to reduce the CI or prepublish testing.


## npm run test-browser
## Browser based tests

```
npm run test browser
```

It's the same test suite, but run in the browser.

Expand Down
28 changes: 8 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,15 @@
"bootstrap": "scripts/bootstrap.sh",
"build": "lerna run build",
"clean": "rm -rf node_modules && lerna clean --yes",
"cover": "NODE_ENV=test nyc --reporter html --reporter cobertura --reporter=lcov npm run test-cover",
"pretty": "prettier --write \"{modules,examples,test}/**/*.js\" --loglevel warn",
"lint": "prettier-check \"{modules,examples,test}/**/*.js\" && eslint modules test examples && npm run lint-yarn",
"lint-yarn": "!(grep -q unpm.u yarn.lock) && echo 'Lockfile valid.' || (echo 'Please rebuild yarn file using public npmrc' && false)",
"publish-prod": "npm run build && npm run test && npm run test-dist && scripts/publish.sh prod",
"publish-beta": "npm run build && npm run test && npm run test-dist && scripts/publish.sh beta",
"test": "npm run lint && npm run test-node && npm run test-browser && npm run test-render",
"test-fast": "npm run test-node",
"test-ci": "npm run lint && node test/start.js test-ci && npm run build && npm run collect-metrics",
"test-cover": "NODE_ENV=test tape -r babel-register test/node.js && nyc report",
"test-node": "node test/start.js test",
"test-dist": "node test/start.js test-dist",
"test-render": "node test/start.js render",
"test-render-react": "node test/start.js render",
"test-render-browser": "webpack-dev-server --config test/webpack.config.js --env.render --progress --hot --open",
"test-browser": "node test/start.js test-browser",
"cover": "NODE_ENV=test nyc --reporter html --reporter cobertura --reporter=lcov npm run test cover",
"lint": "scripts/lint.sh",
"publish-prod": "npm run build && npm run test && npm run test dist && scripts/publish.sh prod",
"publish-beta": "npm run build && npm run test && npm run test dist && scripts/publish.sh beta",
"start": "(cd examples/layer-browser && (path-exists node_modules || npm i) && npm run start-local)",
"test": "scripts/test.sh",
"test-browser-local": "webpack-dev-server --config test/webpack.config.js --env.test_browser --progress --hot --open",
"test-examples": "node test/node-examples.js",
"test-size-es6": "npm run build-es6 && NODE_ENV=production webpack --config test/webpack.config.js --env.import-nothing --env.es6",
"bench": "node test/start.js bench",
"bench-browser": "node test/start.js bench-browser",
"test-render-browser": "webpack-dev-server --config test/webpack.config.js --env.render --progress --hot --open",
"bench": "scripts/test.sh bench",
"bench-browser-local": "webpack-dev-server --config test/webpack.config.js --env.bench --progress --hot --open",
"collect-metrics": "./scripts/collect-metrics.sh"
},
Expand Down
11 changes: 11 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Script to check code styles

set -e

prettier-check "{modules,examples,test}/**/*.js" || echo "Running prettier." && prettier --write "{modules,examples,test}/**/*.js" --loglevel warn

eslint modules test examples

# check if yarn.lock contains private registery information
!(grep -q unpm.u yarn.lock) && echo 'Lockfile valid.' || (echo 'Please rebuild yarn file using public npmrc' && false)
52 changes: 52 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
# Automated tests

set -e

MODE=$1

npm run lint

case $MODE in
"fast")
node test/start.js test
break;;

"bench")
node test/start.js bench
node test/start.js bench-browser
break;;

"ci")
# run by Travis CI
node test/start.js test-ci
npm run build
npm run collect-metrics
break;;

"cover")
NODE_ENV=test tape -r babel-register test/node.js
nyc report
break;;

"dist")
npm run build
node test/start.js test-dist
break;;

"examples")
node test/node-examples.js
break;;

"size-es6")
npm run build
NODE_ENV=production webpack --config test/webpack.config.js --env.import-nothing --env.es6
break;;

*)
# default test
node test/start.js test
node test/start.js test-browser
node test/start.js render
;;
esac

0 comments on commit 732b72e

Please sign in to comment.