🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

@remkoj/optimizely-cms-cli

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remkoj/optimizely-cms-cli

CLI Utility to work with Optimizely SaaS CMS.

npmnpm
Version
6.0.0-pre11
Version published
Weekly downloads
1.9K
31.44%
Maintainers
1
Weekly downloads
 
Created
Source

Optimizely CMS Command Line Toolkit

A collection of Command Line tools used to increase productivity when working with the Optimizely CMS from a TypeScript / JavaScript based frontend.

The defaults and methods are based upon using a Next.JS application with the conventions introduced by the Create Next App template

1. Installing / using

This package has been tested through npx, yarn dlx as well as development dependency within a Yarn managed project. Though there should not be a any dependency on Yarn as package manager for your project it has not been verified.

The usage examples through this readme are assuming the package has been installed as development dependency in a Yarn managed project, you must adjust these based upon your project.

1.1. Installing as development dependency

This package has been designed to work in a Yarn PnP / Zero-install environment, it may or may not work with other package managers.

yarn add --dev @remkoj/optimizely-cms-cli

1.2. Usage through direct execution

Instead of using the yarn opti-cms as shown in the examples, which is available as short-hand after installation as development dependency, you may use one of these as well.

# Execution through NPX, latest version
npx @remkoj/optimizely-cms-cli

# Execution through Yarn DLX, latest version
yarn dlx @remkoj/optimizely-cms-cli

# Execution through NPX, explicit version 5.1.1
npx @remkoj/optimizely-cms-cli@5.1.1

# Execution through Yarn DLX, explicit version 5.1.1
yarn dlx @remkoj/optimizely-cms-cli@5.1.1

2. General usage and parameters

  • List all commands and global parameters: yarn opti-cms --help
  • Build version: yarn opti-cms --version
  • Command specific help and parameters: yarn opti-cms [command] --help

2.1. Global parameters

All commands share these parameters that configure the frontend environment.

ParameterAliasUsageDefault
--versionShow version number
--path-pThe application root folderThe current working directory
--components-cThe components folder within the application./src/components/cms
--cms_url--cuThe Url of the Optimizely CMS ServiceCalculated from the environment variables OPTIMIZELY_CMS_URL and OPTIMIZELY_CMS_SCHEMA
--client_id--ciThe CMS Service Client IDTaken from the environment variable OPTIMIZELY_CMS_CLIENT_ID
--client_secret--csThe CMS Service Client SecretTaken from the environment variable OPTIMIZELY_CMS_CLIENT_SECRET
--user_iduThe CMS User to impersonateTaken from the environment variable OPTIMIZELY_CMS_USER_ID
--verboseShow debugging output
--helpShow help text

2.2. Environment variables

This CLI tool shares the environment variables with @remkoj/optimizely-cms-api. When starting the CLI tool, it looks for .env and .env.local to extend the environment variables and thus works using the Next.JS conventions.

3. Available commands

The following commands are available, you can always run opti-cms --help or opti-cms [command] --help to see all information for the CLI utility or command. If the command is omitted, the CLI will assume the cms:version command.

3.1. General CMS Commands

CommandDescription
cms:versionFetch and display the version of the CMS from the endpoint, allowing validation of the connection with Optimizely CMS.
cms:resetReset the CMS instance by removing all Content, Content Types and Display Templates.
Note: This currently requires some manual steps, the CLI will provide the needed guidance on these manual steps.

3.2. JSON Schema's and Schema Validation

CommandDescription
schema:downloadDownload schema definitions into a .schema folder within your project to facilitate JSON Schema validation by your IDE of choice. Use one or more -s [schemaName] parameters to override the schemas that must be downloaded. The -d [relativePath] to change where the location where the schema files must be stored. Using -f enables overwriting of existing schema files.
schema:listDisplay a list of all schema's available within the Optimizely CMS instance.
schema:validateDownloads the OpenAPI Specification from the configured Optimizely CMS instance, extracts the appropriate types from it and uses those to validate all *.opti-style.json and *.opti-type.json files in the project. The output provides detailled error messages for each file that is not valid.
schema:vscodeUpdates the .vscode folder to include the JSON Schema for both Content Type defintions and Display Templates. This will also create or update the settings.json to enable code-completion and validation on *.opti-style.json and *.opti-type.json files, using these schema's. Rerun this command to ensure that the definitions remain in sync with the OpenAPI specification of the CMS API.

3.3. Display Templates (Styles)

CommandDescription
style:createCreate a new Style definition file (and optionally create it immediately within the CMS as well) using a CLI interface, that will guide you through the process of setting the required properties.
Visual Studio Code users: Running yarn opti-cms schema:vscode will enable VS-Code to provide validation and completion for the generated *.opti-style.json file.

3.4. Content Types

CommandDescription
types:pullRead all existing content types from the Optimizely CMS and create their representation within the codebase. Use the parameters of this method to control which types will be pulled and to allow overwriting of existing files.
types:pushCreate or overwrite the content type defintions from the codebase into Optimizely CMS, use the parameters of this method to control which types will be transferred and whether destructive changes are allowed.

3.5. Next.JS Project support

CommandDescription
nextjs:factoryGenerate the component factories needed for suggested implementation pattern of Optimizely CMS in Next.JS. See 4.1. Generate React Component Factory
nextjs:createAn conveniance command, that will run the appropriate commands from the CLI in the right order to fully scaffold a frontend based upon the Content Types and Display Templates that already exist within the Optimizely CMS instance.
It runs these commands: types:pull, styles:pull, nextjs:fragments nextjs:components, nextjs:visualbuilder and nextjs:factory. The command line arguments you provide to nextjs:create will be forwarded to each of these commands.

4. Detailed command descriptions

4.1. Generate React Component Factory

This is a companion method to the ComponentFactory / DefaultComponentFactory implementation within @remkoj/optimizely-cms-react that is used to resolve content types within Optimizely CMS into React Components. This method will create the needed files to easily construct the factory from the components in the frontend.

Usage & example

Command: nextjs:factory

yarn opti-cms nextjs:factory -f

Command line parameters

ParameterAliasUsageDefault
--excludeTypes--ectKey of content type to exclude. Can be used multiple times to exclude a list of content types[]
--excludeBaseTypes--ebtExclude all content types, with one of these base types. If provided it will replace the default. Add multiple times to build a list["folder","media","image","video"]
--baseTypes-bSelect only content types with one of these base types. Add multiple times to build a list[]
--types-tSelect content types with this key. Add multiple times to build a list[]
--all-aInclude non-supported base types, non supported base types are skipped by default
--force-fBy default, this method is none-destructive. Set this parameter to overwrite existing files.

Keywords

Optimizely CMS

FAQs

Package last updated on 29 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts