@uofx/cli 1.0.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.
- package/LICENSE +40 -0
- package/README.md +444 -0
- package/THIRD-PARTY-NOTICES.txt +894 -0
- package/dist/application/dtos/index.js +24 -0
- package/dist/application/dtos/request/delete-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/get-config.request.dto.js +3 -0
- package/dist/application/dtos/request/get-credentials.request.dto.js +3 -0
- package/dist/application/dtos/request/index.js +27 -0
- package/dist/application/dtos/request/install-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/list-charts.request.dto.js +3 -0
- package/dist/application/dtos/request/set-config.request.dto.js +16 -0
- package/dist/application/dtos/request/setup-environment.request.dto.js +16 -0
- package/dist/application/dtos/request/show-logs.request.dto.js +19 -0
- package/dist/application/dtos/request/start-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/stop-instance.request.dto.js +3 -0
- package/dist/application/dtos/response/credentials.response.dto.js +3 -0
- package/dist/application/dtos/response/delete-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/index.js +26 -0
- package/dist/application/dtos/response/install-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/instance-list.response.dto.js +3 -0
- package/dist/application/dtos/response/instance-status.response.dto.js +3 -0
- package/dist/application/dtos/response/setup-result.response.dto.js +3 -0
- package/dist/application/dtos/response/show-logs.response.dto.js +3 -0
- package/dist/application/dtos/response/start-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/stop-instance.response.dto.js +3 -0
- package/dist/application/index.js +25 -0
- package/dist/application/interfaces/index.js +24 -0
- package/dist/application/interfaces/use-case.interface.js +3 -0
- package/dist/application/use-cases/config/get-config.use-case.js +66 -0
- package/dist/application/use-cases/config/set-config.use-case.js +49 -0
- package/dist/application/use-cases/credentials/get-credentials.use-case.js +57 -0
- package/dist/application/use-cases/index.js +28 -0
- package/dist/application/use-cases/instance/delete-instance.use-case.js +81 -0
- package/dist/application/use-cases/instance/index.js +23 -0
- package/dist/application/use-cases/instance/install-instance.use-case.js +424 -0
- package/dist/application/use-cases/instance/list-charts.use-case.js +43 -0
- package/dist/application/use-cases/instance/list-instances.use-case.js +62 -0
- package/dist/application/use-cases/instance/start-instance.use-case.js +154 -0
- package/dist/application/use-cases/instance/stop-instance.use-case.js +55 -0
- package/dist/application/use-cases/logs/show-logs.use-case.js +66 -0
- package/dist/application/use-cases/setup/setup-environment.use-case.js +53 -0
- package/dist/cli.js +286 -0
- package/dist/constants/config-defaults.js +23 -0
- package/dist/constants/defaults.js +89 -0
- package/dist/constants/deployment.js +39 -0
- package/dist/constants/environments.js +93 -0
- package/dist/constants/index.js +53 -0
- package/dist/constants/oci-artifacts.js +25 -0
- package/dist/constants/paths.js +92 -0
- package/dist/constants/timeouts.js +60 -0
- package/dist/di/container.js +34 -0
- package/dist/di/index.js +22 -0
- package/dist/di/modules/application.module.js +54 -0
- package/dist/di/modules/infrastructure.module.js +206 -0
- package/dist/di/modules/interceptor.module.js +68 -0
- package/dist/di/modules/presentation.module.js +31 -0
- package/dist/di/tokens.js +149 -0
- package/dist/domain/decorators/sensitive.decorator.js +39 -0
- package/dist/domain/entities/credentials-resolver.entity.js +127 -0
- package/dist/domain/entities/credentials.entity.js +65 -0
- package/dist/domain/entities/delete-instance-validation.entity.js +100 -0
- package/dist/domain/entities/deployment-parameters.entity.js +120 -0
- package/dist/domain/entities/environment-validation.entity.js +125 -0
- package/dist/domain/entities/index.js +29 -0
- package/dist/domain/entities/instance-lifecycle-state.entity.js +100 -0
- package/dist/domain/entities/instance-list-aggregator.entity.js +104 -0
- package/dist/domain/entities/instance-metadata.entity.js +86 -0
- package/dist/domain/entities/instance-status.entity.js +79 -0
- package/dist/domain/entities/instance.entity.js +128 -0
- package/dist/domain/entities/log-filter.entity.js +141 -0
- package/dist/domain/index.js +29 -0
- package/dist/domain/interfaces/safe-loggable.interface.js +3 -0
- package/dist/domain/ports/app-config.port.js +3 -0
- package/dist/domain/ports/base-image.port.js +3 -0
- package/dist/domain/ports/chart-version.port.js +3 -0
- package/dist/domain/ports/correlation-id.port.js +3 -0
- package/dist/domain/ports/credentials.port.js +3 -0
- package/dist/domain/ports/deployment.port.js +3 -0
- package/dist/domain/ports/error-handler.port.js +3 -0
- package/dist/domain/ports/index.js +46 -0
- package/dist/domain/ports/instance-manager.port.js +3 -0
- package/dist/domain/ports/instance-metadata.port.js +8 -0
- package/dist/domain/ports/instance-storage.port.js +3 -0
- package/dist/domain/ports/k8s-deployer.port.js +3 -0
- package/dist/domain/ports/logger.port.js +14 -0
- package/dist/domain/ports/output.port.js +3 -0
- package/dist/domain/ports/runtime-environment.port.js +6 -0
- package/dist/domain/ports/user-interaction.port.js +9 -0
- package/dist/domain/ports/user-settings.port.js +3 -0
- package/dist/domain/types/index.js +22 -0
- package/dist/domain/types/logger.types.js +29 -0
- package/dist/domain/types/validation.types.js +9 -0
- package/dist/domain/value-objects/acr-credentials.value-object.js +92 -0
- package/dist/domain/value-objects/chart-version.value-object.js +124 -0
- package/dist/domain/value-objects/config-log-level.value-object.js +84 -0
- package/dist/domain/value-objects/connection-info.value-object.js +65 -0
- package/dist/domain/value-objects/index.js +25 -0
- package/dist/domain/value-objects/instance-name.value-object.js +91 -0
- package/dist/domain/value-objects/jwt-key.value-object.js +97 -0
- package/dist/domain/value-objects/mssql-password.value-object.js +140 -0
- package/dist/domain/value-objects/rsa-key-pair.value-object.js +181 -0
- package/dist/index.js +6 -0
- package/dist/infrastructure/config/app-config.interface.js +3 -0
- package/dist/infrastructure/config/app-config.service.js +280 -0
- package/dist/infrastructure/config/config-validator.js +31 -0
- package/dist/infrastructure/config/crypto.service.js +125 -0
- package/dist/infrastructure/deployment/deployment.adapter.js +118 -0
- package/dist/infrastructure/deployment/interfaces/acr-credential-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/app-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/helm-registry.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/infra-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/k8s-job-runner.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-database-init.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-helm-deployment.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-storage.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-user-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/oci-artifact.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/secret-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/service-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/version-compatibility.interface.js +3 -0
- package/dist/infrastructure/deployment/services/acr-credential-manager.service.js +144 -0
- package/dist/infrastructure/deployment/services/app-manager.service.js +193 -0
- package/dist/infrastructure/deployment/services/base-helm-deployment.service.js +163 -0
- package/dist/infrastructure/deployment/services/helm-registry.service.js +126 -0
- package/dist/infrastructure/deployment/services/infra-manager.service.js +130 -0
- package/dist/infrastructure/deployment/services/k8s-job-runner.service.js +194 -0
- package/dist/infrastructure/deployment/services/mssql-database-init.service.js +139 -0
- package/dist/infrastructure/deployment/services/mssql-helm-deployment.service.js +100 -0
- package/dist/infrastructure/deployment/services/mssql-storage.service.js +54 -0
- package/dist/infrastructure/deployment/services/mssql-user-manager.service.js +66 -0
- package/dist/infrastructure/deployment/services/oci-artifact.service.js +289 -0
- package/dist/infrastructure/deployment/services/secret-manager.service.js +179 -0
- package/dist/infrastructure/deployment/services/service-manager.service.js +82 -0
- package/dist/infrastructure/deployment/services/version-compatibility.service.js +291 -0
- package/dist/infrastructure/environment/interfaces/hardware-info.interface.js +3 -0
- package/dist/infrastructure/environment/interfaces/network-checker.interface.js +3 -0
- package/dist/infrastructure/environment/services/hardware-info.service.js +135 -0
- package/dist/infrastructure/environment/services/network-checker.service.js +142 -0
- package/dist/infrastructure/environment/windows-environment.adapter.js +162 -0
- package/dist/infrastructure/errors/app-error.js +73 -0
- package/dist/infrastructure/errors/error-handler.interface.js +3 -0
- package/dist/infrastructure/errors/error-handler.js +218 -0
- package/dist/infrastructure/errors/exit-codes.js +27 -0
- package/dist/infrastructure/errors/index.js +25 -0
- package/dist/infrastructure/execution/builders/base-command.builder.js +122 -0
- package/dist/infrastructure/execution/builders/host-command.builder.js +58 -0
- package/dist/infrastructure/execution/builders/windows-host-command.builder.js +50 -0
- package/dist/infrastructure/execution/builders/wsl-command.builder.js +29 -0
- package/dist/infrastructure/execution/command-builder.js +252 -0
- package/dist/infrastructure/execution/command-executor.service.js +230 -0
- package/dist/infrastructure/execution/environments/wsl-execution.environment.js +70 -0
- package/dist/infrastructure/execution/execution-environment.factory.js +53 -0
- package/dist/infrastructure/execution/index.js +25 -0
- package/dist/infrastructure/execution/interfaces/command-builder.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/command-executor.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/execution-environment-factory.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/execution-environment.interface.js +7 -0
- package/dist/infrastructure/execution/interfaces/host-command-builder.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/index.js +23 -0
- package/dist/infrastructure/execution/interfaces/script-executor.interface.js +3 -0
- package/dist/infrastructure/execution/script-executor.service.js +171 -0
- package/dist/infrastructure/http/http-client.service.js +176 -0
- package/dist/infrastructure/http/index.js +18 -0
- package/dist/infrastructure/http/interfaces/http-client.interface.js +3 -0
- package/dist/infrastructure/interceptors/index.js +8 -0
- package/dist/infrastructure/interceptors/interceptor.factory.js +44 -0
- package/dist/infrastructure/interceptors/interceptor.interface.js +3 -0
- package/dist/infrastructure/interceptors/logging.interceptor.js +171 -0
- package/dist/infrastructure/logger/correlation-id.adapter.js +68 -0
- package/dist/infrastructure/logger/index.js +23 -0
- package/dist/infrastructure/logger/interfaces/index.js +22 -0
- package/dist/infrastructure/logger/interfaces/log-reader.repository.interface.js +7 -0
- package/dist/infrastructure/logger/interfaces/log-writer.repository.interface.js +7 -0
- package/dist/infrastructure/logger/logger.adapter.js +274 -0
- package/dist/infrastructure/logger/services/file-log-reader.repository.js +148 -0
- package/dist/infrastructure/logger/services/file-log-writer.repository.js +307 -0
- package/dist/infrastructure/logger/services/index.js +22 -0
- package/dist/infrastructure/persistence/index.js +25 -0
- package/dist/infrastructure/persistence/instance-metadata.adapter.js +100 -0
- package/dist/infrastructure/persistence/instance-storage.adapter.js +64 -0
- package/dist/infrastructure/persistence/interfaces/config.repository.interface.js +3 -0
- package/dist/infrastructure/persistence/interfaces/index.js +22 -0
- package/dist/infrastructure/persistence/interfaces/instance.repository.interface.js +3 -0
- package/dist/infrastructure/persistence/services/file-system-config.repository.js +168 -0
- package/dist/infrastructure/persistence/services/file-system-instance.repository.js +170 -0
- package/dist/infrastructure/persistence/services/index.js +22 -0
- package/dist/infrastructure/persistence/user-settings.adapter.js +55 -0
- package/dist/infrastructure/platform-detector.js +71 -0
- package/dist/infrastructure/platforms/windows/interfaces/microk8s.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/rootfs-manager.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/windows-features.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/windows-info.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-config.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-info.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-inspection.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-lifecycle.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-naming.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-manager.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-resources.interface.js +8 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-updater.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wslconfig-parser.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/parsers/wsl-version.parser.js +133 -0
- package/dist/infrastructure/platforms/windows/services/microk8s.service.js +168 -0
- package/dist/infrastructure/platforms/windows/services/rootfs-manager.service.js +336 -0
- package/dist/infrastructure/platforms/windows/services/windows-features.service.js +191 -0
- package/dist/infrastructure/platforms/windows/services/windows-info.service.js +138 -0
- package/dist/infrastructure/platforms/windows/services/wsl-config.service.js +171 -0
- package/dist/infrastructure/platforms/windows/services/wsl-info.service.js +226 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-inspection.service.js +325 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-lifecycle.service.js +442 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-naming.service.js +93 -0
- package/dist/infrastructure/platforms/windows/services/wsl-updater.service.js +273 -0
- package/dist/infrastructure/platforms/windows/services/wslconfig-parser.service.js +222 -0
- package/dist/infrastructure/platforms/windows/wsl-base-image.adapter.js +41 -0
- package/dist/infrastructure/platforms/windows/wsl-instance-manager.adapter.js +150 -0
- package/dist/infrastructure/utils/error-formatter.util.js +29 -0
- package/dist/infrastructure/utils/file-operations.util.js +201 -0
- package/dist/infrastructure/utils/input-validator.util.js +152 -0
- package/dist/infrastructure/utils/retry.util.js +98 -0
- package/dist/presentation/controllers/config.controller.js +146 -0
- package/dist/presentation/controllers/credentials.controller.js +105 -0
- package/dist/presentation/controllers/index.js +25 -0
- package/dist/presentation/controllers/instance.controller.js +363 -0
- package/dist/presentation/controllers/logs.controller.js +103 -0
- package/dist/presentation/controllers/setup.controller.js +175 -0
- package/dist/presentation/interfaces/cli-options.interface.js +8 -0
- package/dist/presentation/prompts/acr-credentials.prompt.js +76 -0
- package/dist/presentation/prompts/index.js +21 -0
- package/dist/presentation/ui/cli-progress.service.js +193 -0
- package/dist/presentation/ui/constants/output-symbols.js +42 -0
- package/dist/presentation/ui/index.js +27 -0
- package/dist/presentation/ui/interaction.service.js +276 -0
- package/dist/presentation/ui/interfaces/cli-progress.interface.js +9 -0
- package/dist/presentation/ui/interfaces/output-formatter.interface.js +23 -0
- package/dist/presentation/ui/log-level.enum.js +66 -0
- package/dist/presentation/ui/output-builder.service.js +378 -0
- package/dist/presentation/ui/output-formatter.service.js +393 -0
- package/package.json +65 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerInfrastructureModule = registerInfrastructureModule;
|
|
4
|
+
const tsyringe_1 = require("tsyringe");
|
|
5
|
+
const tokens_1 = require("../tokens");
|
|
6
|
+
const platform_detector_1 = require("../../infrastructure/platform-detector");
|
|
7
|
+
// ===== Adapters (Domain Ports 實作) =====
|
|
8
|
+
const wsl_instance_manager_adapter_1 = require("../../infrastructure/platforms/windows/wsl-instance-manager.adapter");
|
|
9
|
+
const wsl_base_image_adapter_1 = require("../../infrastructure/platforms/windows/wsl-base-image.adapter");
|
|
10
|
+
const deployment_adapter_1 = require("../../infrastructure/deployment/deployment.adapter");
|
|
11
|
+
const user_settings_adapter_1 = require("../../infrastructure/persistence/user-settings.adapter");
|
|
12
|
+
const instance_storage_adapter_1 = require("../../infrastructure/persistence/instance-storage.adapter");
|
|
13
|
+
const logger_adapter_1 = require("../../infrastructure/logger/logger.adapter");
|
|
14
|
+
const windows_environment_adapter_1 = require("../../infrastructure/environment/windows-environment.adapter");
|
|
15
|
+
// ===== Internal Services - Windows/WSL =====
|
|
16
|
+
const wsl_info_service_1 = require("../../infrastructure/platforms/windows/services/wsl-info.service");
|
|
17
|
+
const wsl_config_service_1 = require("../../infrastructure/platforms/windows/services/wsl-config.service");
|
|
18
|
+
const wsl_updater_service_1 = require("../../infrastructure/platforms/windows/services/wsl-updater.service");
|
|
19
|
+
const rootfs_manager_service_1 = require("../../infrastructure/platforms/windows/services/rootfs-manager.service");
|
|
20
|
+
const microk8s_service_1 = require("../../infrastructure/platforms/windows/services/microk8s.service");
|
|
21
|
+
// ===== WSL 子服務 (取代 WslManagerService) =====
|
|
22
|
+
const wsl_instance_naming_service_1 = require("../../infrastructure/platforms/windows/services/wsl-instance-naming.service");
|
|
23
|
+
const wsl_instance_lifecycle_service_1 = require("../../infrastructure/platforms/windows/services/wsl-instance-lifecycle.service");
|
|
24
|
+
const wsl_instance_inspection_service_1 = require("../../infrastructure/platforms/windows/services/wsl-instance-inspection.service");
|
|
25
|
+
// ===== Internal Services - Persistence =====
|
|
26
|
+
const instance_metadata_adapter_1 = require("../../infrastructure/persistence/instance-metadata.adapter");
|
|
27
|
+
// ===== Internal Services - Environment (平台無關) =====
|
|
28
|
+
const network_checker_service_1 = require("../../infrastructure/environment/services/network-checker.service");
|
|
29
|
+
const hardware_info_service_1 = require("../../infrastructure/environment/services/hardware-info.service");
|
|
30
|
+
// ===== Internal Services - Windows Platform =====
|
|
31
|
+
const windows_info_service_1 = require("../../infrastructure/platforms/windows/services/windows-info.service");
|
|
32
|
+
const windows_features_service_1 = require("../../infrastructure/platforms/windows/services/windows-features.service");
|
|
33
|
+
const wslconfig_parser_service_1 = require("../../infrastructure/platforms/windows/services/wslconfig-parser.service");
|
|
34
|
+
// ===== Internal Services - Deployment =====
|
|
35
|
+
const helm_registry_service_1 = require("../../infrastructure/deployment/services/helm-registry.service");
|
|
36
|
+
const secret_manager_service_1 = require("../../infrastructure/deployment/services/secret-manager.service");
|
|
37
|
+
const version_compatibility_service_1 = require("../../infrastructure/deployment/services/version-compatibility.service");
|
|
38
|
+
const oci_artifact_service_1 = require("../../infrastructure/deployment/services/oci-artifact.service");
|
|
39
|
+
const infra_manager_service_1 = require("../../infrastructure/deployment/services/infra-manager.service");
|
|
40
|
+
const service_manager_service_1 = require("../../infrastructure/deployment/services/service-manager.service");
|
|
41
|
+
const app_manager_service_1 = require("../../infrastructure/deployment/services/app-manager.service");
|
|
42
|
+
// ===== MSSQL 子服務 (取代 MssqlManagerService) =====
|
|
43
|
+
const mssql_helm_deployment_service_1 = require("../../infrastructure/deployment/services/mssql-helm-deployment.service");
|
|
44
|
+
const mssql_storage_service_1 = require("../../infrastructure/deployment/services/mssql-storage.service");
|
|
45
|
+
const mssql_database_init_service_1 = require("../../infrastructure/deployment/services/mssql-database-init.service");
|
|
46
|
+
const mssql_user_manager_service_1 = require("../../infrastructure/deployment/services/mssql-user-manager.service");
|
|
47
|
+
const k8s_job_runner_service_1 = require("../../infrastructure/deployment/services/k8s-job-runner.service");
|
|
48
|
+
// ===== Internal Services - Persistence =====
|
|
49
|
+
const file_system_instance_repository_1 = require("../../infrastructure/persistence/services/file-system-instance.repository");
|
|
50
|
+
const file_system_config_repository_1 = require("../../infrastructure/persistence/services/file-system-config.repository");
|
|
51
|
+
// ===== Internal Services - Logger =====
|
|
52
|
+
const file_log_writer_repository_1 = require("../../infrastructure/logger/services/file-log-writer.repository");
|
|
53
|
+
const file_log_reader_repository_1 = require("../../infrastructure/logger/services/file-log-reader.repository");
|
|
54
|
+
const correlation_id_adapter_1 = require("../../infrastructure/logger/correlation-id.adapter");
|
|
55
|
+
// ===== Internal Services - Execution =====
|
|
56
|
+
const command_executor_service_1 = require("../../infrastructure/execution/command-executor.service");
|
|
57
|
+
const script_executor_service_1 = require("../../infrastructure/execution/script-executor.service");
|
|
58
|
+
const execution_environment_factory_1 = require("../../infrastructure/execution/execution-environment.factory");
|
|
59
|
+
const host_command_builder_1 = require("../../infrastructure/execution/builders/host-command.builder");
|
|
60
|
+
const windows_host_command_builder_1 = require("../../infrastructure/execution/builders/windows-host-command.builder");
|
|
61
|
+
const environments_1 = require("../../constants/environments");
|
|
62
|
+
// ===== Internal Services - HTTP =====
|
|
63
|
+
const http_client_service_1 = require("../../infrastructure/http/http-client.service");
|
|
64
|
+
// ===== Internal Services - Config =====
|
|
65
|
+
const app_config_service_1 = require("../../infrastructure/config/app-config.service");
|
|
66
|
+
// ===== Internal Services - Error Handling =====
|
|
67
|
+
const error_handler_1 = require("../../infrastructure/errors/error-handler");
|
|
68
|
+
// ===== Internal Services - ACR Credentials (merged into Deployment) =====
|
|
69
|
+
const acr_credential_manager_service_1 = require("../../infrastructure/deployment/services/acr-credential-manager.service");
|
|
70
|
+
/**
|
|
71
|
+
* 註冊 Infrastructure 模組
|
|
72
|
+
*
|
|
73
|
+
* 根據平台動態註冊對應的 Adapter
|
|
74
|
+
*
|
|
75
|
+
* 重要:註冊順序需遵循依賴關係
|
|
76
|
+
* - 被依賴的服務必須在依賴它的服務之前註冊
|
|
77
|
+
* - 特別是 VersionCompatibilityService 依賴 HttpClient, AppConfig, AcrCredentialManager
|
|
78
|
+
*/
|
|
79
|
+
function registerInfrastructureModule() {
|
|
80
|
+
const platform = (0, platform_detector_1.detectPlatform)();
|
|
81
|
+
// =========================================================================
|
|
82
|
+
// 第 1 層:基礎服務(無外部依賴或僅依賴 Node.js 內建模組)
|
|
83
|
+
// =========================================================================
|
|
84
|
+
// Node.js Process(用於信號處理)
|
|
85
|
+
tsyringe_1.container.registerInstance(tokens_1.TOKENS.Internal.Process, process);
|
|
86
|
+
// Logger 底層服務(無依賴)
|
|
87
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.FileLogWriter, file_log_writer_repository_1.FileLogWriterRepository);
|
|
88
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.FileLogReader, file_log_reader_repository_1.FileLogReaderRepository);
|
|
89
|
+
// HTTP 客戶端(無依賴)
|
|
90
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.HttpClientService, http_client_service_1.HttpClientService);
|
|
91
|
+
// 執行器服務(無依賴)
|
|
92
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.CommandExecutorService, command_executor_service_1.CommandExecutorService);
|
|
93
|
+
// 主機命令建構器(根據平台註冊對應實作)
|
|
94
|
+
if (process.platform === environments_1.PLATFORM_TYPES.WINDOWS) {
|
|
95
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IHostCommandBuilder, windows_host_command_builder_1.WindowsHostCommandBuilder);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IHostCommandBuilder, host_command_builder_1.HostCommandBuilder);
|
|
99
|
+
}
|
|
100
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.ExecutionEnvironmentFactory, execution_environment_factory_1.ExecutionEnvironmentFactory);
|
|
101
|
+
// =========================================================================
|
|
102
|
+
// 第 2 層:Logger Port(依賴 FileLogWriter, FileLogReader)
|
|
103
|
+
// =========================================================================
|
|
104
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.ILoggerPort, logger_adapter_1.LoggerAdapter);
|
|
105
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.ICorrelationIdPort, correlation_id_adapter_1.CorrelationIdAdapter);
|
|
106
|
+
// =========================================================================
|
|
107
|
+
// 第 3 層:Config 服務(依賴 Logger)
|
|
108
|
+
// =========================================================================
|
|
109
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.AppConfig, app_config_service_1.AppConfig);
|
|
110
|
+
// 公開 token 映射
|
|
111
|
+
tsyringe_1.container.register(tokens_1.TOKENS.IAppConfig, { useToken: tokens_1.TOKENS.Internal.AppConfig });
|
|
112
|
+
// Domain Port 映射(AppConfig 同時實作 IAppConfig 和 IAppConfigPort)
|
|
113
|
+
tsyringe_1.container.register(tokens_1.TOKENS.IAppConfigPort, { useToken: tokens_1.TOKENS.Internal.AppConfig });
|
|
114
|
+
// =========================================================================
|
|
115
|
+
// 第 4 層:錯誤處理(依賴 Logger, Config)
|
|
116
|
+
// =========================================================================
|
|
117
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.ErrorHandler, error_handler_1.ErrorHandler);
|
|
118
|
+
// Domain Port 映射
|
|
119
|
+
tsyringe_1.container.register(tokens_1.TOKENS.IErrorHandlerPort, { useToken: tokens_1.TOKENS.Internal.ErrorHandler });
|
|
120
|
+
// =========================================================================
|
|
121
|
+
// 第 5 層:ACR 憑證管理(依賴 AppConfig)
|
|
122
|
+
// =========================================================================
|
|
123
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.AcrCredentialManager, acr_credential_manager_service_1.AcrCredentialManagerService);
|
|
124
|
+
// =========================================================================
|
|
125
|
+
// 第 6 層:版本相容性服務(依賴 HttpClient, AppConfig, AcrCredentialManager, Logger)
|
|
126
|
+
// =========================================================================
|
|
127
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.VersionCompatibilityService, version_compatibility_service_1.VersionCompatibilityService);
|
|
128
|
+
// =========================================================================
|
|
129
|
+
// 第 6.5 層:OCI Artifact 服務(依賴 HttpClient, AppConfig, ExecutionEnvironmentFactory, Logger)
|
|
130
|
+
// =========================================================================
|
|
131
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IOciArtifactService, oci_artifact_service_1.OciArtifactService);
|
|
132
|
+
// =========================================================================
|
|
133
|
+
// 第 7 層:其他部署相關服務
|
|
134
|
+
// =========================================================================
|
|
135
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.HelmRegistryService, helm_registry_service_1.HelmRegistryService);
|
|
136
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.SecretManagerService, secret_manager_service_1.SecretManagerService);
|
|
137
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.InfraManagerService, infra_manager_service_1.InfraManagerService);
|
|
138
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.ServiceManagerService, service_manager_service_1.ServiceManagerService);
|
|
139
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.AppManagerService, app_manager_service_1.AppManagerService);
|
|
140
|
+
// MSSQL 子服務(取代 MssqlManagerService)
|
|
141
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IMssqlStorage, mssql_storage_service_1.MssqlStorageService);
|
|
142
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IMssqlDatabaseInit, mssql_database_init_service_1.MssqlDatabaseInitService);
|
|
143
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IMssqlUserManager, mssql_user_manager_service_1.MssqlUserManagerService);
|
|
144
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IK8sJobRunner, k8s_job_runner_service_1.K8sJobRunnerService);
|
|
145
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IMssqlHelmDeployment, mssql_helm_deployment_service_1.MssqlHelmDeploymentService);
|
|
146
|
+
// =========================================================================
|
|
147
|
+
// 第 8 層:Script 執行器(依賴 CommandExecutor)
|
|
148
|
+
// =========================================================================
|
|
149
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.ScriptExecutorService, script_executor_service_1.ScriptExecutorService);
|
|
150
|
+
// =========================================================================
|
|
151
|
+
// 第 9 層:Persistence 服務
|
|
152
|
+
// =========================================================================
|
|
153
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.FileInstanceRepository, file_system_instance_repository_1.FileSystemInstanceRepository);
|
|
154
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.FileConfigRepository, file_system_config_repository_1.FileSystemConfigRepository);
|
|
155
|
+
// =========================================================================
|
|
156
|
+
// 第 10 層:System 服務(平台無關)
|
|
157
|
+
// =========================================================================
|
|
158
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.NetworkCheckerService, network_checker_service_1.NetworkCheckerService);
|
|
159
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IHardwareInfo, hardware_info_service_1.HardwareInfoService);
|
|
160
|
+
// =========================================================================
|
|
161
|
+
// 第 11 層:Platform-Specific 服務(Windows/WSL)
|
|
162
|
+
// =========================================================================
|
|
163
|
+
if (platform === 'windows') {
|
|
164
|
+
// Windows 系統資源服務
|
|
165
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.WindowsInfoService, windows_info_service_1.WindowsInfoService);
|
|
166
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.WindowsFeaturesService, windows_features_service_1.WindowsFeaturesService);
|
|
167
|
+
// WSL 相關服務
|
|
168
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.WslInfoService, wsl_info_service_1.WslInfoService);
|
|
169
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IWslConfigParser, wslconfig_parser_service_1.WslConfigParserService);
|
|
170
|
+
// WSL 子服務(取代 WslManagerService)
|
|
171
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IWslInstanceNaming, wsl_instance_naming_service_1.WslInstanceNamingService);
|
|
172
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IWslInstanceInspection, wsl_instance_inspection_service_1.WslInstanceInspectionService);
|
|
173
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.IWslInstanceLifecycle, wsl_instance_lifecycle_service_1.WslInstanceLifecycleService);
|
|
174
|
+
// 其他 WSL 相關服務
|
|
175
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.WslConfigService, wsl_config_service_1.WslConfigService);
|
|
176
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.WslUpdaterService, wsl_updater_service_1.WslUpdaterService);
|
|
177
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.RootfsManagerService, rootfs_manager_service_1.RootfsManagerService);
|
|
178
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.Internal.MicroK8sService, microk8s_service_1.MicroK8sService);
|
|
179
|
+
}
|
|
180
|
+
// =========================================================================
|
|
181
|
+
// 第 12 層:Domain Ports - Adapters(依賴上述所有服務)
|
|
182
|
+
// =========================================================================
|
|
183
|
+
if (platform === 'windows') {
|
|
184
|
+
// Windows/WSL 平台
|
|
185
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IInstanceManagerPort, wsl_instance_manager_adapter_1.WslInstanceManagerAdapter);
|
|
186
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IBaseImagePort, wsl_base_image_adapter_1.WslBaseImageAdapter);
|
|
187
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IRuntimeEnvironmentPort, windows_environment_adapter_1.WindowsEnvironmentAdapter);
|
|
188
|
+
}
|
|
189
|
+
else if (platform === 'linux') {
|
|
190
|
+
// Linux/Docker 平台(未來實作)
|
|
191
|
+
throw new Error('Linux platform not yet implemented');
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
195
|
+
}
|
|
196
|
+
// 共用 Ports(跨平台)
|
|
197
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IDeploymentPort, deployment_adapter_1.DeploymentAdapter);
|
|
198
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IUserSettingsPort, user_settings_adapter_1.UserSettingsAdapter);
|
|
199
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IInstanceStoragePort, instance_storage_adapter_1.InstanceStorageAdapter);
|
|
200
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IInstanceMetadataPort, instance_metadata_adapter_1.InstanceMetadataAdapter);
|
|
201
|
+
// 子介面映射(使用相同的 DeploymentAdapter 實作)
|
|
202
|
+
tsyringe_1.container.register(tokens_1.TOKENS.IK8sDeployerPort, { useToken: tokens_1.TOKENS.IDeploymentPort });
|
|
203
|
+
tsyringe_1.container.register(tokens_1.TOKENS.IChartVersionPort, { useToken: tokens_1.TOKENS.IDeploymentPort });
|
|
204
|
+
tsyringe_1.container.register(tokens_1.TOKENS.ICredentialsPort, { useToken: tokens_1.TOKENS.IDeploymentPort });
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=infrastructure.module.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerInterceptorModule = registerInterceptorModule;
|
|
4
|
+
exports.applyInterceptors = applyInterceptors;
|
|
5
|
+
const tsyringe_1 = require("tsyringe");
|
|
6
|
+
const tokens_1 = require("../tokens");
|
|
7
|
+
const interceptors_1 = require("../../infrastructure/interceptors");
|
|
8
|
+
/**
|
|
9
|
+
* 註冊攔截器模組
|
|
10
|
+
*
|
|
11
|
+
* 註冊 LoggingInterceptor 和 InterceptorFactory 為 Singleton
|
|
12
|
+
*/
|
|
13
|
+
function registerInterceptorModule() {
|
|
14
|
+
tsyringe_1.container.registerSingleton(interceptors_1.LoggingInterceptor);
|
|
15
|
+
tsyringe_1.container.registerSingleton(interceptors_1.InterceptorFactory);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 需要攔截的服務清單
|
|
19
|
+
*
|
|
20
|
+
* token: DI 容器中的 Token
|
|
21
|
+
* name: 服務名稱(用於 log 標識)
|
|
22
|
+
*/
|
|
23
|
+
const INTERCEPTED_SERVICES = [
|
|
24
|
+
// === 核心服務 ===
|
|
25
|
+
{ token: tokens_1.TOKENS.IDeploymentPort, name: 'DeploymentAdapter' },
|
|
26
|
+
{ token: tokens_1.TOKENS.Internal.VersionCompatibilityService, name: 'VersionCompatibility' },
|
|
27
|
+
{ token: tokens_1.TOKENS.Internal.IHelmRegistry, name: 'HelmRegistry' },
|
|
28
|
+
{ token: tokens_1.TOKENS.Internal.IWslInstanceLifecycle, name: 'WslInstanceLifecycle' },
|
|
29
|
+
// === K8s/Helm 服務 ===
|
|
30
|
+
{ token: tokens_1.TOKENS.Internal.IOciArtifactService, name: 'OciArtifact' },
|
|
31
|
+
{ token: tokens_1.TOKENS.Internal.ISecretManager, name: 'SecretManager' },
|
|
32
|
+
{ token: tokens_1.TOKENS.Internal.IK8sJobRunner, name: 'K8sJobRunner' },
|
|
33
|
+
{ token: tokens_1.TOKENS.Internal.IMicroK8s, name: 'MicroK8s' },
|
|
34
|
+
// === 部署管理服務 ===
|
|
35
|
+
{ token: tokens_1.TOKENS.Internal.IInfraManager, name: 'InfraManager' },
|
|
36
|
+
{ token: tokens_1.TOKENS.Internal.IServiceManager, name: 'ServiceManager' },
|
|
37
|
+
{ token: tokens_1.TOKENS.Internal.IAppManager, name: 'AppManager' },
|
|
38
|
+
// === MSSQL 服務 ===
|
|
39
|
+
{ token: tokens_1.TOKENS.Internal.IMssqlHelmDeployment, name: 'MssqlHelmDeployment' },
|
|
40
|
+
{ token: tokens_1.TOKENS.Internal.IMssqlStorage, name: 'MssqlStorage' },
|
|
41
|
+
{ token: tokens_1.TOKENS.Internal.IMssqlDatabaseInit, name: 'MssqlDatabaseInit' },
|
|
42
|
+
// === WSL 服務 ===
|
|
43
|
+
{ token: tokens_1.TOKENS.Internal.IWslInstanceInspection, name: 'WslInstanceInspection' },
|
|
44
|
+
{ token: tokens_1.TOKENS.Internal.RootfsManagerService, name: 'RootfsManager' },
|
|
45
|
+
// === 執行/網路服務 ===
|
|
46
|
+
{ token: tokens_1.TOKENS.Internal.ICommandExecutor, name: 'CommandExecutor' },
|
|
47
|
+
{ token: tokens_1.TOKENS.Internal.IHttpClient, name: 'HttpClient' },
|
|
48
|
+
{ token: tokens_1.TOKENS.Internal.IAcrCredentialManager, name: 'AcrCredentialManager' },
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* 套用攔截器到已註冊的服務
|
|
52
|
+
*
|
|
53
|
+
* 注意:此函數必須在所有服務註冊完成後調用
|
|
54
|
+
*/
|
|
55
|
+
function applyInterceptors() {
|
|
56
|
+
const factory = tsyringe_1.container.resolve(interceptors_1.InterceptorFactory);
|
|
57
|
+
for (const { token, name } of INTERCEPTED_SERVICES) {
|
|
58
|
+
try {
|
|
59
|
+
const original = tsyringe_1.container.resolve(token);
|
|
60
|
+
const intercepted = factory.wrapWithInterceptors(original, name);
|
|
61
|
+
tsyringe_1.container.registerInstance(token, intercepted);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// 服務可能未註冊,跳過
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=interceptor.module.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPresentationModule = registerPresentationModule;
|
|
4
|
+
const tsyringe_1 = require("tsyringe");
|
|
5
|
+
const tokens_1 = require("../tokens");
|
|
6
|
+
// UI Services
|
|
7
|
+
const output_builder_service_1 = require("../../presentation/ui/output-builder.service");
|
|
8
|
+
const output_formatter_service_1 = require("../../presentation/ui/output-formatter.service");
|
|
9
|
+
const interaction_service_1 = require("../../presentation/ui/interaction.service");
|
|
10
|
+
const cli_progress_service_1 = require("../../presentation/ui/cli-progress.service");
|
|
11
|
+
// Prompts
|
|
12
|
+
const acr_credentials_prompt_1 = require("../../presentation/prompts/acr-credentials.prompt");
|
|
13
|
+
// Controllers
|
|
14
|
+
const instance_controller_1 = require("../../presentation/controllers/instance.controller");
|
|
15
|
+
const setup_controller_1 = require("../../presentation/controllers/setup.controller");
|
|
16
|
+
const config_controller_1 = require("../../presentation/controllers/config.controller");
|
|
17
|
+
const logs_controller_1 = require("../../presentation/controllers/logs.controller");
|
|
18
|
+
const credentials_controller_1 = require("../../presentation/controllers/credentials.controller");
|
|
19
|
+
function registerPresentationModule() {
|
|
20
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IOutputPort, output_builder_service_1.OutputBuilder);
|
|
21
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IProgress, cli_progress_service_1.CliProgress);
|
|
22
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IOutputFormatter, output_formatter_service_1.OutputFormatter);
|
|
23
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.IUserInteractionPort, interaction_service_1.UserInteraction);
|
|
24
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.AcrCredentialsPrompt, acr_credentials_prompt_1.AcrCredentialsPrompt);
|
|
25
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.InstanceController, instance_controller_1.InstanceController);
|
|
26
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.SetupController, setup_controller_1.SetupController);
|
|
27
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.ConfigController, config_controller_1.ConfigController);
|
|
28
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.LogsController, logs_controller_1.LogsController);
|
|
29
|
+
tsyringe_1.container.registerSingleton(tokens_1.TOKENS.CredentialsController, credentials_controller_1.CredentialsController);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=presentation.module.js.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DI Container Token 定義
|
|
4
|
+
*
|
|
5
|
+
* 根據 Clean Architecture 分層組織所有依賴注入的 Token
|
|
6
|
+
* 使用字串常數而非 Symbol,以便於除錯和序列化
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TOKENS = void 0;
|
|
10
|
+
exports.TOKENS = {
|
|
11
|
+
// ===========================================================================
|
|
12
|
+
// Domain Ports (12 個核心業務能力 Port)
|
|
13
|
+
// ===========================================================================
|
|
14
|
+
IInstanceManagerPort: 'IInstanceManagerPort',
|
|
15
|
+
IDeploymentPort: 'IDeploymentPort',
|
|
16
|
+
IK8sDeployerPort: 'IK8sDeployerPort',
|
|
17
|
+
IChartVersionPort: 'IChartVersionPort',
|
|
18
|
+
ICredentialsPort: 'ICredentialsPort',
|
|
19
|
+
ILoggerPort: 'ILoggerPort',
|
|
20
|
+
IRuntimeEnvironmentPort: 'IRuntimeEnvironmentPort',
|
|
21
|
+
IBaseImagePort: 'IBaseImagePort',
|
|
22
|
+
IAppConfigPort: 'IAppConfigPort',
|
|
23
|
+
IUserSettingsPort: 'IUserSettingsPort',
|
|
24
|
+
IInstanceStoragePort: 'IInstanceStoragePort',
|
|
25
|
+
IErrorHandlerPort: 'IErrorHandlerPort',
|
|
26
|
+
ICorrelationIdPort: 'ICorrelationIdPort',
|
|
27
|
+
IInstanceMetadataPort: 'IInstanceMetadataPort',
|
|
28
|
+
IUserInteractionPort: 'IUserInteractionPort',
|
|
29
|
+
// ===========================================================================
|
|
30
|
+
// Application Layer - Use Cases
|
|
31
|
+
// ===========================================================================
|
|
32
|
+
// --- Instance Use Cases ---
|
|
33
|
+
InstallInstanceUseCase: 'InstallInstanceUseCase',
|
|
34
|
+
StartInstanceUseCase: 'StartInstanceUseCase',
|
|
35
|
+
StopInstanceUseCase: 'StopInstanceUseCase',
|
|
36
|
+
DeleteInstanceUseCase: 'DeleteInstanceUseCase',
|
|
37
|
+
ListInstancesUseCase: 'ListInstancesUseCase',
|
|
38
|
+
ListChartsUseCase: 'ListChartsUseCase',
|
|
39
|
+
// --- Setup Use Cases ---
|
|
40
|
+
SetupEnvironmentUseCase: 'SetupEnvironmentUseCase',
|
|
41
|
+
// --- Config Use Cases ---
|
|
42
|
+
GetConfigUseCase: 'GetConfigUseCase',
|
|
43
|
+
SetConfigUseCase: 'SetConfigUseCase',
|
|
44
|
+
// --- Credentials Use Cases ---
|
|
45
|
+
GetCredentialsUseCase: 'GetCredentialsUseCase',
|
|
46
|
+
// --- Logs Use Cases ---
|
|
47
|
+
ShowLogsUseCase: 'ShowLogsUseCase',
|
|
48
|
+
// ===========================================================================
|
|
49
|
+
// Presentation Layer - Controllers & UI Services
|
|
50
|
+
// ===========================================================================
|
|
51
|
+
// --- Controllers ---
|
|
52
|
+
InstanceController: 'InstanceController',
|
|
53
|
+
SetupController: 'SetupController',
|
|
54
|
+
ConfigController: 'ConfigController',
|
|
55
|
+
LogsController: 'LogsController',
|
|
56
|
+
CredentialsController: 'CredentialsController',
|
|
57
|
+
// --- UI Services ---
|
|
58
|
+
ISystemOutput: 'ISystemOutput',
|
|
59
|
+
IOutputPort: 'IOutputPort',
|
|
60
|
+
IProgress: 'IProgress',
|
|
61
|
+
IOutputFormatter: 'IOutputFormatter',
|
|
62
|
+
// --- Infrastructure Common Services (CLI 啟動時需要) ---
|
|
63
|
+
IAppConfig: 'IAppConfig',
|
|
64
|
+
// --- Prompts ---
|
|
65
|
+
AcrCredentialsPrompt: 'AcrCredentialsPrompt',
|
|
66
|
+
// ===========================================================================
|
|
67
|
+
// Internal Services (不公開給其他層,僅供 Infrastructure 內部使用)
|
|
68
|
+
// ===========================================================================
|
|
69
|
+
Internal: {
|
|
70
|
+
// --- Windows/WSL Services ---
|
|
71
|
+
WslInfoService: 'Internal.WslInfoService',
|
|
72
|
+
WslConfigService: 'Internal.WslConfigService',
|
|
73
|
+
IWslConfig: 'Internal.WslConfigService', // Alias for injection
|
|
74
|
+
WslUpdaterService: 'Internal.WslUpdaterService',
|
|
75
|
+
RootfsManagerService: 'Internal.RootfsManagerService',
|
|
76
|
+
WindowsInfoService: 'Internal.WindowsInfoService',
|
|
77
|
+
WindowsFeaturesService: 'Internal.WindowsFeaturesService',
|
|
78
|
+
MicroK8sService: 'Internal.MicroK8sService',
|
|
79
|
+
IMicroK8s: 'Internal.MicroK8sService', // Alias for injection
|
|
80
|
+
// --- WSL 子服務 (取代 WslManagerService) ---
|
|
81
|
+
WslInstanceNamingService: 'Internal.WslInstanceNamingService',
|
|
82
|
+
IWslInstanceNaming: 'Internal.WslInstanceNamingService',
|
|
83
|
+
WslInstanceLifecycleService: 'Internal.WslInstanceLifecycleService',
|
|
84
|
+
IWslInstanceLifecycle: 'Internal.WslInstanceLifecycleService',
|
|
85
|
+
WslInstanceInspectionService: 'Internal.WslInstanceInspectionService',
|
|
86
|
+
IWslInstanceInspection: 'Internal.WslInstanceInspectionService',
|
|
87
|
+
// --- K8s/Helm Services ---
|
|
88
|
+
HelmService: 'Internal.HelmService',
|
|
89
|
+
HelmRegistryService: 'Internal.HelmRegistryService',
|
|
90
|
+
IHelmRegistry: 'Internal.HelmRegistryService', // Alias for injection
|
|
91
|
+
SecretManagerService: 'Internal.SecretManagerService',
|
|
92
|
+
ISecretManager: 'Internal.SecretManagerService', // Alias for injection
|
|
93
|
+
VersionCompatibilityService: 'Internal.VersionCompatibilityService',
|
|
94
|
+
// --- OCI Artifact Services ---
|
|
95
|
+
OciArtifactService: 'Internal.OciArtifactService',
|
|
96
|
+
IOciArtifactService: 'Internal.OciArtifactService', // Alias for injection
|
|
97
|
+
// --- MSSQL Services ---
|
|
98
|
+
MssqlHelmDeploymentService: 'Internal.MssqlHelmDeploymentService',
|
|
99
|
+
IMssqlHelmDeployment: 'Internal.MssqlHelmDeploymentService',
|
|
100
|
+
MssqlStorageService: 'Internal.MssqlStorageService',
|
|
101
|
+
IMssqlStorage: 'Internal.MssqlStorageService',
|
|
102
|
+
MssqlDatabaseInitService: 'Internal.MssqlDatabaseInitService',
|
|
103
|
+
IMssqlDatabaseInit: 'Internal.MssqlDatabaseInitService',
|
|
104
|
+
MssqlUserManagerService: 'Internal.MssqlUserManagerService',
|
|
105
|
+
IMssqlUserManager: 'Internal.MssqlUserManagerService',
|
|
106
|
+
K8sJobRunnerService: 'Internal.K8sJobRunnerService',
|
|
107
|
+
IK8sJobRunner: 'Internal.K8sJobRunnerService',
|
|
108
|
+
InfraManagerService: 'Internal.InfraManagerService',
|
|
109
|
+
IInfraManager: 'Internal.InfraManagerService', // Alias for injection
|
|
110
|
+
ServiceManagerService: 'Internal.ServiceManagerService',
|
|
111
|
+
IServiceManager: 'Internal.ServiceManagerService', // Alias for injection
|
|
112
|
+
AppManagerService: 'Internal.AppManagerService',
|
|
113
|
+
IAppManager: 'Internal.AppManagerService', // Alias for injection
|
|
114
|
+
// --- Persistence Services ---
|
|
115
|
+
FileInstanceRepository: 'Internal.FileInstanceRepository',
|
|
116
|
+
FileConfigRepository: 'Internal.FileConfigRepository',
|
|
117
|
+
// --- Logger Services ---
|
|
118
|
+
FileLogWriter: 'Internal.FileLogWriter',
|
|
119
|
+
FileLogReader: 'Internal.FileLogReader',
|
|
120
|
+
// --- Execution Services ---
|
|
121
|
+
CommandExecutorService: 'Internal.CommandExecutorService',
|
|
122
|
+
ICommandExecutor: 'Internal.CommandExecutorService', // Alias for injection
|
|
123
|
+
ScriptExecutorService: 'Internal.ScriptExecutorService',
|
|
124
|
+
HttpClientService: 'Internal.HttpClientService',
|
|
125
|
+
IHttpClient: 'Internal.HttpClientService', // Alias for injection
|
|
126
|
+
ExecutionEnvironmentFactory: 'Internal.ExecutionEnvironmentFactory',
|
|
127
|
+
IExecutionEnvironmentFactory: 'Internal.ExecutionEnvironmentFactory', // Alias for injection
|
|
128
|
+
HostCommandBuilder: 'Internal.HostCommandBuilder',
|
|
129
|
+
IHostCommandBuilder: 'Internal.HostCommandBuilder', // Alias for injection
|
|
130
|
+
// --- System Services ---
|
|
131
|
+
NetworkCheckerService: 'Internal.NetworkCheckerService',
|
|
132
|
+
// --- System Resources Services ---
|
|
133
|
+
HardwareInfoService: 'Internal.HardwareInfoService',
|
|
134
|
+
IHardwareInfo: 'Internal.HardwareInfoService',
|
|
135
|
+
WslConfigParserService: 'Internal.WslConfigParserService',
|
|
136
|
+
IWslConfigParser: 'Internal.WslConfigParserService',
|
|
137
|
+
// --- Security ---
|
|
138
|
+
AcrCredentialManager: 'Internal.AcrCredentialManager',
|
|
139
|
+
IAcrCredentialManager: 'Internal.AcrCredentialManager', // Alias for injection
|
|
140
|
+
// --- Error Handling ---
|
|
141
|
+
ErrorHandler: 'Internal.ErrorHandler',
|
|
142
|
+
IErrorHandler: 'Internal.ErrorHandler', // Alias for injection
|
|
143
|
+
// --- Config ---
|
|
144
|
+
AppConfig: 'Internal.AppConfig',
|
|
145
|
+
// --- Node.js Process ---
|
|
146
|
+
Process: 'Internal.Process',
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SENSITIVE_RETURN_KEY = exports.NO_LOG_ARGS_KEY = exports.SENSITIVE_PARAMS_KEY = void 0;
|
|
4
|
+
exports.Sensitive = Sensitive;
|
|
5
|
+
exports.NoLogArgs = NoLogArgs;
|
|
6
|
+
exports.SensitiveReturn = SensitiveReturn;
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
exports.SENSITIVE_PARAMS_KEY = 'sensitive:params';
|
|
9
|
+
exports.NO_LOG_ARGS_KEY = 'nolog:args';
|
|
10
|
+
exports.SENSITIVE_RETURN_KEY = 'sensitive:return';
|
|
11
|
+
/**
|
|
12
|
+
* 參數裝飾器 - 標記參數為敏感資料
|
|
13
|
+
*/
|
|
14
|
+
function Sensitive(strategy = 'full') {
|
|
15
|
+
return function (target, propertyKey, parameterIndex) {
|
|
16
|
+
const existingParams = Reflect.getMetadata(exports.SENSITIVE_PARAMS_KEY, target, propertyKey) || [];
|
|
17
|
+
existingParams.push({ index: parameterIndex, strategy });
|
|
18
|
+
Reflect.defineMetadata(exports.SENSITIVE_PARAMS_KEY, existingParams, target, propertyKey);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 方法裝飾器 - 標記整個方法的參數為敏感資料
|
|
23
|
+
*/
|
|
24
|
+
function NoLogArgs() {
|
|
25
|
+
return function (target, propertyKey, descriptor) {
|
|
26
|
+
Reflect.defineMetadata(exports.NO_LOG_ARGS_KEY, true, target, propertyKey);
|
|
27
|
+
return descriptor;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 方法裝飾器 - 標記方法的返回值為敏感資料
|
|
32
|
+
*/
|
|
33
|
+
function SensitiveReturn() {
|
|
34
|
+
return function (target, propertyKey, descriptor) {
|
|
35
|
+
Reflect.defineMetadata(exports.SENSITIVE_RETURN_KEY, true, target, propertyKey);
|
|
36
|
+
return descriptor;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=sensitive.decorator.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CredentialsResolver = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 憑證解析策略 Entity
|
|
6
|
+
*
|
|
7
|
+
* 封裝 ACR 憑證的解析優先級邏輯:
|
|
8
|
+
* 1. 優先使用檔案路徑提供的憑證
|
|
9
|
+
* 2. 其次使用配置中的預設憑證
|
|
10
|
+
* 3. 都沒有則回報錯誤
|
|
11
|
+
*/
|
|
12
|
+
class CredentialsResolver {
|
|
13
|
+
constructor(fileCredentials, configCredentials, pullSecretPath) {
|
|
14
|
+
this.fileCredentials = fileCredentials;
|
|
15
|
+
this.configCredentials = configCredentials;
|
|
16
|
+
this.pullSecretPath = pullSecretPath;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 建立憑證解析器
|
|
20
|
+
* @param fileCredentials - 從檔案載入的憑證(可選)
|
|
21
|
+
* @param configCredentials - 從配置載入的憑證(可選)
|
|
22
|
+
* @param pullSecretPath - Pull secret 檔案路徑(可選)
|
|
23
|
+
* @returns 憑證解析器
|
|
24
|
+
*/
|
|
25
|
+
static create(fileCredentials, configCredentials, pullSecretPath) {
|
|
26
|
+
return new CredentialsResolver(fileCredentials, configCredentials, pullSecretPath);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 建立只有檔案憑證的解析器
|
|
30
|
+
* @param credentials - 檔案憑證
|
|
31
|
+
* @param path - 檔案路徑
|
|
32
|
+
* @returns 憑證解析器
|
|
33
|
+
*/
|
|
34
|
+
static fromFile(credentials, path) {
|
|
35
|
+
return new CredentialsResolver(credentials, null, path);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 建立只有配置憑證的解析器
|
|
39
|
+
* @param credentials - 配置憑證
|
|
40
|
+
* @returns 憑證解析器
|
|
41
|
+
*/
|
|
42
|
+
static fromConfig(credentials) {
|
|
43
|
+
return new CredentialsResolver(null, credentials, undefined);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 建立無憑證的解析器
|
|
47
|
+
* @returns 憑證解析器
|
|
48
|
+
*/
|
|
49
|
+
static empty() {
|
|
50
|
+
return new CredentialsResolver(null, null, undefined);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 解析憑證(套用優先級邏輯)
|
|
54
|
+
* @returns 解析結果
|
|
55
|
+
*/
|
|
56
|
+
resolve() {
|
|
57
|
+
// 優先使用檔案憑證
|
|
58
|
+
if (this.fileCredentials) {
|
|
59
|
+
return {
|
|
60
|
+
credentials: this.fileCredentials,
|
|
61
|
+
source: 'file',
|
|
62
|
+
resolved: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// 其次使用配置憑證
|
|
66
|
+
if (this.configCredentials) {
|
|
67
|
+
return {
|
|
68
|
+
credentials: this.configCredentials,
|
|
69
|
+
source: 'config',
|
|
70
|
+
resolved: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// 都沒有則回報錯誤
|
|
74
|
+
return {
|
|
75
|
+
source: 'none',
|
|
76
|
+
resolved: false,
|
|
77
|
+
errorMessage: 'No ACR credentials found. Please provide pull secret or configure default credentials.',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 是否有可用憑證
|
|
82
|
+
*/
|
|
83
|
+
get hasCredentials() {
|
|
84
|
+
return this.resolve().resolved;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 取得解析後的憑證
|
|
88
|
+
* @returns 憑證(如果有)
|
|
89
|
+
*/
|
|
90
|
+
get credentials() {
|
|
91
|
+
return this.resolve().credentials;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 取得憑證來源
|
|
95
|
+
*/
|
|
96
|
+
get source() {
|
|
97
|
+
return this.resolve().source;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 取得憑證來源描述
|
|
101
|
+
*/
|
|
102
|
+
get sourceDescription() {
|
|
103
|
+
const result = this.resolve();
|
|
104
|
+
switch (result.source) {
|
|
105
|
+
case 'file':
|
|
106
|
+
return `from file: ${this.pullSecretPath}`;
|
|
107
|
+
case 'config':
|
|
108
|
+
return 'from config';
|
|
109
|
+
case 'none':
|
|
110
|
+
return 'not found';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 解析憑證,若無則拋出錯誤
|
|
115
|
+
* @returns 憑證
|
|
116
|
+
* @throws Error 如果無可用憑證
|
|
117
|
+
*/
|
|
118
|
+
resolveOrThrow() {
|
|
119
|
+
const result = this.resolve();
|
|
120
|
+
if (!result.resolved) {
|
|
121
|
+
throw new Error(result.errorMessage);
|
|
122
|
+
}
|
|
123
|
+
return result.credentials;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.CredentialsResolver = CredentialsResolver;
|
|
127
|
+
//# sourceMappingURL=credentials-resolver.entity.js.map
|