The dcu
is the core code and metadata synchronization utility, which allows you to grab all of the user modifiable source code and metadata from a Commerce Cloud server, edit it as necessary in your chosen tool, and then upload it back to the server. The utilities also makes it possible to transfer content between Commerce Cloud server instances. The dcu
supports these main operations:
--grab
takes a copy of all available user modifiable source code and metadata from the specified Commerce Cloud server and creates a directory tree on the local disk for it that resembles the structure you see in Code View.--put
sends the contents of a single file back to the specified Commerce Cloud server.--putAll
sends all the files underneath a named directory back to the specified Commerce Cloud server.--transferAll
enables the transfer of content between Commerce Cloud server instances.--compileLess
combines all off the downloaded less resources for widgets, elements, stacks and themes and posts them to the node for compilation
The basic command for grabbing files is:
dcu --grab
The basic command for uploading a single file is:
dcu --put <path to file>
For example:
dcu --put "widget/Add Product To Wish List/instances/ Add Product To Wish List Widget/display.template"
The basic command for uploading all files under a specified directory is:
dcu --putAll <directory>
For example:
dcu --putAll theme
During each of these operations, the utility provides messages to tell you the status of the grab or upload. You can modify these basic commands with the options described in the Understand dcu options section.
Transfer source code and metadata between Commerce Cloud instances
You can use the dcu
to transfer source code from one Commerce Cloud instance to another. This can be useful for promoting source code from a test environment to production.
To use the transfer feature, you must execute a grab from the source instance, for example:
dcu --grab --clean --node http://source
Instance
--userusername
--passwordpwd
After the grab is finished, you transfer the files to the destination instance, using a command similar to the following:
dcu --transferAllpath
--node http://destination
Instance
--userusername
-- passwordpwd
The dcu
takes a “best effort” approach to transferring content between instances. In general, it matches by name so that if, for example, a widget instance on the destination instance has the same name as a widget instance on the source instance, they are assumed to be the same. The matching rules for each entity type are described in the table below.
Type | Matching rules |
---|---|
Global elements | Matches on the |
Application-level JavaScript modules | Matches on the JavaScript file name. If the file name does not exist, it is created on the destination instance. |
Text snippets | Matches on locale. |
Stacks | Matches on the stack instance’s display name. If the stack instance does not exist, a warning is issued. |
Themes | Matches on the theme name. If a matching theme does not exist, one is created on the target instance, using the same name and source code. |
Widgets | Widgets are matched on version number and display name. If the widget does not exist, a warning is issued. Widget instances are matched on display name. If a matching widget instance does not exist, a new widget instance is created on the target instance using the same display name and source code. |
Elements | Widget elements are matched on version number, display name and |
Understand dcu options
The following table describes the options you can use with the dcu
.
Option | Description |
---|---|
| Provides usage information for the utility. |
| Provides the utility’s version number. |
| The URL for the administration interface on the target Commerce Cloud instance, for example, |
| The application key to use to log into the target Commerce Cloud administration interface. It is recommended that you create an application key for authentication purposes. For detailed information on creating an application key, refer to the Use the application key for authentication section. It is also possible to specify the application key using the CC_APPLICATION_KEY environment variable. |
| These options are no longer available, having been replaced by the |
| Copies all available content from the target Commerce Cloud instance into the current working directory, or the base directory if one has been specified. Note: During a grab, a new directory called |
| Sends the specified file back to the specified Commerce Cloud instance. The If a full path is provided, then any value specified in the |
| Specifies the base directory. This can be either a relative or absolute path, in either Windows or POSIX format. |
| Retrieves text snippets and resources for the specified locale only. Also, the informational messages displayed by the Design Code Utility will appear in the locale specified. |
| Gets text data for all locales rather than just the current locale for the target Commerce Cloud instance. |
| Deletes all local files that have been previously grabbed. Used only with the |
| Sends all files back to the target Commerce Cloud instance, beneath the specified directory. The If a full path is provided, then any value specified in the |
| Transfers all files from the local machine to the specified Commerce Cloud instance, matching by name. For example, if a widget instance is called |
| Updates all instance templates, less and locale strings using their respective base assets. By default, when a base widget template, less or locale file is modified, the changes affect only widget instances that are subsequently created. When you select this option, all widget instance assets of a specific type are overwritten with their corresponding base contents. You can use this option to correct issues affecting a large number of existing instances. It is recommended to use this option sparingly. |
| By default, when performing a |
| This option, used in conjunction with |
Add JavaScript to existing user-created widgets
You can add JavaScript to an existing user-created widget by creating a new .js
file under the widget’s /js
directory and issuing a put
, putAll
or transferAll
.