@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,175 @@
|
|
|
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.SetupController = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const tokens_1 = require("../../di/tokens");
|
|
18
|
+
const setup_environment_use_case_1 = require("../../application/use-cases/setup/setup-environment.use-case");
|
|
19
|
+
const runtime_environment_port_1 = require("../../domain/ports/runtime-environment.port");
|
|
20
|
+
const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
|
|
21
|
+
/**
|
|
22
|
+
* Setup Controller
|
|
23
|
+
*
|
|
24
|
+
* 處理環境設定相關的 CLI 命令
|
|
25
|
+
*/
|
|
26
|
+
let SetupController = class SetupController {
|
|
27
|
+
constructor(setupUseCase, output, wslUpdater, runtimeEnvironment) {
|
|
28
|
+
this.setupUseCase = setupUseCase;
|
|
29
|
+
this.output = output;
|
|
30
|
+
this.wslUpdater = wslUpdater;
|
|
31
|
+
this.runtimeEnvironment = runtimeEnvironment;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 執行環境檢查
|
|
35
|
+
*/
|
|
36
|
+
async setup(_options) {
|
|
37
|
+
try {
|
|
38
|
+
this.output
|
|
39
|
+
.item('arrow', 'Checking system environment...')
|
|
40
|
+
.newline()
|
|
41
|
+
.flush();
|
|
42
|
+
const result = await this.setupUseCase.execute();
|
|
43
|
+
// 顯示作業系統資訊
|
|
44
|
+
this.output
|
|
45
|
+
.section('Checking Operating System')
|
|
46
|
+
.item('bullet', `Platform: ${result.osInfo.platform}`)
|
|
47
|
+
.item('bullet', `Version: ${result.osInfo.version}`)
|
|
48
|
+
.item('bullet', `Architecture: ${result.osInfo.arch}`)
|
|
49
|
+
.success('OS check passed')
|
|
50
|
+
.newline();
|
|
51
|
+
// 顯示執行環境資訊
|
|
52
|
+
this.output
|
|
53
|
+
.section('Checking Runtime Environment')
|
|
54
|
+
.item('bullet', `Type: ${result.runtimeInfo.type}`)
|
|
55
|
+
.item('bullet', `Version: ${result.runtimeInfo.version}`);
|
|
56
|
+
if (result.runtimeInfo.isInstalled) {
|
|
57
|
+
this.output.success('Runtime installed');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.output.error('Runtime not installed').newline().render();
|
|
61
|
+
// 詢問使用者是否要安裝 WSL
|
|
62
|
+
const shouldInstall = await this.wslUpdater.promptWslInstall(this.output);
|
|
63
|
+
if (shouldInstall) {
|
|
64
|
+
const { needsRestart } = await this.wslUpdater.installWsl('install', this.output);
|
|
65
|
+
if (needsRestart) {
|
|
66
|
+
this.output
|
|
67
|
+
.newline()
|
|
68
|
+
.info('Please restart your computer and run "uofx env setup" again.')
|
|
69
|
+
.render();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.output
|
|
73
|
+
.newline()
|
|
74
|
+
.success('WSL installation completed. You can now continue with setup.')
|
|
75
|
+
.info('Run "uofx env setup" again to verify the installation.')
|
|
76
|
+
.render();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.output.newline();
|
|
82
|
+
// 顯示記憶體資訊
|
|
83
|
+
const memoryInfo = await this.runtimeEnvironment.getMemoryAvailability();
|
|
84
|
+
this.output.section('Checking Remaining Memory');
|
|
85
|
+
for (const detail of memoryInfo.details) {
|
|
86
|
+
const suffix = detail.suffix ? ` (${detail.suffix})` : '';
|
|
87
|
+
this.output.item('bullet', `${detail.label}: ${detail.valueGB.toFixed(2)} GB${suffix}`);
|
|
88
|
+
}
|
|
89
|
+
const memoryOk = memoryInfo.availableGB >= runtime_environment_port_1.UOFX_REQUIRED_MEMORY_GB;
|
|
90
|
+
if (memoryOk) {
|
|
91
|
+
this.output.success('Memory sufficient for UOFX');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.output
|
|
95
|
+
.warning(`Available memory (${memoryInfo.availableGB.toFixed(2)} GB) is below recommended ${runtime_environment_port_1.UOFX_REQUIRED_MEMORY_GB} GB`)
|
|
96
|
+
.newline()
|
|
97
|
+
.info('Insufficient memory may cause:')
|
|
98
|
+
.item('bullet', 'Kubernetes pods failing to start')
|
|
99
|
+
.item('bullet', 'Services becoming unresponsive');
|
|
100
|
+
}
|
|
101
|
+
this.output.newline();
|
|
102
|
+
// 顯示其他系統資源
|
|
103
|
+
const totalMemoryGB = (result.systemResources.totalMemory / (1024 * 1024 * 1024)).toFixed(2);
|
|
104
|
+
this.output
|
|
105
|
+
.section('Checking System Resources')
|
|
106
|
+
.item('bullet', `Total system memory: ${totalMemoryGB} GB`)
|
|
107
|
+
.item('bullet', `CPU cores: ${result.systemResources.cpuCount}`)
|
|
108
|
+
.success('System resources check passed')
|
|
109
|
+
.newline();
|
|
110
|
+
// 顯示網路狀態
|
|
111
|
+
this.output
|
|
112
|
+
.section('Checking Network Status');
|
|
113
|
+
if (result.networkStatus.isOnline) {
|
|
114
|
+
this.output.success('Network connected');
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
this.output.error('Network disconnected');
|
|
118
|
+
}
|
|
119
|
+
if (result.networkStatus.canReachRegistry) {
|
|
120
|
+
this.output.success('Registry accessible');
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.output.error('Registry not accessible');
|
|
124
|
+
}
|
|
125
|
+
// 計算是否有警告
|
|
126
|
+
const hasWarnings = !memoryOk;
|
|
127
|
+
// 總結
|
|
128
|
+
this.output
|
|
129
|
+
.newline()
|
|
130
|
+
.divider();
|
|
131
|
+
if (result.allChecksPassed && !hasWarnings) {
|
|
132
|
+
// 全部通過,無警告
|
|
133
|
+
this.output
|
|
134
|
+
.newline()
|
|
135
|
+
.success('All checks passed. System meets requirements.')
|
|
136
|
+
.newline()
|
|
137
|
+
.info('You can now install a UOFX instance with:')
|
|
138
|
+
.item('bullet', 'uofx env install --name <instance-name>');
|
|
139
|
+
}
|
|
140
|
+
else if (result.allChecksPassed && hasWarnings) {
|
|
141
|
+
// 通過但有警告
|
|
142
|
+
this.output
|
|
143
|
+
.newline()
|
|
144
|
+
.warning('Checks passed with warnings. Review the warnings above before proceeding.')
|
|
145
|
+
.newline()
|
|
146
|
+
.info('You can still install a UOFX instance, but insufficient memory may cause pods to fail starting:')
|
|
147
|
+
.item('bullet', 'uofx env install --name <instance-name>');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// 有錯誤
|
|
151
|
+
this.output
|
|
152
|
+
.newline()
|
|
153
|
+
.error('Some checks failed. Please fix the issues above.')
|
|
154
|
+
.newline();
|
|
155
|
+
}
|
|
156
|
+
this.output.render();
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
this.output
|
|
160
|
+
.error(`Environment check failed: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
|
|
161
|
+
.render();
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
exports.SetupController = SetupController;
|
|
167
|
+
exports.SetupController = SetupController = __decorate([
|
|
168
|
+
(0, tsyringe_1.injectable)(),
|
|
169
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.SetupEnvironmentUseCase)),
|
|
170
|
+
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
|
|
171
|
+
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.WslUpdaterService)),
|
|
172
|
+
__param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.IRuntimeEnvironmentPort)),
|
|
173
|
+
__metadata("design:paramtypes", [setup_environment_use_case_1.SetupEnvironmentUseCase, Object, Object, Object])
|
|
174
|
+
], SetupController);
|
|
175
|
+
//# sourceMappingURL=setup.controller.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AcrCredentialsPrompt = void 0;
|
|
7
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const value_objects_1 = require("../../domain/value-objects");
|
|
10
|
+
/**
|
|
11
|
+
* ACR 憑證互動 Prompt
|
|
12
|
+
* 負責從使用者獲取 Azure Container Registry 憑證
|
|
13
|
+
*/
|
|
14
|
+
class AcrCredentialsPrompt {
|
|
15
|
+
/**
|
|
16
|
+
* 提示使用者輸入 ACR 憑證
|
|
17
|
+
*/
|
|
18
|
+
async prompt() {
|
|
19
|
+
console.log(chalk_1.default.cyan('\nℹ Azure Container Registry credentials required\n'));
|
|
20
|
+
try {
|
|
21
|
+
const response = await (0, prompts_1.default)([
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
name: 'name',
|
|
25
|
+
message: 'ACR Name:',
|
|
26
|
+
validate: (value) => value.trim().length > 0 || 'ACR name is required',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
name: 'account',
|
|
31
|
+
message: 'Account:',
|
|
32
|
+
validate: (value) => value.trim().length > 0 || 'Account is required',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'password',
|
|
36
|
+
name: 'password',
|
|
37
|
+
message: 'Password:',
|
|
38
|
+
validate: (value) => value.trim().length > 0 || 'Password is required',
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
// 如果使用者取消(Ctrl+C),prompts 會返回空物件
|
|
42
|
+
if (!response.name || !response.account || !response.password) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return value_objects_1.AcrCredentials.create(response.name.trim(), response.account.trim(), response.password.trim());
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// 使用者取消輸入
|
|
49
|
+
console.log(chalk_1.default.yellow('\nPrompt cancelled'));
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 確認是否使用預設憑證
|
|
55
|
+
*/
|
|
56
|
+
async confirmUseDefault(defaultCredentials) {
|
|
57
|
+
console.log(chalk_1.default.cyan('\nFound stored ACR credentials:'));
|
|
58
|
+
console.log(` ACR Name: ${chalk_1.default.white(defaultCredentials.name)}`);
|
|
59
|
+
console.log(` Account: ${chalk_1.default.white(defaultCredentials.account)}`);
|
|
60
|
+
console.log('');
|
|
61
|
+
try {
|
|
62
|
+
const response = await (0, prompts_1.default)({
|
|
63
|
+
type: 'confirm',
|
|
64
|
+
name: 'useDefault',
|
|
65
|
+
message: 'Use these credentials?',
|
|
66
|
+
initial: true,
|
|
67
|
+
});
|
|
68
|
+
return response.useDefault ?? false;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.AcrCredentialsPrompt = AcrCredentialsPrompt;
|
|
76
|
+
//# sourceMappingURL=acr-credentials.prompt.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Presentation Prompts
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./acr-credentials.prompt"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Progress Service
|
|
4
|
+
*
|
|
5
|
+
* 包裝 cli-progress 套件,提供統一的 Progress Bar(進度條)指示器
|
|
6
|
+
* 用於可預估進度的長時間操作
|
|
7
|
+
*/
|
|
8
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
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;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
};
|
|
14
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CliProgress = void 0;
|
|
22
|
+
const tsyringe_1 = require("tsyringe");
|
|
23
|
+
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
24
|
+
/**
|
|
25
|
+
* 進度條實例實作
|
|
26
|
+
* 包裝 cli-progress SingleBar 實例
|
|
27
|
+
*/
|
|
28
|
+
class ProgressBarInstance {
|
|
29
|
+
constructor(bar, total, message) {
|
|
30
|
+
this.bar = bar;
|
|
31
|
+
this.total = total;
|
|
32
|
+
this.currentMessage = message;
|
|
33
|
+
this.bar.start(total, 0, { message });
|
|
34
|
+
}
|
|
35
|
+
update(current) {
|
|
36
|
+
this.bar.update(current, { message: this.currentMessage });
|
|
37
|
+
}
|
|
38
|
+
increment(delta = 1) {
|
|
39
|
+
this.bar.increment(delta, { message: this.currentMessage });
|
|
40
|
+
}
|
|
41
|
+
setTotal(total) {
|
|
42
|
+
this.total = total;
|
|
43
|
+
this.bar.setTotal(total);
|
|
44
|
+
}
|
|
45
|
+
updateMessage(message) {
|
|
46
|
+
this.currentMessage = message;
|
|
47
|
+
this.bar.update({ message });
|
|
48
|
+
}
|
|
49
|
+
stop() {
|
|
50
|
+
this.bar.stop();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 格式化位元組大小
|
|
55
|
+
*/
|
|
56
|
+
function formatBytes(bytes) {
|
|
57
|
+
if (bytes === 0)
|
|
58
|
+
return '0 B';
|
|
59
|
+
const k = 1024;
|
|
60
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
61
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
62
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 格式化 ETA 時間
|
|
66
|
+
*/
|
|
67
|
+
function formatEta(seconds) {
|
|
68
|
+
if (!isFinite(seconds) || seconds < 0)
|
|
69
|
+
return '--:--';
|
|
70
|
+
const mins = Math.floor(seconds / 60);
|
|
71
|
+
const secs = Math.floor(seconds % 60);
|
|
72
|
+
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* CliProgress 實作
|
|
76
|
+
* 提供創建和管理進度條的功能
|
|
77
|
+
*/
|
|
78
|
+
let CliProgress = class CliProgress {
|
|
79
|
+
constructor() {
|
|
80
|
+
this.tty = process.stdout.isTTY ?? false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 創建並啟動一個新的進度條
|
|
84
|
+
*/
|
|
85
|
+
create(message, total, options) {
|
|
86
|
+
const barSize = options?.barSize ?? 40;
|
|
87
|
+
const barCompleteChar = options?.barCompleteChar ?? '█';
|
|
88
|
+
const barIncompleteChar = options?.barIncompleteChar ?? '░';
|
|
89
|
+
const showPercentage = options?.showPercentage ?? true;
|
|
90
|
+
const showValue = options?.showValue ?? true;
|
|
91
|
+
const showEta = options?.showEta ?? false;
|
|
92
|
+
const showSpeed = options?.showSpeed ?? false;
|
|
93
|
+
// 構建格式字串
|
|
94
|
+
let format = '{message} [{bar}]';
|
|
95
|
+
if (showPercentage) {
|
|
96
|
+
format += ' {percentage}%';
|
|
97
|
+
}
|
|
98
|
+
if (showValue) {
|
|
99
|
+
if (options?.formatValue) {
|
|
100
|
+
format += ' ({value})';
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
format += ' ({value}/{total})';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (showEta) {
|
|
107
|
+
format += ' ETA: {eta_formatted}';
|
|
108
|
+
}
|
|
109
|
+
if (showSpeed) {
|
|
110
|
+
format += ' {speed}';
|
|
111
|
+
}
|
|
112
|
+
const bar = new cli_progress_1.default.SingleBar({
|
|
113
|
+
format,
|
|
114
|
+
barCompleteChar,
|
|
115
|
+
barIncompleteChar,
|
|
116
|
+
barsize: barSize,
|
|
117
|
+
hideCursor: options?.hideCursor ?? true,
|
|
118
|
+
clearOnComplete: options?.clearOnComplete ?? false,
|
|
119
|
+
stopOnComplete: true,
|
|
120
|
+
forceRedraw: true,
|
|
121
|
+
etaBuffer: 10,
|
|
122
|
+
formatValue: (value, _opts, type) => {
|
|
123
|
+
// 處理自訂格式化
|
|
124
|
+
if (type === 'value' && options?.formatValue) {
|
|
125
|
+
return options.formatValue(value, total);
|
|
126
|
+
}
|
|
127
|
+
if (type === 'total' && options?.formatValue) {
|
|
128
|
+
return ''; // 自訂格式化已包含在 value 中
|
|
129
|
+
}
|
|
130
|
+
if (type === 'eta' && options?.formatEta) {
|
|
131
|
+
return options.formatEta(value);
|
|
132
|
+
}
|
|
133
|
+
return String(value);
|
|
134
|
+
},
|
|
135
|
+
}, cli_progress_1.default.Presets.shades_classic);
|
|
136
|
+
return new ProgressBarInstance(bar, total, message);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 創建一個下載進度條(預設顯示 bytes 格式和 ETA)
|
|
140
|
+
*/
|
|
141
|
+
createDownloadProgress(message, totalBytes) {
|
|
142
|
+
const format = `{message} [{bar}] {percentage}% ({value}) ETA: {eta_formatted}`;
|
|
143
|
+
const bar = new cli_progress_1.default.SingleBar({
|
|
144
|
+
format,
|
|
145
|
+
barCompleteChar: '█',
|
|
146
|
+
barIncompleteChar: '░',
|
|
147
|
+
barsize: 25,
|
|
148
|
+
hideCursor: true,
|
|
149
|
+
clearOnComplete: false,
|
|
150
|
+
stopOnComplete: true,
|
|
151
|
+
forceRedraw: true,
|
|
152
|
+
etaBuffer: 10,
|
|
153
|
+
formatValue: (value, _opts, type) => {
|
|
154
|
+
if (type === 'value') {
|
|
155
|
+
return `${formatBytes(value)} / ${formatBytes(totalBytes)}`;
|
|
156
|
+
}
|
|
157
|
+
return String(value);
|
|
158
|
+
},
|
|
159
|
+
formatTime: formatEta,
|
|
160
|
+
}, cli_progress_1.default.Presets.shades_classic);
|
|
161
|
+
return new ProgressBarInstance(bar, totalBytes, message);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 執行一個非同步操作並顯示進度條
|
|
165
|
+
*/
|
|
166
|
+
async withProgress(message, total, task, options) {
|
|
167
|
+
const bar = this.create(message, total, options);
|
|
168
|
+
const updateProgress = (current) => {
|
|
169
|
+
bar.update(current);
|
|
170
|
+
};
|
|
171
|
+
try {
|
|
172
|
+
const result = await task(updateProgress);
|
|
173
|
+
bar.stop();
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
bar.stop();
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 檢查環境是否支援進度條
|
|
183
|
+
*/
|
|
184
|
+
isSupported() {
|
|
185
|
+
return this.tty;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
exports.CliProgress = CliProgress;
|
|
189
|
+
exports.CliProgress = CliProgress = __decorate([
|
|
190
|
+
(0, tsyringe_1.injectable)(),
|
|
191
|
+
__metadata("design:paramtypes", [])
|
|
192
|
+
], CliProgress);
|
|
193
|
+
//# sourceMappingURL=cli-progress.service.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INDENT_CONFIG = exports.OUTPUT_SYMBOLS = void 0;
|
|
4
|
+
exports.getSymbolForItem = getSymbolForItem;
|
|
5
|
+
/**
|
|
6
|
+
* 統一的輸出符號定義
|
|
7
|
+
*
|
|
8
|
+
* 集中管理 CLI 輸出使用的符號,確保風格一致性
|
|
9
|
+
*/
|
|
10
|
+
exports.OUTPUT_SYMBOLS = {
|
|
11
|
+
// 狀態符號
|
|
12
|
+
SUCCESS: '\u2713', // ✓
|
|
13
|
+
ERROR: '\u2717', // ✗
|
|
14
|
+
WARNING: '!', // !
|
|
15
|
+
ARROW: '\u2192', // →
|
|
16
|
+
BULLET: '\u2022', // •
|
|
17
|
+
// 分隔符號
|
|
18
|
+
DIVIDER: '\u2500', // ─
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 縮排配置
|
|
22
|
+
*/
|
|
23
|
+
exports.INDENT_CONFIG = {
|
|
24
|
+
/** 每層縮排的字元 */
|
|
25
|
+
UNIT: ' ', // 2 個空格
|
|
26
|
+
/** 最大縮排層級 */
|
|
27
|
+
MAX_LEVEL: 5,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 根據項目類型取得對應符號
|
|
31
|
+
*/
|
|
32
|
+
function getSymbolForItem(type) {
|
|
33
|
+
const symbolMap = {
|
|
34
|
+
check: exports.OUTPUT_SYMBOLS.SUCCESS,
|
|
35
|
+
arrow: exports.OUTPUT_SYMBOLS.ARROW,
|
|
36
|
+
bullet: exports.OUTPUT_SYMBOLS.BULLET,
|
|
37
|
+
warning: exports.OUTPUT_SYMBOLS.WARNING,
|
|
38
|
+
error: exports.OUTPUT_SYMBOLS.ERROR,
|
|
39
|
+
};
|
|
40
|
+
return symbolMap[type];
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=output-symbols.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Presentation UI Services
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
// Enums
|
|
21
|
+
__exportStar(require("./log-level.enum"), exports);
|
|
22
|
+
// Services
|
|
23
|
+
__exportStar(require("./output-builder.service"), exports);
|
|
24
|
+
__exportStar(require("./cli-progress.service"), exports);
|
|
25
|
+
__exportStar(require("./output-formatter.service"), exports);
|
|
26
|
+
__exportStar(require("./interaction.service"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|