edgeone 1.0.15 → 1.0.16-beta.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.
Files changed (3) hide show
  1. package/README.md +71 -38
  2. package/edgeone-dist/cli.js +80001 -1344
  3. package/package.json +4 -1
package/README.md CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  <br/>
3
2
  <div align="center">
4
3
  <img src="https://cloudcache.tencent-cloud.com/qcloud/ui/static/static_source_business/8f2d5c70-8f06-4366-ae29-1a3eb9c7f602.svg" height="96">
@@ -17,12 +16,11 @@ EdgeOne CLI can help you manage and debug Pages Functions in the project more ef
17
16
 
18
17
  ## 1. Preparations
19
18
 
20
-
21
19
  - Quickly register and log in to the [Tencent Cloud Console](https://edgeone.ai/pages/new?s_url=https://console.tencentcloud.com/) using a Gmail account.
22
20
 
23
21
  - Create a [Pages project](https://edgeone.ai/pages/new?s_url=https://console.tencentcloud.com/edgeone/pages) in the Console, and clone the repository to Local.
24
22
 
25
- *If you are a China site user, please go to the corresponding [Pages](https://console.cloud.tencent.com/edgeone/pages) console.*
23
+ _If you are a China site user, please go to the corresponding [Pages](https://console.cloud.tencent.com/edgeone/pages) console._
26
24
 
27
25
  <br />
28
26
 
@@ -31,49 +29,48 @@ EdgeOne CLI can help you manage and debug Pages Functions in the project more ef
31
29
  ### 1. Install
32
30
 
33
31
  In the cloned project during the preparation stage, you can use npm to install the CLI:
34
- ``` plaintext
32
+
33
+ ```plaintext
35
34
  npm install -g edgeone
36
35
  ```
37
36
 
38
37
  Use the `edgeone -v` command to check if the installation is successful. Use the `edgeone -h` command to view all relevant commands.
39
38
 
40
- ###
39
+ ###
41
40
 
42
41
  ### 2. Log in
43
42
 
44
- Execute the login command, follow the prompts to select `Global` (International) or `China`, then complete the login in the pop-up browser window.
45
- ``` plaintext
43
+ Execute the login command, follow the prompts to select `Global` (International) or `China`, then complete the login in the pop-up browser window.
44
+
45
+ ```plaintext
46
46
  edgeone login
47
47
  ```
48
48
 
49
49
  After completing the login, you can use the `edgeone whoami` command to view the current login account information.
50
50
 
51
-
52
-
53
51
  ### 3. Initialize
54
52
 
55
53
  After successful login, execute the initialization command to initialize the basic environment required by Edgeone Pages in the project:
56
- ``` plaintext
54
+
55
+ ```plaintext
57
56
  edgeone pages init
58
57
  ```
59
58
 
60
59
  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.
61
60
 
62
-
63
-
64
61
  ### 4. Local Development
65
62
 
66
63
  After completing initialization, enter the local development stage:
67
- ``` plaintext
64
+
65
+ ```plaintext
68
66
  edgeone pages dev
69
67
  ```
70
68
 
71
69
  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.
72
70
 
73
-
74
-
75
71
  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:
76
- ``` javascript
72
+
73
+ ```javascript
77
74
  module.exports = {
78
75
  devServer: {
79
76
  proxy: {
@@ -82,47 +79,44 @@ module.exports = {
82
79
  chagneOrigin: true,
83
80
  pathRewrite: {
84
81
  '^/api': '',
85
- }
86
- }
87
- }
88
- }
89
- }
82
+ },
83
+ },
84
+ },
85
+ },
86
+ };
90
87
  ```
91
88
 
92
89
  In this way, use the Fetch API in the Pages project:
93
- ``` javascript
90
+
91
+ ```javascript
94
92
  fetch('/api/my-functions', {
95
- method: 'POST',
96
- body: JSON.stringify({ data: 'example' }),
97
- })
93
+ method: 'POST',
94
+ body: JSON.stringify({ data: 'example' }),
95
+ });
98
96
  ```
