Knowledge Base/How to make draft/published structure to remain the same when using CLI to copy Uniform projects

How to make draft/published structure to remain the same when using CLI to copy Uniform projects

how-toDeveloperCLI

The solution is to first sync the published compositions/project map nodes and then sync the draft compositions/project map nodes

  1. Pull the published compositions from the source project. For example, create config file named uniform.config.published.ts:

uniform.config.published.ts

import type { CLIConfiguration } from '@uniformdev/cli'; const config: CLIConfiguration = {   serialization: {     entitiesConfig: {       composition: {         publish: true,         state: 'published',       },       projectMapDefinition: {},       projectMapNode: {},     },   }, }; module.exports = config;
  1. Pull the data into local:
uniform sync pull --config uniform.config.published.ts
  1. Push like this to the destination project (by specifying different env variables):
uniform sync push --config uniform.config.published.ts

This will push and publish only the previously published compositions.

  1. Pull all the compositions from source and push to destination without publish. For example, have the root uniform.config.ts like this:
import type { CLIConfiguration } from '@uniformdev/cli'; const config: CLIConfiguration = {   serialization: {     entitiesConfig: {       composition: {         publish: false,         push: {           mode: 'create',         },         pull: {           mode: 'mirror',         },       },       projectMapDefinition: {},       projectMapNode: {},     },   }, }; module.exports = config;

The 'Create' mode on push will only add the missing draft compositions. This way it should create exactly the same structure as on the site you are pulling from.

Last modified: January 7, 2025