diff --git a/scripts/check-links-validity.js b/scripts/check-links-validity.js index 8edc00914..0382abf99 100644 --- a/scripts/check-links-validity.js +++ b/scripts/check-links-validity.js @@ -1,9 +1,10 @@ /* eslint-disable no-console */ -import 'isomorphic-fetch' - import { exec } from 'child_process' +import dotenv from 'dotenv' import { promisify } from 'util' +dotenv.config() + // Extrait la liste des liens référencés dans la base de code const { stdout, stderr } = await promisify(exec)( "rg -oNI -e 'https?://([\\w/_\\-?=%+@]|\\.\\w)+' -g '*.{yaml,ts,tsx,js,jsx}' -g '!*-en.yaml' ./ | sort | uniq" diff --git a/server/source/server.ts b/server/source/server.ts index dc5730c79..78321324f 100644 --- a/server/source/server.ts +++ b/server/source/server.ts @@ -1,8 +1,6 @@ import cors from '@koa/cors' import Router from '@koa/router' - -import 'dotenv/config' - +import dotenv from 'dotenv' import Koa from 'koa' import koaBody from 'koa-body' @@ -19,6 +17,8 @@ import { initMongodb } from './mongodb.js' import { getAccessToken } from './oauth.js' import { snakeToCamelCaseKeys, validateCrispBody } from './utils.js' +dotenv.config() + const mongo = await initMongodb() type KoaState = Koa.DefaultState diff --git a/site/scripts/fetch-api-stats.js b/site/scripts/fetch-api-stats.js index a982b0aac..8d8717c29 100644 --- a/site/scripts/fetch-api-stats.js +++ b/site/scripts/fetch-api-stats.js @@ -1,5 +1,6 @@ -import 'dotenv/config.js' -import 'isomorphic-fetch' +import dotenv from 'dotenv' + +dotenv.config() const fetchApiStats = async (page, start, end, interval) => { if (!process.env.PLAUSIBLE_API_KEY) { diff --git a/site/scripts/fetch-job-offers.js b/site/scripts/fetch-job-offers.js index 289eea635..e8a33936c 100644 --- a/site/scripts/fetch-job-offers.js +++ b/site/scripts/fetch-job-offers.js @@ -1,13 +1,14 @@ // We publish our job offers on https://beta.gouv.fr/recrutement/. To augment // their reach, we also publish a banner on our website automatically by using // the beta.gouv.fr API. -import 'isomorphic-fetch' - +import dotenv from 'dotenv' import { promisify } from 'util' import { parseString } from 'xml2js' import { createDataDir, writeInDataDir } from './utils.js' +dotenv.config() + const parseXML = promisify(parseString) main() diff --git a/site/scripts/fetch-releases.js b/site/scripts/fetch-releases.js index c0fb3058a..668768b4a 100644 --- a/site/scripts/fetch-releases.js +++ b/site/scripts/fetch-releases.js @@ -7,11 +7,12 @@ // // If you want to fetch unpublished "draft" release, you should check the // "public repo" authorization when generating the access token. -import 'dotenv/config.js' -import 'isomorphic-fetch' +import dotenv from 'dotenv' import { createDataDir, writeInDataDir } from './utils.js' +dotenv.config() + // We use the GitHub API V4 in GraphQL to download the releases. A GraphQL // explorer can be found here : https://developer.github.com/v4/explorer/ const githubAuthToken = process.env.GITHUB_API_SECRET diff --git a/site/scripts/fetch-stats.js b/site/scripts/fetch-stats.js index 0cc45f32e..86acffba3 100644 --- a/site/scripts/fetch-stats.js +++ b/site/scripts/fetch-stats.js @@ -1,6 +1,4 @@ -import 'dotenv/config.js' -import 'isomorphic-fetch' - +import dotenv from 'dotenv' import fs from 'fs' import path from 'path' import { fileURLToPath } from 'url' @@ -8,6 +6,8 @@ import { fileURLToPath } from 'url' import { apiStats } from './fetch-api-stats.js' import { createDataDir, writeInDataDir } from './utils.js' +dotenv.config() + const matomoSiteVisitsHistory = JSON.parse( fs.readFileSync( path.join(fileURLToPath(import.meta.url), '..', 'matomoVisitHistory.json') diff --git a/site/scripts/fetch-versement-mobilité.js b/site/scripts/fetch-versement-mobilité.js index 0bc6e28a5..168b9c165 100644 --- a/site/scripts/fetch-versement-mobilité.js +++ b/site/scripts/fetch-versement-mobilité.js @@ -1,5 +1,3 @@ -import 'isomorphic-fetch' - import { writeInDataDir } from './utils.js' const CURRENT_YEAR = 2022 diff --git a/site/scripts/i18n/utils.js b/site/scripts/i18n/utils.js index e7c342d73..78ed2701f 100644 --- a/site/scripts/i18n/utils.js +++ b/site/scripts/i18n/utils.js @@ -1,11 +1,11 @@ -import 'dotenv/config.js' -import 'isomorphic-fetch' - +import dotenv from 'dotenv' import { readFileSync } from 'fs' import yaml from 'yaml' import rules from '../../../modele-social/dist/index.js' +dotenv.config() + const localesPath = new URL('../../source/locales/', import.meta.url).pathname export let UiStaticAnalysisPath = localesPath + 'static-analysis-fr.json' export let rulesTranslationPath = localesPath + 'rules-en.yaml' diff --git a/site/scripts/search/clean.js b/site/scripts/search/clean.js index 7399c18ef..2eda92cb5 100644 --- a/site/scripts/search/clean.js +++ b/site/scripts/search/clean.js @@ -1,6 +1,7 @@ -import 'dotenv/config.js' - import algoliasearch from 'algoliasearch' +import dotenv from 'dotenv' + +dotenv.config() const { ALGOLIA_APP_ID, diff --git a/site/scripts/search/update-data.ts b/site/scripts/search/update-data.ts index 3f46a2f7c..de76a56e5 100644 --- a/site/scripts/search/update-data.ts +++ b/site/scripts/search/update-data.ts @@ -1,7 +1,5 @@ import algoliasearch from 'algoliasearch' - -import 'dotenv/config.js' - +import dotenv from 'dotenv' import rawRules from 'modele-social' import Engine, { ParsedRules } from 'publicodes' @@ -9,6 +7,8 @@ import getSimulationData, { MetadataSrc, } from '../../source/pages/Simulateurs/metadata-src.js' +dotenv.config() + const parsedRules = new Engine(rawRules).getParsedRules() // @ts-ignore Needed by ts-node/esm