@geek-fun/serverlessinsight 0.8.5 → 0.8.6

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.
@@ -9,7 +9,6 @@
9
9
  "shared": {}
10
10
  }
11
11
  },
12
- "resources": {},
13
- "lineage": "3ea34348-0c9b-4451-9ba3-c734ccf43274",
12
+ "lineage": "b2e9ef02-2d5d-4779-9c83-748e2bf1b564",
14
13
  "serial": 5
15
14
  }
@@ -22,12 +22,11 @@
22
22
  "id": "iam-test-app-dev-sls"
23
23
  }
24
24
  ],
25
- "lastUpdated": "2026-08-28T02:48:38.277Z"
25
+ "lastUpdated": "2026-08-28T07:04:25.346Z"
26
26
  }
27
27
  }
28
28
  }
29
29
  },
30
- "resources": {},
31
- "lineage": "17bbe89a-e7af-441e-9829-f92dbace0ef9",
30
+ "lineage": "2333d026-48b6-46bc-b806-5bcb2271a666",
32
31
  "serial": 3
33
32
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
  }
93
93
  ],
94
- "lastUpdated": "2026-08-28T02:49:20.881Z",
94
+ "lastUpdated": "2026-08-28T07:05:06.430Z",
95
95
  "status": "ready"
96
96
  },
97
97
  "events.gateway_event": {
@@ -166,7 +166,7 @@
166
166
  "stageName": "RELEASE"
167
167
  }
168
168
  ],
169
- "lastUpdated": "2026-08-28T02:49:20.884Z"
169
+ "lastUpdated": "2026-08-28T07:05:06.432Z"
170
170
  }
171
171
  },
172
172
  "shared": {
@@ -185,175 +185,11 @@
185
185
  "id": "insight-poc-deploy-app-dev-sls"
186
186
  }
187
187
  ],
188
- "lastUpdated": "2026-08-28T02:49:15.880Z"
188
+ "lastUpdated": "2026-08-28T07:05:01.428Z"
189
189
  }
190
190
  }
191
191
  }
192
192
  },
193
- "resources": {
194
- "functions.insight_poc_fn": {
195
- "mode": "managed",
196
- "region": "cn-hangzhou",
197
- "definition": {
198
- "functionName": "insight-poc-fn",
199
- "runtime": "nodejs18",
200
- "handler": "index.handler",
201
- "memorySize": 512,
202
- "timeout": 10,
203
- "diskSize": null,
204
- "environment": {
205
- "NODE_ENV": "development",
206
- "TEST_VAR": "testVarValue",
207
- "TEST_VAR_EXTRA": "abcds-testVarValue-andyou"
208
- },
209
- "vpcConfig": null,
210
- "gpuConfig": null,
211
- "customContainerConfig": null,
212
- "nasConfig": null,
213
- "logConfig": {
214
- "project": "insight-poc-deploy-app-dev-sls",
215
- "logstore": "insight-poc-deploy-dev-fn-logs",
216
- "enableRequestMetrics": true,
217
- "enableInstanceMetrics": true
218
- },
219
- "codeHash": "c96b718fa999add5e047823c3d7abfa1397fa8d0075bc6a4f3592785fcd4b76f"
220
- },
221
- "instances": [
222
- {
223
- "type": "ALIYUN_FC3_FUNCTION",
224
- "sid": "si:aliyun:fc3:dev:insight-poc-fn",
225
- "id": "test-function",
226
- "functionName": "test-function",
227
- "functionArn": null,
228
- "functionId": null,
229
- "runtime": "nodejs18",
230
- "handler": "index.handler",
231
- "memorySize": 128,
232
- "timeout": 60,
233
- "diskSize": null,
234
- "cpu": null,
235
- "environment": {},
236
- "vpcConfig": {},
237
- "gpuConfig": {},
238
- "nasConfig": {},
239
- "logConfig": {},
240
- "customContainerConfig": {},
241
- "description": null,
242
- "internetAccess": null,
243
- "role": null,
244
- "codeChecksum": null,
245
- "codeSize": null,
246
- "createdTime": null,
247
- "lastModifiedTime": null,
248
- "state": "Running",
249
- "stateReason": null,
250
- "stateReasonCode": null,
251
- "lastUpdateStatus": null,
252
- "lastUpdateStatusReason": null,
253
- "lastUpdateStatusReasonCode": null
254
- },
255
- {
256
- "sid": "si:aliyun:sls_logstore:dev:insight-poc-deploy-app-dev-sls/insight-poc-deploy-dev-fn-logs",
257
- "id": "insight-poc-deploy-app-dev-sls/insight-poc-deploy-dev-fn-logs",
258
- "type": "ALIYUN_SLS_LOGSTORE",
259
- "logstoreName": "insight-poc-deploy-dev-fn-logs"
260
- },
261
- {
262
- "sid": "si:aliyun:sls_index:dev:insight-poc-deploy-app-dev-sls/insight-poc-deploy-dev-fn-logs/index",
263
- "id": "insight-poc-deploy-app-dev-sls/insight-poc-deploy-dev-fn-logs/index",
264
- "type": "ALIYUN_SLS_INDEX",
265
- "projectName": "insight-poc-deploy-app-dev-sls",
266
- "logstoreName": "insight-poc-deploy-dev-fn-logs"
267
- },
268
- {
269
- "sid": "si:aliyun:ram_role:dev:insight-poc-deploy-app-insight-poc-deploy-dev-fc-role",
270
- "id": "insight-poc-deploy-app-insight-poc-deploy-dev-fc-role",
271
- "type": "ALIYUN_RAM_ROLE",
272
- "body": {
273
- "Role": {
274
- "RoleName": "test-role"
275
- }
276
- }
277
- }
278
- ],
279
- "lastUpdated": "2026-08-28T02:49:20.881Z",
280
- "status": "ready"
281
- },
282
- "events.gateway_event": {
283
- "mode": "managed",
284
- "region": "cn-hangzhou",
285
- "definition": {
286
- "groupName": "insight-poc-deploy-dev-gateway-event-agw-group",
287
- "description": "API Gateway group for insight-poc-deploy",
288
- "basePath": null,
289
- "triggers": [
290
- {
291
- "method": "GET",
292
- "path": "/api/hello",
293
- "backend": "${functions.insight_poc_fn}"
294
- }
295
- ],
296
- "domain": null
297
- },
298
- "instances": [
299
- {
300
- "type": "ALIYUN_APIGW_GROUP",
301
- "sid": "si:aliyun:apigateway:dev:",
302
- "id": "",
303
- "groupId": null,
304
- "groupName": null,
305
- "description": null,
306
- "basePath": null,
307
- "subDomain": null,
308
- "instanceId": null,
309
- "instanceType": null,
310
- "regionId": null,
311
- "status": null,
312
- "createdTime": null,
313
- "modifiedTime": null,
314
- "billingStatus": null,
315
- "illegalStatus": null,
316
- "trafficLimit": null
317
- },
318
- {
319
- "type": "ALIYUN_APIGW_API",
320
- "sid": "si:aliyun:apigateway:dev:[object Object]/undefined",
321
- "id": "",
322
- "apiId": null,
323
- "apiName": null,
324
- "groupId": null,
325
- "groupName": null,
326
- "description": null,
327
- "visibility": null,
328
- "authType": null,
329
- "requestConfig": null,
330
- "serviceConfig": null,
331
- "resultType": null,
332
- "resultSample": null,
333
- "createdTime": null,
334
- "modifiedTime": null,
335
- "deployedInfos": null
336
- },
337
- {
338
- "type": "ALIYUN_APIGW_DEPLOYMENT",
339
- "sid": "si:aliyun:apigateway:dev:[object Object]/[object Object]/RELEASE",
340
- "id": "[object Object]/[object Object]/RELEASE",
341
- "groupId": {
342
- "body": {
343
- "groupId": "group-123"
344
- }
345
- },
346
- "apiId": {
347
- "body": {
348
- "apiId": "api-123"
349
- }
350
- },
351
- "stageName": "RELEASE"
352
- }
353
- ],
354
- "lastUpdated": "2026-08-28T02:49:20.884Z"
355
- }
356
- },
357
- "lineage": "5046b4f9-b550-4933-850f-99eb5411cb42",
193
+ "lineage": "eb2aaf5d-2401-42b0-820e-1059f98fced9",
358
194
  "serial": 2
