Edgio

CLI

This guide shows you everything you can do with the Edgio command line interface.

Installation

To install, or upgrade to the latest, Edgio CLI run
Bash
1npm i -g @layer0/cli
Or with yarn
Bash
1yarn global add @layer0/cli

Upgrade Project to Latest Version

If you already have a project running on Edgio and you want to update packages to the most recent release of @layer0, simply run:
Bash
10 use latest
Before deploying your site, verify that all functionality, including request/response data, is as expected.

Commands

build

Creates a build of your app optimized for production.

Options

NameDescription
--skip-frameworkAlias: “-s”. Skips the framework (Next.js, Vue, Angular, etc..) build and simply rebundles your router
--disable-permanent-assetsSet this to true to suppress errors like “Immutable file (…) content was changed” during deployment.
--include-sourcesIncludes all non-gitignored source files in the bundle uploaded to Edgio. This can be helpful when debugging, especially when working with Edgio support. You can limit the files that are uploaded using the sources config in layer0.config.js.

Example

Bash
10 build

cache-clear

Clears the cache. If neither --path nor --surrogate-key is specified, the entire cache for the specified environment will be cleared.

Options

NameDescription
--team(Required) The team name
--site(Required) The site name
--environment(Required) The environment name
--pathA path to clear. Use ”*” as a wildcard
--surrogate-keyClears all responses assigned to the specified surrogate key (cache tag)

Example

Bash
10 cache-clear --team=my-team --site=my-site --environment=production --path=/p/*

completion

Creates a script that provides autocompletion for Edgio CLI commands that can be installed in your shell.

Example

Bash
10 completion

Using ZSH

Bash
10 completion >> ~/.zshrc

Using BASH

Bash
10 completion >> ~/.bashrc

deploy

Builds and deploys your site on Edgio.

Parameters

NameDescription
teamThe name of the team under which the site will be deployed. The site will be deployed to your private space will be used if omitted.

Options

NameDescription
--siteThe name of the site to deploy. By default the name field in package.json is used.
--environmentThe environment to deploy to. By default the default environment is used.
--branchThe name of the source control branch. This is automatically set when using Git.
--skip-buildSkips the build step
--tokenAuthenticates using a deploy token rather than your user credentials. Use this option when deploying from CI. Alternatively, you can also specify the deploy token by setting the LAYER0_DEPLOY_TOKEN environment variable.
--commit-urlThe URL at which the commit can be viewed in your source control provided. If your package.json provides the repository attribute the commit URL will be derived automatically if you use GitHub, GitLab, or BitBucket.
--include-sourcesIncludes all non-gitignored source files in the bundle uploaded to Edgio. This can be helpful when debugging, especially when working with Edgio support. You can limit the files that are uploaded using the sources config in layer0.config.js.
--disable-permanent-assetsSet this to true to suppress errors like “Immutable file (…) content was changed” during deployment.

Getting Information about the Deployment

The layer0 deploy command writes a file called .layer0/deployment-manifest.json, which contains the following information:
JavaScript
1{
2 "number": /* the deployment number */,
3 "url": /* the permalink URL for the deployment */,
4 "environment": {
5 "url": /* The edge URL for the deployment */,
6 "name": /* The name of the environment that was deployed to */
7 }
8}

Example

Bash
10 deploy my-team --environment=production

docs

Open the Edgio documentation in your browser.

Example

Bash
10 docs

dev

Runs your project in development mode, simulating the Edgio cloud environment. This command is a simplified version of 0 run, with only the —cache option being supported.

Options

NameDescription
--cacheEnables caching during local development so that you can test the caching logic in your router.

Example

Bash
10 dev

init

Run in an existing app to add all required packages and files need to publish your app on Edgio

Example

Bash
10 init

Options

NameDescription
--connectorThe name of a specific connector package to install, or a path to a directory that implements the connector interface.

login

Logs into Edgio via the developer console.

Example

Bash
10 login

logout

Logs out of Edgio

Example

Bash
10 logout

run

Runs your app locally. Uses port 3000 by default. You can change this by setting the PORT environment variable. For example: PORT=5000 0 run.

Options

NameDescription
--productionRuns a production build of your app, simulating the cloud environment. This can also be achieved by setting the NODE_ENV environment variable to true. You need to run 0 build first.
--cacheEnables caching during local development so that you can test the caching logic in your router. By default caching is turned off in local development to ensure you don’t see stale responses as you make changes to your code.

Example

Bash
10 run --production
Or to run a deployment bundle downloaded from Edgio Developer Console, use:
Bash
10 run /path/to/bundle.zip
Production mode is always used when running downloaded bundles.

use

Switches the version of all @layer0/* packages in your project.

Example

To install a particular version:
Bash
10 use 4.10.1
To install the latest stable:
Bash
10 use latest
To install the latest preview:
Bash
10 use next

Troubleshooting


Error: Cannot find module … on 0 init

An uncommon issue when running 0 init can present a similar error:
installing @layer0/core, @layer0/cli, @layer0/prefetch, @layer0/devtools, @layer0/angular… done. Error: Cannot find module ‘/Users/myUser/Projects/my-@layer0-poc/node_modules/@layer0/angular/bin/init’
This may be related to an outdated global version of Edgio CLI. The telltale sign is reference to /bin/ in the module path. This is an old convention. Recommended approach would be to npm i -g @layer0/cli@latest and then run 0 init on the project.