CLI
Common tasks
Many of the kinds of administrative tasks you perform using the Uniform dashboard or the CLI can also be done programmatically using the Uniform APIs.
Backup & restore#
Why backup & restore?#
A common operational need is to keep multiple deployment environments in sync with each other. For example:
Purpose | Example |
---|---|
Separate by user |
|
Separate by purpose |
|
For Uniform, this is done using serialization of project assets, such as Uniform Canvas components or compositions and Uniform Context signals and enrichments, to files on disk. These files can then be committed to source control and shared between environments, or used to scaffold templates and demos.
Which project assets can you backup & restore?#
The Uniform CLI provides the ability to backup and restore the following project assets:
Category | Type |
---|---|
Canvas | Components |
Canvas | Compositions & patterns |
Canvas | Data types |
Context | Audiences & intents |
Context | Enrichments |
Context | Quirks |
Context | Signals |
Context | Tests |
Project map | Definitions |
Project map | Nodes |
Automate backup & restore#
This section describes how to add backup and restore scripts to a Node project. Your CI/CD process can trigger the script in order to automate backup & restore.
Prerequisites
These instructions assume you already have a Node project and a Uniform project.
Make sure the following dependencies are included in your Node project. If you need to add them, you can add them as developer dependencies:
Make sure you have a
.env
file with the values needed to connect to your Uniform project.Add the following scripts to your
package.json
file:package.json
To backup the assets in your Uniform project, run the following command.
Backup project assets
About this step
A file for each project asset is created in the sub folders under the folder
data
.To restore the assets to your Uniform project, run the following command:
Restore project assets
About this step
Project assets stored in the sub folders under the folder
data
are restored to your Uniform project.
tip
Another useful technique with pushing and pulling is to perform bulk updates. Since the serialized files are plain YAML (or JSON), you can use your favorite tools such as jq
to modify them before pushing them back into Uniform.
Backup assets to a single file#
For CI/CD environments it's generally ideal to produce a single artifact instead of many serialized files to define the state of Uniform. To support this, the Uniform CLI allows you to use the pull
and push
commands directly to a package file instead of multiple files on disk.
To use this feature, specify a filename instead of an output directory:
To add multiple types of product assets to a single file, use the same filename: