@cloudbase/cli 2.0.12-alpha.3 → 2.0.14

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 (252) hide show
  1. package/.vscode/launch.json +0 -10
  2. package/.vscode/settings.json +3 -0
  3. package/bin/cloudbase.js +0 -0
  4. package/bin/tcb.js +0 -0
  5. package/lib/commands/lowcode/app.js +2 -30
  6. package/lib/commands/run/service/create.js +4 -0
  7. package/lib/commands/run/service/deploy.js +4 -0
  8. package/lib/commands/run/service/update.js +4 -0
  9. package/lib/run/service/common.js +9 -3
  10. package/lib/run/service/deployPackage.js +2 -9
  11. package/lib/utils/checkTcbrEnv.js +5 -4
  12. package/lib/utils/debug-logger.js +30 -0
  13. package/lib/utils/net/cloud-api-request.js +7 -1
  14. package/lib/utils/net/http-request.js +16 -5
  15. package/package.json +5 -4
  16. package/types/commands/lowcode/app.d.ts +0 -10
  17. package/types/run/service/common.d.ts +4 -1
  18. package/types/types.d.ts +4 -0
  19. package/types/utils/debug-logger.d.ts +1 -0
  20. package/types/utils/net/http-request.d.ts +6 -2
  21. package/.history/.gitignore_20220624162613 +0 -84
  22. package/.history/.gitignore_20220627114054 +0 -86
  23. package/.history/package_20220711204706.json +0 -88
  24. package/.history/package_20220711204818.json +0 -88
  25. package/.history/package_20220712151717.json +0 -88
  26. package/.history/package_20220712212537.json +0 -88
  27. package/.history/package_20220722205058.json +0 -88
  28. package/.history/src/commands/lowcode/app_20220624162613.ts +0 -34
  29. package/.history/src/commands/lowcode/app_20220627114205.ts +0 -52
  30. package/.history/src/index_20220624162613.ts +0 -13
  31. package/.history/src/index_20220627113609.ts +0 -15
  32. package/.history/src/index_20220627114102.ts +0 -13
  33. package/src/auth/index.ts +0 -2
  34. package/src/auth/login.ts +0 -91
  35. package/src/auth/logout.ts +0 -7
  36. package/src/commands/account/index.ts +0 -2
  37. package/src/commands/account/login.ts +0 -192
  38. package/src/commands/account/logout.ts +0 -24
  39. package/src/commands/common.ts +0 -246
  40. package/src/commands/env/base.ts +0 -90
  41. package/src/commands/env/create.ts +0 -92
  42. package/src/commands/env/domain.ts +0 -186
  43. package/src/commands/env/index.ts +0 -4
  44. package/src/commands/env/login.ts +0 -235
  45. package/src/commands/framework/index.ts +0 -124
  46. package/src/commands/functions/alias/getRoute.ts +0 -76
  47. package/src/commands/functions/alias/index.ts +0 -2
  48. package/src/commands/functions/alias/setRoute.ts +0 -82
  49. package/src/commands/functions/code-download.ts +0 -100
  50. package/src/commands/functions/code-update.ts +0 -62
  51. package/src/commands/functions/concurrency/delete.ts +0 -45
  52. package/src/commands/functions/concurrency/index.ts +0 -3
  53. package/src/commands/functions/concurrency/list.ts +0 -58
  54. package/src/commands/functions/concurrency/set.ts +0 -47
  55. package/src/commands/functions/config-update.ts +0 -76
  56. package/src/commands/functions/copy.ts +0 -62
  57. package/src/commands/functions/delete.ts +0 -79
  58. package/src/commands/functions/deploy.ts +0 -293
  59. package/src/commands/functions/detail.ts +0 -138
  60. package/src/commands/functions/index.ts +0 -16
  61. package/src/commands/functions/invoke.ts +0 -121
  62. package/src/commands/functions/layer/bind.ts +0 -182
  63. package/src/commands/functions/layer/common.ts +0 -8
  64. package/src/commands/functions/layer/create.ts +0 -49
  65. package/src/commands/functions/layer/delete.ts +0 -73
  66. package/src/commands/functions/layer/download.ts +0 -92
  67. package/src/commands/functions/layer/index.ts +0 -7
  68. package/src/commands/functions/layer/list.ts +0 -94
  69. package/src/commands/functions/layer/sort.ts +0 -76
  70. package/src/commands/functions/list.ts +0 -68
  71. package/src/commands/functions/log.ts +0 -148
  72. package/src/commands/functions/run.ts +0 -249
  73. package/src/commands/functions/trigger-create.ts +0 -79
  74. package/src/commands/functions/trigger-delete.ts +0 -105
  75. package/src/commands/functions/version/index.ts +0 -2
  76. package/src/commands/functions/version/list.ts +0 -73
  77. package/src/commands/functions/version/publish.ts +0 -43
  78. package/src/commands/gateway/create.ts +0 -109
  79. package/src/commands/gateway/delete.ts +0 -81
  80. package/src/commands/gateway/domain.ts +0 -159
  81. package/src/commands/gateway/index.ts +0 -5
  82. package/src/commands/gateway/list.ts +0 -76
  83. package/src/commands/gateway/switch.ts +0 -107
  84. package/src/commands/helpers/index.ts +0 -3
  85. package/src/commands/helpers/init.ts +0 -431
  86. package/src/commands/helpers/new.ts +0 -117
  87. package/src/commands/helpers/open.ts +0 -67
  88. package/src/commands/hosting/hosting.ts +0 -360
  89. package/src/commands/hosting/index.ts +0 -1
  90. package/src/commands/index.ts +0 -13
  91. package/src/commands/lowcode/app.ts +0 -52
  92. package/src/commands/lowcode/comps.ts +0 -325
  93. package/src/commands/lowcode/index.ts +0 -2
  94. package/src/commands/lowcode/utils.ts +0 -25
  95. package/src/commands/run/create.ts +0 -153
  96. package/src/commands/run/delete.ts +0 -77
  97. package/src/commands/run/image/common.ts +0 -8
  98. package/src/commands/run/image/delete.ts +0 -68
  99. package/src/commands/run/image/download.ts +0 -68
  100. package/src/commands/run/image/index.ts +0 -5
  101. package/src/commands/run/image/list.ts +0 -84
  102. package/src/commands/run/image/upload.ts +0 -76
  103. package/src/commands/run/index.ts +0 -7
  104. package/src/commands/run/list.ts +0 -83
  105. package/src/commands/run/service/config.ts +0 -81
  106. package/src/commands/run/service/create.ts +0 -122
  107. package/src/commands/run/service/deploy.ts +0 -125
  108. package/src/commands/run/service/index.ts +0 -5
  109. package/src/commands/run/service/list.ts +0 -94
  110. package/src/commands/run/service/update.ts +0 -108
  111. package/src/commands/run/standalonegateway/common.ts +0 -8
  112. package/src/commands/run/standalonegateway/create.ts +0 -85
  113. package/src/commands/run/standalonegateway/destroy.ts +0 -59
  114. package/src/commands/run/standalonegateway/index.ts +0 -5
  115. package/src/commands/run/standalonegateway/list.ts +0 -53
  116. package/src/commands/run/standalonegateway/package.ts +0 -62
  117. package/src/commands/run/standalonegateway/turn.ts +0 -63
  118. package/src/commands/run/version/common.ts +0 -8
  119. package/src/commands/run/version/create.ts +0 -369
  120. package/src/commands/run/version/delete.ts +0 -64
  121. package/src/commands/run/version/index.ts +0 -5
  122. package/src/commands/run/version/list.ts +0 -91
  123. package/src/commands/run/version/modify.ts +0 -137
  124. package/src/commands/run/version/update.ts +0 -398
  125. package/src/commands/smart.ts +0 -132
  126. package/src/commands/storage/index.ts +0 -1
  127. package/src/commands/storage/storage.ts +0 -464
  128. package/src/commands/third/index.ts +0 -1
  129. package/src/commands/third/thirdAttach.ts +0 -49
  130. package/src/completion/index.ts +0 -13
  131. package/src/constant.ts +0 -154
  132. package/src/decorators/captureError.ts +0 -25
  133. package/src/decorators/constants.ts +0 -12
  134. package/src/decorators/deprecate.ts +0 -25
  135. package/src/decorators/guard.ts +0 -42
  136. package/src/decorators/index.ts +0 -7
  137. package/src/decorators/injectParams.ts +0 -54
  138. package/src/decorators/params/common.ts +0 -28
  139. package/src/decorators/params/index.ts +0 -35
  140. package/src/env/domain.ts +0 -33
  141. package/src/env/index.ts +0 -63
  142. package/src/env/login.ts +0 -80
  143. package/src/error.ts +0 -36
  144. package/src/function/alias.ts +0 -43
  145. package/src/function/base.ts +0 -253
  146. package/src/function/code.ts +0 -55
  147. package/src/function/concurrency.ts +0 -57
  148. package/src/function/create.ts +0 -78
  149. package/src/function/delete.ts +0 -42
  150. package/src/function/index.ts +0 -11
  151. package/src/function/layer/attach.ts +0 -68
  152. package/src/function/layer/create.ts +0 -63
  153. package/src/function/layer/delete.ts +0 -21
  154. package/src/function/layer/download.ts +0 -54
  155. package/src/function/layer/index.ts +0 -7
  156. package/src/function/layer/list.ts +0 -32
  157. package/src/function/layer/sort.ts +0 -24
  158. package/src/function/trigger.ts +0 -97
  159. package/src/function/update.ts +0 -35
  160. package/src/function/version.ts +0 -39
  161. package/src/function/vpc.ts +0 -22
  162. package/src/gateway/index.ts +0 -137
  163. package/src/help.ts +0 -50
  164. package/src/hosting.ts +0 -212
  165. package/src/index.ts +0 -13
  166. package/src/logger.ts +0 -17
  167. package/src/run/create.ts +0 -23
  168. package/src/run/delete.ts +0 -15
  169. package/src/run/image/build.ts +0 -36
  170. package/src/run/image/delete.ts +0 -14
  171. package/src/run/image/index.ts +0 -4
  172. package/src/run/image/info.ts +0 -27
  173. package/src/run/image/list.ts +0 -23
  174. package/src/run/index.ts +0 -8
  175. package/src/run/list.ts +0 -30
  176. package/src/run/repo.ts +0 -25
  177. package/src/run/service/common.ts +0 -311
  178. package/src/run/service/config.ts +0 -77
  179. package/src/run/service/create.ts +0 -52
  180. package/src/run/service/deployPackage.ts +0 -65
  181. package/src/run/service/index.ts +0 -7
  182. package/src/run/service/list.ts +0 -29
  183. package/src/run/service/showLogs.ts +0 -98
  184. package/src/run/service/update.ts +0 -82
  185. package/src/run/standalonegateway/create.ts +0 -24
  186. package/src/run/standalonegateway/destroy.ts +0 -19
  187. package/src/run/standalonegateway/index.ts +0 -5
  188. package/src/run/standalonegateway/list.ts +0 -74
  189. package/src/run/standalonegateway/package/index.ts +0 -1
  190. package/src/run/standalonegateway/package/list.ts +0 -24
  191. package/src/run/standalonegateway/turn/index.ts +0 -2
  192. package/src/run/standalonegateway/turn/off.ts +0 -19
  193. package/src/run/standalonegateway/turn/on.ts +0 -19
  194. package/src/run/version/create.ts +0 -68
  195. package/src/run/version/delete.ts +0 -16
  196. package/src/run/version/index.ts +0 -6
  197. package/src/run/version/list.ts +0 -17
  198. package/src/run/version/modify.ts +0 -17
  199. package/src/run/version/repo.ts +0 -28
  200. package/src/run/version/update.ts +0 -59
  201. package/src/storage.ts +0 -114
  202. package/src/third/index.ts +0 -13
  203. package/src/types.ts +0 -672
  204. package/src/utils/auth.ts +0 -15
  205. package/src/utils/checkTcbrEnv.ts +0 -67
  206. package/src/utils/cli-table.ts +0 -23
  207. package/src/utils/commonParamsCheck.ts +0 -65
  208. package/src/utils/config.ts +0 -39
  209. package/src/utils/env.ts +0 -244
  210. package/src/utils/fs/del.ts +0 -5
  211. package/src/utils/fs/index.ts +0 -71
  212. package/src/utils/function-packer.ts +0 -97
  213. package/src/utils/index.ts +0 -25
  214. package/src/utils/log.ts +0 -82
  215. package/src/utils/net/cloud-api-request.ts +0 -62
  216. package/src/utils/net/credential.ts +0 -53
  217. package/src/utils/net/http-request.ts +0 -84
  218. package/src/utils/net/index.ts +0 -5
  219. package/src/utils/net/manager-service.ts +0 -36
  220. package/src/utils/net/proxy.ts +0 -6
  221. package/src/utils/notice.ts +0 -28
  222. package/src/utils/output/highlight.ts +0 -5
  223. package/src/utils/output/index.ts +0 -3
  224. package/src/utils/output/link.ts +0 -10
  225. package/src/utils/output/loading.ts +0 -82
  226. package/src/utils/parallel.ts +0 -82
  227. package/src/utils/platform/index.ts +0 -3
  228. package/src/utils/platform/mac.ts +0 -21
  229. package/src/utils/platform/os.ts +0 -64
  230. package/src/utils/platform/port.ts +0 -10
  231. package/src/utils/progress-bar.ts +0 -38
  232. package/src/utils/prompt/index.ts +0 -1
  233. package/src/utils/prompt/select.ts +0 -60
  234. package/src/utils/reporter/agree.ts +0 -20
  235. package/src/utils/reporter/download.ts +0 -26
  236. package/src/utils/reporter/index.ts +0 -3
  237. package/src/utils/reporter/usage.ts +0 -20
  238. package/src/utils/store/auth.ts +0 -49
  239. package/src/utils/store/common.ts +0 -8
  240. package/src/utils/store/db.ts +0 -68
  241. package/src/utils/store/index.ts +0 -5
  242. package/src/utils/store/usage.ts +0 -12
  243. package/src/utils/tcbrApi/callTcbrApi.ts +0 -28
  244. package/src/utils/tcbrApi/index.ts +0 -1
  245. package/src/utils/template.ts +0 -170
  246. package/src/utils/tools/encoding.ts +0 -8
  247. package/src/utils/tools/index.ts +0 -4
  248. package/src/utils/tools/object.ts +0 -33
  249. package/src/utils/tools/time.ts +0 -38
  250. package/src/utils/tools/uid.ts +0 -19
  251. package/src/utils/validator.ts +0 -65
  252. package/yarn-error.log +0 -12841
