Share My Creation FileWatcher (basic GitHub for B4X)

-> DOWNLOAD HERE <- (file too big to upload to forum).

FileWatcher (it needs a better name) is a file watcher with a difference. It will monitor desired folders and track changes to files within those folders. It runs as a tray application which shows the number of changes in the queue.

ObQrawxBkI.png


When you are ready you can push these changes up to GitHub to store your source code. This is done by right clicking the tray icon and clicking "Push Changes"

MAB6FAmkeP.png


After all the changes are pushed to GitHub it will show a notification of status.

vlYwKNKjTe.png


I have been running this application on my laptop for around 6 months without any issues. I chose this route as although I am familiar with git I am a solo developer and this is a handy way to push my code to GitHub for safe keeping. There are NO dependencies to install git, command line tools etc. when running this app (everything is done via the GitHub API).

This app was written with B4X in mind therefore;

1) It will derive the GitHub repository name from the B4X project (e.g. Project1.b4j will be repo Project1)
2) If the repo does not exist in your GitHub account it will create the repo (and make it private by default - you can make it public later in GitHub if you want)
3) If you are maintaining Java libraries (for B4X) it will locate the parent folder of the "src" folder and use that as the repo name (for example in the sample config below the parent folder of "src" is Project2 so the repo will be "Project2".
4) This can all be overidden if you create a text file called "git-repo-name.txt" in the directory and specify the repo name in that file - this can be used to monitor non-B4X folders.

The actual file watcher code is a modified version of @Roycefer jFileWatcher - this was because Roycefer's library does not return the directory of the modified file (which is required here as the app is watching many directories). The app does not monitor subdirectories - I wanted it to be as lightweight as possible.

Changes are written to the included sqlite database.

Multiple changes are handled and only the last change is sent to GitHub - so even if you make 100 changes, this will only be GitHub 1 commit. Changes are only pushed to the master branch at this time.

You will need to update the accompanying config file. This requires;

1) Your GitHub username (if a personal account) or organisation name (I have only tested with a personal account but the API supports both)
2) A GitHub API token, this can be retrieved from your GitHub account.
3) Any extensions or folders you wish to ignore.
4) And lastly the folders you want to watch - NOTE that as this is JSON you need to escape any slashes.

The included exe is based on my C# Runner which is a simpler version of @Erel launcher. It will attempt to find the JDK in in the runtime\java folder first and then C:\Java\jdk etc folder (you can see the exact logic in the source here).

Example config file below.

JSON:
{
    "github": {
        "api_token": "XYZ",
        "user_or_org_name": "ope-nz"
    },
    "ignore_ext": [".meta", ".zip", ".git"],
    "ignore_folders": ["Autobackups", "Objects"],
    "ignore_files": ["git-repo-name.txt"],
    "watch_folders": [
    "D:\\Dropbox\\My Apps\\B4J\\Project1",
    "D:\\Dropbox\\My Apps\\Java\\Project2\\src\\nz\\ope\\project2"
    ]
}
 
Last edited:
Top