Interactive interface for browsing global, full-resolution satellite imagery
Add eslint for nodejs tasks
ZachTRice4a8cecfa0099
diff --git a/.eslintignore b/.eslintignoreindex 82ac99721..0ec5281d2 100644--- a/.eslintignore+++ b/.eslintignore@@ -13,4 +13,4 @@ test/*/tasks/temp/*web/js/lib/*e2e/reports/*-# tasks/build/*+# tasks/*diff --git a/.eslintrc b/.eslintrcindex e13b757eb..e091b2e36 100644--- a/.eslintrc+++ b/.eslintrc@@ -5,7 +5,7 @@"jest/globals": true},"parserOptions": {- "ecmaVersion": 2019,+ "ecmaVersion": "latest","sourceType": "module","ecmaFeatures": {"jsx": true@@ -164,4 +164,4 @@}}]-}\ No newline at end of file+}diff --git a/package-lock.json b/package-lock.jsonindex cb8003c3a..4b84ada8b 100644--- a/package-lock.json+++ b/package-lock.json@@ -103,6 +103,7 @@"eslint-plugin-import": "^2.22.1","eslint-plugin-jest": "^23.8.2","eslint-plugin-jsx-a11y": "^6.2.3",+ "eslint-plugin-n": "^15.6.0","eslint-plugin-no-storage": "^1.0.2","eslint-plugin-node": "^11.1.0","eslint-plugin-promise": "^4.2.1",@@ -5345,6 +5346,30 @@"integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==","dev": true},+ "node_modules/builtins": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",+ "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",+ "dev": true,+ "dependencies": {+ "semver": "^7.0.0"+ }+ },+ "node_modules/builtins/node_modules/semver": {+ "version": "7.3.8",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",+ "dev": true,+ "dependencies": {+ "lru-cache": "^6.0.0"+ },+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },"node_modules/bytes": {"version": "3.0.0","resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",@@ -5660,36 +5685,12 @@"node": ">= 6.0.0"}},- "node_modules/chromedriver/node_modules/axios": {- "version": "0.27.2",- "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",- "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",- "dev": true,- "dependencies": {- "follow-redirects": "^1.14.9",- "form-data": "^4.0.0"- }- },"node_modules/chromedriver/node_modules/compare-versions": {"version": "5.0.1","resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-5.0.1.tgz","integrity": "sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==","dev": true},- "node_modules/chromedriver/node_modules/form-data": {- "version": "4.0.0",- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",- "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",- "dev": true,- "dependencies": {- "asynckit": "^0.4.0",- "combined-stream": "^1.0.8",- "mime-types": "^2.1.12"- },- "engines": {- "node": ">= 6"- }- },"node_modules/chromedriver/node_modules/https-proxy-agent": {"version": "5.0.1","resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",@@ -8434,6 +8435,116 @@"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8"}},+ "node_modules/eslint-plugin-n": {+ "version": "15.6.1",+ "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",+ "integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",+ "dev": true,+ "dependencies": {+ "builtins": "^5.0.1",+ "eslint-plugin-es": "^4.1.0",+ "eslint-utils": "^3.0.0",+ "ignore": "^5.1.1",+ "is-core-module": "^2.11.0",+ "minimatch": "^3.1.2",+ "resolve": "^1.22.1",+ "semver": "^7.3.8"+ },+ "engines": {+ "node": ">=12.22.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/mysticatea"+ },+ "peerDependencies": {+ "eslint": ">=7.0.0"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz",+ "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==",+ "dev": true,+ "dependencies": {+ "eslint-utils": "^2.0.0",+ "regexpp": "^3.0.0"+ },+ "engines": {+ "node": ">=8.10.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/mysticatea"+ },+ "peerDependencies": {+ "eslint": ">=4.19.1"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es/node_modules/eslint-utils": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",+ "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",+ "dev": true,+ "dependencies": {+ "eslint-visitor-keys": "^1.1.0"+ },+ "engines": {+ "node": ">=6"+ },+ "funding": {+ "url": "https://github.com/sponsors/mysticatea"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es/node_modules/eslint-visitor-keys": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",+ "dev": true,+ "engines": {+ "node": ">=4"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/eslint-utils": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",+ "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",+ "dev": true,+ "dependencies": {+ "eslint-visitor-keys": "^2.0.0"+ },+ "engines": {+ "node": "^10.0.0 || ^12.0.0 || >= 14.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/mysticatea"+ },+ "peerDependencies": {+ "eslint": ">=5"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/ignore": {+ "version": "5.2.4",+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",+ "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",+ "dev": true,+ "engines": {+ "node": ">= 4"+ }+ },+ "node_modules/eslint-plugin-n/node_modules/semver": {+ "version": "7.3.8",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",+ "dev": true,+ "dependencies": {+ "lru-cache": "^6.0.0"+ },+ "bin": {+ "semver": "bin/semver.js"+ },+ "engines": {+ "node": ">=10"+ }+ },"node_modules/eslint-plugin-no-storage": {"version": "1.0.2","resolved": "https://registry.npmjs.org/eslint-plugin-no-storage/-/eslint-plugin-no-storage-1.0.2.tgz",@@ -11154,9 +11265,9 @@}},"node_modules/is-core-module": {- "version": "2.9.0",- "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",- "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",+ "version": "2.11.0",+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",+ "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==","dependencies": {"has": "^1.0.3"},@@ -18803,11 +18914,11 @@"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="},"node_modules/resolve": {- "version": "1.22.0",- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz",- "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==",+ "version": "1.22.1",+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",+ "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==","dependencies": {- "is-core-module": "^2.8.1",+ "is-core-module": "^2.9.0","path-parse": "^1.0.7","supports-preserve-symlinks-flag": "^1.0.0"},@@ -27361,6 +27472,26 @@"integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==","dev": true},+ "builtins": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",+ "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",+ "dev": true,+ "requires": {+ "semver": "^7.0.0"+ },+ "dependencies": {+ "semver": {+ "version": "7.3.8",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",+ "dev": true,+ "requires": {+ "lru-cache": "^6.0.0"+ }+ }+ }+ },"bytes": {"version": "3.0.0","resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",@@ -27584,33 +27715,12 @@"debug": "4"}},- "axios": {- "version": "0.27.2",- "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",- "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",- "dev": true,- "requires": {- "follow-redirects": "^1.14.9",- "form-data": "^4.0.0"- }- },"compare-versions": {"version": "5.0.1","resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-5.0.1.tgz","integrity": "sha512-v8Au3l0b+Nwkp4G142JcgJFh1/TUhdxut7wzD1Nq1dyp5oa3tXaqb03EXOAB6jS4gMlalkjAUPZBMiAfKUixHQ==","dev": true},- "form-data": {- "version": "4.0.0",- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",- "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",- "dev": true,- "requires": {- "asynckit": "^0.4.0",- "combined-stream": "^1.0.8",- "mime-types": "^2.1.12"- }- },"https-proxy-agent": {"version": "5.0.1","resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",@@ -29843,6 +29953,75 @@"minimatch": "^3.0.4"}},+ "eslint-plugin-n": {+ "version": "15.6.1",+ "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",+ "integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",+ "dev": true,+ "requires": {+ "builtins": "^5.0.1",+ "eslint-plugin-es": "^4.1.0",+ "eslint-utils": "^3.0.0",+ "ignore": "^5.1.1",+ "is-core-module": "^2.11.0",+ "minimatch": "^3.1.2",+ "resolve": "^1.22.1",+ "semver": "^7.3.8"+ },+ "dependencies": {+ "eslint-plugin-es": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz",+ "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==",+ "dev": true,+ "requires": {+ "eslint-utils": "^2.0.0",+ "regexpp": "^3.0.0"+ },+ "dependencies": {+ "eslint-utils": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",+ "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",+ "dev": true,+ "requires": {+ "eslint-visitor-keys": "^1.1.0"+ }+ },+ "eslint-visitor-keys": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",+ "dev": true+ }+ }+ },+ "eslint-utils": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",+ "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",+ "dev": true,+ "requires": {+ "eslint-visitor-keys": "^2.0.0"+ }+ },+ "ignore": {+ "version": "5.2.4",+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",+ "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",+ "dev": true+ },+ "semver": {+ "version": "7.3.8",+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",+ "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",+ "dev": true,+ "requires": {+ "lru-cache": "^6.0.0"+ }+ }+ }+ },"eslint-plugin-no-storage": {"version": "1.0.2","resolved": "https://registry.npmjs.org/eslint-plugin-no-storage/-/eslint-plugin-no-storage-1.0.2.tgz",@@ -31802,9 +31981,9 @@}},"is-core-module": {- "version": "2.9.0",- "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",- "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==",+ "version": "2.11.0",+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",+ "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==","requires": {"has": "^1.0.3"}@@ -37618,11 +37797,11 @@"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="},"resolve": {- "version": "1.22.0",- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz",- "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==",+ "version": "1.22.1",+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",+ "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==","requires": {- "is-core-module": "^2.8.1",+ "is-core-module": "^2.9.0","path-parse": "^1.0.7","supports-preserve-symlinks-flag": "^1.0.0"}diff --git a/package.json b/package.jsonindex 3fc9e6beb..16fa54c92 100644--- a/package.json+++ b/package.json@@ -63,8 +63,8 @@"generatePreviews": "python3 tasks/python3/fetchPreviewSnapshots.py","linkcheck": "node ./tasks/linkcheck","lint": "run-s lint:*",- "lint:scss": "stylelint ./web/scss/**/*.scss",- "lint:js": "eslint . --quiet",+ "lint:scss": "npx stylelint ./web/scss/**/*.scss",+ "lint:js": "npx eslint . --quiet","preinstall": "node tasks/checkNodeVersion.js","postinstall": "patch-package && npm run python","python": "run-script-os",@@ -117,6 +117,7 @@"eslint-plugin-import": "^2.22.1","eslint-plugin-jest": "^23.8.2","eslint-plugin-jsx-a11y": "^6.2.3",+ "eslint-plugin-n": "^15.6.0","eslint-plugin-no-storage": "^1.0.2","eslint-plugin-node": "^11.1.0","eslint-plugin-promise": "^4.2.1",diff --git a/tasks/.eslintrc b/tasks/.eslintrcnew file mode 100644index 000000000..fac57a149--- /dev/null+++ b/tasks/.eslintrc@@ -0,0 +1,23 @@+{+ "extends": ["standard", "plugin:n/recommended"],+ "rules": {+ "new-cap": ["error", {}],+ "camelcase": ["error", {+ "ignoreDestructuring": true,+ "properties": "never"+ }],+ "n/no-path-concat": "warn",+ "n/no-deprecated-api": "warn",+ "no-async-promise-executor": "warn"+ },+ "overrides": [+ {+ "files": ["*.js"],+ "rules": {+ "no-undef": "off",+ "n/no-unpublished-require": "off",+ "no-unused-expressions": "off"+ }+ }+ ]+}diff --git a/tasks/checkNodeVersion.js b/tasks/checkNodeVersion.jsindex 61a5ae464..b42310c3e 100755--- a/tasks/checkNodeVersion.js+++ b/tasks/checkNodeVersion.js@@ -1,43 +1,42 @@-/* eslint no-console: "off" */-const pkg = require('../package.json');+const pkg = require('../package.json')// modified versionCompare function from https://stackoverflow.com/a/6832721const versionCompare = (v1, v2) => {- let v1parts = v1.split('.');- let v2parts = v2.split('.');+ let v1parts = v1.split('.')+ let v2parts = v2.split('.')- while (v1parts.length < v2parts.length) v1parts.push('0');- while (v2parts.length < v1parts.length) v2parts.push('0');+ while (v1parts.length < v2parts.length) v1parts.push('0')+ while (v2parts.length < v1parts.length) v2parts.push('0')- v1parts = v1parts.map(Number);- v2parts = v2parts.map(Number);+ v1parts = v1parts.map(Number)+ v2parts = v2parts.map(Number)for (let i = 0; i < v1parts.length; i += 1) {if (v2parts.length === i) {- return true;+ return true}if (v1parts[i] !== v2parts[i]) {if (v1parts[i] > v2parts[i]) {- return true;+ return true}- return false;+ return false}}- return true;-};-const packageNode = pkg.engines.node;-const packageNodeArray = pkg.engines.node.split(' ');-const [minVersion] = packageNodeArray;-const nodeVersion = process.version;-const requiredVersionSub = minVersion.substr(2, minVersion.length);-const nodeVersionSub = nodeVersion.substr(1, nodeVersion.length);+ return true+}+const packageNode = pkg.engines.node+const packageNodeArray = pkg.engines.node.split(' ')+const [minVersion] = packageNodeArray+const nodeVersion = process.version+const requiredVersionSub = minVersion.substr(2, minVersion.length)+const nodeVersionSub = nodeVersion.substr(1, nodeVersion.length)-const satisfyMinVersion = packageNodeArray.length > 1 ? versionCompare(nodeVersionSub, requiredVersionSub) : pkg.engines.node === nodeVersionSub;+const satisfyMinVersion = packageNodeArray.length > 1 ? versionCompare(nodeVersionSub, requiredVersionSub) : pkg.engines.node === nodeVersionSubif (!satisfyMinVersion) {- console.log('\x1b[31m', '\x1b[1m'); // Added styling to warn- console.log('WARN', '\x1b[0m', 'The suggested version(s) of node for the installation of Worldview is', '\x1b[32m', '\x1b[1m', packageNode, '\x1b[0m', ' you are using', '\x1b[32m', '\x1b[1m', nodeVersion);- console.log('\x1b[0m', 'If you have difficulties installing Worldview, please try using the install again using the compatible node version(s)', '\x1b[32m', '\x1b[1m', packageNode, '\x1b[0m');+ console.log('\x1b[31m', '\x1b[1m') // Added styling to warn+ console.log('WARN', '\x1b[0m', 'The suggested version(s) of node for the installation of Worldview is', '\x1b[32m', '\x1b[1m', packageNode, '\x1b[0m', ' you are using', '\x1b[32m', '\x1b[1m', nodeVersion)+ console.log('\x1b[0m', 'If you have difficulties installing Worldview, please try using the install again using the compatible node version(s)', '\x1b[32m', '\x1b[1m', packageNode, '\x1b[0m')} else {- console.log('\x1b[0mPreinstall conditions satisfied. Installing...', '\x1b[0m');+ console.log('\x1b[0mPreinstall conditions satisfied. Installing...', '\x1b[0m')}diff --git a/tasks/clean.js b/tasks/clean.jsindex 51395857f..6e000aef3 100755--- a/tasks/clean.js+++ b/tasks/clean.js@@ -1,16 +1,14 @@-#!/usr/bin/env node--const shell = require('shelljs');+const shell = require('shelljs')const dirs = ['build','dist','web/brand','web/config',- 'config/default/release/gc',-];+ 'config/default/release/gc'+]dirs.forEach((dir) => {- console.log('Removing', dir);- shell.rm('-rf', dir);-});+ console.log('Removing', dir)+ shell.rm('-rf', dir)+})diff --git a/tasks/config.js b/tasks/config.jsindex e688b153f..f086bfb95 100755--- a/tasks/config.js+++ b/tasks/config.js@@ -1,36 +1,33 @@-#!/usr/bin/env node-/* eslint-disable no-restricted-syntax */+const fs = require('fs')+const glob = require('glob')+const showdown = require('showdown')+const shell = require('shelljs')+const console = require('console')-const fs = require('fs');-const glob = require('glob');-const showdown = require('showdown');-const shell = require('shelljs');-const console = require('console');--console.log('Converting markdown to html');+console.log('Converting markdown to html')const converter = new showdown.Converter({openLinksInNewWindow: true,// don't require escaping underscores in the middle of a word- literalMidWordUnderscores: true,-});-const configFiles = glob.sync('build/options/config/metadata/**/*.md');-const aboutFiles = glob.sync('build/options/brand/about/*.md');-function convertMDtoHTML(mdFiles) {+ literalMidWordUnderscores: true+})+const configFiles = glob.sync('build/options/config/metadata/**/*.md')+const aboutFiles = glob.sync('build/options/brand/about/*.md')+function convertMDtoHTML (mdFiles) {for (const mdFile of mdFiles) {- const dest = mdFile.replace(/\.md$/, '.html');- const markdown = fs.readFileSync(mdFile, { encoding: 'utf-8' });- const html = converter.makeHtml(markdown);- fs.writeFileSync(dest, html);+ const dest = mdFile.replace(/\.md$/, '.html')+ const markdown = fs.readFileSync(mdFile, { encoding: 'utf-8' })+ const html = converter.makeHtml(markdown)+ fs.writeFileSync(dest, html)}}-convertMDtoHTML(configFiles);-convertMDtoHTML(aboutFiles);+convertMDtoHTML(configFiles)+convertMDtoHTML(aboutFiles)// Remove the markdown files from the build since they've been converted to HTML-shell.rm('-rf', 'build/options/config/metadata/**/*.md');-shell.rm('-rf', 'build/options/brand/about/*.md');+shell.rm('-rf', 'build/options/config/metadata/**/*.md')+shell.rm('-rf', 'build/options/brand/about/*.md')-console.log('Copying options to web directory');-shell.cp('-r', 'build/options/config', 'web');-shell.cp('-r', 'build/options/brand', 'web');-shell.cp('-r', 'build/options/brand.json', 'web/brand');+console.log('Copying options to web directory')+shell.cp('-r', 'build/options/config', 'web')+shell.cp('-r', 'build/options/brand', 'web')+shell.cp('-r', 'build/options/brand.json', 'web/brand')diff --git a/tasks/csv2colormap.js b/tasks/csv2colormap.jsindex 55f7dc984..d3ef8d3d8 100755--- a/tasks/csv2colormap.js+++ b/tasks/csv2colormap.js@@ -1,32 +1,30 @@-#!/usr/bin/env node-/* eslint-disable no-restricted-syntax */+const fs = require('fs')-const fs = require('fs');--function usage() {+function usage () {console.log(`Usage: csv2colormap.js <id> <name> <csv_file> <json_file>Given a CSV file with red, green, and blue values in the rangeof 0-255, create a colormap JSON file that goes in thecommon/config/palettes-custom.json directory.- `);+ `)}if (process.argv.length !== 4 + 2) {- usage();- process.exit(1);+ usage()+ // process.exit(1)+ throw new Error('Incorrect argv length')}-const [id, name, csvFile, jsonFile] = process.argv.slice(2);-const file = fs.readFileSync(csvFile, 'utf8');-const lines = file.split('\n');-const colors = [];+const [id, name, csvFile, jsonFile] = process.argv.slice(2)+const file = fs.readFileSync(csvFile, 'utf8')+const lines = file.split('\n')+const colors = []for (const line of lines) {if (line.trim().length !== 0) {- const [r, g, b] = line.split(',');- const color = `${hex(r)}${hex(g)}${hex(b)}ff`;- colors.push(color);+ const [r, g, b] = line.split(',')+ const color = `${hex(r)}${hex(g)}${hex(b)}ff`+ colors.push(color)}}@@ -34,17 +32,17 @@ const colormap = {[id]: {id,name,- colors,- },-};-fs.writeFileSync(jsonFile, JSON.stringify(colormap));+ colors+ }+}+fs.writeFileSync(jsonFile, JSON.stringify(colormap))// decimal to hex for bytes, 10 => 0a-function hex(dec) {- dec = Number.parseInt(dec, 10);- let h = dec.toString(16);+function hex (dec) {+ dec = Number.parseInt(dec, 10)+ let h = dec.toString(16)if (h.length === 1) {- h = `0${h}`;+ h = `0${h}`}- return h;+ return h}diff --git a/tasks/dist.js b/tasks/dist.jsindex a82ad7216..3338b2468 100755--- a/tasks/dist.js+++ b/tasks/dist.js@@ -1,68 +1,66 @@-#!/usr/bin/env node+const fs = require('fs')+const moment = require('moment')+const shell = require('shelljs')+const tar = require('tar')+const pkg = require('../package.json')-const fs = require('fs');-const moment = require('moment');-const shell = require('shelljs');-const tar = require('tar');-const pkg = require('../package.json');--console.log('Preparing distribution');-shell.rm('-rf', 'build/worldview');-shell.mkdir('-p', 'build/worldview');-shell.cp('-rf', 'web/*', 'build/worldview');+console.log('Preparing distribution')+shell.rm('-rf', 'build/worldview')+shell.mkdir('-p', 'build/worldview')+shell.cp('-rf', 'web/*', 'build/worldview')// Remove preview images, if that feature is disabled, for smaller dist file size-const { CONFIG_ENV, GTM_ID } = process.env;+const { CONFIG_ENV, GTM_ID } = process.envconst featuresConfigPath = CONFIG_ENV? `config/active/${CONFIG_ENV}/features.json`- : 'config/default/common/features.json';-const { features } = JSON.parse(fs.readFileSync(featuresConfigPath));+ : 'config/default/common/features.json'+const { features } = JSON.parse(fs.readFileSync(featuresConfigPath))if (!features.previewSnapshots) {- shell.rm('-rf', 'build/worldview/images/layers/previews');+ shell.rm('-rf', 'build/worldview/images/layers/previews')}-console.log('Branding');-// eslint-disable-next-line import/no-unresolved-const brand = require('../build/worldview/brand/brand.json');+console.log('Branding')+// eslint-disable-next-line n/no-missing-require+const brand = require('../build/worldview/brand/brand.json')const applyTo = ['build/worldview/index.html','build/worldview/build/wv.js','build/worldview/brand/about/*.html','build/worldview/pages/*.html',- 'build/worldview/manifest.webmanifest',-];+ 'build/worldview/manifest.webmanifest'+]// Build date shown in the About box-const buildTimestamp = moment.utc().format('MMMM DD, YYYY [-] HH:mm [UTC]');+const buildTimestamp = moment.utc().format('MMMM DD, YYYY [-] HH:mm [UTC]')// Append to all URI references for cache busting-const buildNonce = moment.utc().format('YYYYMMDDHHmmssSSS');+const buildNonce = moment.utc().format('YYYYMMDDHHmmssSSS')-const officialName = brand.officialName || brand.name;-const longName = brand.longName || brand.name;-const shortName = brand.shortName || brand.name;-const email = brand.email || '[email protected]';-const url = brand.url || 'https://worldview.earthdata.nasa.gov/';+const officialName = brand.officialName || brand.name+const longName = brand.longName || brand.name+const shortName = brand.shortName || brand.name+const email = brand.email || '[email protected]'+const url = brand.url || 'https://worldview.earthdata.nasa.gov/'-shell.sed('-i', /@OFFICIAL_NAME@/g, officialName, applyTo);-shell.sed('-i', /@URL@/g, url, applyTo);-shell.sed('-i', /@LONG_NAME@/g, longName, applyTo);-shell.sed('-i', /@NAME@/g, shortName, applyTo);-shell.sed('-i', /@MAIL@/g, email, applyTo);-shell.sed('-i', /@BUILD_NONCE/g, buildNonce, applyTo);-shell.sed('-i', /@BUILD_TIMESTAMP@/g, buildTimestamp, applyTo);-shell.sed('-i', /@BUILD_VERSION@/g, pkg.version, applyTo);+shell.sed('-i', /@OFFICIAL_NAME@/g, officialName, applyTo)+shell.sed('-i', /@URL@/g, url, applyTo)+shell.sed('-i', /@LONG_NAME@/g, longName, applyTo)+shell.sed('-i', /@NAME@/g, shortName, applyTo)+shell.sed('-i', /@MAIL@/g, email, applyTo)+shell.sed('-i', /@BUILD_NONCE/g, buildNonce, applyTo)+shell.sed('-i', /@BUILD_TIMESTAMP@/g, buildTimestamp, applyTo)+shell.sed('-i', /@BUILD_VERSION@/g, pkg.version, applyTo)// replace google tag manager id-const googleTagManagerID = GTM_ID || '';-shell.sed('-i', /@GTM_ID@/g, googleTagManagerID, applyTo);+const googleTagManagerID = GTM_ID || ''+shell.sed('-i', /@GTM_ID@/g, googleTagManagerID, applyTo)-const dist = 'dist/worldview.tar.gz';-console.log(`Creating distribution: ${dist}`);-shell.mkdir('-p', 'dist');+const dist = 'dist/worldview.tar.gz'+console.log(`Creating distribution: ${dist}`)+shell.mkdir('-p', 'dist')tar.c({gzip: true,portable: true,- C: 'build',-}, ['worldview']).pipe(fs.createWriteStream(dist));+ C: 'build'+}, ['worldview']).pipe(fs.createWriteStream(dist))diff --git a/tasks/distclean.js b/tasks/distclean.jsindex d648d3b91..0ee25cd11 100755--- a/tasks/distclean.js+++ b/tasks/distclean.js@@ -1,13 +1,11 @@-#!/usr/bin/env node--const shell = require('shelljs');+const shell = require('shelljs')const dirs = ['node_modules',- '.python',-];+ '.python'+]dirs.forEach((dir) => {- console.log('Removing', dir);- shell.rm('-rf', dir);-});+ console.log('Removing', dir)+ shell.rm('-rf', dir)+})diff --git a/tasks/generateColormapUnitDictionary.js b/tasks/generateColormapUnitDictionary.jsindex e6ecaa508..12ef9a36b 100644--- a/tasks/generateColormapUnitDictionary.js+++ b/tasks/generateColormapUnitDictionary.js@@ -1,70 +1,70 @@-const fs = require('fs');-const path = require('path');+const fs = require('fs')+const path = require('path')-const SOURCE_DIR = `${path.resolve(__dirname)}/../config/default/release/gc/colormaps/`;-const OUTPUT_DIR = process.argv[2] || './';-const OUTPUT_FILENAME = '_COLORMAP_UNIT_DICT_.json';+const SOURCE_DIR = `${path.resolve(__dirname)}/../config/default/release/gc/colormaps/`+const OUTPUT_DIR = process.argv[2] || './'+const OUTPUT_FILENAME = '_COLORMAP_UNIT_DICT_.json'// HELPERS// https://gist.github.com/nrkn/c7a89bb7039182314415 JSON FORMATTING-const isPrimitive = (obj) => obj === null- || ['string', 'number', 'boolean'].includes(typeof obj);+const isPrimitive = (obj) => obj === null ||+ ['string', 'number', 'boolean'].includes(typeof obj)-const isArrayOfPrimitive = (obj) => Array.isArray(obj) && obj.every(isPrimitive);+const isArrayOfPrimitive = (obj) => Array.isArray(obj) && obj.every(isPrimitive)const format = (arr) => `^^^[ ${arr.map((val) => JSON.stringify(val)).join(', ')-} ]`;+} ]`-const replacer = (key, value) => (isArrayOfPrimitive(value) ? format(value) : value);+const replacer = (key, value) => (isArrayOfPrimitive(value) ? format(value) : value)const expand = (str) => str.replace(- /(?:"\^\^\^)(\[ .* \])(?:")/g, (match, a) => a.replace(/\\"/g, '"'),-);+ /(?:"\^\^\^)(\[ .* \])(?:")/g, (match, a) => a.replace(/\\"/g, '"')+)const readDirPromise = (dirname) => new Promise((resolve, reject) => {fs.readdir(dirname,- (err, filenames) => (err ? reject(err) : resolve(filenames)));-});+ (err, filenames) => (err ? reject(err) : resolve(filenames)))+})// MAIN COLORMAP UNIT DICTIONARY GENERATION-async function generateColormapUnitDictionary(dirname) {- const data = {};- const filenames = await readDirPromise(dirname);+async function generateColormapUnitDictionary (dirname) {+ const data = {}+ const filenames = await readDirPromise(dirname)try {return Promise.all(filenames.map(async (filename) => {const content = await new Promise((resolve, reject) => {fs.readFile(dirname + filename, 'utf8',- (err, content) => (err ? reject(err) : resolve(content)));- });+ (err, content) => (err ? reject(err) : resolve(content)))+ })const parseUnits = (fileContent) => {- const colorMapName = filename.split('.xml')[0];- data[colorMapName] = [];- const lines = fileContent.split(/\r?\n/);+ const colorMapName = filename.split('.xml')[0]+ data[colorMapName] = []+ const lines = fileContent.split(/\r?\n/)lines.forEach((line) => {if (line.includes('units')) {- const unitsString = line.split('units=')[1];- const units = unitsString.split('"')[1];- data[colorMapName].push(units);+ const unitsString = line.split('units=')[1]+ const units = unitsString.split('"')[1]+ data[colorMapName].push(units)}- });- };- parseUnits(content);- })).then(() => data);+ })+ }+ parseUnits(content)+ })).then(() => data)} catch (error) {- return Promise.reject(error);+ return Promise.reject(error)}}-async function main() {- const data = await generateColormapUnitDictionary(SOURCE_DIR);+async function main () {+ const data = await generateColormapUnitDictionary(SOURCE_DIR)fs.writeFile(`${OUTPUT_DIR}${OUTPUT_FILENAME}`, expand(JSON.stringify(data, replacer, 2)), {encoding: 'utf8',- flag: 'w',+ flag: 'w'}, (err) => {- if (err) throw err;- console.log(`Done writing colormap unit dictionary to ${OUTPUT_DIR}${OUTPUT_FILENAME}.`);- });+ if (err) throw err+ console.log(`Done writing colormap unit dictionary to ${OUTPUT_DIR}${OUTPUT_FILENAME}.`)+ })}-main();+main()diff --git a/tasks/generateLayergroup.js b/tasks/generateLayergroup.jsindex 1f55ae605..882c1800a 100644--- a/tasks/generateLayergroup.js+++ b/tasks/generateLayergroup.js@@ -1,12 +1,12 @@-const _ = require('lodash');-const fs = require('fs');-const dir = require('node-dir');+const _ = require('lodash')+const fs = require('fs')+const dir = require('node-dir')-const SOURCE_DIR = './config/default/common/config/wv.json/layers/';-const WV_JSON_PATH = './build/options/config/wv.json';+const SOURCE_DIR = './config/default/common/config/wv.json/layers/'+const WV_JSON_PATH = './build/options/config/wv.json'-const measurementsMap = {};-const measurementsArray = [];+const measurementsMap = {}+const measurementsArray = []// This is a set of layer IDs which we do not wish to generate (or re-generate)const EXCEPTIONS = [@@ -20,25 +20,25 @@ const EXCEPTIONS = ['AMSRE_Sea_Ice_Brightness_Temp_89V','AMSRE_Sea_Ice_Brightness_Temp_89H','AMSRU2_Sea_Ice_Brightness_Temp_6km_89V',- 'AMSRU2_Sea_Ice_Brightness_Temp_6km_89H',-];+ 'AMSRU2_Sea_Ice_Brightness_Temp_6km_89H'+]const errCallback = (err) => {if (err) {- console.log(err);- throw err;+ console.log(err)+ throw err}-};+}function setLayerProp (layer, prop, value) {- const featuredMeasurement = prop === 'measurements' && (value && value.includes('Featured'));+ const featuredMeasurement = prop === 'measurements' && (value && value.includes('Featured'))if (!layer || featuredMeasurement) {- return;+ return}if (!layer[prop]) {- layer[prop] = [value];+ layer[prop] = [value]} else if (!layer[prop].includes(value)) {- layer[prop].push(value);+ layer[prop].push(value)}}@@ -46,64 +46,64 @@ function generateMeasurements (layers, measurementsConfig) {_.forEach(measurementsConfig, (measureObj, measureKey) => {_.forEach(measureObj.sources, ({ settings = [] }, sourceKey) => {settings.forEach((id) => {- setLayerProp(layers[id], 'measurements', measureKey);+ setLayerProp(layers[id], 'measurements', measureKey)if (!measurementsArray.includes(measureKey)) {- measurementsArray.push(measureKey);+ measurementsArray.push(measureKey)}- });- });- });+ })+ })+ })_.forEach(layers, ({ measurements }, id) => {// Reduce to a single measurement:if (id.toLowerCase().includes('orbit')) {- measurementsMap[id] = 'Orbital Track';+ measurementsMap[id] = 'Orbital Track'} else {// eslint-disable-next-line prefer-destructuring- measurementsMap[id] = measurements[0];+ measurementsMap[id] = measurements[0]}- });+ })}function modifyProps (layer) {- const { id } = layer;- layer.layergroup = measurementsMap[id];+ const { id } = layer+ layer.layergroup = measurementsMap[id]return {[id]: {- ...layer,- },- };+ ...layer+ }+ }}-function migrate(filePath) {- const pathStrings = filePath.split('/');- const fileName = pathStrings[pathStrings.length - 1];+function migrate (filePath) {+ const pathStrings = filePath.split('/')+ const fileName = pathStrings[pathStrings.length - 1]if (!fileName.includes('.json')) {- return;+ return}- const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'));- const fileLayerId = fileName.slice(0, fileName.length - 5);- const objPropLayerId = Object.keys(layerJson.layers)[0];+ const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'))+ const fileLayerId = fileName.slice(0, fileName.length - 5)+ const objPropLayerId = Object.keys(layerJson.layers)[0]if (fileLayerId !== objPropLayerId) {- console.log('Mismatched ids!', filePath);+ console.log('Mismatched ids!', filePath)}- const layer = layerJson.layers[objPropLayerId];+ const layer = layerJson.layers[objPropLayerId]if (EXCEPTIONS.includes(layer.id)) {- return;+ return}fs.writeFile(`${filePath}`,JSON.stringify({ layers: modifyProps(layer) }, null, 2),- errCallback,- );+ errCallback+ )}dir.files(SOURCE_DIR, (err, files) => {- if (err) throw err;- const wvJson = JSON.parse(fs.readFileSync(WV_JSON_PATH, 'utf-8'));- generateMeasurements(wvJson.layers, wvJson.measurements);- files.forEach(migrate);-});+ if (err) throw err+ const wvJson = JSON.parse(fs.readFileSync(WV_JSON_PATH, 'utf-8'))+ generateMeasurements(wvJson.layers, wvJson.measurements)+ files.forEach(migrate)+})diff --git a/tasks/generatePreviewImage.js b/tasks/generatePreviewImage.jsindex 64cf35c77..861691440 100644--- a/tasks/generatePreviewImage.js+++ b/tasks/generatePreviewImage.js@@ -1,12 +1,12 @@-const shell = require('shelljs');+const shell = require('shelljs')// create screenshot for local instance of Worldview// https://github.com/sindresorhus/capture-website-cli-const cmdPrefix = 'npx capture-website-cli -s capture-website';-const targetURL = 'http://localhost:3000/?t=2020-12-20';-const outputFile = './web/images/preview.jpg';-const cmdOptions = `--output=${outputFile} --delay=5 --width=1200 --height=630 --type=jpeg --quality=0.2 --overwrite`;+const cmdPrefix = 'npx capture-website-cli -s capture-website'+const targetURL = 'http://localhost:3000/?t=2020-12-20'+const outputFile = './web/images/preview.jpg'+const cmdOptions = `--output=${outputFile} --delay=5 --width=1200 --height=630 --type=jpeg --quality=0.2 --overwrite`-const cmd = `${cmdPrefix} ${targetURL} ${cmdOptions}`;-shell.exec(cmd);+const cmd = `${cmdPrefix} ${targetURL} ${cmdOptions}`+shell.exec(cmd)diff --git a/tasks/link-check/html-url-extract.js b/tasks/link-check/html-url-extract.jsindex 3382476cf..2f875891e 100644--- a/tasks/link-check/html-url-extract.js+++ b/tasks/link-check/html-url-extract.js@@ -1,60 +1,60 @@-const cheerio = require('cheerio');-const fs = require('fs');+const cheerio = require('cheerio')+const fs = require('fs')// walk through directory to collect html file paths, parse for links, and return array of link objects// create collection of HTML file addresses from directoryconst walk = (dir) => {- let results = [];- const list = fs.readdirSync(dir);+ let results = []+ const list = fs.readdirSync(dir)list.forEach((file) => {- file = `${dir}/${file}`;- const stat = fs.statSync(file);+ file = `${dir}/${file}`+ const stat = fs.statSync(file)if (stat && stat.isDirectory()) {/* Recurse into a subdirectory */- results = results.concat(walk(file));+ results = results.concat(walk(file))} else {- const fileType = file.split('.').pop();+ const fileType = file.split('.').pop()if (fileType === 'html') {- results.push(file);+ results.push(file)}}- });- return results;-};+ })+ return results+}// get URLS from HTML in ./build/options using cheerioconst getUrls = (htmlArray) => {// skip exact (rel and href) doubles of links- const trackDoubles = {};- const scrapedHTML = [];+ const trackDoubles = {}+ const scrapedHTML = []for (let i = 0; i < htmlArray.length; i += 1) {- const $ = cheerio.load(fs.readFileSync(htmlArray[i]));- const links = $('a');+ const $ = cheerio.load(fs.readFileSync(htmlArray[i]))+ const links = $('a')// create url object:// { 'AIRS - The AIRS instrument suite physical retrievals': 'http://airs.jpl.nasa.gov/data/physical_retrievals' }$(links).each((i, link) => {- const linkRel = $(link).text() || 'EMPTY';- const linkHref = $(link).attr('href');+ const linkRel = $(link).text() || 'EMPTY'+ const linkHref = $(link).attr('href')if (trackDoubles[linkRel] !== linkHref) {- scrapedHTML.push({ [linkRel]: linkHref });- trackDoubles[linkRel] = linkHref;+ scrapedHTML.push({ [linkRel]: linkHref })+ trackDoubles[linkRel] = linkHref}- });+ })}- return scrapedHTML;-};+ return scrapedHTML+}// get URLS from HTML files// scraped URLs are saved in an array of objects with a key value pair of link text and href:// 'Wildfire MB-CE042, Manitoba, Canada': 'https://eonet.gsfc.nasa.gov/api/v2.1/events/EONET_3518'-const initExtractor = async() => {+const initExtractor = async () => {// any html file with a url will be scraped and added- const htmlFiles = await walk('./build/options');- const htmlUrls = await getUrls(htmlFiles);- return htmlUrls;-};+ const htmlFiles = await walk('./build/options')+ const htmlUrls = await getUrls(htmlFiles)+ return htmlUrls+}-module.exports = initExtractor;+module.exports = initExtractordiff --git a/tasks/link-check/natural-event-url-extract.js b/tasks/link-check/natural-event-url-extract.jsindex fc8167921..7b72997f9 100644--- a/tasks/link-check/natural-event-url-extract.js+++ b/tasks/link-check/natural-event-url-extract.js@@ -1,75 +1,75 @@/* eslint-disable no-restricted-syntax */-const fetch = require('node-fetch');+const fetch = require('node-fetch')// delay helper to prevent too many requests at once-const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms));+const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms))// helper function to find target key in nested object-const findProp = async(obj, keys, out) => {- let i;- const proto = Object.prototype;- const ts = proto.toString;- const hasOwn = proto.hasOwnProperty.bind(obj);+const findProp = async (obj, keys, out) => {+ let i+ const proto = Object.prototype+ const ts = proto.toString+ const hasOwn = proto.hasOwnProperty.bind(obj)if (ts.call(out) !== '[object Array]') {- out = [];+ out = []}for (i in obj) {if (hasOwn(i)) {if (keys.includes(i)) {// handle different title formats from EONET- const title = obj.title ? obj.title : obj.id;+ const title = obj.title ? obj.title : obj.idif (title) {- out.push({ [title]: obj[i] });+ out.push({ [title]: obj[i] })}} else if (ts.call(obj[i]) === '[object Array]' || ts.call(obj[i]) === '[object Object]') {- findProp(obj[i], keys, out);+ findProp(obj[i], keys, out)}}}- return out;-};+ return out+}-const scrapeLinks = async(htmlLinks) => {+const scrapeLinks = async (htmlLinks) => {// skip exact (rel and href) doubles of links- const trackDoubles = {};- const addedUrls = [];+ const trackDoubles = {}+ const addedUrls = []for (let i = 0; i < htmlLinks.length; i += 1) {- const htmlLink = htmlLinks[i];+ const htmlLink = htmlLinks[i]// eslint-disable-next-line no-await-in-loopawait fetch(htmlLink)- .then(async(res) => {- const status = await res.json();- const urls = await findProp(status, ['url', 'link', 'source']);+ .then(async (res) => {+ const status = await res.json()+ const urls = await findProp(status, ['url', 'link', 'source'])for (let j = 0; j < urls.length; j += 1) {- const url = urls[j];- const linkRel = Object.keys(url)[0];- const linkHref = Object.values(url)[0];+ const url = urls[j]+ const linkRel = Object.keys(url)[0]+ const linkHref = Object.values(url)[0]if (trackDoubles[linkRel] !== linkHref) {- addedUrls.push({ [linkRel]: linkHref });- trackDoubles[linkRel] = linkHref;+ addedUrls.push({ [linkRel]: linkHref })+ trackDoubles[linkRel] = linkHref}}}).then(sleeper(500)).catch((err) => {- console.log(htmlLink, err);- });+ console.log(htmlLink, err)+ })}- return addedUrls;-};+ return addedUrls+}// get URLs from natural events EONET// scraped URLs are saved in an array of objects with a key value pair of link text and href:// 'Wildfire MB-CE042, Manitoba, Canada': 'https://eonet.gsfc.nasa.gov/api/v2.1/events/EONET_3518'-const initExtractor = async() => {+const initExtractor = async () => {// target EONET sources from natural eventsconst links = ['https://eonet.gsfc.nasa.gov/api/v2.1/sources','https://eonet.gsfc.nasa.gov/api/v2.1/events',- 'https://eonet.gsfc.nasa.gov/api/v2.1/categories'];- const results = await scrapeLinks(links);- return results;-};+ 'https://eonet.gsfc.nasa.gov/api/v2.1/categories']+ const results = await scrapeLinks(links)+ return results+}-module.exports = initExtractor;+module.exports = initExtractordiff --git a/tasks/link-check/url-check.js b/tasks/link-check/url-check.jsindex 24b286145..b4c4d63fc 100644--- a/tasks/link-check/url-check.js+++ b/tasks/link-check/url-check.js@@ -1,59 +1,59 @@-const fetch = require('node-fetch');+const fetch = require('node-fetch')// URL status check function makes GET requests to provided list of URLs to get status codes / errors// Delay helper to prevent too many requests at once-const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms));+const sleeper = (ms) => (x) => new Promise((resolve) => setTimeout(() => resolve(x), ms))// Checks status code of provided links and return object organized by errors / statuscodes-const requestCheck = async(urls) => {+const requestCheck = async (urls) => {const parsedUrls = {ERROR: [],- STATUSCODE: {},- };+ STATUSCODE: {}+ }for (let i = 0; i < urls.length; i += 1) {- const linkName = Object.keys(urls[i])[0];- const url = Object.values(urls[i])[0];+ const linkName = Object.keys(urls[i])[0]+ const url = Object.values(urls[i])[0]// Skip for mailto email linksif (url[0] === 'h') {// eslint-disable-next-line no-await-in-loopawait fetch(url, { timeout: 10000 })- .then(async(res) => {- const statusCode = await res.status;+ .then(async (res) => {+ const statusCode = await res.statusif (!parsedUrls.STATUSCODE[statusCode]) {- parsedUrls.STATUSCODE[statusCode] = [];+ parsedUrls.STATUSCODE[statusCode] = []}- parsedUrls.STATUSCODE[statusCode].push({ [linkName]: url });+ parsedUrls.STATUSCODE[statusCode].push({ [linkName]: url })}).then(sleeper(500)).catch((err) => { // eslint-disable-line handle-callback-err- parsedUrls.ERROR.push({ [linkName]: url });- });+ parsedUrls.ERROR.push({ [linkName]: url })+ })}}- return parsedUrls;-};+ return parsedUrls+}// Get urls with errors/status codes organized into an object-const getURLStatusCodeCollection = async function(urls) {- const checkStatus = await requestCheck(urls);+const getURLStatusCodeCollection = async function (urls) {+ const checkStatus = await requestCheck(urls)// Log out number of links with errors/status codesconsole.log(`URL STATUSCODE RESULTS:${'-'.repeat(66)}ERRORS: \x1b[31m${checkStatus.ERROR.length}\x1b[0m- STATUSCODE:`);- const codes = Object.keys(checkStatus.STATUSCODE);+ STATUSCODE:`)+ const codes = Object.keys(checkStatus.STATUSCODE)codes.forEach((code) => {- let preColor = '\x1b[33m';+ let preColor = '\x1b[33m'if (code === '200') {- preColor = '\x1b[32m';+ preColor = '\x1b[32m'} else if (Number(code) >= 400) {- preColor = '\x1b[31m';+ preColor = '\x1b[31m'}- console.log(` ${code}: ${preColor + checkStatus.STATUSCODE[code].length}\x1b[0m`);- });- return checkStatus;-};+ console.log(` ${code}: ${preColor + checkStatus.STATUSCODE[code].length}\x1b[0m`)+ })+ return checkStatus+}-module.exports = getURLStatusCodeCollection;+module.exports = getURLStatusCodeCollectiondiff --git a/tasks/linkCheck.js b/tasks/linkCheck.jsindex 441920877..4982c43d4 100755--- a/tasks/linkCheck.js+++ b/tasks/linkCheck.js@@ -4,45 +4,45 @@// Current version 1.0 targets urls collected from:// ./build/options metadata and EONET natural events// *************************************************************************-const fs = require('fs');-const getUrlStatusCodeCollection = require('./link-check/url-check');-const getHtmlUrls = require('./link-check/html-url-extract.js');-const getNaturalEventsUrls = require('./link-check/natural-event-url-extract.js');+const fs = require('fs')+const getUrlStatusCodeCollection = require('./link-check/url-check')+const getHtmlUrls = require('./link-check/html-url-extract.js')+const getNaturalEventsUrls = require('./link-check/natural-event-url-extract.js')const makeLine = (msg) => console.log(`${'-'.repeat(66)}-\x1b[36m${msg}\x1b[0m`);+\x1b[36m${msg}\x1b[0m`)// Prevent majority of TLS SSL related errors-process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';+process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'// Make get requests with URLs with node-fetch to check status codes and organize by errors and codes-const organizeURLStatus = async(scrapedUrls) => {- const timeEstimate = ((scrapedUrls.length * 1000) / 60000).toFixed(0);- makeLine(`Checking url status codes will take approximately ${timeEstimate} minutes...`);+const organizeURLStatus = async (scrapedUrls) => {+ const timeEstimate = ((scrapedUrls.length * 1000) / 60000).toFixed(0)+ makeLine(`Checking url status codes will take approximately ${timeEstimate} minutes...`)// Initiate status code check- const results = await getUrlStatusCodeCollection(scrapedUrls);+ const results = await getUrlStatusCodeCollection(scrapedUrls)// Wait for URLs to be analyzed then stringify and save to JSON file- const stringified = await JSON.stringify(results, null, 2);- const now = new Date();+ const stringified = await JSON.stringify(results, null, 2)+ const now = new Date()// Check for 'results' directory or make new one// eslint-disable-next-line no-unused-expressions- fs.existsSync('./tasks/link-check/results') || fs.mkdirSync('./tasks/link-check/results');+ fs.existsSync('./tasks/link-check/results') || fs.mkdirSync('./tasks/link-check/results')- const fileName = `./tasks/link-check/results/WV-link-check-${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}.json`;+ const fileName = `./tasks/link-check/results/WV-link-check-${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}.json`fs.writeFile(fileName, stringified, 'utf8', () => {- makeLine(`Results file created: ${fileName}`);- process.exit();- });-};+ makeLine(`Results file created: ${fileName}`)+ process.exit()+ })+}-const main = async() => {- makeLine('Starting by collecting urls to check...');+const main = async () => {+ makeLine('Starting by collecting urls to check...')// get natural event urls- const naturalEventsUrls = await getNaturalEventsUrls();+ const naturalEventsUrls = await getNaturalEventsUrls()// get metadata layers and about page urls- const htmlUrls = await getHtmlUrls();- organizeURLStatus(htmlUrls.concat(naturalEventsUrls));-};+ const htmlUrls = await getHtmlUrls()+ organizeURLStatus(htmlUrls.concat(naturalEventsUrls))+}-main();+main()diff --git a/tasks/migrateConfigs.js b/tasks/migrateConfigs.jsindex d1c596a73..fbba24700 100644--- a/tasks/migrateConfigs.js+++ b/tasks/migrateConfigs.js@@ -1,49 +1,49 @@/* eslint-disable no-console */-const _ = require('lodash');-const fs = require('fs');-const util = require('util');-const dir = require('node-dir');--const fsAccess = util.promisify(fs.access);-const fsWriteFile = util.promisify(fs.writeFile);--const { GIT_HOME } = process.env;-const SOURCE_DIR = './config/default/common/config/wv.json/layers/';-const DEST_DIR = `${GIT_HOME}/layers-config/layer-metadata/v1.0/`;-const WV_JSON_PATH = './build/options/config/wv.json';-const OVERWRITE_EXISTING = false;--let wvJson = {};-let metadataCount = 0;-const measurementsMap = {};-const measurementsArray = [];+const _ = require('lodash')+const fs = require('fs')+const util = require('util')+const dir = require('node-dir')++const fsAccess = util.promisify(fs.access)+const fsWriteFile = util.promisify(fs.writeFile)++const { GIT_HOME } = process.env+const SOURCE_DIR = './config/default/common/config/wv.json/layers/'+const DEST_DIR = `${GIT_HOME}/layers-config/layer-metadata/v1.0/`+const WV_JSON_PATH = './build/options/config/wv.json'+const OVERWRITE_EXISTING = false++let wvJson = {}+let metadataCount = 0+const measurementsMap = {}+const measurementsArray = []const periodIntervalMap = {daily: 'Day',monthly: 'Month',- yearly: 'Year',-};+ yearly: 'Year'+}const errCallback = (err) => {if (err) {- console.log(err);- throw err;+ console.log(err)+ throw err}-};+}-function capitalizeFirstLetter(string) {- return !string ? '' : string.charAt(0).toUpperCase() + string.slice(1);+function capitalizeFirstLetter (string) {+ return !string ? '' : string.charAt(0).toUpperCase() + string.slice(1)}function setLayerProp (layer, prop, value) {- const featuredMeasurement = prop === 'measurements' && (value && value.includes('Featured'));+ const featuredMeasurement = prop === 'measurements' && (value && value.includes('Featured'))if (!layer || featuredMeasurement) {- return;+ return}if (!layer[prop]) {- layer[prop] = [value];+ layer[prop] = [value]} else if (!layer[prop].includes(value)) {- layer[prop].push(value);+ layer[prop].push(value)}}@@ -51,164 +51,163 @@ function generateMeasurements (layers, measurementsConfig) {_.forEach(measurementsConfig, (measureObj, measureKey) => {_.forEach(measureObj.sources, ({ settings = [] }, sourceKey) => {settings.forEach((id) => {- setLayerProp(layers[id], 'measurements', measureKey);+ setLayerProp(layers[id], 'measurements', measureKey)if (!measurementsArray.includes(measureKey)) {- measurementsArray.push(measureKey);+ measurementsArray.push(measureKey)}- });- });- });+ })+ })+ })_.forEach(layers, ({ measurements }, id) => {// Reduce to a single measurement:if (id.toLowerCase().includes('orbit')) {- measurementsMap[id] = 'Orbital Track';+ measurementsMap[id] = 'Orbital Track'} else {// eslint-disable-next-line prefer-destructuring- measurementsMap[id] = measurements[0];+ measurementsMap[id] = measurements[0]}// Unmodified output (all measurements):// measurementsMap[id] = measurements;- });+ })// fs.writeFile(`${DEST_DIR}measurements.json`, JSON.stringify(measurementsMap, null, 2), errCallback);}-function setPeriodProps(wvJsonLayer, outputLayer) {- const { period, dateRanges, id } = wvJsonLayer;+function setPeriodProps (wvJsonLayer, outputLayer) {+ const { period, dateRanges, id } = wvJsonLayerif (!period) {- console.log('No layer period for:', id);+ console.log('No layer period for:', id)}if (!dateRanges) {- outputLayer.layerPeriod = capitalizeFirstLetter(period);- return;+ outputLayer.layerPeriod = capitalizeFirstLetter(period)+ return}- const dateIntervals = (dateRanges || []).map(({ dateInterval }) => dateInterval);- const firstInterval = Number.parseInt(dateIntervals[0], 10);+ const dateIntervals = (dateRanges || []).map(({ dateInterval }) => dateInterval)+ const firstInterval = Number.parseInt(dateIntervals[0], 10)const consistentIntervals = dateIntervals.every((interval) => {- const parsedInterval = Number.parseInt(interval, 10);- return parsedInterval === firstInterval;- });+ const parsedInterval = Number.parseInt(interval, 10)+ return parsedInterval === firstInterval+ })- outputLayer.layerPeriod = capitalizeFirstLetter(period);+ outputLayer.layerPeriod = capitalizeFirstLetter(period)if (period === 'subdaily' || firstInterval === 1) {- return;+ return}if (consistentIntervals && firstInterval <= 16) {- outputLayer.layerPeriod = `${firstInterval}-${periodIntervalMap[period]}`;+ outputLayer.layerPeriod = `${firstInterval}-${periodIntervalMap[period]}`} else if (id.includes('7Day')) {- outputLayer.layerPeriod = '7-Day';+ outputLayer.layerPeriod = '7-Day'} else if (id.includes('5Day')) {- outputLayer.layerPeriod = '5-Day';+ outputLayer.layerPeriod = '5-Day'} else if (id.includes('Monthly')) {- outputLayer.layerPeriod = 'Monthly';+ outputLayer.layerPeriod = 'Monthly'} else if (id.includes('Weekly')) {- outputLayer.layerPeriod = '7-Day';+ outputLayer.layerPeriod = '7-Day'} else {- outputLayer.layerPeriod = `Multi-${periodIntervalMap[period]}`;+ outputLayer.layerPeriod = `Multi-${periodIntervalMap[period]}`}}function modifyProps (layerObj) {const {- id, title, subtitle, tracks, daynight, inactive,- } = layerObj;- const wvJsonLayerObj = wvJson.layers[id];+ id, title, subtitle, tracks, daynight, inactive+ } = layerObj+ const wvJsonLayerObj = wvJson.layers[id]if (!wvJsonLayerObj) {- console.error(`Layer ${title} not found in wv.json, run build script!`);- return;+ console.error(`Layer ${title} not found in wv.json, run build script!`)+ return}const {- startDate, endDate, dateRanges, period,- } = wvJsonLayerObj;- const staticLayer = !startDate && !endDate && !dateRanges;+ startDate, endDate, dateRanges, period+ } = wvJsonLayerObj+ const staticLayer = !startDate && !endDate && !dateRangesconst modifiedObj = {title,subtitle,ongoing: staticLayer ? false : !inactive,measurement: measurementsMap[id],- retentionPeriod: -1,- };+ retentionPeriod: -1+ }if (daynight) {- modifiedObj.daynight = daynight;+ modifiedObj.daynight = daynight}if (tracks && period !== 'monthly') {- modifiedObj.orbitTracks = [];- modifiedObj.orbitDirection = [];+ modifiedObj.orbitTracks = []+ modifiedObj.orbitDirection = []tracks.forEach((track) => {- modifiedObj.orbitTracks.push(track);+ modifiedObj.orbitTracks.push(track)if (wvJson.layers[track]) {- modifiedObj.orbitDirection.push(wvJson.layers[track].track);+ modifiedObj.orbitDirection.push(wvJson.layers[track].track)} else {- console.log('Orbit track not found', track);+ console.log('Orbit track not found', track)}- });+ })}if (period) {// WARNING: Not totally accurate, will need to identify N-Day layers.// modifiedObj.period = wvJsonLayerObj.period;- setPeriodProps(wvJsonLayerObj, modifiedObj);+ setPeriodProps(wvJsonLayerObj, modifiedObj)}- return modifiedObj;+ return modifiedObj}-/**** @param {*} filePath*/-async function migrate(filePath) {- const pathStrings = filePath.split('/');- const fileName = pathStrings[pathStrings.length - 1];+async function migrate (filePath) {+ const pathStrings = filePath.split('/')+ const fileName = pathStrings[pathStrings.length - 1]if (!fileName.includes('.json')) {- return;+ return}- const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'));- const fileLayerId = fileName.slice(0, fileName.length - 5);- const id = Object.keys(layerJson.layers)[0];+ const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'))+ const fileLayerId = fileName.slice(0, fileName.length - 5)+ const id = Object.keys(layerJson.layers)[0]if (fileLayerId !== id) {- console.warn('File name did not match id:', filePath);+ console.warn('File name did not match id:', filePath)}- const layerPropsObj = layerJson.layers[id];+ const layerPropsObj = layerJson.layers[id]if (!layerPropsObj) {- console.error('No layer data for:', filePath);- return;+ console.error('No layer data for:', filePath)+ return}- const path = `${DEST_DIR}${fileName}`;- const newObj = modifyProps(layerPropsObj);- const output = JSON.stringify(newObj, null, 2);+ const path = `${DEST_DIR}${fileName}`+ const newObj = modifyProps(layerPropsObj)+ const output = JSON.stringify(newObj, null, 2)try {- await fsAccess(path, fs.constants.F_OK);+ await fsAccess(path, fs.constants.F_OK)} catch (err) {if (err.code === 'ENOENT') {- metadataCount += 1;- await fsWriteFile(path, output, errCallback);+ metadataCount += 1+ await fsWriteFile(path, output, errCallback)}}if (OVERWRITE_EXISTING) {- metadataCount += 1;- await fsWriteFile(path, output, errCallback);+ metadataCount += 1+ await fsWriteFile(path, output, errCallback)}}dir.files(SOURCE_DIR, async (err, files) => {- if (err) throw err;- wvJson = JSON.parse(fs.readFileSync(WV_JSON_PATH, 'utf-8'));- generateMeasurements(wvJson.layers, wvJson.measurements);- await Promise.all(files.map(migrate));+ if (err) throw err+ wvJson = JSON.parse(fs.readFileSync(WV_JSON_PATH, 'utf-8'))+ generateMeasurements(wvJson.layers, wvJson.measurements)+ await Promise.all(files.map(migrate))if (metadataCount > 0) {- console.log(`Successfully generated ${metadataCount} metadata configs.`);+ console.log(`Successfully generated ${metadataCount} metadata configs.`)} else {- console.log('No metadata configs were generated');+ console.log('No metadata configs were generated')}-});+})diff --git a/tasks/node/getCapabilities.js b/tasks/node/getCapabilities.jsindex e868213dd..ce4837601 100755--- a/tasks/node/getCapabilities.js+++ b/tasks/node/getCapabilities.js@@ -1,16 +1,14 @@-#!/usr/bin/env node--const fs = require('fs');-const path = require('path');-const yargs = require('yargs');-const console = require('console');-const request = require('axios').default;-const convert = require('xml-js');-const { promisify } = require('util');-const stream = require('stream');--const finished = promisify(stream.finished);-const prog = path.basename(__filename);+const fs = require('fs')+const path = require('path')+const yargs = require('yargs')+const console = require('console')+const request = require('axios').default+const convert = require('xml-js')+const { promisify } = require('util')+const stream = require('stream')++const finished = promisify(stream.finished)+const prog = path.basename(__filename)// const baseDir = path.join(__dirname, '..');const options = yargs@@ -19,167 +17,166 @@ const options = yargsdemandOption: true,alias: 'c',type: 'string',- description: 'config file',+ description: 'config file'}).option('getcapabilities', {demandOption: true,alias: 'g',type: 'string',- description: 'getcapabilities file',+ description: 'getcapabilities file'})- .epilog('Pulls GetCapabilities XML and linked metadata from configured locations');+ .epilog('Pulls GetCapabilities XML and linked metadata from configured locations')// import config file from ./config/default/release/config.json-const { argv } = options;+const { argv } = optionsif (!argv.config && !argv.getcapabilities) {- console.error('Invalid number of arguments');- process.exit(1);+ throw new Error('Invalid number of arguments')}-const configFile = argv.config;-const outputDir = argv.getcapabilities;-const colormaps = {};-const vectorstyles = {};-const vectordata = {};-const colormapsDir = path.join(outputDir, 'colormaps');-const vectorstylesDir = path.join(outputDir, 'vectorstyles');-const vectordataDir = path.join(outputDir, 'vectordata');--const configData = fs.readFileSync(configFile);-const config = JSON.parse(configData);+const configFile = argv.config+const outputDir = argv.getcapabilities+const colormaps = {}+const vectorstyles = {}+const vectordata = {}+const colormapsDir = path.join(outputDir, 'colormaps')+const vectorstylesDir = path.join(outputDir, 'vectorstyles')+const vectordataDir = path.join(outputDir, 'vectordata')++const configData = fs.readFileSync(configFile)+const config = JSON.parse(configData)async function main () {if (!fs.existsSync(outputDir)) {- fs.mkdirSync(outputDir);+ fs.mkdirSync(outputDir)}- await GetCapabilities();+ await getCapabilities()+ if (colormaps) {+ await gatherProcess(colormaps, 'colormaps', colormapsDir, '.xml')+ }+ if (vectorstyles) {+ await gatherProcess(vectorstyles, 'vectorstyles', vectorstylesDir, '.json')+ }+ if (vectordata) {+ await gatherProcess(vectordata, 'vectordatas', vectordataDir, '.json')+ }// process.exit();}-async function GetCapabilities() {+async function getCapabilities () {// Download each GC xml using the "from" attribute and put it in the "to" locationif (Object.prototype.hasOwnProperty.call(config, 'wv-options-fetch')) {- const fetchValues = config['wv-options-fetch'];- Object.entries(fetchValues).forEach(async ([key, value]) => {- const inputFile = value.from;- const outputFile = `${outputDir}/${value.to}`;+ const fetchValues = config['wv-options-fetch']+ for (const value of fetchValues) {+ const inputFile = value.from+ const outputFile = `${outputDir}/${value.to}`- await fetchConfigs(inputFile, outputFile);- await processGetCapabilities(outputFile);-- if (colormaps) {- await gatherProcess(colormaps, 'colormaps', colormapsDir, '.xml');- }- if (vectorstyles) {- await gatherProcess(vectorstyles, 'vectorstyles', vectorstylesDir, '.json');- }- if (vectordata) {- await gatherProcess(vectordata, 'vectordatas', vectordataDir, '.json');- }- });+ await fetchConfigs(inputFile, outputFile)+ await processGetCapabilities(outputFile)+ }}}-async function fetchConfigs(inputFile, outputFile) {- const writer = await fs.createWriteStream(outputFile);+async function fetchConfigs (inputFile, outputFile) {+ const writer = await fs.createWriteStream(outputFile)return request({method: 'get',url: inputFile,responseType: 'stream',+ timeout: 10000}).then(async (response) => {- await response.data.pipe(writer);- return finished(writer);- });+ await response.data.pipe(writer)+ return finished(writer)+ })}-async function handleException(error, link) {- console.warn(`\n ${prog} WARN: Unable to fetch ${link} ${error}`);+async function handleException (error, link) {+ console.warn(`\n ${prog} WARN: Unable to fetch ${link} ${error}`)}-async function processVectorData(layer) {+async function processVectorData (layer) {if (layer['ows:Metadata']) {Object.values(layer['ows:Metadata']).forEach((item) => {- const schemaVersion = item._attributes['xlink:role'];+ const schemaVersion = item._attributes['xlink:role']if (schemaVersion === 'http://earthdata.nasa.gov/gibs/metadata-type/layer/1.0') {- const vectorDataLink = item._attributes['xlink:href'];- const vectorDataFile = path.basename(vectorDataLink);- const vectorDataId = path.parse(vectorDataFile).name;- vectordata[vectorDataId] = vectorDataLink;+ const vectorDataLink = item._attributes['xlink:href']+ const vectorDataFile = path.basename(vectorDataLink)+ const vectorDataId = path.parse(vectorDataFile).name+ vectordata[vectorDataId] = vectorDataLink}- });+ })}}-async function processLayer(layer) {- const ident = layer['ows:Identifier']._text;+async function processLayer (layer) {+ const ident = layer['ows:Identifier']._textif (layer['ows:Metadata']) {if (config.skipPalettes) {- console.warn(`${prog}: WARN: Skipping palette for ${ident} \n`);+ console.warn(`${prog}: WARN: Skipping palette for ${ident} \n`)} else {Object.values(layer['ows:Metadata']).forEach((item) => {- const schemaVersion = item._attributes['xlink:role'];+ const schemaVersion = item._attributes['xlink:role']if (schemaVersion === 'http://earthdata.nasa.gov/gibs/metadata-type/colormap/1.3') {- const colormapLink = item._attributes['xlink:href'];- const colormapFile = path.basename(colormapLink);- const colormapId = path.parse(colormapFile).name;- colormaps[colormapId] = colormapLink;+ const colormapLink = item._attributes['xlink:href']+ const colormapFile = path.basename(colormapLink)+ const colormapId = path.parse(colormapFile).name+ colormaps[colormapId] = colormapLink} else if (schemaVersion === 'http://earthdata.nasa.gov/gibs/metadata-type/mapbox-gl-style/1.0') {- const vectorStyleLink = item._attributes['xlink:href'];- const vectorStyleFile = path.basename(vectorStyleLink);- const vectorStyleId = path.parse(vectorStyleFile).name;- vectorstyles[vectorStyleId] = vectorStyleLink;+ const vectorStyleLink = item._attributes['xlink:href']+ const vectorStyleFile = path.basename(vectorStyleLink)+ const vectorStyleId = path.parse(vectorStyleFile).name+ vectorstyles[vectorStyleId] = vectorStyleLink}- });+ })}}}-async function processGetCapabilities(outputFile) {- const gcXML = fs.readFileSync(outputFile, { encoding: 'utf-8' });- let gc = convert.xml2json(gcXML, { compact: true, spaces: 2 });- gc = JSON.parse(gc);+async function processGetCapabilities (outputFile) {+ const gcXML = fs.readFileSync(outputFile, { encoding: 'utf-8' })+ let gc = convert.xml2json(gcXML, { compact: true, spaces: 2 })+ gc = JSON.parse(gc)try {if (!gc.Capabilities || !gc.Capabilities.Contents) {- console.error(`error: ${outputFile}: no layers`);- process.exit(1);+ console.error(`error: ${outputFile}: no layers`)+ process.exit(1)}- const layers = gc.Capabilities.Contents.Layer;+ const layers = gc.Capabilities.Contents.LayerObject.values(layers).forEach((layer) => {- processLayer(layer);- processVectorData(layer);- });+ processLayer(layer)+ processVectorData(layer)+ })} catch (error) {- console.error(`ERROR: ${outputFile}: ${error}`);- process.exit(1);+ console.error(`ERROR: ${outputFile}: ${error}`)+ process.exit(1)}}-async function processMetadata(link, dir, ext) {+async function processMetadata (link, dir, ext) {try {- const outputFile = path.join(dir, path.basename(link));+ const outputFile = path.join(dir, path.basename(link))if (link.endsWith(ext)) {- await fetchConfigs(link, outputFile);+ await fetchConfigs(link, outputFile)}} catch (error) {- handleException(error, link);+ handleException(error, link)}}-async function gatherProcess(type, typeStr, dir, ext) {- console.warn(`${prog}: Fetching ${Object.keys(type).length} ${typeStr}`);+async function gatherProcess (type, typeStr, dir, ext) {+ console.warn(`${prog}: Fetching ${Object.keys(type).length} ${typeStr}`)if (!fs.existsSync(dir)) {- fs.mkdirSync(dir);+ fs.mkdirSync(dir)}Object.values(type).forEach(async (link) => {- await processMetadata(link, dir, ext);- });+ await processMetadata(link, dir, ext)+ })}main().catch((err) => {- console.error(err.stack);-});+ console.error(err.stack)+})diff --git a/tasks/removeProps.js b/tasks/removeProps.jsindex f31293bfa..3114672b3 100644--- a/tasks/removeProps.js+++ b/tasks/removeProps.js@@ -1,41 +1,41 @@-const fs = require('fs');-const dir = require('node-dir');+const fs = require('fs')+const dir = require('node-dir')-const SOURCE_DIR = './config/default/common/config/wv.json/layers/';+const SOURCE_DIR = './config/default/common/config/wv.json/layers/'const removeKeys = ['product','title','subtitle','inactive','daynight',- 'tracks',-];+ 'tracks'+]const errCallback = (err) => {if (err) {- console.log(err);- throw err;+ console.log(err)+ throw err}-};+}-function processConfig(filePath) {- const pathStrings = filePath.split('/');- const fileName = pathStrings[pathStrings.length - 1];+function processConfig (filePath) {+ const pathStrings = filePath.split('/')+ const fileName = pathStrings[pathStrings.length - 1]if (!fileName.includes('.json')) {- return;+ return}- const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'));- const layerId = Object.keys(layerJson.layers)[0];+ const layerJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'))+ const layerId = Object.keys(layerJson.layers)[0]removeKeys.forEach((key) => {- const entry = layerJson.layers[layerId];+ const entry = layerJson.layers[layerId]// Leav ID prop on WMS entries- if (entry.type === 'wms' && key === 'id') return;- delete layerJson.layers[layerId][key];- });- fs.writeFile(`${filePath}`, JSON.stringify(layerJson, null, 2), errCallback);+ if (entry.type === 'wms' && key === 'id') return+ delete layerJson.layers[layerId][key]+ })+ fs.writeFile(`${filePath}`, JSON.stringify(layerJson, null, 2), errCallback)}dir.files(SOURCE_DIR, (err, files) => {- if (err) throw err;- files.forEach(processConfig);-});+ if (err) throw err+ files.forEach(processConfig)+})diff --git a/tasks/renameProps.js b/tasks/renameProps.jsindex fa42bd88f..6c4a35d5b 100644--- a/tasks/renameProps.js+++ b/tasks/renameProps.js@@ -1,37 +1,37 @@-const fs = require('fs');-const dir = require('node-dir');+const fs = require('fs')+const dir = require('node-dir')-const { GIT_HOME } = process.env;-const SOURCE_DIR = `${GIT_HOME}/layers-config/layer-metadata/v1.0/`;+const { GIT_HOME } = process.env+const SOURCE_DIR = `${GIT_HOME}/layers-config/layer-metadata/v1.0/`const renameKeys = {- period: 'layerPeriod',-};+ period: 'layerPeriod'+}const errCallback = (err) => {if (err) {- console.log(err);- throw err;+ console.log(err)+ throw err}-};+}-function processConfig(filePath) {- const pathStrings = filePath.split('/');- const fileName = pathStrings[pathStrings.length - 1];+function processConfig (filePath) {+ const pathStrings = filePath.split('/')+ const fileName = pathStrings[pathStrings.length - 1]if (!fileName.includes('.json')) {- return;+ return}- const metadataJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'));+ const metadataJson = JSON.parse(fs.readFileSync(filePath, 'utf-8'))Object.keys(renameKeys).forEach((key) => {- const entry = metadataJson;- const newKey = renameKeys[key];- entry[newKey] = entry[key];- delete entry[key];- });- fs.writeFile(`${filePath}`, JSON.stringify(metadataJson, null, 2), errCallback);+ const entry = metadataJson+ const newKey = renameKeys[key]+ entry[newKey] = entry[key]+ delete entry[key]+ })+ fs.writeFile(`${filePath}`, JSON.stringify(metadataJson, null, 2), errCallback)}dir.files(SOURCE_DIR, (err, files) => {- if (err) throw err;- files.forEach(processConfig);-});+ if (err) throw err+ files.forEach(processConfig)+})diff --git a/tasks/start.js b/tasks/start.jsindex 4ca5497c7..0870ea7f3 100755--- a/tasks/start.js+++ b/tasks/start.js@@ -1,8 +1,8 @@-const compression = require('compression');-const express = require('express');-const path = require('path');+const compression = require('compression')+const express = require('express')+const path = require('path')-const port = process.env.PORT || 3000;+const port = process.env.PORT || 3000const app = express();app.use(compression());@@ -10,5 +10,5 @@ app.use(express.static(path.join(__dirname, '../web')));// app.use('/test', express.static(path.join(__dirname, '../build/worldview'))); // test dist in a "test" sub directoryapp.set('port', port);app.listen(port, () => {- console.log(`Worldview is available at http://localhost:${port}`);-});+ console.log(`Worldview is available at http://localhost:${port}`)+})diff --git a/tasks/upload.js b/tasks/upload.jsindex ff4657374..6b56477d7 100755--- a/tasks/upload.js+++ b/tasks/upload.js@@ -1,18 +1,18 @@#!/usr/bin/env node-const fs = require('fs');-const os = require('os');-const path = require('path');-const yargs = require('yargs');-const shell = require('shelljs');-const { NodeSSH } = require('node-ssh');--const ssh = new NodeSSH();--function error(msg) {- const prog = path.basename(__filename);- console.error(`${prog}: error: ${msg}`);- process.exit(1);+const fs = require('fs')+const os = require('os')+const path = require('path')+const yargs = require('yargs')+const shell = require('shelljs')+const { NodeSSH } = require('node-ssh')++const ssh = new NodeSSH()++function error (msg) {+ const prog = path.basename(__filename)+ console.error(`${prog}: error: ${msg}`)+ process.exit(1)}const { argv } = yargs@@ -20,37 +20,37 @@ const { argv } = yargs.option('d', {alias: 'dist',description: 'do not build, use artifacts found in dist directory',- type: 'boolean',+ type: 'boolean'}).option('e', {alias: 'env',description: 'configuration environment if not "release"',requiresArg: true,- type: 'string',+ type: 'string'}).option('h', {alias: 'host',description: 'upload to this host',requiresArg: true,- type: 'string',+ type: 'string'}).option('k', {alias: 'key',description: 'path to private ssh key',requiresArg: true,- type: 'string',+ type: 'string'}).option('r', {alias: 'root',description: 'extract application to this directory',requiresArg: true,- type: 'string',+ type: 'string'}).option('u', {alias: 'user',description: 'login to remote host using this user name',requiresArg: true,- type: 'string',+ type: 'string'}).epilog(`Defaults for "host", "key", "root", and "user" should be placed in a JSON@@ -59,96 +59,96 @@ file found at "${os.homedir()}/.worldview/upload.config".Values on the command line override those found in the configuration file.If "host" or "root" is not found in the configuration file, it must-appear on the command line.`);+appear on the command line.`)if (argv.help) {- yargs.showHelp();- process.exit(0);+ yargs.showHelp()+ process.exit(0)}-const baseDir = path.join(__dirname, '..');-const distDir = path.join(baseDir, 'dist');-const worldview = 'worldview.tar.gz';-const distWorldview = path.join(distDir, worldview);-const configFile = path.join(os.homedir(), '.worldview', 'upload.config');+const baseDir = path.join(__dirname, '..')+const distDir = path.join(baseDir, 'dist')+const worldview = 'worldview.tar.gz'+const distWorldview = path.join(distDir, worldview)+const configFile = path.join(os.homedir(), '.worldview', 'upload.config')-let configData = '{}';+let configData = '{}'try {- configData = fs.readFileSync(configFile);+ configData = fs.readFileSync(configFile)} catch (err) {// okay if config file cannot be read}-let config = {};+let config = {}try {- config = JSON.parse(configData);+ config = JSON.parse(configData)} catch (err) {- error(`${configFile}:\n${err}`);+ error(`${configFile}:\n${err}`)}-const host = argv.host || config.host;-const root = argv.root || config.root;-const username = argv.user || config.user || os.userInfo().username;-const key = argv.key || config.key || path.join(os.homedir(), '.ssh', 'id_rsa');+const host = argv.host || config.host+const root = argv.root || config.root+const username = argv.user || config.user || os.userInfo().username+const key = argv.key || config.key || path.join(os.homedir(), '.ssh', 'id_rsa')if (!host) {- error('host not found in config file or command line');+ error('host not found in config file or command line')}if (!root) {- error('root not found in config file or command line');+ error('root not found in config file or command line')}if (!username) {- error('user not found in config file or command line');+ error('user not found in config file or command line')}-const name = argv._[0];+const name = argv._[0]if (!name) {- error('name is required');+ error('name is required')}-async function upload() {- console.log(`Uploading to ${host}`);+async function upload () {+ console.log(`Uploading to ${host}`)try {await ssh.connect({host,username,- privateKeyPath: key,- });+ privateKeyPath: key+ })let cmd = `[ -e ${root}/${name}/${worldview} ] &&rm -rf ${root}/${name} &&- mkdir -p ${root}/${name}`;- let result = await ssh.execCommand(cmd);- process.stdout.write(result.stdout);- process.stderr.write(result.stderr);- await ssh.putFile(distWorldview, `${root}/${name}/${worldview}`);+ mkdir -p ${root}/${name}`+ let result = await ssh.execCommand(cmd)+ process.stdout.write(result.stdout)+ process.stderr.write(result.stderr)+ await ssh.putFile(distWorldview, `${root}/${name}/${worldview}`)cmd = `cd ${root}/${name} &&- tar xf ${worldview} --warning=no-unknown-keyword --strip-components=1 --touch`;- result = await ssh.execCommand(cmd);+ tar xf ${worldview} --warning=no-unknown-keyword --strip-components=1 --touch`+ result = await ssh.execCommand(cmd)// Set permissions for Group and Other to Read and Execute for images, config metadata, and brand dirs- cmd = `chmod -R go+xr ${root}/${name}/config && chmod -R go+xr ${root}/${name}/images && chmod -R go+xr ${root}/${name}/brand`;- result = await ssh.execCommand(cmd);- process.stdout.write(result.stdout);- process.stderr.write(result.stderr);- ssh.dispose();- console.log('Done');+ cmd = `chmod -R go+xr ${root}/${name}/config && chmod -R go+xr ${root}/${name}/images && chmod -R go+xr ${root}/${name}/brand`+ result = await ssh.execCommand(cmd)+ process.stdout.write(result.stdout)+ process.stderr.write(result.stderr)+ ssh.dispose()+ console.log('Done')} catch (err) {- error(err.toString());+ error(err.toString())}}if (!argv.dist) {- const options = {};+ const options = {}if (argv.env) {options.env = {...process.env,- CONFIG_ENV: argv.env,- };+ CONFIG_ENV: argv.env+ }}- shell.exec('npm run build', options);- shell.exec('node ./tasks/dist.js', options);+ shell.exec('npm run build', options)+ shell.exec('node ./tasks/dist.js', options)}-upload();+upload()