99
97
 
100
-
101
-
102
98
  ### 5. Associated Project
103
99
 
104
100
  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.
105
- ``` plaintext
101
+
102
+ ```plaintext
106
103
  edgeone pages link
107
104
  ```
108
105
 
109
-
110
-
111
106
  ### 6. Submit for Deployment
112
107
 
113
108
  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.
114
109
 
115
-
116
-
117
110
  ### 7. Switching Accounts
118
111
 
119
112
  If you need to switch to another Tencent Cloud account, you can execute the following command and then log in again:
120
- ``` plaintext
113
+
114
+ ```plaintext
121
115
  edgeone switch
122
116
  ```
123
117
 
124
-
125
118
  ### 8. Combine with front end
119
+
126
120
  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.
127
121
 
128
122
  For frontend applications that need to access local functions, currently you need to distinguish function access paths through environment variables in your frontend code:
@@ -135,24 +129,63 @@ ENV=dev npm run build
135
129
  const REQUEST_API = process.env.ENV === 'dev' ? 'https://localhost:8088/' : '/'
136
130
  ```
137
131
 
138
-
139
132
  For functions involving cross-origin validation scenarios like login and authentication, you can specify the `--fePort` parameter when starting the development server.
140
133
 
141
134
  ```
142
135
  edgeone pages dev --fePort=8000 // your front dev server port
143
136
  ```
144
137
 
138
+ <br/>
139
+
140
+ ## 3. CI/CD Integration
141
+
142
+ This section provides guidance on integrating EdgeOne CLI into your CI/CD pipelines for automated deployments.
143
+
144
+ ### Deploy Command for CI Pipelines
145
+
146
+ The deploy command allows you to deploy a folder or ZIP package directly to EdgeOne Pages from your CI/CD pipeline without using Git-based deployment.
147
+
148
+ ```plaintext
149
+ edgeone pages deploy <directoryOrZip> -t <token>
150
+ ```
151
+
152
+ #### Parameters
153
+
154
+ - `<directoryOrZip>`: Path of folder or ZIP package to deploy (required)
155
+ - `-t, --token`: API Token for CI/CD pipelines (required for non-interactive environments)
156
+ - `-e, --env`: Environment to deploy to, choices: 'production' or 'preview' (default: 'production')
157
+
158
+ #### CI Pipeline Examples
159
+
160
+ ```plaintext
161
+ # Basic CI deployment to production
162
+ edgeone pages deploy ./dist -t $EDGEONE_API_TOKEN
163
+
164
+ # CI deployment to preview environment
165
+ edgeone pages deploy ./build.zip -e preview -t $EDGEONE_API_TOKEN
166
+ ```
167
+
168
+ #### Obtaining an API Token
169
+
170
+ For more information, please refer to https://edgeone.ai/document/177158578324279296'
171
+
172
+ To use the deploy command in CI/CD pipelines, you need to generate an API token:
173
+
174
+ 1. Log in to the EdgeOne Console
175
+ 2. Navigate to the Pages project settings
176
+ 3. Generate an API token with deployment permissions
177
+ 4. Add this token as a secure environment variable in your CI/CD system
145
178
 
146
179
  <br/>
147
180
 
148
181
  ## References
182
+
149
183
  [Pages Introduction](https://edgeone.ai/document/160427672992178176) | [Pages Functions](https://edgeone.ai/document/162227908259442688)
150
184
 
151
- *To access the China site documentation, please click [here](https://edgeone.cloud.tencent.com/pages/document/162936635171454976).*
185
+ _To access the China site documentation, please click [here](https://edgeone.cloud.tencent.com/pages/document/162936635171454976)._
152
186
 
153
187
  <br/>
154
188
 
155
189
  ## Contact
156
- If you need technical support, please [contact us](https://edgeone.ai/contact?source=edgeone-cli).
157
-
158
190
 
191
+ If you need technical support, please [contact us](https://edgeone.ai/contact?source=edgeone-cli).