@cloudbase/cli 3.0.0-alpha.3 → 3.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/standalone/cli.js +2888 -188
  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;
@@ -318256,6 +318256,263 @@ function getHeaders(options) {
318256
318256
  module.exports = Object.getOwnPropertyDescriptor;
318257
318257
 
318258
318258
 
318259
+ /***/ }),
318260
+
318261
+ /***/ 6563:
318262
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
318263
+
318264
+ "use strict";
318265
+
318266
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
318267
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
318268
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
318269
+ 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;
318270
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
318271
+ };
318272
+ var __metadata = (this && this.__metadata) || function (k, v) {
318273
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
318274
+ };
318275
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
318276
+ return function (target, key) { decorator(target, key, paramIndex); }
318277
+ };
318278
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
318279
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
318280
+ return new (P || (P = Promise))(function (resolve, reject) {
318281
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
318282
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
318283
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
318284
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
318285
+ });
318286
+ };
318287
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
318288
+ exports.AppVersionsList = exports.AppVersionDetail = void 0;
318289
+ const common_1 = __webpack_require__(48431);
318290
+ const decorators_1 = __webpack_require__(93480);
318291
+ const utils_1 = __webpack_require__(82079);
318292
+ const utils_2 = __webpack_require__(75213);
318293
+ const constant_1 = __webpack_require__(62977);
318294
+ const i18n_1 = __webpack_require__(69258);
318295
+ const error_1 = __webpack_require__(66759);
318296
+ let AppVersionDetail = class AppVersionDetail extends common_1.Command {
318297
+ get options() {
318298
+ return {
318299
+ cmd: 'app',
318300
+ childCmd: 'versions',
318301
+ childSubCmd: 'detail <serviceName>',
318302
+ options: [
318303
+ { flags: '-v, --version-name <versionName>', desc: (0, i18n_1.t)('版本名称,默认最新版本') }
318304
+ ],
318305
+ desc: (0, i18n_1.t)('查看应用版本详情(默认最新版本)'),
318306
+ requiredEnvId: false,
318307
+ autoRunLogin: true,
318308
+ examples: [
318309
+ 'tcb app versions detail my-app --env-id env-xxx',
318310
+ 'tcb app versions detail my-app --version-name my-app-001 --env-id env-xxx'
318311
+ ],
318312
+ seeAlso: ['tcb app versions list', 'tcb app info'],
318313
+ docs: ['https://docs.cloudbase.net/cli/app/versions']
318314
+ };
318315
+ }
318316
+ execute(envId, params, options, log) {
318317
+ return __awaiter(this, void 0, void 0, function* () {
318318
+ let selectedEnvId = envId;
318319
+ if (!selectedEnvId) {
318320
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
318321
+ }
318322
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
318323
+ if (!serviceName) {
318324
+ throw new error_1.CloudBaseError({
318325
+ message: (0, i18n_1.t)('请指定服务名称'),
318326
+ code: 'MISSING_PARAM',
318327
+ solution: [(0, i18n_1.t)('示例: tcb app versions detail my-app --env-id env-xxx')]
318328
+ });
318329
+ }
318330
+ const loading = (0, utils_1.loadingFactory)();
318331
+ loading.start((0, i18n_1.t)('数据加载中...'));
318332
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
318333
+ const data = yield app.cloudAppService.describeAppVersion({
318334
+ deployType: 'static-hosting',
318335
+ serviceName: serviceName,
318336
+ versionName: options.versionName
318337
+ });
318338
+ loading.stop();
318339
+ if ((0, utils_1.isJsonOutput)()) {
318340
+ this.outputVersionJson(data);
318341
+ return;
318342
+ }
318343
+ this.printVersionInfo(data, log);
318344
+ });
318345
+ }
318346
+ outputVersionJson(data) {
318347
+ var _a, _b;
318348
+ (0, utils_1.outputJson)({
318349
+ buildId: data.BuildId,
318350
+ buildType: data.BuildType,
318351
+ buildTime: data.BuildTime,
318352
+ status: data.Status,
318353
+ framework: data.Framework,
318354
+ failReason: data.FailReason,
318355
+ staticConfig: data.StaticConfig ? {
318356
+ framework: data.StaticConfig.Framework,
318357
+ appPath: data.StaticConfig.AppPath,
318358
+ nodeJsVersion: data.StaticConfig.NodeJsVersion,
318359
+ staticCmd: data.StaticConfig.StaticCmd ? {
318360
+ buildCmd: data.StaticConfig.StaticCmd.BuildCmd,
318361
+ installCmd: data.StaticConfig.StaticCmd.InstallCmd,
318362
+ deployCmd: data.StaticConfig.StaticCmd.DeployCmd
318363
+ } : undefined,
318364
+ staticEnv: ((_b = (_a = data.StaticConfig.StaticEnv) === null || _a === void 0 ? void 0 : _a.Variables) === null || _b === void 0 ? void 0 : _b.length) ? {
318365
+ variables: data.StaticConfig.StaticEnv.Variables.map(v => ({
318366
+ key: v.Key,
318367
+ value: v.Value
318368
+ }))
318369
+ } : undefined
318370
+ } : undefined
318371
+ });
318372
+ }
318373
+ printVersionInfo(data, log) {
318374
+ var _a, _b;
318375
+ log.info((0, i18n_1.t)('版本信息:'));
318376
+ log.info((0, i18n_1.t)(' 构建 ID: {{id}}', { id: data.BuildId || '-' }));
318377
+ log.info((0, i18n_1.t)(' 构建类型: {{type}}', { type: data.BuildType || '-' }));
318378
+ log.info((0, i18n_1.t)(' 框架: {{framework}}', { framework: data.Framework || '-' }));
318379
+ log.info((0, i18n_1.t)(' 状态: {{status}}', { status: data.Status || '-' }));
318380
+ if (data.BuildTime) {
318381
+ log.info((0, i18n_1.t)(' 构建时间: {{time}}', { time: data.BuildTime }));
318382
+ }
318383
+ if (data.FailReason) {
318384
+ log.warn((0, i18n_1.t)(' 失败原因: {{reason}}', { reason: data.FailReason }));
318385
+ }
318386
+ const staticConfig = data.StaticConfig;
318387
+ if (staticConfig) {
318388
+ log.info((0, i18n_1.t)('\n构建配置:'));
318389
+ if (staticConfig.AppPath) {
318390
+ log.info((0, i18n_1.t)(' 应用路径: {{path}}', { path: staticConfig.AppPath }));
318391
+ }
318392
+ if (staticConfig.NodeJsVersion) {
318393
+ log.info((0, i18n_1.t)(' Node.js 版本: {{version}}', { version: staticConfig.NodeJsVersion }));
318394
+ }
318395
+ if (staticConfig.StaticCmd) {
318396
+ log.info((0, i18n_1.t)(' 安装命令: {{cmd}}', { cmd: staticConfig.StaticCmd.InstallCmd || '-' }));
318397
+ log.info((0, i18n_1.t)(' 构建命令: {{cmd}}', { cmd: staticConfig.StaticCmd.BuildCmd || '-' }));
318398
+ log.info((0, i18n_1.t)(' 部署命令: {{cmd}}', { cmd: staticConfig.StaticCmd.DeployCmd || '-' }));
318399
+ }
318400
+ if ((_b = (_a = staticConfig.StaticEnv) === null || _a === void 0 ? void 0 : _a.Variables) === null || _b === void 0 ? void 0 : _b.length) {
318401
+ log.info((0, i18n_1.t)(' 环境变量:'));
318402
+ staticConfig.StaticEnv.Variables.forEach(v => {
318403
+ log.info((0, i18n_1.t)(' {{key}}={{value}}', { key: v.Key, value: v.Value }));
318404
+ });
318405
+ }
318406
+ }
318407
+ }
318408
+ };
318409
+ __decorate([
318410
+ (0, decorators_1.InjectParams)(),
318411
+ __param(0, (0, decorators_1.EnvId)()),
318412
+ __param(1, (0, decorators_1.ArgsParams)()),
318413
+ __param(2, (0, decorators_1.ArgsOptions)()),
318414
+ __param(3, (0, decorators_1.Log)()),
318415
+ __metadata("design:type", Function),
318416
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
318417
+ __metadata("design:returntype", Promise)
318418
+ ], AppVersionDetail.prototype, "execute", null);
318419
+ AppVersionDetail = __decorate([
318420
+ (0, common_1.ICommand)()
318421
+ ], AppVersionDetail);
318422
+ exports.AppVersionDetail = AppVersionDetail;
318423
+ let AppVersionsList = class AppVersionsList extends common_1.Command {
318424
+ get options() {
318425
+ return {
318426
+ cmd: 'app',
318427
+ childCmd: 'versions',
318428
+ childSubCmd: 'list <serviceName>',
318429
+ options: [
318430
+ { flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
318431
+ { flags: '-o, --offset <offset>', desc: (0, i18n_1.t)('数据偏移量,默认值为 0') }
318432
+ ],
318433
+ desc: (0, i18n_1.t)('查询云应用版本列表'),
318434
+ requiredEnvId: false,
318435
+ autoRunLogin: true,
318436
+ examples: ['tcb app versions list my-app --env-id env-xxx'],
318437
+ seeAlso: ['tcb app versions detail', 'tcb app info'],
318438
+ docs: ['https://docs.cloudbase.net/cli/app/versions']
318439
+ };
318440
+ }
318441
+ execute(envId, params, options, log) {
318442
+ return __awaiter(this, void 0, void 0, function* () {
318443
+ let selectedEnvId = envId;
318444
+ if (!selectedEnvId) {
318445
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
318446
+ }
318447
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
318448
+ if (!serviceName) {
318449
+ throw new error_1.CloudBaseError({
318450
+ message: (0, i18n_1.t)('请指定服务名称'),
318451
+ code: 'MISSING_PARAM',
318452
+ solution: [(0, i18n_1.t)('示例: tcb app versions list my-app --env-id env-xxx')]
318453
+ });
318454
+ }
318455
+ const limit = Math.max(1, Number(options.limit || 20));
318456
+ const offset = Number(options.offset || 0);
318457
+ const pageSize = limit;
318458
+ const pageNo = Math.floor(offset / limit) + 1;
318459
+ const loading = (0, utils_1.loadingFactory)();
318460
+ loading.start((0, i18n_1.t)('数据加载中...'));
318461
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
318462
+ const data = yield app.cloudAppService.describeAppVersionList({
318463
+ deployType: 'static-hosting',
318464
+ serviceName: serviceName,
318465
+ pageNo: pageNo,
318466
+ pageSize: pageSize
318467
+ });
318468
+ loading.stop();
318469
+ const versionList = data.VersionList || [];
318470
+ const total = data.Total || 0;
318471
+ if ((0, utils_1.isJsonOutput)()) {
318472
+ (0, utils_1.outputJson)(versionList.map(item => ({
318473
+ versionName: item.VersionName,
318474
+ buildId: item.BuildId,
318475
+ buildType: item.BuildType,
318476
+ buildTime: item.BuildTime,
318477
+ status: item.Status,
318478
+ framework: item.Framework,
318479
+ failReason: item.FailReason
318480
+ })), { total, limit, offset });
318481
+ return;
318482
+ }
318483
+ if (versionList.length === 0) {
318484
+ log.info((0, i18n_1.t)('暂无版本'));
318485
+ return;
318486
+ }
318487
+ 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)('构建时间')];
318488
+ const tableData = versionList.map(item => [
318489
+ item.VersionName || '-',
318490
+ item.BuildId || '-',
318491
+ item.BuildType || '-',
318492
+ item.Framework || '-',
318493
+ item.Status || '-',
318494
+ item.BuildTime || '-'
318495
+ ]);
318496
+ (0, utils_1.printHorizontalTable)(head, tableData);
318497
+ });
318498
+ }
318499
+ };
318500
+ __decorate([
318501
+ (0, decorators_1.InjectParams)(),
318502
+ __param(0, (0, decorators_1.EnvId)()),
318503
+ __param(1, (0, decorators_1.ArgsParams)()),
318504
+ __param(2, (0, decorators_1.ArgsOptions)()),
318505
+ __param(3, (0, decorators_1.Log)()),
318506
+ __metadata("design:type", Function),
318507
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
318508
+ __metadata("design:returntype", Promise)
318509
+ ], AppVersionsList.prototype, "execute", null);
318510
+ AppVersionsList = __decorate([
318511
+ (0, common_1.ICommand)()
318512
+ ], AppVersionsList);
318513
+ exports.AppVersionsList = AppVersionsList;
318514
+
318515
+
318259
318516
  /***/ }),
318260
318517
 
318261
318518
  /***/ 6569:
@@ -324815,6 +325072,124 @@ function renderChoices(choices, pointer) {
324815
325072
  module.exports = RawListPrompt;
324816
325073
 
324817
325074
 
325075
+ /***/ }),
325076
+
325077
+ /***/ 7102:
325078
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
325079
+
325080
+ "use strict";
325081
+
325082
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
325083
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
325084
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
325085
+ 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;
325086
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
325087
+ };
325088
+ var __metadata = (this && this.__metadata) || function (k, v) {
325089
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
325090
+ };
325091
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
325092
+ return function (target, key) { decorator(target, key, paramIndex); }
325093
+ };
325094
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
325095
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
325096
+ return new (P || (P = Promise))(function (resolve, reject) {
325097
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
325098
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
325099
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
325100
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
325101
+ });
325102
+ };
325103
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
325104
+ exports.AppInfo = void 0;
325105
+ const common_1 = __webpack_require__(48431);
325106
+ const decorators_1 = __webpack_require__(93480);
325107
+ const utils_1 = __webpack_require__(82079);
325108
+ const utils_2 = __webpack_require__(75213);
325109
+ const constant_1 = __webpack_require__(62977);
325110
+ const i18n_1 = __webpack_require__(69258);
325111
+ const error_1 = __webpack_require__(66759);
325112
+ let AppInfo = class AppInfo extends common_1.Command {
325113
+ get options() {
325114
+ return {
325115
+ cmd: 'app',
325116
+ childCmd: 'info <serviceName>',
325117
+ options: [],
325118
+ desc: (0, i18n_1.t)('查询云应用详情'),
325119
+ requiredEnvId: false,
325120
+ autoRunLogin: true,
325121
+ examples: ['tcb app info my-app --env-id env-xxx'],
325122
+ seeAlso: ['tcb app list', 'tcb app versions'],
325123
+ docs: ['https://docs.cloudbase.net/cli/app/info']
325124
+ };
325125
+ }
325126
+ execute(envId, params, log) {
325127
+ return __awaiter(this, void 0, void 0, function* () {
325128
+ let selectedEnvId = envId;
325129
+ if (!selectedEnvId) {
325130
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
325131
+ }
325132
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
325133
+ if (!serviceName) {
325134
+ throw new error_1.CloudBaseError({
325135
+ message: (0, i18n_1.t)('请指定服务名称'),
325136
+ code: 'MISSING_PARAM',
325137
+ solution: [(0, i18n_1.t)('示例: tcb app info my-app --env-id env-xxx')]
325138
+ });
325139
+ }
325140
+ const loading = (0, utils_1.loadingFactory)();
325141
+ loading.start((0, i18n_1.t)('数据加载中...'));
325142
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
325143
+ const data = yield app.cloudAppService.describeAppInfo({
325144
+ deployType: 'static-hosting',
325145
+ serviceName: serviceName
325146
+ });
325147
+ loading.stop();
325148
+ if ((0, utils_1.isJsonOutput)()) {
325149
+ (0, utils_1.outputJson)({
325150
+ serviceName: data.ServiceName,
325151
+ deployType: data.DeployType,
325152
+ framework: data.Framework,
325153
+ domain: data.Domain,
325154
+ latestStatus: data.LatestStatus,
325155
+ createTime: data.CreateTime,
325156
+ latestVersionName: data.LatestVersionName,
325157
+ staticConfig: data.StaticConfig
325158
+ });
325159
+ return;
325160
+ }
325161
+ log.info((0, i18n_1.t)('服务名称: {{name}}', { name: data.ServiceName }));
325162
+ log.info((0, i18n_1.t)('部署类型: {{type}}', { type: data.DeployType || 'static-hosting' }));
325163
+ log.info((0, i18n_1.t)('框架类型: {{framework}}', { framework: data.Framework || '-' }));
325164
+ log.info((0, i18n_1.t)('访问地址: {{domain}}', { domain: data.Domain || '-' }));
325165
+ log.info((0, i18n_1.t)('当前版本: {{version}}', { version: data.LatestVersionName || '-' }));
325166
+ log.info((0, i18n_1.t)('构建状态: {{status}}', { status: data.LatestStatus || '-' }));
325167
+ log.info((0, i18n_1.t)('创建时间: {{time}}', { time: data.CreateTime || '-' }));
325168
+ log.info((0, i18n_1.t)('\n下一步:'));
325169
+ log.info((0, i18n_1.t)(' 查看版本 tcb app versions list {{name}} --env-id {{envId}}', {
325170
+ name: serviceName, envId: selectedEnvId
325171
+ }));
325172
+ log.info((0, i18n_1.t)(' 重新部署 tcb app deploy {{name}} --env-id {{envId}}', {
325173
+ name: serviceName, envId: selectedEnvId
325174
+ }));
325175
+ });
325176
+ }
325177
+ };
325178
+ __decorate([
325179
+ (0, decorators_1.InjectParams)(),
325180
+ __param(0, (0, decorators_1.EnvId)()),
325181
+ __param(1, (0, decorators_1.ArgsParams)()),
325182
+ __param(2, (0, decorators_1.Log)()),
325183
+ __metadata("design:type", Function),
325184
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
325185
+ __metadata("design:returntype", Promise)
325186
+ ], AppInfo.prototype, "execute", null);
325187
+ AppInfo = __decorate([
325188
+ (0, common_1.ICommand)()
325189
+ ], AppInfo);
325190
+ exports.AppInfo = AppInfo;
325191
+
325192
+
324818
325193
  /***/ }),
324819
325194
 
324820
325195
  /***/ 7106:
@@ -330606,7 +330981,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
330606
330981
  /***/ ((module) => {
330607
330982
 
330608
330983
  "use strict";
330609
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.3","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.7","@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 - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
330984
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.6","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
330985
 
330611
330986
  /***/ }),
330612
330987
 
@@ -381294,6 +381669,18 @@ process.on('exit', Temp.purgeSyncAll); // Ensuring purgeable temp files are purg
381294
381669
  exports["default"] = Temp;
381295
381670
 
381296
381671
 
381672
+ /***/ }),
381673
+
381674
+ /***/ 14764:
381675
+ /***/ ((__unused_webpack_module, exports) => {
381676
+
381677
+ "use strict";
381678
+
381679
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
381680
+ exports.DEPLOY_TYPE_STATIC_HOSTING = void 0;
381681
+ exports.DEPLOY_TYPE_STATIC_HOSTING = 'static-hosting';
381682
+
381683
+
381297
381684
  /***/ }),
381298
381685
 
381299
381686
  /***/ 14777:
@@ -394907,11 +395294,22 @@ async function createSymlink (srcpath, dstpath, type) {
394907
395294
  } catch { }
394908
395295
 
394909
395296
  if (stats && stats.isSymbolicLink()) {
394910
- const [srcStat, dstStat] = await Promise.all([
394911
- fs.stat(srcpath),
394912
- fs.stat(dstpath)
394913
- ])
395297
+ // When srcpath is relative, resolve it relative to dstpath's directory
395298
+ // (standard symlink behavior) or fall back to cwd if that doesn't exist
395299
+ let srcStat
395300
+ if (path.isAbsolute(srcpath)) {
395301
+ srcStat = await fs.stat(srcpath)
395302
+ } else {
395303
+ const dstdir = path.dirname(dstpath)
395304
+ const relativeToDst = path.join(dstdir, srcpath)
395305
+ try {
395306
+ srcStat = await fs.stat(relativeToDst)
395307
+ } catch {
395308
+ srcStat = await fs.stat(srcpath)
395309
+ }
395310
+ }
394914
395311
 
395312
+ const dstStat = await fs.stat(dstpath)
394915
395313
  if (areIdentical(srcStat, dstStat)) return
394916
395314
  }
394917
395315
 
@@ -394933,7 +395331,21 @@ function createSymlinkSync (srcpath, dstpath, type) {
394933
395331
  stats = fs.lstatSync(dstpath)
394934
395332
  } catch { }
