Skip to main content

Command Line Tool

Install the cli

To install cli, you should type:

$ npm install oc -g

Configure autocomplete

Autocomplete is supported for Mac and Linux.

To enable it in zsh, you should type:

echo '. <(oc completion)' >> .zshrc

To enable it in bash, you should type:

oc completion >> ~/.bashrc

or

oc completion >> ~/.bash_profile

After enabling autocomplete you should reload the shell.

Commands

Basic usage:

$ oc <command> [options]

Hint: Run -h with any command to show the help

For a list of all the available commands, ype oc in your terminal

$ oc

clean

Remove the node_modules directory from each component's subfolder

Usage:

$ oc clean <dirPath> [options]

Parameters:

NameDescriptionDefault
dirPathThe name of the directory where the components are stored

Options:

NameDescription
--yesSkip all confirmation prompts

Example:

$ oc clean ../all-components --yes

dev

Runs a local oc test registry in order to develop and test components

Usage:

$ oc dev <dirPath> [port] [baseUrl] [options]

Parameters:

NameDescriptionDefault
dirPathThe name of the directory to watch, where the components are stored
portThe port where to start a local oc instance.3000
baseUrlThe base url the component is hosted from.http://localhost:port/

Options:

NameDescriptionDefault
--fallbackRegistryUrlUrlUrl to another registry which will be used by dev registry when component cannot be found in local registryempty
--hotReloadingEnables hot reloading. Note: when hot reloading is set to true, each request to the component will make the registry to create a new instance for the javascript closures to be loaded, while when false the instance will be recycled between components executionstrue
--verboseVerbosityfalse
--watchenable the watchertrue
--productionforce packaging for productionfalse

Example:

$ oc dev ../all-components 3001 127.0.0.1:3001 --fallbackRegistryUrl=http://anotherhost:anotherport/

init

Creates a new empty component in the current folder

Usage:

$ oc init <componentPath> [templateType]

Parameters:

NameDescriptionDefault
componentPathThe relative path with a name of the component to create
templateTypeThe name of the published template module on npmoc-template-handlebars

Example:

$ oc init test-component oc-template-jade

or with using relative path:

$ oc init components/test-component oc-template-jade

which will create test-component in components directory.


mock

Allows to mock configuration in order to facilitate local development

Usage

$ oc mock <targetType> <targetName> <targetValue>

Parameters:

NameDescriptionDefault
targetTypeThe type of item to mock
targetNameThe item to mock
targetValueThe mocked value (static plugin) or the file to read (dynamic plugin)

Example:

$ oc mock plugin hash "always-returned-value"

Creates static mock for a "hash" plugin which always returns "always-returned-value" value

To run a dynamic plugin, you can run a plugin locally. This could be the same one running in your registry, or a mock js that behaves differently locally.

$ oc mock plugin <targetName> <path to mock .js>

package

Creates the packaged component ready to be published

Usage:

$ oc package <componentPath> [options]

Parameters:

NameDescriptionDefault
componentPathThe path of the component to package

Options:

NameDescriptionDefault
--compressCreate zipped filefalse
--useComponentDependenciesReuse already installed dependencies to save packaging time and network bandwidthfalse

Example:

$ oc publish my-new-component/

preview

Runs a test page consuming a component

Usage:

$ oc preview <componentHref>

Parameters:

NameDescriptionDefault
componentHrefThe name of the component to preview

Examples:

$ oc preview "http://localhost:3000/my-new-component/1.0.0/?param1=hello&name=Arthur"

publish

Publish a component

Usage:

$ oc publish <componentPath> [options]

Parameters:

NameDescriptionDefault
componentPathThe path of the component to publish

Options:

NameDescriptionDefault
--passwordpassword used to authenticate when publishing to registry
--usernameusername used to authenticate when publishing to registry
--skipPackageto skip packaging step (useful if you publish at a different stage than packaging)false
--registriesalternative to pass a list of registries directly on the command instead of a json
--dryRunIndicates that you don't want to publish the OC and only report if it's ready tofalse

Examples:

$ oc publish my-new-component/

registry

Shows, adds, removes oc registries to the current project

Usage:

$ oc registry <command>

Parameters:

NameDescriptionDefault
registryUrlurl of registry

Commands:

NameDescriptionDefault
add <registryUrl>Adds oc registries to the current project
lsShows oc registries added to the current project
remove <registryUrl>Removes oc registries from the current project

Examples:

$ oc registry add http://my-registry.in.my.domain/
$ oc registry ls
$ oc registry remove http://my-registry.in.my.domain/