@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
@@ -0,0 +1,60 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InstallTemplateUseCase = void 0;
16
+ /**
17
+ * Install Template Use Case
18
+ *
19
+ * 安裝樣板至本地快取
20
+ */
21
+ const tsyringe_1 = require("tsyringe");
22
+ const tokens_1 = require("../../../di/tokens");
23
+ let InstallTemplateUseCase = class InstallTemplateUseCase {
24
+ constructor(templateManager, logger) {
25
+ this.templateManager = templateManager;
26
+ this.logger = logger;
27
+ }
28
+ async execute(request, output) {
29
+ this.logger.debug('Installing template...', { request });
30
+ const result = await this.templateManager.install({
31
+ url: request.url,
32
+ name: request.name,
33
+ withSample: request.withSample,
34
+ }, output);
35
+ if (result.success && result.template) {
36
+ return {
37
+ success: true,
38
+ template: {
39
+ name: result.template.name,
40
+ version: result.template.version,
41
+ installedAt: result.template.installedAt,
42
+ path: result.template.path,
43
+ },
44
+ message: result.message,
45
+ };
46
+ }
47
+ return {
48
+ success: false,
49
+ message: result.message,
50
+ };
51
+ }
52
+ };
53
+ exports.InstallTemplateUseCase = InstallTemplateUseCase;
54
+ exports.InstallTemplateUseCase = InstallTemplateUseCase = __decorate([
55
+ (0, tsyringe_1.injectable)(),
56
+ __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ITemplateManagerPort)),
57
+ __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.ILoggerPort)),
58
+ __metadata("design:paramtypes", [Object, Object])
59
+ ], InstallTemplateUseCase);
60
+ //# sourceMappingURL=install-template.use-case.js.map
@@ -0,0 +1,45 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ListTemplatesUseCase = void 0;
16
+ /**
17
+ * List Templates Use Case
18
+ *
19
+ * 列出已安裝的樣板
20
+ */
21
+ const tsyringe_1 = require("tsyringe");
22
+ const tokens_1 = require("../../../di/tokens");
23
+ let ListTemplatesUseCase = class ListTemplatesUseCase {
24
+ constructor(templateManager) {
25
+ this.templateManager = templateManager;
26
+ }
27
+ async execute() {
28
+ const templates = await this.templateManager.list();
29
+ return {
30
+ templates: templates.map((t) => ({
31
+ name: t.name,
32
+ version: t.version,
33
+ installedAt: t.installedAt,
34
+ path: t.path,
35
+ })),
36
+ };
37
+ }
38
+ };
39
+ exports.ListTemplatesUseCase = ListTemplatesUseCase;
40
+ exports.ListTemplatesUseCase = ListTemplatesUseCase = __decorate([
41
+ (0, tsyringe_1.injectable)(),
42
+ __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ITemplateManagerPort)),
43
+ __metadata("design:paramtypes", [Object])
44
+ ], ListTemplatesUseCase);
45
+ //# sourceMappingURL=list-templates.use-case.js.map
@@ -0,0 +1,130 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ 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;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.NewProjectUseCase = void 0;
49
+ /**
50
+ * New Project Use Case
51
+ *
52
+ * 從已安裝的樣板建立新的 Plugin 專案
53
+ */
54
+ const tsyringe_1 = require("tsyringe");
55
+ const path = __importStar(require("path"));
56
+ const tokens_1 = require("../../../di/tokens");
57
+ const value_objects_1 = require("../../../domain/value-objects");
58
+ let NewProjectUseCase = class NewProjectUseCase {
59
+ constructor(templateManager, projectScaffolder, logger) {
60
+ this.templateManager = templateManager;
61
+ this.projectScaffolder = projectScaffolder;
62
+ this.logger = logger;
63
+ }
64
+ /**
65
+ * 執行新專案建立流程
66
+ * @param request - 新專案建立請求參數
67
+ * @param output - 輸出端口,用於回報進度
68
+ * @returns 新專案建立結果
69
+ */
70
+ async execute(request, output) {
71
+ this.logger.debug('Creating new project...', { request });
72
+ // [1/2] 解析樣板
73
+ output?.section('[1/2] Resolving template').flush();
74
+ const templates = await this.templateManager.list();
75
+ if (templates.length === 0) {
76
+ const msg = 'No templates installed. Run "uofx dev template install" first.';
77
+ output?.error(msg).flush();
78
+ return { success: false, message: msg };
79
+ }
80
+ // 查找指定樣板
81
+ output?.item('arrow', `Looking for template: ${request.template}`).flush();
82
+ const templateInfo = templates.find((t) => t.name === request.template);
83
+ if (!templateInfo) {
84
+ const msg = `Template "${request.template}" not found. Use "uofx dev template list" to see installed templates.`;
85
+ output?.error(msg).flush();
86
+ return { success: false, message: msg };
87
+ }
88
+ output
89
+ ?.success(`Using template: ${templateInfo.name}`)
90
+ .newline()
91
+ .flush();
92
+ // [2/2] 建立專案
93
+ output?.section('[2/2] Creating project').flush();
94
+ const outputDir = path.resolve(request.output || process.cwd());
95
+ // 路徑遍歷防護:禁止輸出到系統關鍵目錄
96
+ if (value_objects_1.OutputPath.isProtected(outputDir)) {
97
+ const msg = `Output directory "${outputDir}" is a protected system path.`;
98
+ output?.error(msg).flush();
99
+ return { success: false, message: msg };
100
+ }
101
+ const result = await this.projectScaffolder.scaffold({
102
+ templatePath: templateInfo.path,
103
+ outputDir,
104
+ skipInstall: request.skipInstall || false,
105
+ force: request.force || false,
106
+ }, output);
107
+ if (!result.success) {
108
+ return {
109
+ success: false,
110
+ message: result.message,
111
+ };
112
+ }
113
+ return {
114
+ success: true,
115
+ projectPath: result.projectPath,
116
+ message: `Project created at ${result.projectPath}`,
117
+ npmInstallFailed: result.npmInstallFailed,
118
+ clientAppDirs: result.clientAppDirs,
119
+ };
120
+ }
121
+ };
122
+ exports.NewProjectUseCase = NewProjectUseCase;
123
+ exports.NewProjectUseCase = NewProjectUseCase = __decorate([
124
+ (0, tsyringe_1.injectable)(),
125
+ __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ITemplateManagerPort)),
126
+ __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IProjectScaffolderPort)),
127
+ __param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.ILoggerPort)),
128
+ __metadata("design:paramtypes", [Object, Object, Object])
129
+ ], NewProjectUseCase);
130
+ //# sourceMappingURL=new-project.use-case.js.map
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ /**
3
+ * Publish Plugin Use Case
4
+ *
5
+ * 執行 Plugin 發布流程:
6
+ * 1. 搜尋 ClientApp → 執行 version schematic 更新 plugin.versions.json
7
+ * 2. 找到 .csproj 目錄 → 執行 dotnet publish 建置
8
+ * 3. 組織產出目錄結構
9
+ */
10
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
23
+ }) : function(o, v) {
24
+ o["default"] = v;
25
+ });
26
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ 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;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ };
32
+ var __importStar = (this && this.__importStar) || (function () {
33
+ var ownKeys = function(o) {
34
+ ownKeys = Object.getOwnPropertyNames || function (o) {
35
+ var ar = [];
36
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
+ return ar;
38
+ };
39
+ return ownKeys(o);
40
+ };
41
+ return function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
+ __setModuleDefault(result, mod);
46
+ return result;
47
+ };
48
+ })();
49
+ var __metadata = (this && this.__metadata) || function (k, v) {
50
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
51
+ };
52
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
53
+ return function (target, key) { decorator(target, key, paramIndex); }
54
+ };
55
+ Object.defineProperty(exports, "__esModule", { value: true });
56
+ exports.PublishPluginUseCase = void 0;
57
+ const tsyringe_1 = require("tsyringe");
58
+ const path = __importStar(require("path"));
59
+ const tokens_1 = require("../../../di/tokens");
60
+ const value_objects_1 = require("../../../domain/value-objects");
61
+ let PublishPluginUseCase = class PublishPluginUseCase {
62
+ constructor(schematicsRunner, dotnetPublisher, logger, interaction, fileSystem) {
63
+ this.schematicsRunner = schematicsRunner;
64
+ this.dotnetPublisher = dotnetPublisher;
65
+ this.logger = logger;
66
+ this.interaction = interaction;
67
+ this.fileSystem = fileSystem;
68
+ }
69
+ /**
70
+ * 執行 Plugin 發布流程
71
+ * @param request - 發布請求參數
72
+ * @param output - 輸出端口,用於回報進度
73
+ * @returns 發布結果
74
+ */
75
+ async execute(request, output) {
76
+ this.logger.debug('Publishing plugin...', { request });
77
+ const clientAppPath = process.cwd();
78
+ const projectDir = this.dotnetPublisher.findProjectDir(clientAppPath);
79
+ const outputDir = request.output
80
+ ? path.resolve(request.output)
81
+ : path.join(projectDir, 'wwwroot');
82
+ // 路徑遍歷防護:禁止輸出到系統關鍵目錄
83
+ if (value_objects_1.OutputPath.isProtected(outputDir)) {
84
+ return {
85
+ success: false,
86
+ message: `Output directory "${outputDir}" is a protected system path.`,
87
+ };
88
+ }
89
+ // ================================================================
90
+ // [1/3] Adding version to plugin.versions.json
91
+ // ================================================================
92
+ output?.section('[1/3] Adding version to plugin.versions.json').flush();
93
+ // 組裝 version schematic 額外參數
94
+ const extraArgs = {
95
+ version: request.serviceVersion,
96
+ 'min-uofx-version': request.minUofxVersion,
97
+ };
98
+ const schematicsResult = await this.schematicsRunner.run({
99
+ projectPath: clientAppPath,
100
+ schematicName: 'version',
101
+ extraArgs,
102
+ dryRun: false,
103
+ }, output);
104
+ if (!schematicsResult.success) {
105
+ return {
106
+ success: false,
107
+ message: `Failed to add version: ${schematicsResult.message}`,
108
+ };
109
+ }
110
+ output?.success('Version added').newline().flush();
111
+ // ================================================================
112
+ // [2/3] Building and publishing .NET project
113
+ // ================================================================
114
+ output?.section('[2/3] Building and publishing .NET project').flush();
115
+ output?.item('bullet', `Project directory: ${projectDir}`).flush();
116
+ // 版本轉換:1.0 → 1_0
117
+ const versionUnderscored = request.serviceVersion.replace(/\./g, '_');
118
+ const publishOutputDir = path.join(outputDir, `${request.serviceName}${versionUnderscored}`);
119
+ // 檢查 publishOutputDir 是否已存在
120
+ const cleanupResult = await this.handleExistingDir(publishOutputDir, request.force, output);
121
+ if (!cleanupResult.continue) {
122
+ return {
123
+ success: false,
124
+ message: cleanupResult.message ?? 'User cancelled.',
125
+ };
126
+ }
127
+ const publishResult = await this.dotnetPublisher.publish({
128
+ projectPath: projectDir,
129
+ outputPath: publishOutputDir,
130
+ }, output);
131
+ if (!publishResult.success) {
132
+ return {
133
+ success: false,
134
+ message: `Failed to publish: ${publishResult.message}`,
135
+ };
136
+ }
137
+ output?.success('Build completed').newline().flush();
138
+ // ================================================================
139
+ // [3/3] Organizing output
140
+ // ================================================================
141
+ output?.section('[3/3] Organizing output').flush();
142
+ try {
143
+ // 建立 <output>/<service-name>/ 目錄
144
+ const serviceDir = path.join(outputDir, request.serviceName);
145
+ // 檢查 serviceDir 是否已存在
146
+ const serviceDirCleanup = await this.handleExistingDir(serviceDir, request.force, output);
147
+ if (!serviceDirCleanup.continue) {
148
+ return {
149
+ success: false,
150
+ message: serviceDirCleanup.message ?? 'User cancelled.',
151
+ };
152
+ }
153
+ await this.fileSystem.ensureDir(serviceDir);
154
+ // 複製 plugin.manifest.json
155
+ const manifestSrc = path.join(clientAppPath, 'src', 'plugin.manifest.json');
156
+ if (await this.fileSystem.exists(manifestSrc)) {
157
+ await this.fileSystem.copyFile(manifestSrc, path.join(serviceDir, 'plugin.manifest.json'));
158
+ output?.item('check', 'Copied plugin.manifest.json').flush();
159
+ }
160
+ else {
161
+ output?.item('warning', 'plugin.manifest.json not found, skipping').flush();
162
+ }
163
+ // 複製 plugin.versions.json
164
+ const versionsSrc = path.join(clientAppPath, 'src', 'plugin.versions.json');
165
+ if (await this.fileSystem.exists(versionsSrc)) {
166
+ await this.fileSystem.copyFile(versionsSrc, path.join(serviceDir, 'plugin.versions.json'));
167
+ output?.item('check', 'Copied plugin.versions.json').flush();
168
+ }
169
+ else {
170
+ output?.item('warning', 'plugin.versions.json not found, skipping').flush();
171
+ }
172
+ output?.success('Output organized').newline().flush();
173
+ // 最終摘要
174
+ output?.divider().flush();
175
+ output?.section('Publish Summary').flush();
176
+ output?.item('bullet', `Service: ${request.serviceName}`).flush();
177
+ output?.item('bullet', `Version: ${request.serviceVersion}`).flush();
178
+ output?.item('bullet', `Output: ${outputDir}`).flush();
179
+ output
180
+ ?.item('bullet', ` ${request.serviceName}/ (manifest + versions)`)
181
+ .flush();
182
+ output
183
+ ?.item('bullet', ` ${request.serviceName}${versionUnderscored}/ (publish output)`)
184
+ .flush();
185
+ output?.divider().flush();
186
+ return {
187
+ success: true,
188
+ message: 'Plugin published successfully.',
189
+ outputPath: outputDir,
190
+ };
191
+ }
192
+ catch (err) {
193
+ const errorMsg = `Failed to organize output: ${err instanceof Error ? err.message : String(err)}`;
194
+ this.logger.error(new Error(errorMsg));
195
+ output?.error(errorMsg).flush();
196
+ return {
197
+ success: false,
198
+ message: errorMsg,
199
+ };
200
+ }
201
+ }
202
+ /**
203
+ * 處理已存在的目錄:force 時直接刪除,否則提示使用者確認
204
+ * @param dirPath - 目標目錄路徑
205
+ * @param force - 是否強制刪除
206
+ * @param output - 輸出端口
207
+ * @returns 是否繼續執行
208
+ */
209
+ async handleExistingDir(dirPath, force, output) {
210
+ if (!(await this.fileSystem.exists(dirPath))) {
211
+ return { continue: true };
212
+ }
213
+ if (force) {
214
+ output?.item('warning', `Removing existing directory: ${dirPath}`).flush();
215
+ await this.fileSystem.removeDir(dirPath);
216
+ return { continue: true };
217
+ }
218
+ output
219
+ ?.warning(`Directory already exists: ${dirPath}`)
220
+ .flush();
221
+ const confirmed = await this.interaction.confirm('Remove existing directory and continue?');
222
+ if (!confirmed) {
223
+ output?.warning('Publish cancelled by user.').flush();
224
+ return {
225
+ continue: false,
226
+ message: 'Publish cancelled by user.',
227
+ };
228
+ }
229
+ await this.fileSystem.removeDir(dirPath);
230
+ return { continue: true };
231
+ }
232
+ };
233
+ exports.PublishPluginUseCase = PublishPluginUseCase;
234
+ exports.PublishPluginUseCase = PublishPluginUseCase = __decorate([
235
+ (0, tsyringe_1.injectable)(),
236
+ __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ISchematicsRunnerPort)),
237
+ __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IDotnetPublisherPort)),
238
+ __param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.ILoggerPort)),
239
+ __param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.IUserInteractionPort)),
240
+ __param(4, (0, tsyringe_1.inject)(tokens_1.TOKENS.IFileSystemPort)),
241
+ __metadata("design:paramtypes", [Object, Object, Object, Object, Object])
242
+ ], PublishPluginUseCase);
243
+ //# sourceMappingURL=publish-plugin.use-case.js.map
@@ -0,0 +1,50 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UninstallTemplateUseCase = void 0;
16
+ /**
17
+ * Uninstall Template Use Case
18
+ *
19
+ * 移除已安裝的樣板
20
+ */
21
+ const tsyringe_1 = require("tsyringe");
22
+ const tokens_1 = require("../../../di/tokens");
23
+ let UninstallTemplateUseCase = class UninstallTemplateUseCase {
24
+ constructor(templateManager, logger) {
25
+ this.templateManager = templateManager;
26
+ this.logger = logger;
27
+ }
28
+ async execute(request) {
29
+ this.logger.debug(`Uninstalling template: ${request.name}`);
30
+ const success = await this.templateManager.uninstall(request.name);
31
+ if (success) {
32
+ return {
33
+ success: true,
34
+ message: `Template "${request.name}" uninstalled successfully.`,
35
+ };
36
+ }
37
+ return {
38
+ success: false,
39
+ message: `Template "${request.name}" is not installed.`,
40
+ };
41
+ }
42
+ };
43
+ exports.UninstallTemplateUseCase = UninstallTemplateUseCase;
44
+ exports.UninstallTemplateUseCase = UninstallTemplateUseCase = __decorate([
45
+ (0, tsyringe_1.injectable)(),
46
+ __param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.ITemplateManagerPort)),
47
+ __param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.ILoggerPort)),
48
+ __metadata("design:paramtypes", [Object, Object])
49
+ ], UninstallTemplateUseCase);
50
+ //# sourceMappingURL=uninstall-template.use-case.js.map
@@ -17,7 +17,7 @@ const tsyringe_1 = require("tsyringe");
17
17
  const tokens_1 = require("../../../di/tokens");
