Configure the OCP CLI
Install, test, and upgrade the Optimizely Connect Platform (OCP) command-line interface (CLI).
Development, management, and publication of an Optimizely Connect Platform (OCP) app is performed via the OCP command-line interface (CLI). Follow the steps below to configure and validate your CLI development environment.
Prerequisites
- You need the API key from your invitation email.
- The OCP CLI requires the Node.js 18 JavaScript runtime environment. Find your platform-specific installer here, or use your preferred Node version manager for the install.
- The OCP CLI requires Yarn. Find global install instructions for Yarn here. If you are on Windows, we suggest installing Yarn through Corepack, as described here.
Configure the OCP CLI
You can configure the OCP CLI on either a Mac/Linux machine or a Windows machine. Skip directly to the section that pertains to your environment.
Configure the OCP CLI for Mac/Linux
-
Run the following command to make a
.opti
directory:mkdir ~/.opti (home dir)
-
Using the API key you received during onboarding, create the credentials file in the
.opti
directory:echo '{"apiKey": "value from invitation"}' > ~/.opti/credentials.json
-
Run the following Yarn command to install the OCP CLI:
yarn global add @optimizely/opti-cli
-
Set your
PATH
variable:export PATH="$(yarn global bin):$PATH"
-
Set your
opti env
variable to production:opti env set production
Configure the OCP CLI for Windows
Note
The following instructions are for PowerShell.
-
Run the following command to make a
.opti
directory:New-Item -Path "~/.opti" -Name "home dir" -ItemType "directory"
-
Using the API key you received during onboarding, create the credentials file in the
.opti
directory:Write-Output '{"apiKey": "value from invitation"}' | out-file "~/.opti/credentials.json" -encoding utf8
-
Run the following Yarn command to install the OCP CLI:
yarn global add @optimizely/opti-cli
-
Ensure the value returned from
yarn global bin
is on your path:yarn global bin
Note
The output should look similar to the following:
C:\Users\user\AppData\Local\Yarn\bin
-
Set your current location to the path returned above:
Set-Location -Path "C:\Users\user\AppData\Local\Yarn\bin"
-
Set your
opti env
variable to production:.\opti env set production
Validate the OCP CLI installation
Now you can validate that the OCP CLI is installed correctly. At this point, the same OCP CLI commands work for both Mac/Linux and Windows.
Note
For Windows terminals (specifically PowerShell), you must use
.\
before allopti
commands. For example, to view your account details, run.\opti accounts whoami
.
View your account details
Run the following command to view your account details:
opti accounts whoami
Example output:
Active environment: production
id: <ID Removed>
email: [email protected]
role: developer
apps:
- id:
accounts:
- trackerId: <ID Removed>
shard: us
Get help and view your environment details
The help context for the OCP CLI is -h
. It provides help and information about your environment after any command. Run the following commands to view your environment details and see available commands.
View your environment details:
opti -h
Example output:
Active environment: production
@optimizely/opti-cli 1.0.0-beta.7 (Apache-2.0)
Usage: opti <command>
Namespaces: (`<namespace>` -h, --help for additional help)
accounts
app
availability
directory
env
View available commands:
opti app -h
Example output:
Active environment: production
@optimizely/opti-cli 1.0.0-beta.7 (Apache-2.0)
Usage: opti app <command>
Commands:
startDev, start-dev Run an app locally
init Create a new app project
logs Fetch app logs
package Prepare a package for manual upload
register Register an app version
upload Validate, package, upload, and build an app to prepare for publishing
validate Validate an app locally
opti <command> -h, --help for help on specific commands
Updated about 1 month ago