feat(file-icons): serve devicon file icons from our own assets #198
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!198
Loading…
Reference in a new issue
No description provided.
Delete branch "enh/vendor-devicons"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Serve the default
deviconfile icons from the instance's own assets instead of jsDelivr, so no visitor IP reaches a third-party CDN and icons no longer change or vanish with devicon's unpinned@latest.Closes #189
Changes
public/assets/img/devicon/: add the 94 SVGs the mappings reference, pinned to devicon v2.17.0 and optimized with svgo (230 KB total), plus devicon's MITLICENSE.tools/generate-devicons.jsandmake devicons: vendor exactly the referenced files from the pinned release, plus aVERSIONfile; needs network, so it is a manual step, not a CI check.web_src/js/features/devicon-map.js: move the mappings out offile-icons.jsinto a pure data module that the generator, the browser code and the test share, and hold theDEVICON_VERSIONpin there..forgejo/renovate.json: trackDEVICON_VERSIONwith acustom.regexmanager (datasourcegithub-tags,devicons/devicon). The shared preset automerges minor and patch updates withignoreTests: true, and the bot's global config allows no post-upgrade commands, so Renovate can bump the pin but not regenerate the SVGs; this dependency therefore has automerge off and a PR note to runmake deviconson the branch.web_src/js/features/file-icons.js: build the<img>URL fromassetUrlPrefixand addloading="lazy"anddecoding="async".-originalvariant,build.sbtuses the Scala icon, and.v/.vshfall back to the generic file icon because devicon has no V icon.github-originalentry.web_src/js/features/file-icons.test.js: assert that the vendoredVERSIONmatches the pin (so a bump-only Renovate PR fails CI), that every mapped icon exists on disk, that every inverted icon is mapped, and that icons load lazily from/assets/img/devicon/.README.md: extend the "Icons & UI" row.Behaviour change
/assets/img/devicon/…instead ofcdn.jsdelivr.net; the diff tree uses the same module, so it is covered too.DEVICON_VERSION, which stays red until someone runsmake deviconson it and commits the result.Validation
vitestforfile-icons.test.jsandDiffFileTreeItem.test.jspasses; deleting one vendored SVG makes the coverage test fail and name the file.crow-plugins/renovatebundles) validates.forgejo/renovate.jsonwith--strictand, in a local run, extractsdevicons/deviconatv2.17.0from the new manager; the release lookup needs the bot's GitHub token, so I could not run it here.v2.18.0without regenerating fails the version test; restoring it passes.prek run -apasses (backend lint, swagger, frontend lint and type checking).Follow-up
-plainicons (elixir, haskell, lua, ocaml, svelte, terraform and others) are black and nearly invisible in dark mode; that predates this change and is left for a separate fix.15c1a9c1dfa20ec89d56a20ec89d56d8fc78828ad8fc78828a2111f54830