@uofx/cli 1.0.2 → 1.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 (240) hide show
  1. package/README.md +159 -3
  2. package/THIRD-PARTY-NOTICES.txt +84 -2
  3. package/dist/application/dtos/config/index.js +22 -0
  4. package/dist/application/dtos/config/request/index.js +19 -0
  5. package/dist/application/dtos/config/request/set-config.request.dto.js +3 -0
  6. package/dist/application/dtos/config/response/get-config.response.dto.js +8 -0
  7. package/dist/application/dtos/config/response/index.js +21 -0
  8. package/dist/application/dtos/dev/index.js +24 -0
  9. package/dist/application/dtos/dev/request/generate-component.request.dto.js +3 -0
  10. package/dist/application/dtos/dev/request/index.js +25 -0
  11. package/dist/application/dtos/dev/request/install-template.request.dto.js +3 -0
  12. package/dist/application/dtos/dev/request/new-project.request.dto.js +3 -0
  13. package/dist/application/dtos/dev/request/publish-plugin.request.dto.js +3 -0
  14. package/dist/application/dtos/dev/request/uninstall-template.request.dto.js +3 -0
  15. package/dist/application/dtos/dev/response/generate-component.response.dto.js +3 -0
  16. package/dist/application/dtos/dev/response/index.js +24 -0
  17. package/dist/application/dtos/dev/response/new-project.response.dto.js +3 -0
  18. package/dist/application/dtos/dev/response/publish-plugin.response.dto.js +3 -0
  19. package/dist/application/dtos/dev/response/template-info.response.dto.js +3 -0
  20. package/dist/application/dtos/env/index.js +24 -0
  21. package/dist/application/dtos/{request → env/request}/index.js +1 -3
  22. package/dist/application/dtos/env/request/list-running-instances.request.dto.js +3 -0
  23. package/dist/application/dtos/{response → env/response}/index.js +1 -1
  24. package/dist/application/dtos/env/response/list-running-instances.response.dto.js +3 -0
  25. package/dist/application/dtos/index.js +9 -2
  26. package/dist/application/dtos/logs/index.js +22 -0
  27. package/dist/application/dtos/logs/request/index.js +18 -0
  28. package/dist/application/dtos/logs/response/index.js +18 -0
  29. package/dist/application/index.js +1 -0
  30. package/dist/application/services/env/environment-validator.service.js +120 -0
  31. package/dist/application/services/env/index.js +11 -0
  32. package/dist/application/services/env/instance-cleanup.service.js +79 -0
  33. package/dist/application/services/index.js +21 -0
  34. package/dist/application/use-cases/config/get-all-config.use-case.js +54 -0
  35. package/dist/application/use-cases/config/get-config.use-case.js +7 -17
  36. package/dist/application/use-cases/config/index.js +23 -0
  37. package/dist/application/use-cases/config/set-config.use-case.js +49 -3
  38. package/dist/application/use-cases/dev/generate-component.use-case.js +138 -0
  39. package/dist/application/use-cases/dev/index.js +28 -0
  40. package/dist/application/use-cases/dev/install-template.use-case.js +60 -0
  41. package/dist/application/use-cases/dev/list-templates.use-case.js +45 -0
  42. package/dist/application/use-cases/dev/new-project.use-case.js +130 -0
  43. package/dist/application/use-cases/dev/publish-plugin.use-case.js +243 -0
  44. package/dist/application/use-cases/dev/uninstall-template.use-case.js +50 -0
  45. package/dist/application/use-cases/{instance → env}/delete-instance.use-case.js +2 -2
  46. package/dist/application/use-cases/{credentials → env}/get-credentials.use-case.js +1 -1
  47. package/dist/application/use-cases/{instance → env}/index.js +11 -0
  48. package/dist/application/use-cases/{instance → env}/install-instance.use-case.js +25 -136
  49. package/dist/application/use-cases/env/list-running-instances.use-case.js +47 -0
  50. package/dist/application/use-cases/{setup → env}/setup-environment.use-case.js +35 -4
  51. package/dist/application/use-cases/{instance → env}/start-instance.use-case.js +53 -41
  52. package/dist/application/use-cases/index.js +9 -6
  53. package/dist/application/use-cases/logs/index.js +21 -0
  54. package/dist/cli.js +175 -26
  55. package/dist/constants/defaults.js +8 -1
  56. package/dist/constants/oci-artifacts.js +4 -0
  57. package/dist/constants/paths.js +0 -4
  58. package/dist/constants/timeouts.js +5 -0
  59. package/dist/di/modules/application.module.js +13 -44
  60. package/dist/di/modules/config.module.js +19 -0
  61. package/dist/di/modules/dev.module.js +45 -0
  62. package/dist/di/modules/env.module.js +42 -0
  63. package/dist/di/modules/index.js +30 -0
  64. package/dist/di/modules/infrastructure.module.js +65 -82
  65. package/dist/di/modules/logs.module.js +15 -0
  66. package/dist/di/modules/presentation.module.js +18 -7
  67. package/dist/di/tokens.js +42 -30
  68. package/dist/domain/entities/credentials-resolver.entity.js +4 -1
  69. package/dist/domain/entities/credentials.entity.js +2 -5
  70. package/dist/domain/entities/delete-instance-validation.entity.js +4 -1
  71. package/dist/domain/entities/deployment-parameters.entity.js +11 -8
  72. package/dist/domain/entities/index.js +5 -1
  73. package/dist/domain/entities/instance-list-aggregator.entity.js +2 -2
  74. package/dist/domain/entities/instance-metadata.entity.js +2 -3
  75. package/dist/domain/entities/instance.entity.js +2 -1
  76. package/dist/domain/entities/log-filter.entity.js +6 -6
  77. package/dist/domain/entities/template-info.entity.js +63 -0
  78. package/dist/{infrastructure/utils/error-formatter.util.js → domain/errors/error-utils.js} +1 -1
  79. package/dist/domain/errors/index.js +19 -0
  80. package/dist/domain/index.js +6 -0
  81. package/dist/domain/interfaces/index.js +21 -0
  82. package/dist/domain/ports/dotnet-publisher.port.js +9 -0
  83. package/dist/{infrastructure/http/interfaces/http-client.interface.js → domain/ports/file-system.port.js} +1 -1
  84. package/dist/domain/ports/http-client.port.js +3 -0
  85. package/dist/domain/ports/index.js +10 -0
  86. package/dist/domain/ports/logger.port.js +3 -3
  87. package/dist/domain/ports/progress.port.js +10 -0
  88. package/dist/domain/ports/project-scaffolder.port.js +9 -0
  89. package/dist/domain/ports/schematics-runner.port.js +9 -0
  90. package/dist/domain/ports/template-manager.port.js +9 -0
  91. package/dist/domain/ports/wsl-setup.port.js +3 -0
  92. package/dist/domain/types/index.js +1 -0
  93. package/dist/domain/value-objects/acr-credentials.value-object.js +13 -1
  94. package/dist/domain/value-objects/chart-version.value-object.js +20 -3
  95. package/dist/domain/value-objects/config-log-level.value-object.js +2 -1
  96. package/dist/domain/value-objects/index.js +3 -1
  97. package/dist/domain/value-objects/instance-name.value-object.js +6 -3
  98. package/dist/domain/value-objects/jwt-key.value-object.js +27 -5
  99. package/dist/domain/value-objects/mssql-password.value-object.js +27 -5
  100. package/dist/domain/value-objects/output-path.value-object.js +85 -0
  101. package/dist/domain/value-objects/rsa-key-pair.value-object.js +29 -3
  102. package/dist/index.js +6 -1
  103. package/dist/infrastructure/config/{app-config.service.js → app-config.adapter.js} +29 -17
  104. package/dist/infrastructure/config/{config-validator.js → config-validator.util.js} +1 -1
  105. package/dist/infrastructure/config/index.js +14 -0
  106. package/dist/infrastructure/config/interfaces/index.js +3 -0
  107. package/dist/infrastructure/config/{crypto.service.js → services/crypto.service.js} +4 -1
  108. package/dist/infrastructure/config/services/index.js +9 -0
  109. package/dist/infrastructure/deployment/deployment.adapter.js +5 -5
  110. package/dist/infrastructure/deployment/index.js +9 -0
  111. package/dist/infrastructure/deployment/interfaces/index.js +3 -0
  112. package/dist/infrastructure/deployment/services/acr-credential-manager.service.js +18 -7
  113. package/dist/infrastructure/deployment/services/app-manager.service.js +3 -3
  114. package/dist/infrastructure/deployment/services/base-helm-deployment.service.js +13 -5
  115. package/dist/infrastructure/deployment/services/helm-registry.service.js +10 -3
  116. package/dist/infrastructure/deployment/services/index.js +35 -0
  117. package/dist/infrastructure/deployment/services/infra-manager.service.js +19 -15
  118. package/dist/infrastructure/deployment/services/k8s-job-runner.service.js +24 -6
  119. package/dist/infrastructure/deployment/services/mssql-database-init.service.js +75 -11
  120. package/dist/infrastructure/deployment/services/mssql-helm-deployment.service.js +17 -5
  121. package/dist/infrastructure/deployment/services/mssql-storage.service.js +5 -1
  122. package/dist/infrastructure/deployment/services/mssql-user-manager.service.js +7 -3
  123. package/dist/infrastructure/deployment/services/oci-artifact.service.js +8 -3
  124. package/dist/infrastructure/deployment/services/secret-manager.service.js +14 -5
  125. package/dist/infrastructure/deployment/services/service-manager.service.js +1 -1
  126. package/dist/infrastructure/deployment/services/version-compatibility.service.js +9 -5
  127. package/dist/infrastructure/dotnet/dotnet-publisher.adapter.js +143 -0
  128. package/dist/infrastructure/dotnet/index.js +9 -0
  129. package/dist/infrastructure/environment/index.js +11 -0
  130. package/dist/infrastructure/environment/interfaces/index.js +3 -0
  131. package/dist/infrastructure/{platform-detector.js → environment/platform-detector.util.js} +1 -1
  132. package/dist/infrastructure/environment/services/hardware-info.service.js +8 -8
  133. package/dist/infrastructure/environment/services/index.js +11 -0
  134. package/dist/infrastructure/errors/{error-handler.js → error-handler.adapter.js} +17 -17
  135. package/dist/infrastructure/errors/index.js +5 -21
  136. package/dist/infrastructure/execution/builders/base-command.builder.js +32 -11
  137. package/dist/infrastructure/execution/builders/index.js +26 -0
  138. package/dist/infrastructure/execution/builders/wsl-command.builder.js +39 -1
  139. package/dist/infrastructure/execution/command-builder.util.js +94 -0
  140. package/dist/infrastructure/execution/environments/index.js +23 -0
  141. package/dist/infrastructure/execution/environments/wsl-execution.environment.js +22 -7
  142. package/dist/infrastructure/execution/index.js +1 -2
  143. package/dist/infrastructure/execution/services/command-executor.service.js +389 -0
  144. package/dist/infrastructure/execution/services/index.js +8 -0
  145. package/dist/infrastructure/execution/{script-executor.service.js → services/script-executor.service.js} +12 -15
  146. package/dist/infrastructure/filesystem/filesystem.adapter.js +86 -0
  147. package/dist/infrastructure/filesystem/index.js +23 -0
  148. package/dist/infrastructure/http/{http-client.service.js → http-client.adapter.js} +20 -13
  149. package/dist/infrastructure/http/index.js +1 -1
  150. package/dist/infrastructure/interceptors/decorators/index.js +23 -0
  151. package/dist/infrastructure/interceptors/index.js +2 -2
  152. package/dist/infrastructure/interceptors/interceptor.factory.js +3 -3
  153. package/dist/infrastructure/interceptors/interfaces/index.js +3 -0
  154. package/dist/infrastructure/interceptors/services/index.js +6 -0
  155. package/dist/infrastructure/interceptors/{logging.interceptor.js → services/logging-interceptor.service.js} +4 -4
  156. package/dist/infrastructure/logger/services/file-log-reader.repository.js +1 -1
  157. package/dist/infrastructure/logger/services/file-log-writer.repository.js +1 -1
  158. package/dist/infrastructure/persistence/instance-metadata.adapter.js +2 -1
  159. package/dist/infrastructure/persistence/services/file-system-config.repository.js +10 -4
  160. package/dist/infrastructure/persistence/services/file-system-instance.repository.js +2 -2
  161. package/dist/infrastructure/platforms/index.js +18 -0
  162. package/dist/infrastructure/platforms/windows/index.js +13 -0
  163. package/dist/infrastructure/platforms/windows/interfaces/index.js +3 -0
  164. package/dist/infrastructure/platforms/windows/parsers/index.js +9 -0
  165. package/dist/infrastructure/platforms/windows/services/index.js +33 -0
  166. package/dist/infrastructure/platforms/windows/services/microk8s.service.js +28 -10
  167. package/dist/infrastructure/platforms/windows/services/rootfs-manager.service.js +7 -3
  168. package/dist/infrastructure/platforms/windows/services/windows-features.service.js +22 -8
  169. package/dist/infrastructure/platforms/windows/services/windows-info.service.js +10 -6
  170. package/dist/infrastructure/platforms/windows/services/wsl-config.service.js +15 -6
  171. package/dist/infrastructure/platforms/windows/services/wsl-info.service.js +12 -12
  172. package/dist/infrastructure/platforms/windows/services/wsl-instance-inspection.service.js +3 -3
  173. package/dist/infrastructure/platforms/windows/services/wsl-instance-lifecycle.service.js +76 -22
  174. package/dist/infrastructure/platforms/windows/services/wsl-updater.service.js +20 -15
  175. package/dist/infrastructure/platforms/windows/services/wslconfig-parser.service.js +3 -3
  176. package/dist/infrastructure/platforms/windows/wsl-instance-manager.adapter.js +8 -3
  177. package/dist/infrastructure/platforms/windows/wsl-setup.adapter.js +100 -0
  178. package/dist/infrastructure/schematics/index.js +11 -0
  179. package/dist/infrastructure/schematics/project-scaffolder.adapter.js +314 -0
  180. package/dist/infrastructure/schematics/schematics-runner.adapter.js +175 -0
  181. package/dist/infrastructure/template/index.js +25 -0
  182. package/dist/infrastructure/template/interfaces/index.js +22 -0
  183. package/dist/infrastructure/template/interfaces/template-downloader.interface.js +6 -0
  184. package/dist/infrastructure/template/interfaces/template-registry.interface.js +6 -0
  185. package/dist/infrastructure/template/services/index.js +24 -0
  186. package/dist/infrastructure/template/services/template-downloader.service.js +319 -0
  187. package/dist/infrastructure/template/services/template-registry.service.js +175 -0
  188. package/dist/infrastructure/template/template-manager.adapter.js +196 -0
  189. package/dist/infrastructure/utils/index.js +23 -0
  190. package/dist/infrastructure/utils/input-validator.util.js +7 -6
  191. package/dist/presentation/controllers/base.controller.js +36 -0
  192. package/dist/presentation/controllers/{config.controller.js → config/config.controller.js} +17 -62
  193. package/dist/presentation/controllers/config/index.js +21 -0
  194. package/dist/presentation/controllers/dev/dev.controller.js +202 -0
  195. package/dist/presentation/controllers/dev/index.js +23 -0
  196. package/dist/presentation/controllers/dev/template.controller.js +158 -0
  197. package/dist/presentation/controllers/{credentials.controller.js → env/credentials.controller.js} +8 -14
  198. package/dist/presentation/controllers/env/index.js +23 -0
  199. package/dist/presentation/controllers/{instance.controller.js → env/instance.controller.js} +35 -92
  200. package/dist/presentation/controllers/{setup.controller.js → env/setup.controller.js} +33 -66
  201. package/dist/presentation/controllers/index.js +9 -5
  202. package/dist/presentation/controllers/logs/index.js +21 -0
  203. package/dist/presentation/controllers/{logs.controller.js → logs/logs.controller.js} +8 -14
  204. package/dist/presentation/interfaces/index.js +21 -0
  205. package/dist/presentation/prompts/acr-credentials.prompt.js +37 -9
  206. package/dist/presentation/ui/constants/index.js +23 -0
  207. package/dist/presentation/ui/interaction.service.js +4 -4
  208. package/dist/presentation/ui/interfaces/cli-progress.interface.js +0 -6
  209. package/dist/presentation/ui/interfaces/index.js +6 -0
  210. package/package.json +6 -1
  211. package/dist/application/dtos/request/set-config.request.dto.js +0 -16
  212. package/dist/infrastructure/errors/error-handler.interface.js +0 -3
  213. package/dist/infrastructure/execution/command-builder.js +0 -252
  214. package/dist/infrastructure/execution/command-executor.service.js +0 -230
  215. /package/dist/application/dtos/{request → config/request}/get-config.request.dto.js +0 -0
  216. /package/dist/application/dtos/{request → env/request}/delete-instance.request.dto.js +0 -0
  217. /package/dist/application/dtos/{request → env/request}/get-credentials.request.dto.js +0 -0
  218. /package/dist/application/dtos/{request → env/request}/install-instance.request.dto.js +0 -0
  219. /package/dist/application/dtos/{request → env/request}/list-charts.request.dto.js +0 -0
  220. /package/dist/application/dtos/{request → env/request}/setup-environment.request.dto.js +0 -0
  221. /package/dist/application/dtos/{request → env/request}/start-instance.request.dto.js +0 -0
  222. /package/dist/application/dtos/{request → env/request}/stop-instance.request.dto.js +0 -0
  223. /package/dist/application/dtos/{response → env/response}/credentials.response.dto.js +0 -0
  224. /package/dist/application/dtos/{response → env/response}/delete-instance.response.dto.js +0 -0
  225. /package/dist/application/dtos/{response → env/response}/install-instance.response.dto.js +0 -0
  226. /package/dist/application/dtos/{response → env/response}/instance-list.response.dto.js +0 -0
  227. /package/dist/application/dtos/{response → env/response}/instance-status.response.dto.js +0 -0
  228. /package/dist/application/dtos/{response → env/response}/setup-result.response.dto.js +0 -0
  229. /package/dist/application/dtos/{response → env/response}/start-instance.response.dto.js +0 -0
  230. /package/dist/application/dtos/{response → env/response}/stop-instance.response.dto.js +0 -0
  231. /package/dist/application/dtos/{request → logs/request}/show-logs.request.dto.js +0 -0
  232. /package/dist/application/dtos/{response → logs/response}/show-logs.response.dto.js +0 -0
  233. /package/dist/application/use-cases/{instance → env}/list-charts.use-case.js +0 -0
  234. /package/dist/application/use-cases/{instance → env}/list-instances.use-case.js +0 -0
  235. /package/dist/application/use-cases/{instance → env}/stop-instance.use-case.js +0 -0
  236. /package/dist/{infrastructure → domain}/errors/app-error.js +0 -0
  237. /package/dist/{infrastructure → domain}/errors/exit-codes.js +0 -0
  238. /package/dist/infrastructure/config/{app-config.interface.js → interfaces/app-config.interface.js} +0 -0
  239. /package/dist/{domain → infrastructure/interceptors}/decorators/sensitive.decorator.js +0 -0
  240. /package/dist/infrastructure/interceptors/{interceptor.interface.js → interfaces/interceptor.interface.js} +0 -0
