EdgeOne CLI
Overview
EdgeOne CLI provides methods for managing Makers functions and capabilities for rapid deployment. Using the CLI, you can generate, configure, and debug functions in your project, and upload the built artifacts to the Makers platform as a folder or a Zip package.
Dual-Command Policy Description
With the upgrade of EdgeOne Pages to EdgeOne Makers, the new namespace
edgeone makers has been introduced in the CLI:Command Family | Status | Description |
edgeone makers <command> | Recommended | A new namespace, recommended for primary use; new features (such as edgeone makers create) are provided only here. |
edgeone pages <command> | Available during transition | The legacy namespace, where all existing subcommands retain their full features; a deprecation notice is displayed upon execution. |
The subcommands of the two namespaces are completely equivalent—
edgeone pages dev and edgeone makers dev behave identically and can be switched between seamlessly.Migration Recommendations
CI/CD Scripts: It is recommended to replace
edgeone pages xxx with edgeone makers xxx during an appropriate release cycle. Not replacing them during the transition period will not affect the build.Local Development: Use the new command
edgeone makers xxx directly.New Features: Some new features (such as
edgeone makers create) are only available under the new namespace and are not registered under edgeone pages.Legacy Command Deprecation Plan
The
edgeone pages namespace will be gradually phased out after the transition period ends, with advance notification provided through CLI deprecation warnings and documentation announcements before the phase-out. It will not be phased out at the current stage, and existing users' scripts and workflows will not be affected.Preparations
Quickly register and sign in to the Tencent Cloud console with a Gmail account.
Activate the Makers service in the console, create a new Makers project, and clone it to your local machine.
Quick Start
1. Installing
During the preparation stage, install the CLI through npm in the cloned project.
npm install -g edgeone
Use the
edgeone -v command to check whether the installation is successful. Use the edgeone -h command to view all related commands.2. Log In
Execute the login command, select
Global (International) or China as prompted. It is recommended to select Global to ensure accurate data and information are obtained, and then complete the login in the pop-up browser window.edgeone login
After completing login, you can execute
edgeone whoami to view the current logged-in account info.3. Initializing a Project
EdgeOne CLI provides two ways to start a project. You can choose based on your starting point:
Create a new project from scratch (
edgeone makers create) — pull the official template to get started quickly.Initialize in an existing project (
edgeone makers init) — add Makers configuration to the existing project.3.1 Creating a New Project from Scratch
Run the following command to pull the official template and create a new project:
edgeone makers create [project-name] --template <slug>
Parameter description:
project-name: directory name for the project to be created (directory name only).
--template: template slug or GitHub directory (required).
-t, --token: API Token for CI/CD or non-interactive environments. It can be omitted when already logged in.
For the list of available templates, see pages.edgeone.ai/templates, or visit the TencentEdgeOne/pages-templates repository.
Note:
The create command is only available under the new namespace edgeone makers. The old command edgeone pages does not have this command.
The create command can be used without logging in. For subsequent dev/deploy operations, you must first run edgeone login.
After the command succeeds, it prints "Next Steps". Please manually run operations such as npm install as instructed (dependencies are not installed automatically by default).
3.2 Initializing in an Existing Project
If you already have an existing project (for example, an application built with frameworks like Next.js), you can initialize the basic environment required by EdgeOne Makers in the project using the following command:
edgeone makers init
During initialization, based on the instructions and your needs, the
edge-functions or cloud-functions folder and example functions will be generated in the project root directory. You can subsequently add new and develop functions under the folder continuously. For detailed usage of functions, see the documentation.4. Local Development
After initialization, enter the local development stage:
edgeone makers dev
Note:
This command first reads the devCommand parameter in edgeone.json to start the dev service. If this configuration is not present, it reads the dev command in package.json to start the service. Do not configure edgeone makers dev in edgeone.json or package.json!
Edge Functions debug service has a limit on the number of times it can start up, so try to avoid frequently exiting and starting the dev service (hot updates in the dev service will not increase the startup count).
In environments where executing
edgeone login is not convenient, you can add the parameters -t, --token after edgeone makers dev (see the end of the document for how to obtain the API Token).By default, running the command starts a service on the local port 8088. Both the Makers Functions service and the Makers project service run on the same port, eliminating the need for an additional proxy.
You can access the frontend page via
http://localhost:8088/. In your frontend project, you can directly use the Fetch API, where the access path is the path to the function files under the edge-functions or cloud-functions folder.// ./cloud-functions/api/my-functions.jsfetch('/api/my-functions', {method: 'POST',body: JSON.stringify({ data: 'example' }),})
5. Associate Project
If you need to use the KV storage capability or synchronize the environment variables already configured in the console to your local debugging environment, run the link project command and enter the project name as prompted. The project name here refers to the Makers project name you created during the preparation phase.
edgeone makers link
Note:
In environments where executing
edgeone login is not convenient, you can add the parameters -t, --token after edgeone makers link (see the end of the document for how to obtain the API Token).If you need to link a project that does not exist, you can also create a new project directly under the CLI guide.
6. Submit Deployment
After completing local development and debugging, push the project code to the remote Git repository. This triggers the CI build and deployment in the Makers backend, completing the entire development workflow.
7. Local Deployment
You can also choose to build and deploy locally using the deploy command. If you need to link an existing project, it must be of the direct upload type.
edgeone makers deploy
Parameter Description
<directoryOrZip>: folder or ZIP package path to deploy
-n, --name: project name to deploy, creates new project automatically if it does not exist
-e, --env: deployment target environment, available values: production or preview (default production)
Note:
When you run deploy, the CLI automatically builds and deploys to Makers without requiring a folder to be specified. For manual builds, you need to place the Makers Functions-related folders and package.json into the output directory (for example, dist) and then execute
edgeone makers deploy ./dist.
Local Deployment Example
# Production environment deploymentedgeone makers deploy# Preview environment deploymentedgeone makers deploy -e preview
8. Switching Accounts
Switch to another Tencent Cloud account, execute the following commands then log in again:
edgeone switch
CI/CD Pipeline Integration
Alternatively, you can integrate EdgeOne CLI into the CI/CD pipeline to realize automatic deployment.
Note:
Installing EdgeOne CLI can be found in "Quick Start - Installation".
CI Pipeline Deployment Command
The
deploy command supports deploying folders or ZIP packages directly from the CI/CD pipeline to EdgeOne Makers without relying on Git.edgeone makers deploy [<directoryOrZip>] -n <projectName> -t <token> [-e <env>]
Parameter Description
<directoryOrZip>: folder or ZIP package path to deploy
-n, --name: project name to deploy, creates new project automatically if it does not exist (required)
-t, --token: API Token for CI/CD pipeline (required)
-e, --env: deployment target environment, available values: production or preview (default production)
Note:
When you run deploy, the CLI automatically builds and deploys the project. For manual builds, place the Makers Functions-related folders and package.json into the output directory (for example, dist), then execute
edgeone makers deploy ./dist.CI Pipeline Example
# Production environment deploymentedgeone makers deploy -n project-name -t $EDGEONE_API_TOKEN# Preview environment deploymentedgeone makers deploy -n project-name -e preview -t $EDGEONE_API_TOKEN
API Token Method for Obtaining
Before using the deploy command in a CI/CD pipeline, generate an API Token in the EdgeOne Makers console. For more information, refer to the API Token documentation.
Environment Variable Management
// List all environment variables in console configurationedgeone makers env ls// Pull console environment variables to a local fileedgeone makers env pull// Pull environment variables can specify local fileedgeone makers env pull -f .env.prod// Add new/modify environment variablesedgeone makers env set ENV_VAR_KEY env_var_value// Delete environment variableedgeone makers env rm ENV_VAR_KEY