394935
395333
  if (stats && stats.isSymbolicLink()) {
394936
- const srcStat = fs.statSync(srcpath)
395334
+ // When srcpath is relative, resolve it relative to dstpath's directory
395335
+ // (standard symlink behavior) or fall back to cwd if that doesn't exist
395336
+ let srcStat
395337
+ if (path.isAbsolute(srcpath)) {
395338
+ srcStat = fs.statSync(srcpath)
395339
+ } else {
395340
+ const dstdir = path.dirname(dstpath)
395341
+ const relativeToDst = path.join(dstdir, srcpath)
395342
+ try {
395343
+ srcStat = fs.statSync(relativeToDst)
395344
+ } catch {
395345
+ srcStat = fs.statSync(srcpath)
395346
+ }
395347
+ }
395348
+
394937
395349
  const dstStat = fs.statSync(dstpath)
394938
395350
  if (areIdentical(srcStat, dstStat)) return
394939
395351
  }
@@ -400167,7 +400579,7 @@ exports.GitBase = GitBase;
400167
400579
  "use strict";
400168
400580
 
400169
400581
 
400170
- var toPosInt = __webpack_require__(32665)
400582
+ var toPosInt = __webpack_require__(55046)
400171
400583
 
400172
400584
  , create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty;
400173
400585
 
@@ -401561,9 +401973,15 @@ async function main() {
401561
401973
  const { outputHelpInfo } = __webpack_require__(95042)
401562
401974
  outputHelpInfo()
401563
401975
  } else if (!['-v', '--version'].includes(processArgv[2])) {
401564
- // HACK: framework 智能命令
401565
- const { smartDeploy } = __webpack_require__(8509)
401566
- smartDeploy()
401976
+ // 检测是否有旧的 framework.plugins 配置
401977
+ if (config?.framework?.plugins) {
401978
+ console.log(chalk.yellow(t('⚠️ 检测到旧版 framework.plugins 配置,请改用 tcb framework deploy')))
401979
+ console.log(chalk.gray(t(' 旧的 framework-core 一体化部署能力已迁移到 tcb framework deploy 命令')))
401980
+ processArgv = [processArgv[0], processArgv[1], 'framework', 'deploy', ...processArgv.slice(2)]
401981
+ } else {
401982
+ // 无子命令时,路由到 tcb app deploy 交互式部署流程
401983
+ processArgv = [processArgv[0], processArgv[1], 'app', 'deploy', ...processArgv.slice(2)]
401984
+ }
401567
401985
  }
401568
401986
  }
401569
401987
  }
@@ -401787,6 +402205,99 @@ if (__webpack_require__.c[__webpack_require__.s] === module) {
401787
402205
  exports.main = main
401788
402206
 
401789
402207
 
402208
+ /***/ }),
402209
+
402210
+ /***/ 18508:
402211
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
402212
+
402213
+ "use strict";
402214
+
402215
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
402216
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
402217
+ return new (P || (P = Promise))(function (resolve, reject) {
402218
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
402219
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
402220
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
402221
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
402222
+ });
402223
+ };
402224
+ var __importDefault = (this && this.__importDefault) || function (mod) {
402225
+ return (mod && mod.__esModule) ? mod : { "default": mod };
402226
+ };
402227
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
402228
+ exports.detectFramework = void 0;
402229
+ const fs_1 = __importDefault(__webpack_require__(79896));
402230
+ const path_1 = __importDefault(__webpack_require__(16928));
402231
+ const FRAMEWORK_RULES = [
402232
+ {
402233
+ name: 'next',
402234
+ displayName: 'Next.js',
402235
+ detect: (deps) => 'next' in deps,
402236
+ config: { buildCommand: 'npm run build', outputDir: '.next' }
402237
+ },
402238
+ {
402239
+ name: 'nuxt',
402240
+ displayName: 'Nuxt',
402241
+ detect: (deps) => 'nuxt' in deps,
402242
+ config: { buildCommand: 'npm run build', outputDir: '.nuxt' }
402243
+ },
402244
+ {
402245
+ name: 'angular',
402246
+ displayName: 'Angular',
402247
+ detect: (deps) => '@angular/cli' in deps,
402248
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
402249
+ },
402250
+ {
402251
+ name: 'vite',
402252
+ displayName: 'Vite',
402253
+ detect: (deps) => 'vite' in deps,
402254
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
402255
+ },
402256
+ {
402257
+ name: 'vue',
402258
+ displayName: 'Vue CLI',
402259
+ detect: (deps) => '@vue/cli-service' in deps,
402260
+ config: { buildCommand: 'npm run build', outputDir: 'dist' }
402261
+ },
402262
+ {
402263
+ name: 'react',
402264
+ displayName: 'React (create-react-app)',
402265
+ detect: (deps) => 'react-scripts' in deps,
402266
+ config: { buildCommand: 'npm run build', outputDir: 'build' }
402267
+ }
402268
+ ];
402269
+ function detectFramework(projectPath) {
402270
+ return __awaiter(this, void 0, void 0, function* () {
402271
+ const packageJsonPath = path_1.default.join(projectPath, 'package.json');
402272
+ if (fs_1.default.existsSync(packageJsonPath)) {
402273
+ try {
402274
+ const raw = yield fs_1.default.promises.readFile(packageJsonPath, 'utf-8');
402275
+ const packageJson = JSON.parse(raw);
402276
+ const allDeps = Object.assign(Object.assign({}, packageJson.dependencies), packageJson.devDependencies);
402277
+ for (const rule of FRAMEWORK_RULES) {
402278
+ if (rule.detect(allDeps)) {
402279
+ return Object.assign({ framework: rule.name, displayName: rule.displayName }, rule.config);
402280
+ }
402281
+ }
402282
+ }
402283
+ catch (_a) {
402284
+ }
402285
+ }
402286
+ const indexHtmlPath = path_1.default.join(projectPath, 'index.html');
402287
+ if (fs_1.default.existsSync(indexHtmlPath)) {
402288
+ return {
402289
+ framework: 'static',
402290
+ displayName: '静态 HTML',
402291
+ buildCommand: '',
402292
+ outputDir: '.'
402293
+ };
402294
+ }
402295
+ return null;
402296
+ });
402297
+ }
402298
+ exports.detectFramework = detectFramework;
402299
+
402300
+
401790
402301
  /***/ }),
401791
402302
 
401792
402303
  /***/ 18560:
@@ -411132,7 +411643,7 @@ exports.prettify = prettify;
411132
411643
  "use strict";
411133
411644
 
411134
411645
 
411135
- var toPosInt = __webpack_require__(32665)
411646
+ var toPosInt = __webpack_require__(55046)
411136
411647
  , maxTimeout = __webpack_require__(45481);
411137
411648
 
411138
411649
  module.exports = function (value) {
@@ -411713,6 +412224,138 @@ ZodError.create = (issues) => {
411713
412224
  };
411714
412225
 
411715
412226
 
412227
+ /***/ }),
412228
+
412229
+ /***/ 20666:
412230
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
412231
+
412232
+ "use strict";
412233
+
412234
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
412235
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
412236
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
412237
+ 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;
412238
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
412239
+ };
412240
+ var __metadata = (this && this.__metadata) || function (k, v) {
412241
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
412242
+ };
412243
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
412244
+ return function (target, key) { decorator(target, key, paramIndex); }
412245
+ };
412246
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
412247
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
412248
+ return new (P || (P = Promise))(function (resolve, reject) {
412249
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
412250
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
412251
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
412252
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
412253
+ });
412254
+ };
412255
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
412256
+ exports.AppList = void 0;
412257
+ const common_1 = __webpack_require__(48431);
412258
+ const decorators_1 = __webpack_require__(93480);
412259
+ const utils_1 = __webpack_require__(82079);
412260
+ const utils_2 = __webpack_require__(75213);
412261
+ const constant_1 = __webpack_require__(62977);
412262
+ const i18n_1 = __webpack_require__(69258);
412263
+ let AppList = class AppList extends common_1.Command {
412264
+ get options() {
412265
+ return {
412266
+ cmd: 'app',
412267
+ childCmd: 'list',
412268
+ options: [
412269
+ { flags: '-l, --limit <limit>', desc: (0, i18n_1.t)('返回数据长度,默认值为 20') },
412270
+ { flags: '-o, --offset <offset>', desc: (0, i18n_1.t)('数据偏移量,默认值为 0') }
412271
+ ],
412272
+ desc: (0, i18n_1.t)('查询云应用列表'),
412273
+ requiredEnvId: false,
412274
+ autoRunLogin: true,
412275
+ examples: ['tcb app list', 'tcb app list --env-id env-xxx --json'],
412276
+ seeAlso: ['tcb app info', 'tcb app deploy'],
412277
+ docs: ['https://docs.cloudbase.net/cli/app/list']
412278
+ };
412279
+ }
412280
+ execute(envId, options, log) {
412281
+ return __awaiter(this, void 0, void 0, function* () {
412282
+ let selectedEnvId = envId;
412283
+ if (!selectedEnvId) {
412284
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
412285
+ }
412286
+ const limit = Math.max(1, Number(options.limit || 20));
412287
+ const offset = Number(options.offset || 0);
412288
+ const pageSize = limit;
412289
+ const pageNo = Math.floor(offset / limit) + 1;
412290
+ const loading = (0, utils_1.loadingFactory)();
412291
+ loading.start((0, i18n_1.t)('数据加载中...'));
412292
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
412293
+ const data = yield app.cloudAppService.describeAppList({
412294
+ deployType: 'static-hosting',
412295
+ pageNo: pageNo,
412296
+ pageSize: pageSize
412297
+ });
412298
+ loading.stop();
412299
+ const serviceList = data.ServiceList || [];
412300
+ const total = data.Total || 0;
412301
+ const buildUrl = (domain, appPath) => {
412302
+ if (!domain)
412303
+ return undefined;
412304
+ const cleanDomain = domain.replace(/^https?:\/\//, '');
412305
+ const path = appPath && appPath !== '/' ? appPath : '';
412306
+ return `https://${cleanDomain}${path}`;
412307
+ };
412308
+ if ((0, utils_1.isJsonOutput)()) {
412309
+ (0, utils_1.outputJson)(serviceList.map((item) => ({
412310
+ serviceName: item.ServiceName,
412311
+ appPath: item.AppPath,
412312
+ framework: item.Framework,
412313
+ domain: item.Domain,
412314
+ url: buildUrl(item.Domain, item.AppPath),
412315
+ latestStatus: item.LatestStatus,
412316
+ latestVersionName: item.LatestVersionName,
412317
+ createTime: item.CreateTime,
412318
+ latestBuildTime: item.LatestBuildTime
412319
+ })), { total, limit, offset });
412320
+ return;
412321
+ }
412322
+ if (serviceList.length === 0) {
412323
+ log.info((0, i18n_1.t)('暂无云应用'));
412324
+ log.info((0, i18n_1.t)('\n下一步:'));
412325
+ log.info((0, i18n_1.t)(' 部署应用 tcb app deploy --env-id {{envId}}', { envId: selectedEnvId }));
412326
+ return;
412327
+ }
412328
+ 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)('更新时间')];
412329
+ const tableData = serviceList.map((item) => [
412330
+ item.ServiceName,
412331
+ item.Framework || '-',
412332
+ item.LatestStatus || '-',
412333
+ buildUrl(item.Domain, item.AppPath) ? (0, utils_1.genClickableLink)(buildUrl(item.Domain, item.AppPath)) : '-',
412334
+ item.LatestVersionName || '-',
412335
+ item.LatestBuildTime || '-'
412336
+ ]);
412337
+ (0, utils_1.printHorizontalTable)(head, tableData);
412338
+ log.info((0, i18n_1.t)('\n下一步:'));
412339
+ log.info((0, i18n_1.t)(' 查看详情 tcb app info <serviceName> --env-id {{envId}}', { envId: selectedEnvId }));
412340
+ log.info((0, i18n_1.t)(' 部署应用 tcb app deploy --env-id {{envId}}', { envId: selectedEnvId }));
412341
+ });
412342
+ }
412343
+ };
412344
+ __decorate([
412345
+ (0, decorators_1.InjectParams)(),
412346
+ __param(0, (0, decorators_1.EnvId)()),
412347
+ __param(1, (0, decorators_1.ArgsOptions)()),
412348
+ __param(2, (0, decorators_1.Log)()),
412349
+ __metadata("design:type", Function),
412350
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
412351
+ __metadata("design:returntype", Promise)
412352
+ ], AppList.prototype, "execute", null);
412353
+ AppList = __decorate([
412354
+ (0, common_1.ICommand)()
412355
+ ], AppList);
412356
+ exports.AppList = AppList;
412357
+
412358
+
411716
412359
  /***/ }),
411717
412360
 
411718
412361
  /***/ 20692:
@@ -436732,6 +437375,327 @@ function listCacheGet(key) {
436732
437375
  module.exports = listCacheGet;
436733
437376
 
436734
437377
 
437378
+ /***/ }),
437379
+
437380
+ /***/ 24786:
437381
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
437382
+
437383
+ "use strict";
437384
+
437385
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
437386
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
437387
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
437388
+ 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;
437389
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
437390
+ };
437391
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
437392
+ exports.PermissionService = void 0;
437393
+ const utils_1 = __webpack_require__(62358);
437394
+ const PERMISSION_BY_RESOURCE = {
437395
+ function: ['CUSTOM'],
437396
+ storage: ['READONLY', 'PRIVATE', 'ADMINWRITE', 'ADMINONLY', 'CUSTOM'],
437397
+ table: ['READONLY', 'PRIVATE', 'ADMINWRITE', 'ADMINONLY'],
437398
+ collection: ['READONLY', 'PRIVATE', 'ADMINWRITE', 'ADMINONLY', 'CUSTOM']
437399
+ };
437400
+ class PermissionService {
437401
+ constructor(environment) {
437402
+ this.environment = environment;
437403
+ this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
437404
+ }
437405
+ async modifyResourcePermission(options) {
437406
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437407
+ const { resourceType, resource, permission, securityRule } = options;
437408
+ if (!resourceType || !PERMISSION_BY_RESOURCE[resourceType]) {
437409
+ throw new Error('Invalid resourceType');
437410
+ }
437411
+ if (typeof resource !== 'string' || resource.trim().length === 0) {
437412
+ throw new Error('Invalid resource');
437413
+ }
437414
+ const allowed = PERMISSION_BY_RESOURCE[resourceType];
437415
+ if (!allowed.includes(permission)) {
437416
+ throw new Error(`Permission ${permission} is not allowed for resourceType ${resourceType}`);
437417
+ }
437418
+ if (permission === 'CUSTOM') {
437419
+ if (typeof securityRule !== 'string' || securityRule.trim().length === 0) {
437420
+ throw new Error('securityRule is required when permission is CUSTOM');
437421
+ }
437422
+ // // 校验 JSON 字符串合法性
437423
+ // try {
437424
+ // JSON.parse(securityRule)
437425
+ // } catch {
437426
+ // throw new Error('securityRule must be a valid JSON string')
437427
+ // }
437428
+ }
437429
+ const reqData = {
437430
+ EnvId,
437431
+ ResourceType: resourceType,
437432
+ Resource: resource,
437433
+ Permission: permission
437434
+ };
437435
+ if (permission === 'CUSTOM') {
437436
+ reqData.SecurityRule = securityRule;
437437
+ }
437438
+ return this.tcbService.request('ModifyResourcePermission', reqData);
437439
+ }
437440
+ async describeResourcePermission(options) {
437441
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437442
+ const { resourceType, resources } = options;
437443
+ if (!resourceType || !PERMISSION_BY_RESOURCE[resourceType]) {
437444
+ throw new Error('Invalid resourceType');
437445
+ }
437446
+ if (resources !== undefined) {
437447
+ if (!Array.isArray(resources)) {
437448
+ throw new Error('Invalid resources');
437449
+ }
437450
+ if (resources.length > 100) {
437451
+ throw new Error('resources length must be <= 100');
437452
+ }
437453
+ const invalid = resources.find(item => typeof item !== 'string' || item.trim().length === 0);
437454
+ if (invalid !== undefined) {
437455
+ throw new Error('resources contains invalid item');
437456
+ }
437457
+ }
437458
+ return this.tcbService.request('DescribeResourcePermission', Object.assign({ EnvId, ResourceType: resourceType }, (resources !== undefined ? { Resources: resources } : {})));
437459
+ }
437460
+ async createRole(options) {
437461
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437462
+ const { roleName, roleIdentity, description, memberUids, policies } = options;
437463
+ // RoleName 校验:非空,2-32字符,中文/字母/数字/_-:@.,必须以字母或中文开头
437464
+ if (typeof roleName !== 'string' || roleName.trim().length === 0) {
437465
+ throw new Error('roleName is required');
437466
+ }
437467
+ if (roleName.length < 2 || roleName.length > 32) {
437468
+ throw new Error('roleName length must be between 2 and 32');
437469
+ }
437470
+ if (!/^[\u4e00-\u9fa5a-zA-Z]/.test(roleName)) {
437471
+ throw new Error('roleName must start with a letter or Chinese character');
437472
+ }
437473
+ if (!/^[\u4e00-\u9fa5a-zA-Z0-9\-_:@.]+$/.test(roleName)) {
437474
+ throw new Error('roleName can only contain Chinese, letters, digits, and -_:@.');
437475
+ }
437476
+ // RoleIdentity 校验:非空,字母/数字/_-:@.,不能与默认角色标识重复
437477
+ if (typeof roleIdentity !== 'string' || roleIdentity.trim().length === 0) {
437478
+ throw new Error('roleIdentity is required');
437479
+ }
437480
+ if (!/^[a-zA-Z0-9\-_:@.]+$/.test(roleIdentity)) {
437481
+ throw new Error('roleIdentity can only contain letters, digits, and -_:@.');
437482
+ }
437483
+ // Description 校验
437484
+ if (description !== undefined && description.length > 255) {
437485
+ throw new Error('description length must be <= 255');
437486
+ }
437487
+ // MemberUids 校验
437488
+ if (memberUids !== undefined) {
437489
+ if (!Array.isArray(memberUids)) {
437490
+ throw new Error('memberUids must be an array');
437491
+ }
437492
+ if (memberUids.length > 100) {
437493
+ throw new Error('memberUids length must be <= 100');
437494
+ }
437495
+ const invalidUid = memberUids.find(uid => typeof uid !== 'string' || uid.trim().length === 0);
437496
+ if (invalidUid !== undefined) {
437497
+ throw new Error('memberUids contains invalid item');
437498
+ }
437499
+ }
437500
+ // Policies 校验
437501
+ if (policies !== undefined) {
437502
+ if (!Array.isArray(policies)) {
437503
+ throw new Error('policies must be an array');
437504
+ }
437505
+ if (policies.length > 50) {
437506
+ throw new Error('policies length must be <= 50');
437507
+ }
437508
+ const invalidPolicy = policies.find(policy => !policy.ResourceType || !policy.Resource);
437509
+ if (invalidPolicy !== undefined) {
437510
+ throw new Error('each policy must have ResourceType and Resource');
437511
+ }
437512
+ }
437513
+ const reqData = {
437514
+ EnvId,
437515
+ RoleName: roleName,
437516
+ RoleIdentity: roleIdentity
437517
+ };
437518
+ if (description !== undefined) {
437519
+ reqData.Description = description;
437520
+ }
437521
+ if (memberUids !== undefined && memberUids.length > 0) {
437522
+ reqData.MemberUids = memberUids;
437523
+ }
437524
+ if (policies !== undefined && policies.length > 0) {
437525
+ reqData.Policies = policies;
437526
+ }
437527
+ return this.tcbService.request('CreateRole', reqData);
437528
+ }
437529
+ async describeRoleList(options = {}) {
437530
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437531
+ const { pageNumber, pageSize, roleId, roleIdentity, roleName, loadDetails } = options;
437532
+ // PageNumber 校验:从1开始
437533
+ if (pageNumber !== undefined && (pageNumber < 1 || !Number.isInteger(pageNumber))) {
437534
+ throw new Error('pageNumber must be a positive integer');
437535
+ }
437536
+ // PageSize 校验:默认10,最大100
437537
+ if (pageSize !== undefined && (pageSize < 1 || pageSize > 100 || !Number.isInteger(pageSize))) {
437538
+ throw new Error('pageSize must be an integer between 1 and 100');
437539
+ }
437540
+ // RoleId 校验
437541
+ if (roleId !== undefined && (typeof roleId !== 'string' || roleId.trim().length === 0)) {
437542
+ throw new Error('Invalid roleId');
437543
+ }
437544
+ // RoleIdentity 校验
437545
+ if (roleIdentity !== undefined && (typeof roleIdentity !== 'string' || roleIdentity.trim().length === 0)) {
437546
+ throw new Error('Invalid roleIdentity');
437547
+ }
437548
+ // RoleName 校验
437549
+ if (roleName !== undefined && (typeof roleName !== 'string' || roleName.trim().length === 0)) {
437550
+ throw new Error('Invalid roleName');
437551
+ }
437552
+ const reqData = { EnvId };
437553
+ if (pageNumber !== undefined) {
437554
+ reqData.PageNumber = pageNumber;
437555
+ }
437556
+ if (pageSize !== undefined) {
437557
+ reqData.PageSize = pageSize;
437558
+ }
437559
+ if (roleId !== undefined) {
437560
+ reqData.RoleId = roleId;
437561
+ }
437562
+ if (roleIdentity !== undefined) {
437563
+ reqData.RoleIdentity = roleIdentity;
437564
+ }
437565
+ if (roleName !== undefined) {
437566
+ reqData.RoleName = roleName;
437567
+ }
437568
+ if (loadDetails !== undefined) {
437569
+ reqData.LoadDetails = loadDetails;
437570
+ }
437571
+ return this.tcbService.request('DescribeRoleList', reqData);
437572
+ }
437573
+ async modifyRole(options) {
437574
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437575
+ const { roleId, roleName, description, addMemberUids, removeMemberUids, addPolicies, removePolicies } = options;
437576
+ // RoleId 校验:必填
437577
+ if (typeof roleId !== 'string' || roleId.trim().length === 0) {
437578
+ throw new Error('roleId is required');
437579
+ }
437580
+ // RoleName 校验:不传或传空 => 不修改;非空时校验规则
437581
+ if (roleName !== undefined && roleName !== '') {
437582
+ if (roleName.length < 2 || roleName.length > 32) {
437583
+ throw new Error('roleName length must be between 2 and 32');
437584
+ }
437585
+ if (!/^[\u4e00-\u9fa5a-zA-Z]/.test(roleName)) {
437586
+ throw new Error('roleName must start with a letter or Chinese character');
437587
+ }
437588
+ if (!/^[\u4e00-\u9fa5a-zA-Z0-9\-_:@.]+$/.test(roleName)) {
437589
+ throw new Error('roleName can only contain Chinese, letters, digits, and -_:@.');
437590
+ }
437591
+ }
437592
+ // Description 校验
437593
+ if (description !== undefined && description.length > 255) {
437594
+ throw new Error('description length must be <= 255');
437595
+ }
437596
+ // AddMemberUids 校验
437597
+ if (addMemberUids !== undefined) {
437598
+ if (!Array.isArray(addMemberUids)) {
437599
+ throw new Error('addMemberUids must be an array');
437600
+ }
437601
+ const invalidUid = addMemberUids.find(uid => typeof uid !== 'string' || uid.trim().length === 0);
437602
+ if (invalidUid !== undefined) {
437603
+ throw new Error('addMemberUids contains invalid item');
437604
+ }
437605
+ }
437606
+ // RemoveMemberUids 校验
437607
+ if (removeMemberUids !== undefined) {
437608
+ if (!Array.isArray(removeMemberUids)) {
437609
+ throw new Error('removeMemberUids must be an array');
437610
+ }
437611
+ const invalidUid = removeMemberUids.find(uid => typeof uid !== 'string' || uid.trim().length === 0);
437612
+ if (invalidUid !== undefined) {
437613
+ throw new Error('removeMemberUids contains invalid item');
437614
+ }
437615
+ }
437616
+ // AddPolicies 校验
437617
+ if (addPolicies !== undefined) {
437618
+ if (!Array.isArray(addPolicies)) {
437619
+ throw new Error('addPolicies must be an array');
437620
+ }
437621
+ const invalidPolicy = addPolicies.find(policy => !policy.ResourceType || !policy.Resource);
437622
+ if (invalidPolicy !== undefined) {
437623
+ throw new Error('each addPolicy must have ResourceType and Resource');
437624
+ }
437625
+ }
437626
+ // RemovePolicies 校验
437627
+ if (removePolicies !== undefined) {
437628
+ if (!Array.isArray(removePolicies)) {
437629
+ throw new Error('removePolicies must be an array');
437630
+ }
437631
+ const invalidPolicy = removePolicies.find(policy => !policy.ResourceType || !policy.Resource);
437632
+ if (invalidPolicy !== undefined) {
437633
+ throw new Error('each removePolicy must have ResourceType and Resource');
437634
+ }
437635
+ }
437636
+ const reqData = { EnvId, RoleId: roleId };
437637
+ // RoleName:不传或传空 => 不修改(不下发)
437638
+ if (roleName !== undefined && roleName !== '') {
437639
+ reqData.RoleName = roleName;
437640
+ }
437641
+ if (description !== undefined) {
437642
+ reqData.Description = description;
437643
+ }
437644
+ if (addMemberUids !== undefined) {
437645
+ reqData.AddMemberUids = addMemberUids;
437646
+ }
437647
+ if (removeMemberUids !== undefined) {
437648
+ reqData.RemoveMemberUids = removeMemberUids;
437649
+ }
437650
+ if (addPolicies !== undefined) {
437651
+ reqData.AddPolicies = addPolicies;
437652
+ }
437653
+ if (removePolicies !== undefined) {
437654
+ reqData.RemovePolicies = removePolicies;
437655
+ }
437656
+ return this.tcbService.request('ModifyRole', reqData);
437657
+ }
437658
+ async deleteRoles(options) {
437659
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
437660
+ const { roleIds } = options;
437661
+ // RoleIds 校验:必填数组,最多100个
437662
+ if (!Array.isArray(roleIds) || roleIds.length === 0) {
437663
+ throw new Error('roleIds is required and must be a non-empty array');
437664
+ }
437665
+ if (roleIds.length > 100) {
437666
+ throw new Error('roleIds length must be <= 100');
437667
+ }
437668
+ const invalidId = roleIds.find(id => typeof id !== 'string' || id.trim().length === 0);
437669
+ if (invalidId !== undefined) {
437670
+ throw new Error('roleIds contains invalid item');
437671
+ }
437672
+ return this.tcbService.request('DeleteRoles', {
437673
+ EnvId,
437674
+ RoleIds: roleIds
437675
+ });
437676
+ }
437677
+ }
437678
+ exports.PermissionService = PermissionService;
437679
+ __decorate([
437680
+ (0, utils_1.preLazy)()
437681
+ ], PermissionService.prototype, "modifyResourcePermission", null);
437682
+ __decorate([
437683
+ (0, utils_1.preLazy)()
437684
+ ], PermissionService.prototype, "describeResourcePermission", null);
437685
+ __decorate([
437686
+ (0, utils_1.preLazy)()
437687
+ ], PermissionService.prototype, "createRole", null);
437688
+ __decorate([
437689
+ (0, utils_1.preLazy)()
437690
+ ], PermissionService.prototype, "describeRoleList", null);
437691
+ __decorate([
437692
+ (0, utils_1.preLazy)()
437693
+ ], PermissionService.prototype, "modifyRole", null);
437694
+ __decorate([
437695
+ (0, utils_1.preLazy)()
437696
+ ], PermissionService.prototype, "deleteRoles", null);
437697
+
437698
+
436735
437699
  /***/ }),
