Sync assets on a Commerce server with a local workspace

Oracle Commerce provides tools for keeping assets on server environments in sync with local workspaces.

Your development team should maintain application code and configuration in a source control system. Developers can access the source control system on their workstations, build and modify applications in their local workspaces, and then deploy the applications to Commerce server environments. Working this way helps ensure that the assets on the server match the ones in the source control system.

However, not all assets are necessarily created by developers in local workspaces. The Design page in the administration interface provides tools that designers can use to create assets such as layouts and containers. In order to keep these assets up to date in the source control system, the OSF command-line interface includes options for syncing assets between a server environment and a local workspace. This section describes how to use these commands. The assets they affect include layouts (pages), widgets and widget instances, containers (widgets that can contain other widgets), text snippets, and slot instances.

Note that you should be careful when you use these options to ensure that you get the results you expect. Depending on which commands you use and the flags you specify, the logic associated with deleting or overwriting existing assets on the target system may differ. Be sure you understand what the effect of a given command will be before you execute it, to ensure that you do not lose any changes. To help avoid conflicts, it is a good idea for each developer working on an application to create a local development version, as described in Access local development applications on a Commerce server.

Upload assets from a local workspace to a server

To copy assets from a local workspace to a server environment, you use the deploy command. For example:

yarn occ deploy blank-store

When you run this command, Commerce creates only new assets on the server. Any asset that already exists on the server will not be overwritten by an asset with the same name from the local workspace.

Run the deploy command with the --reset flag to make the workspace on the administrative server match the local workspace. The server will contain just the assets that were uploaded from the local workspace. For example:

yarn occ deploy blank-store --reset

Note that with this option, any changes that have been made to assets on the server that are not also on the local workspace will be lost. To avoid losing these changes, you should download these assets to the workspace first, and then deploy the application.

Download assets from a server to a local workspace

The CLI includes a download-assets command for copying assets from a server environment to a local workspace. For example:

yarn occ download-assets blank-store

Any asset in the workspace whose name matches an asset downloaded from the server is overwritten; other assets in the workspace remain as is. To avoid losing changes that you have made to assets in your workspace, you should first commit these changes to your source control system before downloading assets from the server, and then resolve any conflicts afterward.

Run the download-assets command with the --reset flag to make the local workspace match the administration server. The local workspace will contain just the assets that were downloaded from the server. For example:

yarn occ download-assets blank-store --reset

Note that with this option, any changes that have been made to assets in the workspace that are not also on the server will be lost. To avoid losing changes that you have made in your workspace, you should first commit these changes to your source control system before downloading assets from the server, and then resolve any conflicts afterward. Or you can first deploy the changes to the server, and then download the assets from there.