Workspace commands and scripts

The OSF workspace includes commands and scripts that you use to build, deploy, and manage the lifecycle of storefront applications.

This section describes the OSF commands and scripts and how they are used.

Commands

The OSF commands are found in the node_modules/.bin subdirectory of the workspace. The commands all begin with occ and accept flags for specifying options. For example, the following command deploys the specified application without performing a build:

occ deploy my-storefront --no-build

Some of the flags take arguments. For example, the following command specifies the URL of the administration server to deploy the application to:

occ deploy my-storefront –-appServerAdmin https://ccstore-1234.oracleoutsourcing.com:9080

The following table summarizes the available commands:

Command Description
build Build an OSF application
configure Update the configuration of a workspace
configure-app Update the configuration of an application
create-action Create an action for an application
create-endpoint Create an endpoint from a Swagger document or a URL
create-fetcher Create a fetcher for an application
create-template Create a workspace template archive containing the application
create-widget Create a widget plug-in for an application
delete Delete an OSF application from the specified server
deploy Deploy an OSF application
deploy-log Query the deployment logs for an application
deploy-status Query the deployment status of an application
download Download the current deployment of an application to the workspace
download-assets Download design assets from a server to the workspace
list-apps List the applications on a server
list-endpoints List all of the endpoints in a Swagger document
output Generate the deployment files for the application
redeploy Resend a deployment to a cluster
serve Start a presentation server
set-logging-options Set the logging options for a cluster
upgrade Update the versions of OSF packages in a workspace
upload-custom-typeahead-keywords Upload custom keywords for typeahead search
upload-search-config Upload the search configuration for an application

You can also see a complete list of the occ commands by entering the following command:

occ –-help

To see a help page about the syntax of an individual command and the options it supports, enter the command with the --help flag. For example:

occ list-apps –-help

The response is similar to the following:

Usage: cli list-apps [options]

List the applications that are on the server.

Options:
  --json                  Output the results as raw JSON instead of formatted text.
  -V, --version           output the version number
  --verbose               Provides verbose logging where available
  --no-verbose            Disables verbose logging
  --appKey [key]          With this option you will be prompted for an application key (OAuth access token)
  --appServer <url>       Application server URL
  --appServerAdmin <url>  Application admin server URL
  --serverEnv <env>       Cloud Commerce server environment to use
  -h, --help              display help for command

Access the commands

Each workspace has its own version of the CLI. If you have multiple workspaces, you must use the version of the CLI associated with the workspace you are currently working in. To ensure that you access the correct version of the CLI, preface the commands with yarn and invoke the command from within the workspace.

For example, suppose you want to invoke the following command:

occ deploy my-storefront --no-build

Instead, enter the following from anywhere in the workspace you are working in:

yarn occ deploy my-storefront --no-build

When you call an occ command this way, Yarn uses Node.js module resolution to ensure that the correct version is executed.

Scripts

In addition to the occ commands, the workspace provides several scripts that can also be run from the command line. These scripts are defined in the scripts object of the package.json file in the top-level directory of the workspace. For example:

"scripts": {
    "stylelint": "stylelint **/*.css --ignore-disables",
    "eslint": "eslint .",
    "eslint:fix": "eslint --fix .",
    "prettier:fix": "prettier --config .prettierrc.js --write \"{packages,qa}/**/*.js\"",
    "lint": "yarn eslint && yarn stylelint",
    "build:prod": "occ build --production",
    "build": "occ build --watch",
    "test:int": "jest -c jest.config.int.js",
    "test:int:debug": "node --inspect-brk node_modules/jest/bin/jest.js -i -c jest.config.int.js",
    "test": "jest -c jest.config.js",
    "test:debug": "node --inspect-brk node_modules/jest/bin/jest.js -i -c jest.config.js",
    "test:api": "jest -c jest.config.api.js",
    "test:api:debug": "node --inspect-brk node_modules/jest/bin/jest.js -i -c jest.config.api.js",
    "perf": "jest -i -c jest.config.perf.js",
    "perf:lighthouse": "jest -i -c jest.config.perf.lighthouse.js",
    "perf:wpt": "jest -i -c jest.config.perf.wpt.js",
    "perf:debug": "node --inspect-brk node_modules/jest/bin/jest.js -i -c jest.config.perf.js",
    "deploy": "occ deploy",
    "delete": "occ delete",
    "download": "occ download",
    "output": "occ output",
    "seed": "yarn deploy --reset --publish",
    "start:prod": "occ serve",
    "start": "nodemon --inspect node_modules/@oracle-cx-commerce/cli/cli.js serve",
    "configure": "occ configure",
    "deploy-status": "occ deploy-status",
    "deploy-log": "occ deploy-log",
    "redeploy": "occ redeploy",
    "download-assets": "occ download-assets",
    "upload-search-config": "occ upload-search-config",
    "upload-demo-search-keywords": "occ upload-demo-search-keywords",
    "list-apps": "occ list-apps"
}

Each entry in the scripts object consists of a Yarn command and the value it maps to. So, for example, suppose you enter this command:

yarn build:prod

This is equivalent to the following:

yarn occ build --production

As you can see, many of the scripts are equivalent to occ commands.

You can also display a complete list of the scripts, and select one to run, by entering the following command:

yarn run

The Yarn scripts use Node.js module resolution to locate the commands they call. This ensures that as long as a script is called from within a workspace, it will find the version of the command that is appropriate for that workspace.