Migrate to SvelteKit 2

This commit is contained in:
Emmanuel 2023-12-20 11:49:21 +01:00
parent 8f9b398abb
commit 902c9af2b0
32 changed files with 343 additions and 548 deletions

796
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,8 +24,9 @@
"exports": { "exports": {
"./package.json": "./package.json", "./package.json": "./package.json",
".": { ".": {
"types": "./dist/index.d.ts", "default": "./dist/index.js",
"default": "./dist/index.js" "svelte": "./dist/index.js",
"types": "./dist/index.d.ts"
} }
}, },
"files": [ "files": [
@ -33,7 +34,6 @@
"!dist/components", "!dist/components",
"!dist/server" "!dist/server"
], ],
"svelte": "./dist/index.js",
"typesVersions": { "typesVersions": {
">4.0": { ">4.0": {
"index": [ "index": [
@ -43,16 +43,17 @@
}, },
"dependencies": { "dependencies": {
"@auditors/core": "^0.7.0", "@auditors/core": "^0.7.0",
"@tricoteuses/explorer-tools": "^0.4.3", "@tricoteuses/explorer-tools": "^0.5.0",
"fast-xml-parser": "^4.2.2", "fast-xml-parser": "^4.3.2",
"he": "^1.2.0", "he": "^1.2.0",
"jsdom": "^23.0.1" "jsdom": "^23.0.1"
}, },
"devDependencies": { "devDependencies": {
"@iconify-icons/codicon": "^1.2.15", "@iconify-icons/codicon": "^1.2.15",
"@playwright/test": "^1.22.2", "@playwright/test": "^1.22.2",
"@sveltejs/adapter-node": "^1.2.3", "@sveltejs/adapter-node": "^2.0.0",
"@sveltejs/package": "^2.1.0", "@sveltejs/package": "^2.1.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@tailwindcss/typography": "^0.5.3", "@tailwindcss/typography": "^0.5.3",
"@tricoteuses/assemblee": "^1.5.2", "@tricoteuses/assemblee": "^1.5.2",
"@types/fs-extra": "^11.0.1", "@types/fs-extra": "^11.0.1",
@ -62,7 +63,7 @@
"@types/papaparse": "^5.3.7", "@types/papaparse": "^5.3.7",
"@typescript-eslint/eslint-plugin": "^6.1.0", "@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0", "@typescript-eslint/parser": "^6.1.0",
"augmented-data-viewer": "^0.3.0", "augmented-data-viewer": "^0.4.4",
"autoprefixer": "^10.4.7", "autoprefixer": "^10.4.7",
"daisyui": "^4.4.22", "daisyui": "^4.4.22",
"dotenv": "^16.0.1", "dotenv": "^16.0.1",
@ -75,7 +76,7 @@
"morgan": "^1.10.0", "morgan": "^1.10.0",
"papaparse": "^5.3.2", "papaparse": "^5.3.2",
"postcss": "^8.4.14", "postcss": "^8.4.14",
"postcss-load-config": "^4.0.1", "postcss-load-config": "^5.0.2",
"postgres": "^3.2.4", "postgres": "^3.2.4",
"prettier": "^3.0.0", "prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.3", "prettier-plugin-svelte": "^3.0.3",
@ -87,11 +88,11 @@
"tslib": "^2.3.1", "tslib": "^2.3.1",
"tsx": "^4.0.0", "tsx": "^4.0.0",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"vite": "^4.0.4", "vite": "^5.0.10",
"zx": "^7.1.1" "zx": "^7.1.1"
}, },
"peerDependencies": { "peerDependencies": {
"@sveltejs/kit": "^1.21.0", "@sveltejs/kit": "^2.0.4",
"svelte": "^4.1.2" "svelte": "^4.2.8"
} }
} }

View file

@ -69,7 +69,7 @@ export const GET: RequestHandler = async ({ params, url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow, latest } = query const { follow, latest } = query
@ -80,7 +80,7 @@ export const GET: RequestHandler = async ({ params, url }) => {
` `
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (article === undefined) { if (article === undefined) {
throw error(404, `ARTICLE ${id} non trouvé`) error(404, `ARTICLE ${id} non trouvé`)
} }
if (latest) { if (latest) {
const latestVersion = article.VERSIONS.VERSION.at(-1) const latestVersion = article.VERSIONS.VERSION.at(-1)

View file

@ -66,7 +66,7 @@ export const GET: RequestHandler = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow, q, latest } = query const { follow, q, latest } = query

View file

@ -76,7 +76,7 @@ export const GET: RequestHandler = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow, limit, nature, offset, q } = query const { follow, limit, nature, offset, q } = query

View file

@ -49,7 +49,7 @@ export const GET: RequestHandler = async ({ params, url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow } = query const { follow } = query
const texteVersion = ( const texteVersion = (
@ -59,7 +59,7 @@ export const GET: RequestHandler = async ({ params, url }) => {
` `
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (texteVersion === undefined) { if (texteVersion === undefined) {
throw error(404, `TEXTE_VERSION ${params.id} non trouvé`) error(404, `TEXTE_VERSION ${params.id} non trouvé`)
} }
const aggregator = new Aggregator(follow) const aggregator = new Aggregator(follow)

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (article === undefined) { if (article === undefined) {
throw error(404, `Article ${params.id} non trouvé`) error(404, `Article ${params.id} non trouvé`)
} }
return { article } return { article }
} }

View file

@ -46,7 +46,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow: requestedFollow } = query const { follow: requestedFollow } = query
@ -66,7 +66,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
console.error( console.error(
`Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`, `Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`,
) )
throw error(response.status, text) error(response.status, text)
} }
return (await response.json()) as GetArticleResult return (await response.json()) as GetArticleResult
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (dossierLegislatif === undefined) { if (dossierLegislatif === undefined) {
throw error(404, `Dossier législatif ${params.id} non trouvé`) error(404, `Dossier législatif ${params.id} non trouvé`)
} }
return { dossier_legislatif: dossierLegislatif } return { dossier_legislatif: dossierLegislatif }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
)[0] )[0]
if (idWrapper === undefined) { if (idWrapper === undefined) {
throw error(404, `ELI ${params.eli} non trouvé`) error(404, `ELI ${params.eli} non trouvé`)
} }
return { id: idWrapper } return { id: idWrapper }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (idcc === undefined) { if (idcc === undefined) {
throw error(404, `IDCC ${params.id} non trouvé`) error(404, `IDCC ${params.id} non trouvé`)
} }
return { idcc } return { idcc }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (jo === undefined) { if (jo === undefined) {
throw error(404, `JO ${params.id} non trouvé`) error(404, `JO ${params.id} non trouvé`)
} }
return { jo } return { jo }
} }

