How do you manage your greasemonkey userscripts using Git?
I'd like to use Git in order to facilitate the development of my userscripts (21). Also, I'd like to have them hosted in GitHub too. (using Greasemonkey with Firefox in windows 10).
So, my question is: what is the suggested way to manage my userscripts using Git, in order to also have them hosted in GitHub?
make a separate folder (e.g. c:\my_scripts which will be my repo folder) containing copies of my userscripts files,
i.e. each time I change one of my userscript files (located in gm_scripts)
I'll have to manually copy it from gm_scripts\script_subfolder to my_scripts?
have all my user userscripts in the same separate folder (my repo folder),
and link them to the gm_scripts folder (using mklink -symbolic links- in a .bat file), as I've read in this answer?
create just one repository containing my gm_scripts content?
(inside gm_scripts, apart from my 21 userscripts, I've got many other scriptss installed, which I'll have to include in my .gitignore file)
or is there any better way that I miss?
I've noticed the repos of two authors of many userscripts: @Mottie and @jerone
who have their many userscripts hosted in GitHub,
yet they follow different approaches:
Mottie's userscripts are all located in the root folder of the repo (just the .js files, there are no subfolders), (screenshot)
while jerone's userscripts are located each in its own subfolder in the repo (screenshot).
My guess is that Mottie has all his userscripts in the same separate folder (which is the repo), and has them linked to the gm_scripts folder,
while jerone either just keeps a separate folder as a repo, with copies of his scripts,
or has his repo containing the gm_scripts folder
(but, jerone's .gitignore doesn't contain entries for those files in gm_folder that should be ignored, such as .db, .wal, .shm, config.xml and such. So, I'm not sure if that's the case).
And, do you use Git for Windows? (Git Bash or Git GUI) ?
Or you use Git inside an editor (e.g. Sublime Text via Git package, Atom, VSCode, etc)?
Or maybe you use some third party GUI client? (GitHub Desktop, SourceTree, SmartGit, etc)?
edit: I have edited my question and posted it in stackoverflow
in case you would prefer to answer there.
I'm a n00b when it comes to development. So my methods are probably not the best nor are they the most efficient. I probably should do my development in Firefox since it appears to be much easier! :wink:
My current set up is that I mainly run Tampermonkey for Chrome. I use the built-in editor to tweak my code, because Chrome stores the userscripts in an SQL database, so there isn't any way to open the file in an editor; but most of my development is in a external editor.
Silverwind once shared with me that you can use a symlink shortcut in Windows to point to the file in the gm_folder, but like I said, I just never got around to using Firefox for development.
When I first started writing userscripts, I made a separate repository for each script, but that got messy fast... it wasn't very organized since GitHub doesn't allow you to categorize your repositories. I did look at Jerone's userscript repository, but for me navigating subfolders was difficult and I like to see everything at once. So it's more of a personal preference on how I organize things. All my documentation is in the wiki pages, so that keeps the root directory clean(er).
Lastly, I use Git Bash, but though the ConEmu terminal because it's awesome!
Thanks a lot for your detailed answer, @Mottie!
For small scripts my way might be a little bit overhead. But I found it to be the best solution for my scripts with translation, documentation, > 3000 lines of code, dependencies, deployment of resources.
First I had a small script which got bigger by time (also I started other scripts with same core functions which are not openly provided to everyone). So I decided to split the script up in a "Core" and the real script. Both have their own github repositories which I combined in one organization: https://github.com/IkaScripts
Advantage of own github repositories: Commits refer only to one script and I can use the issue section without having the issues mixed up between scripts.
Then I split up different parts of the code into different files to keep the overview. Additionally some changing parts of the script like dependenscies, version number, names, etc. are moved to configuration files (this brings also the advantage that I do not forget to do these changes at all places where needed).
To merge these files and replace the variables I created a build script. This script also fetches the translations from transifex automatically, deploys language resources to my server and creates and deploys a documentation if required. In addition it is possible for me to create test versions (with build numbers in the version) which I then can install normally.
Advantage: Not every change is automatically deployed to all users, I can develop different features / bug fixes in independent commits and only the commit after a build release triggers the update on greasy fork. Also I can use the normal version of my script while developing new features (different name for development and release version).
So my development process is:
What might be improved:
Yes, for many things this might be an overhead for lots of projects, but I find this quite useful as I am able to automate some features and eliminate possible errors.
For development I use eclipse, for github I use git bash.
Sign in to post a reply.