mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-09 04:05:01 +00:00
33199b79e0
Ajout d'un Switch oui/non * Fix lint * Add react-router and fix type * Fix lint * Resolution du conflit de version de prettier avec storybook * Fix storybook * Reduce Storybook bundle size Refacto css in QuickLinks Remove useless comment Add default theme to CSS prop * Déploiement de Storybook * Fix déploiement * Fix déploiement storybook url * Fix Switch style * Remplace les oui/non radio bouton par un Switch * Filter aria props + react props in Storybook controls Sort props in Storybook Add global style in Storybook decorator * Update Storybook packages * Ajout d'un debounce dans OuiNonInput * Fix du Switch * Refacto des alias * Fix lint error avec Storybook * Fix eslint error * Refacto deploy for Storybook * ✨Ajout de type pour les yaml d'economie collaborative ✨Ajout de type sur les fonction du locale storage + Autre fix de type * Deploy storybook in dist dir in prod * Fix focus on Switch * Fix cy test * ✨ Remplace l'alias ~ par @ * ✨ Refacto du Switch * Remplace la checkbox par un Switch dans ChiffreAffairesActivitéMixte * Ajout des stories RadioGroup et ToggleGroup * Remplace le Switch oui/non par un ToggleGroup * Ajout d'un label dans le Switch Ajout du mode light sur le Switch * Fix autofocus * Fix cypress test * 🐛 Ajout du polyfill replaceAll * Test de deploiement * Ajout d'une redirection pour Storybook * Fix Storybook url * Fix du deploiement de Storybook
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
/* eslint-env node */
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import yaml from 'js-yaml'
|
|
|
|
const publicodesDir = './règles'
|
|
const outDir = './dist'
|
|
|
|
if (!fs.existsSync(outDir)) {
|
|
fs.mkdirSync(outDir)
|
|
}
|
|
|
|
function recursiveFindYamlFile(dirPath = publicodesDir) {
|
|
return fs
|
|
.readdirSync(dirPath)
|
|
.flatMap((filename) => {
|
|
const fullpath = path.join(dirPath, filename)
|
|
if (fs.statSync(fullpath).isDirectory()) {
|
|
return recursiveFindYamlFile(fullpath)
|
|
} else {
|
|
return filename.endsWith('.yaml') ? fullpath : false
|
|
}
|
|
})
|
|
.filter(Boolean)
|
|
}
|
|
|
|
function readRules() {
|
|
return recursiveFindYamlFile().reduce((rules, filePath) => {
|
|
const newRules = yaml.load(fs.readFileSync(filePath, 'utf-8'), {
|
|
filename: filePath,
|
|
})
|
|
const duplicatedRule = Object.keys(newRules).find(
|
|
(ruleName) => ruleName in rules
|
|
)
|
|
if (duplicatedRule) {
|
|
throw new Error(
|
|
`La règle ${duplicatedRule} a été redéfinie dans dans le fichier ${filePath}, alors qu'elle avait déjà été définie auparavant dans un autre fichier`
|
|
)
|
|
}
|
|
return Object.assign(rules, newRules)
|
|
}, {})
|
|
}
|
|
|
|
export default function writeJSFile() {
|
|
const rules = readRules()
|
|
const names = Object.keys(rules)
|
|
const jsString = `export default ${JSON.stringify(rules, null, 2)}`
|
|
fs.writeFileSync(path.resolve(outDir, 'index.js'), jsString)
|
|
fs.writeFileSync(
|
|
path.resolve(outDir, 'names.ts'),
|
|
`\nexport type Names = ${names.map((name) => `"${name}"`).join('\n | ')}\n`
|
|
)
|
|
}
|
|
|
|
writeJSFile()
|