@cloudbase/cli 2.0.12 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/.history/.gitignore_20220624162613 +84 -0
  2. package/.history/.gitignore_20220627114054 +86 -0
  3. package/.history/package_20220711204706.json +88 -0
  4. package/.history/package_20220711204818.json +88 -0
  5. package/.history/package_20220712151717.json +88 -0
  6. package/.history/package_20220712212537.json +88 -0
  7. package/.history/package_20220722205058.json +88 -0
  8. package/.history/package_20220726110155.json +88 -0
  9. package/.history/package_20220726110201.json +88 -0
  10. package/.history/package_20220728110905.json +88 -0
  11. package/.history/package_20220728110936.json +88 -0
  12. package/.history/package_20220728111531.json +89 -0
  13. package/.history/package_20220728111810.json +89 -0
  14. package/.history/src/commands/lowcode/app_20220728111717.ts +52 -0
  15. package/{src/commands/lowcode/app.ts → .history/src/commands/lowcode/app_20220728112031.ts} +2 -2
  16. package/{src/index.ts → .history/src/index_20220624162613.ts} +0 -0
  17. package/.history/src/index_20220627113609.ts +15 -0
  18. package/.history/src/index_20220627114102.ts +13 -0
  19. package/.vscode/launch.json +10 -0
  20. package/bin/cloudbase.js +0 -0
  21. package/bin/tcb.js +5 -5
  22. package/lib/commands/account/login.js +3 -6
  23. package/lib/commands/env/index.js +0 -1
  24. package/lib/commands/lowcode/app.js +1 -1
  25. package/lib/commands/run/index.js +0 -1
  26. package/lib/commands/run/service/deploy.js +6 -1
  27. package/lib/commands/run/service/index.js +0 -1
  28. package/lib/commands/run/service/update.js +4 -0
  29. package/lib/constant.js +15 -1
  30. package/lib/env/index.js +1 -11
  31. package/lib/run/index.js +0 -1
  32. package/lib/run/service/common.js +20 -7
  33. package/lib/run/service/config.js +2 -3
  34. package/lib/run/service/deployPackage.js +2 -9
  35. package/lib/run/service/index.js +0 -1
  36. package/lib/run/service/update.js +1 -1
  37. package/lib/utils/debug-logger.js +30 -0
  38. package/lib/utils/net/cloud-api-request.js +7 -1
  39. package/lib/utils/net/http-request.js +16 -5
  40. package/package.json +2 -2
  41. package/types/commands/env/index.d.ts +0 -1
  42. package/types/commands/run/index.d.ts +0 -1
  43. package/types/commands/run/service/index.d.ts +0 -1
  44. package/types/env/index.d.ts +0 -6
  45. package/types/run/index.d.ts +0 -1
  46. package/types/run/service/common.d.ts +8 -1
  47. package/types/run/service/index.d.ts +0 -1
  48. package/types/types.d.ts +4 -0
  49. package/types/utils/debug-logger.d.ts +1 -0
  50. package/types/utils/net/http-request.d.ts +6 -2
  51. package/lib/commands/env/create.js +0 -115
  52. package/lib/commands/run/create.js +0 -162
  53. package/lib/commands/run/service/create.js +0 -144
  54. package/lib/run/create.js +0 -19
  55. package/lib/run/service/create.js +0 -67
  56. package/src/auth/index.ts +0 -2
  57. package/src/auth/login.ts +0 -91
  58. package/src/auth/logout.ts +0 -7
  59. package/src/commands/account/index.ts +0 -2
  60. package/src/commands/account/login.ts +0 -192
  61. package/src/commands/account/logout.ts +0 -24
  62. package/src/commands/common.ts +0 -246
  63. package/src/commands/env/base.ts +0 -90
  64. package/src/commands/env/create.ts +0 -92
  65. package/src/commands/env/domain.ts +0 -186
  66. package/src/commands/env/index.ts +0 -4
  67. package/src/commands/env/login.ts +0 -235
  68. package/src/commands/framework/index.ts +0 -124
  69. package/src/commands/functions/alias/getRoute.ts +0 -76
  70. package/src/commands/functions/alias/index.ts +0 -2
  71. package/src/commands/functions/alias/setRoute.ts +0 -82
  72. package/src/commands/functions/code-download.ts +0 -100
  73. package/src/commands/functions/code-update.ts +0 -62
  74. package/src/commands/functions/concurrency/delete.ts +0 -45
  75. package/src/commands/functions/concurrency/index.ts +0 -3
  76. package/src/commands/functions/concurrency/list.ts +0 -58
  77. package/src/commands/functions/concurrency/set.ts +0 -47
  78. package/src/commands/functions/config-update.ts +0 -76
  79. package/src/commands/functions/copy.ts +0 -62
  80. package/src/commands/functions/delete.ts +0 -79
  81. package/src/commands/functions/deploy.ts +0 -293
  82. package/src/commands/functions/detail.ts +0 -138
  83. package/src/commands/functions/index.ts +0 -16
  84. package/src/commands/functions/invoke.ts +0 -121
  85. package/src/commands/functions/layer/bind.ts +0 -182
  86. package/src/commands/functions/layer/common.ts +0 -8
  87. package/src/commands/functions/layer/create.ts +0 -49
  88. package/src/commands/functions/layer/delete.ts +0 -73
  89. package/src/commands/functions/layer/download.ts +0 -92
  90. package/src/commands/functions/layer/index.ts +0 -7
  91. package/src/commands/functions/layer/list.ts +0 -94
  92. package/src/commands/functions/layer/sort.ts +0 -76
  93. package/src/commands/functions/list.ts +0 -68
  94. package/src/commands/functions/log.ts +0 -148
  95. package/src/commands/functions/run.ts +0 -249
  96. package/src/commands/functions/trigger-create.ts +0 -79
  97. package/src/commands/functions/trigger-delete.ts +0 -105
  98. package/src/commands/functions/version/index.ts +0 -2
  99. package/src/commands/functions/version/list.ts +0 -73
  100. package/src/commands/functions/version/publish.ts +0 -43
  101. package/src/commands/gateway/create.ts +0 -109
  102. package/src/commands/gateway/delete.ts +0 -81
  103. package/src/commands/gateway/domain.ts +0 -159
  104. package/src/commands/gateway/index.ts +0 -5
  105. package/src/commands/gateway/list.ts +0 -76
  106. package/src/commands/gateway/switch.ts +0 -107
  107. package/src/commands/helpers/index.ts +0 -3
  108. package/src/commands/helpers/init.ts +0 -431
  109. package/src/commands/helpers/new.ts +0 -117
  110. package/src/commands/helpers/open.ts +0 -67
  111. package/src/commands/hosting/hosting.ts +0 -360
  112. package/src/commands/hosting/index.ts +0 -1
  113. package/src/commands/index.ts +0 -13
  114. package/src/commands/lowcode/comps.ts +0 -325
  115. package/src/commands/lowcode/index.ts +0 -2
  116. package/src/commands/lowcode/utils.ts +0 -25
  117. package/src/commands/run/create.ts +0 -153
  118. package/src/commands/run/delete.ts +0 -77
  119. package/src/commands/run/image/common.ts +0 -8
  120. package/src/commands/run/image/delete.ts +0 -68
  121. package/src/commands/run/image/download.ts +0 -68
  122. package/src/commands/run/image/index.ts +0 -5
  123. package/src/commands/run/image/list.ts +0 -84
  124. package/src/commands/run/image/upload.ts +0 -76
  125. package/src/commands/run/index.ts +0 -7
  126. package/src/commands/run/list.ts +0 -83
  127. package/src/commands/run/service/config.ts +0 -81
  128. package/src/commands/run/service/create.ts +0 -122
  129. package/src/commands/run/service/deploy.ts +0 -125
  130. package/src/commands/run/service/index.ts +0 -5
  131. package/src/commands/run/service/list.ts +0 -94
  132. package/src/commands/run/service/update.ts +0 -108
  133. package/src/commands/run/standalonegateway/common.ts +0 -8
  134. package/src/commands/run/standalonegateway/create.ts +0 -85
  135. package/src/commands/run/standalonegateway/destroy.ts +0 -59
  136. package/src/commands/run/standalonegateway/index.ts +0 -5
  137. package/src/commands/run/standalonegateway/list.ts +0 -53
  138. package/src/commands/run/standalonegateway/package.ts +0 -62
  139. package/src/commands/run/standalonegateway/turn.ts +0 -63
  140. package/src/commands/run/version/common.ts +0 -8
  141. package/src/commands/run/version/create.ts +0 -369
  142. package/src/commands/run/version/delete.ts +0 -64
  143. package/src/commands/run/version/index.ts +0 -5
  144. package/src/commands/run/version/list.ts +0 -91
  145. package/src/commands/run/version/modify.ts +0 -137
  146. package/src/commands/run/version/update.ts +0 -398
  147. package/src/commands/smart.ts +0 -132
  148. package/src/commands/storage/index.ts +0 -1
  149. package/src/commands/storage/storage.ts +0 -464
  150. package/src/commands/third/index.ts +0 -1
  151. package/src/commands/third/thirdAttach.ts +0 -49
  152. package/src/completion/index.ts +0 -13
  153. package/src/constant.ts +0 -154
  154. package/src/decorators/captureError.ts +0 -25
  155. package/src/decorators/constants.ts +0 -12
  156. package/src/decorators/deprecate.ts +0 -25
  157. package/src/decorators/guard.ts +0 -42
  158. package/src/decorators/index.ts +0 -7
  159. package/src/decorators/injectParams.ts +0 -54
  160. package/src/decorators/params/common.ts +0 -28
  161. package/src/decorators/params/index.ts +0 -35
  162. package/src/env/domain.ts +0 -33
  163. package/src/env/index.ts +0 -63
  164. package/src/env/login.ts +0 -80
  165. package/src/error.ts +0 -36
  166. package/src/function/alias.ts +0 -43
  167. package/src/function/base.ts +0 -253
  168. package/src/function/code.ts +0 -55
  169. package/src/function/concurrency.ts +0 -57
  170. package/src/function/create.ts +0 -78
  171. package/src/function/delete.ts +0 -42
  172. package/src/function/index.ts +0 -11
  173. package/src/function/layer/attach.ts +0 -68
  174. package/src/function/layer/create.ts +0 -63
  175. package/src/function/layer/delete.ts +0 -21
  176. package/src/function/layer/download.ts +0 -54
  177. package/src/function/layer/index.ts +0 -7
  178. package/src/function/layer/list.ts +0 -32
  179. package/src/function/layer/sort.ts +0 -24
  180. package/src/function/trigger.ts +0 -97
  181. package/src/function/update.ts +0 -35
  182. package/src/function/version.ts +0 -39
  183. package/src/function/vpc.ts +0 -22
  184. package/src/gateway/index.ts +0 -137
  185. package/src/help.ts +0 -50
  186. package/src/hosting.ts +0 -212
  187. package/src/logger.ts +0 -17
  188. package/src/run/create.ts +0 -23
  189. package/src/run/delete.ts +0 -15
  190. package/src/run/image/build.ts +0 -36
  191. package/src/run/image/delete.ts +0 -14
  192. package/src/run/image/index.ts +0 -4
  193. package/src/run/image/info.ts +0 -27
  194. package/src/run/image/list.ts +0 -23
  195. package/src/run/index.ts +0 -8
  196. package/src/run/list.ts +0 -30
  197. package/src/run/repo.ts +0 -25
  198. package/src/run/service/common.ts +0 -311
  199. package/src/run/service/config.ts +0 -77
  200. package/src/run/service/create.ts +0 -52
  201. package/src/run/service/deployPackage.ts +0 -65
  202. package/src/run/service/index.ts +0 -7
  203. package/src/run/service/list.ts +0 -29
  204. package/src/run/service/showLogs.ts +0 -98
  205. package/src/run/service/update.ts +0 -82
  206. package/src/run/standalonegateway/create.ts +0 -24
  207. package/src/run/standalonegateway/destroy.ts +0 -19
  208. package/src/run/standalonegateway/index.ts +0 -5
  209. package/src/run/standalonegateway/list.ts +0 -74
  210. package/src/run/standalonegateway/package/index.ts +0 -1
  211. package/src/run/standalonegateway/package/list.ts +0 -24
  212. package/src/run/standalonegateway/turn/index.ts +0 -2
  213. package/src/run/standalonegateway/turn/off.ts +0 -19
  214. package/src/run/standalonegateway/turn/on.ts +0 -19
  215. package/src/run/version/create.ts +0 -68
  216. package/src/run/version/delete.ts +0 -16
  217. package/src/run/version/index.ts +0 -6
  218. package/src/run/version/list.ts +0 -17
  219. package/src/run/version/modify.ts +0 -17
  220. package/src/run/version/repo.ts +0 -28
  221. package/src/run/version/update.ts +0 -59
  222. package/src/storage.ts +0 -114
  223. package/src/third/index.ts +0 -13
  224. package/src/types.ts +0 -672
  225. package/src/utils/auth.ts +0 -15
  226. package/src/utils/checkTcbrEnv.ts +0 -69
  227. package/src/utils/cli-table.ts +0 -23
  228. package/src/utils/commonParamsCheck.ts +0 -65
  229. package/src/utils/config.ts +0 -39
  230. package/src/utils/env.ts +0 -244
  231. package/src/utils/fs/del.ts +0 -5
  232. package/src/utils/fs/index.ts +0 -71
  233. package/src/utils/function-packer.ts +0 -97
  234. package/src/utils/index.ts +0 -25
  235. package/src/utils/log.ts +0 -82
  236. package/src/utils/net/cloud-api-request.ts +0 -62
  237. package/src/utils/net/credential.ts +0 -53
  238. package/src/utils/net/http-request.ts +0 -84
  239. package/src/utils/net/index.ts +0 -5
  240. package/src/utils/net/manager-service.ts +0 -36
  241. package/src/utils/net/proxy.ts +0 -6
  242. package/src/utils/notice.ts +0 -28
  243. package/src/utils/output/highlight.ts +0 -5
  244. package/src/utils/output/index.ts +0 -3
  245. package/src/utils/output/link.ts +0 -10
  246. package/src/utils/output/loading.ts +0 -82
  247. package/src/utils/parallel.ts +0 -82
  248. package/src/utils/platform/index.ts +0 -3
  249. package/src/utils/platform/mac.ts +0 -21
  250. package/src/utils/platform/os.ts +0 -64
  251. package/src/utils/platform/port.ts +0 -10
  252. package/src/utils/progress-bar.ts +0 -38
  253. package/src/utils/prompt/index.ts +0 -1
  254. package/src/utils/prompt/select.ts +0 -60
  255. package/src/utils/reporter/agree.ts +0 -20
  256. package/src/utils/reporter/download.ts +0 -26
  257. package/src/utils/reporter/index.ts +0 -3
  258. package/src/utils/reporter/usage.ts +0 -20
  259. package/src/utils/store/auth.ts +0 -49
  260. package/src/utils/store/common.ts +0 -8
  261. package/src/utils/store/db.ts +0 -68
  262. package/src/utils/store/index.ts +0 -5
  263. package/src/utils/store/usage.ts +0 -12
  264. package/src/utils/tcbrApi/callTcbrApi.ts +0 -28
  265. package/src/utils/tcbrApi/index.ts +0 -1
  266. package/src/utils/template.ts +0 -170
  267. package/src/utils/tools/encoding.ts +0 -8
  268. package/src/utils/tools/index.ts +0 -4
  269. package/src/utils/tools/object.ts +0 -33
  270. package/src/utils/tools/time.ts +0 -38
  271. package/src/utils/tools/uid.ts +0 -19
  272. package/src/utils/validator.ts +0 -65
  273. package/types/commands/env/create.d.ts +0 -12
  274. package/types/commands/run/create.d.ts +0 -13
  275. package/types/commands/run/service/create.d.ts +0 -13
  276. package/types/run/create.d.ts +0 -2
  277. package/types/run/service/create.d.ts +0 -7
