@cloudbase/cli 3.0.0-alpha.4 → 3.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/standalone/cli.js +3908 -146
  2. package/package.json +1 -1
@@ -9827,7 +9827,7 @@ exports.FunctionCopy = FunctionCopy;
9827
9827
  "use strict";
9828
9828
 
9829
9829
 
9830
- var toPosInt = __webpack_require__(32665);
9830
+ var toPosInt = __webpack_require__(55046);
9831
9831
 
9832
9832
  module.exports = function (optsLength, fnLength, isAsync) {
9833
9833
  var length;
@@ -296103,6 +296103,1034 @@ function SchemaObject(obj) {
296103
296103
  module.exports = __webpack_require__(91010);
296104
296104
 
296105
296105
 
296106
+ /***/ }),
296107
+
296108
+ /***/ 2604:
296109
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
296110
+
296111
+ "use strict";
296112
+
296113
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
296114
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
296115
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
296116
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
296117
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
296118
+ };
296119
+ var __metadata = (this && this.__metadata) || function (k, v) {
296120
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
296121
+ };
296122
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
296123
+ return function (target, key) { decorator(target, key, paramIndex); }
296124
+ };
296125
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
296126
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
296127
+ return new (P || (P = Promise))(function (resolve, reject) {
296128
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
296129
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
296130
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
296131
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
296132
+ });
296133
+ };
296134
+ var __importDefault = (this && this.__importDefault) || function (mod) {
296135
+ return (mod && mod.__esModule) ? mod : { "default": mod };
296136
+ };
296137
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
296138
+ exports.RoleDeleteCommand = exports.RoleUpdateCommand = exports.RoleCreateCommand = exports.RoleGetCommand = exports.RoleListCommand = void 0;
296139
+ const common_1 = __webpack_require__(48431);
296140
+ const chalk_1 = __importDefault(__webpack_require__(15896));
296141
+ const decorators_1 = __webpack_require__(93480);
296142
+ const error_1 = __webpack_require__(66759);
296143
+ const utils_1 = __webpack_require__(82079);
296144
+ const i18n_1 = __webpack_require__(69258);
296145
+ const PRESET_POLICY_EFFECT_MAP = {
296146
+ AdministratorAccess: 'allow',
296147
+ FunctionsAccess: 'allow',
296148
+ StoragesAccess: 'allow',
296149
+ CloudrunAccess: 'allow',
296150
+ FunctionsDeny: 'deny',
296151
+ StoragesDeny: 'deny',
296152
+ CloudrunDeny: 'deny',
296153
+ };
296154
+ function getPermissionService(envId) {
296155
+ return __awaiter(this, void 0, void 0, function* () {
296156
+ const app = yield (0, utils_1.getMangerService)(envId);
296157
+ return app.permission;
296158
+ });
296159
+ }
296160
+ function printRole(role, log, detail, roleType) {
296161
+ const roleId = role.RoleId || '-';
296162
+ const name = role.RoleName || '-';
296163
+ const identity = role.RoleIdentity || '-';
296164
+ log.info(` ${(0, i18n_1.t)('• {{name}} ({{identity}})', {
296165
+ name: chalk_1.default.bold.cyan(name),
296166
+ identity: chalk_1.default.bold(identity)
296167
+ })}`);
296168
+ log.info(` ${(0, i18n_1.t)('角色ID')}: ${roleId}`);
296169
+ log.info(` ${(0, i18n_1.t)('类型')}: ${roleType}`);
296170
+ if (role.Description) {
296171
+ log.info(` ${(0, i18n_1.t)('描述')}: ${role.Description}`);
296172
+ }
296173
+ if (detail) {
296174
+ const members = role.Members || [];
296175
+ if (members.length === 0) {
296176
+ log.info(` ${(0, i18n_1.t)('成员')}: -`);
296177
+ }
296178
+ else {
296179
+ log.info(` ${(0, i18n_1.t)('成员')}: ${JSON.stringify(members, null, 2).split('\n').map((line, i) => i === 0 ? line : ' ' + line).join('\n')}`);
296180
+ }
296181
+ const policies = role.Policies || [];
296182
+ if (policies.length === 0) {
296183
+ log.info(` ${(0, i18n_1.t)('策略')}: -`);
296184
+ }
296185
+ else {
296186
+ log.info(` ${(0, i18n_1.t)('策略')}: ${JSON.stringify(policies, null, 2).split('\n').map((line, i) => i === 0 ? line : ' ' + line).join('\n')}`);
296187
+ }
296188
+ }
296189
+ }
296190
+ function parseUsers(usersInput) {
296191
+ if (!usersInput)
296192
+ return [];
296193
+ return usersInput
296194
+ .split(',')
296195
+ .map((item) => item.trim())
296196
+ .filter(Boolean);
296197
+ }
296198
+ function normalizeGatewayPolicy(item) {
296199
+ if (typeof item === 'string') {
296200
+ const code = item.trim();
296201
+ if (!code) {
296202
+ throw new error_1.CloudBaseError({
296203
+ message: (0, i18n_1.t)('策略 code 不能为空'),
296204
+ code: 'INVALID_PARAM'
296205
+ });
296206
+ }
296207
+ return {
296208
+ ResourceType: 'gateway',
296209
+ Resource: code,
296210
+ GatewayPolicyCode: code,
296211
+ Effect: PRESET_POLICY_EFFECT_MAP[code]
296212
+ };
296213
+ }
296214
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
296215
+ throw new error_1.CloudBaseError({
296216
+ message: (0, i18n_1.t)('策略项必须是字符串或对象'),
296217
+ code: 'INVALID_PARAM',
296218
+ solution: [(0, i18n_1.t)('示例: "FunctionsAccess" 或 {"code":"custom_api","expression":{...}}')]
296219
+ });
296220
+ }
296221
+ const code = (item.code || '').trim();
296222
+ if (!code) {
296223
+ throw new error_1.CloudBaseError({
296224
+ message: (0, i18n_1.t)('自定义策略缺少 code(GatewayPolicyCode)'),
296225
+ code: 'INVALID_PARAM',
296226
+ solution: [(0, i18n_1.t)('示例: {"code":"custom_api","name":"API策略","expression":{...}}')]
296227
+ });
296228
+ }
296229
+ let expression;
296230
+ if (item.expression !== undefined) {
296231
+ const isPlainObject = typeof item.expression === 'object' &&
296232
+ item.expression !== null &&
296233
+ !Array.isArray(item.expression);
296234
+ if (!isPlainObject) {
296235
+ throw new error_1.CloudBaseError({
296236
+ message: (0, i18n_1.t)('策略 expression 必须是 JSON 对象'),
296237
+ code: 'INVALID_PARAM',
296238
+ solution: [(0, i18n_1.t)('示例: {"expression":{"version":"1.0","statement":[...]}}')]
296239
+ });
296240
+ }
296241
+ expression = JSON.stringify(item.expression);
296242
+ }
296243
+ const rawEffect = String(item.effect || '').trim().toLowerCase();
296244
+ if (!rawEffect || (rawEffect !== 'allow' && rawEffect !== 'deny')) {
296245
+ throw new error_1.CloudBaseError({
296246
+ message: (0, i18n_1.t)('自定义策略必须指定 effect(allow 或 deny)'),
296247
+ code: 'INVALID_PARAM',
296248
+ solution: [(0, i18n_1.t)('示例: {"code":"custom_api","effect":"allow",...}')]
296249
+ });
296250
+ }
296251
+ const effect = rawEffect;
296252
+ return {
296253
+ ResourceType: 'gateway',
296254
+ Resource: code,
296255
+ Effect: effect,
296256
+ GatewayPolicyCode: code,
296257
+ GatewayPolicyName: item.name,
296258
+ GatewayPolicyDescription: item.description,
296259
+ GatewayPolicyExpression: expression
296260
+ };
296261
+ }
296262
+ function parsePolicies(policiesInput) {
296263
+ if (!policiesInput)
296264
+ return [];
296265
+ let raw;
296266
+ try {
296267
+ raw = JSON.parse(policiesInput);
296268
+ }
296269
+ catch (e) {
296270
+ throw new error_1.CloudBaseError({
296271
+ message: (0, i18n_1.t)('参数 --policies 不是合法 JSON'),
296272
+ code: 'INVALID_PARAM',
296273
+ solution: [(0, i18n_1.t)('示例: --policies \'["FunctionsAccess",{"code":"custom_api"}]\'')],
296274
+ original: e
296275
+ });
296276
+ }
296277
+ if (!Array.isArray(raw)) {
296278
+ throw new error_1.CloudBaseError({
296279
+ message: (0, i18n_1.t)('参数 --policies 必须是 JSON 数组'),
296280
+ code: 'INVALID_PARAM'
296281
+ });
296282
+ }
296283
+ return raw.map((item) => normalizeGatewayPolicy(item));
296284
+ }
296285
+ function validateRoleCreateInput(name, identity, users, policies) {
296286
+ if (!name) {
296287
+ throw new error_1.CloudBaseError({
296288
+ message: (0, i18n_1.t)('参数 --name 必填'),
296289
+ code: 'MISSING_PARAM'
296290
+ });
296291
+ }
296292
+ if (!identity) {
296293
+ throw new error_1.CloudBaseError({
296294
+ message: (0, i18n_1.t)('参数 --identity 必填'),
296295
+ code: 'MISSING_PARAM'
296296
+ });
296297
+ }
296298
+ if (name.length < 2 || name.length > 32) {
296299
+ throw new error_1.CloudBaseError({
296300
+ message: (0, i18n_1.t)('角色名称长度需为 2-32 字符'),
296301
+ code: 'INVALID_PARAM'
296302
+ });
296303
+ }
296304
+ if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5\\-_:@.]*$/.test(name)) {
296305
+ throw new error_1.CloudBaseError({
296306
+ message: (0, i18n_1.t)('角色名称格式不合法'),
296307
+ code: 'INVALID_PARAM',
296308
+ solution: [(0, i18n_1.t)('名称需中文/字母开头,仅支持中文、字母、数字和 -_:@.')]
296309
+ });
296310
+ }
296311
+ if (!/^[A-Za-z0-9_:@.-]+$/.test(identity)) {
296312
+ throw new error_1.CloudBaseError({
296313
+ message: (0, i18n_1.t)('角色标识格式不合法'),
296314
+ code: 'INVALID_PARAM',
296315
+ solution: [(0, i18n_1.t)('标识仅支持字母、数字和 _-:@.')]
296316
+ });
296317
+ }
296318
+ if (users.length > 100) {
296319
+ throw new error_1.CloudBaseError({
296320
+ message: (0, i18n_1.t)('用户列表最多支持 100 个'),
296321
+ code: 'INVALID_PARAM'
296322
+ });
296323
+ }
296324
+ if (policies.length > 50) {
296325
+ throw new error_1.CloudBaseError({
296326
+ message: (0, i18n_1.t)('策略列表最多支持 50 条'),
296327
+ code: 'INVALID_PARAM'
296328
+ });
296329
+ }
296330
+ }
296331
+ function parseRemovePolicies(policiesInput) {
296332
+ if (!policiesInput)
296333
+ return [];
296334
+ let raw;
296335
+ try {
296336
+ raw = JSON.parse(policiesInput);
296337
+ }
296338
+ catch (e) {
296339
+ throw new error_1.CloudBaseError({
296340
+ message: (0, i18n_1.t)('参数 --remove-policies 不是合法 JSON'),
296341
+ code: 'INVALID_PARAM',
296342
+ solution: [(0, i18n_1.t)('示例: --remove-policies \'["FunctionsAccess","StoragesDeny"]\'')],
296343
+ original: e
296344
+ });
296345
+ }
296346
+ if (!Array.isArray(raw)) {
296347
+ throw new error_1.CloudBaseError({
296348
+ message: (0, i18n_1.t)('参数 --remove-policies 必须是 JSON 数组'),
296349
+ code: 'INVALID_PARAM'
296350
+ });
296351
+ }
296352
+ return raw.map((item) => {
296353
+ if (typeof item === 'string') {
296354
+ const code = item.trim();
296355
+ if (!code) {
296356
+ throw new error_1.CloudBaseError({
296357
+ message: (0, i18n_1.t)('移除策略 code 不能为空'),
296358
+ code: 'INVALID_PARAM'
296359
+ });
296360
+ }
296361
+ return {
296362
+ ResourceType: 'gateway',
296363
+ Resource: code,
296364
+ GatewayPolicyCode: code
296365
+ };
296366
+ }
296367
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
296368
+ throw new error_1.CloudBaseError({
296369
+ message: (0, i18n_1.t)('移除策略项必须是字符串或对象'),
296370
+ code: 'INVALID_PARAM',
296371
+ solution: [(0, i18n_1.t)('示例: "FunctionsAccess" 或 {"code":"custom_api"}')]
296372
+ });
296373
+ }
296374
+ const code = String(item.code || '').trim();
296375
+ if (!code) {
296376
+ throw new error_1.CloudBaseError({
296377
+ message: (0, i18n_1.t)('移除策略 code 不能为空'),
296378
+ code: 'INVALID_PARAM'
296379
+ });
296380
+ }
296381
+ return {
296382
+ ResourceType: 'gateway',
296383
+ Resource: code,
296384
+ GatewayPolicyCode: code
296385
+ };
296386
+ });
296387
+ }
296388
+ let RoleListCommand = class RoleListCommand extends common_1.Command {
296389
+ get options() {
296390
+ return {
296391
+ cmd: 'role',
296392
+ childCmd: 'list',
296393
+ options: [
296394
+ {
296395
+ flags: '-e, --env-id <envId>',
296396
+ desc: (0, i18n_1.t)('环境 Id'),
296397
+ deprecatedName: 'envId'
296398
+ },
296399
+ {
296400
+ flags: '--type <type>',
296401
+ desc: (0, i18n_1.t)('过滤角色类型'),
296402
+ choices: ['system', 'custom']
296403
+ },
296404
+ {
296405
+ flags: '--limit <n>',
296406
+ desc: (0, i18n_1.t)('返回条数上限,默认 20'),
296407
+ default: 20
296408
+ },
296409
+ {
296410
+ flags: '--offset <n>',
296411
+ desc: (0, i18n_1.t)('跳过条数,默认 0'),
296412
+ default: 0
296413
+ },
296414
+ {
296415
+ flags: '--detail',
296416
+ desc: (0, i18n_1.t)('显示角色成员和权限策略')
296417
+ }
296418
+ ],
296419
+ desc: (0, i18n_1.t)('查询环境下的角色列表(系统角色 + 自定义角色)'),
296420
+ autoRunLogin: true,
296421
+ examples: [
296422
+ 'tcb role list --env-id xxx',
296423
+ 'tcb role list --type custom --env-id xxx',
296424
+ 'tcb role list --detail --env-id xxx',
296425
+ 'tcb role list --limit 50 --offset 0 --env-id xxx',
296426
+ 'tcb role list --json'
296427
+ ]
296428
+ };
296429
+ }
296430
+ execute(envId, options, log) {
296431
+ var _a, _b, _c, _d, _e, _f;
296432
+ return __awaiter(this, void 0, void 0, function* () {
296433
+ const limit = (_a = Number(options.limit)) !== null && _a !== void 0 ? _a : 20;
296434
+ const offset = (_b = Number(options.offset)) !== null && _b !== void 0 ? _b : 0;
296435
+ const type = options.type;
296436
+ const detail = !!options.detail;
296437
+ const pageSize = limit;
296438
+ const pageNumber = Math.floor(offset / limit) + 1;
296439
+ if (!(0, utils_1.isJsonOutput)()) {
296440
+ log.info((0, i18n_1.t)('正在查询角色列表...'));
296441
+ }
296442
+ try {
296443
+ const permissionService = yield getPermissionService(envId);
296444
+ const result = yield permissionService.describeRoleList({
296445
+ pageNumber,
296446
+ pageSize,
296447
+ loadDetails: detail
296448
+ });
296449
+ const systemRoles = ((_c = result.Data) === null || _c === void 0 ? void 0 : _c.SystemRoles) || [];
296450
+ const customRoles = ((_d = result.Data) === null || _d === void 0 ? void 0 : _d.CustomRoles) || [];
296451
+ const totalCount = (_f = (_e = result.Data) === null || _e === void 0 ? void 0 : _e.TotalCount) !== null && _f !== void 0 ? _f : 0;
296452
+ const filteredSystem = type === 'custom' ? [] : systemRoles;
296453
+ const filteredCustom = type === 'system' ? [] : customRoles;
296454
+ if ((0, utils_1.isJsonOutput)()) {
296455
+ if (type === 'system') {
296456
+ (0, utils_1.outputJson)(Object.assign(Object.assign({}, result), { Data: {
296457
+ SystemTotalCount: systemRoles.length,
296458
+ SystemRoles: systemRoles,
296459
+ } }));
296460
+ }
296461
+ else if (type === 'custom') {
296462
+ (0, utils_1.outputJson)(Object.assign(Object.assign({}, result), { Data: {
296463
+ CustomTotalCount: customRoles.length,
296464
+ CustomRoles: customRoles,
296465
+ } }));
296466
+ }
296467
+ else {
296468
+ (0, utils_1.outputJson)(result);
296469
+ }
296470
+ return;
296471
+ }
296472
+ const allRoles = [...filteredSystem, ...filteredCustom];
296473
+ if (allRoles.length === 0) {
296474
+ log.info((0, i18n_1.t)('未查询到角色'));
296475
+ return;
296476
+ }
296477
+ if (filteredSystem.length > 0) {
296478
+ log.info(`\n${(0, i18n_1.t)('系统角色')} (${filteredSystem.length}):`);
296479
+ for (const role of filteredSystem) {
296480
+ printRole(role, log, detail, 'system');
296481
+ }
296482
+ }
296483
+ if (filteredCustom.length > 0) {
296484
+ log.info(`\n${(0, i18n_1.t)('自定义角色')} (${filteredCustom.length}):`);
296485
+ for (const role of filteredCustom) {
296486
+ printRole(role, log, detail, 'custom');
296487
+ }
296488
+ }
296489
+ const displayCount = filteredSystem.length + filteredCustom.length;
296490
+ if (type) {
296491
+ const label = type === 'system' ? (0, i18n_1.t)('系统角色') : (0, i18n_1.t)('自定义角色');
296492
+ log.info(`\n${(0, i18n_1.t)('共 {{count}} 个{{label}}', { count: displayCount, label })}`);
296493
+ }
296494
+ else {
296495
+ log.info(`\n${(0, i18n_1.t)('共 {{count}} 个角色 (系统角色 {{system}}, 自定义角色 {{custom}})', { count: displayCount, system: filteredSystem.length, custom: filteredCustom.length })}`);
296496
+ }
296497
+ log.info((0, i18n_1.t)('\n下一步:'));
296498
+ log.info(` ${(0, i18n_1.t)('创建角色')} ${(0, utils_1.highlightCommand)(`tcb role create --env-id ${envId}`)}`);
296499
+ }
296500
+ catch (e) {
296501
+ throw new error_1.CloudBaseError({
296502
+ message: e.message || (0, i18n_1.t)('查询角色列表失败'),
296503
+ code: 'API_ERROR',
296504
+ solution: [
296505
+ (0, i18n_1.t)('请检查环境 ID 是否正确'),
296506
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
296507
+ ],
296508
+ original: e
296509
+ });
296510
+ }
296511
+ });
296512
+ }
296513
+ };
296514
+ __decorate([
296515
+ (0, decorators_1.InjectParams)(),
296516
+ __param(0, (0, decorators_1.EnvId)()),
296517
+ __param(1, (0, decorators_1.ArgsOptions)()),
296518
+ __param(2, (0, decorators_1.Log)()),
296519
+ __metadata("design:type", Function),
296520
+ __metadata("design:paramtypes", [String, Object, decorators_1.Logger]),
296521
+ __metadata("design:returntype", Promise)
296522
+ ], RoleListCommand.prototype, "execute", null);
296523
+ RoleListCommand = __decorate([
296524
+ (0, common_1.ICommand)()
296525
+ ], RoleListCommand);
296526
+ exports.RoleListCommand = RoleListCommand;
296527
+ let RoleGetCommand = class RoleGetCommand extends common_1.Command {
296528
+ get options() {
296529
+ return {
296530
+ cmd: 'role',
296531
+ childCmd: 'get',
296532
+ options: [
296533
+ {
296534
+ flags: '-e, --env-id <envId>',
296535
+ desc: (0, i18n_1.t)('环境 Id'),
296536
+ deprecatedName: 'envId'
296537
+ },
296538
+ {
296539
+ flags: '--id <roleId>',
296540
+ desc: (0, i18n_1.t)('按角色 ID 查询(精确)')
296541
+ },
296542
+ {
296543
+ flags: '--identity <identity>',
296544
+ desc: (0, i18n_1.t)('按角色标识查询(精确)')
296545
+ },
296546
+ {
296547
+ flags: '--name <name>',
296548
+ desc: (0, i18n_1.t)('按角色名称查询(模糊)')
296549
+ },
296550
+ {
296551
+ flags: '--detail',
296552
+ desc: (0, i18n_1.t)('显示角色成员和权限策略')
296553
+ }
296554
+ ],
296555
+ desc: (0, i18n_1.t)('查询指定角色的详细信息'),
296556
+ autoRunLogin: true,
296557
+ examples: [
296558
+ 'tcb role get --id 2032299359962361858 --env-id xxx',
296559
+ 'tcb role get --identity administrator --env-id xxx',
296560
+ 'tcb role get --name 开发者 --env-id xxx',
296561
+ 'tcb role get --identity administrator --detail --env-id xxx',
296562
+ 'tcb role get --identity administrator --json'
296563
+ ]
296564
+ };
296565
+ }
296566
+ execute(envId, options, log) {
296567
+ return __awaiter(this, void 0, void 0, function* () {
296568
+ const roleId = options.id;
296569
+ const roleIdentity = options.identity;
296570
+ const roleName = options.name;
296571
+ const detail = !!options.detail;
296572
+ const provided = [roleId, roleIdentity, roleName].filter(Boolean);
296573
+ if (provided.length !== 1) {
296574
+ throw new error_1.CloudBaseError({
296575
+ message: (0, i18n_1.t)('请且仅传入一个查询条件:--id / --identity / --name'),
296576
+ code: 'INVALID_PARAM',
296577
+ solution: [
296578
+ (0, i18n_1.t)('示例: tcb role get --id 2032299359962361858 --env-id xxx'),
296579
+ (0, i18n_1.t)('示例: tcb role get --identity administrator --env-id xxx'),
296580
+ (0, i18n_1.t)('示例: tcb role get --name 开发者 --env-id xxx')
296581
+ ]
296582
+ });
296583
+ }
296584
+ if (!(0, utils_1.isJsonOutput)()) {
296585
+ log.info((0, i18n_1.t)('正在查询角色详情...'));
296586
+ }
296587
+ try {
296588
+ const permissionService = yield getPermissionService(envId);
296589
+ const result = yield permissionService.describeRoleList(Object.assign(Object.assign(Object.assign(Object.assign({}, (roleId ? { roleId } : {})), (roleIdentity ? { roleIdentity } : {})), (roleName ? { roleName } : {})), { loadDetails: detail }));
296590
+ if ((0, utils_1.isJsonOutput)()) {
296591
+ (0, utils_1.outputJson)(result);
296592
+ return;
296593
+ }
296594
+ const roles = this.extractRoles(result);
296595
+ if (roles.length === 0) {
296596
+ if ((0, utils_1.isJsonOutput)()) {
296597
+ (0, utils_1.outputJson)([]);
296598
+ }
296599
+ else {
296600
+ log.info((0, i18n_1.t)('未查询到匹配角色'));
296601
+ }
296602
+ return;
296603
+ }
296604
+ if (roles.length > 1) {
296605
+ log.info(`\n${(0, i18n_1.t)('查询到 {{count}} 个角色', { count: roles.length })}:`);
296606
+ for (const item of roles) {
296607
+ printRole(item.role, log, detail, item.roleType);
296608
+ }
296609
+ }
296610
+ else {
296611
+ log.info(`\n${(0, i18n_1.t)('角色详情')}:`);
296612
+ const item = roles[0];
296613
+ printRole(item.role, log, detail, item.roleType);
296614
+ }
296615
+ log.info((0, i18n_1.t)('\n下一步:'));
296616
+ log.info(` ${(0, i18n_1.t)('查看角色列表')} ${(0, utils_1.highlightCommand)(`tcb role list --env-id ${envId}`)}`);
296617
+ }
296618
+ catch (e) {
296619
+ if (e instanceof error_1.CloudBaseError) {
296620
+ throw e;
296621
+ }
296622
+ throw new error_1.CloudBaseError({
296623
+ message: e.message || (0, i18n_1.t)('查询角色详情失败'),
296624
+ code: 'API_ERROR',
296625
+ solution: [
296626
+ (0, i18n_1.t)('请检查环境 ID 是否正确'),
296627
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
296628
+ ],
296629
+ original: e
296630
+ });
296631
+ }
296632
+ });
296633
+ }
296634
+ extractRoles(result) {
296635
+ var _a, _b;
296636
+ const systemRoles = (((_a = result.Data) === null || _a === void 0 ? void 0 : _a.SystemRoles) || []).map((role) => ({
296637
+ role,
296638
+ roleType: 'system'
296639
+ }));
296640
+ const customRoles = (((_b = result.Data) === null || _b === void 0 ? void 0 : _b.CustomRoles) || []).map((role) => ({
296641
+ role,
296642
+ roleType: 'custom'
296643
+ }));
296644
+ return [...systemRoles, ...customRoles];
296645
+ }
296646
+ };
296647
+ __decorate([
296648
+ (0, decorators_1.InjectParams)(),
296649
+ __param(0, (0, decorators_1.EnvId)()),
296650
+ __param(1, (0, decorators_1.ArgsOptions)()),
296651
+ __param(2, (0, decorators_1.Log)()),
296652
+ __metadata("design:type", Function),
296653
+ __metadata("design:paramtypes", [String, Object, decorators_1.Logger]),
296654
+ __metadata("design:returntype", Promise)
296655
+ ], RoleGetCommand.prototype, "execute", null);
296656
+ RoleGetCommand = __decorate([
296657
+ (0, common_1.ICommand)()
296658
+ ], RoleGetCommand);
296659
+ exports.RoleGetCommand = RoleGetCommand;
296660
+ let RoleCreateCommand = class RoleCreateCommand extends common_1.Command {
296661
+ get options() {
296662
+ return {
296663
+ cmd: 'role',
296664
+ childCmd: 'create',
296665
+ options: [
296666
+ {
296667
+ flags: '-e, --env-id <envId>',
296668
+ desc: (0, i18n_1.t)('环境 Id'),
296669
+ deprecatedName: 'envId'
296670
+ },
296671
+ {
296672
+ flags: '--name <name>',
296673
+ desc: (0, i18n_1.t)('角色名称(2-32 字符)')
296674
+ },
296675
+ {
296676
+ flags: '--identity <identity>',
296677
+ desc: (0, i18n_1.t)('角色标识(唯一)')
296678
+ },
296679
+ {
296680
+ flags: '--description <description>',
296681
+ desc: (0, i18n_1.t)('角色描述(最多 255 字符)')
296682
+ },
296683
+ {
296684
+ flags: '--users <uids>',
296685
+ desc: (0, i18n_1.t)('成员 UID 列表(逗号分隔)')
296686
+ },
296687
+ {
296688
+ flags: '--policies <json>',
296689
+ desc: [
296690
+ (0, i18n_1.t)('策略 JSON 数组,支持预设字符串和自定义对象混合'),
296691
+ (0, i18n_1.t)('预设: AdministratorAccess, FunctionsAccess, StoragesAccess, CloudrunAccess, FunctionsDeny, StoragesDeny, CloudrunDeny'),
296692
+ (0, i18n_1.t)('自定义对象字段: code, name, description, effect(allow|deny), expression'),
296693
+ (0, i18n_1.t)('expression 由 version 和 statement 构成,statement 是子语句数组,每条子语句包含 action, resource, effect, condition(非必填)'),
296694
+ (0, i18n_1.t)('action 格式: <功能类型>:<请求路径>,功能类型: storages/functions/cloudrun/model,路径为 * 表示全部'),
296695
+ (0, i18n_1.t)('resource 代表操作的资源,* 表示全部资源'),
296696
+ (0, i18n_1.t)('effect 取值 allow 或 deny,allow 和 deny 同时存在时 deny 优先'),
296697
+ (0, i18n_1.t)('示例: {"version":"1.0","statement":[{"action":"functions:*","resource":"*","effect":"allow"}]}')
296698
+ ].join('\n')
296699
+ }
296700
+ ],
296701
+ desc: (0, i18n_1.t)('创建自定义角色'),
296702
+ autoRunLogin: true,
296703
+ examples: [
296704
+ 'tcb role create --name 开发者 --identity developer --env-id xxx',
296705
+ 'tcb role create --name 开发者 --identity developer --users 1003,1005 --env-id xxx',
296706
+ 'tcb role create --name 网关角色 --identity gateway_role --policies \'["FunctionsAccess","StoragesDeny"]\' --env-id xxx',
296707
+ 'tcb role create --name 全栈开发者 --identity fullstack_dev --policies \'["FunctionsAccess",{"code":"custom_api","name":"API路径策略","description":"仅允许访问/api路径","expression":{"version":"1.0","statement":[{"action":"functions:/api/*","resource":"*","effect":"allow"}]}}]\' --users 1003,1005,1007 --env-id xxx',
296708
+ 'tcb role create --name 开发者 --identity developer --env-id xxx --json'
296709
+ ]
296710
+ };
296711
+ }
296712
+ execute(envId, options, log) {
296713
+ return __awaiter(this, void 0, void 0, function* () {
296714
+ const name = (options.name || '').trim();
296715
+ const identity = (options.identity || '').trim();
296716
+ const description = (options.description || '').trim();
296717
+ const usersInput = options.users;
296718
+ const policiesInput = options.policies;
296719
+ const users = parseUsers(usersInput);
296720
+ const policies = parsePolicies(policiesInput);
296721
+ validateRoleCreateInput(name, identity, users, policies);
296722
+ if (!(0, utils_1.isJsonOutput)()) {
296723
+ log.info((0, i18n_1.t)('正在创建角色...'));
296724
+ }
296725
+ try {
296726
+ const permissionService = yield getPermissionService(envId);
296727
+ const createOptions = {
296728
+ roleName: name,
296729
+ roleIdentity: identity
296730
+ };
296731
+ if (description) {
296732
+ createOptions.description = description;
296733
+ }
296734
+ if (users.length > 0) {
296735
+ createOptions.memberUids = users;
296736
+ }
296737
+ if (policies.length > 0) {
296738
+ createOptions.policies = policies;
296739
+ }
296740
+ const result = yield permissionService.createRole(createOptions);
296741
+ const data = result.Data || {};
296742
+ if ((0, utils_1.isJsonOutput)()) {
296743
+ (0, utils_1.outputJson)(result);
296744
+ return;
296745
+ }
296746
+ log.success((0, i18n_1.t)('角色创建成功'));
296747
+ log.info(` ${(0, i18n_1.t)('角色名称')}: ${name}`);
296748
+ log.info(` ${(0, i18n_1.t)('角色标识')}: ${identity}`);
296749
+ log.info(` ${(0, i18n_1.t)('角色ID')}: ${data.RoleId || '-'}`);
296750
+ if (users.length > 0) {
296751
+ const createdUsers = data.MemberUids || [];
296752
+ const usersText = createdUsers.length > 0 ? JSON.stringify(createdUsers) : '[]';
296753
+ log.info(` ${(0, i18n_1.t)('已添加成员')}: ${usersText}`);
296754
+ }
296755
+ if (policies.length > 0) {
296756
+ const createdPolicies = data.Policies || [];
296757
+ const policiesText = JSON.stringify(createdPolicies, null, 2)
296758
+ .split('\n')
296759
+ .map((line, i) => (i === 0 ? line : ` ${line}`))
296760
+ .join('\n');
296761
+ log.info(` ${(0, i18n_1.t)('已创建策略')}: ${policiesText}`);
296762
+ }
296763
+ log.info((0, i18n_1.t)('\n下一步:'));
296764
+ log.info(` ${(0, i18n_1.t)('查看角色列表')} ${(0, utils_1.highlightCommand)(`tcb role list --env-id ${envId}`)}`);
296765
+ if (data.RoleId) {
296766
+ log.info(` ${(0, i18n_1.t)('查看角色详情')} ${(0, utils_1.highlightCommand)(`tcb role get --id ${data.RoleId} --env-id ${envId}`)}`);
296767
+ }
296768
+ }
296769
+ catch (e) {
296770
+ if (e instanceof error_1.CloudBaseError) {
296771
+ throw e;
296772
+ }
296773
+ throw new error_1.CloudBaseError({
296774
+ message: e.message || (0, i18n_1.t)('创建角色失败'),
296775
+ code: 'API_ERROR',
296776
+ solution: [
296777
+ (0, i18n_1.t)('请检查参数是否正确'),
296778
+ (0, i18n_1.t)('请确认角色名称/角色标识未重复'),
296779
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
296780
+ ],
296781
+ original: e
296782
+ });
296783
+ }
296784
+ });
296785
+ }
296786
+ };
296787
+ __decorate([
296788
+ (0, decorators_1.InjectParams)(),
296789
+ __param(0, (0, decorators_1.EnvId)()),
296790
+ __param(1, (0, decorators_1.ArgsOptions)()),
296791
+ __param(2, (0, decorators_1.Log)()),
296792
+ __metadata("design:type", Function),
296793
+ __metadata("design:paramtypes", [String, Object, decorators_1.Logger]),
296794
+ __metadata("design:returntype", Promise)
296795
+ ], RoleCreateCommand.prototype, "execute", null);
296796
+ RoleCreateCommand = __decorate([
296797
+ (0, common_1.ICommand)()
296798
+ ], RoleCreateCommand);
296799
+ exports.RoleCreateCommand = RoleCreateCommand;
296800
+ let RoleUpdateCommand = class RoleUpdateCommand extends common_1.Command {
296801
+ get options() {
296802
+ return {
296803
+ cmd: 'role',
296804
+ childCmd: 'update',
296805
+ options: [
296806
+ {
296807
+ flags: '-e, --env-id <envId>',
296808
+ desc: (0, i18n_1.t)('环境 Id'),
296809
+ deprecatedName: 'envId'
296810
+ },
296811
+ {
296812
+ flags: '--id <roleId>',
296813
+ desc: (0, i18n_1.t)('角色 ID(必填)')
296814
+ },
296815
+ {
296816
+ flags: '--name <name>',
296817
+ desc: (0, i18n_1.t)('修改角色名称(2-32 字符)')
296818
+ },
296819
+ {
296820
+ flags: '--description <description>',
296821
+ desc: (0, i18n_1.t)('修改角色描述')
296822
+ },
296823
+ {
296824
+ flags: '--add-users <uids>',
296825
+ desc: (0, i18n_1.t)('添加成员(逗号分隔 UID)')
296826
+ },
296827
+ {
296828
+ flags: '--remove-users <uids>',
296829
+ desc: (0, i18n_1.t)('移除成员(逗号分隔 UID)')
296830
+ },
296831
+ {
296832
+ flags: '--add-policies <json>',
296833
+ desc: [
296834
+ (0, i18n_1.t)('策略 JSON 数组,支持预设字符串和自定义对象混合'),
296835
+ (0, i18n_1.t)('预设: AdministratorAccess, FunctionsAccess, StoragesAccess, CloudrunAccess, FunctionsDeny, StoragesDeny, CloudrunDeny'),
296836
+ (0, i18n_1.t)('自定义对象字段: code, name, description, effect(allow|deny), expression'),
296837
+ (0, i18n_1.t)('expression 由 version 和 statement 构成,statement 是子语句数组,每条子语句包含 action, resource, effect, condition(非必填)'),
296838
+ (0, i18n_1.t)('action 格式: <功能类型>:<请求路径>,功能类型: storages/functions/cloudrun/model,路径为 * 表示全部'),
296839
+ (0, i18n_1.t)('resource 代表操作的资源,* 表示全部资源'),
296840
+ (0, i18n_1.t)('effect 取值 allow 或 deny,allow 和 deny 同时存在时 deny 优先'),
296841
+ (0, i18n_1.t)('示例: {"version":"1.0","statement":[{"action":"functions:*","resource":"*","effect":"allow"}]}')
296842
+ ].join('\n')
296843
+ },
296844
+ {
296845
+ flags: '--remove-policies <json>',
296846
+ desc: [
296847
+ (0, i18n_1.t)('移除策略 JSON 数组,支持预设字符串和自定义对象混合'),
296848
+ (0, i18n_1.t)('预设: AdministratorAccess, FunctionsAccess, StoragesAccess, CloudrunAccess, FunctionsDeny, StoragesDeny, CloudrunDeny'),
296849
+ (0, i18n_1.t)('自定义对象需提供 code 字段'),
296850
+ (0, i18n_1.t)('示例: \'["FunctionsAccess", {"code": "custom_api"}]\'')
296851
+ ].join('\n')
296852
+ }
296853
+ ],
296854
+ desc: [
296855
+ (0, i18n_1.t)('更新角色信息(名称、描述、成员、策略)'),
296856
+ '',
296857
+ `${(0, i18n_1.t)('注意:')}\n`,
296858
+ ` · ${(0, i18n_1.t)('管理员角色:仅可修改成员,不可修改策略')}`,
296859
+ ` · ${(0, i18n_1.t)('注册用户/组织成员/匿名用户/所有用户:仅可修改策略,不可修改成员')}`,
296860
+ ` · ${(0, i18n_1.t)('所有系统角色:不可修改角色名称')}`,
296861
+ ` · ${(0, i18n_1.t)('自定义角色:以上均可修改')}`
296862
+ ].join('\n'),
296863
+ autoRunLogin: true,
296864
+ examples: [
296865
+ 'tcb role update --id 2032299359962361858 --name "高级开发者" --env-id xxx',
296866
+ 'tcb role update --id 2032299359962361858 --add-users "1001,1002" --remove-users "1003" --env-id xxx',
296867
+ 'tcb role update --id 2032299359962361858 --add-policies \'["FunctionsAccess"]\' --remove-policies \'["StoragesDeny"]\' --env-id xxx',
296868
+ 'tcb role update --id 2032299359962361858 --name "新名称" --add-users "1001" --env-id xxx --json'
296869
+ ]
296870
+ };
296871
+ }
296872
+ execute(envId, options, log) {
296873
+ var _a, _b, _c, _d;
296874
+ return __awaiter(this, void 0, void 0, function* () {
296875
+ const roleId = (options.id || '').trim();
296876
+ const name = options.name;
296877
+ const description = options.description;
296878
+ const addUsersInput = options.addUsers;
296879
+ const removeUsersInput = options.removeUsers;
296880
+ const addPoliciesInput = options.addPolicies;
296881
+ const removePoliciesInput = options.removePolicies;
296882
+ if (!roleId) {
296883
+ throw new error_1.CloudBaseError({
296884
+ message: (0, i18n_1.t)('参数 --id 必填'),
296885
+ code: 'MISSING_PARAM',
296886
+ solution: [(0, i18n_1.t)('示例: tcb role update --id <roleId> --name "新名称" --env-id xxx')]
296887
+ });
296888
+ }
296889
+ const updateFields = [name, description, addUsersInput, removeUsersInput, addPoliciesInput, removePoliciesInput];
296890
+ const hasUpdate = updateFields.some((f) => f !== undefined && f !== '');
296891
+ if (!hasUpdate) {
296892
+ throw new error_1.CloudBaseError({
296893
+ message: (0, i18n_1.t)('请至少指定一个更新字段'),
296894
+ code: 'MISSING_PARAM',
296895
+ solution: [
296896
+ (0, i18n_1.t)('可用选项: --name, --description, --add-users, --remove-users, --add-policies, --remove-policies'),
296897
+ (0, i18n_1.t)('示例: tcb role update --id {{id}} --name "新名称" --env-id xxx', { id: roleId })
296898
+ ]
296899
+ });
296900
+ }
296901
+ if (name) {
296902
+ const trimmedName = name.trim();
296903
+ if (trimmedName.length < 2 || trimmedName.length > 32) {
296904
+ throw new error_1.CloudBaseError({
296905
+ message: (0, i18n_1.t)('角色名称长度需为 2-32 字符'),
296906
+ code: 'INVALID_PARAM'
296907
+ });
296908
+ }
296909
+ if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5\\-_:@.]*$/.test(trimmedName)) {
296910
+ throw new error_1.CloudBaseError({
296911
+ message: (0, i18n_1.t)('角色名称格式不合法'),
296912
+ code: 'INVALID_PARAM',
296913
+ solution: [(0, i18n_1.t)('名称需中文/字母开头,仅支持中文、字母、数字和 -_:@.')]
296914
+ });
296915
+ }
296916
+ }
296917
+ const addUsers = parseUsers(addUsersInput);
296918
+ const removeUsers = parseUsers(removeUsersInput);
296919
+ const addPolicies = parsePolicies(addPoliciesInput);
296920
+ const removePolicies = parseRemovePolicies(removePoliciesInput);
296921
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('确定要更新角色 {{id}} 吗?', { id: roleId }));
296922
+ if (!confirmed)
296923
+ return;
296924
+ if (!(0, utils_1.isJsonOutput)()) {
296925
+ log.info((0, i18n_1.t)('正在更新角色...'));
296926
+ }
296927
+ try {
296928
+ const permissionService = yield getPermissionService(envId);
296929
+ const modifyOptions = {
296930
+ roleId
296931
+ };
296932
+ if (name) {
296933
+ modifyOptions.roleName = name.trim();
296934
+ }
296935
+ if (description) {
296936
+ modifyOptions.description = description.trim();
296937
+ }
296938
+ if (addUsers.length > 0) {
296939
+ modifyOptions.addMemberUids = addUsers;
296940
+ }
296941
+ if (removeUsers.length > 0) {
296942
+ modifyOptions.removeMemberUids = removeUsers;
296943
+ }
296944
+ if (addPolicies.length > 0) {
296945
+ modifyOptions.addPolicies = addPolicies;
296946
+ }
296947
+ if (removePolicies.length > 0) {
296948
+ modifyOptions.removePolicies = removePolicies;
296949
+ }
296950
+ const result = yield permissionService.modifyRole(modifyOptions);
296951
+ const data = result.Data || {};
296952
+ if ((0, utils_1.isJsonOutput)()) {
296953
+ (0, utils_1.outputJson)(result);
296954
+ return;
296955
+ }
296956
+ log.success((0, i18n_1.t)('角色更新成功'));
296957
+ const hasBasicChange = !!name || !!description;
296958
+ const hasMemberChange = (((_a = data.AddedMemberUids) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0 || (((_b = data.RemovedMemberUids) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0;
296959
+ const hasPolicyChange = (((_c = data.AddedPolicies) === null || _c === void 0 ? void 0 : _c.length) || 0) > 0 || (((_d = data.RemovedPolicies) === null || _d === void 0 ? void 0 : _d.length) || 0) > 0;
296960
+ if (hasBasicChange) {
296961
+ log.info(`\n ${(0, i18n_1.t)('基本信息变更')}:`);
296962
+ if (name) {
296963
+ log.info(` ${(0, i18n_1.t)('角色名称')}: ${name.trim()}`);
296964
+ }
296965
+ if (description) {
296966
+ log.info(` ${(0, i18n_1.t)('描述')}: ${description.trim()}`);
296967
+ }
296968
+ }
296969
+ if (hasMemberChange) {
296970
+ log.info(`\n ${(0, i18n_1.t)('成员变更')}:`);
296971
+ const added = data.AddedMemberUids || [];
296972
+ const removed = data.RemovedMemberUids || [];
296973
+ if (added.length > 0) {
296974
+ log.info(` + ${(0, i18n_1.t)('已添加')}: ${JSON.stringify(added)}`);
296975
+ }
296976
+ if (removed.length > 0) {
296977
+ log.info(` - ${(0, i18n_1.t)('已移除')}: ${JSON.stringify(removed)}`);
296978
+ }
296979
+ }
296980
+ if (hasPolicyChange) {
296981
+ log.info(`\n ${(0, i18n_1.t)('策略变更')}:`);
296982
+ const addedPolicies = data.AddedPolicies || [];
296983
+ const removedPolicies = data.RemovedPolicies || [];
296984
+ if (addedPolicies.length > 0) {
296985
+ log.info(` + ${(0, i18n_1.t)('已添加策略')}: ${JSON.stringify(addedPolicies)}`);
296986
+ }
296987
+ if (removedPolicies.length > 0) {
296988
+ log.info(` - ${(0, i18n_1.t)('已移除策略')}: ${JSON.stringify(removedPolicies)}`);
296989
+ }
296990
+ }
296991
+ log.info((0, i18n_1.t)('\n下一步:'));
296992
+ log.info(` ${(0, i18n_1.t)('查看角色详情')} ${(0, utils_1.highlightCommand)(`tcb role get --id ${roleId} --env-id ${envId}`)}`);
296993
+ log.info(` ${(0, i18n_1.t)('查看角色列表')} ${(0, utils_1.highlightCommand)(`tcb role list --env-id ${envId}`)}`);
296994
+ }
296995
+ catch (e) {
296996
+ if (e instanceof error_1.CloudBaseError) {
296997
+ throw e;
296998
+ }
296999
+ throw new error_1.CloudBaseError({
297000
+ message: e.message || (0, i18n_1.t)('更新角色失败'),
297001
+ code: 'API_ERROR',
297002
+ solution: [
297003
+ (0, i18n_1.t)('请检查参数是否正确'),
297004
+ (0, i18n_1.t)('系统角色可能有修改限制,请参考帮助信息'),
297005
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
297006
+ ],
297007
+ original: e
297008
+ });
297009
+ }
297010
+ });
297011
+ }
297012
+ };
297013
+ __decorate([
297014
+ (0, decorators_1.InjectParams)(),
297015
+ __param(0, (0, decorators_1.EnvId)()),
297016
+ __param(1, (0, decorators_1.ArgsOptions)()),
297017
+ __param(2, (0, decorators_1.Log)()),
297018
+ __metadata("design:type", Function),
297019
+ __metadata("design:paramtypes", [String, Object, decorators_1.Logger]),
297020
+ __metadata("design:returntype", Promise)
297021
+ ], RoleUpdateCommand.prototype, "execute", null);
297022
+ RoleUpdateCommand = __decorate([
297023
+ (0, common_1.ICommand)()
297024
+ ], RoleUpdateCommand);
297025
+ exports.RoleUpdateCommand = RoleUpdateCommand;
297026
+ let RoleDeleteCommand = class RoleDeleteCommand extends common_1.Command {
297027
+ get options() {
297028
+ return {
297029
+ cmd: 'role',
297030
+ childCmd: 'delete <roleIds...>',
297031
+ options: [
297032
+ {
297033
+ flags: '-e, --env-id <envId>',
297034
+ desc: (0, i18n_1.t)('环境 Id'),
297035
+ deprecatedName: 'envId'
297036
+ }
297037
+ ],
297038
+ desc: (0, i18n_1.t)('删除自定义角色(不可撤销)'),
297039
+ autoRunLogin: true,
297040
+ examples: [
297041
+ 'tcb role delete 2037415874111574018 --env-id xxx',
297042
+ 'tcb role delete 2037415874111574018 2037420918731018242 --env-id xxx',
297043
+ 'tcb role delete 2037415874111574018 --env-id xxx --json'
297044
+ ]
297045
+ };
297046
+ }
297047
+ execute(envId, params, log) {
297048
+ var _a, _b;
297049
+ return __awaiter(this, void 0, void 0, function* () {
297050
+ const roleIds = [].concat((params === null || params === void 0 ? void 0 : params[0]) || [])
297051
+ .map((id) => String(id).trim())
297052
+ .filter(Boolean);
297053
+ if (roleIds.length === 0) {
297054
+ throw new error_1.CloudBaseError({
297055
+ message: (0, i18n_1.t)('请指定要删除的角色 ID,例如:tcb role delete <roleId>'),
297056
+ code: 'MISSING_PARAM',
297057
+ solution: [(0, i18n_1.t)('运行 {{cmd}} 查看角色列表', { cmd: (0, utils_1.highlightCommand)(`tcb role list --env-id ${envId}`) })]
297058
+ });
297059
+ }
297060
+ if (roleIds.length > 100) {
297061
+ throw new error_1.CloudBaseError({
297062
+ message: (0, i18n_1.t)('单次最多删除 100 个角色'),
297063
+ code: 'INVALID_PARAM',
297064
+ solution: [(0, i18n_1.t)('请分批删除,每次不超过 100 个')]
297065
+ });
297066
+ }
297067
+ const uniqueIds = [...new Set(roleIds)];
297068
+ if (!(0, utils_1.isJsonOutput)()) {
297069
+ log.warn(chalk_1.default.yellow((0, i18n_1.t)('确认删除以下角色?')));
297070
+ for (const id of uniqueIds) {
297071
+ log.info(` • ${id}`);
297072
+ }
297073
+ log.warn(chalk_1.default.red((0, i18n_1.t)('\n此操作不可撤销,是否继续?')));
297074
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('确定要删除 {{count}} 个角色吗?', { count: uniqueIds.length }), false);
297075
+ if (!confirmed)
297076
+ return;
297077
+ }
297078
+ if (!(0, utils_1.isJsonOutput)()) {
297079
+ log.info((0, i18n_1.t)('正在删除角色...'));
297080
+ }
297081
+ try {
297082
+ const permissionService = yield getPermissionService(envId);
297083
+ const result = yield permissionService.deleteRoles({ roleIds: uniqueIds });
297084
+ const data = result.Data || {};
297085
+ const successCount = (_a = data.SuccessCount) !== null && _a !== void 0 ? _a : 0;
297086
+ const failedCount = (_b = data.FailedCount) !== null && _b !== void 0 ? _b : 0;
297087
+ if ((0, utils_1.isJsonOutput)()) {
297088
+ (0, utils_1.outputJson)(result);
297089
+ return;
297090
+ }
297091
+ if (failedCount > 0) {
297092
+ log.warn((0, i18n_1.t)('已删除 {{success}} 个,失败 {{failed}} 个', { success: successCount, failed: failedCount }));
297093
+ }
297094
+ else {
297095
+ log.success((0, i18n_1.t)('已删除 {{count}} 个角色', { count: successCount }));
297096
+ }
297097
+ log.info((0, i18n_1.t)('\n已删除:'));
297098
+ for (const id of uniqueIds) {
297099
+ log.info(` • ${id}`);
297100
+ }
297101
+ }
297102
+ catch (e) {
297103
+ if (e instanceof error_1.CloudBaseError) {
297104
+ throw e;
297105
+ }
297106
+ throw new error_1.CloudBaseError({
297107
+ message: e.message || (0, i18n_1.t)('删除角色失败'),
297108
+ code: 'API_ERROR',
297109
+ solution: [
297110
+ (0, i18n_1.t)('系统角色不可删除,只能删除自定义角色'),
297111
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
297112
+ ],
297113
+ original: e
297114
+ });
297115
+ }
297116
+ });
297117
+ }
297118
+ };
297119
+ __decorate([
297120
+ (0, decorators_1.InjectParams)(),
297121
+ __param(0, (0, decorators_1.EnvId)()),
297122
+ __param(1, (0, decorators_1.ArgsParams)()),
297123
+ __param(2, (0, decorators_1.Log)()),
297124
+ __metadata("design:type", Function),
297125
+ __metadata("design:paramtypes", [String, Array, decorators_1.Logger]),
297126
+ __metadata("design:returntype", Promise)
297127
+ ], RoleDeleteCommand.prototype, "execute", null);
297128
+ RoleDeleteCommand = __decorate([
297129
+ (0, common_1.ICommand)()
297130
+ ], RoleDeleteCommand);
297131
+ exports.RoleDeleteCommand = RoleDeleteCommand;
297132
+
297133
+
296106
297134
  /***/ }),