@@ -4,16 +4,6 @@
4
4
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
- {
8
- "name": "Launch Program",
9
- "program": "${workspaceFolder}/bin/tcb.js",
10
- "request": "launch",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "args": ["lowcode", "watch"],
15
- "type": "node"
16
- },
17
7
  {
18
8
  "type": "node",
19
9
  "request": "launch",
@@ -0,0 +1,3 @@
1
+ {
2
+ "typescript.tsdk": "node_modules\\typescript\\lib"
3
+ }
package/bin/cloudbase.js CHANGED
File without changes
package/bin/tcb.js CHANGED
File without changes
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
21
  });
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.DanielWatch = exports.LowCodeWatch = void 0;
24
+ exports.LowCodeWatch = void 0;
25
25
  const common_1 = require("../common");
26
26
  const lowcode_cli_1 = require("@cloudbase/lowcode-cli");
27
27
  const decorators_1 = require("../../decorators");
@@ -48,7 +48,7 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
49
  yield (0, lowcode_cli_1.watchApp)({
50
50
  watchPort: 8288,
51
- wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
51
+ wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath,
52
52
  });
53
53
  });
54
54
  }
@@ -65,31 +65,3 @@ LowCodeWatch = __decorate([
65
65
  (0, common_1.ICommand)()
66
66
  ], LowCodeWatch);