436736
437700
 
436737
437701
  /***/ 24808:
@@ -464861,6 +465825,7 @@ const { mkdirs } = __webpack_require__(23585)
464861
465825
  const { pathExists } = __webpack_require__(65057)
464862
465826
  const { utimesMillis } = __webpack_require__(53430)
464863
465827
  const stat = __webpack_require__(62039)
465828
+ const { asyncIteratorConcurrentProcess } = __webpack_require__(64129)
464864
465829
 
464865
465830
  async function copy (src, dest, opts = {}) {
464866
465831
  if (typeof opts === 'function') {
@@ -464968,28 +465933,20 @@ async function onDir (srcStat, destStat, src, dest, opts) {
464968
465933
  await fs.mkdir(dest)
464969
465934
  }
464970
465935
 
464971
- const promises = []
464972
-
464973
- // loop through the files in the current directory to copy everything
464974
- for await (const item of await fs.opendir(src)) {
465936
+ // iterate through the files in the current directory to copy everything
465937
+ await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
464975
465938
  const srcItem = path.join(src, item.name)
464976
465939
  const destItem = path.join(dest, item.name)
464977
465940
 
464978
- promises.push(
464979
- runFilter(srcItem, destItem, opts).then(include => {
464980
- if (include) {
464981
- // only copy the item if it matches the filter function
464982
- return stat.checkPaths(srcItem, destItem, 'copy', opts).then(({ destStat }) => {
464983
- // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
464984
- // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
464985
- return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
464986
- })
464987
- }
464988
- })
464989
- )
464990
- }
464991
-
464992
- await Promise.all(promises)
465941
+ const include = await runFilter(srcItem, destItem, opts)
465942
+ // only copy the item if it matches the filter function
465943
+ if (include) {
465944
+ const { destStat } = await stat.checkPaths(srcItem, destItem, 'copy', opts)
465945
+ // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
465946
+ // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
465947
+ await getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
465948
+ }
465949
+ })
464993
465950
 
464994
465951
  if (!destStat) {
464995
465952
  await fs.chmod(dest, srcStat.mode)
@@ -465018,15 +465975,20 @@ async function onLink (destStat, src, dest, opts) {
465018
465975
  if (opts.dereference) {
465019
465976
  resolvedDest = path.resolve(process.cwd(), resolvedDest)
465020
465977
  }
465021
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
465022
- throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
465023
- }
465978
+ // If both symlinks resolve to the same target, they are still distinct symlinks
465979
+ // that can be copied/overwritten. Only check subdirectory constraints when
465980
+ // the resolved paths are different.
465981
+ if (resolvedSrc !== resolvedDest) {
465982
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
465983
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
465984
+ }
465024
465985
 
465025
- // do not copy if src is a subdir of dest since unlinking
465026
- // dest in this case would result in removing src contents
465027
- // and therefore a broken symlink would be created.
465028
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
465029
- throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
465986
+ // do not copy if src is a subdir of dest since unlinking
465987
+ // dest in this case would result in removing src contents
465988
+ // and therefore a broken symlink would be created.
465989
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
465990
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
465991
+ }
465030
465992
  }
465031
465993
 
465032
465994
  // copy the link
@@ -496341,15 +497303,252 @@ exports.pack = __webpack_require__(30030)
496341
497303
  /***/ }),
496342
497304
 
496343
497305
  /***/ 32665:
496344
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
497306
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
496345
497307
 
496346
497308
  "use strict";
496347
497309
 
496348
-
496349
- var toInteger = __webpack_require__(49806)
496350
- , max = Math.max;
496351
-
496352
- module.exports = function (value) { return max(0, toInteger(value)); };
497310
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
497311
+ if (k2 === undefined) k2 = k;
497312
+ var desc = Object.getOwnPropertyDescriptor(m, k);
497313
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
497314
+ desc = { enumerable: true, get: function() { return m[k]; } };
497315
+ }
497316
+ Object.defineProperty(o, k2, desc);
497317
+ }) : (function(o, m, k, k2) {
497318
+ if (k2 === undefined) k2 = k;
497319
+ o[k2] = m[k];
497320
+ }));
497321
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
497322
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
497323
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
497324
+ 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;
497325
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
497326
+ };
497327
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
497328
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
497329
+ };
497330
+ var __importDefault = (this && this.__importDefault) || function (mod) {
497331
+ return (mod && mod.__esModule) ? mod : { "default": mod };
497332
+ };
497333
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
497334
+ exports.CloudAppService = void 0;
497335
+ const fs_1 = __importDefault(__webpack_require__(79896));
497336
+ const os_1 = __importDefault(__webpack_require__(70857));
497337
+ const path_1 = __importDefault(__webpack_require__(16928));
497338
+ const error_1 = __webpack_require__(40430);
497339
+ const utils_1 = __webpack_require__(62358);
497340
+ const http_request_1 = __webpack_require__(72088);
497341
+ __exportStar(__webpack_require__(35656), exports);
497342
+ /**
497343
+ * CloudApp 统一部署服务
497344
+ * 提供 Web 应用的创建、查询、删除、版本管理等功能
497345
+ */
497346
+ class CloudAppService {
497347
+ constructor(environment) {
497348
+ this.environment = environment;
497349
+ this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
497350
+ }
497351
+ // =========== 应用管理 API ===========
497352
+ /**
497353
+ * 创建/更新 CloudApp 应用
497354
+ * @param params 创建参数
497355
+ */
497356
+ async createApp(params) {
497357
+ const { envId } = this.getEnvInfo();
497358
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497359
+ return this.tcbService.request('CreateCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497360
+ }
497361
+ /**
497362
+ * 获取 CloudApp 应用列表
497363
+ * @param params 查询参数
497364
+ */
497365
+ async describeAppList(params) {
497366
+ const { envId } = this.getEnvInfo();
497367
+ return this.tcbService.request('DescribeCloudAppList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497368
+ }
497369
+ /**
497370
+ * 获取 CloudApp 应用详情
497371
+ * @param params 查询参数
497372
+ */
497373
+ async describeAppInfo(params) {
497374
+ const { envId } = this.getEnvInfo();
497375
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497376
+ return this.tcbService.request('DescribeCloudAppInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497377
+ }
497378
+ /**
497379
+ * 删除 CloudApp 应用
497380
+ * @param params 删除参数
497381
+ */
497382
+ async deleteApp(params) {
497383
+ const { envId } = this.getEnvInfo();
497384
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497385
+ return this.tcbService.request('DeleteCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497386
+ }
497387
+ // =========== 版本管理 API ===========
497388
+ /**
497389
+ * 获取 CloudApp 版本详情
497390
+ * 不指定 versionName 或 buildId 时返回最新版本
497391
+ * @param params 查询参数
497392
+ */
497393
+ async describeAppVersion(params) {
497394
+ const { envId } = this.getEnvInfo();
497395
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497396
+ return this.tcbService.request('DescribeCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497397
+ }
497398
+ /**
497399
+ * 获取 CloudApp 版本列表
497400
+ * @param params 查询参数
497401
+ */
497402
+ async describeAppVersionList(params) {
497403
+ const { envId } = this.getEnvInfo();
497404
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497405
+ return this.tcbService.request('DescribeCloudAppVersionList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497406
+ }
497407
+ /**
497408
+ * 删除 CloudApp 版本
497409
+ * @param params 删除参数
497410
+ */
497411
+ async deleteAppVersion(params) {
497412
+ const { envId } = this.getEnvInfo();
497413
+ this.validateRequiredParams(params, ['serviceName', 'deployType', 'versionName']);
497414
+ return this.tcbService.request('DeleteCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
497415
+ }
497416
+ // =========== COS 上传相关 API ===========
497417
+ /**
497418
+ * 获取 CloudApp COS 上传信息(预签名 URL)
497419
+ * @param params 查询参数
497420
+ */
497421
+ async describeCosInfo(params) {
497422
+ const { envId } = this.getEnvInfo();
497423
+ this.validateRequiredParams(params, ['serviceName', 'deployType']);
497424
+ return this.tcbService.request('DescribeCloudAppCosInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId, suffix: params.suffix || '.zip' })));
497425
+ }
497426
+ // =========== 辅助方法 ===========
497427
+ /**
497428
+ * 上传本地代码到 COS
497429
+ * 自动打包 ZIP 并上传到预签名 URL
497430
+ *
497431
+ * 注意:此方法不依赖应用是否已创建,可在创建应用前调用
497432
+ * 返回的 cosTimestamp 用于 createApp 时传入 staticConfig.cosTimestamp
497433
+ *
497434
+ * @param params 上传参数
497435
+ */
497436
+ async uploadCode(params) {
497437
+ const { serviceName, localPath, ignore = [] } = params;
497438
+ // 1. 验证本地路径
497439
+ if (!fs_1.default.existsSync(localPath)) {
497440
+ throw new error_1.CloudBaseError(`本地路径不存在: ${localPath}`);
497441
+ }
497442
+ const stat = fs_1.default.statSync(localPath);
497443
+ if (!stat.isDirectory()) {
497444
+ throw new error_1.CloudBaseError(`localPath 必须是目录: ${localPath}`);
497445
+ }
497446
+ // 2. 打包本地文件为 ZIP
497447
+ const tmpZipPath = path_1.default.join(os_1.default.tmpdir(), `cloudapp-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`);
497448
+ const defaultIgnore = ['node_modules/**', '.git/**', '.DS_Store', '**/.DS_Store'];
497449
+ await (0, utils_1.compressToZip)({
497450
+ dirPath: localPath,
497451
+ outputPath: tmpZipPath,
497452
+ ignore: [...defaultIgnore, ...ignore]
497453
+ });
497454
+ try {
497455
+ // 3. 获取上传凭证
497456
+ const cosInfo = await this.describeCosInfo({
497457
+ deployType: params.deployType,
497458
+ serviceName,
497459
+ suffix: '.zip'
497460
+ });
497461
+ // 4. 读取 ZIP 文件
497462
+ const zipBuffer = fs_1.default.readFileSync(tmpZipPath);
497463
+ // 5. 构建请求头
497464
+ const headers = {
497465
+ 'Content-Type': 'application/zip'
497466
+ };
497467
+ if (cosInfo.UploadHeaders && cosInfo.UploadHeaders.length > 0) {
497468
+ for (const h of cosInfo.UploadHeaders) {
497469
+ headers[h.Key] = h.Value;
497470
+ }
497471
+ }
497472
+ // 6. 使用预签名 URL 上传
497473
+ const response = await (0, http_request_1.fetchStream)(cosInfo.UploadUrl, {
497474
+ method: 'PUT',
497475
+ body: zipBuffer,
497476
+ headers
497477
+ });
497478
+ if (!response.ok) {
497479
+ let errorDetail = '';
497480
+ try {
497481
+ const responseText = await response.text();
497482
+ errorDetail = responseText ? ` - ${responseText.substring(0, 500)}` : '';
497483
+ }
497484
+ catch (_a) {
497485
+ // 解析失败时 errorDetail 保持空串,不影响主错误抛出
497486
+ }
497487
+ throw new error_1.CloudBaseError(`上传失败: ${response.status} ${response.statusText}${errorDetail}`);
497488
+ }
497489
+ // 7. 返回结果(返回 cosTimestamp,用于创建应用)
497490
+ return {
497491
+ cosTimestamp: cosInfo.UnixTimestamp,
497492
+ unixTimestamp: cosInfo.UnixTimestamp
497493
+ };
497494
+ }
497495
+ finally {
497496
+ // 8. 清理临时文件
497497
+ if (fs_1.default.existsSync(tmpZipPath)) {
497498
+ fs_1.default.unlinkSync(tmpZipPath);
497499
+ }
497500
+ }
497501
+ }
497502
+ /**
497503
+ * 获取环境信息
497504
+ */
497505
+ getEnvInfo() {
497506
+ const envConfig = this.environment.lazyEnvironmentConfig;
497507
+ return {
497508
+ envId: envConfig.EnvId
497509
+ };
497510
+ }
497511
+ /**
497512
+ * 校验必填参数
497513
+ * @param params 参数对象
497514
+ * @param fields 必填字段列表
497515
+ */
497516
+ validateRequiredParams(params, fields) {
497517
+ for (const field of fields) {
497518
+ if (!params[field]) {
497519
+ throw new error_1.CloudBaseError(`${field} 是必填参数`);
497520
+ }
497521
+ }
497522
+ }
497523
+ }
497524
+ exports.CloudAppService = CloudAppService;
497525
+ __decorate([
497526
+ (0, utils_1.preLazy)()
497527
+ ], CloudAppService.prototype, "createApp", null);
497528
+ __decorate([
497529
+ (0, utils_1.preLazy)()
497530
+ ], CloudAppService.prototype, "describeAppList", null);
497531
+ __decorate([
497532
+ (0, utils_1.preLazy)()
497533
+ ], CloudAppService.prototype, "describeAppInfo", null);
497534
+ __decorate([
497535
+ (0, utils_1.preLazy)()
497536
+ ], CloudAppService.prototype, "deleteApp", null);
497537
+ __decorate([
497538
+ (0, utils_1.preLazy)()
497539
+ ], CloudAppService.prototype, "describeAppVersion", null);
497540
+ __decorate([
497541
+ (0, utils_1.preLazy)()
497542
+ ], CloudAppService.prototype, "describeAppVersionList", null);
497543
+ __decorate([
497544
+ (0, utils_1.preLazy)()
497545
+ ], CloudAppService.prototype, "deleteAppVersion", null);
497546
+ __decorate([
497547
+ (0, utils_1.preLazy)()
497548
+ ], CloudAppService.prototype, "describeCosInfo", null);
497549
+ __decorate([
497550
+ (0, utils_1.preLazy)()
497551
+ ], CloudAppService.prototype, "uploadCode", null);
496353
497552
 
496354
497553
 
496355
497554
  /***/ }),
@@ -509795,6 +510994,24 @@ const imageCommonOptions = (sub) => ({
509795
510994
  exports.imageCommonOptions = imageCommonOptions;
509796
510995
 
509797
510996
 
510997
+ /***/ }),
510998
+
510999
+ /***/ 35656:
511000
+ /***/ ((__unused_webpack_module, exports) => {
511001
+
511002
+ "use strict";
511003
+
511004
+ /**
511005
+ * CloudApp 统一部署服务类型定义
511006
+ * 支持 static-hosting(静态托管)和 http-function(预留)两种部署类型
511007
+ *
511008
+ * 命名规范:
511009
+ * - 入参接口(IXxxParams):camelCase,通过 upperCaseObjKey 转换后透传给 API
511010
+ * - 返回值接口(IXxxResult):PascalCase,与 API 响应字段保持一致
511011
+ */
511012
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
511013
+
511014
+
509798
511015
  /***/ }),
509799
511016
 
509800
511017
  /***/ 35674:
@@ -540973,8 +542190,10 @@ const path_1 = __importDefault(__webpack_require__(16928));
540973
542190
  const log_symbols_1 = __importDefault(__webpack_require__(68329));
540974
542191
  const common_1 = __webpack_require__(48431);
540975
542192
  const hosting_1 = __webpack_require__(2767);
542193
+ const utils_1 = __webpack_require__(75213);
542194
+ const constant_1 = __webpack_require__(62977);
540976
542195
  const error_1 = __webpack_require__(66759);
540977
- const utils_1 = __webpack_require__(82079);
542196
+ const utils_2 = __webpack_require__(82079);
540978
542197
  const decorators_1 = __webpack_require__(93480);
540979
542198
  const i18n_1 = __webpack_require__(69258);
540980
542199
  const interactive_1 = __webpack_require__(57695);
@@ -540989,46 +542208,167 @@ const HostingStatusMap = {
540989
542208
  };
540990
542209
  function getHostingService(envId) {
540991
542210
  return __awaiter(this, void 0, void 0, function* () {
540992
- const { hosting } = yield (0, utils_1.getMangerService)(envId);
542211
+ const { hosting } = yield (0, utils_2.getMangerService)(envId);
540993
542212
  return hosting;
540994
542213
  });
540995
542214
  }
542215
+ function getDetailConfig(hostingService, cdnDomain) {
542216
+ var _a, _b;
542217
+ return __awaiter(this, void 0, void 0, function* () {
542218
+ try {
542219
+ const [webConfigRes, checkRes] = yield Promise.all([
542220
+ hostingService.getWebsiteConfig().catch(() => null),
542221
+ hostingService.tcbCheckResource({ domains: [cdnDomain] }).catch(() => null)
542222
+ ]);
542223
+ return {
542224
+ websiteConfig: webConfigRes,
542225
+ 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
542226
+ };
542227
+ }
542228
+ catch (_c) {
542229
+ return { websiteConfig: null, domainConfig: null };
542230
+ }
542231
+ });
542232
+ }
542233
+ function outputWebsiteConfig(websiteConfig, log) {
542234
+ var _a, _b;
542235
+ log.info('');
542236
+ log.info((0, i18n_1.t)('=== 索引文档配置 ==='));
542237
+ const indexDoc = ((_a = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.IndexDocument) === null || _a === void 0 ? void 0 : _a.Suffix) || 'index.html';
542238
+ const errorDoc = ((_b = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.ErrorDocument) === null || _b === void 0 ? void 0 : _b.Key) || '-';
542239
+ log.info((0, i18n_1.t)('默认索引文档:{{doc}}', { doc: indexDoc }));
542240
+ log.info((0, i18n_1.t)('错误文档:{{doc}}', { doc: errorDoc }));
542241
+ }
542242
+ function outputSecurityConfig(domainConfig, log) {
542243
+ var _a, _b;
542244
+ log.info('');
542245
+ log.info((0, i18n_1.t)('=== 安全配置 ==='));
542246
+ const referer = domainConfig.Refer;
542247
+ if ((referer === null || referer === void 0 ? void 0 : referer.Switch) === 'on') {
542248
+ log.info((0, i18n_1.t)('防盗链:已开启'));
542249
+ (_a = referer.RefererRules) === null || _a === void 0 ? void 0 : _a.forEach((rule, index) => {
542250
+ var _a;
542251
+ const type = rule.RefererType === 'whitelist' ? (0, i18n_1.t)('白名单') : (0, i18n_1.t)('黑名单');
542252
+ const allowEmpty = rule.AllowEmpty ? (0, i18n_1.t)('允许') : (0, i18n_1.t)('不允许');
542253
+ log.info((0, i18n_1.t)(' 规则{{index}}:{{type}},{{count}} 条,{{allowEmpty}}空 Referer', {
542254
+ index: index + 1,
542255
+ type,
542256
+ count: ((_a = rule.Referers) === null || _a === void 0 ? void 0 : _a.length) || 0,
542257
+ allowEmpty
542258
+ }));
542259
+ });
542260
+ }
542261
+ else {
542262
+ log.info((0, i18n_1.t)('防盗链:未开启'));
542263
+ }
542264
+ const ipFilter = domainConfig.IpFilter;
542265
+ if ((ipFilter === null || ipFilter === void 0 ? void 0 : ipFilter.Switch) === 'on') {
542266
+ const type = ipFilter.FilterType === 'whitelist' ? (0, i18n_1.t)('白名单') : (0, i18n_1.t)('黑名单');
542267
+ log.info((0, i18n_1.t)('IP {{type}}:已开启,{{count}} 条', { type, count: ((_b = ipFilter.Filters) === null || _b === void 0 ? void 0 : _b.length) || 0 }));
542268
+ }
542269
+ else {
542270
+ log.info((0, i18n_1.t)('IP 黑白名单:未开启'));
542271
+ }
542272
+ const ipFreqLimit = domainConfig.IpFreqLimit;
542273
+ if ((ipFreqLimit === null || ipFreqLimit === void 0 ? void 0 : ipFreqLimit.Switch) === 'on') {
542274
+ log.info((0, i18n_1.t)('IP 访问限频:已开启,{{qps}} QPS', { qps: ipFreqLimit.Qps }));
542275
+ }
542276
+ else {
542277
+ log.info((0, i18n_1.t)('IP 访问限频:未开启'));
542278
+ }
542279
+ }
540996
542280
  let HostingDetail = class HostingDetail extends common_1.Command {
540997
542281
  get options() {
540998
542282
  return {
540999
542283
  cmd: 'hosting',
541000
542284
  childCmd: 'detail',
541001
542285
  deprecateCmd: 'hosting:detail',
541002
- options: [],
541003
- desc: (0, i18n_1.t)('查看静态网站服务信息')
542286
+ options: [
542287
+ {
542288
+ flags: '-e, --env-id <envId>',
542289
+ desc: (0, i18n_1.t)('环境 ID'),
542290
+ deprecatedName: 'envId'
542291
+ }
542292
+ ],
542293
+ requiredEnvId: false,
542294
+ autoRunLogin: true,
542295
+ desc: (0, i18n_1.t)('查看静态网站服务信息'),
542296
+ examples: [
542297
+ 'tcb hosting detail',
542298
+ 'tcb hosting detail --env-id env-xxx',
542299
+ 'tcb hosting detail --json'
542300
+ ],
542301
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541004
542302
  };
541005
542303
  }
541006
542304
  execute(envId, log) {
541007
- var _a;
542305
+ var _a, _b, _c;
541008
542306
  return __awaiter(this, void 0, void 0, function* () {
541009
- const res = yield (0, hosting_1.getHostingInfo)({ envId });
542307
+ let selectedEnvId = envId;
542308
+ if (!selectedEnvId) {
542309
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
542310
+ }
542311
+ const res = yield (0, hosting_1.getHostingInfo)({ envId: selectedEnvId });
541010
542312
  const website = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a[0];
541011
542313
  if (!website) {
541012
- if ((0, utils_1.isJsonOutput)()) {
541013
- (0, utils_1.outputJson)({ error: { message: '静态网站服务未开通' } });
542314
+ if ((0, utils_2.isJsonOutput)()) {
542315
+ (0, utils_2.outputJson)({ error: { message: '静态网站服务未开通' } });
541014
542316
  return;
541015
542317
  }
541016
- yield (0, hosting_1.initHosting)({ envId });
542318
+ yield (0, hosting_1.initHosting)({ envId: selectedEnvId });
541017
542319
  return;
541018
542320
  }
541019
- if ((0, utils_1.isJsonOutput)()) {
541020
- (0, utils_1.outputJson)({
541021
- cdnDomain: website.cdnDomain,
541022
- status: website.status,
541023
- statusText: HostingStatusMap[website.status]
542321
+ const cdnDomain = website.cdnDomain;
542322
+ const bucket = website.bucket;
542323
+ const status = website.status;
542324
+ let detailConfig = { websiteConfig: null, domainConfig: null };
542325
+ if (status === 'online' && cdnDomain) {
542326
+ const hostingService = yield getHostingService(selectedEnvId);
542327
+ detailConfig = yield getDetailConfig(hostingService, cdnDomain);
542328
+ }
542329
+ const { websiteConfig, domainConfig } = detailConfig;
542330
+ if ((0, utils_2.isJsonOutput)()) {
542331
+ (0, utils_2.outputJson)({
542332
+ cdnDomain,
542333
+ bucket,
542334
+ status,
542335
+ statusText: HostingStatusMap[status],
542336
+ indexDocument: ((_b = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.IndexDocument) === null || _b === void 0 ? void 0 : _b.Suffix) || 'index.html',
542337
+ errorDocument: ((_c = websiteConfig === null || websiteConfig === void 0 ? void 0 : websiteConfig.ErrorDocument) === null || _c === void 0 ? void 0 : _c.Key) || '',
542338
+ security: {
542339
+ referer: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.Refer) || null,
542340
+ ipFilter: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.IpFilter) || null,
542341
+ ipFreqLimit: (domainConfig === null || domainConfig === void 0 ? void 0 : domainConfig.IpFreqLimit) || null
542342
+ }
541024
542343
  });
541025
542344
  return;
541026
542345
  }
541027
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
541028
- if (website.status !== 'offline') {
541029
- log.info((0, i18n_1.t)('静态网站域名:{{link}}', { link }));
542346
+ log.info((0, i18n_1.t)('=== 静态网站服务信息 ==='));
542347
+ log.info('');
542348
+ if (status !== 'offline') {
542349
+ const link = (0, utils_2.genClickableLink)(`https://${cdnDomain}`);
542350
+ log.info((0, i18n_1.t)('域名:{{link}}', { link }));
542351
+ }
542352
+ log.info((0, i18n_1.t)('状态:【{{status}}】', { status: HostingStatusMap[status] }));
542353
+ log.info((0, i18n_1.t)('存储桶:{{bucket}}', { bucket }));
542354
+ if (websiteConfig) {
542355
+ outputWebsiteConfig(websiteConfig, log);
542356
+ }
542357
+ if (domainConfig) {
542358
+ outputSecurityConfig(domainConfig, log);
542359
+ }
542360
+ if (status === 'online') {
542361
+ log.info('');
542362
+ log.info((0, i18n_1.t)('💡 下一步:'));
542363
+ log.info((0, i18n_1.t)(' • 部署文件: tcb hosting deploy ./dist'));
542364
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
542365
+ log.info((0, i18n_1.t)(' • 访问网站: https://{{cdnDomain}}', { cdnDomain }));
542366
+ }
542367
+ else if (status === 'offline') {
542368
+ log.info('');
542369
+ log.info((0, i18n_1.t)('💡 下一步:'));
542370
+ log.info((0, i18n_1.t)(' • 开通服务: tcb hosting init'));
541030
542371
  }
541031
- log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
541032
542372
  });
541033
542373
  }
541034
542374
  };
@@ -541050,7 +542390,15 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541050
542390
  cmd: 'hosting',
541051
542391
  childCmd: 'deploy [filePath] [cloudPath]',
541052
542392
  deprecateCmd: 'hosting:deploy [filePath] [cloudPath]',
541053
- options: [],
542393
+ options: [
542394
+ {
542395
+ flags: '-e, --env-id <envId>',
542396
+ desc: (0, i18n_1.t)('环境 ID'),
542397
+ deprecatedName: 'envId'
542398
+ }
542399
+ ],
542400
+ requiredEnvId: false,
542401
+ autoRunLogin: true,
541054
542402
  desc: (0, i18n_1.t)('部署静态网站文件'),
541055
542403
  examples: ['tcb hosting deploy .', 'tcb hosting deploy ./dist'],
541056
542404
  seeAlso: ['tcb hosting list'],
@@ -541060,21 +542408,25 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541060
542408
  execute(envId, params, log) {
541061
542409
  var _a;
541062
542410
  return __awaiter(this, void 0, void 0, function* () {
542411
+ let selectedEnvId = envId;
542412
+ if (!selectedEnvId) {
542413
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
542414
+ }
541063
542415
  const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
541064
542416
  const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
541065
542417
  log.verbose((0, i18n_1.t)('本地目录'), localPath);
541066
542418
  const resolveLocalPath = path_1.default.resolve(localPath);
541067
- (0, utils_1.checkFullAccess)(resolveLocalPath, true);
541068
- const isDir = (0, utils_1.isDirectory)(resolveLocalPath);
541069
- const loading = (0, utils_1.loadingFactory)();
542419
+ (0, utils_2.checkFullAccess)(resolveLocalPath, true);
542420
+ const isDir = (0, utils_2.isDirectory)(resolveLocalPath);
542421
+ const loading = (0, utils_2.loadingFactory)();
541070
542422
  loading.start((0, i18n_1.t)('准备上传中...'));
541071
542423
  let totalFiles = 0;
541072
542424
  if (isDir) {
541073
- let files = yield (0, hosting_1.walkLocalDir)(envId, resolveLocalPath);
541074
- files = files.filter((item) => !(0, utils_1.isDirectory)(item));
542425
+ let files = yield (0, hosting_1.walkLocalDir)(selectedEnvId, resolveLocalPath);
542426
+ files = files.filter((item) => !(0, utils_2.isDirectory)(item));
541075
542427
  totalFiles = files.length;
541076
542428
  }
541077
- const onProgress = (0, utils_1.createUploadProgressBar)(() => {
542429
+ const onProgress = (0, utils_2.createUploadProgressBar)(() => {
541078
542430
  !isDir && log.success((0, i18n_1.t)('文件部署成功!'));
541079
542431
  }, () => {
541080
542432
  loading.stop();
@@ -541084,7 +542436,7 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541084
542436
  yield (0, hosting_1.hostingDeploy)({
541085
542437
  filePath: resolveLocalPath,
541086
542438
  cloudPath,
541087
- envId,
542439
+ envId: selectedEnvId,
541088
542440
  isDir,
541089
542441
  onProgress,
541090
542442
  onFileFinish: (...args) => {
@@ -541099,12 +542451,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541099
542451
  }
541100
542452
  });
541101
542453
  const info = yield (0, hosting_1.getHostingInfo)({
541102
- envId
542454
+ envId: selectedEnvId
541103
542455
  });
541104
542456
  const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
541105
- const link = (0, utils_1.genClickableLink)(`https://${website.cdnDomain}`);
541106
- if ((0, utils_1.isJsonOutput)()) {
541107
- (0, utils_1.outputJson)({
542457
+ const link = (0, utils_2.genClickableLink)(`https://${website.cdnDomain}`);
542458
+ if ((0, utils_2.isJsonOutput)()) {
542459
+ (0, utils_2.outputJson)({
541108
542460
  message: '部署完成',
541109
542461
  url: `https://${website.cdnDomain}`,
541110
542462
  totalFiles: isDir ? totalFiles : 1,
@@ -541118,12 +542470,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541118
542470
  log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
541119
542471
  log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
541120
542472
  if (totalFiles <= 50) {
541121
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
542473
+ (0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
541122
542474
  }
541123
542475
  log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
541124
542476
  if (failedFiles.length) {
541125
542477
  if (totalFiles <= 50) {
541126
- (0, utils_1.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
542478
+ (0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
541127
542479
  }
541128
542480
  else {
541129
542481
  const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
@@ -541131,9 +542483,23 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
541131
542483
  console.log(errorLogPath);
541132
542484
  fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
541133
542485
  }
541134
- throw new error_1.CloudBaseError((0, i18n_1.t)('部分文件上传失败,进程退出'));
542486
+ throw new error_1.CloudBaseError({
542487
+ message: (0, i18n_1.t)('部分文件上传失败,进程退出'),
542488
+ code: 'DEPLOY_PARTIAL_FAILED',
542489
+ solution: [
542490
+ '检查网络连接是否稳定',
542491
+ '查看失败文件列表并手动重试',
542492
+ '运行 tcb hosting list 确认已上传文件'
542493
+ ]
542494
+ });
541135
542495
  }
541136
542496
  }
542497
+ if (failedFiles.length === 0) {
542498
+ log.info('');
542499
+ log.info((0, i18n_1.t)('💡 下一步:'));
542500
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
542501
+ log.info((0, i18n_1.t)(' • 访问网站: https://{{cdnDomain}}', { cdnDomain: website.cdnDomain }));
542502
+ }
541137
542503
  });
541138
542504
  }
541139
542505
  };
@@ -541156,46 +542522,144 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
541156
542522
  cmd: 'hosting',
541157
542523
  childCmd: 'delete [cloudPath]',
541158
542524
  deprecateCmd: 'hosting:delete [cloudPath]',
541159
- options: [{
542525
+ options: [
542526
+ {
542527
+ flags: '-e, --env-id <envId>',
542528
+ desc: (0, i18n_1.t)('环境 ID'),
542529
+ deprecatedName: 'envId'
542530
+ },
542531
+ {
541160
542532
  flags: '-d, --dir',
541161
542533
  desc: (0, i18n_1.t)('删除目标是否为文件夹')
542534
+ },
542535
+ {
542536
+ flags: '--dry-run',
542537
+ desc: (0, i18n_1.t)('预览要删除的文件,不实际执行删除')
541162
542538
  }
541163
542539
  ],
541164
- desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项')
542540
+ requiredEnvId: false,
542541
+ autoRunLogin: true,
542542
+ desc: (0, i18n_1.t)('删除静态网站文件/文件夹,文件夹需指定 --dir 选项'),
542543
+ examples: [
542544
+ 'tcb hosting delete path/to/file',
542545
+ 'tcb hosting delete path/to/dir --dir',
542546
+ 'tcb hosting delete --dry-run --env-id env-xxx',
542547
+ 'tcb hosting delete --env-id env-xxx --yes'
542548
+ ],
542549
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541165
542550
  };
541166
542551
  }
541167
- execute(envId, options, params) {
542552
+ execute(envId, options, params, log) {
541168
542553
  return __awaiter(this, void 0, void 0, function* () {
542554
+ let selectedEnvId = envId;
542555
+ if (!selectedEnvId) {
542556
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
542557
+ }
541169
542558
  const cloudPath = (params === null || params === void 0 ? void 0 : params[0]) || '';
541170
542559
  let isDir = options.dir;
542560
+ const isDryRun = options.dryRun;
542561
+ if (cloudPath === '/') {
542562
+ isDir = true;
542563
+ }
542564
+ const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
542565
+ if (isDryRun) {
542566
+ const loading = (0, utils_2.loadingFactory)();
542567
+ loading.start((0, i18n_1.t)('预览要删除的文件...'));
542568
+ try {
542569
+ const list = yield (0, hosting_1.hostingList)({
542570
+ envId: selectedEnvId
542571
+ });
542572
+ const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
542573
+ const targetFiles = list.filter(notDir).filter((item) => {
542574
+ if (!cloudPath)
542575
+ return true;
542576
+ if (isDir) {
542577
+ return item.Key.startsWith(cloudPath.replace(/\/$/, '') + '/');
542578
+ }
542579
+ return item.Key === cloudPath || item.Key.startsWith(cloudPath + '/');
542580
+ });
542581
+ loading.stop();
542582
+ if ((0, utils_2.isJsonOutput)()) {
542583
+ (0, utils_2.outputJson)(targetFiles.map((item) => ({
542584
+ key: item.Key,
542585
+ size: item.Size,
542586
+ lastModified: item.LastModified
542587
+ })), { total: targetFiles.length, action: 'delete', dryRun: true });
542588
+ return;
542589
+ }
542590
+ if (targetFiles.length === 0) {
542591
+ log.warn((0, i18n_1.t)('没有找到匹配的文件'));
542592
+ return;
542593
+ }
542594
+ log.info((0, i18n_1.t)('将删除以下 {{count}} 个文件:', { count: targetFiles.length }));
542595
+ log.info('');
542596
+ const head = [(0, i18n_1.t)('Key'), (0, i18n_1.t)('Size'), (0, i18n_1.t)('LastModified')];
542597
+ const tableData = targetFiles.map((item) => [
542598
+ item.Key,
542599
+ (0, utils_2.formateFileSize)(item.Size, 'KB'),
542600
+ (0, utils_2.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss')
542601
+ ]);
542602
+ (0, utils_2.printHorizontalTable)(head, tableData);
542603
+ log.info('');
542604
+ log.info((0, i18n_1.t)('💡 运行 tcb hosting delete {{cloudPath}} --yes 执行删除', { cloudPath }));
542605
+ }
542606
+ catch (e) {
542607
+ loading.fail((0, i18n_1.t)('预览失败'));
542608
+ throw new error_1.CloudBaseError({
542609
+ message: e.message,
542610
+ code: 'DRY_RUN_FAILED',
542611
+ original: e,
542612
+ solution: [
542613
+ '检查环境 ID 是否正确',
542614
+ '检查静态托管服务是否已开通'
542615
+ ]
542616
+ });
542617
+ }
542618
+ return;
542619
+ }
541171
542620
  if (!cloudPath) {
541172
542621
  const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'), false);
541173
542622
  if (!confirm) {
541174
- throw new error_1.CloudBaseError((0, i18n_1.t)('操作终止!'));
542623
+ throw new error_1.CloudBaseError({
542624
+ message: (0, i18n_1.t)('操作终止!'),
542625
+ code: 'OPERATION_CANCELLED',
542626
+ solution: ['指定要删除的云端路径,如: tcb hosting delete path/to/file']
542627
+ });
541175
542628
  }
541176
542629
  isDir = true;
541177
542630
  }
541178
- if (cloudPath === '/') {
541179
- isDir = true;
542631
+ const loading = (0, utils_2.loadingFactory)();
542632
+ if (!(0, utils_2.isJsonOutput)()) {
542633
+ loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
541180
542634
  }
541181
- const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
541182
- const loading = (0, utils_1.loadingFactory)();
541183
- loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
541184
542635
  try {
541185
542636
  yield (0, hosting_1.hostingDelete)({
541186
- envId,
542637
+ envId: selectedEnvId,
541187
542638
  isDir,
541188
542639
  cloudPath
541189
542640
  });
541190
542641
  loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
541191
- if ((0, utils_1.isJsonOutput)()) {
541192
- (0, utils_1.outputJson)({ message: `删除${fileText}成功` });
542642
+ if ((0, utils_2.isJsonOutput)()) {
542643
+ (0, utils_2.outputJson)({ message: `删除${fileText}成功` });
541193
542644
  return;
541194
542645
  }
542646
+ log.info('');
542647
+ log.info((0, i18n_1.t)('💡 下一步:'));
542648
+ log.info((0, i18n_1.t)(' • 查看文件: tcb hosting list'));
542649
+ log.info((0, i18n_1.t)(' • 重新部署: tcb hosting deploy'));
541195
542650
  }
541196
542651
  catch (e) {
541197
542652
  loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
541198
- throw new error_1.CloudBaseError(e.message);
542653
+ throw new error_1.CloudBaseError({
542654
+ message: e.message,
542655
+ code: 'DELETE_FILE_FAILED',
542656
+ original: e,
542657
+ solution: [
542658
+ '检查环境 ID 是否正确',
542659
+ '检查网络连接是否正常',
542660
+ '确认文件/文件夹是否存在'
542661
+ ]
542662
+ });
541199
542663
  }
541200
542664
  });
541201
542665
  }
@@ -541205,8 +542669,9 @@ __decorate([
541205
542669
  __param(0, (0, decorators_1.EnvId)()),
541206
542670
  __param(1, (0, decorators_1.ArgsOptions)()),
541207
542671
  __param(2, (0, decorators_1.ArgsParams)()),
542672
+ __param(3, (0, decorators_1.Log)()),
541208
542673
  __metadata("design:type", Function),
541209
- __metadata("design:paramtypes", [Object, Object, Object]),
542674
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
541210
542675
  __metadata("design:returntype", Promise)
541211
542676
  ], HostingDeleteFiles.prototype, "execute", null);
541212
542677
  HostingDeleteFiles = __decorate([
@@ -541219,47 +542684,97 @@ let HostingList = class HostingList extends common_1.Command {
541219
542684
  cmd: 'hosting',
541220
542685
  childCmd: 'list',
541221
542686
  deprecateCmd: 'hosting:list',
541222
- options: [],
542687
+ options: [
542688
+ {
542689
+ flags: '-e, --env-id <envId>',
542690
+ desc: (0, i18n_1.t)('环境 ID'),
542691
+ deprecatedName: 'envId'
542692
+ },
542693
+ {
542694
+ flags: '-l, --limit <n>',
542695
+ desc: (0, i18n_1.t)('返回条数上限'),
542696
+ default: 50
542697
+ },
542698
+ {
542699
+ flags: '--offset <n>',
542700
+ desc: (0, i18n_1.t)('跳过条数'),
542701
+ default: 0
542702
+ }
542703
+ ],
542704
+ requiredEnvId: false,
542705
+ autoRunLogin: true,
541223
542706
  desc: (0, i18n_1.t)('展示文件列表'),
541224
- examples: ['tcb hosting list'],
542707
+ examples: [
542708
+ 'tcb hosting list',
542709
+ 'tcb hosting list --limit 10',
542710
+ 'tcb hosting list --json'
542711
+ ],
541225
542712
  seeAlso: ['tcb hosting deploy'],
541226
542713
  docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541227
542714
  };
541228
542715
  }
541229
- execute(envId) {
542716
+ execute(envId, options, log) {
541230
542717
  return __awaiter(this, void 0, void 0, function* () {
541231
- const loading = (0, utils_1.loadingFactory)();
542718
+ let selectedEnvId = envId;
542719
+ if (!selectedEnvId) {
542720
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
542721
+ }
542722
+ const limit = Number(options.limit) || 50;
542723
+ const offset = Number(options.offset) || 0;
542724
+ const loading = (0, utils_2.loadingFactory)();
541232
542725
  loading.start((0, i18n_1.t)('获取文件列表中...'));
541233
542726
  try {
541234
542727
  const list = yield (0, hosting_1.hostingList)({
541235
- envId
542728
+ envId: selectedEnvId
541236
542729
  });
541237
542730
  loading.stop();
541238
542731
  const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
541239
- if ((0, utils_1.isJsonOutput)()) {
541240
- (0, utils_1.outputJson)(list.filter(notDir).map((item) => ({
542732
+ const allFiles = list.filter(notDir);
542733
+ const total = allFiles.length;
542734
+ const paginatedFiles = allFiles.slice(offset, offset + limit);
542735
+ if ((0, utils_2.isJsonOutput)()) {
542736
+ (0, utils_2.outputJson)(paginatedFiles.map((item) => ({
541241
542737
  key: item.Key,
541242
542738
  lastModified: item.LastModified,
541243
542739
  eTag: item.ETag,
541244
542740
  size: item.Size
541245
- })));
542741
+ })), { total, limit, offset });
542742
+ return;
542743
+ }
542744
+ if (paginatedFiles.length === 0) {
542745
+ log.warn((0, i18n_1.t)('没有找到文件'));
541246
542746
  return;
541247
542747
  }
541248
542748
  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)')];
541249
- const tableData = list
541250
- .filter(notDir)
541251
- .map((item, index) => [
541252
- index + 1,
542749
+ const tableData = paginatedFiles.map((item, index) => [
542750
+ offset + index + 1,
541253
542751
  item.Key,
541254
- (0, utils_1.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
542752
+ (0, utils_2.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
541255
542753
  item.ETag,
541256
- String((0, utils_1.formateFileSize)(item.Size, 'KB'))
542754
+ String((0, utils_2.formateFileSize)(item.Size, 'KB'))
541257
542755
  ]);
541258
- (0, utils_1.printHorizontalTable)(head, tableData);
542756
+ (0, utils_2.printHorizontalTable)(head, tableData);
542757
+ if (total > limit) {
542758
+ log.info('');
542759
+ log.info((0, i18n_1.t)('显示 {{count}}/{{total}} 条,使用 --offset {{next}} 查看更多', {
542760
+ count: paginatedFiles.length,
542761
+ total,
542762
+ next: offset + limit
542763
+ }));
542764
+ }
541259
542765
  }
541260
542766
  catch (e) {
541261
542767
  loading.fail((0, i18n_1.t)('获取文件列表失败!'));
541262
- throw new error_1.CloudBaseError(e.message);
542768
+ throw new error_1.CloudBaseError({
542769
+ message: e.message,
542770
+ code: 'LIST_FILE_FAILED',
542771
+ original: e,
542772
+ solution: [
542773
+ '检查环境 ID 是否正确',
542774
+ '检查静态托管服务是否已开通',
542775
+ '运行 tcb hosting detail 确认服务状态'
542776
+ ]
542777
+ });
541263
542778
  }
541264
542779
  });
541265
542780
  }
@@ -541267,8 +542782,10 @@ let HostingList = class HostingList extends common_1.Command {
541267
542782
  __decorate([
541268
542783
  (0, decorators_1.InjectParams)(),
541269
542784
  __param(0, (0, decorators_1.EnvId)()),
542785
+ __param(1, (0, decorators_1.ArgsOptions)()),
542786
+ __param(2, (0, decorators_1.Log)()),
541270
542787
  __metadata("design:type", Function),
541271
- __metadata("design:paramtypes", [Object]),
542788
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
541272
542789
  __metadata("design:returntype", Promise)
541273
542790
  ], HostingList.prototype, "execute", null);
541274
542791
  HostingList = __decorate([
@@ -541280,23 +542797,41 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
541280
542797
  return {
541281
542798
  cmd: 'hosting',
541282
542799
  childCmd: 'download <cloudPath> [localPath]',
541283
- options: [{
542800
+ options: [
542801
+ {
542802
+ flags: '-e, --env-id <envId>',
542803
+ desc: (0, i18n_1.t)('环境 ID'),
542804
+ deprecatedName: 'envId'
542805
+ },
542806
+ {
541284
542807
  flags: '-d, --dir',
541285
542808
  desc: (0, i18n_1.t)('下载目标是否为文件夹')
541286
542809
  }
541287
542810
  ],
541288
- desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项')
542811
+ requiredEnvId: false,
542812
+ autoRunLogin: true,
542813
+ desc: (0, i18n_1.t)('下载文件/文件夹,文件夹需指定 --dir 选项'),
542814
+ examples: [
542815
+ 'tcb hosting download path/to/file.txt',
542816
+ 'tcb hosting download path/to/dir ./local --dir',
542817
+ 'tcb hosting download path/to/file --env-id env-xxx'
542818
+ ],
542819
+ docs: ['https://docs.cloudbase.net/cli-v1/hosting']
541289
542820
  };
541290
542821
  }
541291
- execute(envId, options, params) {
542822
+ execute(envId, options, params, log) {
541292
542823
  return __awaiter(this, void 0, void 0, function* () {
542824
+ let selectedEnvId = envId;
542825
+ if (!selectedEnvId) {
542826
+ selectedEnvId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
542827
+ }
541293
542828
  let cloudPath = params === null || params === void 0 ? void 0 : params[0];
541294
542829
  const localPath = (params === null || params === void 0 ? void 0 : params[1]) || '.';
541295
- const hostingService = yield getHostingService(envId);
542830
+ const hostingService = yield getHostingService(selectedEnvId);
541296
542831
  const resolveLocalPath = path_1.default.resolve(localPath);
541297
542832
  const { dir } = options;
541298
542833
  const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
541299
- const loading = (0, utils_1.loadingFactory)();
542834
+ const loading = (0, utils_2.loadingFactory)();
541300
542835
  loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
541301
542836
  if (/^\/.+/.test(cloudPath)) {
541302
542837
  cloudPath = cloudPath.slice(1);
@@ -541314,9 +542849,14 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
541314
542849
  });
541315
542850
  }
541316
542851
  loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
541317
- if ((0, utils_1.isJsonOutput)()) {
541318
- (0, utils_1.outputJson)({ message: `下载${fileText}成功` });
542852
+ if ((0, utils_2.isJsonOutput)()) {
542853
+ (0, utils_2.outputJson)({ message: `下载${fileText}成功`, localPath: resolveLocalPath });
542854
+ return;
541319
542855
  }
542856
+ log.info('');
542857
+ log.info((0, i18n_1.t)('💡 下一步:'));
542858
+ log.info((0, i18n_1.t)(' • 查看文件: ls {{path}}', { path: resolveLocalPath }));
542859
+ log.info((0, i18n_1.t)(' • 编辑后重新部署: tcb hosting deploy'));
541320
542860
  });
541321
542861
  }
541322
542862
  };
@@ -541325,8 +542865,9 @@ __decorate([
541325
542865
  __param(0, (0, decorators_1.EnvId)()),
541326
542866
  __param(1, (0, decorators_1.ArgsOptions)()),
541327
542867
  __param(2, (0, decorators_1.ArgsParams)()),
542868
+ __param(3, (0, decorators_1.Log)()),
541328
542869
  __metadata("design:type", Function),
541329
- __metadata("design:paramtypes", [Object, Object, Object]),
542870
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
541330
542871
  __metadata("design:returntype", Promise)
541331
542872
  ], HostingDownloadCommand.prototype, "execute", null);
541332
542873
  HostingDownloadCommand = __decorate([
@@ -542597,29 +544138,6 @@ exports.CreateFileLayer = CreateFileLayer;
542597
544138
 
542598
544139
  "use strict";
542599
544140
 
542600
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
542601
- if (k2 === undefined) k2 = k;
542602
- var desc = Object.getOwnPropertyDescriptor(m, k);
542603
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
542604
- desc = { enumerable: true, get: function() { return m[k]; } };
542605
- }
542606
- Object.defineProperty(o, k2, desc);
542607
- }) : (function(o, m, k, k2) {
542608
- if (k2 === undefined) k2 = k;
542609
- o[k2] = m[k];
542610
- }));
542611
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
542612
- Object.defineProperty(o, "default", { enumerable: true, value: v });
542613
- }) : function(o, v) {
542614
- o["default"] = v;
542615
- });
542616
- var __importStar = (this && this.__importStar) || function (mod) {
542617
- if (mod && mod.__esModule) return mod;
542618
- var result = {};
542619
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
542620
- __setModuleDefault(result, mod);
542621
- return result;
542622
- };
542623
544141
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
542624
544142
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
542625
544143
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -542638,14 +544156,11 @@ const fs_1 = __importDefault(__webpack_require__(79896));
542638
544156
  const os_1 = __importDefault(__webpack_require__(70857));
542639
544157
  const path_1 = __importDefault(__webpack_require__(16928));
542640
544158
  const chalk_1 = __importDefault(__webpack_require__(15896));
542641
- const interactive_1 = __webpack_require__(57695);
542642
- const framework_core_1 = __webpack_require__(50594);
542643
544159
  const toolbox_1 = __webpack_require__(25901);
542644
544160
  const utils_1 = __webpack_require__(82079);
542645
- const Hosting = __importStar(__webpack_require__(2767));
542646
- const Function = __importStar(__webpack_require__(11686));
542647
544161
  const auth_1 = __webpack_require__(73052);
542648
544162
  const i18n_1 = __webpack_require__(69258);
544163
+ const deploy_1 = __webpack_require__(98681);
542649
544164
  function smartDeploy() {
542650
544165
  return __awaiter(this, void 0, void 0, function* () {
542651
544166
  const loading = (0, utils_1.loadingFactory)();
@@ -542669,10 +544184,7 @@ function smartDeploy() {
542669
544184
  yield (0, utils_1.initProjectConfig)(envId, region, projectPath);
542670
544185
  utils_1.logger.success((0, i18n_1.t)('初始化项目成功!\n'));
542671
544186
  }
542672
- const setup = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('是否使用云开发部署当前项目 <{{path}}> ?', { path: chalk_1.default.bold.cyan(relative) }), true);
542673
- if (!setup) {
542674
- return;
542675
- }
544187
+ utils_1.logger.info(chalk_1.default.gray((0, i18n_1.t)('项目目录: {{path}}', { path: relative })));
542676
544188
  const config = yield (0, utils_1.getCloudBaseConfig)();
542677
544189
  let envId = config === null || config === void 0 ? void 0 : config.envId;
542678
544190
  if (!(config === null || config === void 0 ? void 0 : config.region) && !region) {
@@ -542689,32 +544201,13 @@ function smartDeploy() {
542689
544201
  }
542690
544202
  const parser = new toolbox_1.ConfigParser();
542691
544203
  parser.update('region', region);
542692
- yield callFramework(envId);
544204
+ const ctx = {
544205
+ globalOptions: {}
544206
+ };
544207
+ yield (0, deploy_1.executeAppDeploy)(ctx, [], utils_1.logger);
542693
544208
  });
542694
544209
  }
542695
544210
  exports.smartDeploy = smartDeploy;
542696
- function callFramework(envId) {
542697
- return __awaiter(this, void 0, void 0, function* () {
542698
- const loginState = yield utils_1.authSupevisor.getLoginState();
542699
- const { token, secretId, secretKey } = loginState;
542700
- const config = yield (0, utils_1.getCloudBaseConfig)();
542701
- yield (0, framework_core_1.run)({
542702
- projectPath: process.cwd(),
542703
- cloudbaseConfig: {
542704
- secretId,
542705
- secretKey,
542706
- token,
542707
- envId
542708
- },
542709
- config,
542710
- logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
542711
- resourceProviders: {
542712
- hosting: Hosting,
542713
- function: Function
542714
- }
542715
- }, 'deploy', '');
542716
- });
542717
- }
542718
544211
 
542719
544212
 
542720
544213
  /***/ }),
@@ -550429,7 +551922,7 @@ let NosqlExecuteCommand = class NosqlExecuteCommand extends common_1.Command {
550429
551922
  common_2.databaseNameOption,
550430
551923
  common_2.jsonOption
550431
551924
  ],
550432
- desc: (0, i18n_1.t)('执行文档型数据库命令'),
551925
+ 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',
550433
551926
  requiredEnvId: false,
550434
551927
  autoRunLogin: true
550435
551928
  };
@@ -586104,14 +587597,62 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
586104
587597
  };
586105
587598
  Object.defineProperty(exports, "__esModule", ({ value: true }));
586106
587599
  exports.LogService = void 0;
587600
+ exports.isLogServiceEnabled = isLogServiceEnabled;
586107
587601
  const utils_1 = __webpack_require__(62358);
586108
587602
  __exportStar(__webpack_require__(83700), exports);
587603
+ /**
587604
+ * 纯函数:根据 DescribeEnvs 返回的 LogServices 列表判断日志服务是否已开通。
587605
+ * 已开通条件:至少一个条目有有效的 TopicId。
587606
+ */
587607
+ function isLogServiceEnabled(logServices) {
587608
+ if (!logServices || logServices.length === 0)
587609
+ return false;
587610
+ return logServices.some(svc => !!svc.TopicId);
587611
+ }
586109
587612
  class LogService {
586110
587613
  constructor(environment) {
586111
587614
  this.envId = environment.getEnvId();
586112
587615
  this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
586113
587616
  this.tcbrService = new utils_1.CloudService(environment.cloudBaseContext, 'tcbr', '2022-02-17');
586114
587617
  }
587618
+ /**
587619
+ * 检查当前环境的日志服务是否已开通
587620
+ *
587621
+ * 通过 DescribeEnvs 接口获取环境信息,判断 LogServices 字段中是否包含有效的
587622
+ * 日志主题(TopicId 不为空)。
587623
+ *
587624
+ * @returns true 表示已开通,false 表示未开通或开通中
587625
+ */
587626
+ async checkLogServiceEnabled() {
587627
+ var _a;
587628
+ const res = await this.cloudService.request('DescribeEnvs', {
587629
+ EnvId: this.envId
587630
+ });
587631
+ const envInfo = (_a = res === null || res === void 0 ? void 0 : res.EnvList) === null || _a === void 0 ? void 0 : _a[0];
587632
+ if (!envInfo) {
587633
+ return false;
587634
+ }
587635
+ const logServices = envInfo.LogServices;
587636
+ if (!logServices || logServices.length === 0) {
587637
+ return false;
587638
+ }
587639
+ // 已开通:LogServiceInfo 中存在有效的日志主题 ID
587640
+ return isLogServiceEnabled(logServices);
587641
+ }
587642
+ /**
587643
+ * 开通环境日志服务(异步操作)
587644
+ *
587645
+ * 调用 CreateEnvResource 接口开通日志资源。
587646
+ * 注意:接口调用成功不代表日志资源立即可用,需通过 checkLogServiceEnabled() 轮询确认。
587647
+ *
587648
+ * @returns 请求 ID
587649
+ */
587650
+ async createLogService() {
587651
+ return this.cloudService.request('CreateEnvResource', {
587652
+ EnvId: this.envId,
587653
+ Resources: ['log']
587654
+ });
587655
+ }
586115
587656
  /**
586116
587657
  * 搜索 CLS 日志
586117
587658
  *
@@ -596338,6 +597879,7 @@ __exportStar(__webpack_require__(58430), exports);
596338
597879
  __exportStar(__webpack_require__(38001), exports);
596339
597880
  __exportStar(__webpack_require__(11502), exports);
596340
597881
  __exportStar(__webpack_require__(81106), exports);
597882
+ __exportStar(__webpack_require__(60928), exports);
596341
597883
 
596342
597884
 
596343
597885
  /***/ }),
@@ -600397,6 +601939,38 @@ function dump(input, options) {
600397
601939
  module.exports.dump = dump;
600398
601940
 
600399
601941
 
601942
+ /***/ }),
601943
+
601944
+ /***/ 49637:
601945
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
601946
+
601947
+ "use strict";
601948
+
601949
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
601950
+ if (k2 === undefined) k2 = k;
601951
+ var desc = Object.getOwnPropertyDescriptor(m, k);
601952
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
601953
+ desc = { enumerable: true, get: function() { return m[k]; } };
601954
+ }
601955
+ Object.defineProperty(o, k2, desc);
601956
+ }) : (function(o, m, k, k2) {
601957
+ if (k2 === undefined) k2 = k;
601958
+ o[k2] = m[k];
601959
+ }));
601960
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
601961
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
601962
+ };
601963
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
601964
+ exports.getCloudAppService = exports.deployCloudApp = exports.detectFramework = void 0;
601965
+ var framework_detector_1 = __webpack_require__(18508);
601966
+ Object.defineProperty(exports, "detectFramework", ({ enumerable: true, get: function () { return framework_detector_1.detectFramework; } }));
601967
+ var deploy_1 = __webpack_require__(85182);
601968
+ Object.defineProperty(exports, "deployCloudApp", ({ enumerable: true, get: function () { return deploy_1.deployCloudApp; } }));
601969
+ var service_1 = __webpack_require__(94054);
601970
+ Object.defineProperty(exports, "getCloudAppService", ({ enumerable: true, get: function () { return service_1.getCloudAppService; } }));
601971
+ __exportStar(__webpack_require__(14764), exports);
601972
+
601973
+
600400
601974
  /***/ }),
600401
601975
 
600402
601976
  /***/ 49653:
@@ -630829,6 +632403,20 @@ function outputJsonSync (file, data, options) {
630829
632403
  module.exports = outputJsonSync
630830
632404
 
630831
632405
 
632406
+ /***/ }),
632407
+
632408
+ /***/ 55046:
632409
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
632410
+
632411
+ "use strict";
632412
+
632413
+
632414
+ var toInteger = __webpack_require__(49806)
632415
+ , max = Math.max;
632416
+
632417
+ module.exports = function (value) { return max(0, toInteger(value)); };
632418
+
632419
+
630832
632420
  /***/ }),
630833
632421
 
630834
632422
  /***/ 55112:
@@ -648299,6 +649887,13 @@ let LogSearchCommand = class LogSearchCommand extends common_1.Command {
648299
649887
  }
648300
649888
  try {
648301
649889
  const logService = yield (0, utils_3.getLogService)(selectedEnvId);
649890
+ if (!jsonOutput) {
649891
+ loading.stop();
649892
+ }
649893
+ yield (0, utils_3.ensureLogServiceEnabled)(logService, log, { jsonOutput });
649894
+ if (!jsonOutput) {
649895
+ loading.start((0, i18n_1.t)('正在检索日志...'));
649896
+ }
648302
649897
  const result = yield logService.searchClsLog({
648303
649898
  queryString,
648304
649899
  StartTime: startTime,
@@ -648357,6 +649952,9 @@ let LogSearchCommand = class LogSearchCommand extends common_1.Command {
648357
649952
  if (!jsonOutput) {
648358
649953
  loading.fail((0, i18n_1.t)('日志检索失败'));
648359
649954
  }
649955
+ if (e instanceof error_1.CloudBaseError) {
649956
+ throw e;
649957
+ }
648360
649958
  throw new error_1.CloudBaseError({
648361
649959
  message: (0, i18n_1.t)('日志检索失败:{{msg}}', {
648362
649960
  msg: e instanceof Error ? e.message : String(e)
@@ -664886,6 +666484,8 @@ const access_1 = __webpack_require__(70427);
664886
666484
  const user_1 = __webpack_require__(71858);
664887
666485
  const cloudBaseRun_1 = __webpack_require__(24344);
664888
666486
  const mysql_1 = __webpack_require__(61697);
666487
+ const cloudApp_1 = __webpack_require__(32665);
666488
+ const permission_1 = __webpack_require__(24786);
664889
666489
  class Environment {
664890
666490
  constructor(context, envId) {
664891
666491
  this.inited = false;
@@ -664907,6 +666507,8 @@ class Environment {
664907
666507
  this.userService = new user_1.UserService(this);
664908
666508
  this.cloudBaseRunService = new cloudBaseRun_1.CloudBaseRunService(this);
664909
666509
  this.mysqlService = new mysql_1.MysqlService(this);
666510
+ this.permissionService = new permission_1.PermissionService(this);
666511
+ this.cloudAppService = new cloudApp_1.CloudAppService(this);
664910
666512
  }
664911
666513
  async lazyInit() {
664912
666514
  if (!this.inited) {
@@ -664969,6 +666571,12 @@ class Environment {
664969
666571
  getMysqlService() {
664970
666572
  return this.mysqlService;
664971
666573
  }
666574
+ getCloudAppService() {
666575
+ return this.cloudAppService;
666576
+ }
666577
+ getPermissionService() {
666578
+ return this.permissionService;
666579
+ }
664972
666580
  getCommonService(serviceType = 'tcb', serviceVersion) {
664973
666581
  return new common_1.CommonService(this, serviceType, serviceVersion);
664974
666582
  }
@@ -679392,6 +681000,35 @@ NodejsStreamInputAdapter.prototype.resume = function () {
679392
681000
  module.exports = NodejsStreamInputAdapter;
679393
681001
 
679394
681002
 
681003
+ /***/ }),
681004
+
681005
+ /***/ 60928:
681006
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
681007
+
681008
+ "use strict";
681009
+
681010
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
681011
+ if (k2 === undefined) k2 = k;
681012
+ var desc = Object.getOwnPropertyDescriptor(m, k);
681013
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
681014
+ desc = { enumerable: true, get: function() { return m[k]; } };
681015
+ }
681016
+ Object.defineProperty(o, k2, desc);
681017
+ }) : (function(o, m, k, k2) {
681018
+ if (k2 === undefined) k2 = k;
681019
+ o[k2] = m[k];
681020
+ }));
681021
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
681022
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
681023
+ };
681024
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
681025
+ __exportStar(__webpack_require__(98681), exports);
681026
+ __exportStar(__webpack_require__(20666), exports);
681027
+ __exportStar(__webpack_require__(7102), exports);
681028
+ __exportStar(__webpack_require__(6563), exports);
681029
+ __exportStar(__webpack_require__(83277), exports);
681030
+
681031
+
679395
681032
  /***/ }),
679396
681033
 
679397
681034
  /***/ 60973:
@@ -684684,7 +686321,8 @@ function checkParentPathsSync (src, srcStat, dest, funcName) {
684684
686321
  }
684685
686322
 
684686
686323
  function areIdentical (srcStat, destStat) {
684687
- return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
686324
+ // stat.dev can be 0n on windows when node version >= 22.x.x
686325
+ return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
684688
686326
  }
684689
686327
 
684690
686328
  // return true if dest is a subdir of src, otherwise false.
@@ -700723,6 +702361,43 @@ class CloudBaseError extends Error {
700723
702361
  exports.CloudBaseError = CloudBaseError;
700724
702362
 
700725
702363
 
702364
+ /***/ }),
702365
+
702366
+ /***/ 64129:
702367
+ /***/ ((module) => {
702368
+
702369
+ "use strict";
702370
+
702371
+
702372
+ // https://github.com/jprichardson/node-fs-extra/issues/1056
702373
+ // Performing parallel operations on each item of an async iterator is
702374
+ // surprisingly hard; you need to have handlers in place to avoid getting an
702375
+ // UnhandledPromiseRejectionWarning.
702376
+ // NOTE: This function does not presently handle return values, only errors
702377
+ async function asyncIteratorConcurrentProcess (iterator, fn) {
702378
+ const promises = []
702379
+ for await (const item of iterator) {
702380
+ promises.push(
702381
+ fn(item).then(
702382
+ () => null,
702383
+ (err) => err ?? new Error('unknown error')
702384
+ )
702385
+ )
702386
+ }
702387
+ await Promise.all(
702388
+ promises.map((promise) =>
702389
+ promise.then((possibleErr) => {
702390
+ if (possibleErr !== null) throw possibleErr
702391
+ })
702392
+ )
702393
+ )
702394
+ }
702395
+
702396
+ module.exports = {
702397
+ asyncIteratorConcurrentProcess
702398
+ }
702399
+
702400
+
700726
702401
  /***/ }),
700727
702402
 
700728
702403
  /***/ 64179:
@@ -711237,7 +712912,7 @@ module.exports = {
711237
712912
  var iteratorSymbol = (__webpack_require__(72380).iterator)
711238
712913
  , isArguments = __webpack_require__(28746)
711239
712914
  , isFunction = __webpack_require__(92840)
711240
- , toPosInt = __webpack_require__(32665)
712915
+ , toPosInt = __webpack_require__(55046)
711241
712916
  , callable = __webpack_require__(25499)
711242
712917
  , validValue = __webpack_require__(67134)
711243
712918
  , isValue = __webpack_require__(89762)
@@ -731364,7 +733039,7 @@ module.exports = pipeline;
731364
733039
  "use strict";
731365
733040
 
731366
733041
 
731367
- var toPosInt = __webpack_require__(32665)
733042
+ var toPosInt = __webpack_require__(55046)
731368
733043
  , value = __webpack_require__(67134)
731369
733044
  , slice = Array.prototype.slice;
731370
733045
 
@@ -765688,7 +767363,7 @@ module.exports = from;
765688
767363
  "use strict";
765689
767364
 
765690
767365
 
765691
- var toPosInt = __webpack_require__(32665);
767366
+ var toPosInt = __webpack_require__(55046);
765692
767367
 
765693
767368
  var test = function (arg1, arg2) { return arg2; };
765694
767369
 
@@ -818578,6 +820253,115 @@ function createBaseFor(fromRight) {
818578
820253
  module.exports = createBaseFor;
818579
820254
 
818580
820255
 
820256
+ /***/ }),
820257
+
820258
+ /***/ 83277:
820259
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
820260
+
820261
+ "use strict";
820262
+
820263
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
820264
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
820265
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
820266
+ 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;
820267
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
820268
+ };
820269
+ var __metadata = (this && this.__metadata) || function (k, v) {
820270
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
820271
+ };
820272
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
820273
+ return function (target, key) { decorator(target, key, paramIndex); }
820274
+ };
820275
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
820276
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
820277
+ return new (P || (P = Promise))(function (resolve, reject) {
820278
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
820279
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
820280
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
820281
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
820282
+ });
820283
+ };
820284
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
820285
+ exports.AppDelete = void 0;
820286
+ const common_1 = __webpack_require__(48431);
820287
+ const decorators_1 = __webpack_require__(93480);
820288
+ const utils_1 = __webpack_require__(82079);
820289
+ const interactive_1 = __webpack_require__(57695);
820290
+ const utils_2 = __webpack_require__(75213);
820291
+ const constant_1 = __webpack_require__(62977);
820292
+ const i18n_1 = __webpack_require__(69258);
820293
+ const error_1 = __webpack_require__(66759);
820294
+ let AppDelete = class AppDelete extends common_1.Command {
820295
+ get options() {
820296
+ return {
820297
+ cmd: 'app',
820298
+ childCmd: 'delete <serviceName>',
820299
+ options: [],
820300
+ desc: (0, i18n_1.t)('删除云应用及其所有版本'),
820301
+ requiredEnvId: false,
820302
+ autoRunLogin: true,
820303
+ examples: ['tcb app delete my-app --env-id env-xxx'],
820304
+ seeAlso: ['tcb app list'],
820305
+ docs: ['https://docs.cloudbase.net/cli/app/delete']
820306
+ };
820307
+ }
820308
+ execute(envId, params, log) {
820309
+ return __awaiter(this, void 0, void 0, function* () {
820310
+ let selectedEnvId = envId;
820311
+ if (!selectedEnvId) {
820312
+ selectedEnvId = yield (0, utils_2.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
820313
+ }
820314
+ const serviceName = params === null || params === void 0 ? void 0 : params[0];
820315
+ if (!serviceName) {
820316
+ throw new error_1.CloudBaseError({
820317
+ message: (0, i18n_1.t)('请指定服务名称'),
820318
+ code: 'MISSING_PARAM',
820319
+ solution: [(0, i18n_1.t)('示例: tcb app delete my-app --env-id env-xxx')]
820320
+ });
820321
+ }
820322
+ const confirmed = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('确定要删除云应用 {{name}} 及其所有版本吗?', { name: serviceName }), false);
820323
+ if (!confirmed) {
820324
+ log.info((0, i18n_1.t)('已取消删除操作'));
820325
+ return;
820326
+ }
820327
+ const loading = (0, utils_1.loadingFactory)();
820328
+ loading.start((0, i18n_1.t)('正在删除云应用...'));
820329
+ try {
820330
+ const app = yield (0, utils_1.getMangerService)(selectedEnvId);
820331
+ yield app.cloudAppService.deleteApp({
820332
+ deployType: 'static-hosting',
820333
+ serviceName: serviceName
820334
+ });
820335
+ loading.stop();
820336
+ if ((0, utils_1.isJsonOutput)()) {
820337
+ (0, utils_1.outputJson)({ serviceName, deleted: true });
820338
+ }
820339
+ else {
820340
+ loading.succeed((0, i18n_1.t)('云应用 {{name}} 已删除', { name: serviceName }));
820341
+ }
820342
+ }
820343
+ catch (e) {
820344
+ loading.fail((0, i18n_1.t)('删除失败'));
820345
+ throw e;
820346
+ }
820347
+ });
820348
+ }
820349
+ };
820350
+ __decorate([
820351
+ (0, decorators_1.InjectParams)(),
820352
+ __param(0, (0, decorators_1.EnvId)()),
820353
+ __param(1, (0, decorators_1.ArgsParams)()),
820354
+ __param(2, (0, decorators_1.Log)()),
820355
+ __metadata("design:type", Function),
820356
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
820357
+ __metadata("design:returntype", Promise)
820358
+ ], AppDelete.prototype, "execute", null);
820359
+ AppDelete = __decorate([
820360
+ (0, common_1.ICommand)()
820361
+ ], AppDelete);
820362
+ exports.AppDelete = AppDelete;
820363
+
820364
+
818581
820365
  /***/ }),
818582
820366
 
818583
820367
  /***/ 83283:
@@ -833283,15 +835067,20 @@ function onLink (destStat, src, dest, opts) {
833283
835067
  if (opts.dereference) {
833284
835068
  resolvedDest = path.resolve(process.cwd(), resolvedDest)
833285
835069
  }
833286
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
833287
- throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
833288
- }
835070
+ // If both symlinks resolve to the same target, they are still distinct symlinks
835071
+ // that can be copied/overwritten. Only check subdirectory constraints when
835072
+ // the resolved paths are different.
835073
+ if (resolvedSrc !== resolvedDest) {
835074
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
835075
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
835076
+ }
833289
835077
 
833290
- // prevent copy if src is a subdir of dest since unlinking
833291
- // dest in this case would result in removing src contents
833292
- // and therefore a broken symlink would be created.
833293
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
833294
- throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
835078
+ // prevent copy if src is a subdir of dest since unlinking
835079
+ // dest in this case would result in removing src contents
835080
+ // and therefore a broken symlink would be created.
835081
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
835082
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
835083
+ }
833295
835084
  }
833296
835085
  return copyLink(resolvedSrc, dest)
833297
835086
  }
@@ -834052,6 +835841,226 @@ class Git extends git_base_1.GitBase {
834052
835841
  exports.Git = Git;
834053
835842
  //# sourceMappingURL=git.js.map
834054
835843
 
835844
+ /***/ }),
835845
+
835846
+ /***/ 85182:
835847
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
835848
+
835849
+ "use strict";
835850
+
835851
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
835852
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
835853
+ return new (P || (P = Promise))(function (resolve, reject) {
835854
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
835855
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
835856
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
835857
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
835858
+ });
835859
+ };
835860
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
835861
+ exports.deployCloudApp = void 0;
835862
+ const utils_1 = __webpack_require__(82079);
835863
+ const error_1 = __webpack_require__(66759);
835864
+ const i18n_1 = __webpack_require__(69258);
835865
+ const service_1 = __webpack_require__(94054);
835866
+ const types_1 = __webpack_require__(14764);
835867
+ const time_1 = __webpack_require__(41610);
835868
+ function deployCloudApp(options) {
835869
+ return __awaiter(this, void 0, void 0, function* () {
835870
+ const { envId, serviceName, framework, installCommand, buildCommand, outputDir, deployPath, buildPath = '', projectPath, ignore, envVariables, log } = options;
835871
+ const loading = (0, utils_1.loadingFactory)();
835872
+ try {
835873
+ const cloudAppService = yield (0, service_1.getCloudAppService)(envId);
835874
+ loading.start((0, i18n_1.t)('正在打包并上传代码...'));
835875
+ let uploadResult;
835876
+ try {
835877
+ uploadResult = yield cloudAppService.uploadCode({
835878
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
835879
+ serviceName,
835880
+ localPath: projectPath || process.cwd(),
835881
+ ignore: ignore || []
835882
+ });
835883
+ }
835884
+ catch (e) {
835885
+ if (e instanceof error_1.CloudBaseError)
835886
+ throw e;
835887
+ throw new error_1.CloudBaseError({
835888
+ message: (0, i18n_1.t)('代码上传失败: {{message}}', { message: e.message || String(e) }),
835889
+ code: 'DEPLOY_FAILED',
835890
+ requestId: e.requestId,
835891
+ original: e
835892
+ });
835893
+ }
835894
+ loading.succeed((0, i18n_1.t)('代码上传完成'));
835895
+ loading.start((0, i18n_1.t)('正在创建云应用...'));
835896
+ const staticConfig = {
835897
+ cosTimestamp: uploadResult.unixTimestamp,
835898
+ appPath: deployPath || `/${serviceName}`,
835899
+ buildPath
835900
+ };
835901
+ if (framework)
835902
+ staticConfig.framework = framework;
835903
+ const installCmd = installCommand !== null && installCommand !== void 0 ? installCommand : 'npm install';
835904
+ const buildCmd = buildCommand !== null && buildCommand !== void 0 ? buildCommand : 'npm run build';
835905
+ const resolvedDeployPath = deployPath || `/${serviceName}`;
835906
+ const deployCmd = `tcb hosting deploy ${outputDir || 'dist'} ${resolvedDeployPath}`;
835907
+ staticConfig.staticCmd = {
835908
+ buildCmd,
835909
+ installCmd,
835910
+ deployCmd
835911
+ };
835912
+ if (envVariables && Object.keys(envVariables).length > 0) {
835913
+ staticConfig.staticEnv = {
835914
+ variables: Object.entries(envVariables).map(([key, value]) => ({
835915
+ key,
835916
+ value: String(value)
835917
+ }))
835918
+ };
835919
+ }
835920
+ let createResult;
835921
+ try {
835922
+ createResult = yield cloudAppService.createApp({
835923
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
835924
+ serviceName,
835925
+ buildType: 'ZIP',
835926
+ staticConfig
835927
+ });
835928
+ }
835929
+ catch (e) {
835930
+ if (e instanceof error_1.CloudBaseError)
835931
+ throw e;
835932
+ throw new error_1.CloudBaseError({
835933
+ message: (0, i18n_1.t)('创建云应用失败: {{message}}', { message: e.message || String(e) }),
835934
+ code: 'DEPLOY_FAILED',
835935
+ requestId: e.requestId,
835936
+ original: e
835937
+ });
835938
+ }
835939
+ loading.succeed((0, i18n_1.t)('构建已触发'));
835940
+ const buildId = createResult.BuildId;
835941
+ const versionName = createResult.VersionName;
835942
+ loading.start((0, i18n_1.t)('正在云端构建... (约 3~5 分钟)'));
835943
+ const buildStartTime = Date.now();
835944
+ const buildResult = yield pollBuildStatus(cloudAppService, serviceName, versionName, {
835945
+ log,
835946
+ maxWaitTimeMs: options.maxWaitTimeMs
835947
+ });
835948
+ const wallClockDuration = Math.round((Date.now() - buildStartTime) / 1000);
835949
+ if (buildResult.status === 'FAILED') {
835950
+ loading.fail((0, i18n_1.t)('构建失败'));
835951
+ let errorMessage = (0, i18n_1.t)('云端构建失败');
835952
+ if (buildResult.failReason) {
835953
+ errorMessage += `: ${buildResult.failReason}`;
835954
+ }
835955
+ console.log();
835956
+ if (log) {
835957
+ log.error(errorMessage);
835958
+ }
835959
+ else {
835960
+ console.error(errorMessage);
835961
+ }
835962
+ const consoleUrl = `${utils_1.EUrl.DevPlatform}?envId=${envId}#/cloudapp/detail?serviceName=${serviceName}&tabId=build_log`;
835963
+ const clickableLink = (0, utils_1.genClickableLink)(consoleUrl);
835964
+ throw new error_1.CloudBaseError({
835965
+ message: errorMessage,
835966
+ code: 'BUILD_FAILED',
835967
+ solution: [
835968
+ (0, i18n_1.t)('检查构建命令是否正确: {{cmd}}', { cmd: buildCommand || 'npm run build' }),
835969
+ (0, i18n_1.t)('检查输出目录是否存在: {{dir}}', { dir: outputDir || 'dist' }),
835970
+ (0, i18n_1.t)('检查项目依赖是否完整: npm install'),
835971
+ (0, i18n_1.t)('查看控制台构建日志: {{link}}', { link: clickableLink })
835972
+ ]
835973
+ });
835974
+ }
835975
+ loading.succeed((0, i18n_1.t)('构建成功'));
835976
+ let url = '';
835977
+ try {
835978
+ const appInfo = yield cloudAppService.describeAppInfo({
835979
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
835980
+ serviceName
835981
+ });
835982
+ if (appInfo.Domain) {
835983
+ const domain = appInfo.Domain.replace(/^https?:\/\//, '');
835984
+ url = `https://${domain}/${serviceName}`;
835985
+ }
835986
+ }
835987
+ catch (e) {
835988
+ log === null || log === void 0 ? void 0 : log.verbose((0, i18n_1.t)('获取访问地址失败: {{message}}', { message: String(e) }));
835989
+ }
835990
+ const buildDuration = buildResult.duration && buildResult.duration > 0
835991
+ ? buildResult.duration
835992
+ : wallClockDuration;
835993
+ return {
835994
+ serviceName,
835995
+ versionName,
835996
+ buildId,
835997
+ url,
835998
+ deployTime: new Date().toISOString(),
835999
+ buildDuration
836000
+ };
836001
+ }
836002
+ catch (e) {
836003
+ loading.stop();
836004
+ if (e instanceof error_1.CloudBaseError)
836005
+ throw e;
836006
+ const errMessage = e instanceof Error ? e.message : String(e);
836007
+ throw new error_1.CloudBaseError({
836008
+ message: (0, i18n_1.t)('部署失败: {{message}}', { message: errMessage }),
836009
+ code: 'DEPLOY_FAILED',
836010
+ original: e instanceof Error ? e : undefined
836011
+ });
836012
+ }
836013
+ });
836014
+ }
836015
+ exports.deployCloudApp = deployCloudApp;
836016
+ function pollBuildStatus(cloudAppService, serviceName, versionName, options) {
836017
+ var _a;
836018
+ return __awaiter(this, void 0, void 0, function* () {
836019
+ const interval = (options === null || options === void 0 ? void 0 : options.interval) || 5000;
836020
+ const maxAttempts = (options === null || options === void 0 ? void 0 : options.maxWaitTimeMs)
836021
+ ? Math.ceil(options.maxWaitTimeMs / interval)
836022
+ : ((options === null || options === void 0 ? void 0 : options.maxAttempts) || 60);
836023
+ for (let i = 0; i < maxAttempts; i++) {
836024
+ try {
836025
+ const result = yield cloudAppService.describeAppVersion({
836026
+ deployType: types_1.DEPLOY_TYPE_STATIC_HOSTING,
836027
+ serviceName,
836028
+ versionName
836029
+ });
836030
+ (_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 }));
836031
+ if (result.Status === 'SUCCESS') {
836032
+ return {
836033
+ status: 'SUCCESS',
836034
+ url: result.Domain || result.Url,
836035
+ duration: result.BuildDuration
836036
+ };
836037
+ }
836038
+ if (result.Status === 'FAILED') {
836039
+ return {
836040
+ status: 'FAILED',
836041
+ failReason: result.FailReason
836042
+ };
836043
+ }
836044
+ yield (0, time_1.sleep)(interval);
836045
+ }
836046
+ catch (e) {
836047
+ throw new error_1.CloudBaseError({
836048
+ message: (0, i18n_1.t)('查询构建状态失败: {{message}}', { message: e.message || String(e) }),
836049
+ code: e.code || 'QUERY_BUILD_STATUS_FAILED',
836050
+ requestId: e.requestId,
836051
+ original: e
836052
+ });
836053
+ }
836054
+ }
836055
+ throw new error_1.CloudBaseError({
836056
+ message: (0, i18n_1.t)('构建超时'),
836057
+ code: 'BUILD_TIMEOUT',
836058
+ solution: [(0, i18n_1.t)('请稍后重试或检查云端构建日志')]
836059
+ });
836060
+ });
836061
+ }
836062
+
836063
+
834055
836064
  /***/ }),
834056
836065
 
834057
836066
  /***/ 85248:
@@ -841440,7 +843449,7 @@ exports["default"] = def;
841440
843449
  "use strict";
841441
843450
 
841442
843451
 
841443
- var toPosInt = __webpack_require__(32665)
843452
+ var toPosInt = __webpack_require__(55046)
841444
843453
  , callable = __webpack_require__(25499)
841445
843454
  , value = __webpack_require__(67134)
841446
843455
  , objHasOwnProperty = Object.prototype.hasOwnProperty
@@ -923837,6 +925846,48 @@ function regExpEscape (s) {
923837
925846
  }
923838
925847
 
923839
925848
 
925849
+ /***/ }),
925850
+
925851
+ /***/ 94054:
925852
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
925853
+
925854
+ "use strict";
925855
+
925856
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
925857
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
925858
+ return new (P || (P = Promise))(function (resolve, reject) {
925859
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
925860
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
925861
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
925862
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
925863
+ });
925864
+ };
925865
+ var __importDefault = (this && this.__importDefault) || function (mod) {
925866
+ return (mod && mod.__esModule) ? mod : { "default": mod };
925867
+ };
925868
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
925869
+ exports.getCloudAppService = void 0;
925870
+ const manager_node_1 = __importDefault(__webpack_require__(95492));
925871
+ const net_1 = __webpack_require__(25491);
925872
+ const toolbox_1 = __webpack_require__(25901);
925873
+ function getCloudAppService(envId) {
925874
+ return __awaiter(this, void 0, void 0, function* () {
925875
+ const region = yield (0, toolbox_1.getRegion)();
925876
+ const { secretId, secretKey, token } = yield (0, net_1.checkAndGetCredential)(true);
925877
+ const app = new manager_node_1.default({
925878
+ region,
925879
+ token,
925880
+ envId,
925881
+ secretId,
925882
+ secretKey,
925883
+ proxy: (0, net_1.getProxy)()
925884
+ });
925885
+ return app.cloudAppService;
925886
+ });
925887
+ }
925888
+ exports.getCloudAppService = getCloudAppService;
925889
+
925890
+
923840
925891
  /***/ }),