296107
297135
 
296108
297136
  /***/ 2608:
@@ -318256,6 +319284,263 @@ function getHeaders(options) {
318256
319284
  module.exports = Object.getOwnPropertyDescriptor;
318257
319285
 
318258
319286
 
319287
+ /***/ }),
319288
+
319289
+ /***/ 6563:
319290
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
319291
+
319292
+ "use strict";
319293
+
319294
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
319295
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
319296
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
319297
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
319298
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
319299
+ };
319300
+ var __metadata = (this && this.__metadata) || function (k, v) {
319301
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
319302
+ };
319303
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
319304
+ return function (target, key) { decorator(target, key, paramIndex); }
319305
+ };
319306
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
319307
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
319308
+ return new (P || (P = Promise))(function (resolve, reject) {
319309
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
319310
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
319311
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
319312
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
319313
+ });
319314
+ };
319315
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
319316
+ exports.AppVersionsList = exports.AppVersionDetail = void 0;
319317
+ const common_1 = __webpack_require__(48431);
319318
+ const decorators_1 = __webpack_require__(93480);
319319
+ const utils_1 = __webpack_require__(82079);
319320
+ const utils_2 = __webpack_require__(75213);
319321
+ const constant_1 = __webpack_require__(62977);
319322
+ const i18n_1 = __webpack_require__(69258);
319323
+ const error_1 = __webpack_require__(66759);
319324
+ let AppVersionDetail = class AppVersionDetail extends common_1.Command {
319325
+ get options() {
319326
+ return {
319327
+ cmd: 'app',
319328
+ childCmd: 'versions',
319329
+ childSubCmd: 'detail <serviceName>',
319330
+ options: [
319331
+ { flags: '-v, --version-name <versionName>', desc: (0, i18n_1.t)('版本名称,默认最新版本') }
319332
+ ],
319333
+ desc: (0, i18n_1.t)('查看应用版本详情(默认最新版本)'),
319334
+ requiredEnvId: false,
319335
+ autoRunLogin: true,
319336
+ examples: [
319337
+ 'tcb app versions detail my-app --env-id env-xxx',
319338
+ 'tcb app versions detail my-app --version-name my-app-001 --env-id env-xxx'
319339
+ ],
319340
+ seeAlso: ['tcb app versions list', 'tcb app info'],
319341
+ docs: ['https://docs.cloudbase.net/cli/app/versions']
319342
+ };
319343
+ }
319344
+ execute(envId, params, options, log) {
319345
+ return __awaiter(this, void 0, void 0, function* () {
319346
+ let selectedEnvId = envId;
319347
+ if (!selectedEnvId) {
319348
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
319349
+ }
319350
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
319351
+ if (!serviceName) {
319352
+ throw new error_1.CloudBaseError({
319353
+ message: (0, i18n_1.t)('请指定服务名称'),
319354
+ code: 'MISSING_PARAM',
319355
+ solution: [(0, i18n_1.t)('示例: tcb app versions detail my-app --env-id env-xxx')]
319356
+ });
319357
+ }
319358
+ const loading = (0, utils_1.loadingFactory)();
319359
+ loading.start((0, i18n_1.t)('数据加载中...'));
319360
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
319361
+ const data = yield app.cloudAppService.describeAppVersion({
319362
+ deployType: 'static-hosting',
319363
+ serviceName: serviceName,
319364
+ versionName: options.versionName
319365
+ });
319366
+ loading.stop();
319367
+ if ((0, utils_1.isJsonOutput)()) {
319368
+ this.outputVersionJson(data);
319369
+ return;
319370
+ }
319371
+ this.printVersionInfo(data, log);
319372
+ });
319373
+ }
319374
+ outputVersionJson(data) {
319375
+ var _a, _b;
319376
+ (0, utils_1.outputJson)({
319377
+ buildId: data.BuildId,
319378
+ buildType: data.BuildType,
319379
+ buildTime: data.BuildTime,
319380
+ status: data.Status,
319381
+ framework: data.Framework,
319382
+ failReason: data.FailReason,
319383
+ staticConfig: data.StaticConfig ? {
319384
+ framework: data.StaticConfig.Framework,
319385
+ appPath: data.StaticConfig.AppPath,
319386
+ nodeJsVersion: data.StaticConfig.NodeJsVersion,
319387
+ staticCmd: data.StaticConfig.StaticCmd ? {
319388
+ buildCmd: data.StaticConfig.StaticCmd.BuildCmd,
319389
+ installCmd: data.StaticConfig.StaticCmd.InstallCmd,
319390
+ deployCmd: data.StaticConfig.StaticCmd.DeployCmd
319391
+ } : undefined,
319392
+ staticEnv: ((_b = (_a = data.StaticConfig.StaticEnv) === null || _a === void 0 ? void 0 : _a.Variables) === null || _b === void 0 ? void 0 : _b.length) ? {
319393
+ variables: data.StaticConfig.StaticEnv.Variables.map(v => ({
319394
+ key: v.Key,
319395
+ value: v.Value
319396
+ }))
319397
+ } : undefined
319398
+ } : undefined
319399
+ });
319400
+ }
319401
+ printVersionInfo(data, log) {
319402
+ var _a, _b;
319403
+ log.info((0, i18n_1.t)('版本信息:'));
319404
+ log.info((0, i18n_1.t)(' 构建 ID: {{id}}', { id: data.BuildId || '-' }));
319405
+ log.info((0, i18n_1.t)(' 构建类型: {{type}}', { type: data.BuildType || '-' }));
319406
+ log.info((0, i18n_1.t)(' 框架: {{framework}}', { framework: data.Framework || '-' }));
319407
+ log.info((0, i18n_1.t)(' 状态: {{status}}', { status: data.Status || '-' }));
319408
+ if (data.BuildTime) {
319409
+ log.info((0, i18n_1.t)(' 构建时间: {{time}}', { time: data.BuildTime }));
319410
+ }
319411
+ if (data.FailReason) {
319412
+ log.warn((0, i18n_1.t)(' 失败原因: {{reason}}', { reason: data.FailReason }));
319413
+ }
319414
+ const staticConfig = data.StaticConfig;
319415
+ if (staticConfig) {
319416
+ log.info((0, i18n_1.t)('\n构建配置:'));
319417
+ if (staticConfig.AppPath) {
319418
+ log.info((0, i18n_1.t)(' 应用路径: {{path}}', { path: staticConfig.AppPath }));
319419
+ }
319420
+ if (staticConfig.NodeJsVersion) {
319421
+ log.info((0, i18n_1.t)(' Node.js 版本: {{version}}', { version: staticConfig.NodeJsVersion }));
319422
+ }
319423
+ if (staticConfig.StaticCmd) {
319424
+ log.info((0, i18n_1.t)(' 安装命令: {{cmd}}', { cmd: staticConfig.StaticCmd.InstallCmd || '-' }));
319425
+ log.info((0, i18n_1.t)(' 构建命令: {{cmd}}', { cmd: staticConfig.StaticCmd.BuildCmd || '-' }));
319426
+ log.info((0, i18n_1.t)(' 部署命令: {{cmd}}', { cmd: staticConfig.StaticCmd.DeployCmd || '-' }));
319427
+ }
319428
+ if ((_b = (_a = staticConfig.StaticEnv) === null || _a === void 0 ? void 0 : _a.Variables) === null || _b === void 0 ? void 0 : _b.length) {
319429
+ log.info((0, i18n_1.t)(' 环境变量:'));
319430
+ staticConfig.StaticEnv.Variables.forEach(v => {
319431
+ log.info((0, i18n_1.t)(' {{key}}={{value}}', { key: v.Key, value: v.Value }));
319432
+ });
319433
+ }
319434
+ }
319435
+ }
319436
+ };
319437
+ __decorate([
319438
+ (0, decorators_1.InjectParams)(),
319439
+ __param(0, (0, decorators_1.EnvId)()),
319440
+ __param(1, (0, decorators_1.ArgsParams)()),
319441
+ __param(2, (0, decorators_1.ArgsOptions)()),
319442
+ __param(3, (0, decorators_1.Log)()),
319443
+ __metadata("design:type", Function),
319444
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
319445
+ __metadata("design:returntype", Promise)
319446
+ ], AppVersionDetail.prototype, "execute", null);
319447
+ AppVersionDetail = __decorate([
319448
+ (0, common_1.ICommand)()
319449
+ ], AppVersionDetail);
319450
+ exports.AppVersionDetail = AppVersionDetail;
319451
+ let AppVersionsList = class AppVersionsList extends common_1.Command {
319452
+ get options() {
319453
+ return {
319454
+ cmd: 'app',
319455
+ childCmd: 'versions',
319456
+ childSubCmd: 'list <serviceName>',
319457
+ options: [
319458
+ { flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
319459
+ { flags: '-o, --offset <offset>', desc: (0, i18n_1.t)('数据偏移量,默认值为 0') }
319460
+ ],
319461
+ desc: (0, i18n_1.t)('查询云应用版本列表'),
319462
+ requiredEnvId: false,
319463
+ autoRunLogin: true,
319464
+ examples: ['tcb app versions list my-app --env-id env-xxx'],
319465
+ seeAlso: ['tcb app versions detail', 'tcb app info'],
319466
+ docs: ['https://docs.cloudbase.net/cli/app/versions']
319467
+ };
319468
+ }
319469
+ execute(envId, params, options, log) {
319470
+ return __awaiter(this, void 0, void 0, function* () {
319471
+ let selectedEnvId = envId;
319472
+ if (!selectedEnvId) {
319473
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
319474
+ }
319475
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
319476
+ if (!serviceName) {
319477
+ throw new error_1.CloudBaseError({
319478
+ message: (0, i18n_1.t)('请指定服务名称'),
319479
+ code: 'MISSING_PARAM',
319480
+ solution: [(0, i18n_1.t)('示例: tcb app versions list my-app --env-id env-xxx')]
319481
+ });
319482
+ }
319483
+ const limit = Math.max(1, Number(options.limit || 20));
319484
+ const offset = Number(options.offset || 0);
319485
+ const pageSize = limit;
319486
+ const pageNo = Math.floor(offset / limit) + 1;
319487
+ const loading = (0, utils_1.loadingFactory)();
319488
+ loading.start((0, i18n_1.t)('数据加载中...'));
319489
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
319490
+ const data = yield app.cloudAppService.describeAppVersionList({
319491
+ deployType: 'static-hosting',
319492
+ serviceName: serviceName,
319493
+ pageNo: pageNo,
319494
+ pageSize: pageSize
319495
+ });
319496
+ loading.stop();
319497
+ const versionList = data.VersionList || [];
319498
+ const total = data.Total || 0;
319499
+ if ((0, utils_1.isJsonOutput)()) {
319500
+ (0, utils_1.outputJson)(versionList.map(item => ({
319501
+ versionName: item.VersionName,
319502
+ buildId: item.BuildId,
319503
+ buildType: item.BuildType,
319504
+ buildTime: item.BuildTime,
319505
+ status: item.Status,
319506
+ framework: item.Framework,
319507
+ failReason: item.FailReason
319508
+ })), { total, limit, offset });
319509
+ return;
319510
+ }
319511
+ if (versionList.length === 0) {
319512
+ log.info((0, i18n_1.t)('暂无版本'));
319513
+ return;
319514
+ }
319515
+ const head = [(0, i18n_1.t)('版本名称'), (0, i18n_1.t)('构建 ID'), (0, i18n_1.t)('构建类型'), (0, i18n_1.t)('框架'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('构建时间')];
319516
+ const tableData = versionList.map(item => [
319517
+ item.VersionName || '-',
319518
+ item.BuildId || '-',
319519
+ item.BuildType || '-',
319520
+ item.Framework || '-',
319521
+ item.Status || '-',
319522
+ item.BuildTime || '-'
319523
+ ]);
319524
+ (0, utils_1.printHorizontalTable)(head, tableData);
319525
+ });
319526
+ }
319527
+ };
319528
+ __decorate([
319529
+ (0, decorators_1.InjectParams)(),
319530
+ __param(0, (0, decorators_1.EnvId)()),
319531
+ __param(1, (0, decorators_1.ArgsParams)()),
319532
+ __param(2, (0, decorators_1.ArgsOptions)()),
319533
+ __param(3, (0, decorators_1.Log)()),
319534
+ __metadata("design:type", Function),
319535
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
319536
+ __metadata("design:returntype", Promise)
319537
+ ], AppVersionsList.prototype, "execute", null);
319538
+ AppVersionsList = __decorate([
319539
+ (0, common_1.ICommand)()
319540
+ ], AppVersionsList);
319541
+ exports.AppVersionsList = AppVersionsList;
319542
+
319543
+
318259
319544
  /***/ }),
