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

preview
npmnpm
Version
6.0.0-rc.1
Version published
Weekly downloads
1.2K
-18.66%
Maintainers
1
Weekly downloads
 
Created
Source

Optimizely CMS Command Line Toolkit

[!WARNING] There'll be an update of Optimizely SaaS CMS that is incompatible with all SDK versions prior to 5.1.6. If you don't upgrade, you will see empty pages (main website) and "Component not found" messages (preview).

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 currently available in src/commands. Use yarn opti-cms [command] --help for runtime help.

All commands also support the global parameters.

cms:*

CommandDescriptionUsage
cms:resetCompletely clear & reset the CMS Databaseyarn opti-cms cms:reset
cms:versionGet the CMS Version informationyarn opti-cms cms:version

project:*

CommandDescriptionUsage
project:migrateAutomate the directory naming convention updateyarn opti-cms project:migrate

nextjs:*

CommandDescriptionUsage
nextjs:componentsCreate the React Components for a Next.JS / Optimizely Graph structureyarn opti-cms nextjs:components
nextjs:createScaffold a complete Next.JS / Optimizely Graph structureyarn opti-cms nextjs:create
nextjs:factoryCreate the ComponentFactory for a Next.JS / Optimizely Graph structureyarn opti-cms nextjs:factory
nextjs:fragmentsCreate the GrapQL Fragments for a Next.JS / Optimizely Graph structureyarn opti-cms nextjs:fragments
nextjs:queriesCreate the GrapQL Queries to use two queries to load contentyarn opti-cms nextjs:queries
nextjs:visualbuilderCreate the React Components for Visual Builder in a Next.JS / Optimizely Graph structureyarn opti-cms nextjs:visualbuilder

schema:*

CommandDescriptionUsage
schema:downloadCreate JSON schema files for selected typesyarn opti-cms schema:download
schema:listList all schema's that are available within the SaaS CMS instanceyarn opti-cms schema:list
schema:validateValidate the opti-type.json & opti-style.json filesyarn opti-cms schema:validate
schema:vscodeConfigure schema validation for opti-type.json & opti-style.json files by VSCodeyarn opti-cms schema:vscode

style* and styles:*

CommandDescriptionUsage
style:createCreate a new style definitionyarn opti-cms style:create
styles:deleteRemove Visual Builder style definitions from the CMSyarn opti-cms styles:delete
styles:listList Visual Builder style definitions from the CMSyarn opti-cms styles:list
styles:pullCreate Visual Builder style definitions from the CMSyarn opti-cms styles:pull
styles:pushPush Visual Builder style definitions into the CMS (create/replace)yarn opti-cms styles:push

types:*

CommandDescriptionUsage
types:pullPull content type definition files into the projectyarn opti-cms types:pull
types:pushPush content type definition into Optimizely CMS (create / replace)yarn opti-cms types:push

cms:reset

Description: Completely clear & reset the CMS database.

Usage:

yarn opti-cms cms:reset

Parameters: no command-specific parameters (global parameters still apply).

cms:version

Description: Get CMS version and service info.

Usage:

yarn opti-cms cms:version

Parameters: no command-specific parameters (global parameters still apply).

project:migrate

Description: Rename folders/files to match the updated naming conventions and regenerate factories.

Usage:

yarn opti-cms project:migrate [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys while preparing context
--excludeBaseTypes--ebtYes[]Exclude content base types while preparing context
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content types
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite generated files where applicable

nextjs:components

Description: Generate React component stubs for selected content types.

Usage:

yarn opti-cms nextjs:components [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing files

nextjs:create

Description: Run the full Next.js scaffold flow from CMS definitions.

Usage:

yarn opti-cms nextjs:create [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing generated files

nextjs:factory

Description: Generate component factory files.

Usage:

yarn opti-cms nextjs:factory [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing generated files

nextjs:fragments

Description: Generate GraphQL fragments for selected content types.

Usage:

yarn opti-cms nextjs:fragments [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing generated files

nextjs:queries

Description: Generate GraphQL queries (defaults to page/experience base types).

Usage:

yarn opti-cms nextjs:queries [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes['page','experience']Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing generated files

nextjs:visualbuilder

Description: Generate Visual Builder components and node templates.

Usage:

yarn opti-cms nextjs:visualbuilder [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing generated files

schema:download

Description: Download JSON schema files from the CMS OpenAPI specification.

Usage:

yarn opti-cms schema:download [options]
ParameterAliasOptionalDefaultUsage
--schemaDir-dYes'./.schema'Target schema directory relative to project root
--schemas-sYes['DisplayTemplate','ContentType']Schema names to download
--force-fYesfalseOverwrite existing schema files

schema:list

Description: List schemas exposed by the CMS OpenAPI specification.

Usage:

yarn opti-cms schema:list

Parameters: no command-specific parameters (global parameters still apply).

schema:validate

Description: Validate *.opti-type.json and *.opti-style.json files against CMS schemas.

Usage:

yarn opti-cms schema:validate

Parameters: no command-specific parameters (global parameters still apply).

schema:vscode

Description: Configure VS Code schema mappings for Optimizely type/style JSON files.

Usage:

yarn opti-cms schema:vscode

Parameters: no command-specific parameters (global parameters still apply).

style:create

Description: Interactive wizard to create a new style definition.

Usage:

yarn opti-cms style:create

Parameters: no command-specific parameters (global parameters still apply).

styles:delete

Description: Delete display templates from CMS and optionally update/remove local files.

Usage:

yarn opti-cms styles:delete [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--excludeNodeTypes--entYes[]Exclude node types
--excludeTemplates--etYes['folder','media','image','video']Exclude style template keys
--nodes-nYes[]Include only selected node types
--templates-dYes[]Include only selected templates
--templateTypes--ttYes[]Include only selected template types (node,base,component)
--force-fYesfalseExecute deletion (otherwise preview)
--withStyleFile-wYestrueDelete local *.opti-style.json files
--definitions-uYestrueUpdate/remove generated TypeScript display template definitions

styles:list

Description: List display templates from CMS.

Usage:

yarn opti-cms styles:list

Parameters: no command-specific parameters (global parameters still apply).

styles:pull

Description: Pull display templates from CMS and generate style files/helpers.

Usage:

yarn opti-cms styles:pull [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--excludeNodeTypes--entYes[]Exclude node types
--excludeTemplates--etYes['folder','media','image','video']Exclude style template keys
--nodes-nYes[]Include only selected node types
--templates-dYes[]Include only selected templates
--templateTypes--ttYes[]Include only selected template types (node,base,component)
--force-fYesfalseOverwrite existing files
--definitions-uYestrueCreate/update generated TypeScript display template definitions

styles:push

Description: Push local style definitions into CMS.

Usage:

yarn opti-cms styles:push [options]
ParameterAliasOptionalDefaultUsage
--excludeTemplates-eYes[]Exclude template keys from push
--templates-tYes[]Include only selected template keys

types:pull

Description: Pull content type definitions from CMS to local files.

Usage:

yarn opti-cms types:pull [options]
ParameterAliasOptionalDefaultUsage
--excludeTypes--ectYes['folder','media','image','video']Exclude content type keys
--excludeBaseTypes--ebtYes[]Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys
--all-aYesfalseInclude unsupported base types
--force-fYesfalseOverwrite existing files

types:push

Description: Push local content type definitions to CMS.

Usage:

yarn opti-cms types:push [options]
ParameterAliasOptionalDefaultUsage
--force-fYesfalseOverwrite/replace while pushing
--excludeTypes--ectYes[]Exclude content type keys
--excludeBaseTypes--ebtYes['folder','media','image','video']Exclude content base types
--baseTypes-bYes[]Include only selected base types
--types-tYes[]Include only selected content type keys

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 23 Mar 2026

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