-
Notifications
You must be signed in to change notification settings - Fork 15
Creating packages
Quite often you will end up creating scripts that is very specific to the project you are working on but every now and then you'll end up writing something extensions that others may benefit from. OpenIDE comes with a built in package manager. You can easily create a package from any script by running oi package init SCRIPT_NAME. This will create a package.json file within the SCRIPT_NAME-files directory. Packages are only allowed to contain the script file and files contained within the SCRIPT_NAME-files directory.
When initializing the pckage the json file is opened in the editor. If not simply run oi package edit NAME.
The basic infor that needs to be present for packages are:
- os: Operating systems supported by the script
- target: Type of extension => script, rscript, language-script, language-rscript, language
- language: What language it belongs to. Only relevant for language-script and language-rscript
- id: The package identifier. Cannot contain spaces
- version: Package version
- command: Name of the command in this package
- name: Name of the package
- description: Package description
The configuration prefix is not used when uninstalling the package. If you want config options created on install and removed on uninstall use the post install and post uninstall actions.
You can specify packages that this package depends on. These packages will be installed when installing this package. For each dependency you must add the package identifier and what versions of the package is supported.
You can specify actions to be run before and after install and uninstall. Every action must be an OpenIDE command. You can either list the actions as strings or you can use a local/global structure to specify what command will be run if the package is installed locally vs globally. Like this:
"post-install-actions": [
{
"local": "command|conf myscript.option1=something",
"global": "command|conf myscript.option1=something -g"
},
"command|codemodel publish myscript-install-competed"
],
Packages has an options to verifying the environment it's installing in into before and after install. This is handled by creating a runable file at the same level as the package.json file with the name oi-package-install-verify with any extension. If running the script fails or it writes anything to stdout prefixed with error|some message the install will fail.
Like when verifying a package for install there is a way to handle package upgrades. Create a runable file at the same level as package.json with the name oi-package-update with any extension. This script will be called once before update with the argument before-update and then when update is done with after-update. This gives the script the possibility to upgrade it's data.
When updating a script any information inside the folders called rscripts,scripts,snippets,preserved-data,state are preserved between updates. Any other information will be deleted.
To build you package simply use the oi package build myscript /place/it/here. This will build the package and create a myscript.oipkg file in the specified directory if your package id is myscript. Instead of always having to specify the path in where to place the built package you can set the default.package.destination setting with oi conf default.package.destination=/build/to/here -g. Now you can run oi package build myscript and it will end up in that directory.