Documentation
CLI

Anchor link Overview

DADI CLI is a command-line tool to help with the installation and customisation of the various products of the DADI platform.

Anchor link Programmatic vs. interactive mode

Each command requires its own set of parameters – for example, a command for installing a new version of DADI Web will need to know which template engines to install, whereas creating a new API client requires a client ID and a secret.

To provide an optimal experience for both programmatic uses, where a command is executed as part of an automated script, and for actual people running commands in their terminal, CLI applies this principle to every command: there is a flag accepted by the command for every parameter required, which when absent will be prompted to the user using an interactive mode.

Anchor link Requirements

To install some DADI web services, you may also need Git installed on your machine.

Anchor link Usage

Running npx dadi-cli help displays a usage summary:

Usage: npx dadi-cli <command>

where <command> is one of:
  api clients:add      Creates a new client
  api new              Creates a new instance of DADI API
  api setup            Launches an interactive setup wizard

  cdn new              Creates a new instance of DADI CDN
  cdn setup            Launches an interactive setup wizard

  web new              Creates a new instance of DADI Web

--

Type npx dadi-cli help <command> to learn more about a specific command.

Commands begin with the name of the DADI application they apply to. For example, npx dadi-cli api new will install a new instance of API, whilst its CDN counterpart is npx dadi-cli cdn new.

Anchor link API commands

Running npx dadi-cli help api will show a list of all the API-related commands:

Usage: npx dadi-cli api <command>

where <command> is one of:
  clients:add          Creates a new client
  new                  Creates a new instance of DADI API
  setup                Launches an interactive setup wizard

--

Type npx dadi-cli help api <command> to learn more about a specific command.

Anchor link api clients:add

Running npx dadi-cli help api clients:add will show the following details for the command:

Usage: npx dadi-cli api clients:add --id=<id> --secret=<secret>

Creates a new client

Available parameters:

id                     the client ID
secret                 the client secret

This command will create a new oAuth client. It requires two parameters: the client ID and secret, which can be passed using the --id and --secret flags or using the interactive mode.

Anchor link api new

Running npx dadi-cli help api new will show the following details for the command:

Usage: npx dadi-cli api new <directory> --version

Creates a new instance of DADI API

Available parameters:

directory              the name of the directory where DADI
                       API will be installed
version                the version of API to install
                       (defaults to latest)

This command will create a new instance of DADI API. If a name parameter is supplied, API will be installed in a subdirectory of the current directory, using the value supplied for name. If a name parameter is not supplied, API will be installed in the current directory.

In both cases, a warning will be shown when trying to install API on a non-empty directory.

? The target directory (/Users/johndoe/existing-directory) is not empty. Would you like to proceed? (y/N)

If the version parameter is supplied, its value defines the version of CDN that will be installed. If not, the latest available version is used. An error is shown when the value of version doesn’t match a valid version of CDN.

✖ 8.3 is not a valid version. Available versions: 1.5.x, 2.2.x

Anchor link CDN commands

Running npx dadi-cli help cdn will show a list of all the API-related commands:

Usage: npx dadi-cli cdn <command>

where <command> is one of:
  new                  Creates a new instance of DADI CDN
  setup                Launches an interactive setup wizard

--

Type npx dadi-cli help cdn <command> to learn more about a specific command.

Anchor link cdn new

Running npx dadi-cli help cdn new will show the following details for the command:

Usage: npx dadi-cli cdn new <name> --skip-setup --version

Creates a new instance of DADI CDN

Available parameters:

name                   the name of the DADI CDN instance
skip-setup             skips the interactive setup guide
version                the version of CDN to install
                       (defaults to latest)

This command will create a new instance of DADI CDN. If a name parameter is supplied, CDN will be installed in a subdirectory of the current directory, using the value supplied for name. If a name parameter is not supplied, CDN will be installed in the current directory.

In both cases, a warning will be shown when trying to install CDN in a non-empty directory.

? The target directory (/Users/johndoe/existing-directory) is not empty. Would you like to proceed? (y/N)

If the version parameter is supplied, its value defines the version of CDN that will be installed. If not, the latest available version is used. An error is shown when the value of version doesn’t match a valid version of CDN.

By default, this command is succeeded by an interactive setup wizard, where the user is guided through a series of questions used to generate a configuration file. This step can be skipped by appending the --skip-setup parameter to the command.

Anchor link cdn setup

This command will launch an interactive setup wizard, which guides users through a series of questions to form a configuration file.

It must be executed from a directory where an instance of DADI CDN is installed.


  ▓▓▓▓▓  ▓▓▓▓▓▓▓
              ▓▓▓▓
     ▓▓▓▓▓▓▓    ▓▓▓▓
              ▓▓▓▓
          ▓▓▓▓▓▓▓


    DADI CDN setup

Let's start by configuring the web server that DADI CDN will run on. (0% complete)

? What is the name of this CDN instance? My new CDN
? What protocol should this CDN instance run on? HTTP (insecure)
? What is the IP address the application should run on? 0.0.0.0
? What is the port number the application should run on? 8080

Time to configure the sources that CDN will use to retrieve images. (18% complete)

? Would you like to load images from the local filesystem? (y/N)

Anchor link Web commands

Running npx dadi-cli help web will show a list of all the API-related commands:

Usage: npx dadi-cli web <command>

where <command> is one of:
  new                  Creates a new instance of DADI Web

--

Type npx dadi-cli help web <command> to learn more about a specific command.

Anchor link web new

Running npx dadi-cli help web new will show the following details for the command:

Usage: npx dadi-cli web new <name> --engine --version

Creates a new instance of DADI Web

Available parameters:

name                   the name of the DADI Web instance
engine                 name of a template engine interface
                       NPM module (for versions >= 3.x)
version                the version of Web to install
                       (defaults to latest)

This command will create a new instance of DADI Web. If a name parameter is supplied, Web will be installed in a subdirectory of the current directory, using the value supplied for name. If a name parameter is not supplied, Web will be installed in the current directory.

In both cases, a warning will be shown when trying to install Web in a non-empty directory.

? The target directory (/Users/johndoe/existing-directory) is not empty. Would you like to proceed? (y/N)

If the version parameter is supplied, its value defines the version of Web that will be installed. If not, the latest available version is used. An error is shown when the value of version doesn’t match a valid version of Web.

This command also allows users to choose which template engines they’d like to use with their instance of Web. The --engine parameter accepts a list of npm modules to use as engines.

The following command installs the latest version of Web on a subdirectory called my-new-website and installs the Dust.js and Pug.js template engines:

$ npx dadi-cli web new my-new-website --engine=@dadi/web-dustjs --engine=@dadi/web-pugjs

If this parameter is not supplied, CLI will go into interactive mode and ask the user to choose which engines to install from a list of available engines, pulled from NPM.