318260
319545
 
318261
319546
  /***/ 6569:
@@ -324815,6 +326100,124 @@ function renderChoices(choices, pointer) {
324815
326100
  module.exports = RawListPrompt;
324816
326101
 
324817
326102
 
326103
+ /***/ }),
326104
+
326105
+ /***/ 7102:
326106
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
326107
+
326108
+ "use strict";
326109
+
326110
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
326111
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
326112
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
326113
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
326114
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
326115
+ };
326116
+ var __metadata = (this && this.__metadata) || function (k, v) {
326117
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
326118
+ };
326119
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
326120
+ return function (target, key) { decorator(target, key, paramIndex); }
326121
+ };
326122
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
326123
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
326124
+ return new (P || (P = Promise))(function (resolve, reject) {
326125
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
326126
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
326127
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
326128
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
326129
+ });
326130
+ };
326131
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
326132
+ exports.AppInfo = void 0;
326133
+ const common_1 = __webpack_require__(48431);
326134
+ const decorators_1 = __webpack_require__(93480);
326135
+ const utils_1 = __webpack_require__(82079);
326136
+ const utils_2 = __webpack_require__(75213);
326137
+ const constant_1 = __webpack_require__(62977);
326138
+ const i18n_1 = __webpack_require__(69258);
326139
+ const error_1 = __webpack_require__(66759);
326140
+ let AppInfo = class AppInfo extends common_1.Command {
326141
+ get options() {
326142
+ return {
326143
+ cmd: 'app',
326144
+ childCmd: 'info <serviceName>',
326145
+ options: [],
326146
+ desc: (0, i18n_1.t)('查询云应用详情'),
326147
+ requiredEnvId: false,
326148
+ autoRunLogin: true,
326149
+ examples: ['tcb app info my-app --env-id env-xxx'],
326150
+ seeAlso: ['tcb app list', 'tcb app versions'],
326151
+ docs: ['https://docs.cloudbase.net/cli/app/info']
326152
+ };
326153
+ }
326154
+ execute(envId, params, log) {
326155
+ return __awaiter(this, void 0, void 0, function* () {
326156
+ let selectedEnvId = envId;
326157
+ if (!selectedEnvId) {
326158
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
326159
+ }
326160
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
326161
+ if (!serviceName) {
326162
+ throw new error_1.CloudBaseError({
326163
+ message: (0, i18n_1.t)('请指定服务名称'),
326164
+ code: 'MISSING_PARAM',
326165
+ solution: [(0, i18n_1.t)('示例: tcb app info my-app --env-id env-xxx')]
326166
+ });
326167
+ }
326168
+ const loading = (0, utils_1.loadingFactory)();
326169
+ loading.start((0, i18n_1.t)('数据加载中...'));
326170
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
326171
+ const data = yield app.cloudAppService.describeAppInfo({
326172
+ deployType: 'static-hosting',
326173
+ serviceName: serviceName
326174
+ });
326175
+ loading.stop();
326176
+ if ((0, utils_1.isJsonOutput)()) {
326177
+ (0, utils_1.outputJson)({
326178
+ serviceName: data.ServiceName,
326179
+ deployType: data.DeployType,
326180
+ framework: data.Framework,
326181
+ domain: data.Domain,
326182
+ latestStatus: data.LatestStatus,
326183
+ createTime: data.CreateTime,
326184
+ latestVersionName: data.LatestVersionName,
326185
+ staticConfig: data.StaticConfig
326186
+ });
326187
+ return;
326188
+ }
326189
+ log.info((0, i18n_1.t)('服务名称: {{name}}', { name: data.ServiceName }));
326190
+ log.info((0, i18n_1.t)('部署类型: {{type}}', { type: data.DeployType || 'static-hosting' }));
326191
+ log.info((0, i18n_1.t)('框架类型: {{framework}}', { framework: data.Framework || '-' }));
326192
+ log.info((0, i18n_1.t)('访问地址: {{domain}}', { domain: data.Domain || '-' }));
326193
+ log.info((0, i18n_1.t)('当前版本: {{version}}', { version: data.LatestVersionName || '-' }));
326194
+ log.info((0, i18n_1.t)('构建状态: {{status}}', { status: data.LatestStatus || '-' }));
326195
+ log.info((0, i18n_1.t)('创建时间: {{time}}', { time: data.CreateTime || '-' }));
326196
+ log.info((0, i18n_1.t)('\n下一步:'));
326197
+ log.info((0, i18n_1.t)(' 查看版本 tcb app versions list {{name}} --env-id {{envId}}', {
326198
+ name: serviceName, envId: selectedEnvId
326199
+ }));
326200
+ log.info((0, i18n_1.t)(' 重新部署 tcb app deploy {{name}} --env-id {{envId}}', {
326201
+ name: serviceName, envId: selectedEnvId
326202
+ }));
326203
+ });
326204
+ }
326205
+ };
326206
+ __decorate([
326207
+ (0, decorators_1.InjectParams)(),
326208
+ __param(0, (0, decorators_1.EnvId)()),
326209
+ __param(1, (0, decorators_1.ArgsParams)()),
326210
+ __param(2, (0, decorators_1.Log)()),
326211
+ __metadata("design:type", Function),
326212
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
326213
+ __metadata("design:returntype", Promise)
326214
+ ], AppInfo.prototype, "execute", null);
326215
+ AppInfo = __decorate([
326216
+ (0, common_1.ICommand)()
326217
+ ], AppInfo);
326218
+ exports.AppInfo = AppInfo;
326219
+
326220
+
324818
326221
  /***/ }),
324819
326222
 
324820
326223
  /***/ 7106:
@@ -330606,7 +332009,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
330606
332009
  /***/ ((module) => {
330607
332010
 
330608
332011
  "use strict";
330609
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.4","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","test:e2e":"node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern=\'test/e2e/\' --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.11.0-alpha.8","@cloudbase/toolbox":"0.7.17","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","i18next-scanner":"^4.6.0","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
332012
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.8","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","test:e2e":"node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern=\'test/e2e/\' --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.11.0-alpha.9","@cloudbase/toolbox":"0.7.17","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","i18next-scanner":"^4.6.0","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
330610
332013
 
330611
332014
  /***/ }),
330612
332015
 
@@ -381294,6 +382697,18 @@ process.on('exit', Temp.purgeSyncAll); // Ensuring purgeable temp files are purg
381294
382697
  exports["default"] = Temp;
381295
382698
 
381296
382699
 
382700
+ /***/ }),
382701
+
382702
+ /***/ 14764:
382703
+ /***/ ((__unused_webpack_module, exports) => {
382704
+
382705
+ "use strict";
382706
+
382707
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
382708
+ exports.DEPLOY_TYPE_STATIC_HOSTING = void 0;
382709
+ exports.DEPLOY_TYPE_STATIC_HOSTING = 'static-hosting';
382710
+
382711
+
381297
382712
  /***/ }),
381298
382713
 
381299
382714
  /***/ 14777:
@@ -386244,6 +387659,547 @@ return PromiseArray;
386244
387659
  };
386245
387660
 
386246
387661
 
