HomeGuidesAPI ReferenceGraphQL
Submit Documentation FeedbackJoin Developer CommunityLog In

Setting Up The OCP Development Environment

This topic describes how to install, test, and upgrade the Optimizely Connect Platform (OCP) CLI.

Development, management, and publication of an OCP app is performed via the OCP CLI. Follow the steps below to set up and validate the CLI development environment.

Prerequisites

You will need the API key from your invitation email to complete the environment setup.

Install Required Libraries:

Install Node.js

  1. OCP apps run on Node12. Fetch your platform specific installer here or use your favorite Node version manager for the install.

Install Yarn

  1. Install Yarn globally for your platform. If you are on Windows, we suggest installing Yarn through Corepack, as described here.

Setup the opti-cli

  1. Make a .opti directory:
$ mkdir ~/.opti (home dir)
  1. Create the credentials file with the api key you received in the invitation email in the .opti directory:
$ echo '{"apiKey": "value from invitation"}' > ~/.opti/credentials.json
  1. Use Yarn to install the cli:
$ yarn global add @optimizely/opti-cli
  1. For Windows users, ensure the value returned from $ yarn global bin is on your path:
$ yarn global bin
$ C:\Users\user\AppData\Local\Yarn\bin
  1. For MAC users, set your PATH variable:
$ export PATH="$(yarn global bin):$PATH"
  1. Set your opti environment variable to production:
$ opti env set production

Validate the CLI Installation

  1. Validate your account with opti accounts whoami:
$ opti accounts whoami
Active environment: production
id: 'ID Removed'
email: [email protected]
role: developer
apps:
  - id: 
accounts:
  - trackerId: 'ID Removed"
    shard: us
  1. Validate your environment with opti -h:
$ opti -h
Active environment: production
@optimizely/opti-cli  1.0.0-alpha.8  (Apache-2.0)
Usage: opti <command>

Namespaces: (`<namespace>` -h, --help for additional help)
  accounts
  app
  directory
  env

Get Help

-h is the help context for the CLI. You can find the most current refernece of available functionality by including -h at the end of your command:

PS C:\Source Code> opti -h
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
PS C:\Source Code> opti app -h
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
PS C:\Source Code>

Did this page help you?