Skip to content

Commit

Permalink
MAJ classement villes.plus
Browse files Browse the repository at this point in the history
  • Loading branch information
mquandalle committed Sep 9, 2023
1 parent 32abff6 commit 243edfa
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ node_modules
data-fetch/miniatures/aides-jeunes-repo

# Generated at build time
src/data
src/lib/data
src/lib/data/*
!src/lib/data/classement-villeplus.json
Binary file added bun.lockb
Binary file not shown.
28 changes: 28 additions & 0 deletions data-fetch/maj-villesplus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { JSDOM } from 'jsdom';
import epci from '@etalab/decoupage-administratif/data/epci.json' assert { type: 'json' };
import { slugify } from '../src/lib/utils.js';
import { writeJsonData } from '../src/scripts/writeData.js';

const source = await fetch('https://www.villes.plus/cyclables/metropoles');
const { document } = new JSDOM(await source.text()).window;

const rawMetropoles = [...document.querySelectorAll('h3')].map((h3) => h3.textContent);

const simplify = (s) =>
slugify(s)
.replace(/[0-9]/g, '')
.replace(/((euro)?metropole|de|)/g, '')
.replace(/(^-+|-+$)/g, '');

const normalizedEpciNames = rawMetropoles.map(
(line) => epci.find(({ nom }) => simplify(nom).includes(simplify(line)))?.nom
);

if (normalizedEpciNames.find((n) => !n)) {
console.log('❌ Missing EPCI:');
console.log(normalizedEpciNames.filter(Boolean).join('\n'));
} else {
console.log("✅ All EPCI's found:");
console.log(normalizedEpciNames.join('\n'));
writeJsonData('classement-villeplus.json', normalizedEpciNames);
}
34 changes: 0 additions & 34 deletions data-fetch/villes.plus/index.js

This file was deleted.

93 changes: 47 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
{
"name": "mesaidesvelo",
"version": "1.0.0",
"scripts": {
"postinstall": "node ./src/scripts/postinstall.js",
"dev": "VITE_SITE=mesaidesvelo.fr vite dev",
"dev:retrofit": "VITE_SITE=aideretrofit.fr vite dev",
"build": "VITE_SITE=mesaidesvelo.fr vite build",
"build:retrofit": "VITE_SITE=aideretrofit.fr vite build",
"preview": "VITE_SITE=mesaidesvelo.fr vite preview",
"sync-entreprises": "node ./data-fetch/entreprises/download-gsheet-data.js",
"sync": "svelte-kit sync",
"test": "npm run test:playwright && npm run test:vitest -- run",
"test:playwright": "npx playwright test tests/navigation.spec.js",
"test:vitest": "vitest",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"type": "module",
"private": true,
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@playwright/test": "^1.35.1",
"@rollup/plugin-yaml": "^4.1.1",
"@sveltejs/adapter-vercel": "^3.0.1",
"@sveltejs/kit": "^1.21.0",
"mdsvex": "^0.11.0",
"node-fetch": "^3.3.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sharp": "=0.32.1",
"svelte": "^4.0.1",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vite-plugin-windicss": "^1.9.0",
"vitest": "^0.32.2",
"wget-improved": "^3.4.0",
"yaml": "^2.3.1"
},
"dependencies": {
"@etalab/decoupage-administratif": "^3.0.0",
"fuzzysort": "^2.0.4",
"playwright-aws-lambda": "^0.10.0",
"playwright-core": "^1.35.1",
"publicodes": "^1.0.0-beta.70"
}
"name": "mesaidesvelo",
"version": "1.0.0",
"scripts": {
"postinstall": "node ./src/scripts/postinstall.js",
"dev": "VITE_SITE=mesaidesvelo.fr vite dev",
"dev:retrofit": "VITE_SITE=aideretrofit.fr vite dev",
"build": "VITE_SITE=mesaidesvelo.fr vite build",
"build:retrofit": "VITE_SITE=aideretrofit.fr vite build",
"preview": "VITE_SITE=mesaidesvelo.fr vite preview",
"sync-entreprises": "node ./data-fetch/entreprises/download-gsheet-data.js",
"sync": "svelte-kit sync",
"test": "npm run test:playwright && npm run test:vitest -- run",
"test:playwright": "npx playwright test tests/navigation.spec.js",
"test:vitest": "vitest",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
},
"type": "module",
"private": true,
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@playwright/test": "^1.35.1",
"@rollup/plugin-yaml": "^4.1.1",
"@sveltejs/adapter-vercel": "^3.0.1",
"@sveltejs/kit": "^1.21.0",
"mdsvex": "^0.11.0",
"node-fetch": "^3.3.1",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sharp": "=0.32.1",
"svelte": "^4.0.1",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vite-plugin-windicss": "^1.9.0",
"vitest": "^0.32.2",
"wget-improved": "^3.4.0",
"yaml": "^2.3.1"
},
"dependencies": {
"@etalab/decoupage-administratif": "^3.0.0",
"fuzzysort": "^2.0.4",
"jsdom": "^22.1.0",
"playwright-aws-lambda": "^0.10.0",
"playwright-core": "^1.35.1",
"publicodes": "^1.0.0-beta.70"
}
}
24 changes: 24 additions & 0 deletions src/lib/data/classement-villeplus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
"Eurométropole de Strasbourg",
"Bordeaux Métropole",
"Grenoble-Alpes-Métropole",
"Toulouse Métropole",
"Montpellier Méditerranée Métropole",
"Métropole Toulon-Provence-Méditerranée",
"Orléans Métropole",
"CC du Bassin de Marennes",
"Métropole du Grand Paris",
"CC de la Plaine Dijonnaise",
"Métropole de Lyon",
"Tours Métropole Val de Loire",
"Nantes Métropole",
"Brest Métropole",
"Métropole du Grand Nancy",
"Métropole Européenne de Lille",
"Clermont Auvergne Métropole",
"Metz Métropole",
"Métropole Rouen Normandie",
"Métropole Nice Côte d'Azur",
"Métropole d'Aix-Marseille-Provence",
"Saint-Etienne Métropole"
]

0 comments on commit 243edfa

Please sign in to comment.