@geek-fun/serverlessinsight 0.9.4 → 0.9.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.
- package/AGENTS.md +5 -2
- package/CHANGELOG.md +44 -0
- package/README.md +26 -6
- package/README.zh-CN.md +26 -6
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -1
- package/codecov.SHA256SUM.sig +13 -13
- package/dist/package.json +1 -1
- package/dist/src/commands/deploy.js +7 -2
- package/dist/src/commands/destroy.js +6 -3
- package/dist/src/commands/forceUnlock.js +16 -21
- package/dist/src/commands/index.js +14 -4
- package/dist/src/commands/migrate.js +105 -132
- package/dist/src/commands/plan.js +2 -2
- package/dist/src/commands/show.js +17 -6
- package/dist/src/common/aggregateState.js +185 -0
- package/dist/src/common/aggregateStore.js +247 -0
- package/dist/src/common/apiClient.js +35 -12
- package/dist/src/common/constants.js +2 -1
- package/dist/src/common/context.js +22 -15
- package/dist/src/common/effectiveConfig.js +48 -0
- package/dist/src/common/iacHelper.js +2 -2
- package/dist/src/common/index.js +5 -0
- package/dist/src/common/jsonOutput.js +2 -13
- package/dist/src/common/migrationMarker.js +0 -7
- package/dist/src/common/nameBuilder.js +2 -3
- package/dist/src/common/regionalMigration.js +261 -0
- package/dist/src/common/saasProtocol.js +41 -0
- package/dist/src/common/stateBackend/cosStateBackend.js +88 -8
- package/dist/src/common/stateBackend/index.js +42 -18
- package/dist/src/common/stateBackend/localStateBackend.js +61 -26
- package/dist/src/common/stateBackend/ossStateBackend.js +62 -9
- package/dist/src/common/stateBackend/remoteStateBackend.js +94 -94
- package/dist/src/common/stateBackend/saasStateBackend.js +327 -92
- package/dist/src/common/stateBackend/types.js +9 -0
- package/dist/src/common/stateManager.js +38 -11
- package/dist/src/common/stateScope.js +34 -0
- package/dist/src/common/stateStorageIO.js +31 -0
- package/dist/src/lang/en.js +43 -2
- package/dist/src/lang/zh-CN.js +43 -2
- package/dist/src/parser/index.js +33 -8
- package/dist/src/parser/templateValues.js +31 -0
- package/dist/src/stack/aliyunStack/deployer.js +5 -5
- package/dist/src/stack/aliyunStack/destroyer.js +5 -5
- package/dist/src/stack/aliyunStack/fc3Planner.js +1 -1
- package/dist/src/stack/aliyunStack/fc3Resource.js +2 -2
- package/dist/src/stack/aliyunStack/planner.js +1 -1
- package/dist/src/stack/aliyunStack/sharedLogProject.js +2 -2
- package/dist/src/stack/ownershipTag.js +34 -26
- package/dist/src/stack/scfStack/deployer.js +5 -5
- package/dist/src/stack/scfStack/destroyer.js +5 -6
- package/dist/src/stack/scfStack/planner.js +1 -1
- package/dist/src/stack/scfStack/scfResource.js +1 -1
- package/dist/src/stack/scfStack/sharedLogset.js +5 -2
- package/dist/src/stack/volcengineStack/deployer.js +3 -3
- package/dist/src/stack/volcengineStack/destroyer.js +2 -3
- package/dist/src/stack/volcengineStack/planner.js +1 -1
- package/dist/src/stack/volcengineStack/sharedLogProject.js +4 -4
- package/dist/src/stack/volcengineStack/vefaasResource.js +1 -1
- package/dist/src/types/domains/state.js +28 -2
- package/dist/src/validator/index.js +3 -1
- package/dist/src/validator/rootSchema.js +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/release-notes.md +8 -36
- package/samples/README_TENCENT_COS.md +65 -23
- package/samples/README_TENCENT_SCF.md +44 -26
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +0 -14
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +0 -32
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +0 -90
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +0 -118
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +0 -215
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +0 -14
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +0 -132
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +0 -55
- package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +0 -1
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +0 -93
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +0 -163
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +0 -148
package/AGENTS.md
CHANGED
|
@@ -179,7 +179,7 @@ All si-generated cloud resource names MUST come from shared builders — never i
|
|
|
179
179
|
|
|
180
180
|
| Resource | Builder (single source of truth) | Shape |
|
|
181
181
|
|---|---|---|
|
|
182
|
-
| Function execution role | `buildFunctionRoleName` (`src/common/nameBuilder.ts`) |
|
|
182
|
+
| Function execution role | `buildFunctionRoleName` (`src/common/nameBuilder.ts`) | `buildFunctionRoleName(serviceName, stage, region, fnKey)` — shared constrained builder; stored names take precedence |
|
|
183
183
|
| Role execution policy | `buildRolePolicyName` (`src/common/nameBuilder.ts`) | `${roleName}-policy` |
|
|
184
184
|
| Function log topic/logstore | per-provider shared-log module (`buildFunctionLogTopicName` / `buildFunctionLogstoreName`) | `${service}-${stage}-${fn.key}-fn-logs` |
|
|
185
185
|
| Shared log project/logset | `buildSharedProjectName` / `buildSharedLogsetName` | `${app}-${stage}-sls` / `-tls` / `-cls` |
|
|
@@ -761,7 +761,10 @@ export const createRamOperations = (ramClient: RamSdkClient) => ({
|
|
|
761
761
|
|
|
762
762
|
### State Management
|
|
763
763
|
|
|
764
|
-
-
|
|
764
|
+
- Local state is a V4 aggregate at `.serverlessinsight/state-{app}-{service}.json`; Bucket Store retains its configured key.
|
|
765
|
+
- Deploy, destroy and source-to-SaaS migrate automatically prepare V3 under the existing whole-file/key lock; read-only commands never persist upgrades.
|
|
766
|
+
- Partitions use `stages[stage].providers[provider].regions[region]` and share the whole-file lock.
|
|
767
|
+
- Executors/SaaS consume one V4 deployment view; SaaS uses scope protocol 3. App/Service stay literal; provider/region may be selected through CLI flags.
|
|
765
768
|
- Use `setResource`, `getResource`, `removeResource` from `src/common/stateManager`
|
|
766
769
|
- Resources have a `status`: `'ready'` | `'tainted'`
|
|
767
770
|
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Whole template references in string-capable scalar maps (`environment`,
|
|
13
|
+
`vars`, `stages` and `tags`) now preserve string results instead of inferring
|
|
14
|
+
numbers or booleans. For example, references resolving to `"00123"` and
|
|
15
|
+
`"false"` now retain those strings rather than becoming `123` and `false`.
|
|
16
|
+
Consumers of parsed scalar maps should update their type expectations.
|
|
17
|
+
Numeric and boolean YAML literals keep their types; references in typed
|
|
18
|
+
fields such as `memory`, `timeout` and `log` still infer the required type.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Preserve template results for string fields such as certificate IDs,
|
|
23
|
+
including leading zeros and long numeric strings, so valid configurations
|
|
24
|
+
pass resolved configuration validation without losing their original values.
|
|
25
|
+
|
|
26
|
+
## [0.9.5] - 2026-11-05
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Deployment state is now isolated per stage/provider/region: the first
|
|
31
|
+
deploy/destroy/migrate upgrades the legacy state file in place to a V4
|
|
32
|
+
aggregate (original backup kept), so deploying to a second region or
|
|
33
|
+
provider no longer touches another deployment's resources
|
|
34
|
+
([#280](https://github.com/geek-fun/serverlessinsight/issues/280)). CLI
|
|
35
|
+
versions older than this release refuse the upgraded state — upgrade all
|
|
36
|
+
writers together.
|
|
37
|
+
- SaaS deployments now require a Console with regional scope enabled (scope
|
|
38
|
+
protocol 3) and fail closed with guidance against older servers
|
|
39
|
+
([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- `--bind-unknown-region <region>` on `deploy`, `destroy` and `migrate` to
|
|
44
|
+
explicitly bind legacy state entries that carry no region evidence, instead
|
|
45
|
+
of letting the CLI guess where historical resources live
|
|
46
|
+
([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- Console/server conflict messages (state or protocol conflicts) are now
|
|
51
|
+
shown verbatim instead of a generic "HTTP Error 409"
|
|
52
|
+
([#280](https://github.com/geek-fun/serverlessinsight/issues/280)).
|
|
53
|
+
|
|
10
54
|
## [0.9.4] - 2026-10-27
|
|
11
55
|
|
|
12
56
|
### Changed
|
package/README.md
CHANGED
|
@@ -107,12 +107,12 @@ si local # run the app locally on http://localhost:4567
|
|
|
107
107
|
si destroy --stage prod # remove everything si created
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
`si` discovers `serverlessinsight.yml` in the current directory; pass `-f <path>` for a different file name. To target another cloud,
|
|
110
|
+
`si` discovers `serverlessinsight.yml` in the current directory; pass `-f <path>` for a different file name. To target another cloud, select `-v tencent` or `-v volcengine` with a valid region and a compatible resource configuration. The override selects an independent deployment; adapt unsupported runtimes or resources before deploying.
|
|
111
111
|
|
|
112
112
|
## Why ServerlessInsight
|
|
113
113
|
|
|
114
114
|
- **Serverless-native, not generic IaC.** Functions, triggers, API gateways, domains, buckets, databases and tables are first-class resources with provider-aware defaults — no hand-written Terraform modules or SDK wrapper scripts.
|
|
115
|
-
- **One
|
|
115
|
+
- **One configuration format across clouds.** Reuse supported primitives and stage variables across providers; validate each target configuration before deploying.
|
|
116
116
|
- **Plan before anything happens.** `si diff` reads state and live resources without writing anything; `si deploy` executes exactly the plan you approved, and manual console changes surface as drift.
|
|
117
117
|
- **Built for automation.** Logs go to stderr and machine-readable results to stdout, every JSON envelope is versioned, error codes are stable across locales, and exit codes follow Terraform conventions.
|
|
118
118
|
- **Real local development.** Run your handlers, HTTP routes, timer schedules and bucket endpoints locally with the same configuration — no cloud account or credentials needed.
|
|
@@ -122,11 +122,11 @@ si destroy --stage prod # remove everything si created
|
|
|
122
122
|
|
|
123
123
|
### Multi-cloud, one config
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
Use one configuration format across Alibaba Cloud, Tencent Cloud and Volcengine. Shared mappings handle supported provider differences; each target must support the declared runtimes and resources.
|
|
126
126
|
|
|
127
127
|
- **Unified configuration** — one `serverlessinsight.yml` format for every provider
|
|
128
128
|
- **Provider-specific mapping** — runtime names, trigger shapes and resource types are translated to native values
|
|
129
|
-
- **Cross-provider
|
|
129
|
+
- **Cross-provider validation** — unsupported target resources fail before cloud execution
|
|
130
130
|
|
|
131
131
|
### Plan before deploy
|
|
132
132
|
|
|
@@ -145,6 +145,25 @@ Volcengine plans include functions, TOS buckets and API Gateway resources in dep
|
|
|
145
145
|
|
|
146
146
|
**Exit codes**: `si diff` exits `0` when there are no changes, `2` when changes are present (Terraform convention), and `1` on errors. `si validate` exits `0` when valid and `1` when validation fails.
|
|
147
147
|
|
|
148
|
+
### Independent provider and region deployments
|
|
149
|
+
|
|
150
|
+
Deployment identity is `Org / App / Service / Stage / Provider / Region`.
|
|
151
|
+
`app` and `service` stay literal in YAML; `-s`, `-v` and `-r` select one deployment.
|
|
152
|
+
A compatible YAML can be reused, or separate YAML files can describe different regional
|
|
153
|
+
resources. Selecting the same scope and backend location addresses the same deployment.
|
|
154
|
+
Changing provider/region creates or updates the selected deployment and preserves the
|
|
155
|
+
previous deployment until an explicitly scoped destroy. Provider-specific declarations
|
|
156
|
+
must be supported by the target cloud; overrides do not translate unsupported resources.
|
|
157
|
+
|
|
158
|
+
Local state stays at `.serverlessinsight/state-<app>-<service>.json`; Bucket Store keeps
|
|
159
|
+
the exact configured `key`. Both store a V4 aggregate partitioned by stage/provider/region
|
|
160
|
+
under one whole-file lock. Executors and SaaS snapshots use a single-deployment V4 view;
|
|
161
|
+
SaaS mutations require scope protocol 3. Cloud accounts remain credential context rather
|
|
162
|
+
than another identity dimension.
|
|
163
|
+
|
|
164
|
+
See [deployment state and migration](docs/regional-deployment-state.md) for storage
|
|
165
|
+
credentials, automatic V3 upgrades, ownership handoff, lock behavior and recovery.
|
|
166
|
+
|
|
148
167
|
### Infrastructure as code
|
|
149
168
|
|
|
150
169
|
Declarative YAML with validation, planning and state management, following proven IaC patterns.
|
|
@@ -171,9 +190,9 @@ si schema | jq '."$id"' # self-contained draft-07 JSON Schema of the IaC forma
|
|
|
171
190
|
|
|
172
191
|
Stable output envelopes (each carries a version field, so shapes only ever change under a new version):
|
|
173
192
|
|
|
174
|
-
- `si diff --json` → `{ planVersion:
|
|
193
|
+
- `si diff --json` → `{ planVersion: 2, provider, app, service, stage, region, changes: [{ logicalId, type, action: "create|update|destroy|recreate", attributes, drifted?, driftReasons? }], summary: { create, update, destroy, recreate, unchanged } }`
|
|
175
194
|
- `si validate --json` → `{ validateVersion: 1, valid, errors: [{ path, keyword, message, allowedValues? }] }`
|
|
176
|
-
- `si show --json` → `{ showVersion:
|
|
195
|
+
- `si show --json` → `{ showVersion: 2, provider, app, service, stage, region, stateLocation, backend: "saas|bucket_store|local", locked, lock, resources, resourceCount, ... }`
|
|
177
196
|
- failures (in `--json` mode) → `{ error: { code, message } }` on stdout
|
|
178
197
|
|
|
179
198
|
Stable error codes: error `code`s are the i18n message keys behind the translated message (e.g. `RAM_ROLE_NOT_FOUND_IN_CLOUD`) — they are identical under every locale, so agents can map codes to self-healing actions regardless of `LANG`.
|
|
@@ -268,6 +287,7 @@ Notes:
|
|
|
268
287
|
| CLI reference | <https://serverlessinsight.com/cli.html> |
|
|
269
288
|
| JSON Schema | `si schema` (self-contained draft-07) |
|
|
270
289
|
| Local development | [docs/local-development.md](docs/local-development.md) |
|
|
290
|
+
| Deployment state | [docs/regional-deployment-state.md](docs/regional-deployment-state.md) |
|
|
271
291
|
| State locking | [docs/state-locking.md](docs/state-locking.md) |
|
|
272
292
|
| Architecture decisions | [docs/adr](docs/adr) |
|
|
273
293
|
| Samples | [samples](samples) |
|
package/README.zh-CN.md
CHANGED
|
@@ -107,12 +107,12 @@ si local # 在 http://localhost:4567 本地运行
|
|
|
107
107
|
si destroy --stage prod # 删除 si 创建的全部资源
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
`si`
|
|
110
|
+
`si` discovers `serverlessinsight.yml` in the current directory; use `-f <path>` for another file. Select another provider with `-v tencent` or `-v volcengine`, a valid region and a compatible resource configuration. The override selects an independent deployment; adapt unsupported runtimes/resources first.
|
|
111
111
|
|
|
112
112
|
## 为什么选择 ServerlessInsight
|
|
113
113
|
|
|
114
114
|
- **Serverless 原生,而非通用 IaC。** 函数、触发器、API 网关、域名、存储桶、数据库与数据表都是一等资源,并带有云厂商感知的默认值——无需手写 Terraform 模块或 SDK 封装脚本。
|
|
115
|
-
-
|
|
115
|
+
- **One configuration format across clouds.** Reuse supported primitives and variables; validate each target configuration before deployment.
|
|
116
116
|
- **变更之前先看计划。** `si diff` 只读取状态与线上资源、不写入任何内容;`si deploy` 执行的正是你确认过的那份计划,控制台里的手工改动会以漂移形式暴露。
|
|
117
117
|
- **为自动化而生。** 日志输出到 stderr,机器可读结果输出到 stdout,每个 JSON envelope 都带版本号,错误码跨语言环境保持稳定,退出码遵循 Terraform 惯例。
|
|
118
118
|
- **真正可用的本地开发。** 用同一份配置在本地运行处理函数、HTTP 路由、定时调度与存储桶端点——无需云账号或凭证。
|
|
@@ -122,11 +122,11 @@ si destroy --stage prod # 删除 si 创建的全部资源
|
|
|
122
122
|
|
|
123
123
|
### 多云支持,统一配置
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
Use one format across Alibaba Cloud, Tencent Cloud and Volcengine. Shared mappings handle supported differences; each target must support the declared runtimes and resources.
|
|
126
126
|
|
|
127
127
|
- **统一配置** —— 所有云厂商共用同一 `serverlessinsight.yml` 格式
|
|
128
128
|
- **厂商专属映射** —— 运行时名称、触发器结构与资源类型会翻译为对应云平台的原生值
|
|
129
|
-
-
|
|
129
|
+
- **Cross-provider validation** — unsupported target resources fail before cloud execution
|
|
130
130
|
|
|
131
131
|
### 部署前预览
|
|
132
132
|
|
|
@@ -145,6 +145,25 @@ si diff --stage dev --no-refresh
|
|
|
145
145
|
|
|
146
146
|
**退出码**:`si diff` 无变更时退出 `0`,有变更时退出 `2`(Terraform 惯例),出错时退出 `1`。`si validate` 校验通过退出 `0`,校验失败退出 `1`。
|
|
147
147
|
|
|
148
|
+
### Independent provider and region deployments
|
|
149
|
+
|
|
150
|
+
Deployment identity is `Org / App / Service / Stage / Provider / Region`.
|
|
151
|
+
`app` and `service` stay literal in YAML; `-s`, `-v` and `-r` select one deployment.
|
|
152
|
+
A compatible YAML can be reused, or separate YAML files can describe different regional
|
|
153
|
+
resources. Selecting the same scope and backend location addresses the same deployment.
|
|
154
|
+
Changing provider/region creates or updates the selected deployment and preserves the
|
|
155
|
+
previous deployment until an explicitly scoped destroy. Provider-specific declarations
|
|
156
|
+
must be supported by the target cloud; overrides do not translate unsupported resources.
|
|
157
|
+
|
|
158
|
+
Local state stays at `.serverlessinsight/state-<app>-<service>.json`; Bucket Store keeps
|
|
159
|
+
the exact configured `key`. Both store a V4 aggregate partitioned by stage/provider/region
|
|
160
|
+
under one whole-file lock. Executors and SaaS snapshots use a single-deployment V4 view;
|
|
161
|
+
SaaS mutations require scope protocol 3. Cloud accounts remain credential context rather
|
|
162
|
+
than another identity dimension.
|
|
163
|
+
|
|
164
|
+
See [deployment state and migration](docs/regional-deployment-state.md) for storage
|
|
165
|
+
credentials, automatic V3 upgrades, ownership handoff, lock behavior and recovery.
|
|
166
|
+
|
|
148
167
|
### 基础设施即代码
|
|
149
168
|
|
|
150
169
|
声明式 YAML 配置,内置校验、计划与状态管理,遵循成熟的 IaC 实践。
|
|
@@ -171,9 +190,9 @@ si schema | jq '."$id"' # IaC 格式的自包含 draft-07 JSON Schema
|
|
|
171
190
|
|
|
172
191
|
稳定的输出 envelope(每个都带版本号字段,结构只会在新版本号下变化):
|
|
173
192
|
|
|
174
|
-
- `si diff --json` → `{ planVersion:
|
|
193
|
+
- `si diff --json` → `{ planVersion: 2, provider, app, service, stage, region, changes: [{ logicalId, type, action: "create|update|destroy|recreate", attributes, drifted?, driftReasons? }], summary: { create, update, destroy, recreate, unchanged } }`
|
|
175
194
|
- `si validate --json` → `{ validateVersion: 1, valid, errors: [{ path, keyword, message, allowedValues? }] }`
|
|
176
|
-
- `si show --json` → `{ showVersion:
|
|
195
|
+
- `si show --json` → `{ showVersion: 2, provider, app, service, stage, region, stateLocation, backend: "saas|bucket_store|local", locked, lock, resources, resourceCount, ... }`
|
|
177
196
|
- 失败时(`--json` 模式)→ stdout 输出 `{ error: { code, message } }`
|
|
178
197
|
|
|
179
198
|
稳定的错误码:错误 `code` 是翻译消息背后的 i18n key(例如 `RAM_ROLE_NOT_FOUND_IN_CLOUD`)——在所有语言环境下保持一致,Agent 可以据此映射自愈动作,不受 `LANG` 影响。
|
|
@@ -268,6 +287,7 @@ functions:
|
|
|
268
287
|
| CLI 参考 | <https://serverlessinsight.com/cli.html> |
|
|
269
288
|
| JSON Schema | `si schema`(自包含 draft-07) |
|
|
270
289
|
| 本地开发 | [docs/local-development.md](docs/local-development.md) |
|
|
290
|
+
| Deployment state | [docs/regional-deployment-state.md](docs/regional-deployment-state.md) |
|
|
271
291
|
| 状态锁 | [docs/state-locking.md](docs/state-locking.md) |
|
|
272
292
|
| 架构决策记录 | [docs/adr](docs/adr) |
|
|
273
293
|
| 示例 | [samples](samples) |
|
package/codecov
CHANGED
|
Binary file
|
package/codecov.SHA256SUM
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8e1bfb71661378530f6ea21e82b414095899e565cbb4cf555c613064be17b973 codecov
|
package/codecov.SHA256SUM.sig
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
|
2
2
|
|
|
3
|
-
iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
=
|
|
3
|
+
iQIzBAABCgAdFiEEJwNOf9uFDgu8LGL/gGuyiu13mGkFAmriM1YACgkQgGuyiu13
|
|
4
|
+
mGlz3xAAjA+ezaisBIq/CFzGiqM3DBgyzhtC+1Jzdl4LXQV1a9gumHU0wLS4t91x
|
|
5
|
+
v20z2wrDq35SvClgEFX8zMoM6t7KJrQJ7+kHTtpzLLaHJt8TmxE94ZJZigduaObx
|
|
6
|
+
UjAG/JBEUQ+EVj1q5X5/O4hU/Uw+M+cj+NYSh3FEDSnUSR3mJOdhdvY3hJNAWOtN
|
|
7
|
+
M+oEfXyzMJG1Fcpf2P3vAhV6Dx2OR1RcKgLA2bYp4QwbBMvfGwiqURRR66QDqxWT
|
|
8
|
+
ErjiQsYshGgtPNHFktQjcse3aS7n2DvGI9sn0e+TfcOi3F2sxLz9wV7bFjRaaYG8
|
|
9
|
+
gNGY7BSFSrCStv0a0T3jk5n1DkTsRwMjPlSQEOicsau8Bh2qotwKuvMSkYzmwBOs
|
|
10
|
+
jFohe/KBdnV6wMiqRiXqAPga56gp5Cttf8kT7rRn6aT0uECEwTooeVDkmEeWBsV9
|
|
11
|
+
J7s+r62K1cBA6qIaKjUM603VKGAqmr5629SnXW+elagJnLIevT8czjqItSmECl0R
|
|
12
|
+
huRoUEsGwflwxzgfZU/h+EwU6aPFSbazNFxqNv3/MNGbEVjpihEiKfQnw9jfYauA
|
|
13
|
+
7wa3bLRRFvZaRBMnDvqYjXoefpPutP2fSPDgFKdDfE0DmC4cA6A45zez42vLcbDr
|
|
14
|
+
yz/kqWUWy5tqgEghGIT8AZysxnqfRwXuzi9uoewGoDMR8pTSahs=
|
|
15
|
+
=ps64
|
|
16
16
|
-----END PGP SIGNATURE-----
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Full-lifecycle serverless IaC for Alibaba Cloud, Tencent Cloud and Volcengine — one YAML to define, deploy and operate functions, API gateways, storage and databases.",
|
|
5
5
|
"homepage": "https://serverlessinsight.com",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -86,6 +86,11 @@ const deploy = async (options) => {
|
|
|
86
86
|
siApiKey: options.siApiKey,
|
|
87
87
|
migrationMarker: 'refuse',
|
|
88
88
|
});
|
|
89
|
+
await backend.upgradeLegacyState?.({ bindUnknownRegion: options.bindUnknownRegion });
|
|
90
|
+
const readiness = await backend.probeWriteReadiness();
|
|
91
|
+
if (!readiness.ready) {
|
|
92
|
+
throw new Error(readiness.reason ?? lang_1.lang.__('STATE_WRITE_NOT_READY'));
|
|
93
|
+
}
|
|
89
94
|
// ADR-005: wire the backend's event reporter into the global context so
|
|
90
95
|
// executors can emit per-resource deployment events via context.reportEvent.
|
|
91
96
|
if (backend.reportEvent) {
|
|
@@ -165,7 +170,7 @@ const deploy = async (options) => {
|
|
|
165
170
|
// error; withLock's fail branch forwards them.
|
|
166
171
|
const failure = err;
|
|
167
172
|
try {
|
|
168
|
-
const partialState = await backend.loadState(
|
|
173
|
+
const partialState = await backend.loadState();
|
|
169
174
|
failure.stateJson = partialState ? (0, common_1.toPersistedState)(partialState) : {};
|
|
170
175
|
}
|
|
171
176
|
catch {
|
|
@@ -176,7 +181,7 @@ const deploy = async (options) => {
|
|
|
176
181
|
}
|
|
177
182
|
// Read back the final state so the deployment record can link it
|
|
178
183
|
// (console shows Changes + State JSON from the plan and state).
|
|
179
|
-
const finalState = await backend.loadState(
|
|
184
|
+
const finalState = await backend.loadState();
|
|
180
185
|
const stateJson = finalState ? (0, common_1.toPersistedState)(finalState) : {};
|
|
181
186
|
return {
|
|
182
187
|
plan: { items: planResult.items },
|
|
@@ -33,9 +33,12 @@ const destroyStack = async (options) => {
|
|
|
33
33
|
declaredOrg: iac.org,
|
|
34
34
|
migrationMarker: 'refuse',
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await backend.
|
|
36
|
+
await backend.upgradeLegacyState?.({ bindUnknownRegion: options.bindUnknownRegion });
|
|
37
|
+
await backend.loadState();
|
|
38
|
+
const readiness = await backend.probeWriteReadiness();
|
|
39
|
+
if (!readiness.ready) {
|
|
40
|
+
throw new Error(readiness.reason ?? lang_1.lang.__('STATE_WRITE_NOT_READY'));
|
|
41
|
+
}
|
|
39
42
|
// ADR-005: wire the backend's event reporter into the global context so
|
|
40
43
|
// executors can emit per-resource deployment events via context.reportEvent.
|
|
41
44
|
if (backend.reportEvent) {
|
|
@@ -52,13 +52,23 @@ const forceUnlockCommand = async (lockId, options = {}) => {
|
|
|
52
52
|
else {
|
|
53
53
|
const stateDir = node_path_1.default.join(process.cwd(), '.serverlessinsight');
|
|
54
54
|
let foundStatePath;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const lockContent = node_fs_1.default.readFileSync(node_path_1.default.join(stateDir, lockFiles[0]), 'utf-8');
|
|
59
|
-
const lockMeta = JSON.parse(lockContent);
|
|
60
|
-
foundStatePath = lockMeta.path;
|
|
55
|
+
const findLockFiles = (dir) => {
|
|
56
|
+
if (!node_fs_1.default.existsSync(dir)) {
|
|
57
|
+
return [];
|
|
61
58
|
}
|
|
59
|
+
return node_fs_1.default.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
60
|
+
const full = node_path_1.default.join(dir, entry.name);
|
|
61
|
+
if (entry.isDirectory()) {
|
|
62
|
+
return findLockFiles(full);
|
|
63
|
+
}
|
|
64
|
+
return entry.name.endsWith(constants_1.LOCK_FILE_SUFFIX) ? [full] : [];
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const lockFiles = findLockFiles(stateDir);
|
|
68
|
+
if (lockFiles.length > 0) {
|
|
69
|
+
const lockContent = node_fs_1.default.readFileSync(lockFiles[0], 'utf-8');
|
|
70
|
+
const lockMeta = JSON.parse(lockContent);
|
|
71
|
+
foundStatePath = lockMeta.path;
|
|
62
72
|
}
|
|
63
73
|
if (!foundStatePath) {
|
|
64
74
|
common_1.logger.error(lang_1.lang.__('NO_LOCK_FOUND'));
|
|
@@ -68,21 +78,6 @@ const forceUnlockCommand = async (lockId, options = {}) => {
|
|
|
68
78
|
backend = {
|
|
69
79
|
readLock: async () => (0, lockManager_1.readLockFileForCommand)(statePath),
|
|
70
80
|
forceUnlock: async (id) => (0, lockManager_1.forceUnlock)(statePath, id),
|
|
71
|
-
loadState: async () => {
|
|
72
|
-
throw new Error(lang_1.lang.__('FORCE_UNLOCK_NO_LOCATION_MODE'));
|
|
73
|
-
},
|
|
74
|
-
saveState: async () => {
|
|
75
|
-
throw new Error(lang_1.lang.__('FORCE_UNLOCK_NO_LOCATION_MODE'));
|
|
76
|
-
},
|
|
77
|
-
acquireLock: async () => {
|
|
78
|
-
throw new Error(lang_1.lang.__('FORCE_UNLOCK_NO_LOCATION_MODE'));
|
|
79
|
-
},
|
|
80
|
-
releaseLock: async () => {
|
|
81
|
-
throw new Error(lang_1.lang.__('FORCE_UNLOCK_NO_LOCATION_MODE'));
|
|
82
|
-
},
|
|
83
|
-
withLock: async () => {
|
|
84
|
-
throw new Error(lang_1.lang.__('FORCE_UNLOCK_NO_LOCATION_MODE'));
|
|
85
|
-
},
|
|
86
81
|
};
|
|
87
82
|
}
|
|
88
83
|
// Check if lock exists
|
|
@@ -120,14 +120,18 @@ program
|
|
|
120
120
|
.description(lang_1.lang.__('CMD_SHOW_DESC'))
|
|
121
121
|
.option('-f, --file <path>', lang_1.lang.__('OPT_FILE'))
|
|
122
122
|
.option('-s, --stage <stage>', lang_1.lang.__('OPT_STAGE'))
|
|
123
|
+
.option('-r, --region <region>', lang_1.lang.__('OPT_REGION'))
|
|
124
|
+
.option('-v, --provider <provider>', lang_1.lang.__('OPT_PROVIDER'))
|
|
123
125
|
.option('--json', lang_1.lang.__('OPT_JSON'))
|
|
124
|
-
.action(actionWrapper('show', async ({ file, stage, json }) => {
|
|
126
|
+
.action(actionWrapper('show', async ({ file, stage, region, provider, json }) => {
|
|
125
127
|
(0, jsonOutput_1.setJsonMode)(!!json);
|
|
126
128
|
const iacLocation = (0, common_1.getIacLocation)(file);
|
|
127
129
|
const rawIac = (0, parser_1.parseYaml)(iacLocation);
|
|
128
130
|
await (0, common_1.setContext)({
|
|
129
131
|
location: file,
|
|
130
132
|
stage,
|
|
133
|
+
region,
|
|
134
|
+
provider,
|
|
131
135
|
app: rawIac.app,
|
|
132
136
|
service: rawIac.service,
|
|
133
137
|
iacProvider: rawIac.provider,
|
|
@@ -180,6 +184,7 @@ program
|
|
|
180
184
|
.option('-f, --file <path>', lang_1.lang.__('OPT_FILE'))
|
|
181
185
|
.option('-s, --stage <stage>', lang_1.lang.__('OPT_STAGE'))
|
|
182
186
|
.option('-r, --region <region>', lang_1.lang.__('OPT_REGION'))
|
|
187
|
+
.option('--bind-unknown-region <region>', lang_1.lang.__('OPT_BIND_UNKNOWN_REGION'))
|
|
183
188
|
.option('-v, --provider <provider>', lang_1.lang.__('OPT_PROVIDER'))
|
|
184
189
|
.option('-k, --accessKeyId <accessKeyId>', lang_1.lang.__('OPT_ACCESS_KEY_ID'))
|
|
185
190
|
.option('-x, --accessKeySecret <accessKeySecret>', lang_1.lang.__('OPT_ACCESS_KEY_SECRET'))
|
|
@@ -192,12 +197,13 @@ program
|
|
|
192
197
|
previous[key] = val;
|
|
193
198
|
return previous;
|
|
194
199
|
}, {})
|
|
195
|
-
.action(actionWrapper('deploy', async ({ stage, parameter, file, region, provider, accessKeyId, accessKeySecret, securityToken, siApiKey, autoApprove, refresh, }) => {
|
|
200
|
+
.action(actionWrapper('deploy', async ({ stage, parameter, file, region, bindUnknownRegion, provider, accessKeyId, accessKeySecret, securityToken, siApiKey, autoApprove, refresh, }) => {
|
|
196
201
|
await (0, deploy_1.deploy)({
|
|
197
202
|
stage,
|
|
198
203
|
parameters: parameter,
|
|
199
204
|
location: file,
|
|
200
205
|
region,
|
|
206
|
+
bindUnknownRegion,
|
|
201
207
|
provider,
|
|
202
208
|
accessKeyId,
|
|
203
209
|
accessKeySecret,
|
|
@@ -223,7 +229,8 @@ program
|
|
|
223
229
|
.option('--no-marker', lang_1.lang.__('OPT_NO_MARKER'))
|
|
224
230
|
.option('--dry-run', lang_1.lang.__('OPT_DRY_RUN'))
|
|
225
231
|
.option('--rollback', lang_1.lang.__('OPT_ROLLBACK'))
|
|
226
|
-
.
|
|
232
|
+
.option('--bind-unknown-region <region>', lang_1.lang.__('OPT_BIND_UNKNOWN_REGION'))
|
|
233
|
+
.action(actionWrapper('migrate', async ({ stage, file, region, provider, accessKeyId, accessKeySecret, securityToken, siApiKey, autoApprove, force, marker, dryRun, rollback, bindUnknownRegion, }) => {
|
|
227
234
|
await (0, migrate_1.migrate)({
|
|
228
235
|
stage,
|
|
229
236
|
location: file,
|
|
@@ -240,6 +247,7 @@ program
|
|
|
240
247
|
noMarker: marker === false,
|
|
241
248
|
dryRun,
|
|
242
249
|
rollback,
|
|
250
|
+
bindUnknownRegion,
|
|
243
251
|
});
|
|
244
252
|
}));
|
|
245
253
|
program
|
|
@@ -247,16 +255,18 @@ program
|
|
|
247
255
|
.option('-f, --file <path>', lang_1.lang.__('OPT_FILE'))
|
|
248
256
|
.option('-s, --stage <stage>', lang_1.lang.__('OPT_STAGE'))
|
|
249
257
|
.option('-r, --region <region>', lang_1.lang.__('OPT_REGION'))
|
|
258
|
+
.option('--bind-unknown-region <region>', lang_1.lang.__('OPT_BIND_UNKNOWN_REGION'))
|
|
250
259
|
.option('-v, --provider <provider>', lang_1.lang.__('OPT_PROVIDER'))
|
|
251
260
|
.option('-k, --accessKeyId <accessKeyId>', lang_1.lang.__('OPT_ACCESS_KEY_ID'))
|
|
252
261
|
.option('-x, --accessKeySecret <accessKeySecret>', lang_1.lang.__('OPT_ACCESS_KEY_SECRET'))
|
|
253
262
|
.option('-n, --securityToken <securityToken>', lang_1.lang.__('OPT_SECURITY_TOKEN'))
|
|
254
263
|
.description(lang_1.lang.__('CMD_DESTROY_DESC'))
|
|
255
|
-
.action(actionWrapper('destroy', async ({ file, stage, region, provider, accessKeyId, accessKeySecret, securityToken }) => {
|
|
264
|
+
.action(actionWrapper('destroy', async ({ file, stage, region, bindUnknownRegion, provider, accessKeyId, accessKeySecret, securityToken, }) => {
|
|
256
265
|
await (0, destroy_1.destroyStack)({
|
|
257
266
|
location: file,
|
|
258
267
|
stage,
|
|
259
268
|
region,
|
|
269
|
+
bindUnknownRegion,
|
|
260
270
|
provider,
|
|
261
271
|
accessKeyId,
|
|
262
272
|
accessKeySecret,
|