359
195
  }
@@ -9,7 +9,6 @@
9
9
  "shared": {}
10
10
  }
11
11
  },
12
- "resources": {},
13
- "lineage": "6fe96724-0a76-4ea1-945e-62cc4b88214e",
12
+ "lineage": "33a22c7c-a582-4194-971b-0586ae8216ac",
14
13
  "serial": 1
15
14
  }
@@ -63,7 +63,7 @@
63
63
  }
64
64
  ],
65
65
  "status": "ready",
66
- "lastUpdated": "2026-08-28T02:48:53.503Z"
66
+ "lastUpdated": "2026-08-28T07:04:40.381Z"
67
67
  }
68
68
  },
69
69
  "shared": {
@@ -83,72 +83,11 @@
83
83
  "projectId": "proj-123"
84
84
  }
85
85
  ],
86
- "lastUpdated": "2026-08-28T02:48:50.502Z"
86
+ "lastUpdated": "2026-08-28T07:04:37.380Z"
87
87
  }
88
88
  }
89
89
  }
90
90
  },
91
- "resources": {
92
- "functions.insight_poc_fn": {
93
- "mode": "managed",
94
- "region": "cn-beijing",
95
- "definition": {
96
- "functionName": "insight-poc-fn",
97
- "runtime": "node20/v1",
98
- "handler": "index.handler",
99
- "memorySize": 128,
100
- "timeout": 30,
101
- "environment": {
102
- "NODE_ENV": "production"
103
- },
104
- "codeHash": "c96b718fa999add5e047823c3d7abfa1397fa8d0075bc6a4f3592785fcd4b76f",
105
- "role": "trn:iam::123456789012:role/test-role",
106
- "logConfig": {
107
- "project": "insight-volc-app-dev-tls",
108
- "topic": "insight-volc-dev-fn-logs"
109
- }
110
- },
111
- "instances": [
112
- {
113
- "type": "VOLCENGINE_VEFAAS_FUNCTION",
114
- "sid": "si:volcengine:insight-volc:dev:insight-poc-fn",
115
- "id": "test-function",
116
- "functionName": "test-function",
117
- "functionId": "func-123",
118
- "runtime": "node20/v1",
119
- "handler": "index.handler",
120
- "memorySize": 128,
121
- "timeout": 30,
122
- "environment": {},
123
- "status": "Active",
124
- "createdTime": null,
125
- "lastUpdateTime": null
126
- },
127
- {
128
- "sid": "si:volcengine:tls_topic:dev:insight-volc-app-dev-tls/insight-volc-dev-fn-logs",
129
- "id": "insight-volc-app-dev-tls/insight-volc-dev-fn-logs",
130
- "type": "VOLCENGINE_TLS_TOPIC",
131
- "topicName": "insight-volc-dev-fn-logs",
132
- "topicId": "topic-123"
133
- },
134
- {
135
- "sid": "si:volcengine:tls_index:dev:insight-volc-app-dev-tls/insight-volc-dev-fn-logs/index",
136
- "id": "insight-volc-app-dev-tls/insight-volc-dev-fn-logs/index",
137
- "type": "VOLCENGINE_TLS_INDEX"
138
- },
139
- {
140
- "sid": "si:volcengine:iam_role:dev:insight-volc-app-insight-volc-dev-role",
141
- "id": "insight-volc-app-insight-volc-dev-role",
142
- "type": "VOLCENGINE_IAM_ROLE",
143
- "trn": "trn:iam::123456789012:role/test-role",
144
- "roleName": "test-role",
145
- "roleId": "role-123"
146
- }
147
- ],
148
- "status": "ready",
149
- "lastUpdated": "2026-08-28T02:48:53.503Z"
150
- }
151
- },
152
- "lineage": "a61f5dda-66ef-405f-b377-da268afe24a4",
91
+ "lineage": "baa21867-64c2-45c9-9199-9727a751bc7b",
153
92
  "serial": 1