387662
+ /***/ }),
387663
+
387664
+ /***/ 15771:
387665
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
387666
+
387667
+ "use strict";
387668
+
387669
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
387670
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
387671
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
387672
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
387673
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
387674
+ };
387675
+ var __metadata = (this && this.__metadata) || function (k, v) {
387676
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
387677
+ };
387678
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
387679
+ return function (target, key) { decorator(target, key, paramIndex); }
387680
+ };
387681
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
387682
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
387683
+ return new (P || (P = Promise))(function (resolve, reject) {
387684
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
387685
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
387686
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
387687
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
387688
+ });
387689
+ };
387690
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
387691
+ exports.PermissionGetCommand = exports.PermissionSetCommand = void 0;
387692
+ const common_1 = __webpack_require__(48431);
387693
+ const decorators_1 = __webpack_require__(93480);
387694
+ const error_1 = __webpack_require__(66759);
387695
+ const utils_1 = __webpack_require__(82079);
387696
+ const i18n_1 = __webpack_require__(69258);
387697
+ function getPermissionService(envId) {
387698
+ return __awaiter(this, void 0, void 0, function* () {
387699
+ const app = yield (0, utils_1.getMangerService)(envId);
387700
+ return app.permission;
387701
+ });
387702
+ }
387703
+ const VALID_RESOURCE_TYPES = ['function', 'storage', 'table', 'collection'];
387704
+ const VALID_LEVELS = {
387705
+ table: ['readonly', 'private', 'adminwrite', 'adminonly'],
387706
+ collection: ['readonly', 'private', 'adminwrite', 'adminonly', 'custom'],
387707
+ function: ['custom'],
387708
+ storage: ['readonly', 'private', 'adminwrite', 'adminonly', 'custom']
387709
+ };
387710
+ const LEVEL_MAP = {
387711
+ readonly: 'READONLY',
387712
+ private: 'PRIVATE',
387713
+ adminwrite: 'ADMINWRITE',
387714
+ adminonly: 'ADMINONLY',
387715
+ custom: 'CUSTOM'
387716
+ };
387717
+ const REVERSE_LEVEL_MAP = {
387718
+ READONLY: 'readonly',
387719
+ PRIVATE: 'private',
387720
+ ADMINWRITE: 'adminwrite',
387721
+ ADMINONLY: 'adminonly',
387722
+ CUSTOM: 'custom'
387723
+ };
387724
+ const LEVEL_DESCRIPTIONS = {
387725
+ table: {
387726
+ readonly: '读取全部数据,修改本人数据',
387727
+ private: '读取和修改本人数据',
387728
+ adminwrite: '读取全部数据,不可修改数据',
387729
+ adminonly: '无权限'
387730
+ },
387731
+ collection: {
387732
+ readonly: '读取全部数据,修改本人数据',
387733
+ private: '读取和修改本人数据',
387734
+ adminwrite: '读取全部数据,不可修改数据',
387735
+ adminonly: '无权限',
387736
+ custom: '自定义安全规则'
387737
+ },
387738
+ function: {
387739
+ custom: '自定义安全规则'
387740
+ },
387741
+ storage: {
387742
+ readonly: '所有用户可读,仅创建者和管理员可写',
387743
+ private: '仅创建者及管理员可读写',
387744
+ adminwrite: '所有用户可读,仅管理员可写',
387745
+ adminonly: '仅管理员可读写',
387746
+ custom: '自定义安全规则'
387747
+ }
387748
+ };
387749
+ function parseResourceArg(resourceArg) {
387750
+ if (!resourceArg) {
387751
+ throw new error_1.CloudBaseError({
387752
+ message: (0, i18n_1.t)('参数格式错误:请指定资源类型'),
387753
+ code: 'INVALID_PARAM',
387754
+ solution: [
387755
+ (0, i18n_1.t)('用法:tcb permission set <type>:<resource> --level <level>'),
387756
+ (0, i18n_1.t)('示例:tcb permission set table:users --level readonly'),
387757
+ (0, i18n_1.t)('云函数可省略资源名称:tcb permission set function --level custom --rule \'{"read": true}\''),
387758
+ (0, i18n_1.t)('支持的资源类型:{{types}}', { types: VALID_RESOURCE_TYPES.join(', ') })
387759
+ ]
387760
+ });
387761
+ }
387762
+ let resourceType;
387763
+ let resource;
387764
+ if (resourceArg.includes(':')) {
387765
+ const colonIndex = resourceArg.indexOf(':');
387766
+ resourceType = resourceArg.substring(0, colonIndex);
387767
+ resource = resourceArg.substring(colonIndex + 1);
387768
+ }
387769
+ else {
387770
+ resourceType = resourceArg;
387771
+ resource = '';
387772
+ }
387773
+ if (!VALID_RESOURCE_TYPES.includes(resourceType)) {
387774
+ throw new error_1.CloudBaseError({
387775
+ message: (0, i18n_1.t)('不支持的资源类型:{{type}}', { type: resourceType }),
387776
+ code: 'INVALID_ENUM',
387777
+ solution: [
387778
+ (0, i18n_1.t)('支持的资源类型:{{types}}', { types: VALID_RESOURCE_TYPES.join(', ') }),
387779
+ (0, i18n_1.t)('示例:tcb permission set table:users --level readonly')
387780
+ ]
387781
+ });
387782
+ }
387783
+ const typedResourceType = resourceType;
387784
+ if (!resource && typedResourceType !== 'function') {
387785
+ throw new error_1.CloudBaseError({
387786
+ message: (0, i18n_1.t)('资源名称不能为空'),
387787
+ code: 'INVALID_PARAM',
387788
+ solution: [
387789
+ (0, i18n_1.t)('用法:tcb permission set <type>:<resource> --level <level>'),
387790
+ ]
387791
+ });
387792
+ }
387793
+ return { resourceType: typedResourceType, resource };
387794
+ }
387795
+ function parseGetResourceArg(resourceArg) {
387796
+ const [rawType, rawResources = ''] = resourceArg.split(':');
387797
+ const resources = rawResources
387798
+ ? rawResources.split(',').map(r => r.trim()).filter(Boolean)
387799
+ : [];
387800
+ if (!VALID_RESOURCE_TYPES.includes(rawType)) {
387801
+ throw new error_1.CloudBaseError({
387802
+ message: (0, i18n_1.t)('不支持的资源类型:{{type}}', { type: rawType }),
387803
+ code: 'INVALID_ENUM',
387804
+ solution: [
387805
+ (0, i18n_1.t)('支持的资源类型:{{types}}', { types: VALID_RESOURCE_TYPES.join(', ') }),
387806
+ (0, i18n_1.t)('示例:tcb permission get table:users')
387807
+ ]
387808
+ });
387809
+ }
387810
+ if (resources.length > 100) {
387811
+ throw new error_1.CloudBaseError({
387812
+ message: (0, i18n_1.t)('资源列表不能超过 100 条,当前 {{count}} 条', { count: resources.length }),
387813
+ code: 'INVALID_PARAM'
387814
+ });
387815
+ }
387816
+ return { resourceType: rawType, resources };
387817
+ }
387818
+ function fetchResourceIdentifiers(resourceType, envId) {
387819
+ var _a, _b;
387820
+ return __awaiter(this, void 0, void 0, function* () {
387821
+ const app = yield (0, utils_1.getMangerService)(envId);
387822
+ switch (resourceType) {
387823
+ case 'function':
387824
+ return [];
387825
+ case 'storage': {
387826
+ const result = yield app.env.describeEnvs({ EnvId: envId });
387827
+ const storages = ((_b = (_a = result.EnvList) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Storages) || [];
387828
+ return storages.map(s => s.Bucket).filter(Boolean);
387829
+ }
387830
+ case 'collection': {
387831
+ const result = yield app.database.listCollections({});
387832
+ const collections = result.Collections || [];
387833
+ return collections.map(c => c.CollectionName);
387834
+ }
387835
+ case 'table': {
387836
+ const result = yield app.mysql.runSql({
387837
+ Sql: `SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='${envId}' AND TABLE_TYPE='BASE TABLE' AND TABLE_NAME LIKE '%'`,
387838
+ ReadOnly: true
387839
+ });
387840
+ return (result.Items || []).map((item) => {
387841
+ try {
387842
+ const parsed = JSON.parse(item);
387843
+ return Array.isArray(parsed) ? parsed[0] : parsed.TABLE_NAME;
387844
+ }
387845
+ catch (_a) {
387846
+ return item;
387847
+ }
387848
+ });
387849
+ }
387850
+ default:
387851
+ return [];
387852
+ }
387853
+ });
387854
+ }
387855
+ let PermissionSetCommand = class PermissionSetCommand extends common_1.Command {
387856
+ get options() {
387857
+ return {
387858
+ cmd: 'permission',
387859
+ childCmd: 'set <resourceArg>',
387860
+ options: [
387861
+ {
387862
+ flags: '-e, --env-id <envId>',
387863
+ desc: (0, i18n_1.t)('环境 Id'),
387864
+ deprecatedName: 'envId'
387865
+ },
387866
+ {
387867
+ flags: '--level <level>',
387868
+ desc: (0, i18n_1.t)('权限级别'),
387869
+ choices: ['readonly', 'private', 'adminwrite', 'adminonly', 'custom']
387870
+ },
387871
+ {
387872
+ flags: '--rule <rule>',
387873
+ desc: (0, i18n_1.t)('自定义规则(JSON 字符串)')
387874
+ },
387875
+ ],
387876
+ desc: (0, i18n_1.t)('设置资源权限'),
387877
+ examples: [
387878
+ 'tcb permission set table:users --level readonly --env-id xxx',
387879
+ 'tcb permission set function --level custom --rule \'{"read": true}\' --env-id xxx',
387880
+ 'tcb permission set table:users --level readonly --env-id xxx --json'
387881
+ ]
387882
+ };
387883
+ }
387884
+ execute(envId, params, options, log) {
387885
+ var _a;
387886
+ return __awaiter(this, void 0, void 0, function* () {
387887
+ const resourceArg = params === null || params === void 0 ? void 0 : params[0];
387888
+ const { resourceType, resource } = parseResourceArg(resourceArg);
387889
+ const level = options.level;
387890
+ const rule = options.rule;
387891
+ if (!level && !rule) {
387892
+ throw new error_1.CloudBaseError({
387893
+ message: (0, i18n_1.t)('请指定权限级别或自定义规则'),
387894
+ code: 'MISSING_PARAM',
387895
+ solution: [
387896
+ (0, i18n_1.t)('使用 --level 指定权限级别:tcb permission set {{type}}:{{resource}} --level <level>', { type: resourceType, resource }),
387897
+ (0, i18n_1.t)('或使用 --rule 指定自定义规则:tcb permission set {{type}}:{{resource}} --rule \'<json>\'', { type: resourceType, resource }),
387898
+ (0, i18n_1.t)('{{type}} 支持的权限级别:{{levels}}', { type: resourceType, levels: VALID_LEVELS[resourceType].join(', ') })
387899
+ ]
387900
+ });
387901
+ }
387902
+ let finalLevel;
387903
+ if (level) {
387904
+ finalLevel = level;
387905
+ }
387906
+ else {
387907
+ finalLevel = 'custom';
387908
+ }
387909
+ const validLevels = VALID_LEVELS[resourceType];
387910
+ if (!validLevels.includes(finalLevel)) {
387911
+ throw new error_1.CloudBaseError({
387912
+ message: (0, i18n_1.t)('资源类型 {{type}} 不支持权限级别 {{level}}', { type: resourceType, level: finalLevel }),
387913
+ code: 'INVALID_PARAM',
387914
+ solution: [
387915
+ (0, i18n_1.t)('{{type}} 支持的权限级别:{{levels}}', { type: resourceType, levels: validLevels.join(', ') })
387916
+ ]
387917
+ });
387918
+ }
387919
+ if (finalLevel === 'custom' && !rule) {
387920
+ throw new error_1.CloudBaseError({
387921
+ message: (0, i18n_1.t)('权限级别为 custom 时,需要提供 --rule '),
387922
+ code: 'MISSING_PARAM',
387923
+ solution: [
387924
+ (0, i18n_1.t)('使用 --rule 指定规则:--rule \'{"read": true}\''),
387925
+ (0, i18n_1.t)('示例:tcb permission set {{type}}:{{resource}} --level custom --rule \'{"read": true}\'', { type: resourceType, resource })
387926
+ ]
387927
+ });
387928
+ }
387929
+ const apiOptions = {
387930
+ resourceType,
387931
+ resource,
387932
+ permission: LEVEL_MAP[finalLevel]
387933
+ };
387934
+ if (rule) {
387935
+ apiOptions.securityRule = rule;
387936
+ }
387937
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('即将设置 {{type}}/{{resource}} 的权限为 {{level}},确认执行?', {
387938
+ type: resourceType, resource, level: finalLevel
387939
+ }));
387940
+ if (!confirmed)
387941
+ return;
387942
+ if (!(0, utils_1.isJsonOutput)()) {
387943
+ log.info((0, i18n_1.t)('正在设置 {{type}}/{{resource}} 的权限...', { type: resourceType, resource }));
387944
+ }
387945
+ try {
387946
+ const permissionService = yield getPermissionService(envId);
387947
+ const resp = yield permissionService.modifyResourcePermission(apiOptions);
387948
+ if ((0, utils_1.isJsonOutput)()) {
387949
+ (0, utils_1.outputJson)(resp);
387950
+ return;
387951
+ }
387952
+ log.success((0, i18n_1.t)('资源权限设置成功'));
387953
+ log.info('');
387954
+ log.info((0, i18n_1.t)('权限详情:'));
387955
+ log.info(` Resource: ${resourceType}/${resource}`);
387956
+ log.info(` Level: ${finalLevel}`);
387957
+ const description = (_a = LEVEL_DESCRIPTIONS[resourceType]) === null || _a === void 0 ? void 0 : _a[finalLevel];
387958
+ if (description) {
387959
+ log.info(` Description: ${description}`);
387960
+ }
387961
+ if (rule) {
387962
+ log.info(` Rule: ${rule}`);
387963
+ }
387964
+ log.info('');
387965
+ log.info((0, i18n_1.t)('下一步:'));
387966
+ log.info(` ${(0, i18n_1.t)('查看资源权限')} ${(0, utils_1.highlightCommand)(`tcb permission get ${resourceType}:${resource} --env-id ${envId}`)}`);
387967
+ }
387968
+ catch (e) {
387969
+ throw new error_1.CloudBaseError({
387970
+ message: e.message || (0, i18n_1.t)('设置资源权限失败'),
387971
+ code: 'API_ERROR',
387972
+ solution: [
387973
+ (0, i18n_1.t)('请检查资源名称是否正确'),
387974
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
387975
+ ],
387976
+ original: e
387977
+ });
387978
+ }
387979
+ });
387980
+ }
387981
+ };
387982
+ __decorate([
387983
+ (0, decorators_1.InjectParams)(),
387984
+ __param(0, (0, decorators_1.EnvId)()),
387985
+ __param(1, (0, decorators_1.ArgsParams)()),
387986
+ __param(2, (0, decorators_1.ArgsOptions)()),
387987
+ __param(3, (0, decorators_1.Log)()),
387988
+ __metadata("design:type", Function),
387989
+ __metadata("design:paramtypes", [String, Array, Object, decorators_1.Logger]),
387990
+ __metadata("design:returntype", Promise)
387991
+ ], PermissionSetCommand.prototype, "execute", null);
387992
+ PermissionSetCommand = __decorate([
387993
+ (0, common_1.ICommand)()
387994
+ ], PermissionSetCommand);
387995
+ exports.PermissionSetCommand = PermissionSetCommand;
387996
+ let PermissionGetCommand = class PermissionGetCommand extends common_1.Command {
387997
+ get options() {
387998
+ return {
387999
+ cmd: 'permission',
388000
+ childCmd: 'get [resourceArg]',
388001
+ options: [
388002
+ {
388003
+ flags: '-e, --env-id <envId>',
388004
+ desc: (0, i18n_1.t)('环境 Id'),
388005
+ deprecatedName: 'envId'
388006
+ }
388007
+ ],
388008
+ desc: (0, i18n_1.t)('查询资源权限'),
388009
+ autoRunLogin: true,
388010
+ examples: [
388011
+ 'tcb permission get --env-id xxx',
388012
+ 'tcb permission get table --env-id xxx',
388013
+ 'tcb permission get table:users --env-id xxx',
388014
+ 'tcb permission get table:users,orders --env-id xxx',
388015
+ 'tcb permission get function --env-id xxx',
388016
+ 'tcb permission get storage:my-bucket --env-id xxx',
388017
+ 'tcb permission get table --env-id xxx --json'
388018
+ ]
388019
+ };
388020
+ }
388021
+ execute(envId, params, options, log) {
388022
+ return __awaiter(this, void 0, void 0, function* () {
388023
+ const resourceArg = params === null || params === void 0 ? void 0 : params[0];
388024
+ let queryTypes;
388025
+ if (!resourceArg) {
388026
+ queryTypes = [...VALID_RESOURCE_TYPES];
388027
+ }
388028
+ else if (!resourceArg.includes(':')) {
388029
+ if (!VALID_RESOURCE_TYPES.includes(resourceArg)) {
388030
+ throw new error_1.CloudBaseError({
388031
+ message: (0, i18n_1.t)('不支持的资源类型:{{type}}', { type: resourceArg }),
388032
+ code: 'INVALID_ENUM',
388033
+ solution: [
388034
+ (0, i18n_1.t)('支持的资源类型:{{types}}', { types: VALID_RESOURCE_TYPES.join(', ') })
388035
+ ]
388036
+ });
388037
+ }
388038
+ queryTypes = [resourceArg];
388039
+ }
388040
+ else {
388041
+ const { resourceType, resources } = parseGetResourceArg(resourceArg);
388042
+ queryTypes = [resourceType];
388043
+ return this.executeWithResources(resourceType, resources, envId, log);
388044
+ }
388045
+ return this.executeForTypes(queryTypes, envId, log);
388046
+ });
388047
+ }
388048
+ executeWithResources(resourceType, resources, envId, log) {
388049
+ var _a, _b, _c;
388050
+ return __awaiter(this, void 0, void 0, function* () {
388051
+ if (!(0, utils_1.isJsonOutput)()) {
388052
+ const displayResources = resources.join(', ');
388053
+ log.info((0, i18n_1.t)('正在查询 {{type}} 的权限({{resources}})...', {
388054
+ type: resourceType,
388055
+ resources: displayResources
388056
+ }));
388057
+ }
388058
+ try {
388059
+ const permissionService = yield getPermissionService(envId);
388060
+ let finalResources = resources;
388061
+ if (finalResources.length === 0 && resourceType !== 'function') {
388062
+ finalResources = yield fetchResourceIdentifiers(resourceType, envId);
388063
+ }
388064
+ if (finalResources.length === 0) {
388065
+ if (!(0, utils_1.isJsonOutput)()) {
388066
+ log.info((0, i18n_1.t)('{{type}} 类型的资源列表为空,跳过查询', { type: resourceType }));
388067
+ }
388068
+ this.outputResult([], 0, log);
388069
+ return;
388070
+ }
388071
+ const resp = yield permissionService.describeResourcePermission({
388072
+ resourceType,
388073
+ resources: finalResources
388074
+ });
388075
+ this.outputResult(((_a = resp.Data) === null || _a === void 0 ? void 0 : _a.PermissionList) || [], (_c = (_b = resp.Data) === null || _b === void 0 ? void 0 : _b.TotalCount) !== null && _c !== void 0 ? _c : 0, log);
388076
+ }
388077
+ catch (e) {
388078
+ throw new error_1.CloudBaseError({
388079
+ message: e.message || (0, i18n_1.t)('查询资源权限失败'),
388080
+ code: 'API_ERROR',
388081
+ solution: [
388082
+ (0, i18n_1.t)('请检查资源名称是否正确'),
388083
+ (0, i18n_1.t)('运行 {{cmd}} 重新登录', { cmd: (0, utils_1.highlightCommand)('tcb login') })
388084
+ ],
388085
+ original: e
388086
+ });
388087
+ }
388088
+ });
388089
+ }
388090
+ executeForTypes(types, envId, log) {
388091
+ return __awaiter(this, void 0, void 0, function* () {
388092
+ const typeDisplay = types.length === VALID_RESOURCE_TYPES.length
388093
+ ? (0, i18n_1.t)('全部类型')
388094
+ : types.join(', ');
388095
+ if (!(0, utils_1.isJsonOutput)()) {
388096
+ log.info((0, i18n_1.t)('正在查询 {{types}} 的资源权限...', { types: typeDisplay }));
388097
+ }
388098
+ const permissionService = yield getPermissionService(envId);
388099
+ const results = yield Promise.all(types.map((type) => __awaiter(this, void 0, void 0, function* () {
388100
+ var _a, _b, _c, _d;
388101
+ try {
388102
+ const resources = yield fetchResourceIdentifiers(type, envId);
388103
+ if (type !== 'function' && resources.length === 0) {
388104
+ log.verbose(`[${type}] 无资源,跳过查询`);
388105
+ return { permissionList: [], totalCount: 0 };
388106
+ }
388107
+ const apiResources = type === 'function' ? undefined : resources;
388108
+ if (!(0, utils_1.isJsonOutput)()) {
388109
+ log.verbose(`[${type}] 获取到 ${(_a = apiResources === null || apiResources === void 0 ? void 0 : apiResources.length) !== null && _a !== void 0 ? _a : 0} 个资源标识`);
388110
+ }
388111
+ const resp = yield permissionService.describeResourcePermission({
388112
+ resourceType: type,
388113
+ resources: apiResources
388114
+ });
388115
+ return {
388116
+ permissionList: ((_b = resp.Data) === null || _b === void 0 ? void 0 : _b.PermissionList) || [],
388117
+ totalCount: (_d = (_c = resp.Data) === null || _c === void 0 ? void 0 : _c.TotalCount) !== null && _d !== void 0 ? _d : 0
388118
+ };
388119
+ }
388120
+ catch (e) {
388121
+ if (!(0, utils_1.isJsonOutput)()) {
388122
+ log.warn((0, i18n_1.t)('查询 {{type}} 权限失败: {{error}}', {
388123
+ type,
388124
+ error: e.message
388125
+ }));
388126
+ }
388127
+ return { permissionList: [], totalCount: 0 };
388128
+ }
388129
+ })));
388130
+ const allPermissions = results.reduce((list, r) => list.concat(r.permissionList), []);
388131
+ const totalCount = results.reduce((sum, r) => sum + r.totalCount, 0);
388132
+ this.outputResult(allPermissions, totalCount, log);
388133
+ });
388134
+ }
388135
+ outputResult(permissionList, totalCount, log) {
388136
+ if ((0, utils_1.isJsonOutput)()) {
388137
+ (0, utils_1.outputJson)({
388138
+ TotalCount: totalCount,
388139
+ PermissionList: permissionList
388140
+ });
388141
+ return;
388142
+ }
388143
+ if (permissionList.length === 0) {
388144
+ log.info((0, i18n_1.t)('未查询到权限记录'));
388145
+ return;
388146
+ }
388147
+ const head = [
388148
+ (0, i18n_1.t)('资源类型'),
388149
+ (0, i18n_1.t)('资源名称'),
388150
+ (0, i18n_1.t)('权限级别'),
388151
+ (0, i18n_1.t)('描述')
388152
+ ];
388153
+ const tableData = permissionList.map(item => {
388154
+ var _a;
388155
+ const type = item.ResourceType || '-';
388156
+ const resource = item.Resource || '-';
388157
+ const permission = item.Permission || '-';
388158
+ const lowerLevel = REVERSE_LEVEL_MAP[permission] || permission;
388159
+ const description = ((_a = LEVEL_DESCRIPTIONS[type]) === null || _a === void 0 ? void 0 : _a[lowerLevel]) || '-';
388160
+ return [type, resource, lowerLevel, description];
388161
+ });
388162
+ (0, utils_1.printHorizontalTable)(head, tableData);
388163
+ log.info((0, i18n_1.t)('共 {{count}} 条记录', { count: totalCount }));
388164
+ }
388165
+ };
388166
+ __decorate([
388167
+ (0, decorators_1.InjectParams)(),
388168
+ __param(0, (0, decorators_1.EnvId)()),
388169
+ __param(1, (0, decorators_1.ArgsParams)()),
388170
+ __param(2, (0, decorators_1.ArgsOptions)()),
388171
+ __param(3, (0, decorators_1.Log)()),
388172
+ __metadata("design:type", Function),
388173
+ __metadata("design:paramtypes", [String, Array, Object, decorators_1.Logger]),
388174
+ __metadata("design:returntype", Promise)
388175
+ ], PermissionGetCommand.prototype, "execute", null);
388176
+ __decorate([
388177
+ (0, decorators_1.InjectParams)(),
388178
+ __param(3, (0, decorators_1.Log)()),
388179
+ __metadata("design:type", Function),
388180
+ __metadata("design:paramtypes", [String, Array, String, decorators_1.Logger]),
388181
+ __metadata("design:returntype", Promise)
388182
+ ], PermissionGetCommand.prototype, "executeWithResources", null);
388183
+ __decorate([
388184
+ (0, decorators_1.InjectParams)(),
388185
+ __param(2, (0, decorators_1.Log)()),
388186
+ __metadata("design:type", Function),
388187
+ __metadata("design:paramtypes", [Array, String, decorators_1.Logger]),
388188
+ __metadata("design:returntype", Promise)
388189
+ ], PermissionGetCommand.prototype, "executeForTypes", null);
388190
+ __decorate([
388191
+ (0, decorators_1.InjectParams)(),
388192
+ __param(2, (0, decorators_1.Log)()),
388193
+ __metadata("design:type", Function),
388194
+ __metadata("design:paramtypes", [Array, Number, decorators_1.Logger]),
388195
+ __metadata("design:returntype", void 0)
388196
+ ], PermissionGetCommand.prototype, "outputResult", null);
388197
+ PermissionGetCommand = __decorate([
388198
+ (0, common_1.ICommand)()
388199
+ ], PermissionGetCommand);
388200
+ exports.PermissionGetCommand = PermissionGetCommand;
388201
+
388202
+
386247
388203
  /***/ }),
386248
388204
 
386249
388205
  /***/ 15782:
@@ -400192,7 +402148,7 @@ exports.GitBase = GitBase;
400192
402148
  "use strict";
400193
402149
 
400194
402150
 
400195
- var toPosInt = __webpack_require__(32665)
402151
+ var toPosInt = __webpack_require__(55046)
400196
402152
 
400197
402153
  , create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty;
400198
402154
 
@@ -401586,9 +403542,15 @@ async function main() {
401586
403542
  const { outputHelpInfo } = __webpack_require__(95042)
401587
403543
  outputHelpInfo()
401588
403544
  } else if (!['-v', '--version'].includes(processArgv[2])) {
401589
- // HACK: framework 智能命令
401590
- const { smartDeploy } = __webpack_require__(8509)
401591
- smartDeploy()
403545
+ // 检测是否有旧的 framework.plugins 配置
403546
+ if (config?.framework?.plugins) {
403547
+ console.log(chalk.yellow(t('⚠️ 检测到旧版 framework.plugins 配置,请改用 tcb framework deploy')))
403548
+ console.log(chalk.gray(t(' 旧的 framework-core 一体化部署能力已迁移到 tcb framework deploy 命令')))
403549
+ processArgv = [processArgv[0], processArgv[1], 'framework', 'deploy', ...processArgv.slice(2)]
403550
+ } else {
403551
+ // 无子命令时,路由到 tcb app deploy 交互式部署流程
403552
+ processArgv = [processArgv[0], processArgv[1], 'app', 'deploy', ...processArgv.slice(2)]
403553
+ }
401592
403554
  }
401593
403555
  }
401594
403556
  }
@@ -401812,6 +403774,99 @@ if (__webpack_require__.c[__webpack_require__.s] === module) {
401812
403774
  exports.main = main
401813
403775
 
401814
403776
 
403777
+ /***/ }),
403778
+
403779
+ /***/ 18508:
403780
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
403781
+
403782
+ "use strict";
403783
+
403784
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
403785
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
403786
+ return new (P || (P = Promise))(function (resolve, reject) {
403787
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
403788
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
403789
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
403790
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
403791
+ });
403792
+ };
403793
+ var __importDefault = (this && this.__importDefault) || function (mod) {
403794
+ return (mod && mod.__esModule) ? mod : { "default": mod };
403795
+ };
403796
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
403797
+ exports.detectFramework = void 0;
403798
+ const fs_1 = __importDefault(__webpack_require__(79896));
403799
+ const path_1 = __importDefault(__webpack_require__(16928));
403800
+ const FRAMEWORK_RULES = [
403801
+ {
403802
+ name: 'next',
403803
+ displayName: 'Next.js',
403804
+ detect: (deps) => 'next' in deps,
403805
+ config: { buildCommand: 'npm run build', outputDir: '.next' }
403806
+ },
403807
+ {
403808
+ name: 'nuxt',
403809
+ displayName: 'Nuxt',
403810
+ detect: (deps) => 'nuxt' in deps,
403811
+ config: { buildCommand: 'npm run build', outputDir: '.nuxt' }
403812
+ },
403813
+ {
403814
+ name: 'angular',
403815
+ displayName: 'Angular',
403816
+ detect: (deps) => '@angular/cli' in deps,
403817
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
403818
+ },
403819
+ {
403820
+ name: 'vite',
403821
+ displayName: 'Vite',
403822
+ detect: (deps) => 'vite' in deps,
403823
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
403824
+ },
403825
+ {
403826
+ name: 'vue',
403827
+ displayName: 'Vue CLI',
403828
+ detect: (deps) => '@vue/cli-service' in deps,
403829
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
403830
+ },
403831
+ {
403832
+ name: 'react',
403833
+ displayName: 'React (create-react-app)',
403834
+ detect: (deps) => 'react-scripts' in deps,
403835
+ config: { buildCommand: 'npm run build', outputDir: 'build' }
403836
+ }
403837
+ ];
403838
+ function detectFramework(projectPath) {
403839
+ return __awaiter(this, void 0, void 0, function* () {
403840
+ const packageJsonPath = path_1.default.join(projectPath, 'package.json');
403841
+ if (fs_1.default.existsSync(packageJsonPath)) {
403842
+ try {
403843
+ const raw = yield fs_1.default.promises.readFile(packageJsonPath, 'utf-8');
403844
+ const packageJson = JSON.parse(raw);
403845
+ const allDeps = Object.assign(Object.assign({}, packageJson.dependencies), packageJson.devDependencies);
403846
+ for (const rule of FRAMEWORK_RULES) {
403847
+ if (rule.detect(allDeps)) {
403848
+ return Object.assign({ framework: rule.name, displayName: rule.displayName }, rule.config);
403849
+ }
403850
+ }
403851
+ }
403852
+ catch (_a) {
403853
+ }
403854
+ }
403855
+ const indexHtmlPath = path_1.default.join(projectPath, 'index.html');
403856
+ if (fs_1.default.existsSync(indexHtmlPath)) {
403857
+ return {
403858
+ framework: 'static',
403859
+ displayName: '静态 HTML',
403860
+ buildCommand: '',
403861
+ outputDir: '.'
403862
+ };
403863
+ }
403864
+ return null;
403865
+ });
403866
+ }
403867
+ exports.detectFramework = detectFramework;
403868
+
403869
+
401815
403870
  /***/ }),
401816
403871
 
401817
403872
  /***/ 18560:
@@ -411157,7 +413212,7 @@ exports.prettify = prettify;
411157
413212
  "use strict";
411158
413213
 
411159
413214
 
411160
- var toPosInt = __webpack_require__(32665)
413215
+ var toPosInt = __webpack_require__(55046)
411161
413216
  , maxTimeout = __webpack_require__(45481);
411162
413217
 
411163
413218
  module.exports = function (value) {
@@ -411738,6 +413793,138 @@ ZodError.create = (issues) => {
411738
413793
  };
411739
413794
 
411740
413795
 
413796
+ /***/ }),
413797
+
413798
+ /***/ 20666:
413799
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
413800
+
413801
+ "use strict";
413802
+
413803
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
413804
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
413805
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
413806
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
413807
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
413808
+ };
413809
+ var __metadata = (this && this.__metadata) || function (k, v) {
413810
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
413811
+ };
413812
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
413813
+ return function (target, key) { decorator(target, key, paramIndex); }
413814
+ };
413815
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
413816
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
413817
+ return new (P || (P = Promise))(function (resolve, reject) {
413818
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
413819
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
413820
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
413821
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
413822
+ });
413823
+ };
413824
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
413825
+ exports.AppList = void 0;
413826
+ const common_1 = __webpack_require__(48431);
413827
+ const decorators_1 = __webpack_require__(93480);
413828
+ const utils_1 = __webpack_require__(82079);
413829
+ const utils_2 = __webpack_require__(75213);
413830
+ const constant_1 = __webpack_require__(62977);
413831
+ const i18n_1 = __webpack_require__(69258);
413832
+ let AppList = class AppList extends common_1.Command {
413833
+ get options() {
413834
+ return {
413835
+ cmd: 'app',
413836
+ childCmd: 'list',
413837
+ options: [
413838
+ { flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
413839
+ { flags: '-o, --offset <offset>', desc: (0, i18n_1.t)('数据偏移量,默认值为 0') }
413840
+ ],
413841
+ desc: (0, i18n_1.t)('查询云应用列表'),
413842
+ requiredEnvId: false,
413843
+ autoRunLogin: true,
413844
+ examples: ['tcb app list', 'tcb app list --env-id env-xxx --json'],
413845
+ seeAlso: ['tcb app info', 'tcb app deploy'],
413846
+ docs: ['https://docs.cloudbase.net/cli/app/list']
413847
+ };
413848
+ }
413849
+ execute(envId, options, log) {
413850
+ return __awaiter(this, void 0, void 0, function* () {
413851
+ let selectedEnvId = envId;
413852
+ if (!selectedEnvId) {
413853
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
413854
+ }
413855
+ const limit = Math.max(1, Number(options.limit || 20));
413856
+ const offset = Number(options.offset || 0);
413857
+ const pageSize = limit;
413858
+ const pageNo = Math.floor(offset / limit) + 1;
413859
+ const loading = (0, utils_1.loadingFactory)();
413860
+ loading.start((0, i18n_1.t)('数据加载中...'));
413861
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
413862
+ const data = yield app.cloudAppService.describeAppList({
413863
+ deployType: 'static-hosting',
413864
+ pageNo: pageNo,
413865
+ pageSize: pageSize
413866
+ });
413867
+ loading.stop();
413868
+ const serviceList = data.ServiceList || [];
413869
+ const total = data.Total || 0;
413870
+ const buildUrl = (domain, appPath) => {
413871
+ if (!domain)
413872
+ return undefined;
413873
+ const cleanDomain = domain.replace(/^https?:\/\//, '');
413874
+ const path = appPath && appPath !== '/' ? appPath : '';
413875
+ return `https://${cleanDomain}${path}`;
413876
+ };
413877
+ if ((0, utils_1.isJsonOutput)()) {
413878
+ (0, utils_1.outputJson)(serviceList.map((item) => ({
413879
+ serviceName: item.ServiceName,
413880
+ appPath: item.AppPath,
413881
+ framework: item.Framework,
413882
+ domain: item.Domain,
413883
+ url: buildUrl(item.Domain, item.AppPath),
413884
+ latestStatus: item.LatestStatus,
413885
+ latestVersionName: item.LatestVersionName,
413886
+ createTime: item.CreateTime,
413887
+ latestBuildTime: item.LatestBuildTime
413888
+ })), { total, limit, offset });
413889
+ return;
413890
+ }
413891
+ if (serviceList.length === 0) {
413892
+ log.info((0, i18n_1.t)('暂无云应用'));
413893
+ log.info((0, i18n_1.t)('\n下一步:'));
413894
+ log.info((0, i18n_1.t)(' 部署应用 tcb app deploy --env-id {{envId}}', { envId: selectedEnvId }));
413895
+ return;
413896
+ }
413897
+ const head = [(0, i18n_1.t)('应用名称'), (0, i18n_1.t)('框架'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('访问地址'), (0, i18n_1.t)('最新版本'), (0, i18n_1.t)('更新时间')];
413898
+ const tableData = serviceList.map((item) => [
413899
+ item.ServiceName,
413900
+ item.Framework || '-',
413901
+ item.LatestStatus || '-',
413902
+ buildUrl(item.Domain, item.AppPath) ? (0, utils_1.genClickableLink)(buildUrl(item.Domain, item.AppPath)) : '-',
413903
+ item.LatestVersionName || '-',
413904
+ item.LatestBuildTime || '-'
413905
+ ]);
413906
+ (0, utils_1.printHorizontalTable)(head, tableData);
413907
+ log.info((0, i18n_1.t)('\n下一步:'));
413908
+ log.info((0, i18n_1.t)(' 查看详情 tcb app info <serviceName> --env-id {{envId}}', { envId: selectedEnvId }));
413909
+ log.info((0, i18n_1.t)(' 部署应用 tcb app deploy --env-id {{envId}}', { envId: selectedEnvId }));
413910
+ });
413911
+ }
413912
+ };
413913
+ __decorate([
413914
+ (0, decorators_1.InjectParams)(),
413915
+ __param(0, (0, decorators_1.EnvId)()),
413916
+ __param(1, (0, decorators_1.ArgsOptions)()),
413917
+ __param(2, (0, decorators_1.Log)()),
413918
+ __metadata("design:type", Function),
413919
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
413920
+ __metadata("design:returntype", Promise)
413921
+ ], AppList.prototype, "execute", null);
413922
+ AppList = __decorate([
413923
+ (0, common_1.ICommand)()
413924
+ ], AppList);
413925
+ exports.AppList = AppList;
413926
+
413927
+
411741
413928
  /***/ }),
411742
413929
 
411743
413930
  /***/ 20692:
@@ -496685,15 +498872,252 @@ exports.pack = __webpack_require__(30030)
496685
498872
  /***/ }),
496686
498873
 
496687
498874
  /***/ 32665:
496688
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
498875
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
496689
498876
 
496690
498877
  "use strict";
496691
498878
 
