# Command Line Interface

# Purpose

The Darwin Command Line Interface was created for automation. Currently, you can deploy a version of your website from the command line. You can also setup a continuous integration flow with GitHub or some such service where the build of your website is automatically uploaded to the Darwin Cloud and published.

# Getting Started

You can download the Darwin CLI as a node package from NPM.

# Installation

Open up terminal or command prompt and run the following command to install the node package globally:

npm install -g darwincli

or with yarn:

yarn global add darwincli

# Setup & Credentials

You'll need to provide some credentials in order to use the Darwin CLI. You can set the following as environment variables or you can create a file in your project directory called .env with the following content replacing ??? with your credentials (your credentials can be found in the Darwin Cloud Editor by clicking on your Website -> Credentials):

DARWIN_CLIENT_ID=???

DARWIN_CLIENT_SECRET=???

If a .env file is found in the current directory, those credentials will be used, otherwise environment variables will have to be set either globally or passed with the command. To test and make sure Darwin CLI is setup properly, run the command

darwincli info

If the credentials can't be found or are invalid, you'll receive an error telling you to check your DARWIN_CLIENT_ID and DARWIN_CLIENT_SECRET environment variables.

Now that Darwin CLI is setup, you're ready to start using it.

# Actions

Note that <param> means the parameter is required.

Note that [param] means the parameter is optional.

# - Info

darwincli info

Used to test and make sure your client credentials are setup properly. Will show you an error if there is an issue or your client credentials are invalid.

# - List Sites

darwincli site list

Lists out all of the sites for which you have access.

# - List Site Versions

darwincli site versions <siteID>

Lists out all of the versions of a particular site. You can use this to get the id of a specific version for rollback.

  • <siteID> - the id of the site. Use darwincli site list to get the site id.

# - Rollback a Site to a Previous Version

darwincli site rollback <siteID> <versionID>

Rollback your site to the specified version.

  • <siteID> - the id of the site. Use darwincli site list to get the site id.
  • <versionID> - the id of the version to deploy. Use darwincli site versions <siteID> to get the version id.

# - Upload and Deploy a New Version of a Site

darwincli site upload <siteID> <dir> [name] [description]

Uploads a new version of your website using the provided directory. Note that directory is relative to your current directory. Also, if name is unset then name and description will be taken from the last .git commit if the directory is under source control. If the project doesn't have source control and name is unset, then an error will occur. You can use a site.darwinignore file to list out the files you don't want uploaded for your site if any. This file works very similar to a .gitignore file.

  • <siteID> - the id of the site. Use darwincli site list to get the site id.
  • <dir> - a relative path to the directory of site files to upload. The entire directory will be uploaded except for files inside site.darwinignore.
  • [name] - a name for the deployment. Should be short, and describe overall what the changes are. If this is left unset, then the name and description will be taken from the last .git commit if possible.
  • [description] - a description for the deployment. Can be longer than name and describe everything that has changed. If this is left unset, then the name and description will be taken from the last .git commit if possible.
Revised: 5/30/2020, 11:16:14 PM