Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Chore] Add install-and-start script (#194)

Eric Socolofskyf62ff2415109
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 000000000..8104cabd3
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+8.1.0
diff --git a/README.md b/README.md
index 1810353c4..3c73315c9 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,8 @@ Check out this [StackOverflow](https://stackoverflow.com/questions/tagged/kepler
### Env
Use Node v6 and above, older node versions have not been tested
+For best results, use [nvm](https://github.com/creationix/nvm) `nvm install`.
+
### Install
Install node (`> 6`), yarn, and project dependencies
diff --git a/package.json b/package.json
index c9b49fead..365c205cc 100644
--- a/package.json
+++ b/package.json
@@ -24,16 +24,16 @@
},
"scripts": {
"install:example": "cd examples/demo-app && npm i",
- "test": "npm run test-node && npm run test-browser",
+ "install-and-start": "node ./scripts/install-and-start",
"fast-test": "NODE_ENV=test babel-tape-runner ./test/node.js && NODE_ENV=test babel-tape-runner -r ./test/setup-browser-env.js ./test/browser.js",
"test-browser": "NODE_ENV=test babel-tape-runner -r ./test/setup-browser-env.js ./test/browser.js",
"test-node": "NODE_ENV=test babel-tape-runner ./test/node.js | tap-spec",
"cover": "nyc --reporter html --reporter cobertura --reporter json-summary npm test && nyc report",
- "start": "cd examples/demo-app && (path-exists node_modules || npm i) && npm run start-local",
- "start:custom-layer": "(cd examples/custom-layer && (path-exists node_modules || npm i) && npm run start-local)",
- "start:open-modal": "(cd examples/open-modal && (path-exists node_modules || npm i) && npm run start-local)",
- "start:custom-reducer": "(cd examples/custom-reducer && (path-exists node_modules || npm i) && npm run start-local)",
- "start:": "(cd examples/open-modal && (path-exists node_modules || npm i) && npm run start-local)",
+ "start": "npm run install-and-start -- examples/demo-app start-local",
+ "start:custom-layer": "npm run install-and-start -- examples/custom-layer start-local",
+ "start:open-modal": "npm run install-and-start -- examples/open-modal start-local",
+ "start:custom-reducer": "npm run install-and-start -- examples/custom-reducer start-local",
+ "start:": "npm run install-and-start -- examples/open-modal start-local",
"build": "rm -fr dist && uber-licence && babel src --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps inline",
"lint": "eslint src examples/**/src website/src",
"check-licence": "uber-licence --dry",
@@ -170,7 +170,7 @@
]
},
"maintainers": [
- "Shan He [email protected]>",
- "Giuseppe Macri [email protected]"
+ "Shan He <[email protected]>",
+ "Giuseppe Macri <[email protected]>"
]
}
diff --git a/scripts/install-and-start.js b/scripts/install-and-start.js
new file mode 100644
index 000000000..8e0cf7c13
--- /dev/null
+++ b/scripts/install-and-start.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2018 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+const {existsSync} = require('fs');
+const {execSync} = require('child_process');
+
+const folder = process.argv[2];
+const script = process.argv[3];
+
+const cmd = !existsSync(`${folder}/node_modules`)
+ ? `npm i && npm run ${script}`
+ : `npm run ${script}`;
+
+execSync(cmd, {
+ cwd: folder,
+ stdio: 'inherit'
+});
+
+process.exit();