18
18
  const instance_name_value_object_1 = require("../../../domain/value-objects/instance-name.value-object");
19
19
  const delete_instance_validation_entity_1 = require("../../../domain/entities/delete-instance-validation.entity");
20
- const error_formatter_util_1 = require("../../../infrastructure/utils/error-formatter.util");
20
+ const errors_1 = require("../../../domain/errors");
21
21
  /**
22
22
  * 刪除實例 Use Case
23
23
  */
@@ -54,7 +54,7 @@ let DeleteInstanceUseCase = class DeleteInstanceUseCase {
54
54
  }
55
55
  catch (error) {
56
56
  // 停止失敗時繼續刪除,但記錄警告
57
- stopWarning = `Failed to stop instance gracefully: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`;
57
+ stopWarning = `Failed to stop instance gracefully: ${(0, errors_1.formatErrorMessage)(error)}`;
58
58
  }
59
59
  }
60
60
  // 刪除實例
@@ -16,7 +16,7 @@ exports.GetCredentialsUseCase = void 0;
16
16
  const tsyringe_1 = require("tsyringe");
17
17
  const tokens_1 = require("../../../di/tokens");
18
18
  const instance_name_value_object_1 = require("../../../domain/value-objects/instance-name.value-object");
19
- const errors_1 = require("../../../infrastructure/errors");
19
+ const errors_1 = require("../../../domain/errors");
20
20
  /**
21
21
  * 取得憑證 Use Case
22
22
  *
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Env 指令群組 Use Cases
4
+ *
5
+ * 包含 instance、setup、credentials 相關的業務邏輯
6
+ */
2
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
8
  if (k2 === undefined) k2 = k;
4
9
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,10 +19,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
16
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
+ // Instance
17
23
  __exportStar(require("./install-instance.use-case"), exports);
18
24
  __exportStar(require("./start-instance.use-case"), exports);
19
25
  __exportStar(require("./stop-instance.use-case"), exports);
20
26
  __exportStar(require("./delete-instance.use-case"), exports);
21
27
  __exportStar(require("./list-instances.use-case"), exports);
22
28
  __exportStar(require("./list-charts.use-case"), exports);
29
+ __exportStar(require("./list-running-instances.use-case"), exports);
30
+ // Setup
31
+ __exportStar(require("./setup-environment.use-case"), exports);
32
+ // Credentials
33
+ __exportStar(require("./get-credentials.use-case"), exports);
23
34
  //# sourceMappingURL=index.js.map