diff --git a/scripts/check-links-validity.js b/scripts/check-links-validity.js
index 0382abf99..4ef51f0f5 100644
--- a/scripts/check-links-validity.js
+++ b/scripts/check-links-validity.js
@@ -71,14 +71,13 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
-;(async () => {
- await Promise.allSettled(
- Array.from({ length: simultaneousItems }).map(processNextQueueItem)
- )
- if (detectedErrors.length > 0) {
- // Formattage spécifique pour récupérer le résultat avec l'action Github
- if (process.argv.slice(2).includes('--ci')) {
- const message = `
+await Promise.allSettled(
+ Array.from({ length: simultaneousItems }).map(processNextQueueItem)
+)
+if (detectedErrors.length > 0) {
+ // Formattage spécifique pour récupérer le résultat avec l'action Github
+ if (process.argv.slice(2).includes('--ci')) {
+ const message = `
Certains liens référencés ne semblent plus fonctionner :
@@ -88,22 +87,21 @@ function sleep(ms) {
.map(({ status, link }) => `| ${status} | ${link} |`)
.join('\n')}`
- const format = (msg) =>
- msg
- .trim()
- .split('\n')
- .map((line) => line.trim())
- .join('
')
- console.log(`::set-output name=comment::${format(message)}`)
- } else if (detectedErrors) {
- console.log(
- 'Liens invalides :' +
- detectedErrors
- .map(({ status, link }) => `\n- [${status}] ${link}`)
- .join('')
- )
- }
-
- console.log('Terminé')
+ const format = (msg) =>
+ msg
+ .trim()
+ .split('\n')
+ .map((line) => line.trim())
+ .join('
')
+ console.log(`::set-output name=comment::${format(message)}`)
+ } else if (detectedErrors) {
+ console.log(
+ 'Liens invalides :' +
+ detectedErrors
+ .map(({ status, link }) => `\n- [${status}] ${link}`)
+ .join('')
+ )
}
-})()
+
+ console.log('Terminé')
+}
diff --git a/site/scripts/fetch-job-offers.js b/site/scripts/fetch-job-offers.js
index e8a33936c..b0c77d607 100644
--- a/site/scripts/fetch-job-offers.js
+++ b/site/scripts/fetch-job-offers.js
@@ -11,13 +11,9 @@ dotenv.config()
const parseXML = promisify(parseString)
-main()
-
-async function main() {
- createDataDir()
- const jobOffers = await fetchJobOffers()
- writeInDataDir('job-offers.json', jobOffers)
-}
+createDataDir()
+const jobOffers = await fetchJobOffers()
+writeInDataDir('job-offers.json', jobOffers)
async function fetchJobOffers() {
let jobOffers = []
diff --git a/site/scripts/fetch-releases.js b/site/scripts/fetch-releases.js
index 668768b4a..7c8c46f2f 100644
--- a/site/scripts/fetch-releases.js
+++ b/site/scripts/fetch-releases.js
@@ -55,16 +55,14 @@ const fakeData = [
},
]
-async function main() {
- createDataDir()
- const releases = await fetchReleases()
- // The last release name is fetched on all pages (to display the banner)
- // whereas the full release data is used only in the dedicated page, that why
- // we deduplicate the releases data in two separated files that can be
- // bundled/fetched separately.
- writeInDataDir('releases.json', releases)
- writeInDataDir('last-release.json', { name: releases[0].name })
-}
+createDataDir()
+const releases = await fetchReleases()
+// The last release name is fetched on all pages (to display the banner)
+// whereas the full release data is used only in the dedicated page, that why
+// we deduplicate the releases data in two separated files that can be
+// bundled/fetched separately.
+writeInDataDir('releases.json', releases)
+writeInDataDir('last-release.json', { name: releases[0].name })
async function fetchReleases(after = 'null') {
if (!githubAuthToken) {
@@ -100,5 +98,3 @@ async function fetchReleases(after = 'null') {
return fakeData
}
}
-
-main()
diff --git a/site/scripts/fetch-stats.js b/site/scripts/fetch-stats.js
index 86acffba3..c46ddefcd 100644
--- a/site/scripts/fetch-stats.js
+++ b/site/scripts/fetch-stats.js
@@ -543,62 +543,59 @@ async function fetchAllUserFeedbackIssues() {
}
}
-async function main() {
- createDataDir()
- // In case we cannot fetch the release (the API is down or the Authorization
- // token isn't valid) we fallback to some fake data -- it would be better to
- // have a static ressource accessible without authentification.
- writeInDataDir('stats.json', {
- retoursUtilisateurs: {
- open: [],
- closed: [],
- },
- nbAnswersLast30days: 0,
- })
+createDataDir()
+// In case we cannot fetch the release (the API is down or the Authorization
+// token isn't valid) we fallback to some fake data -- it would be better to
+// have a static ressource accessible without authentification.
+writeInDataDir('stats.json', {
+ retoursUtilisateurs: {
+ open: [],
+ closed: [],
+ },
+ nbAnswersLast30days: 0,
+})
- try {
- if (
- !process.env.ATINTERNET_API_ACCESS_KEY ||
- !process.env.ATINTERNET_API_SECRET_KEY ||
- !process.env.ZAMMAD_API_SECRET_KEY
- ) {
- console.log(
- "Variables d'environnement manquantes : nous ne récupérons pas les statistiques d'usage"
- )
- return
- }
- const [
- visitesJours,
- visitesMois,
- rawSatisfaction,
- retoursUtilisateurs,
- nbAnswersLast30days,
- ] = await Promise.all([
- fetchDailyVisits(),
- fetchMonthlyVisits(),
- fetchApi(buildSatisfactionQuery()),
- fetchAllUserFeedbackIssues(),
- fetchAllUserAnswerStats(),
- ])
- const satisfaction = uniformiseData(flattenPage(await rawSatisfaction)).map(
- (page) => {
- // eslint-disable-next-line no-unused-vars
- const { date, ...satisfactionPage } = {
- month: new Date(new Date(page.date).setDate(1)),
- ...page,
- }
- return satisfactionPage
- }
+try {
+ if (
+ !process.env.ATINTERNET_API_ACCESS_KEY ||
+ !process.env.ATINTERNET_API_SECRET_KEY ||
+ !process.env.ZAMMAD_API_SECRET_KEY
+ ) {
+ console.log(
+ "Variables d'environnement manquantes : nous ne récupérons pas les statistiques d'usage"
)
- writeInDataDir('stats.json', {
- visitesJours,
- visitesMois,
- satisfaction,
- retoursUtilisateurs,
- nbAnswersLast30days,
- })
- } catch (e) {
- console.error(e)
+ process.exit(1)
}
+ const [
+ visitesJours,
+ visitesMois,
+ rawSatisfaction,
+ retoursUtilisateurs,
+ nbAnswersLast30days,
+ ] = await Promise.all([
+ fetchDailyVisits(),
+ fetchMonthlyVisits(),
+ fetchApi(buildSatisfactionQuery()),
+ fetchAllUserFeedbackIssues(),
+ fetchAllUserAnswerStats(),
+ ])
+ const satisfaction = uniformiseData(flattenPage(await rawSatisfaction)).map(
+ (page) => {
+ // eslint-disable-next-line no-unused-vars
+ const { date, ...satisfactionPage } = {
+ month: new Date(new Date(page.date).setDate(1)),
+ ...page,
+ }
+ return satisfactionPage
+ }
+ )
+ writeInDataDir('stats.json', {
+ visitesJours,
+ visitesMois,
+ satisfaction,
+ retoursUtilisateurs,
+ nbAnswersLast30days,
+ })
+} catch (e) {
+ console.error(e)
}
-main()
diff --git a/site/scripts/fetch-versement-mobilité.js b/site/scripts/fetch-versement-mobilité.js
index 168b9c165..71a8eb9ce 100644
--- a/site/scripts/fetch-versement-mobilité.js
+++ b/site/scripts/fetch-versement-mobilité.js
@@ -10,37 +10,33 @@ const INDEX = {
DATE_EFFET: 4,
}
-;(async function main() {
- const response = await fetch(CSV_URL)
- const rawCSV = await response.text()
- const data = rawCSV
- .split('\n')
- .slice(1, -1)
- .map((row) => row.split(';'))
- .filter((r) => r[INDEX.TAUX] !== '0')
- .filter(
- (r) => !r[INDEX.DATE_EFFET].startsWith((CURRENT_YEAR + 1).toString())
- )
- .map((r) => {
- r[INDEX.CODE_COMMUNE] = r[INDEX.CODE_COMMUNE].slice(1, -1) // Remove single quote ''
- return r
- })
- .sort((a, b) =>
- +a[INDEX.CODE_COMMUNE] < +b[INDEX.CODE_COMMUNE]
- ? -1
- : +a[INDEX.CODE_COMMUNE] > +b[INDEX.CODE_COMMUNE]
- ? 1
- : a[INDEX.DATE_EFFET] > b[INDEX.DATE_EFFET]
- ? -1
- : 1
- )
- .reduce(
- (acc, r) => ({
- [r[INDEX.CODE_COMMUNE]]: +r[INDEX.TAUX],
- ...acc,
- }),
- {}
- )
+const response = await fetch(CSV_URL)
+const rawCSV = await response.text()
+const data = rawCSV
+ .split('\n')
+ .slice(1, -1)
+ .map((row) => row.split(';'))
+ .filter((r) => r[INDEX.TAUX] !== '0')
+ .filter((r) => !r[INDEX.DATE_EFFET].startsWith((CURRENT_YEAR + 1).toString()))
+ .map((r) => {
+ r[INDEX.CODE_COMMUNE] = r[INDEX.CODE_COMMUNE].slice(1, -1) // Remove single quote ''
+ return r
+ })
+ .sort((a, b) =>
+ +a[INDEX.CODE_COMMUNE] < +b[INDEX.CODE_COMMUNE]
+ ? -1
+ : +a[INDEX.CODE_COMMUNE] > +b[INDEX.CODE_COMMUNE]
+ ? 1
+ : a[INDEX.DATE_EFFET] > b[INDEX.DATE_EFFET]
+ ? -1
+ : 1
+ )
+ .reduce(
+ (acc, r) => ({
+ [r[INDEX.CODE_COMMUNE]]: +r[INDEX.TAUX],
+ ...acc,
+ }),
+ {}
+ )
- writeInDataDir('versement-mobilité.json', data)
-})()
+writeInDataDir('versement-mobilité.json', data)
diff --git a/site/scripts/i18n/translate-rules.js b/site/scripts/i18n/translate-rules.js
index aa5e575ff..d4dbd5eba 100644
--- a/site/scripts/i18n/translate-rules.js
+++ b/site/scripts/i18n/translate-rules.js
@@ -14,27 +14,26 @@ writeFileSync(
rulesTranslationPath,
yaml.stringify(resolved, { sortMapEntries: true })
)
-;(async function main() {
- await Promise.all(
- missingTranslations.map(async ([dottedName, attr, value]) => {
- try {
- const translation = await fetchTranslation(value)
- resolved[dottedName][attr] = '[automatic] ' + translation
- } catch (e) {
- console.error(e)
- console.log(value)
- }
- })
- )
- prettier.resolveConfig(rulesTranslationPath).then((options) => {
- const formattedYaml = prettier.format(
- yaml.stringify(resolved, { sortMapEntries: true }),
- {
- ...options,
- parser: 'yaml',
- }
- )
- writeFileSync(rulesTranslationPath, formattedYaml)
+await Promise.all(
+ missingTranslations.map(async ([dottedName, attr, value]) => {
+ try {
+ const translation = await fetchTranslation(value)
+ resolved[dottedName][attr] = '[automatic] ' + translation
+ } catch (e) {
+ console.error(e)
+ console.log(value)
+ }
})
-})()
+)
+
+prettier.resolveConfig(rulesTranslationPath).then((options) => {
+ const formattedYaml = prettier.format(
+ yaml.stringify(resolved, { sortMapEntries: true }),
+ {
+ ...options,
+ parser: 'yaml',
+ }
+ )
+ writeFileSync(rulesTranslationPath, formattedYaml)
+})
diff --git a/site/scripts/i18n/translate-ui.js b/site/scripts/i18n/translate-ui.js
index 208ebd2de..911ad43bf 100644
--- a/site/scripts/i18n/translate-ui.js
+++ b/site/scripts/i18n/translate-ui.js
@@ -8,36 +8,32 @@ import {
getUiMissingTranslations,
} from './utils.js'
-;(async function () {
- const missingTranslations = getUiMissingTranslations()
- let originalKeys = yaml.parse(
- readFileSync(UiOriginalTranslationPath, 'utf-8')
- )
- let translatedKeys = yaml.parse(readFileSync(UiTranslationPath, 'utf-8'))
- await Promise.all(
- Object.entries(missingTranslations)
- .map(([key, value]) => [key, value === 'NO_TRANSLATION' ? key : value])
- .map(async ([key, originalTranslation]) => {
- try {
- const translation = await fetchTranslation(originalTranslation)
- const path = key.split(/(?<=[A-zÀ-ü0-9])\.(?=[A-zÀ-ü0-9])/)
- translatedKeys = assocPath(path, translation, translatedKeys)
- originalKeys = assocPath(path, originalTranslation, originalKeys)
- } catch (e) {
- console.error(e)
- console.log(originalTranslation)
- }
- })
- )
- writeFileSync(
- UiTranslationPath,
- yaml.stringify(translatedKeys, { sortMapEntries: true })
- )
- writeFileSync(
- UiOriginalTranslationPath,
- yaml.stringify(originalKeys, { sortMapEntries: true })
- )
-})()
+const missingTranslations = getUiMissingTranslations()
+let originalKeys = yaml.parse(readFileSync(UiOriginalTranslationPath, 'utf-8'))
+let translatedKeys = yaml.parse(readFileSync(UiTranslationPath, 'utf-8'))
+await Promise.all(
+ Object.entries(missingTranslations)
+ .map(([key, value]) => [key, value === 'NO_TRANSLATION' ? key : value])
+ .map(async ([key, originalTranslation]) => {
+ try {
+ const translation = await fetchTranslation(originalTranslation)
+ const path = key.split(/(?<=[A-zÀ-ü0-9])\.(?=[A-zÀ-ü0-9])/)
+ translatedKeys = assocPath(path, translation, translatedKeys)
+ originalKeys = assocPath(path, originalTranslation, originalKeys)
+ } catch (e) {
+ console.error(e)
+ console.log(originalTranslation)
+ }
+ })
+)
+writeFileSync(
+ UiTranslationPath,
+ yaml.stringify(translatedKeys, { sortMapEntries: true })
+)
+writeFileSync(
+ UiOriginalTranslationPath,
+ yaml.stringify(originalKeys, { sortMapEntries: true })
+)
function assocPath(path, val, obj) {
if (path.length === 0) return val