- Developer guides
CLI commands and configuration
The Content SDK CLI provides commands and supports scripts for common tasks during the development of projects using the Content SDK. To use the CLI, you must first install it globally on your local machine.
The CLI is configured using the sitecore.cli.config.ts file by default. When this file is created as part of an app using a starter template, it contains the following configuration settings:
The build command supports the --config flag that you can use to provide the location of a config file.
The build command
The sitecore-tools project build CLI command prepares app-specific build artifacts, such as those required for the app to connect to SitecoreAI. It does this by sequentially executing the functions listed in the build: section of your CLI config file.
Your app's package.json file includes a build script that calls this CLI command, so it runs every time your app is built.
By default, the CLI will try to use a file named sitecore.cli.config.ts in the folder where you run the command. If that file does not exist the CLI will try to use sitecore.cli.config.js instead.
If you're running the command in a folder that doesn't contain either of these files, you need to specify the name and (relative) location of the file by using the --config argument, as shown in the following example where a custom file is used in the current folder:
Within the config file's build.commands: section, you can add custom functionality as shown with myBuildCommand() in the following example:
You can configure the default generateMetadata method using a GenerateMetadataConfig object. It accepts two optional parameters:
Parameter | Type | Description |
|---|---|---|
| string | Specify the path to store the generated metadata. If no value is provided, the default path is used. Default: .sitecore/metadata.json |
| boolean | Specify whether to allow metadata generation for npm monorepos. Default: false |
For additional examples of customization, look at the implementations of generateMetadata and generateSites in the core package.
The experimental list command
The sitecore-tools project experimental list command lists the experimental features available in your Content SDK app and whether each feature is enabled. It reads the features from the app's installed @sitecore-content-sdk packages, including @sitecore-content-sdk/angular.
Run the command from the root folder of your app:
For each feature, the output includes:
| Detail | Description |
|---|---|
| Name | The feature's display name and ID. |
| Status | enabled or disabled. |
| Environment variable | The variable used to enable the feature. |
| Description | A short description of the feature. |
The command also prints instructions for enabling features. For example, the following output shows a sample feature:
Sample dummy features are available to verify the command. Actual experimental features appear in the same format as they become available.
To enable experimental features:
- To enable one feature, set its environment variable to
true. - To enable all features, set
CSDK_GLOBAL_EXPERIMENTAL_FEATURES_ENABLED=true.
Use the lowercase value true. Values such as TRUE and 1 do not enable features. Run the command again after changing the environment variables to see the updated status.
If the installed packages have no experimental features, the command reports that none are available in the current version. If you run it outside a Content SDK app, it prints the following error: