@cloudbase/cli 3.0.0-alpha.4 → 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.
- package/dist/standalone/cli.js +2309 -146
- package/package.json +1 -1
package/dist/standalone/cli.js
CHANGED
|
@@ -9827,7 +9827,7 @@ exports.FunctionCopy = FunctionCopy;
|
|
|
9827
9827
|
"use strict";
|
|
9828
9828
|
|
|
9829
9829
|
|
|
9830
|
-
var toPosInt = __webpack_require__(
|
|
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.
|
|
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:
|
|
@@ -400192,7 +400579,7 @@ exports.GitBase = GitBase;
|
|
|
400192
400579
|
"use strict";
|
|
400193
400580
|
|
|
400194
400581
|
|
|
400195
|
-
var toPosInt = __webpack_require__(
|
|
400582
|
+
var toPosInt = __webpack_require__(55046)
|
|
400196
400583
|
|
|
400197
400584
|
, create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
400198
400585
|
|
|
@@ -401586,9 +401973,15 @@ async function main() {
|
|
|
401586
401973
|
const { outputHelpInfo } = __webpack_require__(95042)
|
|
401587
401974
|
outputHelpInfo()
|
|
401588
401975
|
} else if (!['-v', '--version'].includes(processArgv[2])) {
|
|
401589
|
-
//
|
|
401590
|
-
|
|
401591
|
-
|
|
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
|
+
}
|
|
401592
401985
|
}
|
|
401593
401986
|
}
|
|
401594
401987
|
}
|
|
@@ -401812,6 +402205,99 @@ if (__webpack_require__.c[__webpack_require__.s] === module) {
|
|
|
401812
402205
|
exports.main = main
|
|
401813
402206
|
|
|
401814
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
|
+
|
|
401815
402301
|
/***/ }),
|
|
401816
402302
|
|
|
401817
402303
|
/***/ 18560:
|
|
@@ -411157,7 +411643,7 @@ exports.prettify = prettify;
|
|
|
411157
411643
|
"use strict";
|
|
411158
411644
|
|
|
411159
411645
|
|
|
411160
|
-
var toPosInt = __webpack_require__(
|
|
411646
|
+
var toPosInt = __webpack_require__(55046)
|
|
411161
411647
|
, maxTimeout = __webpack_require__(45481);
|
|
411162
411648
|
|
|
411163
411649
|
module.exports = function (value) {
|
|
@@ -411738,6 +412224,138 @@ ZodError.create = (issues) => {
|
|
|
411738
412224
|
};
|
|
411739
412225
|
|
|
411740
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
|
+
|
|
411741
412359
|
/***/ }),
|
|
411742
412360
|
|
|
411743
412361
|
/***/ 20692:
|
|
@@ -496685,15 +497303,252 @@ exports.pack = __webpack_require__(30030)
|
|
|
496685
497303
|
/***/ }),
|
|
496686
497304
|
|
|
496687
497305
|
/***/ 32665:
|
|
496688
|
-
/***/ ((
|
|
497306
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
496689
497307
|
|
|
496690
497308
|
"use strict";
|
|
496691
497309
|
|
|
496692
|
-
|
|
496693
|
-
|
|
496694
|
-
|
|
496695
|
-
|
|
496696
|
-
|
|
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);
|
|
496697
497552
|
|
|
496698
497553
|
|
|
496699
497554
|
/***/ }),
|
|
@@ -510139,6 +510994,24 @@ const imageCommonOptions = (sub) => ({
|
|
|
510139
510994
|
exports.imageCommonOptions = imageCommonOptions;
|
|
510140
510995
|
|
|
510141
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
|
+
|
|
510142
511015
|
/***/ }),
|
|
510143
511016
|
|
|
510144
511017
|
/***/ 35674:
|
|
@@ -541317,8 +542190,10 @@ const path_1 = __importDefault(__webpack_require__(16928));
|
|
|
541317
542190
|
const log_symbols_1 = __importDefault(__webpack_require__(68329));
|
|
541318
542191
|
const common_1 = __webpack_require__(48431);
|
|
541319
542192
|
const hosting_1 = __webpack_require__(2767);
|
|
542193
|
+
const utils_1 = __webpack_require__(75213);
|
|
542194
|
+
const constant_1 = __webpack_require__(62977);
|
|
541320
542195
|
const error_1 = __webpack_require__(66759);
|
|
541321
|
-
const
|
|
542196
|
+
const utils_2 = __webpack_require__(82079);
|
|
541322
542197
|
const decorators_1 = __webpack_require__(93480);
|
|
541323
542198
|
const i18n_1 = __webpack_require__(69258);
|
|
541324
542199
|
const interactive_1 = __webpack_require__(57695);
|
|
@@ -541333,46 +542208,167 @@ const HostingStatusMap = {
|
|
|
541333
542208
|
};
|
|
541334
542209
|
function getHostingService(envId) {
|
|
541335
542210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541336
|
-
const { hosting } = yield (0,
|
|
542211
|
+
const { hosting } = yield (0, utils_2.getMangerService)(envId);
|
|
541337
542212
|
return hosting;
|
|
541338
542213
|
});
|
|
541339
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
|
+
}
|
|
541340
542280
|
let HostingDetail = class HostingDetail extends common_1.Command {
|
|
541341
542281
|
get options() {
|
|
541342
542282
|
return {
|
|
541343
542283
|
cmd: 'hosting',
|
|
541344
542284
|
childCmd: 'detail',
|
|
541345
542285
|
deprecateCmd: 'hosting:detail',
|
|
541346
|
-
options: [
|
|
541347
|
-
|
|
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']
|
|
541348
542302
|
};
|
|
541349
542303
|
}
|
|
541350
542304
|
execute(envId, log) {
|
|
541351
|
-
var _a;
|
|
542305
|
+
var _a, _b, _c;
|
|
541352
542306
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541353
|
-
|
|
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 });
|
|
541354
542312
|
const website = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a[0];
|
|
541355
542313
|
if (!website) {
|
|
541356
|
-
if ((0,
|
|
541357
|
-
(0,
|
|
542314
|
+
if ((0, utils_2.isJsonOutput)()) {
|
|
542315
|
+
(0, utils_2.outputJson)({ error: { message: '静态网站服务未开通' } });
|
|
541358
542316
|
return;
|
|
541359
542317
|
}
|
|
541360
|
-
yield (0, hosting_1.initHosting)({ envId });
|
|
542318
|
+
yield (0, hosting_1.initHosting)({ envId: selectedEnvId });
|
|
541361
542319
|
return;
|
|
541362
542320
|
}
|
|
541363
|
-
|
|
541364
|
-
|
|
541365
|
-
|
|
541366
|
-
|
|
541367
|
-
|
|
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
|
+
}
|
|
541368
542343
|
});
|
|
541369
542344
|
return;
|
|
541370
542345
|
}
|
|
541371
|
-
|
|
541372
|
-
|
|
541373
|
-
|
|
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'));
|
|
541374
542371
|
}
|
|
541375
|
-
log.info((0, i18n_1.t)('静态网站状态:【{{status}}】', { status: HostingStatusMap[website.status] }));
|
|
541376
542372
|
});
|
|
541377
542373
|
}
|
|
541378
542374
|
};
|
|
@@ -541394,7 +542390,15 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541394
542390
|
cmd: 'hosting',
|
|
541395
542391
|
childCmd: 'deploy [filePath] [cloudPath]',
|
|
541396
542392
|
deprecateCmd: 'hosting:deploy [filePath] [cloudPath]',
|
|
541397
|
-
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,
|
|
541398
542402
|
desc: (0, i18n_1.t)('部署静态网站文件'),
|
|
541399
542403
|
examples: ['tcb hosting deploy .', 'tcb hosting deploy ./dist'],
|
|
541400
542404
|
seeAlso: ['tcb hosting list'],
|
|
@@ -541404,21 +542408,25 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541404
542408
|
execute(envId, params, log) {
|
|
541405
542409
|
var _a;
|
|
541406
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
|
+
}
|
|
541407
542415
|
const localPath = (params === null || params === void 0 ? void 0 : params[0]) || '.';
|
|
541408
542416
|
const cloudPath = (params === null || params === void 0 ? void 0 : params[1]) || '';
|
|
541409
542417
|
log.verbose((0, i18n_1.t)('本地目录'), localPath);
|
|
541410
542418
|
const resolveLocalPath = path_1.default.resolve(localPath);
|
|
541411
|
-
(0,
|
|
541412
|
-
const isDir = (0,
|
|
541413
|
-
const loading = (0,
|
|
542419
|
+
(0, utils_2.checkFullAccess)(resolveLocalPath, true);
|
|
542420
|
+
const isDir = (0, utils_2.isDirectory)(resolveLocalPath);
|
|
542421
|
+
const loading = (0, utils_2.loadingFactory)();
|
|
541414
542422
|
loading.start((0, i18n_1.t)('准备上传中...'));
|
|
541415
542423
|
let totalFiles = 0;
|
|
541416
542424
|
if (isDir) {
|
|
541417
|
-
let files = yield (0, hosting_1.walkLocalDir)(
|
|
541418
|
-
files = files.filter((item) => !(0,
|
|
542425
|
+
let files = yield (0, hosting_1.walkLocalDir)(selectedEnvId, resolveLocalPath);
|
|
542426
|
+
files = files.filter((item) => !(0, utils_2.isDirectory)(item));
|
|
541419
542427
|
totalFiles = files.length;
|
|
541420
542428
|
}
|
|
541421
|
-
const onProgress = (0,
|
|
542429
|
+
const onProgress = (0, utils_2.createUploadProgressBar)(() => {
|
|
541422
542430
|
!isDir && log.success((0, i18n_1.t)('文件部署成功!'));
|
|
541423
542431
|
}, () => {
|
|
541424
542432
|
loading.stop();
|
|
@@ -541428,7 +542436,7 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541428
542436
|
yield (0, hosting_1.hostingDeploy)({
|
|
541429
542437
|
filePath: resolveLocalPath,
|
|
541430
542438
|
cloudPath,
|
|
541431
|
-
envId,
|
|
542439
|
+
envId: selectedEnvId,
|
|
541432
542440
|
isDir,
|
|
541433
542441
|
onProgress,
|
|
541434
542442
|
onFileFinish: (...args) => {
|
|
@@ -541443,12 +542451,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541443
542451
|
}
|
|
541444
542452
|
});
|
|
541445
542453
|
const info = yield (0, hosting_1.getHostingInfo)({
|
|
541446
|
-
envId
|
|
542454
|
+
envId: selectedEnvId
|
|
541447
542455
|
});
|
|
541448
542456
|
const website = (_a = info === null || info === void 0 ? void 0 : info.data) === null || _a === void 0 ? void 0 : _a[0];
|
|
541449
|
-
const link = (0,
|
|
541450
|
-
if ((0,
|
|
541451
|
-
(0,
|
|
542457
|
+
const link = (0, utils_2.genClickableLink)(`https://${website.cdnDomain}`);
|
|
542458
|
+
if ((0, utils_2.isJsonOutput)()) {
|
|
542459
|
+
(0, utils_2.outputJson)({
|
|
541452
542460
|
message: '部署完成',
|
|
541453
542461
|
url: `https://${website.cdnDomain}`,
|
|
541454
542462
|
totalFiles: isDir ? totalFiles : 1,
|
|
@@ -541462,12 +542470,12 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541462
542470
|
log.success((0, i18n_1.t)('文件共计 {{totalFiles}} 个', { totalFiles }));
|
|
541463
542471
|
log.success((0, i18n_1.t)('文件上传成功 {{count}} 个', { count: successFiles.length }));
|
|
541464
542472
|
if (totalFiles <= 50) {
|
|
541465
|
-
(0,
|
|
542473
|
+
(0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], successFiles.map((item) => [log_symbols_1.default.success, item]));
|
|
541466
542474
|
}
|
|
541467
542475
|
log.error((0, i18n_1.t)('文件上传失败 {{count}} 个', { count: failedFiles.length }));
|
|
541468
542476
|
if (failedFiles.length) {
|
|
541469
542477
|
if (totalFiles <= 50) {
|
|
541470
|
-
(0,
|
|
542478
|
+
(0, utils_2.printHorizontalTable)([(0, i18n_1.t)('状态'), (0, i18n_1.t)('文件')], failedFiles.map((item) => [log_symbols_1.default.error, item]));
|
|
541471
542479
|
}
|
|
541472
542480
|
else {
|
|
541473
542481
|
const errorLogPath = path_1.default.resolve('./cloudbase-error.log');
|
|
@@ -541475,9 +542483,23 @@ let HostingDeploy = class HostingDeploy extends common_1.Command {
|
|
|
541475
542483
|
console.log(errorLogPath);
|
|
541476
542484
|
fs_1.default.writeFileSync(errorLogPath, failedFiles.join('\n'));
|
|
541477
542485
|
}
|
|
541478
|
-
throw new error_1.CloudBaseError(
|
|
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
|
+
});
|
|
541479
542495
|
}
|
|
541480
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
|
+
}
|
|
541481
542503
|
});
|
|
541482
542504
|
}
|
|
541483
542505
|
};
|
|
@@ -541500,46 +542522,144 @@ let HostingDeleteFiles = class HostingDeleteFiles extends common_1.Command {
|
|
|
541500
542522
|
cmd: 'hosting',
|
|
541501
542523
|
childCmd: 'delete [cloudPath]',
|
|
541502
542524
|
deprecateCmd: 'hosting:delete [cloudPath]',
|
|
541503
|
-
options: [
|
|
542525
|
+
options: [
|
|
542526
|
+
{
|
|
542527
|
+
flags: '-e, --env-id <envId>',
|
|
542528
|
+
desc: (0, i18n_1.t)('环境 ID'),
|
|
542529
|
+
deprecatedName: 'envId'
|
|
542530
|
+
},
|
|
542531
|
+
{
|
|
541504
542532
|
flags: '-d, --dir',
|
|
541505
542533
|
desc: (0, i18n_1.t)('删除目标是否为文件夹')
|
|
542534
|
+
},
|
|
542535
|
+
{
|
|
542536
|
+
flags: '--dry-run',
|
|
542537
|
+
desc: (0, i18n_1.t)('预览要删除的文件,不实际执行删除')
|
|
541506
542538
|
}
|
|
541507
542539
|
],
|
|
541508
|
-
|
|
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']
|
|
541509
542550
|
};
|
|
541510
542551
|
}
|
|
541511
|
-
execute(envId, options, params) {
|
|
542552
|
+
execute(envId, options, params, log) {
|
|
541512
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
|
+
}
|
|
541513
542558
|
const cloudPath = (params === null || params === void 0 ? void 0 : params[0]) || '';
|
|
541514
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
|
+
}
|
|
541515
542620
|
if (!cloudPath) {
|
|
541516
542621
|
const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('指定云端路径为空,将会删除所有文件,是否继续'), false);
|
|
541517
542622
|
if (!confirm) {
|
|
541518
|
-
throw new error_1.CloudBaseError(
|
|
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
|
+
});
|
|
541519
542628
|
}
|
|
541520
542629
|
isDir = true;
|
|
541521
542630
|
}
|
|
541522
|
-
|
|
541523
|
-
|
|
542631
|
+
const loading = (0, utils_2.loadingFactory)();
|
|
542632
|
+
if (!(0, utils_2.isJsonOutput)()) {
|
|
542633
|
+
loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
|
|
541524
542634
|
}
|
|
541525
|
-
const fileText = isDir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
|
|
541526
|
-
const loading = (0, utils_1.loadingFactory)();
|
|
541527
|
-
loading.start((0, i18n_1.t)('删除{{fileText}}中...', { fileText }));
|
|
541528
542635
|
try {
|
|
541529
542636
|
yield (0, hosting_1.hostingDelete)({
|
|
541530
|
-
envId,
|
|
542637
|
+
envId: selectedEnvId,
|
|
541531
542638
|
isDir,
|
|
541532
542639
|
cloudPath
|
|
541533
542640
|
});
|
|
541534
542641
|
loading.succeed((0, i18n_1.t)('删除{{fileText}}成功!', { fileText }));
|
|
541535
|
-
if ((0,
|
|
541536
|
-
(0,
|
|
542642
|
+
if ((0, utils_2.isJsonOutput)()) {
|
|
542643
|
+
(0, utils_2.outputJson)({ message: `删除${fileText}成功` });
|
|
541537
542644
|
return;
|
|
541538
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'));
|
|
541539
542650
|
}
|
|
541540
542651
|
catch (e) {
|
|
541541
542652
|
loading.fail((0, i18n_1.t)('删除{{fileText}}失败!', { fileText }));
|
|
541542
|
-
throw new error_1.CloudBaseError(
|
|
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
|
+
});
|
|
541543
542663
|
}
|
|
541544
542664
|
});
|
|
541545
542665
|
}
|
|
@@ -541549,8 +542669,9 @@ __decorate([
|
|
|
541549
542669
|
__param(0, (0, decorators_1.EnvId)()),
|
|
541550
542670
|
__param(1, (0, decorators_1.ArgsOptions)()),
|
|
541551
542671
|
__param(2, (0, decorators_1.ArgsParams)()),
|
|
542672
|
+
__param(3, (0, decorators_1.Log)()),
|
|
541552
542673
|
__metadata("design:type", Function),
|
|
541553
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
542674
|
+
__metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
|
|
541554
542675
|
__metadata("design:returntype", Promise)
|
|
541555
542676
|
], HostingDeleteFiles.prototype, "execute", null);
|
|
541556
542677
|
HostingDeleteFiles = __decorate([
|
|
@@ -541563,47 +542684,97 @@ let HostingList = class HostingList extends common_1.Command {
|
|
|
541563
542684
|
cmd: 'hosting',
|
|
541564
542685
|
childCmd: 'list',
|
|
541565
542686
|
deprecateCmd: 'hosting:list',
|
|
541566
|
-
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,
|
|
541567
542706
|
desc: (0, i18n_1.t)('展示文件列表'),
|
|
541568
|
-
examples: [
|
|
542707
|
+
examples: [
|
|
542708
|
+
'tcb hosting list',
|
|
542709
|
+
'tcb hosting list --limit 10',
|
|
542710
|
+
'tcb hosting list --json'
|
|
542711
|
+
],
|
|
541569
542712
|
seeAlso: ['tcb hosting deploy'],
|
|
541570
542713
|
docs: ['https://docs.cloudbase.net/cli-v1/hosting']
|
|
541571
542714
|
};
|
|
541572
542715
|
}
|
|
541573
|
-
execute(envId) {
|
|
542716
|
+
execute(envId, options, log) {
|
|
541574
542717
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541575
|
-
|
|
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)();
|
|
541576
542725
|
loading.start((0, i18n_1.t)('获取文件列表中...'));
|
|
541577
542726
|
try {
|
|
541578
542727
|
const list = yield (0, hosting_1.hostingList)({
|
|
541579
|
-
envId
|
|
542728
|
+
envId: selectedEnvId
|
|
541580
542729
|
});
|
|
541581
542730
|
loading.stop();
|
|
541582
542731
|
const notDir = (item) => !(Number(item.Size) === 0 && /\/$/g.test(item.Key));
|
|
541583
|
-
|
|
541584
|
-
|
|
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) => ({
|
|
541585
542737
|
key: item.Key,
|
|
541586
542738
|
lastModified: item.LastModified,
|
|
541587
542739
|
eTag: item.ETag,
|
|
541588
542740
|
size: item.Size
|
|
541589
|
-
})));
|
|
542741
|
+
})), { total, limit, offset });
|
|
542742
|
+
return;
|
|
542743
|
+
}
|
|
542744
|
+
if (paginatedFiles.length === 0) {
|
|
542745
|
+
log.warn((0, i18n_1.t)('没有找到文件'));
|
|
541590
542746
|
return;
|
|
541591
542747
|
}
|
|
541592
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)')];
|
|
541593
|
-
const tableData =
|
|
541594
|
-
|
|
541595
|
-
.map((item, index) => [
|
|
541596
|
-
index + 1,
|
|
542749
|
+
const tableData = paginatedFiles.map((item, index) => [
|
|
542750
|
+
offset + index + 1,
|
|
541597
542751
|
item.Key,
|
|
541598
|
-
(0,
|
|
542752
|
+
(0, utils_2.formatDate)(item.LastModified, 'yyyy-MM-dd hh:mm:ss'),
|
|
541599
542753
|
item.ETag,
|
|
541600
|
-
String((0,
|
|
542754
|
+
String((0, utils_2.formateFileSize)(item.Size, 'KB'))
|
|
541601
542755
|
]);
|
|
541602
|
-
(0,
|
|
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
|
+
}
|
|
541603
542765
|
}
|
|
541604
542766
|
catch (e) {
|
|
541605
542767
|
loading.fail((0, i18n_1.t)('获取文件列表失败!'));
|
|
541606
|
-
throw new error_1.CloudBaseError(
|
|
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
|
+
});
|
|
541607
542778
|
}
|
|
541608
542779
|
});
|
|
541609
542780
|
}
|
|
@@ -541611,8 +542782,10 @@ let HostingList = class HostingList extends common_1.Command {
|
|
|
541611
542782
|
__decorate([
|
|
541612
542783
|
(0, decorators_1.InjectParams)(),
|
|
541613
542784
|
__param(0, (0, decorators_1.EnvId)()),
|
|
542785
|
+
__param(1, (0, decorators_1.ArgsOptions)()),
|
|
542786
|
+
__param(2, (0, decorators_1.Log)()),
|
|
541614
542787
|
__metadata("design:type", Function),
|
|
541615
|
-
__metadata("design:paramtypes", [Object]),
|
|
542788
|
+
__metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
|
|
541616
542789
|
__metadata("design:returntype", Promise)
|
|
541617
542790
|
], HostingList.prototype, "execute", null);
|
|
541618
542791
|
HostingList = __decorate([
|
|
@@ -541624,23 +542797,41 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
|
|
|
541624
542797
|
return {
|
|
541625
542798
|
cmd: 'hosting',
|
|
541626
542799
|
childCmd: 'download <cloudPath> [localPath]',
|
|
541627
|
-
options: [
|
|
542800
|
+
options: [
|
|
542801
|
+
{
|
|
542802
|
+
flags: '-e, --env-id <envId>',
|
|
542803
|
+
desc: (0, i18n_1.t)('环境 ID'),
|
|
542804
|
+
deprecatedName: 'envId'
|
|
542805
|
+
},
|
|
542806
|
+
{
|
|
541628
542807
|
flags: '-d, --dir',
|
|
541629
542808
|
desc: (0, i18n_1.t)('下载目标是否为文件夹')
|
|
541630
542809
|
}
|
|
541631
542810
|
],
|
|
541632
|
-
|
|
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']
|
|
541633
542820
|
};
|
|
541634
542821
|
}
|
|
541635
|
-
execute(envId, options, params) {
|
|
542822
|
+
execute(envId, options, params, log) {
|
|
541636
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
|
+
}
|
|
541637
542828
|
let cloudPath = params === null || params === void 0 ? void 0 : params[0];
|
|
541638
542829
|
const localPath = (params === null || params === void 0 ? void 0 : params[1]) || '.';
|
|
541639
|
-
const hostingService = yield getHostingService(
|
|
542830
|
+
const hostingService = yield getHostingService(selectedEnvId);
|
|
541640
542831
|
const resolveLocalPath = path_1.default.resolve(localPath);
|
|
541641
542832
|
const { dir } = options;
|
|
541642
542833
|
const fileText = dir ? (0, i18n_1.t)('文件夹') : (0, i18n_1.t)('文件');
|
|
541643
|
-
const loading = (0,
|
|
542834
|
+
const loading = (0, utils_2.loadingFactory)();
|
|
541644
542835
|
loading.start((0, i18n_1.t)('下载{{fileText}}中', { fileText }));
|
|
541645
542836
|
if (/^\/.+/.test(cloudPath)) {
|
|
541646
542837
|
cloudPath = cloudPath.slice(1);
|
|
@@ -541658,9 +542849,14 @@ let HostingDownloadCommand = class HostingDownloadCommand extends common_1.Comma
|
|
|
541658
542849
|
});
|
|
541659
542850
|
}
|
|
541660
542851
|
loading.succeed((0, i18n_1.t)('下载{{fileText}}成功!', { fileText }));
|
|
541661
|
-
if ((0,
|
|
541662
|
-
(0,
|
|
542852
|
+
if ((0, utils_2.isJsonOutput)()) {
|
|
542853
|
+
(0, utils_2.outputJson)({ message: `下载${fileText}成功`, localPath: resolveLocalPath });
|
|
542854
|
+
return;
|
|
541663
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'));
|
|
541664
542860
|
});
|
|
541665
542861
|
}
|
|
541666
542862
|
};
|
|
@@ -541669,8 +542865,9 @@ __decorate([
|
|
|
541669
542865
|
__param(0, (0, decorators_1.EnvId)()),
|
|
541670
542866
|
__param(1, (0, decorators_1.ArgsOptions)()),
|
|
541671
542867
|
__param(2, (0, decorators_1.ArgsParams)()),
|
|
542868
|
+
__param(3, (0, decorators_1.Log)()),
|
|
541672
542869
|
__metadata("design:type", Function),
|
|
541673
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
542870
|
+
__metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
|
|
541674
542871
|
__metadata("design:returntype", Promise)
|
|
541675
542872
|
], HostingDownloadCommand.prototype, "execute", null);
|
|
541676
542873
|
HostingDownloadCommand = __decorate([
|
|
@@ -542941,29 +544138,6 @@ exports.CreateFileLayer = CreateFileLayer;
|
|
|
542941
544138
|
|
|
542942
544139
|
"use strict";
|
|
542943
544140
|
|
|
542944
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
542945
|
-
if (k2 === undefined) k2 = k;
|
|
542946
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
542947
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
542948
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
542949
|
-
}
|
|
542950
|
-
Object.defineProperty(o, k2, desc);
|
|
542951
|
-
}) : (function(o, m, k, k2) {
|
|
542952
|
-
if (k2 === undefined) k2 = k;
|
|
542953
|
-
o[k2] = m[k];
|
|
542954
|
-
}));
|
|
542955
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
542956
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
542957
|
-
}) : function(o, v) {
|
|
542958
|
-
o["default"] = v;
|
|
542959
|
-
});
|
|
542960
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
542961
|
-
if (mod && mod.__esModule) return mod;
|
|
542962
|
-
var result = {};
|
|
542963
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
542964
|
-
__setModuleDefault(result, mod);
|
|
542965
|
-
return result;
|
|
542966
|
-
};
|
|
542967
544141
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
542968
544142
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
542969
544143
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -542982,14 +544156,11 @@ const fs_1 = __importDefault(__webpack_require__(79896));
|
|
|
542982
544156
|
const os_1 = __importDefault(__webpack_require__(70857));
|
|
542983
544157
|
const path_1 = __importDefault(__webpack_require__(16928));
|
|
542984
544158
|
const chalk_1 = __importDefault(__webpack_require__(15896));
|
|
542985
|
-
const interactive_1 = __webpack_require__(57695);
|
|
542986
|
-
const framework_core_1 = __webpack_require__(50594);
|
|
542987
544159
|
const toolbox_1 = __webpack_require__(25901);
|
|
542988
544160
|
const utils_1 = __webpack_require__(82079);
|
|
542989
|
-
const Hosting = __importStar(__webpack_require__(2767));
|
|
542990
|
-
const Function = __importStar(__webpack_require__(11686));
|
|
542991
544161
|
const auth_1 = __webpack_require__(73052);
|
|
542992
544162
|
const i18n_1 = __webpack_require__(69258);
|
|
544163
|
+
const deploy_1 = __webpack_require__(98681);
|
|
542993
544164
|
function smartDeploy() {
|
|
542994
544165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
542995
544166
|
const loading = (0, utils_1.loadingFactory)();
|
|
@@ -543013,10 +544184,7 @@ function smartDeploy() {
|
|
|
543013
544184
|
yield (0, utils_1.initProjectConfig)(envId, region, projectPath);
|
|
543014
544185
|
utils_1.logger.success((0, i18n_1.t)('初始化项目成功!\n'));
|
|
543015
544186
|
}
|
|
543016
|
-
|
|
543017
|
-
if (!setup) {
|
|
543018
|
-
return;
|
|
543019
|
-
}
|
|
544187
|
+
utils_1.logger.info(chalk_1.default.gray((0, i18n_1.t)('项目目录: {{path}}', { path: relative })));
|
|
543020
544188
|
const config = yield (0, utils_1.getCloudBaseConfig)();
|
|
543021
544189
|
let envId = config === null || config === void 0 ? void 0 : config.envId;
|
|
543022
544190
|
if (!(config === null || config === void 0 ? void 0 : config.region) && !region) {
|
|
@@ -543033,32 +544201,13 @@ function smartDeploy() {
|
|
|
543033
544201
|
}
|
|
543034
544202
|
const parser = new toolbox_1.ConfigParser();
|
|
543035
544203
|
parser.update('region', region);
|
|
543036
|
-
|
|
544204
|
+
const ctx = {
|
|
544205
|
+
globalOptions: {}
|
|
544206
|
+
};
|
|
544207
|
+
yield (0, deploy_1.executeAppDeploy)(ctx, [], utils_1.logger);
|
|
543037
544208
|
});
|
|
543038
544209
|
}
|
|
543039
544210
|
exports.smartDeploy = smartDeploy;
|
|
543040
|
-
function callFramework(envId) {
|
|
543041
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
543042
|
-
const loginState = yield utils_1.authSupevisor.getLoginState();
|
|
543043
|
-
const { token, secretId, secretKey } = loginState;
|
|
543044
|
-
const config = yield (0, utils_1.getCloudBaseConfig)();
|
|
543045
|
-
yield (0, framework_core_1.run)({
|
|
543046
|
-
projectPath: process.cwd(),
|
|
543047
|
-
cloudbaseConfig: {
|
|
543048
|
-
secretId,
|
|
543049
|
-
secretKey,
|
|
543050
|
-
token,
|
|
543051
|
-
envId
|
|
543052
|
-
},
|
|
543053
|
-
config,
|
|
543054
|
-
logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
|
|
543055
|
-
resourceProviders: {
|
|
543056
|
-
hosting: Hosting,
|
|
543057
|
-
function: Function
|
|
543058
|
-
}
|
|
543059
|
-
}, 'deploy', '');
|
|
543060
|
-
});
|
|
543061
|
-
}
|
|
543062
544211
|
|
|
543063
544212
|
|
|
543064
544213
|
/***/ }),
|
|
@@ -550773,7 +551922,7 @@ let NosqlExecuteCommand = class NosqlExecuteCommand extends common_1.Command {
|
|
|
550773
551922
|
common_2.databaseNameOption,
|
|
550774
551923
|
common_2.jsonOption
|
|
550775
551924
|
],
|
|
550776
|
-
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',
|
|
550777
551926
|
requiredEnvId: false,
|
|
550778
551927
|
autoRunLogin: true
|
|
550779
551928
|
};
|
|
@@ -596730,6 +597879,7 @@ __exportStar(__webpack_require__(58430), exports);
|
|
|
596730
597879
|
__exportStar(__webpack_require__(38001), exports);
|
|
596731
597880
|
__exportStar(__webpack_require__(11502), exports);
|
|
596732
597881
|
__exportStar(__webpack_require__(81106), exports);
|
|
597882
|
+
__exportStar(__webpack_require__(60928), exports);
|
|
596733
597883
|
|
|
596734
597884
|
|
|
596735
597885
|
/***/ }),
|
|
@@ -600789,6 +601939,38 @@ function dump(input, options) {
|
|
|
600789
601939
|
module.exports.dump = dump;
|
|
600790
601940
|
|
|
600791
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
|
+
|
|
600792
601974
|
/***/ }),
|
|
600793
601975
|
|
|
600794
601976
|
/***/ 49653:
|
|
@@ -631221,6 +632403,20 @@ function outputJsonSync (file, data, options) {
|
|
|
631221
632403
|
module.exports = outputJsonSync
|
|
631222
632404
|
|
|
631223
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
|
+
|
|
631224
632420
|
/***/ }),
|
|
631225
632421
|
|
|
631226
632422
|
/***/ 55112:
|
|
@@ -665288,6 +666484,7 @@ const access_1 = __webpack_require__(70427);
|
|
|
665288
666484
|
const user_1 = __webpack_require__(71858);
|
|
665289
666485
|
const cloudBaseRun_1 = __webpack_require__(24344);
|
|
665290
666486
|
const mysql_1 = __webpack_require__(61697);
|
|
666487
|
+
const cloudApp_1 = __webpack_require__(32665);
|
|
665291
666488
|
const permission_1 = __webpack_require__(24786);
|
|
665292
666489
|
class Environment {
|
|
665293
666490
|
constructor(context, envId) {
|
|
@@ -665311,6 +666508,7 @@ class Environment {
|
|
|
665311
666508
|
this.cloudBaseRunService = new cloudBaseRun_1.CloudBaseRunService(this);
|
|
665312
666509
|
this.mysqlService = new mysql_1.MysqlService(this);
|
|
665313
666510
|
this.permissionService = new permission_1.PermissionService(this);
|
|
666511
|
+
this.cloudAppService = new cloudApp_1.CloudAppService(this);
|
|
665314
666512
|
}
|
|
665315
666513
|
async lazyInit() {
|
|
665316
666514
|
if (!this.inited) {
|
|
@@ -665373,6 +666571,9 @@ class Environment {
|
|
|
665373
666571
|
getMysqlService() {
|
|
665374
666572
|
return this.mysqlService;
|
|
665375
666573
|
}
|
|
666574
|
+
getCloudAppService() {
|
|
666575
|
+
return this.cloudAppService;
|
|
666576
|
+
}
|
|
665376
666577
|
getPermissionService() {
|
|
665377
666578
|
return this.permissionService;
|
|
665378
666579
|
}
|
|
@@ -679799,6 +681000,35 @@ NodejsStreamInputAdapter.prototype.resume = function () {
|
|
|
679799
681000
|
module.exports = NodejsStreamInputAdapter;
|
|
679800
681001
|
|
|
679801
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
|
+
|
|
679802
681032
|
/***/ }),
|
|
679803
681033
|
|
|
679804
681034
|
/***/ 60973:
|
|
@@ -711682,7 +712912,7 @@ module.exports = {
|
|
|
711682
712912
|
var iteratorSymbol = (__webpack_require__(72380).iterator)
|
|
711683
712913
|
, isArguments = __webpack_require__(28746)
|
|
711684
712914
|
, isFunction = __webpack_require__(92840)
|
|
711685
|
-
, toPosInt = __webpack_require__(
|
|
712915
|
+
, toPosInt = __webpack_require__(55046)
|
|
711686
712916
|
, callable = __webpack_require__(25499)
|
|
711687
712917
|
, validValue = __webpack_require__(67134)
|
|
711688
712918
|
, isValue = __webpack_require__(89762)
|
|
@@ -731809,7 +733039,7 @@ module.exports = pipeline;
|
|
|
731809
733039
|
"use strict";
|
|
731810
733040
|
|
|
731811
733041
|
|
|
731812
|
-
var toPosInt = __webpack_require__(
|
|
733042
|
+
var toPosInt = __webpack_require__(55046)
|
|
731813
733043
|
, value = __webpack_require__(67134)
|
|
731814
733044
|
, slice = Array.prototype.slice;
|
|
731815
733045
|
|
|
@@ -766133,7 +767363,7 @@ module.exports = from;
|
|
|
766133
767363
|
"use strict";
|
|
766134
767364
|
|
|
766135
767365
|
|
|
766136
|
-
var toPosInt = __webpack_require__(
|
|
767366
|
+
var toPosInt = __webpack_require__(55046);
|
|
766137
767367
|
|
|
766138
767368
|
var test = function (arg1, arg2) { return arg2; };
|
|
766139
767369
|
|
|
@@ -819023,6 +820253,115 @@ function createBaseFor(fromRight) {
|
|
|
819023
820253
|
module.exports = createBaseFor;
|
|
819024
820254
|
|
|
819025
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
|
+
|
|
819026
820365
|
/***/ }),
|
|
819027
820366
|
|
|
819028
820367
|
/***/ 83283:
|
|
@@ -834502,6 +835841,226 @@ class Git extends git_base_1.GitBase {
|
|
|
834502
835841
|
exports.Git = Git;
|
|
834503
835842
|
//# sourceMappingURL=git.js.map
|
|
834504
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
|
+
|
|
834505
836064
|
/***/ }),
|
|
834506
836065
|
|
|
834507
836066
|
/***/ 85248:
|
|
@@ -841890,7 +843449,7 @@ exports["default"] = def;
|
|
|
841890
843449
|
"use strict";
|
|
841891
843450
|
|
|
841892
843451
|
|
|
841893
|
-
var toPosInt = __webpack_require__(
|
|
843452
|
+
var toPosInt = __webpack_require__(55046)
|
|
841894
843453
|
, callable = __webpack_require__(25499)
|
|
841895
843454
|
, value = __webpack_require__(67134)
|
|
841896
843455
|
, objHasOwnProperty = Object.prototype.hasOwnProperty
|
|
@@ -924287,6 +925846,48 @@ function regExpEscape (s) {
|
|
|
924287
925846
|
}
|
|
924288
925847
|
|
|
924289
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
|
+
|
|
924290
925891
|
/***/ }),
|
|
924291
925892
|
|
|
924292
925893
|
/***/ 94068:
|
|
@@ -937639,6 +939240,9 @@ const outputHelpInfo = () => {
|
|
|
937639
939240
|
db [cmd] ${(0, i18n_1.t)('数据库管理操作')}
|
|
937640
939241
|
agent [cmd] ${(0, i18n_1.t)('Agent 管理操作')}
|
|
937641
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)('临时密钥管理操作')}
|
|
937642
939246
|
`;
|
|
937643
939247
|
const options = `
|
|
937644
939248
|
${(0, i18n_1.t)('选项')}
|
|
@@ -944813,9 +946417,34 @@ class CloudBase {
|
|
|
944813
946417
|
get mysql() {
|
|
944814
946418
|
return this.currentEnvironment().getMysqlService();
|
|
944815
946419
|
}
|
|
946420
|
+
/**
|
|
946421
|
+
* 云托管服务(CloudBaseRun)
|
|
946422
|
+
* 提供云托管版本流量配置等能力
|
|
946423
|
+
* @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
|
|
946424
|
+
*/
|
|
944816
946425
|
get cloudApp() {
|
|
944817
946426
|
return this.currentEnvironment().getCloudBaseRunService();
|
|
944818
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
|
+
}
|
|
944819
946448
|
commonService(service, version) {
|
|
944820
946449
|
return this.currentEnvironment().getCommonService(service, version);
|
|
944821
946450
|
}
|
|
@@ -955982,7 +957611,7 @@ if (process.platform === 'linux') {
|
|
|
955982
957611
|
|
|
955983
957612
|
|
|
955984
957613
|
|
|
955985
|
-
var toPosInteger = __webpack_require__(
|
|
957614
|
+
var toPosInteger = __webpack_require__(55046)
|
|
955986
957615
|
, lruQueue = __webpack_require__(18056)
|
|
955987
957616
|
, extensions = __webpack_require__(93923);
|
|
955988
957617
|
|
|
@@ -958644,7 +960273,7 @@ exports["default"] = $Ref;
|
|
|
958644
960273
|
|
|
958645
960274
|
|
|
958646
960275
|
var numberIsNaN = __webpack_require__(14295)
|
|
958647
|
-
, toPosInt = __webpack_require__(
|
|
960276
|
+
, toPosInt = __webpack_require__(55046)
|
|
958648
960277
|
, value = __webpack_require__(67134)
|
|
958649
960278
|
, indexOf = Array.prototype.indexOf
|
|
958650
960279
|
, objHasOwnProperty = Object.prototype.hasOwnProperty
|
|
@@ -962034,6 +963663,540 @@ module.exports = function (object, opts) {
|
|
|
962034
963663
|
};
|
|
962035
963664
|
|
|
962036
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
|
+
|
|
962037
964200
|
/***/ }),
|
|
962038
964201
|
|
|
962039
964202
|
/***/ 98718:
|