edgeone 1.0.34 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -54
- package/edgeone-bin/edgeone.js +6 -4011
- package/edgeone-dist/cli.js +1943 -176204
- package/edgeone-dist/pages/dev/runner-worker.js +1488 -0
- package/package.json +18 -5
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ After successful login, execute the initialization command to initialize the bas
|
|
|
56
56
|
edgeone pages init
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
After initialization,
|
|
59
|
+
After initialization, an `edge-functions` or `node-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.
|
|
60
60
|
|
|
61
61
|
### 4. Local Development
|
|
62
62
|
|
|
@@ -66,35 +66,22 @@ After completing initialization, enter the local development stage:
|
|
|
66
66
|
edgeone pages dev
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Executing the command will start a service on the local port 8088 by default.
|
|
69
|
+
Executing the command will start a service on the local port 8088 by default. The Pages Functions service and the Pages project run on the same port.
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```javascript
|
|
74
|
-
module.exports = {
|
|
75
|
-
devServer: {
|
|
76
|
-
proxy: {
|
|
77
|
-
'/api': {
|
|
78
|
-
target: 'http://localhost:8088', // Local Development Service Address for Pages Function
|
|
79
|
-
chagneOrigin: true,
|
|
80
|
-
pathRewrite: {
|
|
81
|
-
'^/api': '',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
In this way, use the Fetch API in the Pages project:
|
|
71
|
+
Visit the frontend at `http://localhost:8088/`, and call your functions directly using their file paths under `edge-functions` or `node-functions`.
|
|
90
72
|
|
|
91
73
|
```javascript
|
|
74
|
+
// ./node-functions/api/my-functions.js
|
|
92
75
|
fetch('/api/my-functions', {
|
|
93
76
|
method: 'POST',
|
|
94
77
|
body: JSON.stringify({ data: 'example' }),
|
|
95
78
|
});
|
|
96
79
|
```
|
|
97
80
|
|
|
81
|
+
Note:
|
|
82
|
+
- The dev service will read `devCommand` from `edgeone.json` to start your dev server. If absent, it will read the `dev` script from your project's `package.json`.
|
|
83
|
+
- Edge Functions debug service has a limit on the number of times it can start up, so try to avoid frequently logging out and starting the dev service (hot updates within the dev service will not increase the startup count).
|
|
84
|
+
|
|
98
85
|
### 5. Associated Project
|
|
99
86
|
|
|
100
87
|
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.
|
|
@@ -102,29 +89,35 @@ If you need to use the Key-Value Storage capability or synchronize the environme
|
|
|
102
89
|
```plaintext
|
|
103
90
|
edgeone pages link
|
|
104
91
|
```
|
|
92
|
+
If you need to link a project that does not exist, you can also create a new project directly under the CLI guide.
|
|
93
|
+
|
|
105
94
|
|
|
106
95
|
### 6. Deploy
|
|
107
96
|
|
|
108
|
-
|
|
97
|
+
If your project is created via "direct upload", you can also deploy it directly to the Pages platform locally by executing the following command:
|
|
109
98
|
|
|
110
99
|
```plaintext
|
|
111
|
-
edgeone pages deploy <directoryOrZip> -n <projectName>
|
|
100
|
+
edgeone pages deploy [<directoryOrZip>] [-n <projectName>] [-e <env>]
|
|
112
101
|
```
|
|
113
102
|
|
|
114
103
|
#### Parameters
|
|
115
104
|
|
|
116
|
-
- `<directoryOrZip>`: Path of folder or ZIP package to deploy
|
|
117
|
-
- `-n, --name`: Project name for deployment (creates new or updates existing project)
|
|
105
|
+
- `<directoryOrZip>`: Path of folder or ZIP package to deploy
|
|
106
|
+
- `-n, --name`: Project name for deployment (creates new or updates existing project)
|
|
118
107
|
- `-e, --env`: Environment to deploy to, choices: 'production' or 'preview' (default: 'production')
|
|
119
108
|
|
|
109
|
+
Note:
|
|
110
|
+
- By default, when executing deploy, the CLI will automatically build and package frontend code, `node-functions`, and `edge-functions` into the `.edgeone` folder and deploy to Pages.
|
|
111
|
+
- If you choose to manually build the project, you need to copy the related folders of Pages Functions and the project's `package.json` file to dist (suppose the output directory is dist) after building, then rerun `edgeone pages deploy ./dist`.
|
|
112
|
+
|
|
120
113
|
#### Usage Examples
|
|
121
114
|
|
|
122
115
|
```plaintext
|
|
123
116
|
# Deploy build folder to production
|
|
124
|
-
edgeone pages deploy
|
|
117
|
+
edgeone pages deploy
|
|
125
118
|
|
|
126
119
|
# Deploy ZIP package to preview environment
|
|
127
|
-
edgeone pages deploy
|
|
120
|
+
edgeone pages deploy -e preview
|
|
128
121
|
```
|
|
129
122
|
|
|
130
123
|
**Alternative: Git-based Deployment**
|
|
@@ -139,26 +132,6 @@ If you need to switch to another Tencent Cloud account, you can execute the foll
|
|
|
139
132
|
edgeone switch
|
|
140
133
|
```
|
|
141
134
|
|
|
142
|
-
### 8. Combine with front end
|
|
143
|
-
|
|
144
|
-
EdgeOne Pages CLI supports local development and debugging of EdgeOne Pages functions. If your project contains frontend code, you need to manually start the corresponding development service.
|
|
145
|
-
|
|
146
|
-
For frontend applications that need to access local functions, currently you need to distinguish function access paths through environment variables in your frontend code:
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
// when start dev server
|
|
150
|
-
ENV=dev npm run build
|
|
151
|
-
|
|
152
|
-
//In your code
|
|
153
|
-
const REQUEST_API = process.env.ENV === 'dev' ? 'https://localhost:8088/' : '/'
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
For functions involving cross-origin validation scenarios like login and authentication, you can specify the `--fePort` parameter when starting the development server.
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
edgeone pages dev --fePort=8000 // your front dev server port
|
|
160
|
-
```
|
|
161
|
-
|
|
162
135
|
<br/>
|
|
163
136
|
|
|
164
137
|
## 3. CI/CD Integration
|
|
@@ -170,24 +143,28 @@ This section provides guidance on integrating EdgeOne CLI into your CI/CD pipeli
|
|
|
170
143
|
For CI/CD pipelines, you can use the same deploy command with an API Token for authentication:
|
|
171
144
|
|
|
172
145
|
```plaintext
|
|
173
|
-
edgeone pages deploy <directoryOrZip> -n <projectName> -t <token>
|
|
146
|
+
edgeone pages deploy [<directoryOrZip>] -n <projectName> -t <token> [-e <env>]
|
|
174
147
|
```
|
|
175
148
|
|
|
176
149
|
#### Parameters
|
|
177
150
|
|
|
178
|
-
- `<directoryOrZip>`: Path of folder or ZIP package to deploy
|
|
151
|
+
- `<directoryOrZip>`: Path of folder or ZIP package to deploy
|
|
179
152
|
- `-n, --name`: Project name for deployment (creates new or updates existing project) (required)
|
|
180
153
|
- `-e, --env`: Environment to deploy to, choices: 'production' or 'preview' (default: 'production')
|
|
181
154
|
- `-t, --token`: API Token for CI/CD pipelines (required for automated deployments)
|
|
182
155
|
|
|
156
|
+
Note:
|
|
157
|
+
- By default, when executing deploy, the CLI will automatically build and package frontend code, `node-functions`, and `edge-functions` into the `.edgeone` folder and deploy to Pages.
|
|
158
|
+
- If you choose to manually build the project, you need to copy the related folders of Pages Functions and the project's `package.json` file to dist (suppose the output directory is dist) after building, then rerun `edgeone pages deploy ./dist`.
|
|
159
|
+
|
|
183
160
|
#### CI/CD Pipeline Examples
|
|
184
161
|
|
|
185
162
|
```plaintext
|
|
186
163
|
# Basic CI deployment to production with API token
|
|
187
|
-
edgeone pages deploy
|
|
164
|
+
edgeone pages deploy -n edgeone-pages-project -t $EDGEONE_API_TOKEN
|
|
188
165
|
|
|
189
166
|
# CI deployment to preview environment with API token
|
|
190
|
-
edgeone pages deploy
|
|
167
|
+
edgeone pages deploy -n edgeone-pages-project -e preview -t $EDGEONE_API_TOKEN
|
|
191
168
|
```
|
|
192
169
|
|
|
193
170
|
#### Obtaining an API Token
|
|
@@ -200,13 +177,13 @@ How to create an API Token
|
|
|
200
177
|
4. Select "expiration time" to ensure your information security.
|
|
201
178
|
5. Click Submit.
|
|
202
179
|
|
|
203
|
-
For more information, please refer to https://edgeone.ai/document/
|
|
180
|
+
For more information, please refer to https://pages.edgeone.ai/document/api-token
|
|
204
181
|
|
|
205
182
|
<br/>
|
|
206
183
|
|
|
207
184
|
## References
|
|
208
185
|
|
|
209
|
-
[Pages Introduction](https://edgeone.ai/document/
|
|
186
|
+
[Pages Introduction](https://pages.edgeone.ai/document/product-introduction) | [Pages Functions](https://pages.edgeone.ai/document/pages-functions-overview)
|
|
210
187
|
|
|
211
188
|
_To access the China site documentation, please click [here](https://edgeone.cloud.tencent.com/pages/document/162936635171454976)._
|
|
212
189
|
|
|
@@ -214,4 +191,4 @@ _To access the China site documentation, please click [here](https://edgeone.clo
|
|
|
214
191
|
|
|
215
192
|
## Contact
|
|
216
193
|
|
|
217
|
-
If you need technical support, please [contact us](https://edgeone.ai/contact?source=edgeone-cli).
|
|
194
|
+
If you need technical support, please [contact us](https://edgeone.ai/contact?source=edgeone-cli).
|