FoxDock comes with a plugin center: a window inside the Visual FoxPro 9 IDE to install, update and remove plugins. The ones I have written are there, but the center was made so that anyone can publish their own and everyone else installs it the same way.
In this tutorial we publish one. By the end, another developer opens the center, types the address of your repository and presses Install. If you also ask for the entry in the index, your plugin shows in the Available list next to mine.
Nobody has to approve what you publish. Only the entry in the index is reviewed, and that is the last step and an optional one.
What you need
- FoxDock 0.10.4 or later, with your plugin working in your plugins folder. If you have not written one yet, FoxDock > Plugins > New plugin… makes the folder and the
.prgfor you, and the manual (FoxDock > Help) has a tutorial that builds the first one step by step. - A GitHub account and git installed. The plugin is published in a public repository. A repository is the folder of a project, kept on GitHub with all its history.
The example plugin
We are going to publish clock, a plugin that puts a bar on the FoxDock menu and tells the time. It is a folder, clock, with one file inside:
DEFINE CLASS ClockPlugin AS PluginBase
cTitle = "Clock"
PROCEDURE BuildMenu
LPARAMETERS toMenu
toMenu.AddBar("What \<time is it", "SayTime")
ENDPROC
PROCEDURE SayTime
This.oHost.Notify("It is " + TIME())
ENDPROC
ENDDEFINEThe name of the folder is the id of the plugin. The file is named after the id, with its first letter in uppercase, followed by Plugin.prg: for clock, ClockPlugin.prg. That is what FoxDock looks for.
It is published, with these same steps, at Irwin1985/foxdock-clock: there you can see what the repository looks like, with its two files and its tag.
Step 1. The foxpack.json
In the plugin folder, next to the .prg, goes a file foxpack.json that says what your plugin is. This is the one of clock:
{
"name": "foxdock-clock",
"kind": "foxdock-plugin",
"id": "clock",
"foxdockApi": 1,
"version": "1.0.0",
"description": "A clock in the FoxDock menu",
"license": "MIT",
"files": ["ClockPlugin.prg"],
"requires": []
}| Field | What it holds |
|---|---|
name | The name of the package. The custom is foxdock- and the id |
kind | Always foxdock-plugin |
id | The id of the plugin: lowercase letters, digits and _, starting with a letter, up to 30 characters |
foxdockApi | The version of the FoxDock contract it needs. Today it is 1 |
version | The version, like 1.0.0 |
description | One line that says what it does |
license | The license, like MIT |
files | The files that get installed: .prg, .h, .json, .txt and .md, in subfolders too |
requires | The libraries of the FoxPack index it uses, as name or name@version. If it uses none, [] |
If your plugin uses a library of the index (JSONFox, for example), put it in requires and do not copy it yourself. FoxPack downloads it when the plugin is installed and leaves it in lib\<name>\, inside its folder.
Step 2. The repository on GitHub
Go to github.com, create a new public repository and name it after the name of the foxpack.json: foxdock-clock. You do not need to add anything to it from the web.
Then open a console in the plugin folder and send what you have. Replace your-user with yours:
git init
git add .
git commit -m "clock 1.0.0"
git branch -M main
git remote add origin https://github.com/your-user/foxdock-clock.git
git push -u origin mainThe code is now on GitHub. ClockPlugin.prg and foxpack.json must end up at the root of the repository.
Step 3. The version and its tag
Each version you publish is a commit with its tag. A commit is a snapshot of the repository saved with git, and a tag is the name git gives to a commit.
The tag is a v and the version of the foxpack.json: with "version": "1.0.0", the tag is v1.0.0. The two must match, or FoxPack does not install it.
git tag v1.0.0
git push origin v1.0.0The first command puts the tag on the last commit, and the second one sends it to GitHub. If you prefer, you can create the tag from the page of the repository, when you publish a release.
From this moment your plugin is published.
Step 4. Install it the way someone else would
Before telling anyone, try it from the plugin center.
Your working copy is in the plugins folder under the name of your plugin, and the center does not touch it: the card would say that folder already exists, and the Install button would be off. So first move your clock folder out of the plugins folder and choose FoxDock > Plugins > Reload plugins.
Now open FoxDock > Plugins > Plugin center…, go to Available and press From a repository…. Type your-user/foxdock-clock and press Look.
The card of your plugin appears, with the mark “not reviewed”, because it is not in the index yet. Install asks a second time, and it installs with Yes, install. The plugin loads right away, without restarting FoxDock, and the bar What time is it shows on the menu.
That is how anyone you give the address of your repository to is going to install it.
To pass it to a colleague before publishing you do not need GitHub. In Installed, the button From a folder or zip… installs what is in a folder or in a zip. In that case the libraries of requires are not downloaded: the folder has to bring them in lib\<name>\.
Step 5. Asking for the entry in the index
This step is optional. The FoxPack index is the list of plugins that shows in Available. With your plugin in the index, nobody needs to know the address of your repository to find it.
The index lives in the repository Irwin1985/foxpack-index, and the entry is asked for with a pull request: a proposed change that you make from GitHub and that is accepted or not. The entry of clock would be this one:
{
"name": "foxdock-clock",
"kind": "foxdock-plugin",
"id": "clock",
"repo": "your-user/foxdock-clock",
"description": "A clock in the FoxDock menu"
}name, kind and id are the ones of the foxpack.json, and repo is user/repository.
Before I accept an entry I look at four things:
- that the repository is public and has a tag equal to the version of the
foxpack.json; - that the plugin installs and loads cleanly with FoxPack;
- that the code brings no binaries without their source, and that it does not touch the network, the disk or the registry beyond what its description says;
- that it has a license.
When it gets in, your plugin shows in Available with the mark “reviewed” and installs in one step.
The review is of the version there is when you ask for the entry. The versions you publish afterwards reach whoever has it installed without another review.
A new version
- Change
versionin thefoxpack.json, for example to1.1.0. - Save the change in a commit and send it:
git commit -am "clock 1.1.0"andgit push. - Give it its tag and send it:
git tag v1.1.0andgit push origin v1.1.0.
Whoever has your plugin installed sees the new version in the Updates view of the center. The index is not touched, because the entry points to the repository and covers all its versions.
What is not accepted
- Files that are not
.prg,.h,.json,.txtor.md. A form (.scx), a visual class library (.vcx), an.fxpor a DLL are not installed, and FoxPack rejects a plugin that has them infiles. - In
requires, libraries that are not in the FoxPack index. - An
idthat does not follow the rule of the table. - A
foxdockApinewer than the FoxDock of whoever installs it. The center says so and does not install it.
Where all this is
The FoxDock manual covers it in full in the section “Publishing your plugin”, and the section “The plugin center” explains the marks “official”, “reviewed” and “not reviewed”. It opens from FoxDock > Help, in your browser and in the language of the menu.
If something does not work for you, write to me at soporte@irwinrodriguez.dev.