496692
-
496693
- var toInteger = __webpack_require__(49806)
496694
- , max = Math.max;
496695
-
496696
- module.exports = function (value) { return max(0, toInteger(value)); };
498879
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
498880
+ if (k2 === undefined) k2 = k;
498881
+ var desc = Object.getOwnPropertyDescriptor(m, k);
498882
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
498883
+ desc = { enumerable: true, get: function() { return m[k]; } };
498884
+ }
498885
+ Object.defineProperty(o, k2, desc);
498886
+ }) : (function(o, m, k, k2) {
498887
+ if (k2 === undefined) k2 = k;
498888
+ o[k2] = m[k];
498889
+ }));
498890
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
498891
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
498892
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
498893
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
498894
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
498895
+ };
498896
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
498897
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
498898
+ };
498899
+ var __importDefault = (this && this.__importDefault) || function (mod) {
498900
+ return (mod && mod.__esModule) ? mod : { "default": mod };
498901
+ };
498902
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
498903
+ exports.CloudAppService = void 0;
498904
+ const fs_1 = __importDefault(__webpack_require__(79896));
498905
+ const os_1 = __importDefault(__webpack_require__(70857));
498906
+ const path_1 = __importDefault(__webpack_require__(16928));
498907
+ const error_1 = __webpack_require__(40430);
498908
+ const utils_1 = __webpack_require__(62358);
498909
+ const http_request_1 = __webpack_require__(72088);
498910
+ __exportStar(__webpack_require__(35656), exports);
498911
+ /**
498912
+ * CloudApp 统一部署服务
498913
+ * 提供 Web 应用的创建、查询、删除、版本管理等功能
498914
+ */
498915
+ class CloudAppService {
498916
+ constructor(environment) {
498917
+ this.environment = environment;
498918
+ this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
498919
+ }
498920
+ // =========== 应用管理 API ===========
498921
+ /**
498922
+ * 创建/更新 CloudApp 应用
498923
+ * @param params 创建参数
498924
+ */
498925
+ async createApp(params) {
498926
+ const { envId } = this.getEnvInfo();
498927
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498928
+ return this.tcbService.request('CreateCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498929
+ }
498930
+ /**
498931
+ * 获取 CloudApp 应用列表
498932
+ * @param params 查询参数
498933
+ */
498934
+ async describeAppList(params) {
498935
+ const { envId } = this.getEnvInfo();
498936
+ return this.tcbService.request('DescribeCloudAppList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498937
+ }
498938
+ /**
498939
+ * 获取 CloudApp 应用详情
498940
+ * @param params 查询参数
498941
+ */
498942
+ async describeAppInfo(params) {
498943
+ const { envId } = this.getEnvInfo();
498944
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498945
+ return this.tcbService.request('DescribeCloudAppInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498946
+ }
498947
+ /**
498948
+ * 删除 CloudApp 应用
498949
+ * @param params 删除参数
498950
+ */
498951
+ async deleteApp(params) {
498952
+ const { envId } = this.getEnvInfo();
498953
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498954
+ return this.tcbService.request('DeleteCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498955
+ }
498956
+ // =========== 版本管理 API ===========
498957
+ /**
498958
+ * 获取 CloudApp 版本详情
498959
+ * 不指定 versionName 或 buildId 时返回最新版本
498960
+ * @param params 查询参数
498961
+ */
498962
+ async describeAppVersion(params) {
498963
+ const { envId } = this.getEnvInfo();
498964
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498965
+ return this.tcbService.request('DescribeCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498966
+ }
498967
+ /**
498968
+ * 获取 CloudApp 版本列表
498969
+ * @param params 查询参数
498970
+ */
498971
+ async describeAppVersionList(params) {
498972
+ const { envId } = this.getEnvInfo();
498973
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498974
+ return this.tcbService.request('DescribeCloudAppVersionList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498975
+ }
498976
+ /**
498977
+ * 删除 CloudApp 版本
498978
+ * @param params 删除参数
498979
+ */
498980
+ async deleteAppVersion(params) {
498981
+ const { envId } = this.getEnvInfo();
498982
+ this.validateRequiredParams(params, ['serviceName', 'deployType', 'versionName']);
498983
+ return this.tcbService.request('DeleteCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
498984
+ }
498985
+ // =========== COS 上传相关 API ===========
498986
+ /**
498987
+ * 获取 CloudApp COS 上传信息(预签名 URL)
498988
+ * @param params 查询参数
498989
+ */
498990
+ async describeCosInfo(params) {
498991
+ const { envId } = this.getEnvInfo();
498992
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
498993
+ return this.tcbService.request('DescribeCloudAppCosInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId, suffix: params.suffix || '.zip' })));
498994
+ }
498995
+ // =========== 辅助方法 ===========
498996
+ /**
498997
+ * 上传本地代码到 COS
498998
+ * 自动打包 ZIP 并上传到预签名 URL
498999
+ *
499000
+ * 注意:此方法不依赖应用是否已创建,可在创建应用前调用
499001
+ * 返回的 cosTimestamp 用于 createApp 时传入 staticConfig.cosTimestamp
499002
+ *
499003
+ * @param params 上传参数
499004
+ */
499005
+ async uploadCode(params) {
499006
+ const { serviceName, localPath, ignore = [] } = params;
499007
+ // 1. 验证本地路径
499008
+ if (!fs_1.default.existsSync(localPath)) {
499009
+ throw new error_1.CloudBaseError(`本地路径不存在: ${localPath}`);
499010
+ }
499011
+ const stat = fs_1.default.statSync(localPath);
499012
+ if (!stat.isDirectory()) {
499013
+ throw new error_1.CloudBaseError(`localPath 必须是目录: ${localPath}`);
499014
+ }
499015
+ // 2. 打包本地文件为 ZIP
499016
+ const tmpZipPath = path_1.default.join(os_1.default.tmpdir(), `cloudapp-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`);
499017
+ const defaultIgnore = ['node_modules/**', '.git/**', '.DS_Store', '**/.DS_Store'];
499018
+ await (0, utils_1.compressToZip)({
499019
+ dirPath: localPath,
499020
+ outputPath: tmpZipPath,
499021
+ ignore: [...defaultIgnore, ...ignore]
499022
+ });
499023
+ try {
499024
+ // 3. 获取上传凭证
499025
+ const cosInfo = await this.describeCosInfo({
499026
+ deployType: params.deployType,
499027
+ serviceName,
499028
+ suffix: '.zip'
499029
+ });
499030
+ // 4. 读取 ZIP 文件
499031
+ const zipBuffer = fs_1.default.readFileSync(tmpZipPath);
499032
+ // 5. 构建请求头
499033
+ const headers = {
499034
+ 'Content-Type': 'application/zip'
499035
+ };
499036
+ if (cosInfo.UploadHeaders && cosInfo.UploadHeaders.length > 0) {
499037
+ for (const h of cosInfo.UploadHeaders) {
499038
+ headers[h.Key] = h.Value;
499039
+ }
499040
+ }
499041
+ // 6. 使用预签名 URL 上传
499042
+ const response = await (0, http_request_1.fetchStream)(cosInfo.UploadUrl, {
499043
+ method: 'PUT',
499044
+ body: zipBuffer,
499045
+ headers
499046
+ });
499047
+ if (!response.ok) {
499048
+ let errorDetail = '';
499049
+ try {
499050
+ const responseText = await response.text();
499051
+ errorDetail = responseText ? ` - ${responseText.substring(0, 500)}` : '';
499052
+ }
499053
+ catch (_a) {
499054
+ // 解析失败时 errorDetail 保持空串,不影响主错误抛出
499055
+ }
499056
+ throw new error_1.CloudBaseError(`上传失败: ${response.status} ${response.statusText}${errorDetail}`);
499057
+ }
499058
+ // 7. 返回结果(返回 cosTimestamp,用于创建应用)
499059
+ return {
499060
+ cosTimestamp: cosInfo.UnixTimestamp,
499061
+ unixTimestamp: cosInfo.UnixTimestamp
499062
+ };
499063
+ }
499064
+ finally {
499065
+ // 8. 清理临时文件
499066
+ if (fs_1.default.existsSync(tmpZipPath)) {
499067
+ fs_1.default.unlinkSync(tmpZipPath);
499068
+ }
499069
+ }
499070
+ }
499071
+ /**
499072
+ * 获取环境信息
499073
+ */
499074
+ getEnvInfo() {
499075
+ const envConfig = this.environment.lazyEnvironmentConfig;
499076
+ return {
499077
+ envId: envConfig.EnvId
499078
+ };
499079
+ }
499080
+ /**
499081
+ * 校验必填参数
499082
+ * @param params 参数对象
499083
+ * @param fields 必填字段列表
499084
+ */
499085
+ validateRequiredParams(params, fields) {
499086
+ for (const field of fields) {
499087
+ if (!params[field]) {
499088
+ throw new error_1.CloudBaseError(`${field} 是必填参数`);
499089
+ }
499090
+ }
499091
+ }
499092
+ }
499093
+ exports.CloudAppService = CloudAppService;
499094
+ __decorate([
499095
+ (0, utils_1.preLazy)()
499096
+ ], CloudAppService.prototype, "createApp", null);
499097
+ __decorate([
499098
+ (0, utils_1.preLazy)()
499099
+ ], CloudAppService.prototype, "describeAppList", null);
499100
+ __decorate([
499101
+ (0, utils_1.preLazy)()
499102
+ ], CloudAppService.prototype, "describeAppInfo", null);
499103
+ __decorate([
499104
+ (0, utils_1.preLazy)()
499105
+ ], CloudAppService.prototype, "deleteApp", null);
499106
+ __decorate([
499107
+ (0, utils_1.preLazy)()
499108
+ ], CloudAppService.prototype, "describeAppVersion", null);
499109
+ __decorate([
499110
+ (0, utils_1.preLazy)()
499111
+ ], CloudAppService.prototype, "describeAppVersionList", null);
499112
+ __decorate([
499113
+ (0, utils_1.preLazy)()
499114
+ ], CloudAppService.prototype, "deleteAppVersion", null);
499115
+ __decorate([
499116
+ (0, utils_1.preLazy)()
499117
+ ], CloudAppService.prototype, "describeCosInfo", null);
499118
+ __decorate([
499119
+ (0, utils_1.preLazy)()
499120
+ ], CloudAppService.prototype, "uploadCode", null);
496697
499121
 
496698
499122
 
496699
499123
  /***/ }),
@@ -510139,6 +512563,24 @@ const imageCommonOptions = (sub) => ({
510139
512563
  exports.imageCommonOptions = imageCommonOptions;
510140
512564
 
510141
512565
 
512566
+ /***/ }),
512567
+
512568
+ /***/ 35656:
512569
+ /***/ ((__unused_webpack_module, exports) => {
512570
+
512571
+ "use strict";
512572
+
512573
+ /**
512574
+ * CloudApp 统一部署服务类型定义
512575
+ * 支持 static-hosting(静态托管)和 http-function(预留)两种部署类型
512576
+ *
512577
+ * 命名规范:
512578
+ * - 入参接口(IXxxParams):camelCase,通过 upperCaseObjKey 转换后透传给 API
512579
+ * - 返回值接口(IXxxResult):PascalCase,与 API 响应字段保持一致
512580
+ */
512581
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
512582
+
512583
+
510142
512584
  /***/ }),
510143
512585
 
510144
512586
  /***/ 35674:
@@ -541317,8 +543759,10 @@ const path_1 = __importDefault(__webpack_require__(16928));
541317
543759
  const log_symbols_1 = __importDefault(__webpack_require__(68329));
541318
543760
  const common_1 = __webpack_require__(48431);
541319
543761
  const hosting_1 = __webpack_require__(2767);
543762
+ const utils_1 = __webpack_require__(75213);
543763
+ const constant_1 = __webpack_require__(62977);
541320
543764
  const error_1 = __webpack_require__(66759);
541321
- const utils_1 = __webpack_require__(82079);
543765
+ const utils_2 = __webpack_require__(82079);
541322
543766
  const decorators_1 = __webpack_require__(93480);
541323
543767
  const i18n_1 = __webpack_require__(69258);
541324
543768
  const interactive_1 = __webpack_require__(57695);
@@ -541333,46 +543777,167 @@ const HostingStatusMap = {
541333
543777
  };
541334
543778
  function getHostingService(envId) {
541335
543779
  return __awaiter(this, void 0, void 0, function* () {
541336
- const { hosting } = yield (0, utils_1.getMangerService)(envId);
543780
+ const { hosting } = yield (0, utils_2.getMangerService)(envId);
541337
543781
  return hosting;
541338
543782
  });
541339
543783
  }
543784
+ function getDetailConfig(hostingService, cdnDomain) {
543785
+ var _a, _b;
543786
+ return __awaiter(this, void 0, void 0, function* () {
543787
+ try {
543788
+ const [webConfigRes, checkRes] = yield Promise.all([
543789
+ hostingService.getWebsiteConfig().catch(() => null),
543790
+ hostingService.tcbCheckResource({ domains: [cdnDomain] }).catch(() => null)
543791
+ ]);
543792
+ return {
543793
+ websiteConfig: webConfigRes,
543794
+ domainConfig: (_b = (_a = checkRes === null || checkRes === void 0 ? void 0 : checkRes.Domains) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.DomainConfig
543795
+ };
543796
+ }
543797
+ catch (_c) {
543798
+ return { websiteConfig: null, domainConfig: null };
543799
+ }
543800
+ });
543801
+ }
543802
+ function outputWebsiteConfig(websiteConfig, log) {
543803
+ var _a, _b;
543804
+ log.info('');
543805
+ log.info((0, i18n_1.t)('=== 索引文档配置 ==='));
543806
+ const indexDoc = ((_a = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.IndexDocument) === null || _a === void 0 ? void 0 : _a.Suffix) || 'index.html';
543807
+ const errorDoc = ((_b = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.ErrorDocument) === null || _b === void 0 ? void 0 : _b.Key) || '-';
543808
+ log.info((0, i18n_1.t)('默认索引文档:{{doc}}', { doc: indexDoc }));
543809
+ log.info((0, i18n_1.t)('错误文档:{{doc}}', { doc: errorDoc }));
543810
+ }
543811
+ function outputSecurityConfig(domainConfig, log) {
543812
+ var _a, _b;
543813
+ log.info('');
543814
+ log.info((0, i18n_1.t)('=== 安全配置 ==='));
543815
+ const referer = domainConfig.Refer;
543816
+ if ((referer === null || referer === void 0 ? void 0 : referer.Switch) === 'on') {
543817
+ log.info((0, i18n_1.t)('防盗链:已开启'));
543818
+ (_a = referer.RefererRules) === null || _a === void 0 ? void 0 : _a.forEach((rule, index) => {
543819
+ var _a;
543820
+ const type = rule.RefererType === 'whitelist' ? (0, i18n_1.t)('白名单') : (0, i18n_1.t)('黑名单');
543821
+ const allowEmpty = rule.AllowEmpty ? (0, i18n_1.t)('允许') : (0, i18n_1.t)('不允许');
543822
+ log.info((0, i18n_1.t)(' 规则{{index}}:{{type}},{{count}} 条,{{allowEmpty}}空 Referer', {
543823
+ index: index + 1,
543824
+ type,
543825
+ count: ((_a = rule.Referers) === null || _a === void 0 ? void 0 : _a.length) || 0,
543826
+ allowEmpty
543827
+ }));
543828
+ });
543829
+ }
543830
+ else {
543831
+ log.info((0, i18n_1.t)('防盗链:未开启'));
543832
+ }
543833
+ const ipFilter = domainConfig.IpFilter;
543834
+ if ((ipFilter === null || ipFilter === void 0 ? void 0 : ipFilter.Switch) === 'on') {
543835
+ const type = ipFilter.FilterType === 'whitelist' ? (0, i18n_1.t)('白名单') : (0, i18n_1.t)('黑名单');
543836
+ log.info((0, i18n_1.t)('IP {{type}}:已开启,{{count}} 条', { type, count: ((_b = ipFilter.Filters) === null || _b === void 0 ? void 0 : _b.length) || 0 }));
543837
+ }
543838
+ else {
543839
+ log.info((0, i18n_1.t)('IP 黑白名单:未开启'));
543840
+ }
543841
+ const ipFreqLimit = domainConfig.IpFreqLimit;
543842
+ if ((ipFreqLimit === null || ipFreqLimit === void 0 ? void 0 : ipFreqLimit.Switch) === 'on') {
543843
+ log.info((0, i18n_1.t)('IP 访问限频:已开启,{{qps}} QPS', { qps: ipFreqLimit.Qps }));
543844
+ }
543845
+ else {
543846
+ log.info((0, i18n_1.t)('IP 访问限频:未开启'));
543847
+ }
543848
+ }
541340
543849
  let HostingDetail = class HostingDetail extends common_1.Command {
541341
543850
  get options() {
541342
543851
  return {
541343
543852
  cmd: 'hosting',
541344
543853
  childCmd: 'detail',
541345
543854
  deprecateCmd: 'hosting:detail',
541346
- options: [],
541347
- desc: (0, i18n_1.t)('查看静态网站服务信息')
543855
+ options: [
543856
+ {
543857
+ flags: '-e, --env-id <envId>',
543858
+ desc: (0, i18n_1.t)('环境 ID'),
543859
+ deprecatedName: 'envId'
543860
+ }
543861
+ ],
543862
+ requiredEnvId: false,
543863
+ autoRunLogin: true,
543864
+ desc: (0, i18n_1.t)('查看静态网站服务信息'),
543865
+ examples: [
543866
+ 'tcb hosting detail',
543867
+ 'tcb hosting detail --env-id env-xxx',
543868
+ 'tcb hosting detail --json'
543869
+ ],
543870
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541348
543871
  };
541349
543872
  }
541350
543873
  execute(envId, log) {
541351
- var _a;
543874
+ var _a, _b, _c;
541352
543875
  return __awaiter(this, void 0, void 0, function* () {
541353
- const res = yield (0, hosting_1.getHostingInfo)({ envId });
543876
+ let selectedEnvId = envId;
543877
+ if (!selectedEnvId) {
543878
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
543879
+ }
543880
+ const res = yield (0, hosting_1.getHostingInfo)({ envId: selectedEnvId });
541354
543881
  const website = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a[0];
541355
543882
  if (!website) {
541356
- if ((0, utils_1.isJsonOutput)()) {
541357
- (0, utils_1.outputJson)({ error: { message: '静态网站服务未开通' } });
543883
+ if ((0, utils_2.isJsonOutput)()) {
543884
+ (0, utils_2.outputJson)({ error: { message: '静态网站服务未开通' } });
541358
543885
  return;
541359
543886
  }
541360
- yield (0, hosting_1.initHosting)({ envId });
543887
+ yield (0, hosting_1.initHosting)({ envId: selectedEnvId });
541361
543888
  return;
541362
543889
  }
541363
- if ((0, utils_1.isJsonOutput)()) {
541364
- (0, utils_1.outputJson)({
541365
- cdnDomain: website.cdnDomain,
541366
- status: website.status,
541367
- statusText: HostingStatusMap[website.status]
543890
+ const cdnDomain = website.cdnDomain;
543891
+ const bucket = website.bucket;
543892
+ const status = website.status;
543893
+ let detailConfig = { websiteConfig: null, domainConfig: null };
543894
+ if (status === 'online' && cdnDomain) {
543895
+ const hostingService = yield getHostingService(selectedEnvId);
543896
+ detailConfig = yield getDetailConfig(hostingService, cdnDomain);
543897
+ }
543898
+ const { websiteConfig, domainConfig } = detailConfig;
543899
+ if ((0, utils_2.isJsonOutput)()) {
543900
+ (0, utils_2.outputJson)({
543901
+ cdnDomain,
543902
+ bucket,
543903
+ status,
543904
+ statusText: HostingStatusMap[status],
543905
+ indexDocument: ((_b = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.IndexDocument) === null || _b === void 0 ? void 0 : _b.Suffix) || 'index.html',
543906
+ errorDocument: ((_c = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.ErrorDocument) === null || _c === void 0 ? void 0 : _c.Key) || '',
543907
+ security: {
543908
+ referer: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.Refer) || null,
543909
+ ipFilter: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.IpFilter) || null,
543910
+ ipFreqLimit: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.IpFreqLimit) || null
543911
+ }
541368
543912
  });
541369
543913
  return;
541370
543914
  }
541371
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
541372
- if (website.status !== 'offline') {
541373
- log.info((0, i18n_1.t)('静态网站域名:{{link}}', { link }));
543915
+ log.info((0, i18n_1.t)('=== 静态网站服务信息 ==='));
543916
+ log.info('');
543917
+ if (status !== 'offline') {
543918
+ const link = (0, utils_2.genClickableLink)(`https://${cdnDomain}`);
543919
+ log.info((0, i18n_1.t)('域名:{{link}}', { link }));
543920
+ }
543921
+ log.info((0, i18n_1.t)('状态:【{{status}}】', { status: HostingStatusMap[status] }));
543922
+ log.info((0, i18n_1.t)('存储桶:{{bucket}}', { bucket }));
543923
+ if (websiteConfig) {
543924
+ outputWebsiteConfig(websiteConfig, log);
543925
+ }
543926
+ if (domainConfig) {
543927
+ outputSecurityConfig(domainConfig, log);
543928
+ }
543929
+ if (status === 'online') {
543930
+ log.info('');
543931
+ log.info((0, i18n_1.t)('💡 下一步:'));
543932
+ log.info((0, i18n_1.t)(' • 部署文件: tcb hosting deploy ./dist'));
543933
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
543934
+ log.info((0, i18n_1.t)(' • 访问网站: https://{{cdnDomain}}', { cdnDomain }));
543935
+ }
543936
+ else if (status === 'offline') {
543937
+ log.info('');
543938
+ log.info((0, i18n_1.t)('💡 下一步:'));
543939
+ log.info((0, i18n_1.t)(' • 开通服务: tcb hosting init'));
541374
543940
  }
541375
- log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
541376
543941
  });
541377
543942
  }
541378
543943
  };
@@ -541394,7 +543959,15 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541394
543959
  cmd: 'hosting',
541395
543960
  childCmd: 'deploy [filePath] [cloudPath]',
541396
543961
  deprecateCmd: 'hosting:deploy [filePath] [cloudPath]',
541397
- options: [],
543962
+ options: [
543963
+ {
543964
+ flags: '-e, --env-id <envId>',
543965
+ desc: (0, i18n_1.t)('环境 ID'),
543966
+ deprecatedName: 'envId'
543967
+ }
543968
+ ],
543969
+ requiredEnvId: false,
543970
+ autoRunLogin: true,
541398
543971
  desc: (0, i18n_1.t)('部署静态网站文件'),
541399
543972
  examples: ['tcb hosting deploy .', 'tcb hosting deploy ./dist'],
541400
543973
  seeAlso: ['tcb hosting list'],
@@ -541404,21 +543977,25 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541404
543977
  execute(envId, params, log) {
541405
543978
  var _a;
541406
543979
  return __awaiter(this, void 0, void 0, function* () {
543980
+ let selectedEnvId = envId;
543981
+ if (!selectedEnvId) {
543982
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
543983
+ }
541407
543984
  const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
541408
543985
  const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
541409
543986
  log.verbose((0, i18n_1.t)('本地目录'), localPath);
541410
543987
  const resolveLocalPath = path_1.default.resolve(localPath);
541411
- (0, utils_1.checkFullAccess)(resolveLocalPath, true);
541412
- const isDir = (0, utils_1.isDirectory)(resolveLocalPath);
541413
- const loading = (0, utils_1.loadingFactory)();
543988
+ (0, utils_2.checkFullAccess)(resolveLocalPath, true);
543989
+ const isDir = (0, utils_2.isDirectory)(resolveLocalPath);
543990
+ const loading = (0, utils_2.loadingFactory)();
541414
543991
  loading.start((0, i18n_1.t)('准备上传中...'));
541415
543992
  let totalFiles = 0;
541416
543993
  if (isDir) {
541417
- let files = yield (0, hosting_1.walkLocalDir)(envId, resolveLocalPath);
541418
- files = files.filter((item) => !(0, utils_1.isDirectory)(item));
543994
+ let files = yield (0, hosting_1.walkLocalDir)(selectedEnvId, resolveLocalPath);
543995
+ files = files.filter((item) => !(0, utils_2.isDirectory)(item));
541419
543996
  totalFiles = files.length;
541420
543997
  }
541421
- const onProgress = (0, utils_1.createUploadProgressBar)(() => {
543998
+ const onProgress = (0, utils_2.createUploadProgressBar)(() => {
541422
543999
  !isDir && log.success((0, i18n_1.t)('文件部署成功!'));
541423
544000
  }, () => {
541424
544001
  loading.stop();
@@ -541428,7 +544005,7 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541428
544005
  yield (0, hosting_1.hostingDeploy)({
541429
544006
  filePath: resolveLocalPath,
541430
544007
  cloudPath,
541431
- envId,
544008
+ envId: selectedEnvId,
541432
544009
  isDir,
541433
544010
  onProgress,
541434
544011
  onFileFinish: (...args) => {
@@ -541443,12 +544020,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541443
544020
  }
541444
544021
  });
541445
544022
  const info = yield (0, hosting_1.getHostingInfo)({
541446
- envId
544023
+ envId: selectedEnvId
541447
544024
  });
541448
544025
  const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
541449
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
541450
- if ((0, utils_1.isJsonOutput)()) {
541451
- (0, utils_1.outputJson)({
544026
+ const link = (0, utils_2.genClickableLink)(`https://${website.cdnDomain}`);
544027
+ if ((0, utils_2.isJsonOutput)()) {
544028
+ (0, utils_2.outputJson)({
541452
544029
  message: '部署完成',
541453
544030
  url: `https://${website.cdnDomain}`,
541454
544031
  totalFiles: isDir ? totalFiles : 1,
@@ -541462,12 +544039,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541462
544039
  log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
541463
544040
  log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
541464
544041
  if (totalFiles <= 50) {
541465
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
544042
+ (0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
541466
544043
  }
541467
544044
  log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
541468
544045
  if (failedFiles.length) {
541469
544046
  if (totalFiles <= 50) {
541470
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
544047
+ (0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
541471
544048
  }
541472
544049
  else {
541473
544050
  const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
@@ -541475,9 +544052,23 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541475
544052
  console.log(errorLogPath);
541476
544053
  fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
541477
544054
  }
541478
- throw new error_1.CloudBaseError((0, i18n_1.t)('部分文件上传失败,进程退出'));
544055
+ throw new error_1.CloudBaseError({
544056
+ message: (0, i18n_1.t)('部分文件上传失败,进程退出'),
544057
+ code: 'DEPLOY_PARTIAL_FAILED',
544058
+ solution: [
544059
+ '检查网络连接是否稳定',
544060
+ '查看失败文件列表并手动重试',
544061
+ '运行 tcb hosting list 确认已上传文件'
544062
+ ]
544063
+ });
541479
544064
  }
541480
544065
  }
544066
+ if (failedFiles.length === 0) {
544067
+ log.info('');
544068
+ log.info((0, i18n_1.t)('💡 下一步:'));
544069
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
544070
+ log.info((0, i18n_1.t)(' • 访问网站: https://{{cdnDomain}}', { cdnDomain: website.cdnDomain }));
544071
+ }
541481
544072
  });
541482
544073
  }
541483
544074
  };
@@ -541500,46 +544091,144 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
541500
544091
  cmd: 'hosting',
541501
544092
  childCmd: 'delete [cloudPath]',
541502
544093
  deprecateCmd: 'hosting:delete [cloudPath]',
541503
- options: [{
544094
+ options: [
544095
+ {
544096
+ flags: '-e, --env-id <envId>',
544097
+ desc: (0, i18n_1.t)('环境 ID'),
544098
+ deprecatedName: 'envId'
544099
+ },
544100
+ {
541504
544101
  flags: '-d, --dir',
541505
544102
  desc: (0, i18n_1.t)('删除目标是否为文件夹')
544103
+ },
544104
+ {
544105
+ flags: '--dry-run',
544106
+ desc: (0, i18n_1.t)('预览要删除的文件,不实际执行删除')
541506
544107
  }
541507
544108
  ],
541508
- desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项')
544109
+ requiredEnvId: false,
544110
+ autoRunLogin: true,
544111
+ desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项'),
544112
+ examples: [
544113
+ 'tcb hosting delete path/to/file',
544114
+ 'tcb hosting delete path/to/dir --dir',
544115
+ 'tcb hosting delete --dry-run --env-id env-xxx',
544116
+ 'tcb hosting delete --env-id env-xxx --yes'
544117
+ ],
544118
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541509
544119
  };
541510
544120
  }
541511
- execute(envId, options, params) {
544121
+ execute(envId, options, params, log) {
541512
544122
  return __awaiter(this, void 0, void 0, function* () {
544123
+ let selectedEnvId = envId;
544124
+ if (!selectedEnvId) {
544125
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
544126
+ }
541513
544127
  const cloudPath = (params === null || params === void 0 ? void 0 : params[0]) || '';
541514
544128
  let isDir = options.dir;
544129
+ const isDryRun = options.dryRun;
544130
+ if (cloudPath === '/') {
544131
+ isDir = true;
544132
+ }
544133
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
544134
+ if (isDryRun) {
544135
+ const loading = (0, utils_2.loadingFactory)();
544136
+ loading.start((0, i18n_1.t)('预览要删除的文件...'));
544137
+ try {
544138
+ const list = yield (0, hosting_1.hostingList)({
544139
+ envId: selectedEnvId
544140
+ });
544141
+ const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
544142
+ const targetFiles = list.filter(notDir).filter((item) => {
544143
+ if (!cloudPath)
544144
+ return true;
544145
+ if (isDir) {
544146
+ return item.Key.startsWith(cloudPath.replace(/\/$/, '') + '/');
544147
+ }
544148
+ return item.Key === cloudPath || item.Key.startsWith(cloudPath + '/');
544149
+ });
544150
+ loading.stop();
544151
+ if ((0, utils_2.isJsonOutput)()) {
544152
+ (0, utils_2.outputJson)(targetFiles.map((item) => ({
544153
+ key: item.Key,
544154
+ size: item.Size,
544155
+ lastModified: item.LastModified
544156
+ })), { total: targetFiles.length, action: 'delete', dryRun: true });
544157
+ return;
544158
+ }
544159
+ if (targetFiles.length === 0) {
544160
+ log.warn((0, i18n_1.t)('没有找到匹配的文件'));
544161
+ return;
544162
+ }
544163
+ log.info((0, i18n_1.t)('将删除以下 {{count}} 个文件:', { count: targetFiles.length }));
544164
+ log.info('');
544165
+ const head = [(0, i18n_1.t)('Key'), (0, i18n_1.t)('Size'), (0, i18n_1.t)('LastModified')];
544166
+ const tableData = targetFiles.map((item) => [
544167
+ item.Key,
544168
+ (0, utils_2.formateFileSize)(item.Size, 'KB'),
544169
+ (0, utils_2.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss')
544170
+ ]);
544171
+ (0, utils_2.printHorizontalTable)(head, tableData);
544172
+ log.info('');
544173
+ log.info((0, i18n_1.t)('💡 运行 tcb hosting delete {{cloudPath}} --yes 执行删除', { cloudPath }));
544174
+ }
544175
+ catch (e) {
544176
+ loading.fail((0, i18n_1.t)('预览失败'));
544177
+ throw new error_1.CloudBaseError({
544178
+ message: e.message,
544179
+ code: 'DRY_RUN_FAILED',
544180
+ original: e,
544181
+ solution: [
544182
+ '检查环境 ID 是否正确',
544183
+ '检查静态托管服务是否已开通'
544184
+ ]
544185
+ });
544186
+ }
544187
+ return;
544188
+ }
541515
544189
  if (!cloudPath) {
541516
544190
  const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'), false);
541517
544191
  if (!confirm) {
541518
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
544192
+ throw new error_1.CloudBaseError({
544193
+ message: (0, i18n_1.t)('操作终止!'),
544194
+ code: 'OPERATION_CANCELLED',
544195
+ solution: ['指定要删除的云端路径,如: tcb hosting delete path/to/file']
544196
+ });
541519
544197
  }
541520
544198
  isDir = true;
541521
544199
  }
541522
- if (cloudPath === '/') {
541523
- isDir = true;
544200
+ const loading = (0, utils_2.loadingFactory)();
544201
+ if (!(0, utils_2.isJsonOutput)()) {
544202
+ loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
541524
544203
  }
541525
- const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
541526
- const loading = (0, utils_1.loadingFactory)();
541527
- loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
541528
544204
  try {
541529
544205
  yield (0, hosting_1.hostingDelete)({
541530
- envId,
544206
+ envId: selectedEnvId,
541531
544207
  isDir,
541532
544208
  cloudPath
541533
544209
  });
541534
544210
  loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
541535
- if ((0, utils_1.isJsonOutput)()) {
541536
- (0, utils_1.outputJson)({ message: `删除${fileText}成功` });
544211
+ if ((0, utils_2.isJsonOutput)()) {
544212
+ (0, utils_2.outputJson)({ message: `删除${fileText}成功` });
541537
544213
  return;
541538
544214
  }
544215
+ log.info('');
544216
+ log.info((0, i18n_1.t)('💡 下一步:'));
544217
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
544218
+ log.info((0, i18n_1.t)(' • 重新部署: tcb hosting deploy'));
541539
544219
  }
541540
544220
  catch (e) {
541541
544221
  loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
541542
- throw new error_1.CloudBaseError(e.message);
544222
+ throw new error_1.CloudBaseError({
544223
+ message: e.message,
544224
+ code: 'DELETE_FILE_FAILED',
544225
+ original: e,
544226
+ solution: [
544227
+ '检查环境 ID 是否正确',
544228
+ '检查网络连接是否正常',
544229
+ '确认文件/文件夹是否存在'
544230
+ ]
544231
+ });
541543
544232
  }
541544
544233
  });
541545
544234
  }
@@ -541549,8 +544238,9 @@ __decorate([
541549
544238
  __param(0, (0, decorators_1.EnvId)()),
541550
544239
  __param(1, (0, decorators_1.ArgsOptions)()),
541551
544240
  __param(2, (0, decorators_1.ArgsParams)()),
544241
+ __param(3, (0, decorators_1.Log)()),
541552
544242
  __metadata("design:type", Function),
541553
- __metadata("design:paramtypes", [Object, Object, Object]),
544243
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
541554
544244
  __metadata("design:returntype", Promise)
541555
544245
  ], HostingDeleteFiles.prototype, "execute", null);
541556
544246
  HostingDeleteFiles = __decorate([
@@ -541563,47 +544253,97 @@ let HostingList = class HostingList extends common_1.Command {
541563
544253
  cmd: 'hosting',
541564
544254
  childCmd: 'list',
541565
544255
  deprecateCmd: 'hosting:list',
541566
- options: [],
544256
+ options: [
544257
+ {
544258
+ flags: '-e, --env-id <envId>',
544259
+ desc: (0, i18n_1.t)('环境 ID'),
544260
+ deprecatedName: 'envId'
544261
+ },
544262
+ {
544263
+ flags: '-l, --limit <n>',
544264
+ desc: (0, i18n_1.t)('返回条数上限'),
544265
+ default: 50
544266
+ },
544267
+ {
544268
+ flags: '--offset <n>',
544269
+ desc: (0, i18n_1.t)('跳过条数'),
544270
+ default: 0
544271
+ }
544272
+ ],
544273
+ requiredEnvId: false,
544274
+ autoRunLogin: true,
541567
544275
  desc: (0, i18n_1.t)('展示文件列表'),
541568
- examples: ['tcb hosting list'],
544276
+ examples: [
544277
+ 'tcb hosting list',
544278
+ 'tcb hosting list --limit 10',
544279
+ 'tcb hosting list --json'
544280
+ ],
541569
544281
  seeAlso: ['tcb hosting deploy'],
541570
544282
  docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541571
544283
  };
541572
544284
  }
541573
- execute(envId) {
544285
+ execute(envId, options, log) {
541574
544286
  return __awaiter(this, void 0, void 0, function* () {
541575
- const loading = (0, utils_1.loadingFactory)();
544287
+ let selectedEnvId = envId;
544288
+ if (!selectedEnvId) {
544289
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
544290
+ }
544291
+ const limit = Number(options.limit) || 50;
544292
+ const offset = Number(options.offset) || 0;
544293
+ const loading = (0, utils_2.loadingFactory)();
541576
544294
  loading.start((0, i18n_1.t)('获取文件列表中...'));
541577
544295
  try {
541578
544296
  const list = yield (0, hosting_1.hostingList)({
541579
- envId
544297
+ envId: selectedEnvId
541580
544298
  });
541581
544299
  loading.stop();
541582
544300
  const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
541583
- if ((0, utils_1.isJsonOutput)()) {
541584
- (0, utils_1.outputJson)(list.filter(notDir).map((item) => ({
544301
+ const allFiles = list.filter(notDir);
544302
+ const total = allFiles.length;
544303
+ const paginatedFiles = allFiles.slice(offset, offset + limit);
544304
+ if ((0, utils_2.isJsonOutput)()) {
544305
+ (0, utils_2.outputJson)(paginatedFiles.map((item) => ({
541585
544306
  key: item.Key,
541586
544307
  lastModified: item.LastModified,
541587
544308
  eTag: item.ETag,
541588
544309
  size: item.Size
541589
- })));
544310
+ })), { total, limit, offset });
544311
+ return;
544312
+ }
544313
+ if (paginatedFiles.length === 0) {
544314
+ log.warn((0, i18n_1.t)('没有找到文件'));
541590
544315
  return;
541591
544316
  }
541592
544317
  const head = [(0, i18n_1.t)('序号'), (0, i18n_1.t)('Key'), (0, i18n_1.t)('LastModified'), (0, i18n_1.t)('ETag'), (0, i18n_1.t)('Size(KB)')];
541593
- const tableData = list
541594
- .filter(notDir)
541595
- .map((item, index) => [
541596
- index + 1,
544318
+ const tableData = paginatedFiles.map((item, index) => [
544319
+ offset + index + 1,
541597
544320
  item.Key,
541598
- (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
544321
+ (0, utils_2.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
541599
544322
  item.ETag,
541600
- String((0, utils_1.formateFileSize)(item.Size, 'KB'))
544323
+ String((0, utils_2.formateFileSize)(item.Size, 'KB'))
541601
544324
  ]);
541602
- (0, utils_1.printHorizontalTable)(head, tableData);
544325
+ (0, utils_2.printHorizontalTable)(head, tableData);
544326
+ if (total > limit) {
544327
+ log.info('');
544328
+ log.info((0, i18n_1.t)('显示 {{count}}/{{total}} 条,使用 --offset {{next}} 查看更多', {
544329
+ count: paginatedFiles.length,
544330
+ total,
544331
+ next: offset + limit
544332
+ }));
544333
+ }
541603
544334
  }
541604
544335
  catch (e) {
541605
544336
  loading.fail((0, i18n_1.t)('获取文件列表失败!'));
541606
- throw new error_1.CloudBaseError(e.message);
544337
+ throw new error_1.CloudBaseError({
544338
+ message: e.message,
544339
+ code: 'LIST_FILE_FAILED',
544340
+ original: e,
544341
+ solution: [
544342
+ '检查环境 ID 是否正确',
544343
+ '检查静态托管服务是否已开通',
544344
+ '运行 tcb hosting detail 确认服务状态'
544345
+ ]
544346
+ });
541607
544347
  }
541608
544348
  });
541609
544349
  }
@@ -541611,8 +544351,10 @@ let HostingList = class HostingList extends common_1.Command {
541611
544351
  __decorate([
541612
544352
  (0, decorators_1.InjectParams)(),
541613
544353
  __param(0, (0, decorators_1.EnvId)()),
544354
+ __param(1, (0, decorators_1.ArgsOptions)()),
544355
+ __param(2, (0, decorators_1.Log)()),
541614
544356
  __metadata("design:type", Function),
541615
- __metadata("design:paramtypes", [Object]),
544357
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
541616
544358
  __metadata("design:returntype", Promise)
541617
544359
  ], HostingList.prototype, "execute", null);
541618
544360
  HostingList = __decorate([
@@ -541624,23 +544366,41 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
541624
544366
  return {
541625
544367
  cmd: 'hosting',
541626
544368
  childCmd: 'download <cloudPath> [localPath]',
541627
- options: [{
544369
+ options: [
544370
+ {
544371
+ flags: '-e, --env-id <envId>',
544372
+ desc: (0, i18n_1.t)('环境 ID'),
544373
+ deprecatedName: 'envId'
544374
+ },
544375
+ {
541628
544376
  flags: '-d, --dir',
541629
544377
  desc: (0, i18n_1.t)('下载目标是否为文件夹')
541630
544378
  }
541631
544379
  ],
541632
- desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
544380
+ requiredEnvId: false,
544381
+ autoRunLogin: true,
544382
+ desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项'),
544383
+ examples: [
544384
+ 'tcb hosting download path/to/file.txt',
544385
+ 'tcb hosting download path/to/dir ./local --dir',
544386
+ 'tcb hosting download path/to/file --env-id env-xxx'
544387
+ ],
544388
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541633
544389
  };
541634
544390
  }
541635
- execute(envId, options, params) {
544391
+ execute(envId, options, params, log) {
541636
544392
  return __awaiter(this, void 0, void 0, function* () {
544393
+ let selectedEnvId = envId;
544394
+ if (!selectedEnvId) {
544395
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
544396
+ }
541637
544397
  let cloudPath = params === null || params === void 0 ? void 0 : params[0];
541638
544398
  const localPath = (params === null || params === void 0 ? void 0 : params[1]) || '.';
541639
- const hostingService = yield getHostingService(envId);
544399
+ const hostingService = yield getHostingService(selectedEnvId);
541640
544400
  const resolveLocalPath = path_1.default.resolve(localPath);
541641
544401
  const { dir } = options;
541642
544402
  const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
541643
- const loading = (0, utils_1.loadingFactory)();
544403
+ const loading = (0, utils_2.loadingFactory)();
541644
544404
  loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
541645
544405
  if (/^\/.+/.test(cloudPath)) {
541646
544406
  cloudPath = cloudPath.slice(1);
@@ -541658,9 +544418,14 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
541658
544418
  });
541659
544419
  }
541660
544420
  loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
541661
- if ((0, utils_1.isJsonOutput)()) {
541662
- (0, utils_1.outputJson)({ message: `下载${fileText}成功` });
544421
+ if ((0, utils_2.isJsonOutput)()) {
544422
+ (0, utils_2.outputJson)({ message: `下载${fileText}成功`, localPath: resolveLocalPath });
544423
+ return;
541663
544424
  }
544425
+ log.info('');
544426
+ log.info((0, i18n_1.t)('💡 下一步:'));
544427
+ log.info((0, i18n_1.t)(' • 查看文件: ls {{path}}', { path: resolveLocalPath }));
544428
+ log.info((0, i18n_1.t)(' • 编辑后重新部署: tcb hosting deploy'));
541664
544429
  });
541665
544430
  }
541666
544431
  };
@@ -541669,8 +544434,9 @@ __decorate([
541669
544434
  __param(0, (0, decorators_1.EnvId)()),
541670
544435
  __param(1, (0, decorators_1.ArgsOptions)()),
541671
544436
  __param(2, (0, decorators_1.ArgsParams)()),
544437
+ __param(3, (0, decorators_1.Log)()),
541672
544438
  __metadata("design:type", Function),
541673
- __metadata("design:paramtypes", [Object, Object, Object]),
544439
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
541674
544440
  __metadata("design:returntype", Promise)
541675
544441
  ], HostingDownloadCommand.prototype, "execute", null);
541676
544442
  HostingDownloadCommand = __decorate([
@@ -542941,29 +545707,6 @@ exports.CreateFileLayer = CreateFileLayer;
542941
545707
 
542942
545708
  "use strict";
542943
545709
 
542944
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
542945
- if (k2 === undefined) k2 = k;
542946
- var desc = Object.getOwnPropertyDescriptor(m, k);
542947
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
542948
- desc = { enumerable: true, get: function() { return m[k]; } };
542949
- }
542950
- Object.defineProperty(o, k2, desc);
542951
- }) : (function(o, m, k, k2) {
542952
- if (k2 === undefined) k2 = k;
542953
- o[k2] = m[k];
542954
- }));
542955
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
542956
- Object.defineProperty(o, "default", { enumerable: true, value: v });
542957
- }) : function(o, v) {
542958
- o["default"] = v;
542959
- });
542960
- var __importStar = (this && this.__importStar) || function (mod) {
542961
- if (mod && mod.__esModule) return mod;
542962
- var result = {};
542963
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
542964
- __setModuleDefault(result, mod);
542965
- return result;
542966
- };
542967
545710
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
542968
545711
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
542969
545712
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -542982,14 +545725,11 @@ const fs_1 = __importDefault(__webpack_require__(79896));
542982
545725
  const os_1 = __importDefault(__webpack_require__(70857));
542983
545726
  const path_1 = __importDefault(__webpack_require__(16928));
542984
545727
  const chalk_1 = __importDefault(__webpack_require__(15896));
542985
- const interactive_1 = __webpack_require__(57695);
542986
- const framework_core_1 = __webpack_require__(50594);
542987
545728
  const toolbox_1 = __webpack_require__(25901);
542988
545729
  const utils_1 = __webpack_require__(82079);
542989
- const Hosting = __importStar(__webpack_require__(2767));
542990
- const Function = __importStar(__webpack_require__(11686));
542991
545730
  const auth_1 = __webpack_require__(73052);
542992
545731
  const i18n_1 = __webpack_require__(69258);
545732
+ const deploy_1 = __webpack_require__(98681);
542993
545733
  function smartDeploy() {
542994
545734
  return __awaiter(this, void 0, void 0, function* () {
542995
545735
  const loading = (0, utils_1.loadingFactory)();
@@ -543013,10 +545753,7 @@ function smartDeploy() {
543013
545753
  yield (0, utils_1.initProjectConfig)(envId, region, projectPath);
543014
545754
  utils_1.logger.success((0, i18n_1.t)('初始化项目成功!\n'));
543015
545755
  }
543016
- const setup = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('是否使用云开发部署当前项目 <{{path}}> ?', { path: chalk_1.default.bold.cyan(relative) }), true);
543017
- if (!setup) {
543018
- return;
543019
- }
545756
+ utils_1.logger.info(chalk_1.default.gray((0, i18n_1.t)('项目目录: {{path}}', { path: relative })));
543020
545757
  const config = yield (0, utils_1.getCloudBaseConfig)();
543021
545758
  let envId = config === null || config === void 0 ? void 0 : config.envId;
543022
545759
  if (!(config === null || config === void 0 ? void 0 : config.region) && !region) {
@@ -543033,32 +545770,13 @@ function smartDeploy() {
543033
545770
  }
543034
545771
  const parser = new toolbox_1.ConfigParser();
543035
545772
  parser.update('region', region);
543036
- yield callFramework(envId);
545773
+ const ctx = {
545774
+ globalOptions: {}
545775
+ };
545776
+ yield (0, deploy_1.executeAppDeploy)(ctx, [], utils_1.logger);
543037
545777
  });
543038
545778
  }
543039
545779
  exports.smartDeploy = smartDeploy;
543040
- function callFramework(envId) {
543041
- return __awaiter(this, void 0, void 0, function* () {
543042
- const loginState = yield utils_1.authSupevisor.getLoginState();
543043
- const { token, secretId, secretKey } = loginState;
543044
- const config = yield (0, utils_1.getCloudBaseConfig)();
543045
- yield (0, framework_core_1.run)({
543046
- projectPath: process.cwd(),
543047
- cloudbaseConfig: {
543048
- secretId,
543049
- secretKey,
543050
- token,
543051
- envId
543052
- },
543053
- config,
543054
- logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
543055
- resourceProviders: {
543056
- hosting: Hosting,
543057
- function: Function
543058
- }
543059
- }, 'deploy', '');
543060
- });
543061
- }
543062
545780
 
543063
545781
 
543064
545782
  /***/ }),
@@ -546125,6 +548843,32 @@ function sleep(time) {
546125
548843
  exports.sleep = sleep;
546126
548844
 
546127
548845
 
548846
+ /***/ }),
548847
+
548848
+ /***/ 41650:
548849
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
548850
+
548851
+ "use strict";
548852
+
548853
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
548854
+ if (k2 === undefined) k2 = k;
548855
+ var desc = Object.getOwnPropertyDescriptor(m, k);
548856
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
548857
+ desc = { enumerable: true, get: function() { return m[k]; } };
548858
+ }
548859
+ Object.defineProperty(o, k2, desc);
548860
+ }) : (function(o, m, k, k2) {
548861
+ if (k2 === undefined) k2 = k;
548862
+ o[k2] = m[k];
548863
+ }));
548864
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
548865
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
548866
+ };
548867
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
548868
+ __exportStar(__webpack_require__(15771), exports);
548869
+ __exportStar(__webpack_require__(2604), exports);
548870
+
548871
+
546128
548872
  /***/ }),
546129
548873
 
546130
548874
  /***/ 41665:
@@ -550773,7 +553517,7 @@ let NosqlExecuteCommand = class NosqlExecuteCommand extends common_1.Command {
550773
553517
  common_2.databaseNameOption,
550774
553518
  common_2.jsonOption
550775
553519
  ],
550776
- desc: (0, i18n_1.t)('执行文档型数据库命令'),
553520
+ desc: (0, i18n_1.t)('执行文档型数据库命令') + '\n RunCommands 接口文档: https://cloud.tencent.com/document/api/876/129012\n MgoCommandParam 数据结构: https://cloud.tencent.com/document/api/876/34822#MgoCommandParam',
550777
553521
  requiredEnvId: false,
550778
553522
  autoRunLogin: true
550779
553523
  };
@@ -596730,6 +599474,8 @@ __exportStar(__webpack_require__(58430), exports);
596730
599474
  __exportStar(__webpack_require__(38001), exports);
596731
599475
  __exportStar(__webpack_require__(11502), exports);
596732
599476
  __exportStar(__webpack_require__(81106), exports);
599477
+ __exportStar(__webpack_require__(60928), exports);
599478
+ __exportStar(__webpack_require__(41650), exports);
596733
599479
 
596734
599480
 
596735
599481
  /***/ }),
@@ -600789,6 +603535,38 @@ function dump(input, options) {
600789
603535
  module.exports.dump = dump;
600790
603536
 
600791
603537
 
603538
+ /***/ }),
603539
+
603540
+ /***/ 49637:
603541
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
603542
+
603543
+ "use strict";
603544
+
603545
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
603546
+ if (k2 === undefined) k2 = k;
603547
+ var desc = Object.getOwnPropertyDescriptor(m, k);
603548
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
603549
+ desc = { enumerable: true, get: function() { return m[k]; } };
603550
+ }
603551
+ Object.defineProperty(o, k2, desc);
603552
+ }) : (function(o, m, k, k2) {
603553
+ if (k2 === undefined) k2 = k;
603554
+ o[k2] = m[k];
603555
+ }));
603556
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
603557
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
603558
+ };
603559
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
603560
+ exports.getCloudAppService = exports.deployCloudApp = exports.detectFramework = void 0;
603561
+ var framework_detector_1 = __webpack_require__(18508);
603562
+ Object.defineProperty(exports, "detectFramework", ({ enumerable: true, get: function () { return framework_detector_1.detectFramework; } }));
603563
+ var deploy_1 = __webpack_require__(85182);
603564
+ Object.defineProperty(exports, "deployCloudApp", ({ enumerable: true, get: function () { return deploy_1.deployCloudApp; } }));
603565
+ var service_1 = __webpack_require__(94054);
603566
+ Object.defineProperty(exports, "getCloudAppService", ({ enumerable: true, get: function () { return service_1.getCloudAppService; } }));
603567
+ __exportStar(__webpack_require__(14764), exports);
603568
+
603569
+
600792
603570
  /***/ }),
600793
603571
 
600794
603572
  /***/ 49653:
@@ -631221,6 +633999,20 @@ function outputJsonSync (file, data, options) {
631221
633999
  module.exports = outputJsonSync
631222
634000
 
631223
634001
 
634002
+ /***/ }),
634003
+
634004
+ /***/ 55046:
634005
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
634006
+
634007
+ "use strict";
634008
+
634009
+
634010
+ var toInteger = __webpack_require__(49806)
634011
+ , max = Math.max;
634012
+
634013
+ module.exports = function (value) { return max(0, toInteger(value)); };
634014
+
634015
+
631224
634016
  /***/ }),
631225
634017
 
631226
634018
  /***/ 55112:
@@ -665288,6 +668080,7 @@ const access_1 = __webpack_require__(70427);
665288
668080
  const user_1 = __webpack_require__(71858);
665289
668081
  const cloudBaseRun_1 = __webpack_require__(24344);
665290
668082
  const mysql_1 = __webpack_require__(61697);
668083
+ const cloudApp_1 = __webpack_require__(32665);
665291
668084
  const permission_1 = __webpack_require__(24786);
665292
668085
  class Environment {
665293
668086
  constructor(context, envId) {
@@ -665311,6 +668104,7 @@ class Environment {
665311
668104
  this.cloudBaseRunService = new cloudBaseRun_1.CloudBaseRunService(this);
665312
668105
  this.mysqlService = new mysql_1.MysqlService(this);
665313
668106
  this.permissionService = new permission_1.PermissionService(this);
668107
+ this.cloudAppService = new cloudApp_1.CloudAppService(this);
665314
668108
  }
665315
668109
  async lazyInit() {
665316
668110
  if (!this.inited) {
@@ -665373,6 +668167,9 @@ class Environment {
665373
668167
  getMysqlService() {
665374
668168
  return this.mysqlService;
665375
668169
  }
668170
+ getCloudAppService() {
668171
+ return this.cloudAppService;
668172
+ }
665376
668173
  getPermissionService() {
665377
668174
  return this.permissionService;
665378
668175
  }
@@ -679799,6 +682596,35 @@ NodejsStreamInputAdapter.prototype.resume = function () {
679799
682596
  module.exports = NodejsStreamInputAdapter;
679800
682597
 
679801
682598
 
682599
+ /***/ }),
682600
+
682601
+ /***/ 60928:
682602
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
682603
+
682604
+ "use strict";
682605
+
682606
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
682607
+ if (k2 === undefined) k2 = k;
682608
+ var desc = Object.getOwnPropertyDescriptor(m, k);
682609
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
682610
+ desc = { enumerable: true, get: function() { return m[k]; } };
682611
+ }
682612
+ Object.defineProperty(o, k2, desc);
682613
+ }) : (function(o, m, k, k2) {
682614
+ if (k2 === undefined) k2 = k;
682615
+ o[k2] = m[k];
682616
+ }));
682617
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
682618
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
682619
+ };
682620
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
682621
+ __exportStar(__webpack_require__(98681), exports);
682622
+ __exportStar(__webpack_require__(20666), exports);
682623
+ __exportStar(__webpack_require__(7102), exports);
682624
+ __exportStar(__webpack_require__(6563), exports);
682625
+ __exportStar(__webpack_require__(83277), exports);
682626
+
682627
+
679802
682628
  /***/ }),
679803
682629
 
679804
682630
  /***/ 60973:
@@ -711682,7 +714508,7 @@ module.exports = {
711682
714508
  var iteratorSymbol = (__webpack_require__(72380).iterator)
711683
714509
  , isArguments = __webpack_require__(28746)
711684
714510
  , isFunction = __webpack_require__(92840)
711685
- , toPosInt = __webpack_require__(32665)
714511
+ , toPosInt = __webpack_require__(55046)
711686
714512
  , callable = __webpack_require__(25499)
711687
714513
  , validValue = __webpack_require__(67134)
711688
714514
  , isValue = __webpack_require__(89762)
@@ -731809,7 +734635,7 @@ module.exports = pipeline;
731809
734635
  "use strict";
731810
734636
 
731811
734637
 
731812
- var toPosInt = __webpack_require__(32665)
734638
+ var toPosInt = __webpack_require__(55046)
731813
734639
  , value = __webpack_require__(67134)
731814
734640
  , slice = Array.prototype.slice;
731815
734641
 
@@ -766133,7 +768959,7 @@ module.exports = from;
766133
768959
  "use strict";
766134
768960
 
766135
768961
 
766136
- var toPosInt = __webpack_require__(32665);
768962
+ var toPosInt = __webpack_require__(55046);
766137
768963
 
766138
768964
  var test = function (arg1, arg2) { return arg2; };
766139
768965
 
@@ -819023,6 +821849,115 @@ function createBaseFor(fromRight) {
819023
821849
  module.exports = createBaseFor;
819024
821850
 
819025
821851
 
821852
+ /***/ }),
821853
+
821854
+ /***/ 83277:
821855
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
821856
+
821857
+ "use strict";
821858
+
821859
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
821860
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
821861
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
821862
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
821863
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
821864
+ };
821865
+ var __metadata = (this && this.__metadata) || function (k, v) {
821866
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
821867
+ };
821868
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
821869
+ return function (target, key) { decorator(target, key, paramIndex); }
821870
+ };
821871
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
821872
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
821873
+ return new (P || (P = Promise))(function (resolve, reject) {
821874
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
821875
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
821876
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
821877
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
821878
+ });
821879
+ };
821880
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
821881
+ exports.AppDelete = void 0;
821882
+ const common_1 = __webpack_require__(48431);
821883
+ const decorators_1 = __webpack_require__(93480);
821884
+ const utils_1 = __webpack_require__(82079);
821885
+ const interactive_1 = __webpack_require__(57695);
821886
+ const utils_2 = __webpack_require__(75213);
821887
+ const constant_1 = __webpack_require__(62977);
821888
+ const i18n_1 = __webpack_require__(69258);
821889
+ const error_1 = __webpack_require__(66759);
821890
+ let AppDelete = class AppDelete extends common_1.Command {
821891
+ get options() {
821892
+ return {
821893
+ cmd: 'app',
821894
+ childCmd: 'delete <serviceName>',
821895
+ options: [],
821896
+ desc: (0, i18n_1.t)('删除云应用及其所有版本'),
821897
+ requiredEnvId: false,
821898
+ autoRunLogin: true,
821899
+ examples: ['tcb app delete my-app --env-id env-xxx'],
821900
+ seeAlso: ['tcb app list'],
821901
+ docs: ['https://docs.cloudbase.net/cli/app/delete']
821902
+ };
821903
+ }
821904
+ execute(envId, params, log) {
821905
+ return __awaiter(this, void 0, void 0, function* () {
821906
+ let selectedEnvId = envId;
821907
+ if (!selectedEnvId) {
821908
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
821909
+ }
821910
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
821911
+ if (!serviceName) {
821912
+ throw new error_1.CloudBaseError({
821913
+ message: (0, i18n_1.t)('请指定服务名称'),
821914
+ code: 'MISSING_PARAM',
821915
+ solution: [(0, i18n_1.t)('示例: tcb app delete my-app --env-id env-xxx')]
821916
+ });
821917
+ }
821918
+ const confirmed = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('确定要删除云应用 {{name}} 及其所有版本吗?', { name: serviceName }), false);
821919
+ if (!confirmed) {
821920
+ log.info((0, i18n_1.t)('已取消删除操作'));
821921
+ return;
821922
+ }
821923
+ const loading = (0, utils_1.loadingFactory)();
821924
+ loading.start((0, i18n_1.t)('正在删除云应用...'));
821925
+ try {
821926
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
821927
+ yield app.cloudAppService.deleteApp({
821928
+ deployType: 'static-hosting',
821929
+ serviceName: serviceName
821930
+ });
821931
+ loading.stop();
821932
+ if ((0, utils_1.isJsonOutput)()) {
821933
+ (0, utils_1.outputJson)({ serviceName, deleted: true });
821934
+ }
821935
+ else {
821936
+ loading.succeed((0, i18n_1.t)('云应用 {{name}} 已删除', { name: serviceName }));
821937
+ }
821938
+ }
821939
+ catch (e) {
821940
+ loading.fail((0, i18n_1.t)('删除失败'));
821941
+ throw e;
821942
+ }
821943
+ });
821944
+ }
821945
+ };
821946
+ __decorate([
821947
+ (0, decorators_1.InjectParams)(),
821948
+ __param(0, (0, decorators_1.EnvId)()),
821949
+ __param(1, (0, decorators_1.ArgsParams)()),
821950
+ __param(2, (0, decorators_1.Log)()),
821951
+ __metadata("design:type", Function),
821952
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
821953
+ __metadata("design:returntype", Promise)
821954
+ ], AppDelete.prototype, "execute", null);
821955
+ AppDelete = __decorate([
821956
+ (0, common_1.ICommand)()
821957
+ ], AppDelete);
821958
+ exports.AppDelete = AppDelete;
821959
+
821960
+
819026
821961
  /***/ }),
