Configure your OCP development environment
Configure the development environment needed for building custom apps for Optimizely Connect Platform (OCP).
Develop, manage, and publish an Optimizely Connect Platform (OCP) app using the OCP command-line interface (CLI). Configure the OCP CLI on a Mac or Linux machine or a Windows machine. Skip to the section that pertains to your environment.
NoteIf you are migrating from OCP CLI v1, see the OCP CLI v2 migration guide for instructions on uninstalling v1 and upgrading to v2.
Prerequisites
- An OCP developer account.
- The API key from your invitation email. See step two in Getting Started for information.
- Node.js 22+ JavaScript runtime environment, required for app development. Find your platform-specific installer on the Node.js site, or use your preferred Node version manager for the installation.
- A package manager for app development. Apps running Node.js 22+ support Yarn, Yarn Berry, npm, pnpm, and Bun. Apps on Node.js runtimes earlier than version 22 require Yarn 1. See the Yarn global installation instructions or, if you are on Windows, install Yarn through Corepack.
Note
If your app uses Node.js 22+ and you want to migrate from Yarn 1 to a different package manager, see the Package manager migration guide.
- The OCP CLI requires Git to build an app. See the Git global installation instructions.
Note
If you are not planning to build an app, you can skip the Git install.
Configure the OCP CLI for Mac or Linux
-
Run the following command to make a
.ocpdirectory:mkdir ~/.ocp (home dir) -
Create the credentials file in the
.ocpdirectory using the API key you received during onboarding:echo '{"apiKey": "<value-from-invitation>"}' > ~/.ocp/credentials.json -
Run the following script to install the OCP CLI:
curl -fsSL https://cli.ocp.optimizely.com/install.sh | bashThe script downloads the latest OCP CLI release, verifies the tarball checksum, installs it to
~/.local/share/ocp. It also adds theocpbinary to yourPATH. The CLI ships with its own runtime, so it operates independently of any local Node.js installation.
Configure the OCP CLI for Windows
NoteThe following instructions are for PowerShell.
-
Run the following command to make a
.ocpdirectory:New-Item -Path "~/.ocp" -Name "home dir" -ItemType "directory" -
Create the credentials file in the
.ocpdirectory using the API key you received during onboarding:Write-Output '{"apiKey": "<value-from-invitation>"}' | out-file "~/.ocp/credentials.json" -encoding utf8 -
Run the following PowerShell script to install the OCP CLI:
iwr -useb https://cli.ocp.optimizely.com/install.ps1 | iexThe script downloads the latest OCP CLI release, verifies the tarball checksum, installs it to
$env:LOCALAPPDATA\ocp, and adds theocpbinary to yourPATH. The CLI ships with its own runtime, so it operates independently of any local Node.js installation.
Test your OCP CLI configuration
Verify your OCP CLI configuration by running the following command:
ocp accounts whoamiThe results look similar to the following:
$ ocp accounts whoami
id: e1006b36-183e-4951-912c-416012f5a882
email: [email protected]
role: developer
githubUsername: jonhsmith
accounts:
- 7b5d1518a0be
personal_apps: []
vendor: mycompany
vendor_apps: []Run OCP CLI commands using npx
npxYou can also run OCP CLI commands directly using npx, without requiring any installation. However, ensure your shell has the correct Node.js runtime version for the application to function as expected. See the following example:
npx @optimizely/ocp-cli-v2 app init
npx @optimizely/ocp-cli-v2 app validate
npx @optimizely/ocp-cli-v2 app package(Optional) Configure OCP autocomplete
The OCP CLI supports shell autocomplete for Bash, Zsh, and PowerShell 7+. To configure autocomplete, run the following command and follow the instructions displayed in the terminal:
ocp autocompleteRestart your shell or source the relevant configuration file after configuration. Press Tab while entering an ocp command to autocomplete commands and subcommands. To autocomplete flags, enter - and press Tab. Press Tab twice to display all available options for the current input.
Autocomplete dynamic values
Autocomplete suggests values for command arguments and flags fetched from your account. After setting up autocomplete, press Tab at the position where a value is expected:
| Example | What Tab suggests |
|---|---|
ocp directory list-installs <Tab> | App IDs you have access to |
ocp directory publish my_app@<Tab> | Versions of my_app (type @ to switch from app names to that app's versions) |
ocp jobs list --appId <Tab> --appVersion <Tab> | App versions for the given app |
ocp app set-log-level [email protected] <Tab> | Valid log levels |
ocp jobs list <appId> --status=<Tab> --version=<Tab> | Supported job statuses and versions for the app |
ocp ... -a <Tab> | Availability shards (us, eu, etc.) |
Static option lists, such as log levels, job statuses, environments, and sort directions, are always available. Dynamic values, such as app IDs or versions, are fetched from the platform on first use and cached locally so subsequent Tab presses are instant.
Refresh the autocomplete cache
The autocomplete cache is refreshed automatically in the background after ocp autocomplete is run. If you registered a new app or published a new version and want it to display immediately in suggestions, refresh the cache manually:
ocp autocomplete --refresh-cache
NoteIf a refresh fails (for example, due to a network issue), the cache retains its stored values so autocomplete continues to work with the most recent known data. Any entries that were not refreshed are listed at the end of the command's output.
Local development server
The OCP CLI includes a built-in local development server that helps you develop and test your apps locally before publishing. Start the local development server with:
# Quick start (recommended)
ocp dev
# With additional configuration options
ocp dev-server start --port=3001 --verbose
NoteThe local development server is available through the OCP CLI. For additional configuration options, use
ocp dev-server start --help.
For detailed usage instructions, see Test your app locally.
OCP CLI commands
Commands are grouped into namespaces.
$ ocp -h
Usage: ocp <command>
Namespaces: (`<namespace>` -h, --help for additional help)
accounts
app
availability
dev-server
directory
env
jobs
review
Commands:
autocomplete Display autocomplete installation instructions
dev Start the local development server for OCP apps
update Update the OCP CLIRun the help command, -h or --help, to list commands in a namespace. See the following example:
$ ocp app -h
Usage: ocp app <command>
Commands:
init Create a new app project
logs Fetch app logs
package Prepare a package for manual upload
prepare Validate, package, upload and build an app to prepare for publishing
register Register an app version
validate Validate an app locally
ocp <command> -h, --help for help on specific commandsAdding the help context on a command displays documentation for the command with all available options. See the following example:
$ ocp app prepare -h
Usage: ocp app prepare [<path>] [--noProgress | --no-progress] [--upgradeDeps | --upgrade-deps] [--publish] [--usePreviousAppEnvValues | --use-previous-app-env-values] [--bumpDevVersion | --bump-dev-version]
Parameters:
path The root directory of the app
Flags:
--noProgress, --no-progress Don't display any progress indicators
--upgradeDeps, --upgrade-deps Automatically update dependencies
--publish Automatically publish if the upload is successful
--usePreviousAppEnvValues Use app env values (.env file) from the previous version of the app.
Any values in local .env file are ignored
--bumpDevVersion Bump dev version before building. Allows quickly testing dev versionsFor the full list of OCP CLI commands, namespaces, flags, and options, see the OCP CLI command reference.
Uninstall OCP CLI
If you want to completely remove OCP CLI from your system, run the following script for MacOS or Linux:
rm -rf ~/.local/share/ocp ~/.local/bin/ocpRun the following script for Windows:
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\ocp"