边缘开发者平台
  • Pages
    • 产品简介
    • 快速开始
    • 框架指南
    • 项目指南
      • 项目管理
      • edgeone.json
      • 错误码
    • 构建指南
    • 部署指南
    • 域名管理
    • Pages Functions
    • KV 存储
    • EdgeOne CLI
    • 常见问题
    • 联系我们
    • 产品动态
    • 迁移指南
      • 从 Vercel 迁移至 EdgeOne Pages
      • 从 Cloudflare Pages 迁移至 EdgeOne Pages
      • 从 Netlify 迁移至 EdgeOne Pages
当前内容仅提供英语版本,中文版我们将尽快补充,感谢您的理解。
当前为国际站中文文档,如需访问中国站文档,请点击这里

EdgeOne CLI

Overview

The rapid integration of item and Pages function capabilities can be achieved through the Edgeone CLI.
EdgeOne CLI provides methods to manage Pages functions. With the CLI, you can generate, configure, and debug functions in your project.


1. Preparations

Quickly register and log in to the Tencent Cloud Console using a Gmail account.
In the console, activate the Pages service, create a new Pages project, and clone it to your local machine.


2. Quick Start

1. Install

In the cloned project during the preparation stage, you can use npm to install the CLI:
npm install -g edgeone
Use the edgeone -v command to check if the installation is successful. Use the edgeone -h command to view all relevant 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 the login, you can use the edgeone whoami command to view the current login account information.


3. Initialize

After successful login, execute the initialization command to initialize the basic environment required by Edgeone Pages in the project:
edgeone pages init
After initialization, a functions folder and sample functions will be generated in the root directory of the project. You can continue to add and develop functions in this folder. Refer to the documentation for detailed usage of the functions.


4. Local Development

After completing initialization, enter the local development stage:
edgeone pages dev
Executing the command will start a service on the local port 8088 by default. You can access the sample function via http://localhost:8088/helloworld. Here, the access path is the address path of the function file in the functions folder.

During local development, the service for Pages Functions and the service for the Pages project may run on different ports. In order to allow the Pages project to call functions, you can use a proxy server or reverse proxy to forward requests to the correct port. Here is an example configuration of webpack-dev-server:
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8088', // Local Development Service Address for Pages Function
chagneOrigin: true,
pathRewrite: {
'^/api': '',
}
}
}
}
}
In this way, use the Fetch API in the Pages project:
fetch('/api/my-functions', {
method: 'POST',
body: JSON.stringify({ data: 'example' }),
})


5. Associated Project

If you need to use the Key-Value Storage capability or synchronize the environment variables set in the console to local debugging, you can execute the Associated Project commands, enter the project name as required. The project name here is the one created in the Preparation Work of the Pages project.
edgeone pages link


6. Submit for deployment

After local development and debugging are completed, push the project code to the Git remote to trigger the CI build and deployment in the Pages backend, completing the entire development process.


7. Switching Accounts

If you need to switch to another Tencent Cloud account, you can execute the following command and then log in again:
edgeone switch