The uniform sync command requires a configuration file to specify how it should work. By default, it looks for the uniform.config.ts file in the project's root directory.
It's a TypeScript, JavaScript, or JSON file that exports the configuration object. The object should have a serialization key with a configuration object to specify how uniform sync command should work.
Here is an example of configuration file to enable backup/restore of canvas entities with default settings (YAML format, mirror mode, ./uniform-data directory).
Serialization mode: mirror or createOrUpdate or create
Serialization directory or file path to store serialized data
Serialization entities configuration: to specify which entities and how to serialize
Use will depend on your application. An example case could be where you want to push a new component from your local environment. Review the output details of the push component command.
There are also 3 levels of granular configuration:
Global configuration
Per entity type configuration
Per pull or push command configuration
Here is an example with explanation:
import type { CLIConfiguration } from '@uniformdev/cli';
const config: CLIConfiguration = {
// Sync command related configuration should be under "serialization" key
serialization: {
// Serialization format should be yaml for all enabled entities, unless other format is specified per entity type
format: "yaml",
// Same regarding mode
mode: "mirror",
// Same regarding directory. Note that every content type will be saved in its own subdirectory: `./uniform-data/<content-type>`
directory: "./uniform-data",
entitiesConfig: {
// To enable serialization for specific entity type, you should add it to "entitiesConfig" object. empty object is enough
category: {},
component: {
// Override serialization format for component entity type
format: "json",
mode: "createOrUpdate",
directory: "./custom-directory-for-components"
},
composition: {
format: "json",
pull: {
// Override serialization mode for composition entity type for push command
mode: "create"
},
push: {
// Disable only pushing compositions (if 'push' is not specified, it is enabled using top level settings by default)
disabled: true
},
// Only pull published compositions
state: 'published'
}
}
}
}
module.exports = config;
The default configuration before merging with user provided configuration is:
import type { CLIConfiguration } from '@uniformdev/cli';
const config: CLIConfiguration = {
serialization: {
format: "yaml",
mode: "mirror",
directory: "./uniform-data",
// no entity types are enabled by default
entitiesConfig: {}
}
}
module.exports = config;
Most of the time you will need to override only entitiesConfig object:
import type { CLIConfiguration } from '@uniformdev/cli';
const config: CLIConfiguration = {
serialization: {
format: "yaml",
mode: "mirror",
directory: "./uniform-data",
entitiesConfig: {
asset: {},
composition: {
push: {
// May be useful to only create new compositions and not update existing ones to avoid accidental overrides
mode: 'create'
}
},
category: {},
component: {},
componentPattern: {},
contentType: {},
entry: {},
entryPattern: {},
dataType: {},
signal: {},
test: {},
aggregate: {},
enrichment: {},
locale: {},
quirk: {},
projectMapDefinition: {},
projectMapNode: {},
redirect: {},
workflow: {},
}
}
}
module.exports = config;
To configure this command you should provide the configuration file in one of two ways: