Skip to content

Commit

Permalink
Merge pull request #161 from Wikimedia-Austria/2023-dependency-upgrades
Browse files Browse the repository at this point in the history
2023 dependency upgrades
  • Loading branch information
reiterbene committed Jun 27, 2023
2 parents 08f70d0 + 0310518 commit 108ba79
Show file tree
Hide file tree
Showing 36 changed files with 44,360 additions and 5,869 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const NODE_ENV = process.env.NODE_ENV;

module.exports = {
extends: ["react-app"],
// ISSUE: https://github.com/facebook/create-react-app/issues/12070 --> will be fixed with next cra version
parserOptions: {
babelOptions: { presets: [["babel-preset-react-app", false]] },
},
};
19 changes: 15 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"i18n-ally.localesPaths": [
"src/translations/locales"
]
}
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"i18n-ally.localesPaths": [
"src/translations/locales"
],
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features",
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
},
}
76 changes: 34 additions & 42 deletions boundary-checker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const readline = require('readline');
const { promisify } = require('util');
const fs = require('fs');
const readline = require("readline");
const { promisify } = require("util");
const fs = require("fs");

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
});

rl.question[promisify.custom] = (question) => {
Expand All @@ -13,10 +13,8 @@ rl.question[promisify.custom] = (question) => {
});
};

const boundaries = require('./src/config/boundaries.json');
const wikidata = require('./src/config/wikidata-gkz.json');

const diff = (diffMe, diffBy) => diffMe.split(diffBy).join('')
const boundaries = require("./src/config/boundaries.json");
const wikidata = require("./src/config/wikidata-gkz.json");

async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
Expand All @@ -27,46 +25,40 @@ async function asyncForEach(array, callback) {
const newBoundaries = [];

const checkData = async () => {
await asyncForEach(boundaries, async b => {
await asyncForEach(boundaries, async (b) => {
const unitCode = b.unit_code;

const match = wikidata.find(w => parseInt(w.gemeindekennzahl) === parseInt(unitCode));

if(match) {
const difference = diff(b.name.replace(/ *\([^)]*\) */g, "").replace('Sankt', 'St.'), match.gemeinde.replace(/ *\([^)]*\) */g, "").replace('Sankt', 'St.'));

if(difference.length > 0) {
const answer = await promisify(rl.question)(`${b.name}: Wikidata Name not matching: ${match.gemeinde.replace(/ *\([^)]*\) */g, "")} (Mapbox: ${unitCode} / Wikidata: ${match.gemeindekennzahl}) | 'y' for OK, otherwise enter correct GKZ:`);

if(answer !== '' && answer !== 'y') {
b.unit_code = '' + answer;
console.log(`GKZ overwritten with ${answer}`);
}
}
} else {
const match = wikidata.find(w => b.name.replace(/ *\([^)]*\) */g, "") === w.gemeinde.replace(/ *\([^)]*\) */g, ""));

if(match) {
const answer = await promisify(rl.question)(`${b.name}: GKZ not Found, Match by Name: ${match.gemeinde.replace(/ *\([^)]*\) */g, "")} (Mapbox: ${unitCode} / Wikidata: ${match.gemeindekennzahl}) | 'y' to use GKZ '${match.gemeindekennzahl}', otherwise enter correct GKZ:`);

if(answer !== '' && answer !== 'y') {
b.unit_code = '' + answer;
console.log(`GKZ overwritten with ${answer}`);
}
} else {
const answer = await promisify(rl.question)(`${b.name}: GKZ not Found, no Match by Name (Mapbox GKZ: ${unitCode}) | Please enter correct GKZ:`);
b.unit_code = '' + answer;
console.log(`GKZ overwritten with ${answer}`);
}
let match = wikidata.find(
(w) => parseInt(w.gemeindekennzahl) === parseInt(unitCode)
);

while (!match) {
const answer = await promisify(rl.question)(
`${b.name}: GKZ not Found (Mapbox GKZ: ${unitCode}) | Please enter correct GKZ:`
);
match = wikidata.find(
(w) => parseInt(w.gemeindekennzahl) === parseInt(answer)
);
}

b.unit_code = "" + match.gemeindekennzahl;
b.name = match.gemeinde.replace(/ *\([^)]*\) */g, "");
b.wikidata = match.wikidata;

newBoundaries.push(b);
});

fs.writeFile('./src/config/boundaries_mapped.json', JSON.stringify(newBoundaries), 'utf8', () => {
console.log('New Data written to ./scr/config/boundaries_mapped.json. Goodbye!');
process.exit();
});
}
fs.writeFile(
"./src/config/boundaries_mapped.json",
JSON.stringify(newBoundaries),
"utf8",
() => {
console.log(
"New Data written to ./scr/config/boundaries_mapped.json. Goodbye!"
);
process.exit();
}
);
};

checkData();
35 changes: 19 additions & 16 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
const {
override,
addWebpackModuleRule,
} = require("customize-cra");
const { override, addWebpackModuleRule } = require("customize-cra");

const setGlobalObject = value => config => {
const setGlobalObject = (value) => (config) => {
// mutate config as you want
config.output.globalObject = value;

// return config so the next function in the pipeline receives it as argument
return config
}
return config;
};

const overrideStats = (value) => (config) => {
config.stats = value;
return config;
};

module.exports = (config, env) => {
return override(
setGlobalObject('(self || this)'),
setGlobalObject("(self || this)"),
/*overrideStats({
children: true
}),*/ // enable if you weant to see more detailed stats for debug
addWebpackModuleRule({
test: /\.html$/,
use: [
{loader: 'html-loader', options: { esModule: true }}
]
use: [{ loader: "html-loader", options: { esModule: true } }],
}),
addWebpackModuleRule({
test: /(\.worker|mapbox-gl-csp-worker).js$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
filename: "[name].[contenthash].worker.js"
}
filename: "[name].[contenthash].worker.js",
},
},
]
],
})
)(config, env);
}
};
42 changes: 22 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,43 @@
"description": "WikiDaheim Client for Wikimedia Austria",
"author": "Benedikt Reiter",
"dependencies": {
"@formatjs/intl-pluralrules": "^5.0.2",
"@formatjs/intl-relativetimeformat": "^11.0.2",
"@sentry/browser": "^7.3.0",
"@formatjs/intl-pluralrules": "^5.2.4",
"@formatjs/intl-relativetimeformat": "^11.2.4",
"@sentry/browser": "^7.55.0",
"dialog-polyfill": "^0.5.6",
"geolib": "^3.2.1",
"immutable": "^4.1.0",
"mapbox-gl": "^2.9.1",
"geolib": "^3.3.4",
"gpx-builder": "^5.2.1",
"history": "^5.3.0",
"immutable": "^4.3.0",
"mapbox-gl": "^2.15.0",
"react": "^18.2.0",
"react-autocomplete": "^1.8.1",
"react-dom": "^18.2.0",
"react-dropdown": "^1.7.0",
"react-intl": "^6.0.4",
"react-dropdown": "^1.11.0",
"react-intl": "^6.4.4",
"react-mapbox-gl": "^5.1.1",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-redux": "^8.1.0",
"react-router-dom": "^6.12.1",
"react-scripts": "5.0.1",
"react-spinners-kit": "^1.9.1",
"react-truncate": "^2.4.0",
"react-virtualized": "^9.21.2",
"redux": "^4.0.5",
"react-virtualized": "^9.22.5",
"redux": "^4.2.1",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"sass": "^1.53.0",
"redux-thunk": "^2.4.2",
"sass": "^1.63.4",
"wikimedia-commons-file-path": "^2.1.1"
},
"engines": {
"node": ">=18.0.0 <19.0.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"analyze": "npx source-map-explorer 'build/static/js/*.js'",
"manage:translations": "formatjs extract 'src/components/**/*.js*' --out-file src/translations/extractedMessages.json --format simple",
"check:boundaries": "node ./boundary-checker.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -57,10 +59,10 @@
]
},
"devDependencies": {
"@formatjs/cli": "^5.0.2",
"babel-plugin-formatjs": "^10.3.25",
"@formatjs/cli": "^6.1.3",
"babel-plugin-formatjs": "^10.5.3",
"customize-cra": "^1.0.0",
"html-loader": "^4.1.0",
"html-loader": "^4.2.0",
"react-app-rewired": "^2.1.6",
"worker-loader": "^3.0.8"
}
Expand Down
54 changes: 23 additions & 31 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="description" content="WikiDaheim ist ein Projekt von Freiwilligen der Wikimedia-Projekte wie Wikipedia, das sich mit dem Sammeln von Informationen über Gemeinden in ganz Österreich beschäftigt.">
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>WikiDaheim: deine Heimat in der Wikipedia</title>
</head>
<body>
<noscript>
WikiDaheim ist ein Projekt von Freiwilligen der Wikimedia-Projekte wie Wikipedia, das sich mit dem Sammeln von Informationen über Gemeinden in ganz Österreich beschäftigt.
WikiDaheim ist eine Webapplikation und benötigt daher JavaScript. Bitte aktiviere JavaScript für diese Webseite.
</noscript>
<div id="root"></div>

<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//wikilovesmonuments.at/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '4']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
</body>
</html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="description"
content="WikiDaheim ist ein Projekt von Freiwilligen der Wikimedia-Projekte wie Wikipedia, das sich mit dem Sammeln von Informationen über Gemeinden in ganz Österreich beschäftigt.">
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>WikiDaheim: deine Heimat in der Wikipedia</title>
</head>

<body>
<noscript>
WikiDaheim ist ein Projekt von Freiwilligen der Wikimedia-Projekte wie Wikipedia, das sich mit dem Sammeln von
Informationen über Gemeinden in ganz Österreich beschäftigt.
WikiDaheim ist eine Webapplikation und benötigt daher JavaScript. Bitte aktiviere JavaScript für diese Webseite.
</noscript>
<div id="root"></div>
</body>

</html>
Loading

0 comments on commit 108ba79

Please sign in to comment.