819027
821962
 
819028
821963
  /***/ 83283:
@@ -834502,6 +837437,226 @@ class Git extends git_base_1.GitBase {
834502
837437
  exports.Git = Git;
834503
837438
  //# sourceMappingURL=git.js.map
834504
837439
 
837440
+ /***/ }),
837441
+
837442
+ /***/ 85182:
837443
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
837444
+
837445
+ "use strict";
837446
+
837447
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
837448
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
837449
+ return new (P || (P = Promise))(function (resolve, reject) {
837450
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
837451
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
837452
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
837453
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
837454
+ });
837455
+ };
837456
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
837457
+ exports.deployCloudApp = void 0;
837458
+ const utils_1 = __webpack_require__(82079);
837459
+ const error_1 = __webpack_require__(66759);
837460
+ const i18n_1 = __webpack_require__(69258);
837461
+ const service_1 = __webpack_require__(94054);
837462
+ const types_1 = __webpack_require__(14764);
837463
+ const time_1 = __webpack_require__(41610);
837464
+ function deployCloudApp(options) {
837465
+ return __awaiter(this, void 0, void 0, function* () {
837466
+ const { envId, serviceName, framework, installCommand, buildCommand, outputDir, deployPath, buildPath = '', projectPath, ignore, envVariables, log } = options;
837467
+ const loading = (0, utils_1.loadingFactory)();
837468
+ try {
837469
+ const cloudAppService = yield (0, service_1.getCloudAppService)(envId);
837470
+ loading.start((0, i18n_1.t)('正在打包并上传代码...'));
837471
+ let uploadResult;
837472
+ try {
837473
+ uploadResult = yield cloudAppService.uploadCode({
837474
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
837475
+ serviceName,
837476
+ localPath: projectPath || process.cwd(),
837477
+ ignore: ignore || []
837478
+ });
837479
+ }
837480
+ catch (e) {
837481
+ if (e instanceof error_1.CloudBaseError)
837482
+ throw e;
837483
+ throw new error_1.CloudBaseError({
837484
+ message: (0, i18n_1.t)('代码上传失败: {{message}}', { message: e.message || String(e) }),
837485
+ code: 'DEPLOY_FAILED',
837486
+ requestId: e.requestId,
837487
+ original: e
837488
+ });
837489
+ }
837490
+ loading.succeed((0, i18n_1.t)('代码上传完成'));
837491
+ loading.start((0, i18n_1.t)('正在创建云应用...'));
837492
+ const staticConfig = {
837493
+ cosTimestamp: uploadResult.unixTimestamp,
837494
+ appPath: deployPath || `/${serviceName}`,
837495
+ buildPath
837496
+ };
837497
+ if (framework)
837498
+ staticConfig.framework = framework;
837499
+ const installCmd = installCommand !== null && installCommand !== void 0 ? installCommand : 'npm install';
837500
+ const buildCmd = buildCommand !== null && buildCommand !== void 0 ? buildCommand : 'npm run build';
837501
+ const resolvedDeployPath = deployPath || `/${serviceName}`;
837502
+ const deployCmd = `tcb hosting deploy ${outputDir || 'dist'} ${resolvedDeployPath}`;
837503
+ staticConfig.staticCmd = {
837504
+ buildCmd,
837505
+ installCmd,
837506
+ deployCmd
837507
+ };
837508
+ if (envVariables && Object.keys(envVariables).length > 0) {
837509
+ staticConfig.staticEnv = {
837510
+ variables: Object.entries(envVariables).map(([key, value]) => ({
837511
+ key,
837512
+ value: String(value)
837513
+ }))
837514
+ };
837515
+ }
837516
+ let createResult;
837517
+ try {
837518
+ createResult = yield cloudAppService.createApp({
837519
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
837520
+ serviceName,
837521
+ buildType: 'ZIP',
837522
+ staticConfig
837523
+ });
837524
+ }
837525
+ catch (e) {
837526
+ if (e instanceof error_1.CloudBaseError)
837527
+ throw e;
837528
+ throw new error_1.CloudBaseError({
837529
+ message: (0, i18n_1.t)('创建云应用失败: {{message}}', { message: e.message || String(e) }),
837530
+ code: 'DEPLOY_FAILED',
837531
+ requestId: e.requestId,
837532
+ original: e
837533
+ });
837534
+ }
837535
+ loading.succeed((0, i18n_1.t)('构建已触发'));
837536
+ const buildId = createResult.BuildId;
837537
+ const versionName = createResult.VersionName;
837538
+ loading.start((0, i18n_1.t)('正在云端构建... (约 3~5 分钟)'));
837539
+ const buildStartTime = Date.now();
837540
+ const buildResult = yield pollBuildStatus(cloudAppService, serviceName, versionName, {
837541
+ log,
837542
+ maxWaitTimeMs: options.maxWaitTimeMs
837543
+ });
837544
+ const wallClockDuration = Math.round((Date.now() - buildStartTime) / 1000);
837545
+ if (buildResult.status === 'FAILED') {
837546
+ loading.fail((0, i18n_1.t)('构建失败'));
837547
+ let errorMessage = (0, i18n_1.t)('云端构建失败');
837548
+ if (buildResult.failReason) {
837549
+ errorMessage += `: ${buildResult.failReason}`;
837550
+ }
837551
+ console.log();
837552
+ if (log) {
837553
+ log.error(errorMessage);
837554
+ }
837555
+ else {
837556
+ console.error(errorMessage);
837557
+ }
837558
+ const consoleUrl = `${utils_1.EUrl.DevPlatform}?envId=${envId}#/cloudapp/detail?serviceName=${serviceName}&tabId=build_log`;
837559
+ const clickableLink = (0, utils_1.genClickableLink)(consoleUrl);
837560
+ throw new error_1.CloudBaseError({
837561
+ message: errorMessage,
837562
+ code: 'BUILD_FAILED',
837563
+ solution: [
837564
+ (0, i18n_1.t)('检查构建命令是否正确: {{cmd}}', { cmd: buildCommand || 'npm run build' }),
837565
+ (0, i18n_1.t)('检查输出目录是否存在: {{dir}}', { dir: outputDir || 'dist' }),
837566
+ (0, i18n_1.t)('检查项目依赖是否完整: npm install'),
837567
+ (0, i18n_1.t)('查看控制台构建日志: {{link}}', { link: clickableLink })
837568
+ ]
837569
+ });
837570
+ }
837571
+ loading.succeed((0, i18n_1.t)('构建成功'));
837572
+ let url = '';
837573
+ try {
837574
+ const appInfo = yield cloudAppService.describeAppInfo({
837575
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
837576
+ serviceName
837577
+ });
837578
+ if (appInfo.Domain) {
837579
+ const domain = appInfo.Domain.replace(/^https?:\/\//, '');
837580
+ url = `https://${domain}/${serviceName}`;
837581
+ }
837582
+ }
837583
+ catch (e) {
837584
+ log === null || log === void 0 ? void 0 : log.verbose((0, i18n_1.t)('获取访问地址失败: {{message}}', { message: String(e) }));
837585
+ }
837586
+ const buildDuration = buildResult.duration && buildResult.duration > 0
837587
+ ? buildResult.duration
837588
+ : wallClockDuration;
837589
+ return {
837590
+ serviceName,
837591
+ versionName,
837592
+ buildId,
837593
+ url,
837594
+ deployTime: new Date().toISOString(),
837595
+ buildDuration
837596
+ };
837597
+ }
837598
+ catch (e) {
837599
+ loading.stop();
837600
+ if (e instanceof error_1.CloudBaseError)
837601
+ throw e;
837602
+ const errMessage = e instanceof Error ? e.message : String(e);
837603
+ throw new error_1.CloudBaseError({
837604
+ message: (0, i18n_1.t)('部署失败: {{message}}', { message: errMessage }),
837605
+ code: 'DEPLOY_FAILED',
837606
+ original: e instanceof Error ? e : undefined
837607
+ });
837608
+ }
837609
+ });
837610
+ }
837611
+ exports.deployCloudApp = deployCloudApp;
837612
+ function pollBuildStatus(cloudAppService, serviceName, versionName, options) {
837613
+ var _a;
837614
+ return __awaiter(this, void 0, void 0, function* () {
837615
+ const interval = (options === null || options === void 0 ? void 0 : options.interval) || 5000;
837616
+ const maxAttempts = (options === null || options === void 0 ? void 0 : options.maxWaitTimeMs)
837617
+ ? Math.ceil(options.maxWaitTimeMs / interval)
837618
+ : ((options === null || options === void 0 ? void 0 : options.maxAttempts) || 60);
837619
+ for (let i = 0; i < maxAttempts; i++) {
837620
+ try {
837621
+ const result = yield cloudAppService.describeAppVersion({
837622
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
837623
+ serviceName,
837624
+ versionName
837625
+ });
837626
+ (_a = options === null || options === void 0 ? void 0 : options.log) === null || _a === void 0 ? void 0 : _a.verbose((0, i18n_1.t)('构建状态: {{status}}', { status: result.Status }));
837627
+ if (result.Status === 'SUCCESS') {
837628
+ return {
837629
+ status: 'SUCCESS',
837630
+ url: result.Domain || result.Url,
837631
+ duration: result.BuildDuration
837632
+ };
837633
+ }
837634
+ if (result.Status === 'FAILED') {
837635
+ return {
837636
+ status: 'FAILED',
837637
+ failReason: result.FailReason
837638
+ };
837639
+ }
837640
+ yield (0, time_1.sleep)(interval);
837641
+ }
837642
+ catch (e) {
837643
+ throw new error_1.CloudBaseError({
837644
+ message: (0, i18n_1.t)('查询构建状态失败: {{message}}', { message: e.message || String(e) }),
837645
+ code: e.code || 'QUERY_BUILD_STATUS_FAILED',
837646
+ requestId: e.requestId,
837647
+ original: e
837648
+ });
837649
+ }
837650
+ }
837651
+ throw new error_1.CloudBaseError({
837652
+ message: (0, i18n_1.t)('构建超时'),
837653
+ code: 'BUILD_TIMEOUT',
837654
+ solution: [(0, i18n_1.t)('请稍后重试或检查云端构建日志')]
837655
+ });
837656
+ });
837657
+ }
837658
+
837659
+
834505
837660
  /***/ }),
834506
837661
 
834507
837662
  /***/ 85248:
@@ -841890,7 +845045,7 @@ exports["default"] = def;
841890
845045
  "use strict";
841891
845046
 
841892
845047
 
841893
- var toPosInt = __webpack_require__(32665)
845048
+ var toPosInt = __webpack_require__(55046)
841894
845049
  , callable = __webpack_require__(25499)
841895
845050
  , value = __webpack_require__(67134)
841896
845051
  , objHasOwnProperty = Object.prototype.hasOwnProperty
@@ -924287,6 +927442,48 @@ function regExpEscape (s) {
924287
927442
  }
924288
927443
 
924289
927444
 
927445
+ /***/ }),
927446
+
927447
+ /***/ 94054:
927448
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
927449
+
927450
+ "use strict";
927451
+
927452
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
927453
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
927454
+ return new (P || (P = Promise))(function (resolve, reject) {
927455
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
927456
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
927457
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
927458
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
927459
+ });
927460
+ };
927461
+ var __importDefault = (this && this.__importDefault) || function (mod) {
927462
+ return (mod && mod.__esModule) ? mod : { "default": mod };
927463
+ };
927464
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
927465
+ exports.getCloudAppService = void 0;
927466
+ const manager_node_1 = __importDefault(__webpack_require__(95492));
927467
+ const net_1 = __webpack_require__(25491);
927468
+ const toolbox_1 = __webpack_require__(25901);
927469
+ function getCloudAppService(envId) {
927470
+ return __awaiter(this, void 0, void 0, function* () {
927471
+ const region = yield (0, toolbox_1.getRegion)();
927472
+ const { secretId, secretKey, token } = yield (0, net_1.checkAndGetCredential)(true);
927473
+ const app = new manager_node_1.default({
927474
+ region,
927475
+ token,
927476
+ envId,
927477
+ secretId,
927478
+ secretKey,
927479
+ proxy: (0, net_1.getProxy)()
927480
+ });
927481
+ return app.cloudAppService;
927482
+ });
927483
+ }
927484
+ exports.getCloudAppService = getCloudAppService;
927485
+
927486
+
924290
927487
  /***/ }),
924291
927488
 
924292
927489
  /***/ 94068:
@@ -937639,6 +940836,12 @@ const outputHelpInfo = () => {
937639
940836
  db [cmd] ${(0, i18n_1.t)('数据库管理操作')}
937640
940837
  agent [cmd] ${(0, i18n_1.t)('Agent 管理操作')}
937641
940838
  logs [cmd] ${(0, i18n_1.t)('日志管理操作')}
940839
+ docs [cmd] ${(0, i18n_1.t)('云开发文档检索操作')}
940840
+ api [cmd] ${(0, i18n_1.t)('通用腾讯云 API 调用操作')}
940841
+ secrets [cmd] ${(0, i18n_1.t)('临时密钥管理操作')}
940842
+ user [cmd] ${(0, i18n_1.t)('用户管理操作')}
940843
+ permission [cmd] ${(0, i18n_1.t)('资源权限管理操作')}
940844
+ role [cmd] ${(0, i18n_1.t)('角色管理操作')}
937642
940845
  `;
937643
940846
  const options = `
937644
940847
  ${(0, i18n_1.t)('选项')}
@@ -944813,9 +948016,34 @@ class CloudBase {
944813
948016
  get mysql() {
944814
948017
  return this.currentEnvironment().getMysqlService();
944815
948018
  }
948019
+ /**
948020
+ * 云托管服务(CloudBaseRun)
948021
+ * 提供云托管版本流量配置等能力
948022
+ * @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
948023
+ */
944816
948024
  get cloudApp() {
944817
948025
  return this.currentEnvironment().getCloudBaseRunService();
944818
948026
  }
948027
+ /**
948028
+ * 云托管服务(CloudBaseRun)
948029
+ * 提供云托管版本流量配置等能力
948030
+ */
948031
+ get cloudBaseRun() {
948032
+ return this.currentEnvironment().getCloudBaseRunService();
948033
+ }
948034
+ /**
948035
+ * 云应用服务(CloudApp 统一部署)
948036
+ * 提供 Web 应用的创建、部署、版本管理等能力
948037
+ */
948038
+ get cloudAppService() {
948039
+ return this.currentEnvironment().getCloudAppService();
948040
+ }
948041
+ /**
948042
+ * 获取云应用服务
948043
+ */
948044
+ getCloudAppService() {
948045
+ return this.currentEnvironment().getCloudAppService();
948046
+ }
944819
948047
  commonService(service, version) {
944820
948048
  return this.currentEnvironment().getCommonService(service, version);
944821
948049
  }
@@ -955982,7 +959210,7 @@ if (process.platform === 'linux') {
955982
959210
 
955983
959211
 
955984
959212
 
955985
- var toPosInteger = __webpack_require__(32665)
959213
+ var toPosInteger = __webpack_require__(55046)
955986
959214
  , lruQueue = __webpack_require__(18056)
955987
959215
  , extensions = __webpack_require__(93923);
955988
959216
 
@@ -958644,7 +961872,7 @@ exports["default"] = $Ref;
958644
961872
 
958645
961873
 
958646
961874
  var numberIsNaN = __webpack_require__(14295)
958647
- , toPosInt = __webpack_require__(32665)
961875
+ , toPosInt = __webpack_require__(55046)
958648
961876
  , value = __webpack_require__(67134)
958649
961877
  , indexOf = Array.prototype.indexOf
958650
961878
  , objHasOwnProperty = Object.prototype.hasOwnProperty
@@ -962034,6 +965262,540 @@ module.exports = function (object, opts) {
962034
965262
  };
962035
965263
 
962036
965264
 
965265
+ /***/ }),
965266
+
965267
+ /***/ 98681:
965268
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
965269
+
965270
+ "use strict";
965271
+
965272
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
965273
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
965274
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
965275
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
965276
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
965277
+ };
965278
+ var __metadata = (this && this.__metadata) || function (k, v) {
965279
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
965280
+ };
965281
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
965282
+ return function (target, key) { decorator(target, key, paramIndex); }
965283
+ };
965284
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
965285
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
965286
+ return new (P || (P = Promise))(function (resolve, reject) {
965287
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
965288
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
965289
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
965290
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
965291
+ });
965292
+ };
965293
+ var __importDefault = (this && this.__importDefault) || function (mod) {
965294
+ return (mod && mod.__esModule) ? mod : { "default": mod };
965295
+ };
965296
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
965297
+ exports.getProjectName = exports.Deploy = exports.AppDeploy = exports.executeAppDeploy = exports.APP_DEPLOY_EXAMPLES = exports.APP_DEPLOY_OPTIONS = void 0;
965298
+ const path_1 = __importDefault(__webpack_require__(16928));
965299
+ const fs_1 = __importDefault(__webpack_require__(79896));
965300
+ const inquirer_1 = __importDefault(__webpack_require__(6403));
965301
+ const common_1 = __webpack_require__(48431);
965302
+ const decorators_1 = __webpack_require__(93480);
965303
+ const i18n_1 = __webpack_require__(69258);
965304
+ const error_1 = __webpack_require__(66759);
965305
+ const utils_1 = __webpack_require__(75213);
965306
+ const utils_2 = __webpack_require__(82079);
965307
+ const constant_1 = __webpack_require__(62977);
965308
+ const app_1 = __webpack_require__(49637);
965309
+ exports.APP_DEPLOY_OPTIONS = [
965310
+ {
965311
+ flags: '-e, --env-id <envId>',
965312
+ desc: (0, i18n_1.t)('目标环境 ID'),
965313
+ deprecatedName: 'envId'
965314
+ },
965315
+ {
965316
+ flags: '--framework <framework>',
965317
+ desc: (0, i18n_1.t)('框架类型'),
965318
+ choices: ['react', 'vue', 'vite', 'next', 'nuxt', 'angular', 'static']
965319
+ },
965320
+ {
965321
+ flags: '--install-command <cmd>',
965322
+ desc: (0, i18n_1.t)('安装命令(留空跳过安装步骤)')
965323
+ },
965324
+ {
965325
+ flags: '--build-command <cmd>',
965326
+ desc: (0, i18n_1.t)('构建命令(留空跳过构建步骤,适用于纯静态项目)')
965327
+ },
965328
+ {
965329
+ flags: '--output-dir <dir>',
965330
+ desc: (0, i18n_1.t)('构建产物目录,默认 dist')
965331
+ },
965332
+ {
965333
+ flags: '--deploy-path <path>',
965334
+ desc: (0, i18n_1.t)('部署路径(静态托管挂载路径),默认 /服务名')
965335
+ },
965336
+ {
965337
+ flags: '--dir <path>',
965338
+ desc: (0, i18n_1.t)('项目目录,相对路径(默认当前目录)')
965339
+ },
965340
+ {
965341
+ flags: '-f, --force',
965342
+ desc: (0, i18n_1.t)('应用名称已存在时跳过确认,直接覆盖更新')
965343
+ }
965344
+ ];
965345
+ exports.APP_DEPLOY_EXAMPLES = [
965346
+ 'tcb deploy',
965347
+ 'tcb deploy my-app --env-id env-xxx',
965348
+ 'tcb deploy --dir ./frontend',
965349
+ 'tcb deploy my-app --env-id env-xxx --framework react --json',
965350
+ 'tcb deploy my-app --env-id env-xxx --yes --json',
965351
+ 'tcb deploy my-app --env-id env-xxx --force'
965352
+ ];
965353
+ function executeAppDeploy(ctx, params, log) {
965354
+ var _a, _b, _c, _d, _e, _f, _g, _h;
965355
+ return __awaiter(this, void 0, void 0, function* () {
965356
+ const { config, globalOptions } = ctx;
965357
+ let { envId } = ctx;
965358
+ const { json, yes } = globalOptions || {};
965359
+ const { framework, installCommand: installCommandOption, buildCommand, outputDir, deployPath: deployPathOption, dir, force } = ctx.options || {};
965360
+ let serviceName = params === null || params === void 0 ? void 0 : params[0];
965361
+ const dirOption = dir || ((_a = config === null || config === void 0 ? void 0 : config.app) === null || _a === void 0 ? void 0 : _a.root);
965362
+ let projectPath = process.cwd();
965363
+ if (dirOption) {
965364
+ projectPath = path_1.default.resolve(process.cwd(), dirOption);
965365
+ if (!fs_1.default.existsSync(projectPath)) {
965366
+ throw new error_1.CloudBaseError({
965367
+ message: (0, i18n_1.t)('指定的项目目录不存在: {{path}}', { path: projectPath }),
965368
+ code: 'INVALID_PARAM',
965369
+ solution: [
965370
+ (0, i18n_1.t)('检查 --dir 参数路径是否正确'),
965371
+ (0, i18n_1.t)('当前工作目录: {{cwd}}', { cwd: process.cwd() })
965372
+ ]
965373
+ });
965374
+ }
965375
+ if (!fs_1.default.statSync(projectPath).isDirectory()) {
965376
+ throw new error_1.CloudBaseError({
965377
+ message: (0, i18n_1.t)('--dir 参数必须指向一个目录: {{path}}', { path: projectPath }),
965378
+ code: 'INVALID_PARAM'
965379
+ });
965380
+ }
965381
+ log.info((0, i18n_1.t)('项目目录: {{path}}', { path: dirOption }));
965382
+ }
965383
+ const buildPath = dirOption || '';
965384
+ if (!envId || envId.startsWith('{{')) {
965385
+ if (envId === null || envId === void 0 ? void 0 : envId.startsWith('{{')) {
965386
+ log.warn((0, i18n_1.t)('配置文件中的环境变量 {{envId}} 未找到对应的值,请选择环境', { envId }));
965387
+ }
965388
+ envId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
965389
+ log.info((0, i18n_1.t)('已选择环境: {{envId}}', { envId }));
965390
+ }
965391
+ if (!serviceName) {
965392
+ if ((_b = config === null || config === void 0 ? void 0 : config.app) === null || _b === void 0 ? void 0 : _b.serviceName) {
965393
+ serviceName = config.app.serviceName;
965394
+ }
965395
+ else if (!yes && !json) {
965396
+ serviceName = yield selectOrCreateService(envId, projectPath, log);
965397
+ }
965398
+ else {
965399
+ serviceName = getProjectName(projectPath);
965400
+ }
965401
+ }
965402
+ const serviceNameFromParam = (params === null || params === void 0 ? void 0 : params[0]) || ((_c = config === null || config === void 0 ? void 0 : config.app) === null || _c === void 0 ? void 0 : _c.serviceName) || (yes || json ? getProjectName(projectPath) : null);
965403
+ if (serviceNameFromParam) {
965404
+ const existing = yield checkServiceExists(envId, serviceName);
965405
+ if (existing) {
965406
+ if (force || yes) {
965407
+ log.verbose((0, i18n_1.t)('应用 "{{name}}" 已存在,覆盖更新', { name: serviceName }));
965408
+ }
965409
+ else if (json) {
965410
+ }
965411
+ else {
965412
+ log.warn((0, i18n_1.t)('云端已存在同名应用 [{{name}}]', { name: serviceName }));
965413
+ const { confirmed } = yield inquirer_1.default.prompt({
965414
+ type: 'confirm',
965415
+ name: 'confirmed',
965416
+ message: (0, i18n_1.t)('是否覆盖更新?'),
965417
+ default: true
965418
+ });
965419
+ if (!confirmed) {
965420
+ log.info((0, i18n_1.t)('已取消部署'));
965421
+ return null;
965422
+ }
965423
+ }
965424
+ }
965425
+ }
965426
+ let frameworkConfig = null;
965427
+ if (config === null || config === void 0 ? void 0 : config.app) {
965428
+ const appConfig = config.app;
965429
+ frameworkConfig = {
965430
+ framework: appConfig.framework || '',
965431
+ displayName: appConfig.framework || '',
965432
+ buildCommand: appConfig.buildCommand || '',
965433
+ outputDir: appConfig.outputDir || ''
965434
+ };
965435
+ }
965436
+ const needDetect = !(frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework);
965437
+ if (needDetect && !framework) {
965438
+ const detected = yield (0, app_1.detectFramework)(projectPath);
965439
+ if (detected) {
965440
+ log.success((0, i18n_1.t)('✔ 检测到框架: {{name}}', { name: detected.displayName }));
965441
+ log.info((0, i18n_1.t)(' 构建命令: {{cmd}}', { cmd: detected.buildCommand || '无' }));
965442
+ log.info((0, i18n_1.t)(' 输出目录: {{dir}}', { dir: detected.outputDir }));
965443
+ frameworkConfig = {
965444
+ framework: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework) || detected.framework,
965445
+ displayName: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.displayName) || detected.displayName,
965446
+ buildCommand: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.buildCommand) || detected.buildCommand,
965447
+ outputDir: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.outputDir) || detected.outputDir
965448
+ };
965449
+ }
965450
+ }
965451
+ const finalFramework = framework || (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework);
965452
+ const detectedBuildCommand = (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.buildCommand) || undefined;
965453
+ const detectedOutputDir = (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.outputDir) || undefined;
965454
+ const configInstallCommand = (_d = config === null || config === void 0 ? void 0 : config.app) === null || _d === void 0 ? void 0 : _d.installCommand;
965455
+ let finalInstallCommand;
965456
+ if (installCommandOption !== undefined) {
965457
+ finalInstallCommand = installCommandOption;
965458
+ }
965459
+ else if (configInstallCommand !== undefined) {
965460
+ finalInstallCommand = configInstallCommand;
965461
+ }
965462
+ else if (!yes && !json) {
965463
+ const { installCmd } = yield inquirer_1.default.prompt({
965464
+ type: 'input',
965465
+ name: 'installCmd',
965466
+ message: (0, i18n_1.t)('请输入安装命令(留空跳过)'),
965467
+ default: 'npm install'
965468
+ });
965469
+ finalInstallCommand = installCmd;
965470
+ }
965471
+ else {
965472
+ finalInstallCommand = 'npm install';
965473
+ }
965474
+ const configBuildCommand = ((_e = config === null || config === void 0 ? void 0 : config.app) === null || _e === void 0 ? void 0 : _e.buildCommand) || undefined;
965475
+ let finalBuildCommand;
965476
+ if (buildCommand !== undefined) {
965477
+ finalBuildCommand = buildCommand;
965478
+ }
965479
+ else if (configBuildCommand !== undefined) {
965480
+ finalBuildCommand = configBuildCommand;
965481
+ }
965482
+ else if (detectedBuildCommand !== undefined) {
965483
+ finalBuildCommand = detectedBuildCommand;
965484
+ }
965485
+ else if (!yes && !json) {
965486
+ const { buildCmd } = yield inquirer_1.default.prompt({
965487
+ type: 'input',
965488
+ name: 'buildCmd',
965489
+ message: (0, i18n_1.t)('请输入构建命令(留空跳过)'),
965490
+ default: 'npm run build'
965491
+ });
965492
+ finalBuildCommand = buildCmd;
965493
+ }
965494
+ else {
965495
+ finalBuildCommand = 'npm run build';
965496
+ }
965497
+ const configOutputDir = ((_f = config === null || config === void 0 ? void 0 : config.app) === null || _f === void 0 ? void 0 : _f.outputDir) || undefined;
965498
+ let finalOutputDir;
965499
+ if (outputDir !== undefined) {
965500
+ finalOutputDir = outputDir;
965501
+ }
965502
+ else if (configOutputDir !== undefined) {
965503
+ finalOutputDir = configOutputDir;
965504
+ }
965505
+ else if (detectedOutputDir !== undefined) {
965506
+ finalOutputDir = detectedOutputDir;
965507
+ }
965508
+ else if (!yes && !json) {
965509
+ const { outDir } = yield inquirer_1.default.prompt({
965510
+ type: 'input',
965511
+ name: 'outDir',
965512
+ message: (0, i18n_1.t)('请输入构建产物目录'),
965513
+ default: 'dist'
965514
+ });
965515
+ finalOutputDir = outDir;
965516
+ }
965517
+ else {
965518
+ finalOutputDir = 'dist';
965519
+ }
965520
+ let finalDeployPath = deployPathOption || ((_g = config === null || config === void 0 ? void 0 : config.app) === null || _g === void 0 ? void 0 : _g.deployPath);
965521
+ if (!finalDeployPath) {
965522
+ if (!yes && !json) {
965523
+ const { deployPathInput } = yield inquirer_1.default.prompt({
965524
+ type: 'input',
965525
+ name: 'deployPathInput',
965526
+ message: (0, i18n_1.t)('请输入部署路径(静态托管挂载路径)'),
965527
+ default: `/${serviceName}`,
965528
+ validate: (input) => {
965529
+ const p = input.trim();
965530
+ if (!p)
965531
+ return (0, i18n_1.t)('部署路径不能为空');
965532
+ if (!p.startsWith('/'))
965533
+ return (0, i18n_1.t)('部署路径必须以 / 开头');
965534
+ return true;
965535
+ }
965536
+ });
965537
+ finalDeployPath = deployPathInput;
965538
+ }
965539
+ }
965540
+ const envVariables = (_h = config === null || config === void 0 ? void 0 : config.app) === null || _h === void 0 ? void 0 : _h.envVariables;
965541
+ const result = yield (0, app_1.deployCloudApp)({
965542
+ envId,
965543
+ serviceName,
965544
+ framework: finalFramework,
965545
+ installCommand: finalInstallCommand,
965546
+ buildCommand: finalBuildCommand,
965547
+ outputDir: finalOutputDir,
965548
+ deployPath: finalDeployPath,
965549
+ buildPath,
965550
+ envVariables,
965551
+ log
965552
+ });
965553
+ if (json) {
965554
+ (0, utils_2.outputJson)(result, {
965555
+ nextSteps: [
965556
+ `tcb app info ${serviceName} --env-id ${envId}`,
965557
+ `tcb app versions ${serviceName} --env-id ${envId}`
965558
+ ]
965559
+ });
965560
+ }
965561
+ else {
965562
+ log.success((0, i18n_1.t)('\n✔ 部署成功!'));
965563
+ log.info((0, i18n_1.t)(' 访问地址: {{url}}', { url: result.url ? (0, utils_2.genClickableLink)(result.url) : '-' }));
965564
+ log.info((0, i18n_1.t)(' 版本号: {{version}}', { version: result.versionName }));
965565
+ log.info((0, i18n_1.t)(' 耗时: {{duration}}s', { duration: String(result.buildDuration) }));
965566
+ log.info((0, i18n_1.t)('\n下一步:'));
965567
+ log.info((0, i18n_1.t)(' 查看应用 tcb app info {{name}} --env-id {{envId}}', {
965568
+ name: serviceName, envId
965569
+ }));
965570
+ log.info((0, i18n_1.t)(' 查看版本 tcb app versions {{name}} --env-id {{envId}}', {
965571
+ name: serviceName, envId
965572
+ }));
965573
+ }
965574
+ if (!(config === null || config === void 0 ? void 0 : config.app)) {
965575
+ const appConfig = {
965576
+ serviceName,
965577
+ framework: finalFramework,
965578
+ installCommand: finalInstallCommand,
965579
+ buildCommand: finalBuildCommand,
965580
+ outputDir: finalOutputDir
965581
+ };
965582
+ if (dirOption) {
965583
+ appConfig.root = dirOption;
965584
+ }
965585
+ if (finalDeployPath && finalDeployPath !== `/${serviceName}`) {
965586
+ appConfig.deployPath = finalDeployPath;
965587
+ }
965588
+ yield (0, utils_1.upsertCloudbaserc)(projectPath, {
965589
+ envId,
965590
+ app: appConfig
965591
+ });
965592
+ log.success((0, i18n_1.t)('配置已保存到 cloudbaserc.json'));
965593
+ }
965594
+ return result;
965595
+ });
965596
+ }
965597
+ exports.executeAppDeploy = executeAppDeploy;
965598
+ let AppDeploy = class AppDeploy extends common_1.Command {
965599
+ get options() {
965600
+ return {
965601
+ cmd: 'app',
965602
+ childCmd: 'deploy [serviceName]',
965603
+ options: exports.APP_DEPLOY_OPTIONS,
965604
+ desc: (0, i18n_1.t)('部署云应用到云端。支持零配置自动检测框架。'),
965605
+ requiredEnvId: false,
965606
+ autoRunLogin: true,
965607
+ examples: exports.APP_DEPLOY_EXAMPLES,
965608
+ docs: ['https://docs.cloudbase.net/cli/app/deploy']
965609
+ };
965610
+ }
965611
+ execute(ctx, params, log) {
965612
+ return __awaiter(this, void 0, void 0, function* () {
965613
+ return executeAppDeploy(ctx, params, log);
965614
+ });
965615
+ }
965616
+ };
965617
+ __decorate([
965618
+ (0, decorators_1.InjectParams)(),
965619
+ __param(0, (0, decorators_1.CmdContext)()),
965620
+ __param(1, (0, decorators_1.ArgsParams)()),
965621
+ __param(2, (0, decorators_1.Log)()),
965622
+ __metadata("design:type", Function),
965623
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
965624
+ __metadata("design:returntype", Promise)
965625
+ ], AppDeploy.prototype, "execute", null);
965626
+ AppDeploy = __decorate([
965627
+ (0, common_1.ICommand)()
965628
+ ], AppDeploy);
965629
+ exports.AppDeploy = AppDeploy;
965630
+ let Deploy = class Deploy extends common_1.Command {
965631
+ get options() {
965632
+ return {
965633
+ cmd: 'deploy [serviceName]',
965634
+ options: exports.APP_DEPLOY_OPTIONS,
965635
+ desc: (0, i18n_1.t)('部署云应用到云端。支持零配置自动检测框架。'),
965636
+ requiredEnvId: false,
965637
+ autoRunLogin: true,
965638
+ examples: exports.APP_DEPLOY_EXAMPLES,
965639
+ seeAlso: ['tcb app deploy', 'tcb app list', 'tcb app info'],
965640
+ docs: ['https://docs.cloudbase.net/cli/app/deploy']
965641
+ };
965642
+ }
965643
+ execute(ctx, params, log) {
965644
+ return __awaiter(this, void 0, void 0, function* () {
965645
+ return executeAppDeploy(ctx, params, log);
965646
+ });
965647
+ }
965648
+ };
965649
+ __decorate([
965650
+ (0, decorators_1.InjectParams)(),
965651
+ __param(0, (0, decorators_1.CmdContext)()),
965652
+ __param(1, (0, decorators_1.ArgsParams)()),
965653
+ __param(2, (0, decorators_1.Log)()),
965654
+ __metadata("design:type", Function),
965655
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
965656
+ __metadata("design:returntype", Promise)
965657
+ ], Deploy.prototype, "execute", null);
965658
+ Deploy = __decorate([
965659
+ (0, common_1.ICommand)()
965660
+ ], Deploy);
965661
+ exports.Deploy = Deploy;
965662
+ function checkServiceExists(envId, serviceName) {
965663
+ return __awaiter(this, void 0, void 0, function* () {
965664
+ try {
965665
+ const app = yield (0, utils_2.getMangerService)(envId);
965666
+ const data = yield app.cloudAppService.describeAppList({
965667
+ deployType: app_1.DEPLOY_TYPE_STATIC_HOSTING,
965668
+ pageSize: 100
965669
+ });
965670
+ const list = data.ServiceList || [];
965671
+ return list.some((item) => item.ServiceName === serviceName);
965672
+ }
965673
+ catch (_a) {
965674
+ return false;
965675
+ }
965676
+ });
965677
+ }
965678
+ function selectOrCreateService(envId, projectPath, log) {
965679
+ return __awaiter(this, void 0, void 0, function* () {
965680
+ const loading = (0, utils_2.loadingFactory)();
965681
+ loading.start((0, i18n_1.t)('正在查询云端应用列表...'));
965682
+ let serviceList = [];
965683
+ try {
965684
+ const app = yield (0, utils_2.getMangerService)(envId);
965685
+ const data = yield app.cloudAppService.describeAppList({
965686
+ deployType: app_1.DEPLOY_TYPE_STATIC_HOSTING,
965687
+ pageSize: 100
965688
+ });
965689
+ serviceList = data.ServiceList || [];
965690
+ }
965691
+ catch (_a) {
965692
+ log.verbose((0, i18n_1.t)('查询云端应用列表失败,将直接输入服务名'));
965693
+ }
965694
+ finally {
965695
+ loading.stop();
965696
+ }
965697
+ if (serviceList.length === 0) {
965698
+ log.info((0, i18n_1.t)('当前环境暂无已部署的云应用'));
965699
+ return inputNewServiceName(projectPath, []);
965700
+ }
965701
+ const { action } = yield inquirer_1.default.prompt({
965702
+ type: 'list',
965703
+ name: 'action',
965704
+ message: (0, i18n_1.t)('请选择部署方式'),
965705
+ choices: [
965706
+ { name: (0, i18n_1.t)('关联已有项目'), value: 'link' },
965707
+ { name: (0, i18n_1.t)('部署新项目'), value: 'create' }
965708
+ ]
965709
+ });
965710
+ if (action === 'create') {
965711
+ return inputNewServiceName(projectPath, serviceList.map(i => i.ServiceName));
965712
+ }
965713
+ const selectedService = yield selectServiceWithPagination(serviceList);
965714
+ log.info((0, i18n_1.t)('已关联云端应用: {{name}}', { name: selectedService }));
965715
+ return selectedService;
965716
+ });
965717
+ }
965718
+ const PAGE_SIZE = 10;
965719
+ const LOAD_MORE = '__LOAD_MORE__';
965720
+ function selectServiceWithPagination(serviceList) {
965721
+ return __awaiter(this, void 0, void 0, function* () {
965722
+ let page = 1;
965723
+ while (true) {
965724
+ const pageItems = serviceList.slice(0, page * PAGE_SIZE);
965725
+ const hasMore = serviceList.length > page * PAGE_SIZE;
965726
+ const shown = pageItems.length;
965727
+ const total = serviceList.length;
965728
+ const choices = [
965729
+ ...pageItems.map((item) => ({
965730
+ name: `${item.ServiceName}${item.Domain ? ` (${item.Domain})` : ''}${item.LatestStatus ? ` [${item.LatestStatus}]` : ''}`,
965731
+ value: item.ServiceName,
965732
+ short: item.ServiceName
965733
+ })),
965734
+ ...(hasMore ? [
965735
+ new inquirer_1.default.Separator(),
965736
+ {
965737
+ name: (0, i18n_1.t)('显示更多 ({{shown}}/{{total}})', { shown, total }),
965738
+ value: LOAD_MORE,
965739
+ short: (0, i18n_1.t)('显示更多')
965740
+ }
965741
+ ] : [])
965742
+ ];
965743
+ const { selectedService } = yield inquirer_1.default.prompt({
965744
+ type: 'list',
965745
+ name: 'selectedService',
965746
+ message: (0, i18n_1.t)('请选择要关联的云端应用'),
965747
+ choices,
965748
+ pageSize: PAGE_SIZE + 2
965749
+ });
965750
+ if (selectedService === LOAD_MORE) {
965751
+ page++;
965752
+ continue;
965753
+ }
965754
+ return selectedService;
965755
+ }
965756
+ });
965757
+ }
965758
+ function inputNewServiceName(projectPath, existingNames) {
965759
+ return __awaiter(this, void 0, void 0, function* () {
965760
+ const defaultName = getProjectName(projectPath);
965761
+ const { serviceName } = yield inquirer_1.default.prompt({
965762
+ type: 'input',
965763
+ name: 'serviceName',
965764
+ message: (0, i18n_1.t)('请输入服务名称'),
965765
+ default: defaultName,
965766
+ validate: (input) => {
965767
+ const name = input.trim();
965768
+ if (!name)
965769
+ return (0, i18n_1.t)('服务名称不能为空');
965770
+ if (existingNames.includes(name)) {
965771
+ return (0, i18n_1.t)('服务名称 "{{name}}" 已被占用,请使用其他名称', { name });
965772
+ }
965773
+ return true;
965774
+ }
965775
+ });
965776
+ return serviceName;
965777
+ });
965778
+ }
965779
+ function getProjectName(projectPath) {
965780
+ const packageJsonPath = path_1.default.join(projectPath, 'package.json');
965781
+ if (fs_1.default.existsSync(packageJsonPath)) {
965782
+ try {
965783
+ const raw = fs_1.default.readFileSync(packageJsonPath, 'utf-8');
965784
+ const packageJson = JSON.parse(raw);
965785
+ if (packageJson.name && typeof packageJson.name === 'string') {
965786
+ const name = packageJson.name.replace(/^@[^/]+\//, '');
965787
+ if (name)
965788
+ return name;
965789
+ }
965790
+ }
965791
+ catch (_a) {
965792
+ }
965793
+ }
965794
+ return path_1.default.basename(projectPath);
965795
+ }
965796
+ exports.getProjectName = getProjectName;
965797
+
965798
+
962037
965799
  /***/ }),
962038
965800
 
962039
965801
  /***/ 98718: