CLI tools to streamline Team Opti's Optimizely workflow.
- Installed
pnpmandnode. - MacOS or Unix-based command-line shell
Either clone the repository and install it from there or install it directly from releases.
Install latest version:
# --force flag ensures pnpm cache busting and pulling lates release
pnpm add -g --force https://github.com/bouvet/opti-cli/releases/latest/download/opti-cli.tgz
# check installation:
opti --versionInstall specific version:
pnpm add -g --force https://github.com/bouvet/opti-cli/archive/refs/tags/vX.X.X.tar.gzUninstall:
pnpm remove -g @bouvet/opti-cliClone the repository, install dependencies and install the cli:
pnpm install
pnpm cli:installUninstall:
pnpm cli:uninstallTo start using opti-cli with your Optimizely project, initialize a project config in the root of your project's repo:
# in root of your repo, or wherever inside your project that suits you
$ opti initThis creates a directory .opti where all opti-cli related configs and files exist.
Run this command in all your Optimizely projects where you want to use opti-cli.
💡 Remember to push your updated
.gitignore
In terminal, run opti followed by command. To get a list of commands, run opti -h. To view current project settings, run opti config.
Download a database through the DXP portal, and place the resulting .bacpac file in the .opti/bacpac directory of your Optimizely project.
Run the database import wizard and follow the steps:
$ opti dbThis creates a docker-compose.yml file in the .opti directory and starts a container stack in Docker which runs your database. The database is then imported using the dotnet cli and sqlpackage. Your selected appsettings.json in updated with the new connection string.
There are a lot of commands associated with the opti db command, to list them:
$ opti db --helpThe main ones are:
$ opti db # do a full database setup and import
$ opti db clean # create copy of database with redundant tables removed
$ opti db import # redo import with previously selected .bacpac
$ opti db apply # re-apply connection string to appsettingsIf you have a lot of profiles in launchSettings.json, opti watch lets you pick between them. Use the -d flag to pin picked option as default to run in the future.
$ opti watch
$ opti watch --default # use selected profile as default
$ opti watch --profile <profile> # use this profile bypassing the wizard and defaultOpti clean tries to completely clean the project build files by rm -rf the obj, bin and modules directories and rebuilds project by running dotnet clean, dotnet restore and dotnet build.
$ opti cleanAdding a command can be done by running the below command which generates a new one from a template.
pnpm commands:add <name of command>To exit excecution early, use the global quit() function. This is the same as using process.exit.
*** Could not allocate a new page for database '[database]' because the 'PRIMARY' filegroup is full due to lack of storage space or database files reaching the maximum allowed size.This error occurs when Docker does not have enough storage allocated. Can be fixed by going into docker settings and increasing the limit, or removing large tables using opti db clean.
To increase Docker storage limit:
Docker -> settings -> resources -> Disk usage limit