Deleting, Adding, and Exporting the Template
Step 1 - Deleting the Saved Template
To save the example-template
above, we had to initialize AND specify the --save
flag. This can be inconvenient if one does not want to initialize the template now, but still wants to save it.
The alternate way of saving/adding the template is using the uip template add
command. Before doing so, let’s first delete the saved template by running
uip template delete example-template
which should print
Successfully deleted "example-template (1.0.0)"
Running
uip template list
should now only show the built-in templates (which cannot be deleted):
+--------------------+---------+---------------------------------------------------------+ | Extension Template | Version | Description | +--------------------+---------+---------------------------------------------------------+ | ue-task | 1.0.0 | starter Extension with minimal code | +--------------------+---------+---------------------------------------------------------+ | ue-publisher | 1.0.0 | starter Extension with a local Universal Event template | +--------------------+---------+---------------------------------------------------------+
Step 2 - Adding the Template using uip template add
To add/save the example-template
without having to initialize first, run
uip template add <path to example-template.zip>
which should print
Successfully added "example-template (1.0.0)"
Running
uip template list
should now only show the built-in templates (which cannot be deleted):
+--------------------+---------+---------------------------------------------------------+ | Extension Template | Version | Description | +--------------------+---------+---------------------------------------------------------+ | ue-task | 1.0.0 | starter Extension with minimal code | +--------------------+---------+---------------------------------------------------------+ | ue-publisher | 1.0.0 | starter Extension with a local Universal Event template | +--------------------+---------+---------------------------------------------------------+ | example-template | 1.0.0 | this is the description for example template | +--------------------+---------+---------------------------------------------------------+
Step 2.1 - Updating the Template
In addition to adding the template, the CLI also supports updating the template.
!!!
Each template is uniquely identified by its name and version, defined in template_config.yml
. As long as those two things don’t change, the saved template can be updated.
Navigate to the folder where we created example-template
. This folder should contain template_config.yml.
The updates to example-template
will be pretty minor. Open up template_config.yml
and
- Change the description to
this is the UPDATED description for example template
- Add an entry for
src/test.txt
in thefiles_to_template
array
The updated template_config.yml
should be as follows:
name: example-template version: 1.0.0 description: this is the UPDATED description for example template files_to_template: - src/extension.py - src/templates/template.json - src/test.txt variables: msg: default: test_message description: message to print to STDOUT and STDERR log_level: default: Info description: Universal Template Log Level
Create a new file called test.txt
under the src
folder (file should be at the same level as extension.py
) and populate it with:
{{ msg }}
Now, zip up all the contents once again in a file called updated_example_template.zip
(or whatever you want to call it).
To update the saved template, simply run
uip template add <path to updated_example_template.zip>
which should print
Successfully updated "example_template (1.0.0)"
If you now list the available templates, you will see the updated description
+--------------------+---------+---------------------------------------------------------+ | Extension Template | Version | Description | +--------------------+---------+---------------------------------------------------------+ | ue-task | 1.0.0 | starter Extension with minimal code | +--------------------+---------+---------------------------------------------------------+ | ue-publisher | 1.0.0 | starter Extension with a local Universal Event template | +--------------------+---------+---------------------------------------------------------+ | example-template | 1.0.0 | this is the UPDATED description for example template | +--------------------+---------+---------------------------------------------------------+
If you initialize example-template
now using
uip init -t example-template -e 'msg=this is a new message'
you will see the new file, src/test.txt
, containing the specified message.
Step 3 - Exporting the Saved Template
The CLI also supports exporting a saved template. This may be helpful, if you no longer have access to the original template zip and want to share it.
To export example-template
, run
uip template export example-template
This will export a file called example_template-1.0.0.zip
in your current working directory. This zip can be shared and imported by others.