From 1584b7b20b3cacabb08abf87ea69375d07e23095 Mon Sep 17 00:00:00 2001 From: Guillaume Brioudes Date: Sat, 5 Oct 2024 11:22:09 +0200 Subject: [PATCH] chore: import i18n yml with webpack --- core/models/lang.js | 12 +-------- package-lock.json | 59 ++++++++++++++++++++++++++++++++++++++--- package.json | 3 ++- webpack-back.config.mjs | 7 ++++- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/core/models/lang.js b/core/models/lang.js index 2a707eac..43138faf 100644 --- a/core/models/lang.js +++ b/core/models/lang.js @@ -4,17 +4,7 @@ * @copyright GNU GPL 3.0 Cosma's authors */ -import fs from 'node:fs'; -import path from 'node:path'; -import Config from './config.js'; -import yml from 'yaml'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -// const config = new Config(); -const file = fs.readFileSync(path.join(__dirname, '../i18n.yml'), 'utf-8'); -const content = yml.parse(file); +import content from '../i18n.yml'; const i = content; diff --git a/package-lock.json b/package-lock.json index 4b1159e8..9fcbaa15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@graphlab-fr/cosma", - "version": "2.5.0", + "version": "2.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@graphlab-fr/cosma", - "version": "2.5.0", + "version": "2.5.1", "license": "GPL-3.0-or-later", "dependencies": { "@zettlr/citr": "^1.2.2", @@ -40,7 +40,8 @@ "mocha": "^10.4.0", "prettier": "3.2.5", "webpack": "^5.94.0", - "webpack-cli": "^5.1.4" + "webpack-cli": "^5.1.4", + "yaml-loader": "^0.8.1" } }, "node_modules/@ampproject/remapping": { @@ -3351,6 +3352,15 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -4599,6 +4609,15 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "node_modules/emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -5908,6 +5927,12 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/javascript-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-2.1.0.tgz", + "integrity": "sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==", + "dev": true + }, "node_modules/jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", @@ -6843,6 +6868,20 @@ "node": ">=6.11.5" } }, + "node_modules/loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, + "dependencies": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + }, + "engines": { + "node": ">=8.9.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -9098,6 +9137,20 @@ "node": ">= 14" } }, + "node_modules/yaml-loader": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/yaml-loader/-/yaml-loader-0.8.1.tgz", + "integrity": "sha512-BCEndnUoi3BaZmePkwGGe93txRxLgMhBa/gE725v1/GHnura8QvNs7c4+4C1yyhhKoj3Dg63M7IqhA++15j6ww==", + "dev": true, + "dependencies": { + "javascript-stringify": "^2.0.1", + "loader-utils": "^2.0.0", + "yaml": "^2.0.0" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index bea414f8..7880b4a2 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,8 @@ "mocha": "^10.4.0", "prettier": "3.2.5", "webpack": "^5.94.0", - "webpack-cli": "^5.1.4" + "webpack-cli": "^5.1.4", + "yaml-loader": "^0.8.1" }, "directories": { "doc": "docs", diff --git a/webpack-back.config.mjs b/webpack-back.config.mjs index 9a4862f8..59addd4e 100644 --- a/webpack-back.config.mjs +++ b/webpack-back.config.mjs @@ -12,7 +12,12 @@ export default { }, target: 'node', module: { - rules: [], + rules: [ + { + test: /\.ya?ml$/, + use: 'yaml-loader', + }, + ], }, plugins: [ new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),