Skip to content

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

[Chore] Add a script to automatically edit kepler.gl version (#714)

Shan He7df8ac61f14d
diff --git a/examples/custom-reducer/package.json b/examples/custom-reducer/package.json
index 4de5e890b..dab1c1549 100644
--- a/examples/custom-reducer/package.json
+++ b/examples/custom-reducer/package.json
@@ -5,7 +5,7 @@
},
"dependencies": {
"global": "^4.3.0",
- "kepler.gl": "^1.1.4",
+ "kepler.gl": "^1.1.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-palm": "^1.1.2",
@@ -46,4 +46,4 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-stats-plugin": "^0.2.1"
}
-}
+}
\ No newline at end of file
diff --git a/examples/custom-theme/package.json b/examples/custom-theme/package.json
index b650dd53d..394c0b1ab 100644
--- a/examples/custom-theme/package.json
+++ b/examples/custom-theme/package.json
@@ -5,7 +5,7 @@
},
"dependencies": {
"global": "^4.3.0",
- "kepler.gl": "^1.1.4",
+ "kepler.gl": "^1.1.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-palm": "^1.1.2",
@@ -47,4 +47,4 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-stats-plugin": "^0.2.1"
}
-}
+}
\ No newline at end of file
diff --git a/examples/demo-app/package.json b/examples/demo-app/package.json
index 1981f9606..ef7c12b31 100644
--- a/examples/demo-app/package.json
+++ b/examples/demo-app/package.json
@@ -9,7 +9,7 @@
"d3-request": "^1.0.6",
"dropbox": "^4.0.12",
"global": "^4.3.0",
- "kepler.gl": "^1.1.4",
+ "kepler.gl": "^1.1.6",
"lodash.debounce": "^4.0.8",
"lodash.get": "^4.4.2",
"react": "^16.8.4",
@@ -56,4 +56,4 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-stats-plugin": "^0.2.1"
}
-}
+}
\ No newline at end of file
diff --git a/examples/open-modal/package.json b/examples/open-modal/package.json
index 57ca60737..ac331f20e 100644
--- a/examples/open-modal/package.json
+++ b/examples/open-modal/package.json
@@ -5,7 +5,7 @@
},
"dependencies": {
"global": "^4.3.0",
- "kepler.gl": "^1.1.4",
+ "kepler.gl": "^1.1.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-modal": "^3.1.10",
@@ -47,4 +47,4 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-stats-plugin": "^0.2.1"
}
-}
+}
\ No newline at end of file
diff --git a/examples/replace-component/package.json b/examples/replace-component/package.json
index 61508d05c..002f0462a 100644
--- a/examples/replace-component/package.json
+++ b/examples/replace-component/package.json
@@ -5,7 +5,7 @@
},
"dependencies": {
"global": "^4.3.0",
- "kepler.gl": "^1.1.4",
+ "kepler.gl": "^1.1.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-palm": "^1.1.2",
@@ -46,4 +46,4 @@
"webpack-hot-middleware": "^2.24.3",
"webpack-stats-plugin": "^0.2.1"
}
-}
+}
\ No newline at end of file
diff --git a/examples/umd-client/index.html b/examples/umd-client/index.html
index 0f93bb6f6..bb04c1130 100644
--- a/examples/umd-client/index.html
+++ b/examples/umd-client/index.html
@@ -18,7 +18,7 @@
<script src="https://unpkg.com/[email protected]/dist/styled-components.min.js" crossorigin></script>
<!-- Load Kepler.gl-->
- <script src="https://unpkg.com/[email protected]/umd/keplergl.min.js"></script>
+ <script src="https://unpkg.com/[email protected]/umd/keplergl.min.js"></script>
<!--If you want to load the build from filepath -->
<!--<script src="../../umd/keplergl.min.js"></script>-->
diff --git a/package.json b/package.json
index 8b2b3f9c6..90eebb760 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"add-licence": "uber-licence",
"prepublish": "uber-licence && yarn build && yarn build:umd",
"docs": "babel-node ./scripts/documentation.js",
+ "example-version": "babel-node ./scripts/edit-version.js",
"lint": "eslint src webpack/*.js examples/*.js examples/**/src examples/**/*.js website/*.js website/src --fix",
"web": "(yarn && yarn install:web && yarn start:web)",
"deploy": "yarn install:web && (cd website && yarn build)",
diff --git a/scripts/edit-version.js b/scripts/edit-version.js
new file mode 100644
index 000000000..593936ce2
--- /dev/null
+++ b/scripts/edit-version.js
@@ -0,0 +1,89 @@
+// Copyright (c) 2019 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.
+
+import fs from 'fs';
+import {resolve, join} from 'path';
+import {logSuccess, logProgress, logStep} from './log';
+
+const KeplerPackage = require('../package');
+const exampleDir = resolve('./examples');
+// edit package.json in examples
+
+function readWritePackage(file, version) {
+ fs.readFile(file, (err, data) => {
+ if (err) throw err;
+ const PackageContent = JSON.parse(data);
+ PackageContent.dependencies['kepler.gl'] = `^${version}`;
+ const out = JSON.stringify(PackageContent, null, 2);
+
+ fs.writeFile(file, out, error => {
+ if (error) throw error;
+ logStep(` ## Edit ${file} success.`);
+ });
+ });
+}
+
+function editExamplePackageJson(version) {
+ logProgress(
+ '\n============= Start Editing examples package.json =================\n'
+ );
+
+ fs.readdir(exampleDir, (err, items) => {
+ if (err) throw err;
+
+ for (let i = 0; i < items.length; i++) {
+ // for each example folder
+ const packageJsonPath = join(exampleDir, items[i], 'package.json');
+ if (fs.existsSync(packageJsonPath)) {
+ readWritePackage(packageJsonPath, version);
+ }
+ }
+ });
+}
+
+function editUMDPackage(version) {
+ logProgress(
+ '\n============= Start Editing umd package version =================\n'
+ );
+ const htmlFile = join(exampleDir, 'umd-client', 'index.html');
+ fs.readFile(htmlFile, 'utf8', (err, html) => {
+ if (err) throw err;
+
+ const out = html.replace(
+ /kepler\.gl@\d+.\d+.\d+\/umd/,
+ `kepler.gl@${version}/umd`
+ );
+ fs.writeFile(htmlFile, out, error => {
+ if (error) throw error;
+ logStep(` ## Edit ${htmlFile} success.`);
+ });
+ });
+}
+
+(function main() {
+ const KeplerGlVersion = KeplerPackage.version;
+
+ editExamplePackageJson(KeplerGlVersion);
+ editUMDPackage(KeplerGlVersion);
+
+ logSuccess(
+ `\n================= Edit example kepler.gl version to ${KeplerGlVersion} Success! =================\n`
+ );
+})();