67
67
  exports.LowCodeWatch = LowCodeWatch;
68
- let DanielWatch = class DanielWatch extends common_1.Command {
69
- get options() {
70
- return {
71
- cmd: 'lowcode',
72
- childCmd: 'watch-ws',
73
- options: [],
74
- desc: '开启云开发低码的本地开发模式',
75
- requiredEnvId: false
76
- };
77
- }
78
- execute(ctx, options) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- console.log('>>> 启动啦');
81
- });
82
- }
83
- };
84
- __decorate([
85
- (0, decorators_1.InjectParams)(),
86
- __param(0, (0, decorators_1.CmdContext)()),
87
- __param(1, (0, decorators_1.ArgsOptions)()),
88
- __metadata("design:type", Function),
89
- __metadata("design:paramtypes", [Object, Object]),
90
- __metadata("design:returntype", Promise)
91
- ], DanielWatch.prototype, "execute", null);
92
- DanielWatch = __decorate([
93
- (0, common_1.ICommand)()
94
- ], DanielWatch);
95
- exports.DanielWatch = DanielWatch;
@@ -81,6 +81,10 @@ let CreateServiceTcbr = class CreateServiceTcbr extends common_1.Command {
81
81
  flags: '--envParams <envParams>',
82
82
  desc: '环境变量,格式为xx=a&yy=b,默认为空'
83
83
  },
84
+ {
85
+ flags: '--log_type <log_type>',
86
+ desc: '日志类型,只能为 none,如需自定义日志,请前往控制台配置'
87
+ },
84
88
  {
85
89
  flags: '--containerPort <containerPort>',
86
90
  desc: '监听端口,必填'
@@ -80,6 +80,10 @@ let DeployServiceTcbr = class DeployServiceTcbr extends common_1.Command {
80
80
  flags: '--envParams <envParams>',
81
81
  desc: '环境变量,格式为xx=a&yy=b,默认为空'
82
82
  },
83
+ {
84
+ flags: '--log_type <log_type>',
85
+ desc: '日志类型,只能为 none,如需自定义日志,请前往控制台配置'
86
+ },
83
87
  {
84
88
  flags: '--containerPort <containerPort>',
85
89
  desc: '监听端口,必填'
@@ -80,6 +80,10 @@ let UpdateServiceTcbr = class UpdateServiceTcbr extends common_1.Command {
80
80
  flags: '--envParams <envParams>',
81
81
  desc: '环境变量,格式为xx=a&yy=b,默认为空'
82
82
  },
83
+ {
84
+ flags: '--log_type <log_type>',
85
+ desc: '日志类型,只能为 none,如需自定义日志,请前往控制台配置'
86
+ },
83
87
  {
84
88
  flags: '--containerPort <containerPort>',
85
89
  desc: '监听端口,必填'
@@ -87,7 +87,7 @@ function checkRequiredParams(options) {
87
87
  }
88
88
  function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerConfig) {
89
89
  return __awaiter(this, void 0, void 0, function* () {
90
- let { noConfirm: _noConfirm = false, override: _override = (defaultOverride || false), envId, serviceName, path, cpu, mem, minNum, maxNum, policyDetails, customLogs, envParams, containerPort, remark, targetDir, dockerfile, image, custom_image, library_image, json: _json = false } = options;
90
+ let { noConfirm: _noConfirm = false, override: _override = (defaultOverride || false), envId, serviceName, path, cpu, mem, minNum, maxNum, policyDetails, customLogs, envParams, containerPort, remark, targetDir, dockerfile, image, custom_image, library_image, log_type, json: _json = false } = options;
91
91
  checkRequiredParams({
92
92
  envId,
93
93
  serviceName,
@@ -111,7 +111,10 @@ function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerC
111
111
  maxNum,
112
112
  minNum
113
113
  });
114
- const defaultLogType = 'none';
114
+ if (log_type && log_type !== "none") {
115
+ throw new toolbox_1.CloudBaseError('日志类型 log_type 只能为 none,如需自定义日志,请前往控制台配置');
116
+ }
117
+ const defaultLogType = "none";
115
118
  const newServiceOptions = {
116
119
  ServerName: serviceName,
117
120
  EnvId: envId,
@@ -132,7 +135,10 @@ function tcbrServiceOptions(options, isCreated, defaultOverride, previousServerC
132
135
  Port: containerPort,
133
136
  HasDockerfile: true,
134
137
  Dockerfile: dockerfile || 'Dockerfile',
135
- LogType: defaultLogType
138
+ LogType: (0, utils_1.parseInputParam)(log_type, _override, null, previousServerConfig === null || previousServerConfig === void 0 ? void 0 : previousServerConfig.LogType, defaultLogType),
139
+ LogSetId: previousServerConfig === null || previousServerConfig === void 0 ? void 0 : previousServerConfig.LogSetId,
140
+ LogTopicId: previousServerConfig === null || previousServerConfig === void 0 ? void 0 : previousServerConfig.LogTopicId,
141
+ LogParseType: previousServerConfig === null || previousServerConfig === void 0 ? void 0 : previousServerConfig.LogParseType,
136
142
  },
137
143
  DeployInfo: Object.assign({}, DeployInfo)
138
144
  };
@@ -38,13 +38,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.packageDeploy = void 0;
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const fs = __importStar(require("fs"));
41
- const utils_1 = require("../../utils");
42
41
  const __1 = require("..");
43
42
  const toolbox_1 = require("@cloudbase/toolbox");
44
43
  function packageDeploy(options) {
45
44
  return __awaiter(this, void 0, void 0, function* () {
46
45
  let { envId, serviceName, filePath, fileToIgnore } = options;
47
- let { PackageName, PackageVersion, UploadUrl } = yield (0, __1.createBuild)({
46
+ let { PackageName, PackageVersion, UploadUrl, UploadHeaders } = yield (0, __1.createBuild)({
48
47
  envId,
49
48
  serviceName
50
49
  });
@@ -68,13 +67,7 @@ function packageDeploy(options) {
68
67
  }
69
68
  try {
70
69
  return yield (0, toolbox_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
71
- yield (0, utils_1.fetch)(UploadUrl, {
72
- method: 'PUT',
73
- body: fs.createReadStream(zipFile),
74
- headers: {
75
- 'content-type': 'application/zip'
76
- }
77
- });
70
+ yield (0, __1.uploadZip)(zipFile, UploadUrl, UploadHeaders[0]);
78
71
  return { PackageName, PackageVersion };
79
72
  }), {
80
73
  startTip: '\n正在上传代码包...',
@@ -15,8 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.logEnvCheck = exports.checkTcbrEnv = void 0;
16
16
  const chalk_1 = __importDefault(require("chalk"));
17
17
  const error_1 = require("../error");
18
- const net_1 = require("./net");
19
- const tcbService = net_1.CloudApiService.getInstance('tcb');
18
+ const tcbrApi_1 = require("./tcbrApi");
20
19
  const oldCmdSet = `
21
20
  服务列表:tcb run:deprecated list --envId <envId>
22
21
  创建服务:tcb run:deprecated create --envId <envId> --name <name>
@@ -45,11 +44,13 @@ function checkTcbrEnv(envId, isTcbr) {
45
44
  if (envId === undefined) {
46
45
  throw new error_1.CloudBaseError('请使用 -e 或 --envId 指定环境 ID');
47
46
  }
48
- const { EnvList: [envInfo] } = yield tcbService.request('DescribeEnvs', {
47
+ const { data: res } = yield (0, tcbrApi_1.callTcbrApi)('DescribeCloudRunEnvs', {
49
48
  EnvId: envId
50
49
  });
50
+ const { EnvList } = res;
51
+ const envInfo = EnvList === null || EnvList === void 0 ? void 0 : EnvList.find((item) => (item === null || item === void 0 ? void 0 : item.EnvId) === envId);
51
52
  if (envInfo === undefined) {
52
- throw new error_1.CloudBaseError('无法读取到有效的环境信息,请检查环境 ID 是否正确');
53
+ throw new error_1.CloudBaseError(`无法读取到有效的环境信息,请检查环境 ID 是否正确\nrequestId: ${res === null || res === void 0 ? void 0 : res.RequestId}`);
53
54
  }
54
55
  if ((envInfo.EnvType === 'tcbr' && isTcbr) || (envInfo.EnvType !== 'tcbr' && !isTcbr)) {
55
56
  return 0;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.debugLogger = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ function debugLogger(req, resp, startTime, endTime, writeToLocal = true) {
10
+ if (process.env.NODE_ENV !== 'DEBUG') {
11
+ return;
12
+ }
13
+ const cost = endTime.valueOf() - startTime.valueOf();
14
+ const startTimeFormatted = startTime.toISOString();
15
+ const endTimeFormatted = endTime.toISOString();
16
+ console.log(chalk_1.default.underline('\n[DEBUG]', startTimeFormatted));
17
+ console.log(chalk_1.default.cyan(JSON.stringify(req)), '\n');
18
+ console.log(chalk_1.default.underline('[DEBUG]', endTimeFormatted));
19
+ console.log(chalk_1.default.magenta(JSON.stringify(resp)), '\n');
20
+ if (writeToLocal) {
21
+ const filePath = `${process.cwd()}/cloudbase-cli.debug.log`;
22
+ const logContent = `\n{start:${startTimeFormatted}, req: ${JSON.stringify(req)}, end:${endTimeFormatted}, resp: ${JSON.stringify(resp)}, cost: ${cost}}`;
23
+ fs_1.default.appendFile(filePath, logContent, (err) => {
24
+ if (err) {
25
+ console.error(chalk_1.default.red(`\n写入日志失败:${JSON.stringify(err)}`));
26
+ }
27
+ });
28
+ }
29
+ }
30
+ exports.debugLogger = debugLogger;
@@ -14,6 +14,7 @@ const toolbox_1 = require("@cloudbase/toolbox");
14
14
  const cloud_api_1 = require("@cloudbase/cloud-api");
15
15
  const error_1 = require("../../error");
16
16
  const constant_1 = require("../../constant");
17
+ const debug_logger_1 = require("../debug-logger");
17
18
  let commonCredential;
18
19
  const isTokenExpired = (credential, gap = 120) => credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000;
19
20
  class CloudApiService {
@@ -49,7 +50,12 @@ class CloudApiService {
49
50
  request(action, data = {}, method = 'POST') {
50
51
  return __awaiter(this, void 0, void 0, function* () {
51
52
  const region = this.region || (yield (0, toolbox_1.getRegion)());
52
- return this.apiService.request({ action, data, method, region });
53
+ const reqOptions = { action, data, method, region };
54
+ const startTime = new Date();
55
+ const res = yield this.apiService.request(reqOptions);
56
+ const endTime = new Date();
57
+ (0, debug_logger_1.debugLogger)(reqOptions, res, startTime, endTime);
58
+ return res;
53
59
  });
54
60
  }
55
61
  }
@@ -18,6 +18,7 @@ const https_proxy_agent_1 = require("https-proxy-agent");
18
18
  const constant_1 = require("../../constant");
19
19
  const error_1 = require("../../error");
20
20
  const proxy_1 = require("./proxy");
21
+ const debug_logger_1 = require("../debug-logger");
21
22
  function handleTimeout(e) {
22
23
  if (e.type === 'request-timeout') {
23
24
  throw new error_1.CloudBaseError('请求超时,请检查你的网络,如果终端无法直接访问公网,请设置终端 HTTP 请求代理!');
@@ -26,6 +27,16 @@ function handleTimeout(e) {
26
27
  throw e;
27
28
  }
28
29
  }
30
+ function fetchWithDebugLogger(useTextTransform, ...args) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const startTime = new Date();
33
+ const rawRes = yield (0, node_fetch_1.default)(...args);
34
+ const res = useTextTransform ? yield rawRes.text() : rawRes;
35
+ const endTime = new Date();
36
+ (0, debug_logger_1.debugLogger)(args, res, startTime, endTime);
37
+ return res;
38
+ });
39
+ }
29
40
  function fetch(url, config = {}) {
30
41
  return __awaiter(this, void 0, void 0, function* () {
31
42
  const proxy = (0, proxy_1.getProxy)();
@@ -36,8 +47,8 @@ function fetch(url, config = {}) {
36
47
  let json;
37
48
  let text;
38
49
  try {
39
- const res = yield (0, node_fetch_1.default)(url, config);
40
- text = yield res.text();
50
+ const res = yield fetchWithDebugLogger(true, url, config);
51
+ text = res;
41
52
  json = JSON.parse(text);
42
53
  }
43
54
  catch (e) {
@@ -65,8 +76,8 @@ function postFetch(url, data) {
65
76
  let json;
66
77
  let text;
67
78
  try {
68
- const res = yield (0, node_fetch_1.default)(url, config);
69
- text = yield res.text();
79
+ const res = yield fetchWithDebugLogger(true, url, config);
80
+ text = res;
70
81
  json = JSON.parse(text);
71
82
  }
72
83
  catch (e) {
@@ -85,7 +96,7 @@ function fetchStream(url, config = {}) {
85
96
  }
86
97
  config.timeout = constant_1.REQUEST_TIMEOUT;
87
98
  try {
88
- const res = yield (0, node_fetch_1.default)(url, config);
99
+ const res = yield fetchWithDebugLogger(false, url, config);
89
100
  return res;
90
101
  }
91
102
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.0.12-alpha.3",
3
+ "version": "2.0.14",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
12
12
  "tsc": "tsc",
13
13
  "pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
14
- "postinstall": "node ./post-install.js || exit 0"
14
+ "postinstall": "node ./post-install.js || exit 0",
15
+ "prepublishOnly": "npm run build"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -23,7 +24,7 @@
23
24
  },
24
25
  "husky": {
25
26
  "hooks": {
26
- "pre-commit": "npm run build && git add ."
27
+ "pre-commit": "npm run build"
27
28
  }
28
29
  },
29
30
  "author": "cwuyiqing@gmail.com",
@@ -31,7 +32,7 @@
31
32
  "dependencies": {
32
33
  "@cloudbase/cloud-api": "^0.5.5",
33
34
  "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "0.14.5-alpha.3",
35
+ "@cloudbase/lowcode-cli": "^0.14.3",
35
36
  "@cloudbase/manager-node": "4.0.1",
36
37
  "@cloudbase/toolbox": "^0.7.3",
37
38
  "@sentry/node": "^5.10.2",
@@ -12,13 +12,3 @@ export declare class LowCodeWatch extends Command {
12
12
  };
13
13
  execute(ctx: any, options: any): Promise<void>;
14
14
  }
15
- export declare class DanielWatch extends Command {
16
- get options(): {
17
- cmd: string;
18
- childCmd: string;
19
- options: any[];
20
- desc: string;
21
- requiredEnvId: boolean;
22
- };
23
- execute(ctx: any, options: any): Promise<void>;
24
- }
@@ -27,7 +27,10 @@ export declare function tcbrServiceOptions(options: ITcbrServiceOptions, isCreat
27
27
  Port: number;
28
28
  HasDockerfile: boolean;
29
29
  Dockerfile: string;
30
- LogType: string;
30
+ LogType: any;
31
+ LogSetId: any;
32
+ LogTopicId: any;
33
+ LogParseType: any;
31
34
  };
32
35
  DeployInfo: any;
33
36
  }>;
package/types/types.d.ts CHANGED
@@ -490,6 +490,9 @@ export interface IDescribeCloudRunServerDetail {
490
490
  ServerConfig: ITcbrServerBaseConfig;
491
491
  RequestId: string;
492
492
  }
493
+ export declare const enum TCBR_LOG_TYPE {
494
+ NONE = "none"
495
+ }
493
496
  export interface ITcbrServiceOptions {
494
497
  noConfirm: boolean;
495
498
  override: boolean;
@@ -511,6 +514,7 @@ export interface ITcbrServiceOptions {
511
514
  image: string;
512
515
  custom_image: string;
513
516
  library_image: string;
517
+ log_type: TCBR_LOG_TYPE;
514
518
  json: boolean;
515
519
  }
516
520
  export interface ICloudRunProcessLog {
@@ -0,0 +1 @@
1
+ export declare function debugLogger(req: unknown, resp: unknown, startTime: Date, endTime: Date, writeToLocal?: boolean): void;
@@ -1,4 +1,8 @@
1
- import { RequestInit } from 'node-fetch';
1
+ import _fetch, { RequestInit } from 'node-fetch';
2
+ declare type fetchReturnType = ReturnType<typeof _fetch>;
3
+ declare type UnPromisify<T> = T extends PromiseLike<infer U> ? U : T;
4
+ declare type fetchReturnTypeExtracted = UnPromisify<fetchReturnType>;
2
5
  export declare function fetch(url: string, config?: RequestInit): Promise<any>;
3
6
  export declare function postFetch(url: string, data?: Record<string, any>): Promise<any>;
4
- export declare function fetchStream(url: any, config?: Record<string, any>): Promise<import("node-fetch").Response>;
7
+ export declare function fetchStream(url: any, config?: Record<string, any>): Promise<fetchReturnTypeExtracted>;
8
+ export {};
@@ -1,84 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- package-lock.json
8
- yarn.lock
9
-
10
- # Runtime data
11
- pids
12
- *.pid
13
- *.seed
14
- *.pid.lock
15
-
16
- # Directory for instrumented libs generated by jscoverage/JSCover
17
- lib-cov
18
-
19
- # Coverage directory used by tools like istanbul
20
- coverage
21
-
22
- # nyc test coverage
23
- .nyc_output
24
-
25
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26
- .grunt
27
-
28
- # Bower dependency directory (https://bower.io/)
29
- bower_components
30
-
31
- # node-waf configuration
32
- .lock-wscript
33
-
34
- # Compiled binary addons (https://nodejs.org/api/addons.html)
35
- build/Release
36
-
37
- # Dependency directories
38
- node_modules/
39
- jspm_packages/
40
-
41
- # TypeScript v1 declaration files
42
- typings/
43
-
44
- # Optional npm cache directory
45
- .npm
46
-
47
- # Optional eslint cache
48
- .eslintcache
49
-
50
- # Optional REPL history
51
- .node_repl_history
52
-
53
- # Output of 'npm pack'
54
- *.tgz
55
-
56
- # Yarn Integrity file
57
- .yarn-integrity
58
-
59
- # dotenv environment variables file
60
- .env
61
-
62
- # next.js build output
63
- .next
64
-
65
- dist
66
-
67
- example/**/tcb.json
68
-
69
- node_modules
70
-
71
- .idea
72
- .vscode/*
73
- !.vscode/launch.json
74
-
75
- # Test api Key
76
- test/api-key.js
77
-
78
- pkg/
79
-
80
- .DS_Store
81
-
82
- # Build files
83
- /lib
84
- /types
@@ -1,86 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- package-lock.json
8
- yarn.lock
9
-
10
- # Runtime data
11
- pids
12
- *.pid
13
- *.seed
14
- *.pid.lock
15
-
16
- # Directory for instrumented libs generated by jscoverage/JSCover
17
- lib-cov
18
-
19
- # Coverage directory used by tools like istanbul
20
- coverage
21
-
22
- # nyc test coverage
23
- .nyc_output
24
-
25
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26
- .grunt
27
-
28
- # Bower dependency directory (https://bower.io/)
29
- bower_components
30
-
31
- # node-waf configuration
32
- .lock-wscript
33
-
34
- # Compiled binary addons (https://nodejs.org/api/addons.html)
35
- build/Release
36
-
37
- # Dependency directories
38
- node_modules/
39
- jspm_packages/
40
-
41
- # TypeScript v1 declaration files
42
- typings/
43
-
44
- # Optional npm cache directory
45
- .npm
46
-
47
- # Optional eslint cache
48
- .eslintcache
49
-
50
- # Optional REPL history
51
- .node_repl_history
52
-
53
- # Output of 'npm pack'
54
- *.tgz
55
-
56
- # Yarn Integrity file
57
- .yarn-integrity
58
-
59
- # dotenv environment variables file
60
- .env
61
-
62
- # next.js build output
63
- .next
64
-
65
- dist
66
-
67
- example/**/tcb.json
68
-
69
- node_modules
70
-
71
- .idea
72
- .vscode/*
73
- !.vscode/launch.json
74
-
75
- # Test api Key
76
- test/api-key.js
77
-
78
- pkg/
79
-
80
- .DS_Store
81
-
82
- # Build files
83
- /lib
84
- /types
85
-
86
- .history
@@ -1,88 +0,0 @@
1
- {
2
- "name": "@cloudbase/cli",
3
- "version": "2.0.11",
4
- "description": "cli tool for cloudbase",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "build": "rimraf lib types && tsc",
8
- "watch": "rimraf lib types && tsc -w",
9
- "dev": "rimraf lib types && tsc -w",
10
- "eslint": "eslint \"./**/*.ts\"",
11
- "test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
12
- "tsc": "tsc",
13
- "pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
14
- "postinstall": "node ./post-install.js || exit 0"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/TencentCloudBase/cloud-base-cli.git"
19
- },
20
- "bin": {
21
- "tcb": "bin/tcb.js",
22
- "cloudbase": "bin/cloudbase.js"
23
- },
24
- "husky": {
25
- "hooks": {
26
- "pre-commit": "npm run build && git add ."
27
- }
28
- },
29
- "author": "cwuyiqing@gmail.com",
30
- "license": "ISC",
31
- "dependencies": {
32
- "@cloudbase/cloud-api": "^0.5.5",
33
- "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "^0.14.3",
35
- "@cloudbase/manager-node": "4.0.1",
36
- "@cloudbase/toolbox": "^0.7.3",
37
- "@sentry/node": "^5.10.2",
38
- "address": "^1.1.2",
39
- "chalk": "^2.4.2",
40
- "cli-table3": "^0.5.1",
41
- "commander": "7",
42
- "del": "^5.1.0",
43
- "didyoumean": "^1.2.2",
44
- "enquirer": "^2.3.6",
45
- "execa": "^4.0.3",
46
- "fs-extra": "^8.1.0",
47
- "https-proxy-agent": "^5.0.1",
48
- "inquirer": "^6.5.0",
49
- "lodash": "^4.17.21",
50
- "log-symbols": "^3.0.0",
51
- "lowdb": "^1.0.0",
52
- "make-dir": "^3.0.0",
53
- "node-fetch": "^2.6.0",
54
- "open": "^7.0.0",
55
- "ora": "^4.0.2",
56
- "portfinder": "^1.0.28",
57
- "progress": "^2.0.3",
58
- "query-string": "^6.8.1",
59
- "reflect-metadata": "^0.1.13",
60
- "semver": "^7.3.7",
61
- "tar-fs": "^2.0.1",
62
- "terminal-link": "^2.1.1",
63
- "unzipper": "^0.10.10",
64
- "update-notifier": "^4.0.0",
65
- "xdg-basedir": "^4.0.0",
66
- "yargs": "^16.2.0",
67
- "yargs-parser": "^21.0.1"
68
- },
69
- "devDependencies": {
70
- "@types/jest": "^27",
71
- "@types/koa__router": "^8.0.11",
72
- "@types/lodash": "^4.14.182",
73
- "@types/node": "^12.12.38",
74
- "@types/node-fetch": "^2.5.4",
75
- "@types/react": "^17.0.37",
76
- "@types/semver": "^7.3.9",
77
- "@types/webpack-dev-server": "^3.11.1",
78
- "@typescript-eslint/eslint-plugin": "^4.8.1",
79
- "@typescript-eslint/parser": "^4.8.1",
80
- "eslint": "^7.14.0",
81
- "eslint-config-alloy": "^3.8.2",
82
- "husky": "^3.0.9",
83
- "jest": "^27",
84
- "rimraf": "^3.0.2",
85
- "ts-jest": "^27",
86
- "typescript": "^4.7.2"
87
- }
88
- }