View file

@ -14,7 +14,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
console.error( console.error(
`Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`, `Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`,
) )
throw error(response.status, text) error(response.status, text)
} }
return (await response.json()) as GetRechercheResult return (await response.json()) as GetRechercheResult
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (sectionTa === undefined) { if (sectionTa === undefined) {
throw error(404, `SECTION_TA ${params.id} non trouvé`) error(404, `SECTION_TA ${params.id} non trouvé`)
} }
return { section_ta: sectionTa } return { section_ta: sectionTa }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (texteVersion === undefined) { if (texteVersion === undefined) {
throw error(404, `TEXTE_VERSION ${params.id} non trouvé`) error(404, `TEXTE_VERSION ${params.id} non trouvé`)
} }
return { texte_version: texteVersion } return { texte_version: texteVersion }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (textekali === undefined) { if (textekali === undefined) {
throw error(404, `TEXTEKALI ${params.id} non trouvé`) error(404, `TEXTEKALI ${params.id} non trouvé`)
} }
return { textekali } return { textekali }
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
).map(({ data }) => data)[0] ).map(({ data }) => data)[0]
if (textelr === undefined) { if (textelr === undefined) {
throw error(404, `TEXTELR ${params.id} non trouvé`) error(404, `TEXTELR ${params.id} non trouvé`)
} }
return { textelr: textelr } return { textelr: textelr }
} }

View file

@ -14,7 +14,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
console.error( console.error(
`Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`, `Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`,
) )
throw error(response.status, text) error(response.status, text)
} }
return (await response.json()) as ListTextesResult return (await response.json()) as ListTextesResult
} }

View file

@ -46,7 +46,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { follow: requestedFollow } = query const { follow: requestedFollow } = query
@ -73,7 +73,7 @@ export const load: PageLoad = async ({ fetch, url }) => {
console.error( console.error(
`Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`, `Error in ${url.pathname} while calling ${apiUrl}:\n${response.status} ${response.statusText}\n\n${text}`,
) )
throw error(response.status, text) error(response.status, text)
} }
return (await response.json()) as GetTexteResult return (await response.json()) as GetTexteResult
} }

View file

@ -44,7 +44,7 @@ export const load: PageServerLoad = async ({ url }) => {
2, 2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`, )}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
) )
throw error(400, JSON.stringify(queryError, null, 2)) error(400, JSON.stringify(queryError, null, 2))
} }
const { limit, offset } = query const { limit, offset } = query

View file

@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ params }) => {
)[0] )[0]
if (versionsWrapper === undefined) { if (versionsWrapper === undefined) {
throw error(404, `Versions ${params.eli} non trouvé`) error(404, `Versions ${params.eli} non trouvé`)
} }
return { versions: versionsWrapper } return { versions: versionsWrapper }
} }

View file

@ -1,5 +1,5 @@
import adapter from "@sveltejs/adapter-node" import adapter from "@sveltejs/adapter-node"
import { vitePreprocess } from "@sveltejs/kit/vite" import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
const config = { const config = {

View file

@ -8,11 +8,7 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"skipLibCheck": true, "skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true
"paths": {
"$lib": ["./src/lib"],
"$lib/*": ["./src/lib/*"]
}
} }
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// //