@@ -1,115 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __importDefault = (this && this.__importDefault) || function (mod) {
24
- return (mod && mod.__esModule) ? mod : { "default": mod };
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.CreateCommand = void 0;
28
- const inquirer_1 = __importDefault(require("inquirer"));
29
- const env_1 = require("../../env");
30
- const utils_1 = require("../../utils");
31
- const error_1 = require("../../error");
32
- const common_1 = require("../common");
33
- const decorators_1 = require("../../decorators");
34
- let CreateCommand = class CreateCommand extends common_1.Command {
35
- get options() {
36
- return {
37
- cmd: 'env',
38
- childCmd: 'create <alias>',
39
- deprecateCmd: 'env:create <alias>',
40
- options: [],
41
- desc: '创建云开发免费环境',
42
- requiredEnvId: false
43
- };
44
- }
45
- execute(params) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const alias = params === null || params === void 0 ? void 0 : params[0];
48
- if (!alias) {
49
- throw new error_1.CloudBaseError('环境名称不能为空!');
50
- }
51
- const loading = (0, utils_1.loadingFactory)();
52
- loading.start('检查中...');
53
- const { CurrentFreeEnvNum, MaxFreeEnvNum, CurrentEnvNum, MaxEnvNum } = yield (0, env_1.getEnvLimit)();
54
- loading.stop();
55
- if (+CurrentFreeEnvNum >= +MaxFreeEnvNum) {
56
- const link = (0, utils_1.genClickableLink)('https://console.cloud.tencent.com/tcb');
57
- throw new error_1.CloudBaseError(`免费环境数量已达上限,无法创建免费的环境,请到云开发-控制台中创建付费环境\n👉 ${link}`);
58
- }
59
- if (+CurrentEnvNum >= +MaxEnvNum) {
60
- throw new error_1.CloudBaseError('环境数量已达上限,无法创建新的环境!');
61
- }
62
- const { payment } = yield inquirer_1.default.prompt({
63
- type: 'list',
64
- name: 'payment',
65
- choices: [
66
- {
67
- name: '按量计费(免费配额)',
68
- value: 'postpay'
69
- },
70
- {
71
- name: '包年包月(免费版本)',
72
- value: 'prepay'
73
- }
74
- ],
75
- message: '请选择环境计费模式:',
76
- default: 'postpay'
77
- });
78
- const { confirm } = yield inquirer_1.default.prompt({
79
- type: 'confirm',
80
- name: 'confirm',
81
- message: '因支付权限问题,仅支持通过 API 秘钥登录的主账户使用 CLI 创建包年包月免费环境,其他用户需要登录控制台支付相关订单才能完成环境创建,是否继续?',
82
- default: false
83
- });
84
- if (!confirm) {
85
- throw new error_1.CloudBaseError('创建环境流程终止');
86
- }
87
- loading.start('环境创建中...');
88
- try {
89
- const res = yield (0, env_1.createEnv)({
90
- alias,
91
- paymentMode: payment
92
- });
93
- }
94
- catch (e) {
95
- if (e.code === 'ResourceInsufficient') {
96
- throw new error_1.CloudBaseError('环境数量已达上限,无法创建新的环境!');
97
- }
98
- throw e;
99
- }
100
- loading.succeed('创建环境成功,初始化预计需要花费 3 分钟');
101
- console.log('你可以使用 cloudbase init 创建云开发项目');
102
- });
103
- }
104
- };
105
- __decorate([
106
- (0, decorators_1.InjectParams)(),
107
- __param(0, (0, decorators_1.ArgsParams)()),
108
- __metadata("design:type", Function),
109
- __metadata("design:paramtypes", [Object]),
110
- __metadata("design:returntype", Promise)
111
- ], CreateCommand.prototype, "execute", null);
112
- CreateCommand = __decorate([
113
- (0, common_1.ICommand)()
114
- ], CreateCommand);
115
- exports.CreateCommand = CreateCommand;
@@ -1,162 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.CreateRun = void 0;
25
- const common_1 = require("../common");
26
- const error_1 = require("../../error");
27
- const run_1 = require("../../run");
28
- const utils_1 = require("../../utils");
29
- const decorators_1 = require("../../decorators");
30
- const ZoneMap = {
31
- shanghai: '上海',
32
- guangzhou: '广州'
33
- };
34
- let CreateRun = class CreateRun extends common_1.Command {
35
- get options() {
36
- return {
37
- cmd: 'run:deprecated',
38
- childCmd: 'create',
39
- options: [
40
- {
41
- flags: '-e, --envId <envId>',
42
- desc: '环境 Id'
43
- },
44
- {
45
- flags: '-n, --name <name>',
46
- desc: '服务名称,必填'
47
- },
48
- {
49
- flags: '-c, --vpc <vpc>',
50
- desc: '云托管网络设置,默认系统创建,选择已有私有网络则填入格式为私有网络Id|子网Id1,...,子网Idn'
51
- },
52
- {
53
- flags: '-p, --repo <repo>',
54
- desc: '镜像仓库名,默认系统创建'
55
- },
56
- {
57
- flags: '-m, --remark <remark>',
58
- desc: '备注,默认为空'
59
- },
60
- {
61
- flags: '-a, --publicAccess <publicAccess>',
62
- desc: '是否允许公网访问(Y/N),默认为允许'
63
- }
64
- ],
65
- desc: '创建云托管服务'
66
- };
67
- }
68
- execute(envId, options) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
71
- if (envCheckType !== 0) {
72
- (0, utils_1.logEnvCheck)(envId, envCheckType);
73
- return;
74
- }
75
- let { name: _name = '', vpc: _vpc = '', repo: _repo = '', log: _log = '', remark: _remark = '', publicAccess: _publicAccess = '' } = options;
76
- let name;
77
- let remark;
78
- let vpcInfo;
79
- let imageRepo;
80
- let logType;
81
- let esInfo;
82
- let publicAccess;
83
- const loading = (0, utils_1.loadingFactory)();
84
- if (!_name) {
85
- throw new error_1.CloudBaseError('请填入服务名');
86
- }
87
- else {
88
- name = _name;
89
- }
90
- remark = _remark;
91
- if (!_vpc) {
92
- vpcInfo = {
93
- VpcId: '',
94
- SubnetIds: [],
95
- CreateType: 1
96
- };
97
- }
98
- else {
99
- vpcInfo = {
100
- VpcId: _vpc.split('|')[0],
101
- SubnetIds: _vpc.split('|')[1].split(','),
102
- CreateType: 2
103
- };
104
- }
105
- if (!_repo) {
106
- imageRepo = undefined;
107
- }
108
- else {
109
- imageRepo = _repo;
110
- }
111
- if (!_log) {
112
- logType = 'cls';
113
- }
114
- else {
115
- logType = 'es';
116
- esInfo = _log.split('&').reduce((pre, item) => {
117
- pre[item.split('=')[0]] = item.split('=')[0] === 'Port' ? Number(item.split('=')[1]) : item.split('=')[1];
118
- return pre;
119
- }, {});
120
- }
121
- if (!_publicAccess) {
122
- publicAccess = 1;
123
- }
124
- else if (/[^nNyY]/.test(_publicAccess) || _publicAccess.length !== 1) {
125
- throw new error_1.CloudBaseError('请输入符合规范的公网访问服务设置');
126
- }
127
- else if (_publicAccess === 'N' || _publicAccess === 'n') {
128
- publicAccess = 2;
129
- }
130
- else {
131
- publicAccess = 1;
132
- }
133
- const res = yield (0, run_1.createRun)({
134
- envId,
135
- name,
136
- remark,
137
- vpcInfo,
138
- imageRepo,
139
- logType,
140
- esInfo,
141
- publicAccess,
142
- isPublic: true
143
- });
144
- if (res === 'succ')
145
- loading.succeed(`云托管服务 ${name} 创建成功!`);
146
- else
147
- throw new error_1.CloudBaseError('创建失败,请查看是否已经有同名服务');
148
- });
149
- }
150
- };
151
- __decorate([
152
- (0, decorators_1.InjectParams)(),
153
- __param(0, (0, decorators_1.EnvId)()),
154
- __param(1, (0, decorators_1.ArgsOptions)()),
155
- __metadata("design:type", Function),
156
- __metadata("design:paramtypes", [Object, Object]),
157
- __metadata("design:returntype", Promise)
158
- ], CreateRun.prototype, "execute", null);
159
- CreateRun = __decorate([
160
- (0, common_1.ICommand)()
161
- ], CreateRun);
162
- exports.CreateRun = CreateRun;
@@ -1,144 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.CreateServiceTcbr = void 0;
25
- const common_1 = require("../../common");
26
- const decorators_1 = require("../../../decorators");
27
- const error_1 = require("../../../error");
28
- const run_1 = require("../../../run");
29
- const utils_1 = require("../../../utils");
30
- let CreateServiceTcbr = class CreateServiceTcbr extends common_1.Command {
31
- get options() {
32
- return {
33
- cmd: 'run',
34
- childCmd: 'service:create',
35
- options: [
36
- {
37
- flags: '--noConfirm',
38
- desc: '发布前是否跳过二次确认'
39
- },
40
- {
41
- flags: '--override',
42
- desc: '缺省的参数是否沿用旧版本配置'
43
- },
44
- {
45
- flags: '-e, --envId <envId>',
46
- desc: '环境 Id,必填'
47
- },
48
- {
49
- flags: '-s, --serviceName <serviceName>',
50
- desc: '服务名,必填'
51
- },
52
- {
53
- flags: '--path <path>',
54
- desc: '本地代码根目录'
55
- },
56
- {
57
- flags: '--cpu <cpu>',
58
- desc: '单一实例cpu规格,默认0.5'
59
- },
60
- {
61
- flags: '--mem <mem>',
62
- desc: '单一实例内存规格,默认1'
63
- },
64
- {
65
- flags: '--minNum <minNum>',
66
- desc: '最小副本数,默认0'
67
- },
68
- {
69
- flags: '--maxNum <maxNum>',
70
- desc: '最大副本数,默认50,不能大于50'
71
- },
72
- {
73
- flags: '--policyDetails <policyDetails>',
74
- desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
75
- },
76
- {
77
- flags: '--customLogs <customLogs>',
78
- desc: '日志采集路径,默认stdout'
79
- },
80
- {
81
- flags: '--envParams <envParams>',
82
- desc: '环境变量,格式为xx=a&yy=b,默认为空'
83
- },
84
- {
85
- flags: '--containerPort <containerPort>',
86
- desc: '监听端口,必填'
87
- },
88
- {
89
- flags: '--remark <remark>',
90
- desc: '版本备注,默认为空'
91
- },
92
- {
93
- flags: '--targetDir <targetDir>',
94
- desc: '目标目录'
95
- },
96
- {
97
- flags: '--dockerfile <dockerfile>',
98
- desc: 'Dockerfile文件名,默认为 Dockerfile'
99
- },
100
- {
101
- flags: '--custom_image <custom_image>',
102
- desc: 'TCR 仓库镜像 URL'
103
- },
104
- {
105
- flags: '--image <image>',
106
- desc: '镜像标签或ID'
107
- },
108
- {
109
- flags: '--json',
110
- desc: '以 JSON 形式展示结果'
111
- }
112
- ],
113
- desc: '在指定环境下创建服务'
114
- };
115
- }
116
- execute(options) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, true);
119
- if (envCheckType !== 0) {
120
- (0, utils_1.logEnvCheck)(options.envId, envCheckType);
121
- return;
122
- }
123
- const { data: serviceDetail } = yield (0, run_1.describeCloudRunServerDetail)({
124
- envId: options.envId,
125
- serviceName: options.serviceName
126
- });
127
- if (serviceDetail !== undefined) {
128
- throw new error_1.CloudBaseError('当前服务已存在,请使用 tcb run service:deploy 更新服务');
129
- }
130
- yield (0, run_1.createTcbrService)(options);
131
- });
132
- }
133
- };
134
- __decorate([
135
- (0, decorators_1.InjectParams)(),
136
- __param(0, (0, decorators_1.ArgsOptions)()),
137
- __metadata("design:type", Function),
138
- __metadata("design:paramtypes", [Object]),
139
- __metadata("design:returntype", Promise)
140
- ], CreateServiceTcbr.prototype, "execute", null);
141
- CreateServiceTcbr = __decorate([
142
- (0, common_1.ICommand)()
143
- ], CreateServiceTcbr);
144
- exports.CreateServiceTcbr = CreateServiceTcbr;
package/lib/run/create.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createRun = void 0;
13
- const utils_1 = require("../utils");
14
- const tcbService = utils_1.CloudApiService.getInstance('tcb');
15
- const createRun = (options) => __awaiter(void 0, void 0, void 0, function* () {
16
- const { Result } = yield tcbService.request('EstablishCloudBaseRunServer', Object.assign(Object.assign({ EnvId: options.envId, ServiceName: options.name, Remark: options.remark, VpcInfo: options.vpcInfo, LogType: options.logType, IsPublic: options.isPublic }, (options.imageRepo ? { ImageRepo: options.imageRepo } : {})), (options.logType === 'es' ? { EsInfo: options.esInfo } : {})));
17
- return Result;
18
- });
19
- exports.createRun = createRun;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createTcbrService = exports.createCloudRunServer = exports.describeCloudRunServerDetail = void 0;
16
- const utils_1 = require("../../utils");
17
- const _1 = require(".");
18
- const inquirer_1 = __importDefault(require("inquirer"));
19
- const toolbox_1 = require("@cloudbase/toolbox");
20
- const describeCloudRunServerDetail = (options) => __awaiter(void 0, void 0, void 0, function* () {
21
- return yield (0, utils_1.callTcbrApi)('DescribeCloudRunServerDetail', {
22
- EnvId: options.envId,
23
- ServerName: options.serviceName,
24
- });
25
- });
26
- exports.describeCloudRunServerDetail = describeCloudRunServerDetail;
27
- function createCloudRunServer(serviceConfigOptions) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return (0, utils_1.callTcbrApi)('CreateCloudRunServer', serviceConfigOptions);
30
- });
31
- }
32
- exports.createCloudRunServer = createCloudRunServer;
33
- function createTcbrService(options) {
34
- var _a;
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const newServiceOptions = yield (0, _1.tcbrServiceOptions)(options, false, false);
37
- if (!options.noConfirm) {
38
- const { confirm } = yield inquirer_1.default.prompt([
39
- {
40
- type: 'confirm',
41
- name: 'confirm',
42
- message: '确定要创建服务吗?',
43
- }
44
- ]);
45
- if (!confirm) {
46
- return;
47
- }
48
- }
49
- const createRes = yield createCloudRunServer(newServiceOptions);
50
- const taskId = (_a = createRes.data) === null || _a === void 0 ? void 0 : _a.TaskId;
51
- if (options.json) {
52
- console.log(JSON.stringify(createRes, null, 2));
53
- }
54
- if (process.argv.includes('--verbose')) {
55
- yield (0, _1.getLogs)({
56
- envId: options.envId,
57
- taskId,
58
- serviceName: options.serviceName
59
- });
60
- console.log(`本次任务的 TaskID: ${taskId}`);
61
- }
62
- else {
63
- toolbox_1.logger.success('创建服务成功, 本次任务的 TaskID: ' + taskId);
64
- }
65
- });
66
- }
67
- exports.createTcbrService = createTcbrService;
package/src/auth/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './login'
2
- export * from './logout'
package/src/auth/login.ts DELETED
@@ -1,91 +0,0 @@
1
- import _ from 'lodash'
2
- import { Credential } from '@cloudbase/toolbox'
3
- import { authSupevisor, checkAndGetCredential, execWithLoading, checkEnvAvaliable } from '../utils'
4
- import { ILoginOptions } from '../types'
5
- import { ENV_STATUS } from '../constant'
6
- import { Logger } from '../decorators'
7
- import { getEnvInfo } from '../env'
8
-
9
- const log = new Logger()
10
-
11
- // 登录返回 code 与信息
12
- const LoginRes = {
13
- SUCCESS: {
14
- code: 'SUCCESS',
15
- msg: '登录成功!'
16
- },
17
- INVALID_TOKEN: {
18
- code: 'INVALID_TOKEN',
19
- msg: '无效的身份信息!'
20
- },
21
- CHECK_LOGIN_FAILED: {
22
- code: 'CHECK_LOGIN_FAILED',
23
- msg: '检查登录态失败'
24
- },
25
- INVALID_PARAM(msg) {
26
- return {
27
- code: 'INVALID_PARAM',
28
- msg: `参数无效:${msg}`
29
- }
30
- }
31
- }
32
-
33
- // 打开腾讯云-云开发控制台,通过获取临时密钥登录,临时密钥可续期,最长时间为 1 个月
34
- export async function loginByWebAuth() {
35
- const credential = await authSupevisor.loginByWebAuth()
36
-
37
- if (_.isEmpty(credential)) {
38
- return LoginRes.INVALID_TOKEN
39
- }
40
-
41
- return {
42
- credential,
43
- ...LoginRes.SUCCESS
44
- }
45
- }
46
-
47
- // 使用密钥登录
48
- export async function loginWithKey(secretId?: string, secretKey?: string, token?: string) {
49
- if (!secretId || !secretKey) {
50
- return LoginRes.INVALID_PARAM('SecretID 或 SecretKey 不能为空')
51
- }
52
-
53
- const credential = await authSupevisor.loginByApiSecret(secretId, secretKey, token)
54
-
55
- if (_.isEmpty(credential)) {
56
- return LoginRes.INVALID_TOKEN
57
- }
58
-
59
- return LoginRes.SUCCESS
60
- }
61
-
62
- export async function login(
63
- options: ILoginOptions = {}
64
- ): Promise<{ code: string; msg: string; credential?: Credential }> {
65
- const { secretId, secretKey, key, token } = options
66
- return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth()
67
- }
68
-
69
- // 检查是否登录,没有登录时,自动拉起浏览器授权
70
- export async function checkLogin() {
71
- const credential = await checkAndGetCredential()
72
- // 没有登录,拉起 Web 登录
73
- if (_.isEmpty(credential)) {
74
- log.info('你还没有登录,请在控制台中授权登录')
75
-
76
- const res = await execWithLoading(() => login(), {
77
- startTip: '获取授权中...',
78
- successTip: '授权登录成功!'
79
- })
80
-
81
- const envId = res?.credential?.envId
82
-
83
- // 登录返回 envId,检查环境初始化
84
- if (envId) {
85
- const env = await getEnvInfo(envId)
86
- if (env.Status === ENV_STATUS.UNAVAILABLE) {
87
- await checkEnvAvaliable(envId)
88
- }
89
- }
90
- }
91
- }
@@ -1,7 +0,0 @@
1
- import { authSupevisor } from '../utils'
2
-
3
- // 注销登录信息
4
- export async function logout() {
5
- process.emit('logout')
6
- await authSupevisor.logout()
7
- }
@@ -1,2 +0,0 @@
1
- export * from './login'
2
- export * from './logout'