Nettoyage du fichier .env.template + Ajout du devtool redux uniquement en mode dev (#2001)

*  Déplace les scripts de traduction dans site

*  Nettoyage du fichier .env.template

*  Ajout du devtool redux uniquement en mode dev

*  Ajout d'une erreur si l'api github ne retourne pas un status 200

*  Fix types

*  Temporary fix package import error

* ⬆️ Update @redux-devtools/extension
pull/2004/head
Jérémy Rialland 2022-02-09 10:26:56 +01:00 committed by GitHub
parent d5649f8a2a
commit 88d0627c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 27 deletions

View File

@ -162,6 +162,7 @@ yarn run i18n:check
Pour traduire automatiquement les chaînes manquantes via l'api Deepl :
```sh
cd site
yarn run i18n:rules:translate
yarn run i18n:ui:translate

View File

@ -26,7 +26,9 @@
"test:type": "yarn workspaces run tsc --skipLibCheck --noEmit",
"clean": "yarn workspaces run clean && rimraf node_modules",
"start": "yarn workspace site start",
"moso:up": "yarn workspace modele-social run up && yarn workspace site upgrade modele-social"
"moso:up": "yarn workspace modele-social run up && yarn workspace site upgrade modele-social",
"i18n:check": "yarn workspace site i18n:check",
"i18n:translate": "yarn workspace site i18n:translate"
},
"resolutions": {
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"

View File

@ -1,21 +1,25 @@
### Variables utilisées par les scripts ###
# Voir https://github.com/betagouv/compta-mon-entreprise/issues/3
DEEPL_API_SECRET=
INSEE_SIRENE_API_SECRET=
MATOMO_TOKEN=
ALGOLIA_ADMIN_KEY=
ATINTERNET_API_ACCESS_KEY=
ATINTERNET_API_SECRET_KEY=
DEEPL_API_SECRET=
ZAMMAD_API_SECRET_KEY=
ALGOLIA_APP_ID=
ALGOLIA_ADMIN_KEY=
ALGOLIA_SEARCH_KEY=
ALGOLIA_INDEX_PREFIX=monentreprise-{env}-
# Utiliser votre propre token
# Utilisez votre propre token (voir issue en haut pour en créé un)
GITHUB_API_SECRET=
# Valeurs optionnelles
COMPANY_SEARCH_HOST=https://search-recherche-entreprises.fabrique.social.gouv.fr
### Variables utilisées par l'app ###
VITE_ALGOLIA_APP_ID=
VITE_ALGOLIA_SEARCH_KEY=
VITE_ALGOLIA_INDEX_PREFIX=monentreprise-{env}-
VITE_AT_INTERNET_SITE_ID=
# Valeurs pour l'app
VITE_FR_BASE_URL="http://localhost:3000/mon-entreprise"
VITE_EN_BASE_URL="http://localhost:3000/infrance"
VITE_EN_BASE_URL="http://localhost:3000/infrance"
# Variables optionnelles
VITE_COMPANY_SEARCH_HOST=https://search-recherche-entreprises.fabrique.social.gouv.fr
# https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/Features/Trace.md
VITE_REDUX_TRACE=true

View File

@ -34,11 +34,11 @@
"test:record-http-calls:mon-entreprise": "cypress run --env record_http=",
"algolia:update": "node scripts/search/update-data.js",
"algolia:clean": "node scripts/search/clean.js",
"i18n:check": "yarn run i18n:rules:check && yarn run i18n:ui:check",
"i18n:translate": "yarn run i18n:rules:translate && yarn run i18n:ui:translate",
"i18n:check": "yarn i18n:rules:check && yarn i18n:ui:check",
"i18n:translate": "yarn i18n:rules:translate && yarn i18n:ui:translate",
"i18n:rules:check": "node scripts/i18n/check-missing-rule-translation.js",
"i18n:rules:translate": "node scripts/i18n/translate-rules.js",
"i18n:ui:check": "i18next -c scripts/i18n/parser.config.cjs && node scripts/i18n/check-missing-UI-translation",
"i18n:ui:check": "i18next -c scripts/i18n/parser.config.cjs && node scripts/i18n/check-missing-UI-translation.js",
"i18n:ui:translate": "rm -rf source/locales/static-analysis-fr.json && i18next -c scripts/i18n/parser.config.cjs && node scripts/i18n/translate-ui.js"
},
"resolutions": {
@ -99,6 +99,7 @@
"devDependencies": {
"@react-types/numberfield": "^3.1.0",
"@react-types/searchfield": "^3.1.2",
"@redux-devtools/extension": "^3.2.2",
"@rollup/plugin-yaml": "^3.1.0",
"@types/iframe-resizer": "^3.5.7",
"@types/ramda": "^0.26.43",

View File

@ -251,6 +251,14 @@ async function fetchUserFeedbackIssues() {
query,
}),
})
if (response.status != 200) {
console.error(
`❌ Github response status: ${response.status}\n` +
'\tCheck your GITHUB_API_SECRET key in site/.env\n'
)
}
const data = await response.json()
const issues = Object.entries(data.data.repository)
.filter(([, value]) => !!value)

View File

@ -14,15 +14,15 @@ import { createBrowserHistory } from 'history'
import i18next from 'i18next'
import logo from 'Images/logo-monentreprise.svg'
import { useIframeResizer } from 'Hooks/useIframeResizer'
import React, { createContext, useMemo } from 'react'
import { createContext, ReactNode, useMemo } from 'react'
import { HelmetProvider } from 'react-helmet-async'
import { I18nextProvider } from 'react-i18next'
import { Provider as ReduxProvider } from 'react-redux'
import { Router } from 'react-router-dom'
import reducers, { RootState } from 'Reducers/rootReducer'
import { composeWithDevToolsDevelopmentOnly } from '@redux-devtools/extension'
import {
applyMiddleware,
compose,
createStore,
Middleware,
PreloadedState,
@ -59,9 +59,13 @@ type SiteName = 'mon-entreprise' | 'infrance' | 'publicodes'
export const SiteNameContext = createContext<SiteName | null>(null)
const composeEnhancers = composeWithDevToolsDevelopmentOnly(
import.meta.env.VITE_REDUX_TRACE ? { trace: true, traceLimit: 25 } : {}
)
export type ProviderProps = {
basename: SiteName
children: React.ReactNode
children: ReactNode
sitePaths?: SitePaths
initialStore?: PreloadedState<RootState>
onStoreCreated?: (store: Store) => void
@ -75,8 +79,8 @@ export default function Provider({
onStoreCreated,
children,
sitePaths = {} as SitePaths,
}: ProviderProps) {
const storeEnhancer = compose(applyMiddleware(...reduxMiddlewares))
}: ProviderProps): JSX.Element {
const storeEnhancer = composeEnhancers(applyMiddleware(...reduxMiddlewares))
// Hack: useMemo is used to persist the store across hot reloads.
const store = useMemo(() => {
@ -147,7 +151,7 @@ function BrowserRouterProvider({
children,
basename,
}: {
children: React.ReactNode
children: ReactNode
basename: string
}) {
// The server rouer is only provided in the entry-server file

View File

@ -10,12 +10,12 @@ interface ImportMetaEnv {
VITE_GIT_HEAD: string
VITE_AT_INTERNET_SITE_ID: string
VITE_ATINTERNET_API_ACCESS_KEY: string
VITE_ATINTERNET_API_SECRET_KEY: string
VITE_ALGOLIA_INDEX_PREFIX: string
VITE_ALGOLIA_SEARCH_KEY: string
VITE_ALGOLIA_APP_ID: string
VITE_REDUX_TRACE: string
VITE_COMPANY_SEARCH_HOST?: string
VITE_REDUX_TRACE?: string
}

View File

@ -83,7 +83,7 @@ function multipleSPA(options: MultipleSPAOptions): Plugin {
const template = await fs.readFile(options.templatePath, 'utf-8')
const filledTemplate = template
.toString()
.replace(/\{\{(.+)\}\}/g, (_match, p1) => siteData[p1.trim()])
.replace(/\{\{(.+)\}\}/g, (_match, p1) => siteData[(p1 as string).trim()])
return filledTemplate
}
return {
@ -159,7 +159,7 @@ function multipleSPA(options: MultipleSPAOptions): Plugin {
function monEntrepriseDevServer(): Plugin {
return {
name: 'mon-entreprise',
configureServer(vite) {
configureServer() {
// We could use native ViteJS watch API, but it would require changing
// more code and maybe the whole "modele-social" package build process.
watchDottedNames()

View File

@ -319,6 +319,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.17.0":
version "7.17.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941"
integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/standalone@^7.16.4":
version "7.16.12"
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.16.12.tgz#bfa53fe78d223a781ca4fd8e14139743b2e0a038"
@ -1476,6 +1483,13 @@
dependencies:
"@react-types/shared" "^3.9.0"
"@redux-devtools/extension@^3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@redux-devtools/extension/-/extension-3.2.2.tgz#2d6da4df2c4d32a0aac54d824e46f52b1fd9fc4d"
integrity sha512-fKA2TWNzJF7wXSDwBemwcagBFudaejXCzH5hRszN3Z6B7XEJtEmGD77AjV0wliZpIZjA/fs3U7CejFMQ+ipS7A==
dependencies:
"@babel/runtime" "^7.17.0"
"@rollup/plugin-yaml@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-yaml/-/plugin-yaml-3.1.0.tgz#03a13039ba366fc8d39a1ab94a7debacdd776c2f"