154
93
  }
package/README.md CHANGED
@@ -45,18 +45,6 @@ ServerlessInsight is a **cross-provider serverless framework** — it replaces c
45
45
 
46
46
  ## Installation
47
47
 
48
- <a href="https://www.npmjs.com/package/@geek-fun/serverlessinsight">
49
- <img src="https://img.shields.io/badge/npm_install-g_--g_@geek--fun/serverlessinsight-CB3837&logo=npm&logoColor=white" alt="npm install">
50
- </a>
51
- &nbsp;
52
- <a href="https://github.com/geek-fun/serverlessinsight/releases">
53
- <img src="https://img.shields.io/badge/Releases-GitHub-lightgrey&logo=github" alt="Releases">
54
- </a>
55
- &nbsp;
56
- <a href="https://serverlessinsight.geekfun.club">
57
- <img src="https://img.shields.io/badge/Docs-serverlessinsight.geekfun.club-blue&logo=gitbook&logoColor=white" alt="Docs">
58
- </a>
59
-
60
48
  ```bash
61
49
  npm install -g @geek-fun/serverlessinsight
62
50
  si --version
package/README.zh-CN.md CHANGED
@@ -1,116 +1,180 @@
1
+ <div align="center">
2
+
1
3
  # ServerlessInsight
2
4
 
3
- <div align="center">
5
+ **全生命周期跨云服务商的 Serverless 管理 —— 描述你的应用,其余交给我们。**
4
6
 
5
- [![Node.js CI](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml/badge.svg)](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml)
6
- [![release](https://github.com/geek-fun/serverlessinsight/actions/workflows/release.yml/badge.svg)](https://github.com/geek-fun/serverlessinsight/actions/workflows/release.yml)
7
- [![npm version](https://badge.fury.io/js/@geek-fun%2Fserverlessinsight.svg)](https://badge.fury.io/js/@geek-fun%2Fserverlessinsight)
8
- [![Known Vulnerabilities](https://snyk.io/test/github/geek-fun/serverlessinsight/badge.svg)](https://snyk.io/test/github/geek-fun/serverlessinsight)
9
- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
10
- [![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
7
+ **开源。多云。基础设施即代码。**
11
8
 
12
- **描述你的应用,剩下的交给我们。**
9
+ **面向阿里云 · 腾讯云 · 华为云 · 火山引擎的 Serverless 命令行工具。**
13
10
 
14
- *为快速增长的业务提供全生命周期跨云服务商的 Serverless 应用管理*
11
+ [![Release](https://img.shields.io/github/v/release/geek-fun/serverlessinsight?color=orange&label=release&logo=github)](https://github.com/geek-fun/serverlessinsight/releases)
12
+ [![npm version](https://img.shields.io/npm/v/@geek-fun/serverlessinsight?color=orange&logo=npm)](https://www.npmjs.com/package/@geek-fun/serverlessinsight)
13
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg&logo=apache)](LICENSE)
14
+ [![Stars](https://img.shields.io/github/stars/geek-fun/serverlessinsight&logo=github)](https://github.com/geek-fun/serverlessinsight/stargazers)
15
+ [![CI](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml/badge.svg)](https://github.com/geek-fun/serverlessinsight/actions/workflows/node.yml)
16
+
17
+ <p>
18
+ <img src="https://img.shields.io/badge/Node.js-339933&logo=nodedotjs&logoColor=white"/>
19
+ <img src="https://img.shields.io/badge/TypeScript-3178C6&logo=typescript&logoColor=white"/>
20
+ <img src="https://img.shields.io/badge/Alibaba%20Cloud-FF6A00&logo=alibabacloud&logoColor=white"/>
21
+ <img src="https://img.shields.io/badge/Tencent%20Cloud-0A9AED&logo=tencentqq&logoColor=white"/>
22
+ <img src="https://img.shields.io/badge/Huawei%20Cloud-FF0000&logo=hauwei&logoColor=white"/>
23
+ <img src="https://img.shields.io/badge/AWS-232F3E&logo=amazonwebservices&logoColor=white"/>
24
+ </p>
15
25
 
16
- [官方网站](https://serverlessinsight.geekfun.club) • [文档](https://serverlessinsight.geekfun.club) • [示例](./samples) • [English](./README.md)
26
+ [npm](https://www.npmjs.com/package/@geek-fun/serverlessinsight) · [文档](https://serverlessinsight.geekfun.club) · [官网](https://serverlessinsight.geekfun.club) · [GitHub](https://github.com/geek-fun/serverlessinsight)
27
+
28
+ 简体中文 · [English](README.md)
17
29
 
18
30
  </div>
19
31
 
20
32
  ---
21
33
 
22
- ServerlessInsight 是一个强大的 Serverless 框架,用于跨多个云服务商管理 Serverless 应用。它提供了统一的接口来部署、管理和调试 Serverless 函数和资源,使用基础设施即代码(IaC)原则。
34
+ ServerlessInsight 是一个**跨云服务商的 Serverless 框架**——它用统一的单一工具替代各家云厂商专属的 CLI、Web 控制台和 DIY 脚本。用 YAML 定义一次你的 Serverless 基础设施,即可部署到阿里云、腾讯云、华为云等。可将其视为面向 Serverless 的 Terraform,专为函数、API 网关、存储和数据库而打造。
23
35
 
24
- 无论您是在 AWS、阿里云、华为云还是其他服务商上构建应用,ServerlessInsight 都能简化您的开发工作流程:
36
+ <p align="center">
37
+ <img src="https://img.shields.io/badge/Alibaba%20Cloud-FF6A00?logo=alibabacloud&logoColor=white" />
38
+ <img src="https://img.shields.io/badge/Tencent%20Cloud-0A9AED?logo=tencentqq&logoColor=white" />
39
+ <img src="https://img.shields.io/badge/Huawei%20Cloud-FF0000?logo=huawei&logoColor=white" />
40
+ <img src="https://img.shields.io/badge/Volcengine-1677FF?logoColor=white" />
41
+ <img src="https://img.shields.io/badge/AWS-232F3E?logo=amazonwebservices&logoColor=white" />
42
+ <img src="https://img.shields.io/badge/Azure-0078D4?logo=microsoftazure&logoColor=white" />
43
+ <img src="https://img.shields.io/badge/GCP-4285F4?logo=googlecloud&logoColor=white" />
44
+ </p>
25
45
 
26
- - **多云支持** - 使用单一工具与多个云服务商协作
27
- - **基础设施即代码** - 使用 YAML 定义您的 Serverless 基础设施
28
- - **本地开发** - 在部署前本地测试您的函数
29
- - **类型安全模板** - 在部署前验证您的配置
46
+ ## 安装
30
47
 
31
- ---
32
-
33
- ## ✨ 特性
48
+ ```bash
49
+ npm install -g @geek-fun/serverlessinsight
50
+ si --version
51
+ ```
34
52
 
35
- - 🌍 **多云服务商支持** - 部署到阿里云、华为云等多个平台
36
- - 📦 **统一配置** - 所有服务商使用单一 YAML 格式
37
- - 🚀 **快速部署** - 使用单个命令部署 Serverless 应用
38
- - 🔍 **模板验证** - 在部署前验证您的 IaC 模板
39
- - 🏠 **本地测试** - 在本地运行和调试 Serverless 函数
40
- - 🔄 **模板生成** - 生成特定云服务商的 IaC 模板
41
- - 🌐 **API 网关集成** - 为您的函数配置 HTTP 端点
42
- - 🌐 **自定义域名绑定** - 支持 OSS 和 API 网关的自动域名绑定与 DNS 验证
43
- - 💾 **资源管理** - 管理存储、数据库和其他云资源
44
- - 🔐 **安全优先** - 内置验证和安全最佳实践
45
- - 📊 **全面的日志记录** - 调试和监控您的应用
53
+ ## 核心特性
46
54
 
47
- ---
55
+ ### 多云支持,统一配置
48
56
 
49
- ## ☁️ 支持的云服务商
57
+ 使用 YAML 一次性定义你的基础设施,即可部署到阿里云、腾讯云、华为云和火山引擎——AWS、Azure 和 GCP 已在路线图中。不再需要为每个云厂商疲于应付专属 CLI 或 Terraform 模块。
50
58
 
51
- ServerlessInsight 支持以下云服务商:
59
+ - **统一配置** —— 所有云服务商共用单一 `serverless.yml` 格式
60
+ - **云厂商专属模板生成** —— 根据配置生成原生 IaC 模板
61
+ - **跨云感知** —— 同一套抽象可在不同云之间通用
52
62
 
53
63
  | 云服务商 | 函数 | API 网关 | 存储 | 数据库 | 状态 |
54
64
  | ---------------- | ---------------- | ----------- | ----------- | ---------------- | ------ |
55
65
  | **阿里云** | ✅ FC3 | ✅ API 网关 | ✅ OSS | ✅ RDS, OTS, ESS | 稳定 |
56
66
  | **腾讯云** | ✅ SCF | 🚧 即将推出 | ✅ COS | ✅ TDSQL-C | 稳定 |
67
+ | **火山引擎** | ✅ veFaaS | ✅ API 网关 | ✅ TOS | — | 稳定 |
57
68
  | **华为云** | ✅ FunctionGraph | 🚧 即将推出 | 🚧 即将推出 | 🚧 即将推出 | 测试版 |
58
69
  | **AWS** | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 计划中 |
59
70
  | **Azure** | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 计划中 |
60
71
  | **Google Cloud** | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 🔜 计划中 | 计划中 |
61
72
 
62
- ---
73
+ ### 基础设施即代码
63
74
 
64
- ## 🚀 快速开始
75
+ 声明式 YAML 配置,内置校验、计划与状态管理——遵循成熟的 IaC 实践。
65
76
 
66
- ### 前置要求
77
+ - **部署前预览** —— `si plan` 在实际变更前精确展示将要发生的改动
78
+ - **状态追踪** —— 基于本地状态文件的增量部署与漂移检测
79
+ - **配置校验** —— 类型安全的模板校验在配置触达云端前捕获错误
80
+ - **部分失败恢复** —— 即使部分资源失败,已成功部署的资源仍会被保存;重试即可继续
67
81
 
68
- - **Node.js** 16.x 或更高版本
69
- - 云服务商凭证(阿里云 AccessKey、华为云凭证等)
82
+ ### 快速部署
70
83
 
71
- ### 安装
84
+ ```bash
85
+ # 校验你的配置
86
+ si validate -f serverless.yml
72
87
 