@@ -14,18 +14,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CredentialsController = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
- const tokens_1 = require("../../di/tokens");
18
- const get_credentials_use_case_1 = require("../../application/use-cases/credentials/get-credentials.use-case");
19
- const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
17
+ const tokens_1 = require("../../../di/tokens");
18
+ const use_cases_1 = require("../../../application/use-cases");
19
+ const base_controller_1 = require("../../controllers/base.controller");
20
20
  /**
21
21
  * Credentials Controller
22
22
  *
23
23
  * 處理憑證相關的 CLI 命令
24
24
  */
25
- let CredentialsController = class CredentialsController {
25
+ let CredentialsController = class CredentialsController extends base_controller_1.BaseController {
26
26
  constructor(getCredentialsUseCase, output) {
27
+ super(output);
27
28
  this.getCredentialsUseCase = getCredentialsUseCase;
28
- this.output = output;
29
29
  }
30
30
  /**
31
31
  * 取得實例憑證
@@ -33,7 +33,7 @@ let CredentialsController = class CredentialsController {
33
33
  * @param reveal - 是否顯示完整憑證
34
34
  */
35
35
  async get(name, reveal = false) {
36
- try {
36
+ await this.executeAction('Failed to retrieve credentials', async () => {
37
37
  const credentials = await this.getCredentialsUseCase.execute({ name });
38
38
  if (!credentials) {
39
39
  this.output
@@ -69,13 +69,7 @@ let CredentialsController = class CredentialsController {
69
69
  .item('bullet', 'Do not share passwords in plain text')
70
70
  .newline()
71
71
  .render();
72
- }
73
- catch (error) {
74
- this.output
75
- .error(`Failed to retrieve credentials: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
76
- .render();
77
- throw error;
78
- }
72
+ });
79
73
  }
80
74
  /**
81
75
  * 遮罩密碼 - 僅顯示後 4 碼
@@ -100,6 +94,6 @@ exports.CredentialsController = CredentialsController = __decorate([
100
94
  (0, tsyringe_1.injectable)(),
101
95
  __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.GetCredentialsUseCase)),
102
96
  __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
103
- __metadata("design:paramtypes", [get_credentials_use_case_1.GetCredentialsUseCase, Object])
97
+ __metadata("design:paramtypes", [use_cases_1.GetCredentialsUseCase, Object])
104
98
  ], CredentialsController);
105
99
  //# sourceMappingURL=credentials.controller.js.map
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * Env 指令群組 Controllers
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./instance.controller"), exports);
21
+ __exportStar(require("./setup.controller"), exports);
22
+ __exportStar(require("./credentials.controller"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -14,28 +14,24 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.InstanceController = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
- const tokens_1 = require("../../di/tokens");
18
- const install_instance_use_case_1 = require("../../application/use-cases/instance/install-instance.use-case");
19
- const start_instance_use_case_1 = require("../../application/use-cases/instance/start-instance.use-case");
20
- const stop_instance_use_case_1 = require("../../application/use-cases/instance/stop-instance.use-case");
21
- const delete_instance_use_case_1 = require("../../application/use-cases/instance/delete-instance.use-case");
22
- const list_instances_use_case_1 = require("../../application/use-cases/instance/list-instances.use-case");
23
- const list_charts_use_case_1 = require("../../application/use-cases/instance/list-charts.use-case");
24
- const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
17
+ const tokens_1 = require("../../../di/tokens");
18
+ const use_cases_1 = require("../../../application/use-cases");
19
+ const errors_1 = require("../../../domain/errors");
20
+ const base_controller_1 = require("../../controllers/base.controller");
25
21
  /**
26
22
  * Instance Controller
27
23
  *
28
24
  * 處理實例相關的 CLI 命令
29
25
  */
30
- let InstanceController = class InstanceController {
26
+ let InstanceController = class InstanceController extends base_controller_1.BaseController {
31
27
  constructor(installUseCase, startUseCase, stopUseCase, deleteUseCase, listUseCase, listChartsUseCase, output, interaction) {
28
+ super(output);
32
29
  this.installUseCase = installUseCase;
33
30
  this.startUseCase = startUseCase;
34
31
  this.stopUseCase = stopUseCase;
35
32
  this.deleteUseCase = deleteUseCase;
36
33
  this.listUseCase = listUseCase;
37
34
  this.listChartsUseCase = listChartsUseCase;
38
- this.output = output;
39
35
  this.interaction = interaction;
40
36
  output.resetIndent();
41
37
  }
@@ -43,12 +39,13 @@ let InstanceController = class InstanceController {
43
39
  * 安裝新實例
44
40
  */
45
41
  async install(options) {
46
- try {
42
+ await this.executeAction('Installation failed', async () => {
47
43
  const request = {
48
44
  name: options.name,
49
45
  chartVersion: options.chartVersion,
50
46
  pullSecretPath: options.pullSecret,
51
47
  rootfsPath: options.rootfs,
48
+ skipNorthwind: !options.northwind,
52
49
  };
53
50
  this.output
54
51
  .info(`Installing instance: ${request.name}`)
@@ -64,38 +61,19 @@ let InstanceController = class InstanceController {
64
61
  .info('To view credentials, run:')
65
62
  .item('bullet', `uofx env list credentials --name ${result.instanceName} --reveal`)
66
63
  .render();
67
- }
68
- catch (error) {
69
- this.output
70
- .error(`Installation failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
71
- .render();
72
- throw error;
73
- }
64
+ });
74
65
  }
75
66
  /**
76
67
  * 啟動實例
77
68
  */
78
69
  async start(name, options) {
79
- try {
80
- // 檢查其他運行中的實例
81
- const otherRunning = await this.startUseCase.listOtherRunningInstances(name);
82
- if (otherRunning.length > 0) {
83
- const otherName = otherRunning[0];
84
- this.output
85
- .newline()
86
- .warning(`Another instance is already running: ${otherName}`)
87
- .flush();
88
- const shouldStop = await this.interaction.confirm(`Do you want to stop "${otherName}" and start "${name}"?`, false);
89
- if (!shouldStop) {
90
- this.output.info('Start cancelled').render();
91
- return;
92
- }
93
- this.output.info(`Stopping ${otherName}...`).flush();
94
- await this.startUseCase.stopInstance(otherName, this.output);
95
- this.output.success(`${otherName} stopped`).flush();
96
- }
70
+ await this.executeAction('Start failed', async () => {
97
71
  this.output.newline().flush();
98
- const result = await this.startUseCase.execute({ name, waitForReady: true }, this.output);
72
+ const result = await this.startUseCase.execute({ name, waitForReady: true, resolveConflicts: true }, this.output);
73
+ // 使用者取消啟動
74
+ if (!result.success) {
75
+ return;
76
+ }
99
77
  this.output.newline();
100
78
  if (result.alreadyRunning) {
101
79
  this.output.success(`Instance '${result.instanceName}' is already running`);
@@ -112,13 +90,7 @@ let InstanceController = class InstanceController {
112
90
  .item('bullet', `uofx env list credentials --name ${name} --reveal`);
113
91
  }
114
92
  this.output.render();
115
- }
116
- catch (error) {
117
- this.output
118
- .error(`Start failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
119
- .render();
120
- throw error;
121
- }
93
+ });
122
94
  }
123
95
  /**
124
96
  * 顯示連線資訊
@@ -153,7 +125,7 @@ let InstanceController = class InstanceController {
153
125
  * 停止實例
154
126
  */
155
127
  async stop(name, options) {
156
- try {
128
+ await this.executeAction('Stop failed', async () => {
157
129
  const force = options?.force || false;
158
130
  this.output
159
131
  .info(`Stopping instance: ${name}`)
@@ -171,24 +143,22 @@ let InstanceController = class InstanceController {
171
143
  this.output
172
144
  .success(`Instance ${name} stopped`)
173
145
  .render();
174
- }
175
- catch (error) {
146
+ }, (error) => {
176
147
  this.output
177
- .error(`Stop failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
148
+ .error(`Stop failed: ${(0, errors_1.formatErrorMessage)(error)}`)
178
149
  .newline()
179
150
  .section('Troubleshooting')
180
151
  .item('bullet', `Try force stop: uofx env stop --name ${name} --force`)
181
152
  .item('bullet', 'Check WSL status: wsl --list --verbose')
182
153
  .item('bullet', `Manually terminate: wsl --terminate uofx-${name}`)
183
154
  .render();
184
- throw error;
185
- }
155
+ });
186
156
  }
187
157
  /**
188
158
  * 刪除實例
189
159
  */
190
160
  async delete(name, force = false) {
191
- try {
161
+ await this.executeAction('Deletion failed', async () => {
192
162
  // 取得實例詳細資訊
193
163
  const details = await this.deleteUseCase.getInstanceDetails(name);
194
164
  if (!details) {
@@ -245,23 +215,21 @@ let InstanceController = class InstanceController {
245
215
  .info('Use "uofx env install --name <name>" to create a new instance.');
246
216
  }
247
217
  this.output.render();
248
- }
249
- catch (error) {
218
+ }, (error) => {
250
219
  this.output
251
- .error(`Deletion failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
220
+ .error(`Deletion failed: ${(0, errors_1.formatErrorMessage)(error)}`)
252
221
  .newline()
253
222
  .section('If the instance is corrupted, try manual cleanup')
254
223
  .item('bullet', `wsl --unregister uofx-${name}`)
255
224
  .item('bullet', 'Delete the instance folder manually')
256
225
  .render();
257
- throw error;
258
- }
226
+ });
259
227
  }
260
228
  /**
261
229
  * 列出所有實例
262
230
  */
263
231
  async list() {
264
- try {
232
+ await this.executeAction('Failed to list instances', async () => {
265
233
  const result = await this.listUseCase.execute();
266
234
  if (result.instances.length === 0) {
267
235
  this.output
@@ -286,19 +254,13 @@ let InstanceController = class InstanceController {
286
254
  .newline()
287
255
  .info(`Total: ${result.instances.length} instances`)
288
256
  .render();
289
- }
290
- catch (error) {
291
- this.output
292
- .error(`Failed to list instances: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
293
- .render();
294
- throw error;
295
- }
257
+ });
296
258
  }
297
259
  /**
298
260
  * 列出可用的 Chart 版本
299
261
  */
300
262
  async listCharts() {
301
- try {
263
+ await this.executeAction('Failed to query chart versions', async () => {
302
264
  const versions = await this.listChartsUseCase.execute({ chartName: 'uofx' });
303
265
  if (versions.length === 0) {
304
266
  this.output
@@ -311,7 +273,7 @@ let InstanceController = class InstanceController {
311
273
  .section('Available UOFX Chart Versions')
312
274
  .table(['VERSION', 'TYPE', 'STATUS'], versions.map((v, i) => [
313
275
  v.toString(),
314
- this.getVersionType(v.toString()),
276
+ v.getType(),
315
277
  i === 0 ? 'Latest' : '',
316
278
  ]))
317
279
  .newline()
@@ -320,26 +282,7 @@ let InstanceController = class InstanceController {
320
282
  .info('Use the following command to install a specific version:')
321
283
  .item('bullet', 'uofx env install --name <name> --chart-version <version>')
322
284
  .render();
323
- }
324
- catch (error) {
325
- this.output
326
- .error(`Failed to query chart versions: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
327
- .render();
328
- throw error;
329
- }
330
- }
331
- /**
332
- * 判斷版本類型 (Beta/Stable)
333
- */
334
- getVersionType(version) {
335
- const parts = version.split('.');
336
- if (parts.length >= 3) {
337
- const patch = parts[2];
338
- if (patch.startsWith('2')) {
339
- return 'Beta';
340
- }
341
- }
342
- return 'Stable';
285
+ });
343
286
  }
344
287
  };
345
288
  exports.InstanceController = InstanceController;
@@ -353,11 +296,11 @@ exports.InstanceController = InstanceController = __decorate([
353
296
  __param(5, (0, tsyringe_1.inject)(tokens_1.TOKENS.ListChartsUseCase)),
354
297
  __param(6, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
355
298
  __param(7, (0, tsyringe_1.inject)(tokens_1.TOKENS.IUserInteractionPort)),
356
- __metadata("design:paramtypes", [install_instance_use_case_1.InstallInstanceUseCase,
357
- start_instance_use_case_1.StartInstanceUseCase,
358
- stop_instance_use_case_1.StopInstanceUseCase,
359
- delete_instance_use_case_1.DeleteInstanceUseCase,
360
- list_instances_use_case_1.ListInstancesUseCase,
361
- list_charts_use_case_1.ListChartsUseCase, Object, Object])
299
+ __metadata("design:paramtypes", [use_cases_1.InstallInstanceUseCase,
300
+ use_cases_1.StartInstanceUseCase,
301
+ use_cases_1.StopInstanceUseCase,
302
+ use_cases_1.DeleteInstanceUseCase,
303
+ use_cases_1.ListInstancesUseCase,
304
+ use_cases_1.ListChartsUseCase, Object, Object])
362
305
  ], InstanceController);
363
306
  //# sourceMappingURL=instance.controller.js.map
@@ -14,33 +14,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.SetupController = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
- const tokens_1 = require("../../di/tokens");
18
- const setup_environment_use_case_1 = require("../../application/use-cases/setup/setup-environment.use-case");
19
- const runtime_environment_port_1 = require("../../domain/ports/runtime-environment.port");
20
- const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
17
+ const tokens_1 = require("../../../di/tokens");
18
+ const use_cases_1 = require("../../../application/use-cases");
19
+ const runtime_environment_port_1 = require("../../../domain/ports/runtime-environment.port");
20
+ const base_controller_1 = require("../../controllers/base.controller");
21
21
  /**
22
22
  * Setup Controller
23
23
  *
24
24
  * 處理環境設定相關的 CLI 命令
25
25
  */
26
- let SetupController = class SetupController {
27
- constructor(setupUseCase, output, wslInfo, wslUpdater, runtimeEnvironment) {
26
+ let SetupController = class SetupController extends base_controller_1.BaseController {
27
+ constructor(setupUseCase, output) {
28
+ super(output);
28
29
  this.setupUseCase = setupUseCase;
29
- this.output = output;
30
- this.wslInfo = wslInfo;
31
- this.wslUpdater = wslUpdater;
32
- this.runtimeEnvironment = runtimeEnvironment;
33
30
  }
34
31
  /**
35
32
  * 執行環境檢查
36
33
  */
37
34
  async setup(_options) {
38
- try {
35
+ await this.executeAction('Environment check failed', async () => {
39
36
  this.output
40
37
  .item('arrow', 'Checking system environment...')
41
38
  .newline()
42
39
  .flush();
43
- const result = await this.setupUseCase.execute();
40
+ const result = await this.setupUseCase.execute(this.output);
44
41
  // 顯示作業系統資訊
45
42
  this.output
46
43
  .section('Checking Operating System')
@@ -56,48 +53,30 @@ let SetupController = class SetupController {
56
53
  .item('bullet', `Version: ${result.runtimeInfo.version}`);
57
54
  if (result.runtimeInfo.isInstalled) {
58
55
  this.output.success('Runtime installed');
59
- // 檢查是否需要更新
60
- const versionInfo = await this.wslInfo.getWslVersionInfo();
61
- const updateReq = this.wslInfo.checkWslUpdateRequirement(versionInfo);
62
- if (updateReq.needsUpdate || updateReq.needsDefaultVersion) {
63
- this.output.newline().render();
64
- // 詢問使用者是否要更新
65
- const shouldSetup = await this.wslUpdater.promptWslSetup(updateReq, this.output);
66
- if (shouldSetup) {
67
- // 執行更新
68
- if (updateReq.needsUpdate) {
69
- const { needsRestart } = await this.wslUpdater.installWsl('update', this.output);
70
- if (needsRestart) {
71
- this.output
72
- .newline()
73
- .info('Please restart your computer and run "uofx env setup" again.')
74
- .render();
75
- return;
76
- }
77
- }
78
- // 設定預設版本
79
- if (updateReq.needsDefaultVersion) {
80
- await this.wslUpdater.setDefaultVersion(this.output);
81
- }
56
+ }
57
+ else {
58
+ this.output.error('Runtime not installed');
59
+ }
60
+ // 處理 WSL 設定結果
61
+ if (result.wslSetup) {
62
+ if (result.wslSetup.action === 'installed') {
63
+ if (result.wslSetup.needsRestart) {
82
64
  this.output
83
65
  .newline()
84
- .success('WSL setup completed.')
66
+ .info('Please restart your computer and run "uofx env setup" again.')
85
67
  .render();
86
- return;
87
68
  }
88
69
  else {
89
- // 使用者取消
90
- this.wslUpdater.handleSetupCancelled(updateReq, this.output);
70
+ this.output
71
+ .newline()
72
+ .success('WSL installation completed. You can now continue with setup.')
73
+ .info('Run "uofx env setup" again to verify the installation.')
74
+ .render();
91
75
  }
76
+ return;
92
77
  }
93
- }
94
- else {
95
- this.output.error('Runtime not installed').newline().render();
96
- // 詢問使用者是否要安裝 WSL
97
- const shouldInstall = await this.wslUpdater.promptWslInstall(this.output);
98
- if (shouldInstall) {
99
- const { needsRestart } = await this.wslUpdater.installWsl('install', this.output);
100
- if (needsRestart) {
78
+ if (result.wslSetup.action === 'updated') {
79
+ if (result.wslSetup.needsRestart) {
101
80
  this.output
102
81
  .newline()
103
82
  .info('Please restart your computer and run "uofx env setup" again.')
@@ -106,8 +85,7 @@ let SetupController = class SetupController {
106
85
  else {
107
86
  this.output
108
87
  .newline()
109
- .success('WSL installation completed. You can now continue with setup.')
110
- .info('Run "uofx env setup" again to verify the installation.')
88
+ .success('WSL setup completed.')
111
89
  .render();
112
90
  }
113
91
  return;
@@ -115,19 +93,17 @@ let SetupController = class SetupController {
115
93
  }
116
94
  this.output.newline();
117
95
  // 顯示記憶體資訊
118
- const memoryInfo = await this.runtimeEnvironment.getMemoryAvailability();
119
96
  this.output.section('Checking Remaining Memory');
120
- for (const detail of memoryInfo.details) {
97
+ for (const detail of result.memoryInfo.details) {
121
98
  const suffix = detail.suffix ? ` (${detail.suffix})` : '';
122
99
  this.output.item('bullet', `${detail.label}: ${detail.valueGB.toFixed(2)} GB${suffix}`);
123
100
  }
124
- const memoryOk = memoryInfo.availableGB >= runtime_environment_port_1.UOFX_REQUIRED_MEMORY_GB;
125
- if (memoryOk) {
101
+ if (result.memoryInfo.isSufficient) {
126
102
  this.output.success('Memory sufficient for UOFX');
127
103
  }
128
104
  else {
129
105
  this.output
130
- .warning(`Available memory (${memoryInfo.availableGB.toFixed(2)} GB) is below recommended ${runtime_environment_port_1.UOFX_REQUIRED_MEMORY_GB} GB`)
106
+ .warning(`Available memory (${result.memoryInfo.availableGB.toFixed(2)} GB) is below recommended ${runtime_environment_port_1.UOFX_REQUIRED_MEMORY_GB} GB`)
131
107
  .newline()
132
108
  .info('Insufficient memory may cause:')
133
109
  .item('bullet', 'Kubernetes pods failing to start')
@@ -158,7 +134,7 @@ let SetupController = class SetupController {
158
134
  this.output.error('Registry not accessible');
159
135
  }
160
136
  // 計算是否有警告
161
- const hasWarnings = !memoryOk;
137
+ const hasWarnings = !result.memoryInfo.isSufficient;
162
138
  // 總結
163
139
  this.output
164
140
  .newline()
@@ -189,13 +165,7 @@ let SetupController = class SetupController {
189
165
  .newline();
190
166
  }
191
167
  this.output.render();
192
- }
193
- catch (error) {
194
- this.output
195
- .error(`Environment check failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
196
- .render();
197
- throw error;
198
- }
168
+ });
199
169
  }
200
170
  };
201
171
  exports.SetupController = SetupController;
@@ -203,9 +173,6 @@ exports.SetupController = SetupController = __decorate([
203
173
  (0, tsyringe_1.injectable)(),
204
174
  __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.SetupEnvironmentUseCase)),
205
175
  __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
206
- __param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.WslInfoService)),
207
- __param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.WslUpdaterService)),
208
- __param(4, (0, tsyringe_1.inject)(tokens_1.TOKENS.IRuntimeEnvironmentPort)),
209
- __metadata("design:paramtypes", [setup_environment_use_case_1.SetupEnvironmentUseCase, Object, Object, Object, Object])
176
+ __metadata("design:paramtypes", [use_cases_1.SetupEnvironmentUseCase, Object])
210
177
  ], SetupController);
211
178
  //# sourceMappingURL=setup.controller.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Presentation Controllers
4
+ * 按指令群組組織
4
5
  */
5
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
7
  if (k2 === undefined) k2 = k;
@@ -17,9 +18,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
19
  };
19
20
  Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./instance.controller"), exports);
21
- __exportStar(require("./setup.controller"), exports);
22
- __exportStar(require("./config.controller"), exports);
23
- __exportStar(require("./logs.controller"), exports);
24
- __exportStar(require("./credentials.controller"), exports);
21
+ // Env 指令群組 (instance, setup, credentials)
22
+ __exportStar(require("./env"), exports);
23
+ // Config 指令群組
24
+ __exportStar(require("./config"), exports);
25
+ // Logs 指令群組
26
+ __exportStar(require("./logs"), exports);
27
+ // Dev 指令群組
28
+ __exportStar(require("./dev"), exports);
25
29
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Logs 指令群組 Controllers
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./logs.controller"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -14,24 +14,24 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.LogsController = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
- const tokens_1 = require("../../di/tokens");
18
- const show_logs_use_case_1 = require("../../application/use-cases/logs/show-logs.use-case");
19
- const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
17
+ const tokens_1 = require("../../../di/tokens");
18
+ const use_cases_1 = require("../../../application/use-cases");
19
+ const base_controller_1 = require("../../controllers/base.controller");
20
20
  /**
21
21
  * Logs Controller
22
22
  *
23
23
  * 處理日誌相關的 CLI 命令
24
24
  */
25
- let LogsController = class LogsController {
25
+ let LogsController = class LogsController extends base_controller_1.BaseController {
26
26
  constructor(showLogsUseCase, output) {
27
+ super(output);
27
28
  this.showLogsUseCase = showLogsUseCase;
28
- this.output = output;
29
29
  }
30
30
  /**
31
31
  * 顯示日志
32
32
  */
33
33
  async show(options) {
34
- try {
34
+ await this.executeAction('Failed to show logs', async () => {
35
35
  const request = {
36
36
  lines: options.lines || 50,
37
37
  level: options.level,
@@ -43,13 +43,7 @@ let LogsController = class LogsController {
43
43
  };
44
44
  const result = await this.showLogsUseCase.execute(request);
45
45
  this.formatAndDisplayLogs(result);
46
- }
47
- catch (error) {
48
- this.output
49
- .error(`Failed to show logs: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
50
- .render();
51
- throw error;
52
- }
46
+ });
53
47
  }
54
48
  /**
55
49
  * 格式化並顯示日誌
@@ -98,6 +92,6 @@ exports.LogsController = LogsController = __decorate([
98
92
  (0, tsyringe_1.injectable)(),
99
93
  __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ShowLogsUseCase)),
100
94
  __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
101
- __metadata("design:paramtypes", [show_logs_use_case_1.ShowLogsUseCase, Object])
95
+ __metadata("design:paramtypes", [use_cases_1.ShowLogsUseCase, Object])
102
96
  ], LogsController);
103
97
  //# sourceMappingURL=logs.controller.js.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Presentation 層介面匯出
19
+ */
20
+ __exportStar(require("./cli-options.interface"), exports);
21
+ //# sourceMappingURL=index.js.map