diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 01f5919f..8363cf46 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: with: node-version: "lts/*" - name: 🚧 Install dependencies - run: npm ci + run: npm install - name: 🛂 Enforce linting run: npm run lint-fix - uses: EndBug/add-and-commit@v9.1.4 diff --git a/.github/workflows/package-size-report.yml b/.github/workflows/package-size-report.yml new file mode 100644 index 00000000..5afbec89 --- /dev/null +++ b/.github/workflows/package-size-report.yml @@ -0,0 +1,26 @@ +name: Package Size Report + +on: + pull_request: + branches: [main] + +jobs: + pkg-size-report: + name: Package Size Report + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4.1.3 + + - name: Setup Node.js + uses: actions/setup-node@v4.0.2 + with: + node-version: "lts/*" + + - name: Package size report + uses: pkg-size/action@v1.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + hide-files: "*.{js,css}.map" diff --git a/copyAssets.mjs b/copyAssets.mjs index 43bd7554..73c240ed 100644 --- a/copyAssets.mjs +++ b/copyAssets.mjs @@ -1,9 +1,21 @@ -import { mkdir, readdir, stat, copyFile } from "fs/promises"; -import { join } from "path"; +import { + mkdir, + readdir, + stat, + copyFile, + writeFile, + readFile, +} from "fs/promises"; +import { join, extname } from "path"; const sourceDir = "./src/locales"; const destDir = "./dist/locales"; +// Function to minify JSON content +function minifyJSON(content) { + return JSON.stringify(JSON.parse(content)); +} + // Function to recursively copy directories async function copyDirAsync(src, dest) { try { @@ -18,8 +30,18 @@ async function copyDirAsync(src, dest) { // Recursively copy subdirectories await copyDirAsync(srcPath, destPath); } else { - // Copy files - await copyFile(srcPath, destPath); + // Check if it's a JSON file + if (extname(file) === ".json") { + // Read JSON content + const content = await readFile(srcPath, "utf-8"); + // Minify JSON content + const minifiedContent = minifyJSON(content); + // Write minified JSON to destination + await writeFile(destPath, minifiedContent); + } else { + // Copy files + await copyFile(srcPath, destPath); + } } }), ); diff --git a/documentation/src/components/multiple_dosage_to_text.tsx b/documentation/src/components/multiple_dosage_to_text.tsx index 2bb0459b..6295c650 100644 --- a/documentation/src/components/multiple_dosage_to_text.tsx +++ b/documentation/src/components/multiple_dosage_to_text.tsx @@ -13,6 +13,7 @@ type Dosage = DosageR4 | DosageR5; function decodeHtmlEntities(text: string): string { return text .replace(/"/g, '"') + .replace(/&/g, "&") .replace(/&#(\d+);/g, function (match, dec) { return String.fromCharCode(dec); }) diff --git a/documentation/src/components/single_dosage_to_text.tsx b/documentation/src/components/single_dosage_to_text.tsx index b7510c27..a88904b0 100644 --- a/documentation/src/components/single_dosage_to_text.tsx +++ b/documentation/src/components/single_dosage_to_text.tsx @@ -13,6 +13,7 @@ type Dosage = DosageR4 | DosageR5; function decodeHtmlEntities(text: string): string { return text .replace(/"/g, '"') + .replace(/&/g, "&") .replace(/&#(\d+);/g, function (match, dec) { return String.fromCharCode(dec); })