73
- 使用 npm 全局安装 ServerlessInsight:
88
+ # 预览变更
89
+ si plan -f serverless.yml
74
90
 
75
- ```bash
76
- npm install -g @geek-fun/serverlessinsight
91
+ # 部署到生产环境
92
+ si deploy -f serverless.yml -s prod
93
+
94
+ # 完成后销毁
95
+ si destroy -f serverless.yml
77
96
  ```
78
97
 
79
- 验证安装:
98
+ ### 本地开发
80
99
 
81
- ```bash
82
- si --version
83
- ```
100
+ 无需部署到云端,即可本地运行和调试你的 Serverless 函数。
84
101
 
85
- ---
102
+ - **LocalStack 服务** —— 在本地测试函数、存储桶和 API 端点
103
+ - **存储桶文件服务** —— 通过 HTTP 访问本地存储文件,加速迭代
104
+ - **同一配置,不同目标** —— `si local -f serverless.yml -s local` 复用你现有的配置
86
105
 
87
- ## 📚 使用方法
106
+ ### API 网关与自定义域名
88
107
 
89
- ```bash
90
- # 验证您的 Serverless 配置
91
- si validate -f serverless.yml
108
+ 配置 HTTP 端点并绑定自定义域名,附带自动 DNS 验证。
92
109
 
93
- # 生成部署计划(查看将要发生的变更)
94
- si plan -f serverless.yml
110
+ - **API 网关集成** —— 使用 HTTP 方法和路径定义触发器
111
+ - **自定义域名绑定** —— 为 OSS 和 API 网关自动完成 CNAME + DNS TXT 所有权验证
112
+ - **CDN 加速** —— 为静态站点提供边缘缓存与全球内容分发
113
+ - **OSS 传输加速** —— 通过阿里云骨干网进行跨区域数据传输
95
114
 
96
- # 部署您的 Serverless 应用
97
- si deploy -f serverless.yml -s dev
115
+ ### 资源管理
98
116
 
99
- # 本地运行您的应用进行调试
100
- si local -f serverless.yml -s local
117
+ 不止于函数——管理包含存储、数据库等在内的完整 Serverless 技术栈。
101
118
 
102
- # 显示已部署资源信息
103
- si show -f serverless.yml
119
+ - **对象存储** —— OSS(阿里云)、COS(腾讯云)、TOS(火山引擎)
120
+ - **数据库** —— RDS、OTS、ESS、TDSQL-C,更多陆续支持
121
+ - **Elasticsearch Serverless** —— 部署并管理 ES 集群
122
+ - **GPU 函数** —— 部署支持 GPU 的 Serverless 函数
104
123
 
105
- # 销毁已部署的堆栈
106
- si destroy -f serverless.yml
124
+ ### 架构
125
+
126
+ ServerlessInsight 采用**函数式客户端架构**,将云厂商 SDK 与业务逻辑清晰分离:
127
+
128
+ ```
129
+ ┌─────────────────────────────────────────┐
130
+ │ Resource / Planner / Executor Layer │ ← 与云厂商无关的业务逻辑
131
+ │ (纯函数,不引入 SDK) │
132
+ └─────────────────────────────────────────┘
133
+ ↓
134
+ ┌─────────────────────────────────────────┐
135
+ │ Functional Client Layer │ ← 封装的 SDK 操作
136
+ │ (aliyunClient.ts, tencentClient.ts) │
137
+ └─────────────────────────────────────────┘
138
+ ↓
139
+ ┌─────────────────────────────────────────┐
140
+ │ Cloud Provider SDKs │ ← @alicloud/*, tencentcloud-*
141
+ └─────────────────────────────────────────┘
107
142
  ```
108
143
 
109
- ---
144
+ - **函数式且纯粹** —— 业务逻辑使用不可变数据的纯函数
145
+ - **SDK 封装** —— 云厂商 SDK 仅能通过客户端模块访问
146
+ - **无类** —— 优先使用 `type` 而非 `interface`,优先采用函数式模式而非类
147
+
148
+ ## 开发
149
+
150
+ ServerlessInsight 基于 [Node.js](https://nodejs.org/) + [TypeScript](https://www.typescriptlang.org/)、[Commander.js](https://github.com/tj/commander.js/) CLI 构建,采用纯函数式架构。
151
+
152
+ ### 前置要求
153
+
154
+ - **Node.js** >= 16
155
+
156
+ ### 快速开始
157
+
158
+ ```bash
159
+ git clone https://github.com/geek-fun/serverlessinsight.git
160
+ cd serverlessinsight
161
+ npm install
162
+ npm run build
163
+ npm link
164
+ ```
110
165
 
111
- ## 💡 示例
166
+ ### 脚本
112
167
 
113
- ServerlessInsight 使用简单的 YAML 格式来定义您的 Serverless 基础设施:
168
+ | 命令 | 说明 |
169
+ | ------------------ | -------------------- |
170
+ | `npm run build` | TypeScript 编译 |
171
+ | `npm test` | 运行全部测试(含覆盖率) |
172
+ | `npm run test:unit` | 仅单元测试 |
173
+ | `npm run test:service` | 仅服务测试 |
174
+ | `npm run lint:check` | ESLint 检查 |
175
+ | `npm run lint:fix` | 自动修复 lint 问题 |
176
+
177
+ ### 示例配置
114
178
 
115
179
  ```yaml
116
180
  version: 0.0.1
@@ -129,8 +193,6 @@ functions:
129
193
  path: ./src
130
194
  memory: 512
131
195
  timeout: 10
132
- environment:
133
- NODE_ENV: production
134
196
 
135
197
  events:
136
198
  api_gateway:
@@ -142,207 +204,12 @@ events:
142
204
  backend: ${functions.hello_function}
143
205
  ```
144
206
 
145
- 更多示例请查看 [samples](./samples) 目录:
146
-
147
- - [API 网关示例](./samples/aliyun-poc-api.yml) - 部署带 HTTP 端点的函数
148
- - [存储示例](./samples/aliyun-poc-bucket.yml) - 配置 OSS 存储桶
149
- - [自定义域名示例](./samples/aliyun-poc-domain.yml) - 配置 OSS 静态网站托管与自定义域名绑定
150
- - [数据库示例](./samples/aliyun-poc-rds.yml) - 设置 RDS 数据库
151
- - [表格存储示例](./samples/aliyun-poc-table.yml) - 配置 OTS 表格存储
152
- - [Elasticsearch 示例](./samples/aliyun-poc-es.yml) - 部署 Elasticsearch Serverless
153
- - [GPU 函数示例](./samples/aliyun-poc-fc-gpu.yml) - 部署支持 GPU 的函数
154
- - [华为云示例](./samples/huawei-poc-fc.yml) - 部署到华为云 FunctionGraph
155
-
156
- ---
157
-
158
- ## 🔧 本地开发
159
-
160
- ```bash
161
- # 克隆和设置
162
- git clone https://github.com/geek-fun/serverlessinsight.git
163
- cd serverlessinsight
164
- npm install
165
-
166
- # 构建并链接用于开发
167
- npm run build
168
- npm link
169
-
170
- # 运行本地开发服务器
171
- si local -f serverless.yml -s local
207
+ 更多示例见 [samples](./samples) 目录。
172
208
 
173
- # 运行测试
174
- npm test
175
-
176
- # 检查代码规范
177
- npm run lint:check
178
- ```
179
-
180
- ---
181
-
182
- ## 🌐 自定义域名绑定
183
-
184
- ServerlessInsight 为 OSS 存储桶和 API 网关提供自动化的自定义域名绑定,内置 DNS 验证功能。
185
-
186
- ### OSS 自定义域名绑定
187
-
188
- 当您为 OSS 存储桶(静态网站托管)配置自定义域名时,ServerlessInsight 会自动:
189
-
190
- 1. **绑定域名**到您的 OSS 存储桶
191
- 2. **创建 DNS CNAME 记录**,指向正确的 OSS Endpoint
192
- 3. **处理域名所有权验证**,通过 DNS TXT 记录完成云服务商要求的验证
193
- 4. **管理重试逻辑**,通过 DNS 传播轮询确保绑定可靠
194
-
195
- ```yaml
196
- buckets:
197
- my_website:
198
- name: my-website-bucket
199
- security:
200
- acl: PUBLIC_READ
201
- website:
202
- code: ./dist
203
- domain: www.example.com # 自定义域名绑定
204
- index: index.html
205
- error_page: 404.html
206
- ```
207
-
208
- ### 域名所有权验证流程
209
-
210
- 当绑定需要所有权验证的自定义域名时:
211
-
212
- ```
213
- ┌─────────────────────────────────────────────────────────────────┐
214
- │ OSS 自定义域名绑定流程 │
215
- └─────────────────────────────────────────────────────────────────┘
216
- │
217
- ▼
218
- ┌───────────────────────┐
219
- │ PutCname (首次尝试) │
220
- └───────────────────────┘
221
- │
222
- ┌───────────────────┴───────────────────┐
223
- │ │
224
- ▼ ▼
225
- ┌───────────────┐ ┌─────────────────┐
226
- │ 绑定成功 │ │ 需要域名所有权 │
227
- └───────────────┘ │ 验证 │
228
- └─────────────────┘
229
- │
230
- ▼
231
- ┌─────────────────────────┐
232
- │ CreateCnameToken API │
233
- │ (获取 TXT 记录值) │
234
- └─────────────────────────┘
235
- │
236
- ▼
237
- ┌─────────────────────────┐
238
- │ 检查现有 TXT 记录 │
239
- │ (避免重复创建) │
240
- └─────────────────────────┘
241
- │
242
- ▼
243
- ┌─────────────────────────┐
244
- │ 添加 DNS TXT 记录 │
245
- │ (_dnsauth.domain) │
246
- └─────────────────────────┘
247
- │
248
- ▼
249
- ┌─────────────────────────┐
250
- │ 轮询 DNS 传播状态 │
251
- │ (最多 10 次 × 1 分钟) │
252
- └─────────────────────────┘
253
- │
254
- ▼
255
- ┌─────────────────────────┐
256
- │ 重试 PutCname │
257
- │ (最多 5 次 × 30 秒) │
258
- └─────────────────────────┘
259
- ```
260
-
261
- ### 支持的域名类型
262
-
263
- 对于 OSS 静态网站托管,ServerlessInsight 支持:
264
-
265
- | 域名类型 | CNAME 目标 | 使用场景 |
266
- | -------------- | -------------------------------- | --------------------------- |
267
- | 根域名 (`@`) | `bucket.region.taihangcda.cn` | 绕过根域名的 DNS CNAME 限制 |
268
- | 子域名 (`www`) | `bucket.oss-region.aliyuncs.com` | 标准 OSS Endpoint |
269
-
270
- 详细配置请参考 [OSS 自定义域名绑定指南](./docs/oss-custom-domain-binding.md)。
271
-
272
- ---
273
-
274
- ## 📘 文档
275
-
276
- 完整文档请访问 [serverlessinsight.geekfun.club](https://serverlessinsight.geekfun.club)
277
-
278
- 其他资源:
279
-
280
- - [快速开始指南](https://serverlessinsight.geekfun.club)
281
- - [配置参考](https://serverlessinsight.geekfun.club)
282
- - [API 文档](https://serverlessinsight.geekfun.club)
283
- - [最佳实践](https://serverlessinsight.geekfun.club)
284
-
285
- ---
286
-
287
- ## 🗄️ 状态管理
288
-
289
- ServerlessInsight 使用基于状态的部署模型,在本地状态文件 (`.serverlessinsight/state.json`) 中跟踪所有已部署的资源。这使得:
290
-
291
- - **增量部署** - 只有更改的资源才会被更新
292
- - **漂移检测** - 识别本地状态与云资源之间的差异
293
- - **安全销毁** - 知道要清理哪些资源
294
-
295
- ### 部分失败恢复
296
-
297
- 当部署多个资源时,如果其中一个失败,ServerlessInsight 确保:
298
-
299
- 1. **成功部署的资源始终保存到状态** - 即使后续资源失败,您的状态文件也将包含所有成功创建/更新/删除的资源
300
- 2. **清晰的错误报告** - 您将看到哪些资源成功,哪些资源失败
301
- 3. **轻松重试** - 只需再次运行 `deploy` 即可从中断的地方继续
302
-
303
- 部分失败输出示例:
304
-
305
- ```
306
- ⚠️ 部署部分失败: 2 个资源成功,但 functions.api_handler 失败。
307
- 已成功部署的资源状态已保存。再次运行 deploy 以重试失败的资源。
308
- 后续步骤: 1) 查看上面的错误, 2) 修复配置问题, 3) 再次运行 deploy 继续。
309
- ```
310
-
311
- ### 状态文件位置
312
-
313
- 状态文件存储在项目目录的 `.serverlessinsight/state.json` 中。此文件:
314
-
315
- - 应提交到版本控制以便团队协作
316
- - 包含资源元数据和标识符
317
- - 在每次成功操作后自动更新
318
-
319
- ### 状态恢复
320
-
321
- 如果遇到状态漂移(云资源存在但不在状态文件中):
322
-
323
- 1. **手动导入** - 目前,资源必须手动添加到状态文件
324
- 2. **重新开始** - 删除状态文件和云中的资源,然后重新部署
325
-
326
- > 💡 **提示**:在进行手动修改之前,请始终备份您的状态文件。
327
-
328
- ---
329
-
330
- ## 🤝 贡献
331
-
332
- 我们欢迎社区的贡献!以下是您可以帮助的方式:
333
-
334
- 1. **Fork 仓库**
335
- 2. **创建功能分支** (`git checkout -b feature/amazing-feature`)
336
- 3. **提交您的更改** (`git commit -m 'Add amazing feature'`)
337
- 4. **推送到分支** (`git push origin feature/amazing-feature`)
338
- 5. **打开 Pull Request**
339
-
340
- ---
341
-
342
- ## 👥 社区
209
+ ## 社区
343
210
 
344
211
  <p align="center">
345
- <img src="https://www.geekfun.club/wechat-group.jpg" width="140" alt="微信群">
212
+ <img src="https://www.geekfun.club/wechat-group.jpg" width="140" alt="WeChat Group">
346
213
  </p>
347
214
 
348
215
  <p align="center">
@@ -355,33 +222,26 @@ ServerlessInsight 使用基于状态的部署模型,在本地状态文件 (`.s
355
222
  <a href="https://github.com/geek-fun"><img src="https://img.shields.io/badge/GitHub-关注-181717?logo=github&logoColor=white" alt="GitHub" /></a>
356
223
  </p>
357
224
 
358
- ## Sponsor
225
+ ## 贡献
226
+
227
+ 欢迎贡献!提交 Issue 或 Pull Request 即可。编码规范请参见 [AGENTS.md](AGENTS.md)。
228
+
229
+ ## 赞助
359
230
 
360
231
  <p align="center">
361
232
  <a href="https://github.com/sponsors/geek-fun"><img src="https://img.shields.io/badge/GitHub_Sponsors-%E2%9D%A4_支持-EA4AAA?logo=githubsponsors&logoColor=white" alt="GitHub Sponsors" /></a>
362
233
  </p>
363
234
 
364
- ## 📄 许可证
365
-
366
- 本项目采用 Apache License 2.0 许可证 - 详见 [LICENSE](LICENSE) 文件。
367
-
368
- ---
369
-
370
- ## 🙏 致谢
371
-
372
- ServerlessInsight 使用以下优秀技术构建:
373
-
374
- - [Node.js](https://nodejs.org/) - JavaScript 运行时
375
- - [TypeScript](https://www.typescriptlang.org/) - 类型安全的 JavaScript
376
- - [Commander.js](https://github.com/tj/commander.js/) - CLI 框架
377
- - [阿里云 ROS CDK](https://github.com/aliyun/Resource-Orchestration-Service-Cloud-Development-Kit) - 云基础设施 SDK
378
-
379
- ---
380
-
381
- <div align="center">
235
+ ## Star 历史
382
236
 
383
- **由 [geek-fun](https://github.com/geek-fun) 团队用 ❤️ 制作**
237
+ <a href="https://www.star-history.com/?repos=geek-fun/serverlessinsight&type=date">
238
+ <picture>
239
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date&theme=dark" />
240
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date" />
241
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=geek-fun/serverlessinsight&type=date" />
242
+ </picture>
243
+ </a>
384
244
 
385
- [⬆ 回到顶部](#serverlessinsight)
245
+ ## 许可证
386
246
 
387
- </div>
247
+ [Apache 2.0](LICENSE) © GEEKFUN
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.com",
6
6
  "main": "dist/src/index.js",
@@ -157,7 +157,7 @@ const deploy = async (options) => {
157
157
  const failure = err;
158
158
  try {
159
159
  const partialState = await backend.loadState(iac.provider.name, iac.app, iac.service, options.stage ?? 'dev');
160
- failure.stateJson = partialState ?? {};
160
+ failure.stateJson = partialState ? (0, common_1.toPersistedState)(partialState) : {};
161
161
  }
162
162
  catch {
163
163
  // state may be unreadable mid-failure — plan alone is still useful
@@ -168,13 +168,11 @@ const deploy = async (options) => {
168
168
  // Read back the final state so the deployment record can link it
169
169
  // (console shows Changes + State JSON from the plan and state).
170
170
  const finalState = await backend.loadState(iac.provider.name, iac.app, iac.service, options.stage ?? 'dev');
171
+ const stateJson = finalState ? (0, common_1.toPersistedState)(finalState) : {};
171
172
  return {
172
173
  plan: { items: planResult.items },
173
- stateJson: finalState ?? {},
174
- contentHash: node_crypto_1.default
175
- .createHash('sha256')
176
- .update(JSON.stringify(finalState ?? {}))
177
- .digest('hex'),
174
+ stateJson,
175
+ contentHash: node_crypto_1.default.createHash('sha256').update(JSON.stringify(stateJson)).digest('hex'),
178
176
  resourceCount: Object.keys(finalState?.resources ?? {}).length,
179
177
  };
180
178
  }, {}, (lockId) => {
@@ -84,12 +84,11 @@ const createRemoteStateBackend = (adapter, config) => {
84
84
  app,
85
85
  service,
86
86
  stages: {},
87
- resources: {},
88
87
  };
89
88
  try {
90
89
  const raw = await adapter.read(config.key);
91
90
  if (raw)
92
- existing = raw;
91
+ existing = (0, stateManager_1.toPersistedState)(raw);
93
92
  }
94
93
  catch {
95
94
  // noop
@@ -107,7 +106,6 @@ const createRemoteStateBackend = (adapter, config) => {
107
106
  shared: state.stages?.[stage]?.shared ?? existing.stages?.[stage]?.shared ?? {},
108
107
  },
109
108
  },
110
- resources: state.resources,
111
109
  };
112
110
  await adapter.write(config.key, stateToSave);
113
111
  },
@@ -98,9 +98,19 @@ const createSaasStateBackend = (context) => {
98
98
  await ensureProvisioned(provider, stage);
99
99
  try {
100
100
  const state = await client.get(`/api/v1/apps/${resolvedAppId}/services/${resolvedServiceId}/state/current?stage=${encodeURIComponent(stage)}`);
101
+ const migrated = (0, stateManager_1.migrateState)(state.stateJson);
102
+ // Legacy Console states hold fresh resources only in the top-level
103
+ // field (pre-stage-syncing saves) — prefer the stage store, fall back.
104
+ const stageResources = migrated.stages?.[stage]?.resources;
105
+ const resources = stageResources && Object.keys(stageResources).length > 0
106
+ ? stageResources
107
+ : migrated.resources && Object.keys(migrated.resources).length > 0
108
+ ? migrated.resources
109
+ : {};
101
110
  // Attach console metadata so subsequent deploys have the UUIDs
102
111
  return {
103
- ...(0, stateManager_1.migrateState)(state.stateJson),
112
+ ...migrated,
113
+ resources,
104
114
  orgId,
105
115
  appId: resolvedAppId,
106
116
  serviceId: resolvedServiceId,
@@ -119,15 +129,26 @@ const createSaasStateBackend = (context) => {
119
129
  saveState: async (state, app, service, stage) => {
120
130
  // If not provisioned yet, use the state's provider for provisioning
121
131
  await ensureProvisioned(state.provider, stage);
122
- // The backend persists the full state file under state_json — send the whole
123
- // StateFile (not just resources) so loadState round-trips it unchanged.
132
+ // Sync the runtime projection into the stage store before stripping, so
133
+ // stages[stage].resources carries the fresh working set (mirrors the fs
134
+ // and remote backends' save contract)
135
+ const stateJson = (0, stateManager_1.toPersistedState)({
136
+ ...state,
137
+ stages: {
138
+ ...state.stages,
139
+ [stage]: {
140
+ ...state.stages?.[stage],
141
+ resources: state.resources,
142
+ },
143
+ },
144
+ });
124
145
  const body = {
125
146
  appName: app,
126
147
  serviceName: service,
127
148
  provider: state.provider,
128
149
  stage,
129
- stateJson: state,
130
- contentHash: node_crypto_1.default.createHash('sha256').update(JSON.stringify(state)).digest('hex'),
150
+ stateJson,
151
+ contentHash: node_crypto_1.default.createHash('sha256').update(JSON.stringify(stateJson)).digest('hex'),
131
152
  resourceCount: Object.keys(state.resources).length,
132
153
  };
133
154
  await client.post(`/api/v1/apps/${resolvedAppId}/services/${resolvedServiceId}/state/sync`, body);
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRoleArnFromState = exports.removeSharedResource = exports.setSharedResource = exports.getSharedResource = exports.getAllSharedResources = exports.getAllResources = exports.removeResource = exports.setResource = exports.getResource = exports.saveStateWithLock = exports.saveState = exports.loadState = exports.migrateState = exports.clearStateMigrations = exports.registerStateMigration = exports.ensureStateDir = exports.getStatePath = void 0;
6
+ exports.getRoleArnFromState = exports.removeSharedResource = exports.setSharedResource = exports.getSharedResource = exports.getAllSharedResources = exports.getAllResources = exports.removeResource = exports.setResource = exports.getResource = exports.saveStateWithLock = exports.saveState = exports.loadState = exports.toPersistedState = exports.migrateState = exports.clearStateMigrations = exports.registerStateMigration = exports.ensureStateDir = exports.getStatePath = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const node_crypto_1 = __importDefault(require("node:crypto"));
@@ -90,6 +90,12 @@ const migrateState = (raw) => {
90
90
  return migrated;
91
91
  };
92
92
  exports.migrateState = migrateState;
93
+ /** Strip the runtime-only `resources` projection — `stages` is the authoritative store (issue #225). */
94
+ const toPersistedState = (state) => {
95
+ const { resources: _projection, ...persisted } = state;
96
+ return persisted;
97
+ };
98
+ exports.toPersistedState = toPersistedState;
93
99
  /**
94
100
  * Load state file, scoped to the given stage.
95
101
  * The returned StateFile has `resources` populated from `stages[stage].resources`.
@@ -150,12 +156,11 @@ const saveState = (state, app, service, stage, baseDir = process.cwd()) => {
150
156
  app,
151
157
  service,
152
158
  stages: {},
153
- resources: {},
154
159
  };
155
160
  try {
156
161
  if (node_fs_1.default.existsSync(statePath)) {
157
162
  const content = node_fs_1.default.readFileSync(statePath, 'utf-8');
158
- existing = JSON.parse(content);
163
+ existing = (0, exports.toPersistedState)(JSON.parse(content));
159
164
  }
160
165
  }
161
166
  catch {
@@ -177,7 +182,6 @@ const saveState = (state, app, service, stage, baseDir = process.cwd()) => {
177
182
  shared: state.stages?.[stage]?.shared ?? existing.stages?.[stage]?.shared ?? {},
178
183
  },
179
184
  },
180
- resources: state.resources,
181
185
  };
182
186
  // Atomic write: back up the previous state, then write tmp + fsync + rename
183
187
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.com",
6
6
  "main": "dist/src/index.js",