🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@remkoj/optimizely-cms-cli

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remkoj/optimizely-cms-cli

Optimizely CMS CLI Tools

npmnpm
Version
6.0.0-pre5
Version published
Weekly downloads
1.1K
-16.72%
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

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

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.

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.
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.
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.
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.
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.
nextjs:factoryGenerate the component factories needed for suggested implementation pattern of Optimizely CMS in Next.JS. See 3.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.

3.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.

FAQs

Package last updated on 11 Jul 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