923841
925892
 
923842
925893
  /***/ 94068:
@@ -937189,6 +939240,9 @@ const outputHelpInfo = () => {
937189
939240
  db [cmd] ${(0, i18n_1.t)('数据库管理操作')}
937190
939241
  agent [cmd] ${(0, i18n_1.t)('Agent 管理操作')}
937191
939242
  logs [cmd] ${(0, i18n_1.t)('日志管理操作')}
939243
+ docs [cmd] ${(0, i18n_1.t)('云开发文档检索操作')}
939244
+ api [cmd] ${(0, i18n_1.t)('通用腾讯云 API 调用操作')}
939245
+ secrets [cmd] ${(0, i18n_1.t)('临时密钥管理操作')}
937192
939246
  `;
937193
939247
  const options = `
937194
939248
  ${(0, i18n_1.t)('选项')}
@@ -944363,9 +946417,34 @@ class CloudBase {
944363
946417
  get mysql() {
944364
946418
  return this.currentEnvironment().getMysqlService();
944365
946419
  }
946420
+ /**
946421
+ * 云托管服务(CloudBaseRun)
946422
+ * 提供云托管版本流量配置等能力
946423
+ * @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
946424
+ */
944366
946425
  get cloudApp() {
944367
946426
  return this.currentEnvironment().getCloudBaseRunService();
944368
946427
  }
946428
+ /**
946429
+ * 云托管服务(CloudBaseRun)
946430
+ * 提供云托管版本流量配置等能力
946431
+ */
946432
+ get cloudBaseRun() {
946433
+ return this.currentEnvironment().getCloudBaseRunService();
946434
+ }
946435
+ /**
946436
+ * 云应用服务(CloudApp 统一部署)
946437
+ * 提供 Web 应用的创建、部署、版本管理等能力
946438
+ */
946439
+ get cloudAppService() {
946440
+ return this.currentEnvironment().getCloudAppService();
946441
+ }
946442
+ /**
946443
+ * 获取云应用服务
946444
+ */
946445
+ getCloudAppService() {
946446
+ return this.currentEnvironment().getCloudAppService();
946447
+ }
944369
946448
  commonService(service, version) {
944370
946449
  return this.currentEnvironment().getCommonService(service, version);
944371
946450
  }
@@ -944381,6 +946460,9 @@ class CloudBase {
944381
946460
  get user() {
944382
946461
  return this.currentEnvironment().getUserService();
944383
946462
  }
946463
+ get permission() {
946464
+ return this.currentEnvironment().getPermissionService();
946465
+ }
944384
946466
  get docs() {
944385
946467
  if (!this.docsService) {
944386
946468
  this.docsService = new docs_1.DocsService();
@@ -955227,12 +957309,96 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
955227
957309
  return (mod && mod.__esModule) ? mod : { "default": mod };
955228
957310
  };
955229
957311
  Object.defineProperty(exports, "__esModule", ({ value: true }));
955230
- exports.safeParseJSON = exports.resolveTimeRange = exports.getLogService = void 0;
957312
+ exports.safeParseJSON = exports.resolveTimeRange = exports.getLogService = exports.ensureLogServiceEnabled = void 0;
955231
957313
  const manager_node_1 = __importDefault(__webpack_require__(95492));
955232
957314
  const toolbox_1 = __webpack_require__(25901);
955233
957315
  const utils_1 = __webpack_require__(82079);
955234
957316
  const error_1 = __webpack_require__(66759);
955235
957317
  const i18n_1 = __webpack_require__(69258);
957318
+ function ensureLogServiceEnabled(logService, log, opts = {}) {
957319
+ return __awaiter(this, void 0, void 0, function* () {
957320
+ const { jsonOutput = false } = opts;
957321
+ let enabled;
957322
+ try {
957323
+ enabled = yield logService.checkLogServiceEnabled();
957324
+ }
957325
+ catch (e) {
957326
+ throw new error_1.CloudBaseError({
957327
+ message: (0, i18n_1.t)('检查日志服务状态失败:{{message}}', { message: e.message || String(e) }),
957328
+ original: e
957329
+ });
957330
+ }
957331
+ if (enabled) {
957332
+ return;
957333
+ }
957334
+ const notEnabledError = new error_1.CloudBaseError({
957335
+ message: (0, i18n_1.t)('日志服务未开通,无法执行日志查询。请开通日志服务后重试。'),
957336
+ code: 'LOG_SERVICE_NOT_ENABLED',
957337
+ solution: [
957338
+ (0, i18n_1.t)('运行 tcb logs search --yes 可自动开通日志服务'),
957339
+ (0, i18n_1.t)('或前往云开发控制台手动开通')
957340
+ ]
957341
+ });
957342
+ if (jsonOutput) {
957343
+ throw notEnabledError;
957344
+ }
957345
+ log.warn((0, i18n_1.t)('您的环境尚未开通日志服务,开通后不额外计费,日志将按照您购买的套餐提供不同时长保存,' +
957346
+ '详情可参考文档:https://cloud.tencent.com/document/product/876/75213'));
957347
+ const confirm = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('是否现在开通日志服务?'), true);
957348
+ if (!confirm) {
957349
+ throw notEnabledError;
957350
+ }
957351
+ if (!jsonOutput) {
957352
+ log.info((0, i18n_1.t)('正在开通日志服务(异步操作,最长等待 5 分钟)...'));
957353
+ }
957354
+ try {
957355
+ yield logService.createLogService();
957356
+ }
957357
+ catch (e) {
957358
+ const code = (e === null || e === void 0 ? void 0 : e.code) || (e === null || e === void 0 ? void 0 : e.Code) || '';
957359
+ if (code !== 'ResourceInUse.LogExist') {
957360
+ throw new error_1.CloudBaseError({
957361
+ message: (0, i18n_1.t)('开通日志服务失败:{{message}}', { message: e.message || String(e) }),
957362
+ original: e
957363
+ });
957364
+ }
957365
+ }
957366
+ const MAX_POLL = 60;
957367
+ const POLL_INTERVAL_MS = 2000;
957368
+ let pollCount = 0;
957369
+ yield new Promise((resolve, reject) => {
957370
+ const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
957371
+ pollCount++;
957372
+ try {
957373
+ const ready = yield logService.checkLogServiceEnabled();
957374
+ if (ready) {
957375
+ clearInterval(timer);
957376
+ if (!jsonOutput) {
957377
+ log.info((0, i18n_1.t)('日志服务开通成功!'));
957378
+ }
957379
+ resolve();
957380
+ return;
957381
+ }
957382
+ }
957383
+ catch (e) {
957384
+ clearInterval(timer);
957385
+ reject(new error_1.CloudBaseError({
957386
+ message: (0, i18n_1.t)('轮询日志服务状态失败:{{message}}', {
957387
+ message: e.message || String(e)
957388
+ }),
957389
+ original: e
957390
+ }));
957391
+ return;
957392
+ }
957393
+ if (pollCount >= MAX_POLL) {
957394
+ clearInterval(timer);
957395
+ reject(new error_1.CloudBaseError((0, i18n_1.t)('日志服务开通超时(已等待 5 分钟),请稍后重试或前往控制台确认开通状态。')));
957396
+ }
957397
+ }), POLL_INTERVAL_MS);
957398
+ });
957399
+ });
957400
+ }
957401
+ exports.ensureLogServiceEnabled = ensureLogServiceEnabled;
955236
957402
  function getLogService(envId) {
955237
957403
  return __awaiter(this, void 0, void 0, function* () {
955238
957404
  const region = yield (0, toolbox_1.getRegion)();
@@ -955445,7 +957611,7 @@ if (process.platform === 'linux') {
955445
957611
 
955446
957612
 
955447
957613
 
955448
- var toPosInteger = __webpack_require__(32665)
957614
+ var toPosInteger = __webpack_require__(55046)
955449
957615
  , lruQueue = __webpack_require__(18056)
955450
957616
  , extensions = __webpack_require__(93923);
955451
957617
 
@@ -958107,7 +960273,7 @@ exports["default"] = $Ref;
958107
960273
 
958108
960274
 
958109
960275
  var numberIsNaN = __webpack_require__(14295)
958110
- , toPosInt = __webpack_require__(32665)
960276
+ , toPosInt = __webpack_require__(55046)
958111
960277
  , value = __webpack_require__(67134)
958112
960278
  , indexOf = Array.prototype.indexOf
958113
960279
  , objHasOwnProperty = Object.prototype.hasOwnProperty
@@ -961497,6 +963663,540 @@ module.exports = function (object, opts) {
961497
963663
  };
961498
963664
 
961499
963665
 
963666
+ /***/ }),
963667
+
963668
+ /***/ 98681:
963669
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
963670
+
963671
+ "use strict";
963672
+
963673
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
963674
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
963675
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
963676
+ 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;
963677
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
963678
+ };
963679
+ var __metadata = (this && this.__metadata) || function (k, v) {
963680
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
963681
+ };
963682
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
963683
+ return function (target, key) { decorator(target, key, paramIndex); }
963684
+ };
963685
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
963686
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
963687
+ return new (P || (P = Promise))(function (resolve, reject) {
963688
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
963689
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
963690
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
963691
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
963692
+ });
963693
+ };
963694
+ var __importDefault = (this && this.__importDefault) || function (mod) {
963695
+ return (mod && mod.__esModule) ? mod : { "default": mod };
963696
+ };
963697
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
963698
+ exports.getProjectName = exports.Deploy = exports.AppDeploy = exports.executeAppDeploy = exports.APP_DEPLOY_EXAMPLES = exports.APP_DEPLOY_OPTIONS = void 0;
963699
+ const path_1 = __importDefault(__webpack_require__(16928));
963700
+ const fs_1 = __importDefault(__webpack_require__(79896));
963701
+ const inquirer_1 = __importDefault(__webpack_require__(6403));
963702
+ const common_1 = __webpack_require__(48431);
963703
+ const decorators_1 = __webpack_require__(93480);
963704
+ const i18n_1 = __webpack_require__(69258);
963705
+ const error_1 = __webpack_require__(66759);
963706
+ const utils_1 = __webpack_require__(75213);
963707
+ const utils_2 = __webpack_require__(82079);
963708
+ const constant_1 = __webpack_require__(62977);
963709
+ const app_1 = __webpack_require__(49637);
963710
+ exports.APP_DEPLOY_OPTIONS = [
963711
+ {
963712
+ flags: '-e, --env-id <envId>',
963713
+ desc: (0, i18n_1.t)('目标环境 ID'),
963714
+ deprecatedName: 'envId'
963715
+ },
963716
+ {
963717
+ flags: '--framework <framework>',
963718
+ desc: (0, i18n_1.t)('框架类型'),
963719
+ choices: ['react', 'vue', 'vite', 'next', 'nuxt', 'angular', 'static']
963720
+ },
963721
+ {
963722
+ flags: '--install-command <cmd>',
963723
+ desc: (0, i18n_1.t)('安装命令(留空跳过安装步骤)')
963724
+ },
963725
+ {
963726
+ flags: '--build-command <cmd>',
963727
+ desc: (0, i18n_1.t)('构建命令(留空跳过构建步骤,适用于纯静态项目)')
963728
+ },
963729
+ {
963730
+ flags: '--output-dir <dir>',
963731
+ desc: (0, i18n_1.t)('构建产物目录,默认 dist')
963732
+ },
963733
+ {
963734
+ flags: '--deploy-path <path>',
963735
+ desc: (0, i18n_1.t)('部署路径(静态托管挂载路径),默认 /服务名')
963736
+ },
963737
+ {
963738
+ flags: '--dir <path>',
963739
+ desc: (0, i18n_1.t)('项目目录,相对路径(默认当前目录)')
963740
+ },
963741
+ {
963742
+ flags: '-f, --force',
963743
+ desc: (0, i18n_1.t)('应用名称已存在时跳过确认,直接覆盖更新')
963744
+ }
963745
+ ];
963746
+ exports.APP_DEPLOY_EXAMPLES = [
963747
+ 'tcb deploy',
963748
+ 'tcb deploy my-app --env-id env-xxx',
963749
+ 'tcb deploy --dir ./frontend',
963750
+ 'tcb deploy my-app --env-id env-xxx --framework react --json',
963751
+ 'tcb deploy my-app --env-id env-xxx --yes --json',
963752
+ 'tcb deploy my-app --env-id env-xxx --force'
963753
+ ];
963754
+ function executeAppDeploy(ctx, params, log) {
963755
+ var _a, _b, _c, _d, _e, _f, _g, _h;
963756
+ return __awaiter(this, void 0, void 0, function* () {
963757
+ const { config, globalOptions } = ctx;
963758
+ let { envId } = ctx;
963759
+ const { json, yes } = globalOptions || {};
963760
+ const { framework, installCommand: installCommandOption, buildCommand, outputDir, deployPath: deployPathOption, dir, force } = ctx.options || {};
963761
+ let serviceName = params === null || params === void 0 ? void 0 : params[0];
963762
+ const dirOption = dir || ((_a = config === null || config === void 0 ? void 0 : config.app) === null || _a === void 0 ? void 0 : _a.root);
963763
+ let projectPath = process.cwd();
963764
+ if (dirOption) {
963765
+ projectPath = path_1.default.resolve(process.cwd(), dirOption);
963766
+ if (!fs_1.default.existsSync(projectPath)) {
963767
+ throw new error_1.CloudBaseError({
963768
+ message: (0, i18n_1.t)('指定的项目目录不存在: {{path}}', { path: projectPath }),
963769
+ code: 'INVALID_PARAM',
963770
+ solution: [
963771
+ (0, i18n_1.t)('检查 --dir 参数路径是否正确'),
963772
+ (0, i18n_1.t)('当前工作目录: {{cwd}}', { cwd: process.cwd() })
963773
+ ]
963774
+ });
963775
+ }
963776
+ if (!fs_1.default.statSync(projectPath).isDirectory()) {
963777
+ throw new error_1.CloudBaseError({
963778
+ message: (0, i18n_1.t)('--dir 参数必须指向一个目录: {{path}}', { path: projectPath }),
963779
+ code: 'INVALID_PARAM'
963780
+ });
963781
+ }
963782
+ log.info((0, i18n_1.t)('项目目录: {{path}}', { path: dirOption }));
963783
+ }
963784
+ const buildPath = dirOption || '';
963785
+ if (!envId || envId.startsWith('{{')) {
963786
+ if (envId === null || envId === void 0 ? void 0 : envId.startsWith('{{')) {
963787
+ log.warn((0, i18n_1.t)('配置文件中的环境变量 {{envId}} 未找到对应的值,请选择环境', { envId }));
963788
+ }
963789
+ envId = yield (0, utils_1.selectEnv)({ envTypes: [constant_1.EnvType.BAAS, constant_1.EnvType.WEDA] });
963790
+ log.info((0, i18n_1.t)('已选择环境: {{envId}}', { envId }));
963791
+ }
963792
+ if (!serviceName) {
963793
+ if ((_b = config === null || config === void 0 ? void 0 : config.app) === null || _b === void 0 ? void 0 : _b.serviceName) {
963794
+ serviceName = config.app.serviceName;
963795
+ }
963796
+ else if (!yes && !json) {
963797
+ serviceName = yield selectOrCreateService(envId, projectPath, log);
963798
+ }
963799
+ else {
963800
+ serviceName = getProjectName(projectPath);
963801
+ }
963802
+ }
963803
+ 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);
963804
+ if (serviceNameFromParam) {
963805
+ const existing = yield checkServiceExists(envId, serviceName);
963806
+ if (existing) {
963807
+ if (force || yes) {
963808
+ log.verbose((0, i18n_1.t)('应用 "{{name}}" 已存在,覆盖更新', { name: serviceName }));
963809
+ }
963810
+ else if (json) {
963811
+ }
963812
+ else {
963813
+ log.warn((0, i18n_1.t)('云端已存在同名应用 [{{name}}]', { name: serviceName }));
963814
+ const { confirmed } = yield inquirer_1.default.prompt({
963815
+ type: 'confirm',
963816
+ name: 'confirmed',
963817
+ message: (0, i18n_1.t)('是否覆盖更新?'),
963818
+ default: true
963819
+ });
963820
+ if (!confirmed) {
963821
+ log.info((0, i18n_1.t)('已取消部署'));
963822
+ return null;
963823
+ }
963824
+ }
963825
+ }
963826
+ }
963827
+ let frameworkConfig = null;
963828
+ if (config === null || config === void 0 ? void 0 : config.app) {
963829
+ const appConfig = config.app;
963830
+ frameworkConfig = {
963831
+ framework: appConfig.framework || '',
963832
+ displayName: appConfig.framework || '',
963833
+ buildCommand: appConfig.buildCommand || '',
963834
+ outputDir: appConfig.outputDir || ''
963835
+ };
963836
+ }
963837
+ const needDetect = !(frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework);
963838
+ if (needDetect && !framework) {
963839
+ const detected = yield (0, app_1.detectFramework)(projectPath);
963840
+ if (detected) {
963841
+ log.success((0, i18n_1.t)('✔ 检测到框架: {{name}}', { name: detected.displayName }));
963842
+ log.info((0, i18n_1.t)(' 构建命令: {{cmd}}', { cmd: detected.buildCommand || '无' }));
963843
+ log.info((0, i18n_1.t)(' 输出目录: {{dir}}', { dir: detected.outputDir }));
963844
+ frameworkConfig = {
963845
+ framework: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework) || detected.framework,
963846
+ displayName: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.displayName) || detected.displayName,
963847
+ buildCommand: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.buildCommand) || detected.buildCommand,
963848
+ outputDir: (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.outputDir) || detected.outputDir
963849
+ };
963850
+ }
963851
+ }
963852
+ const finalFramework = framework || (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.framework);
963853
+ const detectedBuildCommand = (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.buildCommand) || undefined;
963854
+ const detectedOutputDir = (frameworkConfig === null || frameworkConfig === void 0 ? void 0 : frameworkConfig.outputDir) || undefined;
963855
+ const configInstallCommand = (_d = config === null || config === void 0 ? void 0 : config.app) === null || _d === void 0 ? void 0 : _d.installCommand;
963856
+ let finalInstallCommand;
963857
+ if (installCommandOption !== undefined) {
963858
+ finalInstallCommand = installCommandOption;
963859
+ }
963860
+ else if (configInstallCommand !== undefined) {
963861
+ finalInstallCommand = configInstallCommand;
963862
+ }
963863
+ else if (!yes && !json) {
963864
+ const { installCmd } = yield inquirer_1.default.prompt({
963865
+ type: 'input',
963866
+ name: 'installCmd',
963867
+ message: (0, i18n_1.t)('请输入安装命令(留空跳过)'),
963868
+ default: 'npm install'
963869
+ });
963870
+ finalInstallCommand = installCmd;
963871
+ }
963872
+ else {
963873
+ finalInstallCommand = 'npm install';
963874
+ }
963875
+ const configBuildCommand = ((_e = config === null || config === void 0 ? void 0 : config.app) === null || _e === void 0 ? void 0 : _e.buildCommand) || undefined;
963876
+ let finalBuildCommand;
963877
+ if (buildCommand !== undefined) {
963878
+ finalBuildCommand = buildCommand;
963879
+ }
963880
+ else if (configBuildCommand !== undefined) {
963881
+ finalBuildCommand = configBuildCommand;
963882
+ }
963883
+ else if (detectedBuildCommand !== undefined) {
963884
+ finalBuildCommand = detectedBuildCommand;
963885
+ }
963886
+ else if (!yes && !json) {
963887
+ const { buildCmd } = yield inquirer_1.default.prompt({
963888
+ type: 'input',
963889
+ name: 'buildCmd',
963890
+ message: (0, i18n_1.t)('请输入构建命令(留空跳过)'),
963891
+ default: 'npm run build'
963892
+ });
963893
+ finalBuildCommand = buildCmd;
963894
+ }
963895
+ else {
963896
+ finalBuildCommand = 'npm run build';
963897
+ }
963898
+ const configOutputDir = ((_f = config === null || config === void 0 ? void 0 : config.app) === null || _f === void 0 ? void 0 : _f.outputDir) || undefined;
963899
+ let finalOutputDir;
963900
+ if (outputDir !== undefined) {
963901
+ finalOutputDir = outputDir;
963902
+ }
963903
+ else if (configOutputDir !== undefined) {
963904
+ finalOutputDir = configOutputDir;
963905
+ }
963906
+ else if (detectedOutputDir !== undefined) {
963907
+ finalOutputDir = detectedOutputDir;
963908
+ }
963909
+ else if (!yes && !json) {
963910
+ const { outDir } = yield inquirer_1.default.prompt({
963911
+ type: 'input',
963912
+ name: 'outDir',
963913
+ message: (0, i18n_1.t)('请输入构建产物目录'),
963914
+ default: 'dist'
963915
+ });
963916
+ finalOutputDir = outDir;
963917
+ }
963918
+ else {
963919
+ finalOutputDir = 'dist';
963920
+ }
963921
+ let finalDeployPath = deployPathOption || ((_g = config === null || config === void 0 ? void 0 : config.app) === null || _g === void 0 ? void 0 : _g.deployPath);
963922
+ if (!finalDeployPath) {
963923
+ if (!yes && !json) {
963924
+ const { deployPathInput } = yield inquirer_1.default.prompt({
963925
+ type: 'input',
963926
+ name: 'deployPathInput',
963927
+ message: (0, i18n_1.t)('请输入部署路径(静态托管挂载路径)'),
963928
+ default: `/${serviceName}`,
963929
+ validate: (input) => {
963930
+ const p = input.trim();
963931
+ if (!p)
963932
+ return (0, i18n_1.t)('部署路径不能为空');
963933
+ if (!p.startsWith('/'))
963934
+ return (0, i18n_1.t)('部署路径必须以 / 开头');
963935
+ return true;
963936
+ }
963937
+ });
963938
+ finalDeployPath = deployPathInput;
963939
+ }
963940
+ }
963941
+ const envVariables = (_h = config === null || config === void 0 ? void 0 : config.app) === null || _h === void 0 ? void 0 : _h.envVariables;
963942
+ const result = yield (0, app_1.deployCloudApp)({
963943
+ envId,
963944
+ serviceName,
963945
+ framework: finalFramework,
963946
+ installCommand: finalInstallCommand,
963947
+ buildCommand: finalBuildCommand,
963948
+ outputDir: finalOutputDir,
963949
+ deployPath: finalDeployPath,
963950
+ buildPath,
963951
+ envVariables,
963952
+ log
963953
+ });
963954
+ if (json) {
963955
+ (0, utils_2.outputJson)(result, {
963956
+ nextSteps: [
963957
+ `tcb app info ${serviceName} --env-id ${envId}`,
963958
+ `tcb app versions ${serviceName} --env-id ${envId}`
963959
+ ]
963960
+ });
963961
+ }
963962
+ else {
963963
+ log.success((0, i18n_1.t)('\n✔ 部署成功!'));
963964
+ log.info((0, i18n_1.t)(' 访问地址: {{url}}', { url: result.url ? (0, utils_2.genClickableLink)(result.url) : '-' }));
963965
+ log.info((0, i18n_1.t)(' 版本号: {{version}}', { version: result.versionName }));
963966
+ log.info((0, i18n_1.t)(' 耗时: {{duration}}s', { duration: String(result.buildDuration) }));
963967
+ log.info((0, i18n_1.t)('\n下一步:'));
963968
+ log.info((0, i18n_1.t)(' 查看应用 tcb app info {{name}} --env-id {{envId}}', {
963969
+ name: serviceName, envId
963970
+ }));
963971
+ log.info((0, i18n_1.t)(' 查看版本 tcb app versions {{name}} --env-id {{envId}}', {
963972
+ name: serviceName, envId
963973
+ }));
963974
+ }
963975
+ if (!(config === null || config === void 0 ? void 0 : config.app)) {
963976
+ const appConfig = {
963977
+ serviceName,
963978
+ framework: finalFramework,
963979
+ installCommand: finalInstallCommand,
963980
+ buildCommand: finalBuildCommand,
963981
+ outputDir: finalOutputDir
963982
+ };
963983
+ if (dirOption) {
963984
+ appConfig.root = dirOption;
963985
+ }
963986
+ if (finalDeployPath && finalDeployPath !== `/${serviceName}`) {
963987
+ appConfig.deployPath = finalDeployPath;
963988
+ }
963989
+ yield (0, utils_1.upsertCloudbaserc)(projectPath, {
963990
+ envId,
963991
+ app: appConfig
963992
+ });
963993
+ log.success((0, i18n_1.t)('配置已保存到 cloudbaserc.json'));
963994
+ }
963995
+ return result;
963996
+ });
963997
+ }
963998
+ exports.executeAppDeploy = executeAppDeploy;
963999
+ let AppDeploy = class AppDeploy extends common_1.Command {
964000
+ get options() {
964001
+ return {
964002
+ cmd: 'app',
964003
+ childCmd: 'deploy [serviceName]',
964004
+ options: exports.APP_DEPLOY_OPTIONS,
964005
+ desc: (0, i18n_1.t)('部署云应用到云端。支持零配置自动检测框架。'),
964006
+ requiredEnvId: false,
964007
+ autoRunLogin: true,
964008
+ examples: exports.APP_DEPLOY_EXAMPLES,
964009
+ docs: ['https://docs.cloudbase.net/cli/app/deploy']
964010
+ };
964011
+ }
964012
+ execute(ctx, params, log) {
964013
+ return __awaiter(this, void 0, void 0, function* () {
964014
+ return executeAppDeploy(ctx, params, log);
964015
+ });
964016
+ }
964017
+ };
964018
+ __decorate([
964019
+ (0, decorators_1.InjectParams)(),
964020
+ __param(0, (0, decorators_1.CmdContext)()),
964021
+ __param(1, (0, decorators_1.ArgsParams)()),
964022
+ __param(2, (0, decorators_1.Log)()),
964023
+ __metadata("design:type", Function),
964024
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
964025
+ __metadata("design:returntype", Promise)
964026
+ ], AppDeploy.prototype, "execute", null);
964027
+ AppDeploy = __decorate([
964028
+ (0, common_1.ICommand)()
964029
+ ], AppDeploy);
964030
+ exports.AppDeploy = AppDeploy;
964031
+ let Deploy = class Deploy extends common_1.Command {
964032
+ get options() {
964033
+ return {
964034
+ cmd: 'deploy [serviceName]',
964035
+ options: exports.APP_DEPLOY_OPTIONS,
964036
+ desc: (0, i18n_1.t)('部署云应用到云端。支持零配置自动检测框架。'),
964037
+ requiredEnvId: false,
964038
+ autoRunLogin: true,
964039
+ examples: exports.APP_DEPLOY_EXAMPLES,
964040
+ seeAlso: ['tcb app deploy', 'tcb app list', 'tcb app info'],
964041
+ docs: ['https://docs.cloudbase.net/cli/app/deploy']
964042
+ };
964043
+ }
964044
+ execute(ctx, params, log) {
964045
+ return __awaiter(this, void 0, void 0, function* () {
964046
+ return executeAppDeploy(ctx, params, log);
964047
+ });
964048
+ }
964049
+ };
964050
+ __decorate([
964051
+ (0, decorators_1.InjectParams)(),
964052
+ __param(0, (0, decorators_1.CmdContext)()),
964053
+ __param(1, (0, decorators_1.ArgsParams)()),
964054
+ __param(2, (0, decorators_1.Log)()),
964055
+ __metadata("design:type", Function),
964056
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
964057
+ __metadata("design:returntype", Promise)
964058
+ ], Deploy.prototype, "execute", null);
964059
+ Deploy = __decorate([
964060
+ (0, common_1.ICommand)()
964061
+ ], Deploy);
964062
+ exports.Deploy = Deploy;
964063
+ function checkServiceExists(envId, serviceName) {
964064
+ return __awaiter(this, void 0, void 0, function* () {
964065
+ try {
964066
+ const app = yield (0, utils_2.getMangerService)(envId);
964067
+ const data = yield app.cloudAppService.describeAppList({
964068
+ deployType: app_1.DEPLOY_TYPE_STATIC_HOSTING,
964069
+ pageSize: 100
964070
+ });
964071
+ const list = data.ServiceList || [];
964072
+ return list.some((item) => item.ServiceName === serviceName);
964073
+ }
964074
+ catch (_a) {
964075
+ return false;
964076
+ }
964077
+ });
964078
+ }
964079
+ function selectOrCreateService(envId, projectPath, log) {
964080
+ return __awaiter(this, void 0, void 0, function* () {
964081
+ const loading = (0, utils_2.loadingFactory)();
964082
+ loading.start((0, i18n_1.t)('正在查询云端应用列表...'));
964083
+ let serviceList = [];
964084
+ try {
964085
+ const app = yield (0, utils_2.getMangerService)(envId);
964086
+ const data = yield app.cloudAppService.describeAppList({
964087
+ deployType: app_1.DEPLOY_TYPE_STATIC_HOSTING,
964088
+ pageSize: 100
964089
+ });
964090
+ serviceList = data.ServiceList || [];
964091
+ }
964092
+ catch (_a) {
964093
+ log.verbose((0, i18n_1.t)('查询云端应用列表失败,将直接输入服务名'));
964094
+ }
964095
+ finally {
964096
+ loading.stop();
964097
+ }
964098
+ if (serviceList.length === 0) {
964099
+ log.info((0, i18n_1.t)('当前环境暂无已部署的云应用'));
964100
+ return inputNewServiceName(projectPath, []);
964101
+ }
964102
+ const { action } = yield inquirer_1.default.prompt({
964103
+ type: 'list',
964104
+ name: 'action',
964105
+ message: (0, i18n_1.t)('请选择部署方式'),
964106
+ choices: [
964107
+ { name: (0, i18n_1.t)('关联已有项目'), value: 'link' },
964108
+ { name: (0, i18n_1.t)('部署新项目'), value: 'create' }
964109
+ ]
964110
+ });
964111
+ if (action === 'create') {
964112
+ return inputNewServiceName(projectPath, serviceList.map(i => i.ServiceName));
964113
+ }
964114
+ const selectedService = yield selectServiceWithPagination(serviceList);
964115
+ log.info((0, i18n_1.t)('已关联云端应用: {{name}}', { name: selectedService }));
964116
+ return selectedService;
964117
+ });
964118
+ }
964119
+ const PAGE_SIZE = 10;
964120
+ const LOAD_MORE = '__LOAD_MORE__';
964121
+ function selectServiceWithPagination(serviceList) {
964122
+ return __awaiter(this, void 0, void 0, function* () {
964123
+ let page = 1;
964124
+ while (true) {
964125
+ const pageItems = serviceList.slice(0, page * PAGE_SIZE);
964126
+ const hasMore = serviceList.length > page * PAGE_SIZE;
964127
+ const shown = pageItems.length;
964128
+ const total = serviceList.length;
964129
+ const choices = [
964130
+ ...pageItems.map((item) => ({
964131
+ name: `${item.ServiceName}${item.Domain ? ` (${item.Domain})` : ''}${item.LatestStatus ? ` [${item.LatestStatus}]` : ''}`,
964132
+ value: item.ServiceName,
964133
+ short: item.ServiceName
964134
+ })),
964135
+ ...(hasMore ? [
964136
+ new inquirer_1.default.Separator(),
964137
+ {
964138
+ name: (0, i18n_1.t)('显示更多 ({{shown}}/{{total}})', { shown, total }),
964139
+ value: LOAD_MORE,
964140
+ short: (0, i18n_1.t)('显示更多')
964141
+ }
964142
+ ] : [])
964143
+ ];
964144
+ const { selectedService } = yield inquirer_1.default.prompt({
964145
+ type: 'list',
964146
+ name: 'selectedService',
964147
+ message: (0, i18n_1.t)('请选择要关联的云端应用'),
964148
+ choices,
964149
+ pageSize: PAGE_SIZE + 2
964150
+ });
964151
+ if (selectedService === LOAD_MORE) {
964152
+ page++;
964153
+ continue;
964154
+ }
964155
+ return selectedService;
964156
+ }
964157
+ });
964158
+ }
964159
+ function inputNewServiceName(projectPath, existingNames) {
964160
+ return __awaiter(this, void 0, void 0, function* () {
964161
+ const defaultName = getProjectName(projectPath);
964162
+ const { serviceName } = yield inquirer_1.default.prompt({
964163
+ type: 'input',
964164
+ name: 'serviceName',
964165
+ message: (0, i18n_1.t)('请输入服务名称'),
964166
+ default: defaultName,
964167
+ validate: (input) => {
964168
+ const name = input.trim();
964169
+ if (!name)
964170
+ return (0, i18n_1.t)('服务名称不能为空');
964171
+ if (existingNames.includes(name)) {
964172
+ return (0, i18n_1.t)('服务名称 "{{name}}" 已被占用,请使用其他名称', { name });
964173
+ }
964174
+ return true;
964175
+ }
964176
+ });
964177
+ return serviceName;
964178
+ });
964179
+ }
964180
+ function getProjectName(projectPath) {
964181
+ const packageJsonPath = path_1.default.join(projectPath, 'package.json');
964182
+ if (fs_1.default.existsSync(packageJsonPath)) {
964183
+ try {
964184
+ const raw = fs_1.default.readFileSync(packageJsonPath, 'utf-8');
964185
+ const packageJson = JSON.parse(raw);
964186
+ if (packageJson.name && typeof packageJson.name === 'string') {
964187
+ const name = packageJson.name.replace(/^@[^/]+\//, '');
964188
+ if (name)
964189
+ return name;
964190
+ }
964191
+ }
964192
+ catch (_a) {
964193
+ }
964194
+ }
964195
+ return path_1.default.basename(projectPath);
964196
+ }
964197
+ exports.getProjectName = getProjectName;
964198
+
964199
+
961500
964200
  /***/ }),
961501
964201
 
961502
964202
  /***/ 98718: