chore: change extension of publicodes files

pull/2877/head
Johan Girod 2024-01-25 17:56:36 +01:00
parent 71da738c73
commit c20a7cb80d
47 changed files with 9 additions and 5 deletions

View File

@ -2,9 +2,8 @@
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ban.spellright",
"styled-components.vscode-styled-components",
"tamasfe.even-better-toml",
"mikestead.dotenv"
"mikestead.dotenv",
"emilerolley.publicodes-language-server"
]
}

View File

@ -1,11 +1,11 @@
import { writeFileSync } from 'fs'
import { existsSync, mkdirSync, writeFileSync } from 'fs'
import path from 'path'
import { getModelFromSource } from '@publicodes/tools/compilation'
import Engine from 'publicodes'
const outDir = './dist'
const rules = getModelFromSource(path.resolve('./règles/**/*.yaml'), {
const rules = getModelFromSource(path.resolve('./règles'), {
verbose: true,
})
@ -13,6 +13,11 @@ export default function writeJSFile() {
const json = JSON.stringify(JSON.stringify(rules))
const names = Object.keys(new Engine(rules).getParsedRules())
const jsString = `export const json = /*@__PURE__*/ ${json};\nexport default /*@__PURE__*/ JSON.parse(json);`
// Create folder if doesn't exist
const folder = path.resolve(outDir)
if (!existsSync(folder)) {
mkdirSync(folder)
}
writeFileSync(path.resolve(outDir, 'index.js'), jsString)
writeFileSync(
path.resolve(outDir, 'names.ts'),