Shoutem CLI

Shoutem Command Line Interface (CLI) is a tool that helps you build extensions. Using it, you can create extensions, generate code snippets, upload extensions to your Shoutem account and install them on your applications.

Installation

Download and install Shoutem CLI through npm, the package manager for Node.js.

$ npm install -g @shoutem/cli

In case you don’t have npm installed, the best way to install it is with installing Node.js, which includes npm.

Commands

Here is the list of available commands.

  • shoutem

Lists all the commands.

$ shoutem
Usage: shoutem [command] [-h]

Commands:
...
  • shoutem [--version|-v]

Prints out the CLI version.

$ shoutem -v
1.0.0
  • shoutem <cmd> [--help|-h]

Prints help for command.

$ shoutem init -h

Usage: shoutem init <extension-name>

Create a scaffold of all files and folders required to build an extension.
  • shoutem login

Authenticates you as developer. Enter your Shoutem credentials. If you’re not a Shoutem user yet, sign up at www.shoutem.com.

$ shoutem login
Enter your Shoutem credentials:
E-mail: developer@example.com
Password: ********

Each Shoutem user can become Shoutem developer. If you still are not a developer, after you entered correct credentials, you’ll be prompted a new developer name.

Enter new developer name:
Name: david
You are registered as `david`!
  • shoutem logout

Logs you out from CLI.

$ shoutem logout
Successfully logged out.
  • shoutem init <extension-name>

Initializes extension project.

$ shoutem init example
Enter information about your extension. Press `return` to accept (default) values.

Title: Restaurants
Version: 0.0.1
Description: List of restaurants

Extension initialized!

After initialization, your extension folder structure will look as follows:

Restaurants/
  ├ app/
  |  ├ node_modules/
  |  |  └ ...
  |  ├ const.js
  |  ├ index.js
  |  └ package.json
  ├ server/
  |  ├ node_modules/
  |  |  └ ...
  |  ├ index.js
  |  └ package.json
  └ extension.json

Run this command from extension folder.

  • shoutem push

Pushes extension to Shoutem server.

$ shoutem push
Uploading `Restaurants` extension to Shoutem...
Success!

As long as extension is not published, every push will overwrite current development version of extension. Once you publish extension, that version of extension will be unchangeable and you will be able to push only higher version numbers.

Run this command from extension folder.

  • shoutem publish

Publishes extension to Shoutem server.

$ shoutem publish
Publishing `Restaurants` extension to Shoutem...
Version `0.0.1` is successfully published!

Run this command from extension folder.

  • shoutem install [--new|--app=<app-id>]

Installs extension to the app. If no flags or arguments are passed, CLI will offer interactive menu.

$ shoutem install
Select app to install your extension:
> RestaurantsApp
  --------------
  Create a new app

Pass a flag --new to install it on a new app.

$ shoutem install --new
Installing `Restaurnats` extension to the new app...
Extension successfully installed to the new app. Check it here:
https://builder.shoutem.com/app/5128

Also, you can install it on specific app by providing app id, found in app settings:

$ shoutem install --app=5127
Installing `Restaurnats` extension to `Restaurants` app...
Extension successfully installed to the app. Check it here:
https://builder.shoutem.com/app/5127

Installation can be done through builder as well.

  • shoutem shortcut add <shortcut-name> [--screen=<screen-name>]

Adds shortcut to the extension.

$ shoutem shortcut add RestaurantsList
Enter shortcut information:
Title: RestaurantsList
Description: 
Shortcut `RestaurantsList` is created!
File `extension.json` was modified.

Pass --screen option with screen name as value, to create a screen and connect it with new shortcut in extension.json.

$ shoutem shortcut add RestaurantsList --screen=List
Enter shorcut information:
Title: RestaurantsList
Description:
Shortcut `RestaurantsList` is created!
Screen `List` is created in file `app/screens/List.js`!
Shortcut and screen are connected.
File `extension.json` was modified.
File `app/extensions.js` was modified.

Run this command from extension folder.

  • shoutem screen add <screen-name>

Adds screen to the extension.

$ shoutem screen add List
Screen `List` is created in file `app/screens/List.js`!
File `extension.json` was modified.
File `app/extensions.js` was modified.

Run this command from extension folder.

  • shoutem schema add <schema-name>

Adds schema to the extension.

$ shoutem schema add Restaurants
Schema `Restaurants` is created in file `server/schemas/Restaurants.json`!
File `extension.json` was modified.

Run this command from extension folder.

  • shoutem theme add <theme-name>

Adds theme to the extension.

$ shoutem theme add Argo
Theme `Argo` is created in file `app/themes/Argo.js`.
Variables for the theme are created in file `server/themes/ArgoVariables.json`
File `extension.json` was modified.

Run this command from extension folder.

  • shoutem env install

Installs environment for local extension development.

$ shoutem env install
Downloading environment v1.0.0...
Mobile app downloaded, installing dependencies...
...
Mobile environment v1.0.0 installation complete. Now you can use `shoutem run-ios` or `shoutem run-android`!

This command is also used to update the environment.

Connects local extension to the app for local development.

$ shoutem env link
Extension is successfully linked!
$ shoutem env unlink
Extension is successfully unlinked!
  • shoutem env show

Logs the version of environment used.

$ shoutem env show
Mobile environment version: v1.0.0
Shoutem app used: None.
Local extensions linked: None.
  • shoutem run-ios [app-id]

Runs application with app-id ID locally on the iOS simulator. Setup iOS environment for React Native before.

$ shoutem run-ios 1234
Running iOS application 1234...
...

On consecutive attempts, app-id argument is not needed.

  • shoutem run-android [app-id]

Runs application with app-id ID locally on the Android emulator. Setup Android environment for React Native before.

Running Android application 1234...
...

On consecutive attempts, app-id argument is not needed.

  • shoutem pack

Packs the extension. This command is used by shoutem push and with it, you can check how your extensions looks like when it’s pushed to Shoutem servers.

$ shoutem pack
Extension is successfully packed!

Find the extension packed in the root of the extension folder.