Developing plugins
As mentioned the custom plugins are simple ESM JS files that are loaded during qlbuilder start-up phase.
The custom plugin have to export two entities:
More info 1
How the plugin is built (plain JS, rollup, vite etc.) is not in the scope of this documentation
More info 2
How the plugin is distributed (published to public/private npm, copy-paste etc.) is not in the scope of this documentation
More info 3
Considering the idea to have a dedicated repo for public community plugins. Still undecided at this point
More info 4
For any issues and questions please feel free to open and issue in the repo
Meta object
The meta object have the following structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Only command.name is the required option and if the others are not provided qlBuilder will populate them with a default values.
But for clarity it is recommended to explicitly provide as many of the properties as possible.
Command
For more information about the command section please refer to commander.js documentation
Options
This section defines few properties which guide qlBuilder on what the arguments for the action function should include.
requireConnection- (defaulttrue) iftrueconnection will be established andglobalobject (fromenigma.js) will be provided. (requireEnvmust betrue)requireApp- (defaulttrue) iftruethe required app will be open and the app handle will be provided (requireEnvmust betrue)requireEnv- (defaulttrue) iftruethe command will have to have an environment as an argumentconfigFile- (defaultconfig.yml) allows to specify which config file to be used
Action function
The command is first registered from the meta object. When the custom command is invoked qlBuilder will do the needful first (some checks, establish connection etc.) and then will call the plugin action function. The call will include the object below as an argument:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Very simple action function:
1 2 3 4 5 6 7 8 9 10 | |
More info
All core commands are implemented as plugins so you can use them as more advanced examples. Have a look at the qlBuilder repo
Example
The below plugin will register new command (testing) which accepts one argument (-s, --someFlag) and upon execution will print Something in the console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |