From b5d34456afe7c366ad2cd8d43ad5847423491e26 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Wed, 25 Feb 2026 21:56:06 +0000 Subject: [PATCH] fix(#5): ignore generated vendor manifest in prettier --- .prettierignore | 1 + scripts/generate-vendor-icon-manifest.mjs | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/.prettierignore b/.prettierignore index 6562bcb..2df23c2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,4 @@ pnpm-lock.yaml yarn.lock bun.lock bun.lockb +src/lib/config/vendorIconManifest.ts diff --git a/scripts/generate-vendor-icon-manifest.mjs b/scripts/generate-vendor-icon-manifest.mjs index 46131cd..4f31db9 100644 --- a/scripts/generate-vendor-icon-manifest.mjs +++ b/scripts/generate-vendor-icon-manifest.mjs @@ -8,6 +8,7 @@ const projectRoot = path.resolve(currentDirPath, '..'); const vendorRoot = path.join(projectRoot, 'static/icons/vendor/homarr'); const outputPath = path.join(projectRoot, 'src/lib/config/vendorIconManifest.ts'); +const prettierIgnorePath = path.join(projectRoot, '.prettierignore'); const allowedExtensions = new Set(['.svg', '.png', '.webp']); const extensionPriority = { @@ -65,6 +66,33 @@ function compareIconRecords(a, b) { return a.key.localeCompare(b.key); } +/** @param {string} filePath @param {string} entry */ +async function ensureIgnoreEntry(filePath, entry) { + const normalizedEntry = toPosixPath(entry).replace(/^\.?\//, ''); + let contents = ''; + try { + contents = await fs.readFile(filePath, 'utf8'); + } catch (error) { + if (!(error instanceof Error) || !('code' in error) || error.code !== 'ENOENT') { + throw error; + } + } + + const eol = contents.includes('\r\n') ? '\r\n' : '\n'; + const existingEntries = contents + .split(/\r?\n/) + .map((line) => line.trim()) + .filter((line) => line && !line.startsWith('#')) + .map((line) => toPosixPath(line).replace(/^\.?\//, '')); + if (existingEntries.includes(normalizedEntry)) { + return; + } + + const suffix = contents.length > 0 && !contents.endsWith('\n') && !contents.endsWith('\r\n') ? eol : ''; + const nextContents = `${contents}${suffix}${normalizedEntry}${eol}`; + await fs.writeFile(filePath, nextContents, 'utf8'); +} + async function main() { const vendorExists = await fs .access(vendorRoot) @@ -149,8 +177,10 @@ async function main() { const footer = ['];', ''].join('\n'); const output = `${header}\n${body}\n${footer}`; + const outputIgnoreEntry = toPosixPath(path.relative(projectRoot, outputPath)); await fs.mkdir(path.dirname(outputPath), { recursive: true }); + await ensureIgnoreEntry(prettierIgnorePath, outputIgnoreEntry); await fs.writeFile(outputPath, output, 'utf8'); }