@geek-fun/serverlessinsight 0.9.3 → 0.9.4
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/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -3
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +2 -2
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/CHANGELOG.md +28 -0
- package/README.md +246 -179
- package/README.zh-CN.md +244 -147
- package/dist/package.json +22 -19
- package/dist/src/commands/index.js +12 -59
- package/dist/src/commands/plan.js +25 -1
- package/dist/src/common/aliyunClient/apigwOperations.js +32 -9
- package/dist/src/lang/en.js +5 -4
- package/dist/src/lang/index.js +28 -14
- package/dist/src/lang/zh-CN.js +5 -4
- package/dist/src/stack/aliyunStack/apigwDomainPlan.js +82 -0
- package/dist/src/stack/aliyunStack/apigwExecutor.js +4 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +115 -55
- package/dist/src/stack/aliyunStack/apigwResource.js +169 -124
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/release-notes.md +33 -59
- package/samples/README_TENCENT_COS.md +3 -3
- package/samples/README_TENCENT_SCF.md +3 -3
|
@@ -153,46 +153,9 @@ program
|
|
|
153
153
|
process.exitCode = 1;
|
|
154
154
|
}
|
|
155
155
|
}));
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.option('-f, --file <path>', lang_1.lang.__('OPT_FILE'))
|
|
160
|
-
.option('-s, --stage <stage>', lang_1.lang.__('OPT_STAGE'))
|
|
161
|
-
.option('-r, --region <region>', lang_1.lang.__('OPT_REGION'))
|
|
162
|
-
.option('-v, --provider <provider>', lang_1.lang.__('OPT_PROVIDER'))
|
|
163
|
-
.option('-k, --accessKeyId <accessKeyId>', lang_1.lang.__('OPT_ACCESS_KEY_ID'))
|
|
164
|
-
.option('-x, --accessKeySecret <accessKeySecret>', lang_1.lang.__('OPT_ACCESS_KEY_SECRET'))
|
|
165
|
-
.option('-n, --securityToken <securityToken>', lang_1.lang.__('OPT_SECURITY_TOKEN'))
|
|
166
|
-
.option('--no-refresh', lang_1.lang.__('OPT_NO_REFRESH'))
|
|
167
|
-
.option('--json', lang_1.lang.__('OPT_JSON'))
|
|
168
|
-
.option('--no-color', lang_1.lang.__('OPT_NO_COLOR'))
|
|
169
|
-
.option('-p, --parameter <key=value>', lang_1.lang.__('OPT_PARAMETER'), (value, previous) => {
|
|
170
|
-
const [key, val] = value.split('=');
|
|
171
|
-
return { ...previous, [key]: val };
|
|
172
|
-
}, {})
|
|
173
|
-
.action(actionWrapper('plan', async ({ stage, parameter, file, region, provider, accessKeyId, accessKeySecret, securityToken, refresh, json, color, }) => {
|
|
174
|
-
(0, jsonOutput_1.setJsonMode)(!!json);
|
|
175
|
-
const result = await (0, plan_1.plan)({
|
|
176
|
-
stage,
|
|
177
|
-
parameters: parameter,
|
|
178
|
-
location: file,
|
|
179
|
-
region,
|
|
180
|
-
provider,
|
|
181
|
-
accessKeyId,
|
|
182
|
-
accessKeySecret,
|
|
183
|
-
securityToken,
|
|
184
|
-
refresh,
|
|
185
|
-
json: !!json,
|
|
186
|
-
noColor: color === false,
|
|
187
|
-
});
|
|
188
|
-
// Issue #250 exit-code convention (terraform-compatible):
|
|
189
|
-
// 0 = no changes, 2 = changes present, 1 = execution error (handler).
|
|
190
|
-
if (result.hasChanges) {
|
|
191
|
-
process.exitCode = 2;
|
|
192
|
-
}
|
|
193
|
-
}));
|
|
194
|
-
// Issue #246: `diff` is the primary verb users say — it runs the same plan
|
|
195
|
-
// flow; `plan` stays for compatibility.
|
|
156
|
+
// Issue #246/#271: `diff` is the sole verb for previewing deployment changes;
|
|
157
|
+
// the legacy `plan` verb is removed. Options and the action handler are
|
|
158
|
+
// defined exactly once.
|
|
196
159
|
program
|
|
197
160
|
.command('diff')
|
|
198
161
|
.description(lang_1.lang.__('CMD_DIFF_DESC'))
|
|
@@ -210,25 +173,7 @@ program
|
|
|
210
173
|
const [key, val] = value.split('=');
|
|
211
174
|
return { ...previous, [key]: val };
|
|
212
175
|
}, {})
|
|
213
|
-
.action(actionWrapper('diff',
|
|
214
|
-
(0, jsonOutput_1.setJsonMode)(!!json);
|
|
215
|
-
const result = await (0, plan_1.plan)({
|
|
216
|
-
stage,
|
|
217
|
-
parameters: parameter,
|
|
218
|
-
location: file,
|
|
219
|
-
region,
|
|
220
|
-
provider,
|
|
221
|
-
accessKeyId,
|
|
222
|
-
accessKeySecret,
|
|
223
|
-
securityToken,
|
|
224
|
-
refresh,
|
|
225
|
-
json: !!json,
|
|
226
|
-
noColor: color === false,
|
|
227
|
-
});
|
|
228
|
-
if (result.hasChanges) {
|
|
229
|
-
process.exitCode = 2;
|
|
230
|
-
}
|
|
231
|
-
}));
|
|
176
|
+
.action(actionWrapper('diff', plan_1.runDiffCommand));
|
|
232
177
|
program
|
|
233
178
|
.command('deploy')
|
|
234
179
|
.description(lang_1.lang.__('CMD_DEPLOY_DESC'))
|
|
@@ -358,4 +303,12 @@ program
|
|
|
358
303
|
securityToken,
|
|
359
304
|
});
|
|
360
305
|
}));
|
|
306
|
+
// Issue #271: `si plan` was removed in favor of `si diff` — the legacy verb is
|
|
307
|
+
// rejected with a localized migration hint before anything runs (no cloud or
|
|
308
|
+
// state mutations). The check runs before commander parses argv so the hint
|
|
309
|
+
// also wins over generic unknown-command handling, while every other unknown
|
|
310
|
+
// verb keeps commander's default error, including did-you-mean suggestions.
|
|
311
|
+
if (process.argv[2] === 'plan') {
|
|
312
|
+
program.error(`error: ${lang_1.lang.__('CMD_PLAN_REMOVED')}`);
|
|
313
|
+
}
|
|
361
314
|
program.parse();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plan = void 0;
|
|
3
|
+
exports.runDiffCommand = exports.plan = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const stateBackend_1 = require("../common/stateBackend");
|
|
6
6
|
const jsonOutput_1 = require("../common/jsonOutput");
|
|
@@ -76,3 +76,27 @@ const plan = async (options) => {
|
|
|
76
76
|
return { hasChanges: changeCount > 0 };
|
|
77
77
|
};
|
|
78
78
|
exports.plan = plan;
|
|
79
|
+
// Single action implementation behind `si diff`, the sole command for
|
|
80
|
+
// previewing deployment changes (issue #271).
|
|
81
|
+
const runDiffCommand = async (options) => {
|
|
82
|
+
(0, jsonOutput_1.setJsonMode)(!!options.json);
|
|
83
|
+
const result = await (0, exports.plan)({
|
|
84
|
+
stage: options.stage,
|
|
85
|
+
parameters: options.parameter,
|
|
86
|
+
location: options.file,
|
|
87
|
+
region: options.region,
|
|
88
|
+
provider: options.provider,
|
|
89
|
+
accessKeyId: options.accessKeyId,
|
|
90
|
+
accessKeySecret: options.accessKeySecret,
|
|
91
|
+
securityToken: options.securityToken,
|
|
92
|
+
refresh: options.refresh,
|
|
93
|
+
json: !!options.json,
|
|
94
|
+
noColor: options.color === false,
|
|
95
|
+
});
|
|
96
|
+
// Issue #250 exit-code convention (terraform-compatible):
|
|
97
|
+
// 0 = no changes, 2 = changes present, 1 = execution error (handler).
|
|
98
|
+
if (result.hasChanges) {
|
|
99
|
+
process.exitCode = 2;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.runDiffCommand = runDiffCommand;
|
|
@@ -358,6 +358,36 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
358
358
|
logger_1.logger.error(`\n${separator}\n${lang_1.lang.__('APIGW_VERIFICATION_NEXT_STEPS')}\n${lang_1.lang.__('APIGW_VERIFICATION_STEP1')}\n${lang_1.lang.__('APIGW_VERIFICATION_STEP2')}\n${separator}\n`);
|
|
359
359
|
};
|
|
360
360
|
const operations = {
|
|
361
|
+
deleteDomainCertificate: async (groupId, domainName) => {
|
|
362
|
+
try {
|
|
363
|
+
const response = await apigwClient.describeDomain(new cloudapi.DescribeDomainRequest({ groupId, domainName }));
|
|
364
|
+
if (!response.body?.domainName ||
|
|
365
|
+
(!response.body.certificateId && response.body.certificateBody)) {
|
|
366
|
+
throw new Error(lang_1.lang.__('APIGW_DOMAIN_READ_INVALID', { domainId: domainName }));
|
|
367
|
+
}
|
|
368
|
+
if (!response.body.certificateId)
|
|
369
|
+
return;
|
|
370
|
+
await apigwClient.deleteDomainCertificate(new cloudapi.DeleteDomainCertificateRequest({
|
|
371
|
+
groupId,
|
|
372
|
+
domainName,
|
|
373
|
+
certificateId: response.body.certificateId,
|
|
374
|
+
}));
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
if (!(0, exports.isApigwNotFoundError)(error))
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
setDomainCertificate: async (config) => {
|
|
382
|
+
await apigwClient.setDomainCertificate(new cloudapi.SetDomainCertificateRequest({
|
|
383
|
+
groupId: config.groupId,
|
|
384
|
+
domainName: config.domainName,
|
|
385
|
+
certificateName: config.certificateName,
|
|
386
|
+
certificateBody: config.certificateBody,
|
|
387
|
+
certificatePrivateKey: config.certificatePrivateKey,
|
|
388
|
+
}));
|
|
389
|
+
logger_1.logger.info(lang_1.lang.__('APIGW_DOMAIN_CERTIFICATE_UPDATED', { domain: config.domainName }));
|
|
390
|
+
},
|
|
361
391
|
/**
|
|
362
392
|
* Create an API Gateway group
|
|
363
393
|
*/
|
|
@@ -385,7 +415,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
385
415
|
throw new Error(lang_1.lang.__('APIGW_DOMAIN_READ_INVALID', { domainId: domainName }));
|
|
386
416
|
return {
|
|
387
417
|
domainName: response.body.domainName,
|
|
388
|
-
certificateBody: response.body.certificateBody
|
|
418
|
+
certificateBody: response.body.certificateBody || (response.body.certificateId ? undefined : null),
|
|
389
419
|
};
|
|
390
420
|
}
|
|
391
421
|
catch (error) {
|
|
@@ -1008,14 +1038,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
1008
1038
|
});
|
|
1009
1039
|
const setCertificate = async () => {
|
|
1010
1040
|
if (config.certificateName && config.certificateBody && config.certificatePrivateKey) {
|
|
1011
|
-
|
|
1012
|
-
groupId: config.groupId,
|
|
1013
|
-
domainName: config.domainName,
|
|
1014
|
-
certificateName: config.certificateName,
|
|
1015
|
-
certificateBody: config.certificateBody,
|
|
1016
|
-
certificatePrivateKey: config.certificatePrivateKey,
|
|
1017
|
-
});
|
|
1018
|
-
await apigwClient.setDomainCertificate(certRequest);
|
|
1041
|
+
await operations.setDomainCertificate(config);
|
|
1019
1042
|
}
|
|
1020
1043
|
};
|
|
1021
1044
|
try {
|
package/dist/src/lang/en.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.en = {
|
|
|
5
5
|
PLAN_SENSITIVE_VALUE: '(sensitive)',
|
|
6
6
|
PLAN_NAS_NETWORK_REQUIRED: 'NAS storage on {{logicalId}} needs a declared VPC network or recorded mount targets. Planning stopped before creating any resources.',
|
|
7
7
|
APIGW_DOMAIN_READ_INVALID: 'Invalid domain response for: {{domainId}}',
|
|
8
|
+
APIGW_DOMAIN_CERTIFICATE_UPDATED: 'Updated gateway certificate for domain: {{domain}}',
|
|
8
9
|
PLAN_DRIFT_EVENT_DOMAIN: 'Gateway domain or certificate differs from the requested configuration or is missing',
|
|
9
10
|
PLAN_DRIFT_HTTP_TRIGGER: 'HTTP trigger differs from the requested configuration or is missing',
|
|
10
11
|
PLAN_DRIFT_FUNCTION_DOMAIN: 'Function domain differs from the requested configuration or is missing',
|
|
@@ -234,7 +235,7 @@ exports.en = {
|
|
|
234
235
|
FORCE_UNLOCK_CONFIRM: 'Are you absolutely sure? (yes/no): ',
|
|
235
236
|
FORCE_UNLOCK_CANCELLED: 'Force unlock cancelled',
|
|
236
237
|
SAAS_FORCE_UNLOCK_NOT_SUPPORTED: 'Force unlock is not supported via CLI for SaaS state. Open {{consoleUrl}} in your browser and unlock the deployment from the Deployments page.',
|
|
237
|
-
PLAN_COMMAND_NOT_SUPPORTED: '
|
|
238
|
+
PLAN_COMMAND_NOT_SUPPORTED: 'Planning is not supported for this provider',
|
|
238
239
|
// Lock info formatting
|
|
239
240
|
LOCK_INFO_HEADER: 'Lock Info:',
|
|
240
241
|
LOCK_INFO_ID: ' ID: {{id}}',
|
|
@@ -869,7 +870,7 @@ exports.en = {
|
|
|
869
870
|
MIGRATE_ROLLBACK_NO_MARKER: 'No migration marker found on the legacy state — nothing to roll back.',
|
|
870
871
|
MIGRATE_ROLLBACK_DONE: 'Migration marker cleared. The legacy backend is writable again.',
|
|
871
872
|
MIGRATE_ROLLBACK_DONE_HINT: 'If you already removed the backend.state_manager block from your YAML, restore it before deploying via the legacy backend.',
|
|
872
|
-
MIGRATE_CUTOVER_STEPS: 'Cutover checklist:\n 1. Remove the backend.state_manager block from serverlessinsight.yml, add a top-level org declaration (org: <slug> — see your org settings in Console), and merge\n 2. Run `si
|
|
873
|
+
MIGRATE_CUTOVER_STEPS: 'Cutover checklist:\n 1. Remove the backend.state_manager block from serverlessinsight.yml, add a top-level org declaration (org: <slug> — see your org settings in Console), and merge\n 2. Run `si diff` — it MUST report no changes and exit 0 (that is the proof of a lossless migration)\n 3. Resume deploys; the Console now owns the deployment timeline',
|
|
873
874
|
MIGRATION_MARKER_REFUSED: 'This state has been migrated to the ServerlessInsight Console (managedBy=saas) and the legacy backend is closed for changes.\n • To continue with the Console: remove the backend.state_manager block from your YAML, declare a top-level org: <slug>, then deploy again.\n • To deliberately use the legacy backend: run `si migrate --rollback` to clear the marker.',
|
|
874
875
|
MIGRATION_MARKER_WARN: 'This state has been migrated to the Console (managedBy=saas) — the copy shown here is read-only and may be stale. Do not deploy from this backend.',
|
|
875
876
|
// HTTP trigger messages
|
|
@@ -1079,8 +1080,8 @@ exports.en = {
|
|
|
1079
1080
|
CMD_WHOAMI_DESC: 'show current login status',
|
|
1080
1081
|
CMD_SHOW_DESC: 'show deployed resources from state',
|
|
1081
1082
|
CMD_VALIDATE_DESC: 'validate serverless Iac yaml',
|
|
1082
|
-
|
|
1083
|
-
|
|
1083
|
+
CMD_DIFF_DESC: 'show changes between your config and the live cloud',
|
|
1084
|
+
CMD_PLAN_REMOVED: 'the plan command has been removed; use the diff command instead — it accepts the same options and arguments.',
|
|
1084
1085
|
CMD_DEPLOY_DESC: 'deploy serverless Iac yaml',
|
|
1085
1086
|
CMD_DESTROY_DESC: 'destroy serverless stack',
|
|
1086
1087
|
CMD_LOCAL_DESC: 'run Serverless application locally for debugging',
|
package/dist/src/lang/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lang = exports.lookupErrorCode = exports.hasLangKey = void 0;
|
|
3
|
+
exports.getSystemLanguage = exports.lang = exports.lookupErrorCode = exports.hasLangKey = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const i18n_1 = require("i18n");
|
|
6
6
|
const en_1 = require("./en");
|
|
@@ -11,24 +11,38 @@ const zh_CN_1 = require("./zh-CN");
|
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
12
|
const mustache = require('mustache');
|
|
13
13
|
mustache.escape = (text) => text;
|
|
14
|
+
const normalizeLocale = (value) => {
|
|
15
|
+
if (!value)
|
|
16
|
+
return null;
|
|
17
|
+
const normalized = value.trim().toLowerCase();
|
|
18
|
+
if (normalized.startsWith('zh'))
|
|
19
|
+
return 'zh-CN';
|
|
20
|
+
if (normalized.startsWith('en'))
|
|
21
|
+
return 'en-US';
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
14
24
|
const getSystemLanguage = (defaultLang) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
+
const override = normalizeLocale(process.env.SI_LANG);
|
|
26
|
+
if (override)
|
|
27
|
+
return override;
|
|
28
|
+
const envLocale = [process.env.LC_ALL, process.env.LANG].reduce((found, value) => found ?? normalizeLocale(value), null);
|
|
29
|
+
if (envLocale)
|
|
30
|
+
return envLocale;
|
|
31
|
+
if (process.platform === 'win32') {
|
|
32
|
+
try {
|
|
33
|
+
const codePageOutput = (0, child_process_1.execSync)('chcp').toString();
|
|
34
|
+
const codePageMatch = codePageOutput.match(/(\d+)\s*$/m);
|
|
35
|
+
if (codePageMatch) {
|
|
36
|
+
return parseInt(codePageMatch[1]) === 936 ? 'zh-CN' : 'en-US';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// ignore
|
|
25
41
|
}
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
// ignore
|
|
29
42
|
}
|
|
30
43
|
return defaultLang;
|
|
31
44
|
};
|
|
45
|
+
exports.getSystemLanguage = getSystemLanguage;
|
|
32
46
|
const lang = new i18n_1.I18n({
|
|
33
47
|
locales: ['en-US', 'zh-CN'],
|
|
34
48
|
defaultLocale: getSystemLanguage('zh-CN'),
|
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.zhCN = {
|
|
|
5
5
|
PLAN_SENSITIVE_VALUE: '(敏感值)',
|
|
6
6
|
PLAN_NAS_NETWORK_REQUIRED: '{{logicalId}} 的 NAS 存储需要声明 VPC 网络或已有挂载目标记录。计划已停止,尚未创建任何资源。',
|
|
7
7
|
APIGW_DOMAIN_READ_INVALID: '域名 {{domainId}} 的查询响应无效',
|
|
8
|
+
APIGW_DOMAIN_CERTIFICATE_UPDATED: '已更新网关域名证书: {{domain}}',
|
|
8
9
|
PLAN_DRIFT_EVENT_DOMAIN: '网关域名或证书与配置不一致或不存在',
|
|
9
10
|
PLAN_DRIFT_HTTP_TRIGGER: 'HTTP 触发器与请求配置不同或已丢失',
|
|
10
11
|
PLAN_DRIFT_FUNCTION_DOMAIN: '函数域名与请求配置不同或已丢失',
|
|
@@ -234,7 +235,7 @@ exports.zhCN = {
|
|
|
234
235
|
FORCE_UNLOCK_CONFIRM: '您确定吗?(yes/no): ',
|
|
235
236
|
FORCE_UNLOCK_CANCELLED: '强制解锁已取消',
|
|
236
237
|
SAAS_FORCE_UNLOCK_NOT_SUPPORTED: 'SaaS 模式下不支持通过 CLI 强制解锁。请在浏览器中打开 {{consoleUrl}},从部署页面解锁该部署。',
|
|
237
|
-
PLAN_COMMAND_NOT_SUPPORTED: '
|
|
238
|
+
PLAN_COMMAND_NOT_SUPPORTED: '此提供商不支持生成部署计划',
|
|
238
239
|
// Lock info formatting
|
|
239
240
|
LOCK_INFO_HEADER: '锁信息:',
|
|
240
241
|
LOCK_INFO_ID: ' ID: {{id}}',
|
|
@@ -861,7 +862,7 @@ exports.zhCN = {
|
|
|
861
862
|
MIGRATE_ROLLBACK_NO_MARKER: '旧状态没有迁移标记——无需回滚。',
|
|
862
863
|
MIGRATE_ROLLBACK_DONE: '已清除迁移标记,旧后端恢复可写。',
|
|
863
864
|
MIGRATE_ROLLBACK_DONE_HINT: '如果已从 YAML 中删除 backend.state_manager 段,经旧后端部署前请先恢复该段。',
|
|
864
|
-
MIGRATE_CUTOVER_STEPS: 'cutover 清单:\n 1. 从 serverlessinsight.yml 删除 backend.state_manager 段,并在顶层添加 org 声明(org: <slug>,slug 见 Console 组织设置)后合并\n 2. 运行 `si
|
|
865
|
+
MIGRATE_CUTOVER_STEPS: 'cutover 清单:\n 1. 从 serverlessinsight.yml 删除 backend.state_manager 段,并在顶层添加 org 声明(org: <slug>,slug 见 Console 组织设置)后合并\n 2. 运行 `si diff`——必须显示无变更并退出 0(这是迁移无损的证明)\n 3. 恢复部署;此后部署时间线由 Console 接管',
|
|
865
866
|
MIGRATION_MARKER_REFUSED: '该状态已迁移至 ServerlessInsight Console(managedBy=saas),旧后端已关闭变更。\n • 继续使用 Console:从 YAML 中删除 backend.state_manager 段并在顶层声明 org: <slug> 后重新部署。\n • 确需经旧后端操作:运行 `si migrate --rollback` 清除标记。',
|
|
866
867
|
MIGRATION_MARKER_WARN: '该状态已迁移至 Console(managedBy=saas)——此处展示的是只读副本,可能已过期。请勿从该后端部署。',
|
|
867
868
|
// HTTP trigger messages
|
|
@@ -1071,8 +1072,8 @@ exports.zhCN = {
|
|
|
1071
1072
|
CMD_WHOAMI_DESC: '显示当前登录状态',
|
|
1072
1073
|
CMD_SHOW_DESC: '从状态中显示已部署资源',
|
|
1073
1074
|
CMD_VALIDATE_DESC: '校验 serverless IaC yaml',
|
|
1074
|
-
|
|
1075
|
-
|
|
1075
|
+
CMD_DIFF_DESC: '展示配置与线上云环境的差异',
|
|
1076
|
+
CMD_PLAN_REMOVED: 'plan 命令已被移除;请改用 diff 命令——两者接受完全相同的选项和参数。迁移方式:将 si plan 替换为 si diff,所有参数保持不变。',
|
|
1076
1077
|
CMD_DEPLOY_DESC: '部署 serverless IaC yaml',
|
|
1077
1078
|
CMD_DESTROY_DESC: '销毁 serverless 资源栈',
|
|
1078
1079
|
CMD_LOCAL_DESC: '本地运行 Serverless 应用进行调试',
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.planApigwDomains = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const certUtils_1 = require("../../common/certUtils");
|
|
6
|
+
const domainUtils_1 = require("../../common/domainUtils");
|
|
7
|
+
const refreshCache_1 = require("../../common/refreshCache");
|
|
8
|
+
const lang_1 = require("../../lang");
|
|
9
|
+
const apigwTypes_1 = require("./apigwTypes");
|
|
10
|
+
const fingerprint = (value) => value ? (0, node_crypto_1.createHash)('sha256').update(value.replace(/\s/g, '')).digest('hex') : null;
|
|
11
|
+
/** Compare readable binding fields without exposing certificate contents or private keys. */
|
|
12
|
+
const planApigwDomains = async (context, client, groupId, domain, summaries, removeCertificate = false) => {
|
|
13
|
+
const primary = String(domain.domain_name);
|
|
14
|
+
const www = domain.www_bind_apex === true ? (0, domainUtils_1.deriveWwwDomain)(primary) : null;
|
|
15
|
+
const names = [primary, ...(www ? [www] : [])];
|
|
16
|
+
const redirect = (0, apigwTypes_1.inferProtocolConfig)(domain.protocol).isHttpRedirectToHttps ??
|
|
17
|
+
false;
|
|
18
|
+
const certificate = domain.certificate_id
|
|
19
|
+
? (await (0, refreshCache_1.cachedRefreshRead)(context, `cas.getCertificate:${domain.certificate_id}`, () => client.cas.getCertificate(String(domain.certificate_id))))?.cert
|
|
20
|
+
: domain.certificate_body
|
|
21
|
+
? (0, certUtils_1.readPemContent)(String(domain.certificate_body))
|
|
22
|
+
: undefined;
|
|
23
|
+
if (domain.certificate_id && !certificate)
|
|
24
|
+
throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', { reference: String(domain.certificate_id) }));
|
|
25
|
+
const desiredFingerprint = certificate
|
|
26
|
+
? fingerprint(certificate)
|
|
27
|
+
: removeCertificate
|
|
28
|
+
? null
|
|
29
|
+
: undefined;
|
|
30
|
+
const entries = await Promise.all(names.map(async (name) => {
|
|
31
|
+
const summary = summaries?.find((entry) => entry.domainName === name);
|
|
32
|
+
// An omitted summary entry is not proof of absence. Confirm against the detail API.
|
|
33
|
+
const detail = !summary || certificate || removeCertificate
|
|
34
|
+
? await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.getDomain:${groupId}:${name}`, () => client.apigw.getDomain(groupId, name))
|
|
35
|
+
: undefined;
|
|
36
|
+
const exists = detail === null ? false : detail || summary ? true : undefined;
|
|
37
|
+
const actualFingerprint = detail?.certificateBody !== undefined ? fingerprint(detail.certificateBody) : undefined;
|
|
38
|
+
const before = {
|
|
39
|
+
...(exists !== undefined ? { exists } : {}),
|
|
40
|
+
...(summary?.isHttpRedirectToHttps !== undefined && exists !== false
|
|
41
|
+
? { redirectToHttps: summary.isHttpRedirectToHttps }
|
|
42
|
+
: {}),
|
|
43
|
+
...(desiredFingerprint !== undefined && actualFingerprint !== undefined
|
|
44
|
+
? { certificateFingerprint: actualFingerprint }
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
47
|
+
const after = {
|
|
48
|
+
...(exists !== undefined ? { exists: true } : {}),
|
|
49
|
+
...(summary?.isHttpRedirectToHttps !== undefined || exists === false
|
|
50
|
+
? { redirectToHttps: redirect }
|
|
51
|
+
: {}),
|
|
52
|
+
...(desiredFingerprint !== undefined &&
|
|
53
|
+
(actualFingerprint !== undefined || exists === false)
|
|
54
|
+
? { certificateFingerprint: desiredFingerprint }
|
|
55
|
+
: {}),
|
|
56
|
+
};
|
|
57
|
+
const binding = exists === false ||
|
|
58
|
+
(summary?.isHttpRedirectToHttps !== undefined &&
|
|
59
|
+
summary.isHttpRedirectToHttps !== redirect);
|
|
60
|
+
const certificateChanged = desiredFingerprint !== undefined &&
|
|
61
|
+
(exists === false ||
|
|
62
|
+
(actualFingerprint !== undefined && actualFingerprint !== desiredFingerprint));
|
|
63
|
+
return {
|
|
64
|
+
name,
|
|
65
|
+
before,
|
|
66
|
+
after,
|
|
67
|
+
verified: exists === true &&
|
|
68
|
+
desiredFingerprint !== undefined &&
|
|
69
|
+
actualFingerprint === desiredFingerprint,
|
|
70
|
+
update: binding || certificateChanged
|
|
71
|
+
? { exists: exists === true, binding, certificate: certificateChanged }
|
|
72
|
+
: undefined,
|
|
73
|
+
};
|
|
74
|
+
}));
|
|
75
|
+
return {
|
|
76
|
+
before: Object.fromEntries(entries.map((entry) => [entry.name, entry.before])),
|
|
77
|
+
after: Object.fromEntries(entries.map((entry) => [entry.name, entry.after])),
|
|
78
|
+
updates: Object.fromEntries(entries.flatMap((entry) => (entry.update ? [[entry.name, entry.update]] : []))),
|
|
79
|
+
certificateVerified: entries.every((entry) => entry.verified),
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.planApigwDomains = planApigwDomains;
|
|
@@ -28,7 +28,10 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, resolveR
|
|
|
28
28
|
throw new Error(lang_1.lang.__('RESOURCE_EVENT_NOT_FOUND', { logicalId: item.logicalId }));
|
|
29
29
|
}
|
|
30
30
|
common_1.logger.info(lang_1.lang.__('UPDATING_RESOURCE', { resourceType: 'API Gateway resources', name: event.name }));
|
|
31
|
-
const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState, {
|
|
31
|
+
const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState, {
|
|
32
|
+
repairDomain: item.driftReasons?.includes('PLAN_DRIFT_EVENT_DOMAIN'),
|
|
33
|
+
scope: item.gatewayUpdate,
|
|
34
|
+
});
|
|
32
35
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'API Gateway resources', name: event.name }));
|
|
33
36
|
return newState;
|
|
34
37
|
}
|