homerchen19 / github-file-icons

🌈 🗂 A browser extension which gives different filetypes different icons to GitHub, GitLab, gitea and gogs.
https://chrome.google.com/webstore/detail/file-icon-for-github-and/ficfmibkjjnpogdcfhfokmihanoldbfe
MIT License
1.41k stars 67 forks source link

Switch to using a local implementation of the file-icons-js package #121

Closed csandman closed 2 years ago

csandman commented 2 years ago

This PR would close #120, the issue I made. The purpose of this PR is to replace the package file-icons-js, which hasn't been updated in 2 years, with a local version of it.

Summary of Changes

Explanation

For the most part, the new code in file-icons.ts is a TypeScript port of the file-icons-js package. However, instead of adding the content of the iconsdb.js file to the main part of the code (like they do in the file-icons-js package), I added a script which automatically downloads the newest version of that file from the file-icons/atom package.

This script also downloads all the associated style and font files. The original style files are .less files, so I added the less package to compile them at download time. This could probably be done in the webpack config, but I thought it might be simpler to do so in the download process to prevent it from running every time the extension is built.

This script can be run manually periodically, or using an action of some sort like they do in the github-material-icons-extension package. That part is up to you, but at least you have a base to go off of, and have control over when the files are updated. At least when run manually, you can see a git diff if the files were actually changed and you can push based on that.

As for the folder structure, I decided to keep all of the assets and code files related to file-icons in their own directory in src. It's up to you whether you like that structure, but I felt like it was simpler to keep them together. Most of the files in that directory are downloaded automatically and probably shouldn't be touched because the changes will be overrode. However, there are a few files I added manually that should be taken note of:

These files can be modified manually as needed.

And finally, I just fixed a few lint warnings because they were bugging the hell out of me haha. They were pretty small so this shouldn't fall outside of the scope too much.

csandman commented 2 years ago

As a side note, this should close a few issues:

I made a test project to see what they looked like and they all work:

image
csandman commented 2 years ago

I'm also thinking about just making a fork of the file-icons-js package and setting up a GitHub action to keep it updated, but that probably won't exist for a bit. I can let you know if I get a working version at some point though!

homerchen19 commented 2 years ago

I'm also thinking about just making a fork of the file-icons-js package and setting up a GitHub action to keep it updated, but that probably won't exist for a bit. I can let you know if I get a working version at some point though!

Yes that will be even better. We can use your package from npm in this extension and no need to implement a local version. That can also help other potential projects too. Please consider doing so 🙏

csandman commented 2 years ago

Yes that will be even better. We can use your package from npm in this extension and no need to implement a local version. That can also help other potential projects too. Please consider doing so 🙏

I have started looking into this, and I will probably do it at some point. My main thing is, if I'm going to do it, I'd like to make sure I have an action set up to automatically update the package, otherwise I'd probably end up forgetting about it at some point and letting it get just as outdated as file-icons-js.

homerchen19 commented 2 years ago

I have started looking into this, and I will probably do it at some point. My main thing is, if I'm going to do it, I'd like to make sure I have an action set up to automatically update the package, otherwise I'd probably end up forgetting about it at some point and letting it get just as outdated as file-icons-js.

Got it. Hope you get it done soon! Please also open a PR to this repo once you finish creating it.

csandman commented 2 years ago

Got it. Hope you get it done soon! Please also open a PR to this repo once you finish creating it.

Will do!