@uofx/cli 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -3
- package/THIRD-PARTY-NOTICES.txt +84 -2
- package/dist/application/dtos/config/index.js +22 -0
- package/dist/application/dtos/config/request/index.js +19 -0
- package/dist/application/dtos/config/request/set-config.request.dto.js +3 -0
- package/dist/application/dtos/config/response/get-config.response.dto.js +8 -0
- package/dist/application/dtos/config/response/index.js +21 -0
- package/dist/application/dtos/dev/index.js +24 -0
- package/dist/application/dtos/dev/request/generate-component.request.dto.js +3 -0
- package/dist/application/dtos/dev/request/index.js +25 -0
- package/dist/application/dtos/dev/request/install-template.request.dto.js +3 -0
- package/dist/application/dtos/dev/request/new-project.request.dto.js +3 -0
- package/dist/application/dtos/dev/request/publish-plugin.request.dto.js +3 -0
- package/dist/application/dtos/dev/request/uninstall-template.request.dto.js +3 -0
- package/dist/application/dtos/dev/response/generate-component.response.dto.js +3 -0
- package/dist/application/dtos/dev/response/index.js +24 -0
- package/dist/application/dtos/dev/response/new-project.response.dto.js +3 -0
- package/dist/application/dtos/dev/response/publish-plugin.response.dto.js +3 -0
- package/dist/application/dtos/dev/response/template-info.response.dto.js +3 -0
- package/dist/application/dtos/env/index.js +24 -0
- package/dist/application/dtos/{request → env/request}/index.js +1 -3
- package/dist/application/dtos/env/request/list-running-instances.request.dto.js +3 -0
- package/dist/application/dtos/{response → env/response}/index.js +1 -1
- package/dist/application/dtos/env/response/list-running-instances.response.dto.js +3 -0
- package/dist/application/dtos/index.js +9 -2
- package/dist/application/dtos/logs/index.js +22 -0
- package/dist/application/dtos/logs/request/index.js +18 -0
- package/dist/application/dtos/logs/response/index.js +18 -0
- package/dist/application/index.js +1 -0
- package/dist/application/services/env/environment-validator.service.js +120 -0
- package/dist/application/services/env/index.js +11 -0
- package/dist/application/services/env/instance-cleanup.service.js +79 -0
- package/dist/application/services/index.js +21 -0
- package/dist/application/use-cases/config/get-all-config.use-case.js +54 -0
- package/dist/application/use-cases/config/get-config.use-case.js +7 -17
- package/dist/application/use-cases/config/index.js +23 -0
- package/dist/application/use-cases/config/set-config.use-case.js +49 -3
- package/dist/application/use-cases/dev/generate-component.use-case.js +138 -0
- package/dist/application/use-cases/dev/index.js +28 -0
- package/dist/application/use-cases/dev/install-template.use-case.js +60 -0
- package/dist/application/use-cases/dev/list-templates.use-case.js +45 -0
- package/dist/application/use-cases/dev/new-project.use-case.js +130 -0
- package/dist/application/use-cases/dev/publish-plugin.use-case.js +243 -0
- package/dist/application/use-cases/dev/uninstall-template.use-case.js +50 -0
- package/dist/application/use-cases/{instance → env}/delete-instance.use-case.js +2 -2
- package/dist/application/use-cases/{credentials → env}/get-credentials.use-case.js +1 -1
- package/dist/application/use-cases/{instance → env}/index.js +11 -0
- package/dist/application/use-cases/{instance → env}/install-instance.use-case.js +25 -136
- package/dist/application/use-cases/env/list-running-instances.use-case.js +47 -0
- package/dist/application/use-cases/{setup → env}/setup-environment.use-case.js +35 -4
- package/dist/application/use-cases/{instance → env}/start-instance.use-case.js +53 -41
- package/dist/application/use-cases/index.js +9 -6
- package/dist/application/use-cases/logs/index.js +21 -0
- package/dist/cli.js +175 -26
- package/dist/constants/defaults.js +8 -1
- package/dist/constants/oci-artifacts.js +4 -0
- package/dist/constants/paths.js +0 -4
- package/dist/constants/timeouts.js +5 -0
- package/dist/di/modules/application.module.js +13 -44
- package/dist/di/modules/config.module.js +19 -0
- package/dist/di/modules/dev.module.js +45 -0
- package/dist/di/modules/env.module.js +42 -0
- package/dist/di/modules/index.js +30 -0
- package/dist/di/modules/infrastructure.module.js +65 -82
- package/dist/di/modules/logs.module.js +15 -0
- package/dist/di/modules/presentation.module.js +18 -7
- package/dist/di/tokens.js +42 -30
- package/dist/domain/entities/credentials-resolver.entity.js +4 -1
- package/dist/domain/entities/credentials.entity.js +2 -5
- package/dist/domain/entities/delete-instance-validation.entity.js +4 -1
- package/dist/domain/entities/deployment-parameters.entity.js +11 -8
- package/dist/domain/entities/index.js +5 -1
- package/dist/domain/entities/instance-list-aggregator.entity.js +2 -2
- package/dist/domain/entities/instance-metadata.entity.js +2 -3
- package/dist/domain/entities/instance.entity.js +2 -1
- package/dist/domain/entities/log-filter.entity.js +6 -6
- package/dist/domain/entities/template-info.entity.js +63 -0
- package/dist/{infrastructure/utils/error-formatter.util.js → domain/errors/error-utils.js} +1 -1
- package/dist/domain/errors/index.js +19 -0
- package/dist/domain/index.js +6 -0
- package/dist/domain/interfaces/index.js +21 -0
- package/dist/domain/ports/dotnet-publisher.port.js +9 -0
- package/dist/{infrastructure/http/interfaces/http-client.interface.js → domain/ports/file-system.port.js} +1 -1
- package/dist/domain/ports/http-client.port.js +3 -0
- package/dist/domain/ports/index.js +10 -0
- package/dist/domain/ports/logger.port.js +3 -3
- package/dist/domain/ports/progress.port.js +10 -0
- package/dist/domain/ports/project-scaffolder.port.js +9 -0
- package/dist/domain/ports/schematics-runner.port.js +9 -0
- package/dist/domain/ports/template-manager.port.js +9 -0
- package/dist/domain/ports/wsl-setup.port.js +3 -0
- package/dist/domain/types/index.js +1 -0
- package/dist/domain/value-objects/acr-credentials.value-object.js +13 -1
- package/dist/domain/value-objects/chart-version.value-object.js +20 -3
- package/dist/domain/value-objects/config-log-level.value-object.js +2 -1
- package/dist/domain/value-objects/index.js +3 -1
- package/dist/domain/value-objects/instance-name.value-object.js +6 -3
- package/dist/domain/value-objects/jwt-key.value-object.js +27 -5
- package/dist/domain/value-objects/mssql-password.value-object.js +27 -5
- package/dist/domain/value-objects/output-path.value-object.js +85 -0
- package/dist/domain/value-objects/rsa-key-pair.value-object.js +29 -3
- package/dist/index.js +6 -1
- package/dist/infrastructure/config/{app-config.service.js → app-config.adapter.js} +29 -17
- package/dist/infrastructure/config/{config-validator.js → config-validator.util.js} +1 -1
- package/dist/infrastructure/config/index.js +14 -0
- package/dist/infrastructure/config/interfaces/index.js +3 -0
- package/dist/infrastructure/config/{crypto.service.js → services/crypto.service.js} +4 -1
- package/dist/infrastructure/config/services/index.js +9 -0
- package/dist/infrastructure/deployment/deployment.adapter.js +5 -5
- package/dist/infrastructure/deployment/index.js +9 -0
- package/dist/infrastructure/deployment/interfaces/index.js +3 -0
- package/dist/infrastructure/deployment/services/acr-credential-manager.service.js +18 -7
- package/dist/infrastructure/deployment/services/app-manager.service.js +3 -3
- package/dist/infrastructure/deployment/services/base-helm-deployment.service.js +13 -5
- package/dist/infrastructure/deployment/services/helm-registry.service.js +10 -3
- package/dist/infrastructure/deployment/services/index.js +35 -0
- package/dist/infrastructure/deployment/services/infra-manager.service.js +19 -15
- package/dist/infrastructure/deployment/services/k8s-job-runner.service.js +24 -6
- package/dist/infrastructure/deployment/services/mssql-database-init.service.js +75 -11
- package/dist/infrastructure/deployment/services/mssql-helm-deployment.service.js +17 -5
- package/dist/infrastructure/deployment/services/mssql-storage.service.js +5 -1
- package/dist/infrastructure/deployment/services/mssql-user-manager.service.js +7 -3
- package/dist/infrastructure/deployment/services/oci-artifact.service.js +8 -3
- package/dist/infrastructure/deployment/services/secret-manager.service.js +14 -5
- package/dist/infrastructure/deployment/services/service-manager.service.js +1 -1
- package/dist/infrastructure/deployment/services/version-compatibility.service.js +9 -5
- package/dist/infrastructure/dotnet/dotnet-publisher.adapter.js +143 -0
- package/dist/infrastructure/dotnet/index.js +9 -0
- package/dist/infrastructure/environment/index.js +11 -0
- package/dist/infrastructure/environment/interfaces/index.js +3 -0
- package/dist/infrastructure/{platform-detector.js → environment/platform-detector.util.js} +1 -1
- package/dist/infrastructure/environment/services/hardware-info.service.js +8 -8
- package/dist/infrastructure/environment/services/index.js +11 -0
- package/dist/infrastructure/errors/{error-handler.js → error-handler.adapter.js} +17 -17
- package/dist/infrastructure/errors/index.js +5 -21
- package/dist/infrastructure/execution/builders/base-command.builder.js +32 -11
- package/dist/infrastructure/execution/builders/index.js +26 -0
- package/dist/infrastructure/execution/builders/wsl-command.builder.js +39 -1
- package/dist/infrastructure/execution/command-builder.util.js +94 -0
- package/dist/infrastructure/execution/environments/index.js +23 -0
- package/dist/infrastructure/execution/environments/wsl-execution.environment.js +22 -7
- package/dist/infrastructure/execution/index.js +1 -2
- package/dist/infrastructure/execution/services/command-executor.service.js +389 -0
- package/dist/infrastructure/execution/services/index.js +8 -0
- package/dist/infrastructure/execution/{script-executor.service.js → services/script-executor.service.js} +12 -15
- package/dist/infrastructure/filesystem/filesystem.adapter.js +86 -0
- package/dist/infrastructure/filesystem/index.js +23 -0
- package/dist/infrastructure/http/{http-client.service.js → http-client.adapter.js} +20 -13
- package/dist/infrastructure/http/index.js +1 -1
- package/dist/infrastructure/interceptors/decorators/index.js +23 -0
- package/dist/infrastructure/interceptors/index.js +2 -2
- package/dist/infrastructure/interceptors/interceptor.factory.js +3 -3
- package/dist/infrastructure/interceptors/interfaces/index.js +3 -0
- package/dist/infrastructure/interceptors/services/index.js +6 -0
- package/dist/infrastructure/interceptors/{logging.interceptor.js → services/logging-interceptor.service.js} +4 -4
- package/dist/infrastructure/logger/services/file-log-reader.repository.js +1 -1
- package/dist/infrastructure/logger/services/file-log-writer.repository.js +1 -1
- package/dist/infrastructure/persistence/instance-metadata.adapter.js +2 -1
- package/dist/infrastructure/persistence/services/file-system-config.repository.js +10 -4
- package/dist/infrastructure/persistence/services/file-system-instance.repository.js +2 -2
- package/dist/infrastructure/platforms/index.js +18 -0
- package/dist/infrastructure/platforms/windows/index.js +13 -0
- package/dist/infrastructure/platforms/windows/interfaces/index.js +3 -0
- package/dist/infrastructure/platforms/windows/parsers/index.js +9 -0
- package/dist/infrastructure/platforms/windows/services/index.js +33 -0
- package/dist/infrastructure/platforms/windows/services/microk8s.service.js +28 -10
- package/dist/infrastructure/platforms/windows/services/rootfs-manager.service.js +7 -3
- package/dist/infrastructure/platforms/windows/services/windows-features.service.js +22 -8
- package/dist/infrastructure/platforms/windows/services/windows-info.service.js +10 -6
- package/dist/infrastructure/platforms/windows/services/wsl-config.service.js +15 -6
- package/dist/infrastructure/platforms/windows/services/wsl-info.service.js +12 -12
- package/dist/infrastructure/platforms/windows/services/wsl-instance-inspection.service.js +3 -3
- package/dist/infrastructure/platforms/windows/services/wsl-instance-lifecycle.service.js +76 -22
- package/dist/infrastructure/platforms/windows/services/wsl-updater.service.js +20 -15
- package/dist/infrastructure/platforms/windows/services/wslconfig-parser.service.js +3 -3
- package/dist/infrastructure/platforms/windows/wsl-instance-manager.adapter.js +8 -3
- package/dist/infrastructure/platforms/windows/wsl-setup.adapter.js +100 -0
- package/dist/infrastructure/schematics/index.js +11 -0
- package/dist/infrastructure/schematics/project-scaffolder.adapter.js +314 -0
- package/dist/infrastructure/schematics/schematics-runner.adapter.js +175 -0
- package/dist/infrastructure/template/index.js +25 -0
- package/dist/infrastructure/template/interfaces/index.js +22 -0
- package/dist/infrastructure/template/interfaces/template-downloader.interface.js +6 -0
- package/dist/infrastructure/template/interfaces/template-registry.interface.js +6 -0
- package/dist/infrastructure/template/services/index.js +24 -0
- package/dist/infrastructure/template/services/template-downloader.service.js +319 -0
- package/dist/infrastructure/template/services/template-registry.service.js +175 -0
- package/dist/infrastructure/template/template-manager.adapter.js +196 -0
- package/dist/infrastructure/utils/index.js +23 -0
- package/dist/infrastructure/utils/input-validator.util.js +7 -6
- package/dist/presentation/controllers/base.controller.js +36 -0
- package/dist/presentation/controllers/{config.controller.js → config/config.controller.js} +17 -62
- package/dist/presentation/controllers/config/index.js +21 -0
- package/dist/presentation/controllers/dev/dev.controller.js +202 -0
- package/dist/presentation/controllers/dev/index.js +23 -0
- package/dist/presentation/controllers/dev/template.controller.js +158 -0
- package/dist/presentation/controllers/{credentials.controller.js → env/credentials.controller.js} +8 -14
- package/dist/presentation/controllers/env/index.js +23 -0
- package/dist/presentation/controllers/{instance.controller.js → env/instance.controller.js} +35 -92
- package/dist/presentation/controllers/{setup.controller.js → env/setup.controller.js} +33 -66
- package/dist/presentation/controllers/index.js +9 -5
- package/dist/presentation/controllers/logs/index.js +21 -0
- package/dist/presentation/controllers/{logs.controller.js → logs/logs.controller.js} +8 -14
- package/dist/presentation/interfaces/index.js +21 -0
- package/dist/presentation/prompts/acr-credentials.prompt.js +37 -9
- package/dist/presentation/ui/constants/index.js +23 -0
- package/dist/presentation/ui/interaction.service.js +4 -4
- package/dist/presentation/ui/interfaces/cli-progress.interface.js +0 -6
- package/dist/presentation/ui/interfaces/index.js +6 -0
- package/package.json +6 -1
- package/dist/application/dtos/request/set-config.request.dto.js +0 -16
- package/dist/infrastructure/errors/error-handler.interface.js +0 -3
- package/dist/infrastructure/execution/command-builder.js +0 -252
- package/dist/infrastructure/execution/command-executor.service.js +0 -230
- /package/dist/application/dtos/{request → config/request}/get-config.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/delete-instance.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/get-credentials.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/install-instance.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/list-charts.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/setup-environment.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/start-instance.request.dto.js +0 -0
- /package/dist/application/dtos/{request → env/request}/stop-instance.request.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/credentials.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/delete-instance.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/install-instance.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/instance-list.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/instance-status.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/setup-result.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/start-instance.response.dto.js +0 -0
- /package/dist/application/dtos/{response → env/response}/stop-instance.response.dto.js +0 -0
- /package/dist/application/dtos/{request → logs/request}/show-logs.request.dto.js +0 -0
- /package/dist/application/dtos/{response → logs/response}/show-logs.response.dto.js +0 -0
- /package/dist/application/use-cases/{instance → env}/list-charts.use-case.js +0 -0
- /package/dist/application/use-cases/{instance → env}/list-instances.use-case.js +0 -0
- /package/dist/application/use-cases/{instance → env}/stop-instance.use-case.js +0 -0
- /package/dist/{infrastructure → domain}/errors/app-error.js +0 -0
- /package/dist/{infrastructure → domain}/errors/exit-codes.js +0 -0
- /package/dist/infrastructure/config/{app-config.interface.js → interfaces/app-config.interface.js} +0 -0
- /package/dist/{domain → infrastructure/interceptors}/decorators/sensitive.decorator.js +0 -0
- /package/dist/infrastructure/interceptors/{interceptor.interface.js → interfaces/interceptor.interface.js} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Infrastructure 工具函式匯出
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./input-validator.util"), exports);
|
|
21
|
+
__exportStar(require("./retry.util"), exports);
|
|
22
|
+
__exportStar(require("./file-operations.util"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -9,6 +9,7 @@ exports.requireValidInstanceName = requireValidInstanceName;
|
|
|
9
9
|
exports.requireValidUsername = requireValidUsername;
|
|
10
10
|
exports.requireValidPath = requireValidPath;
|
|
11
11
|
const instance_name_value_object_1 = require("../../domain/value-objects/instance-name.value-object");
|
|
12
|
+
const errors_1 = require("../../domain/errors");
|
|
12
13
|
/**
|
|
13
14
|
* 輸入驗證工具
|
|
14
15
|
*
|
|
@@ -118,9 +119,9 @@ function validateCommandArg(arg) {
|
|
|
118
119
|
*/
|
|
119
120
|
function requireValidInstanceName(name) {
|
|
120
121
|
if (!validateInstanceName(name)) {
|
|
121
|
-
throw new
|
|
122
|
+
throw new errors_1.AppError(`Invalid instance name: '${name}'. ` +
|
|
122
123
|
`Instance name must be 1-50 characters, start and end with alphanumeric characters, ` +
|
|
123
|
-
`and contain only letters, numbers, and hyphens
|
|
124
|
+
`and contain only letters, numbers, and hyphens.`, { exitCode: errors_1.EXIT_CODES.VALIDATION_ERROR });
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
/**
|
|
@@ -131,10 +132,10 @@ function requireValidInstanceName(name) {
|
|
|
131
132
|
*/
|
|
132
133
|
function requireValidUsername(username) {
|
|
133
134
|
if (!validateUsername(username)) {
|
|
134
|
-
throw new
|
|
135
|
+
throw new errors_1.AppError(`Invalid username: '${username}'. ` +
|
|
135
136
|
`Username must start with a lowercase letter or underscore, ` +
|
|
136
137
|
`contain only lowercase letters, numbers, underscores, and hyphens, ` +
|
|
137
|
-
`and be at most 32 characters
|
|
138
|
+
`and be at most 32 characters.`, { exitCode: errors_1.EXIT_CODES.VALIDATION_ERROR });
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
/**
|
|
@@ -145,8 +146,8 @@ function requireValidUsername(username) {
|
|
|
145
146
|
*/
|
|
146
147
|
function requireValidPath(path) {
|
|
147
148
|
if (!validateLinuxPath(path)) {
|
|
148
|
-
throw new
|
|
149
|
-
`Path contains dangerous characters or is in an invalid format
|
|
149
|
+
throw new errors_1.AppError(`Invalid path: '${path}'. ` +
|
|
150
|
+
`Path contains dangerous characters or is in an invalid format.`, { exitCode: errors_1.EXIT_CODES.VALIDATION_ERROR });
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
//# sourceMappingURL=input-validator.util.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseController = void 0;
|
|
4
|
+
const errors_1 = require("../../domain/errors");
|
|
5
|
+
/**
|
|
6
|
+
* Controller 基底類別
|
|
7
|
+
*
|
|
8
|
+
* 提供統一的錯誤處理包裝,消除 Controller 中重複的 try/catch 模式
|
|
9
|
+
*/
|
|
10
|
+
class BaseController {
|
|
11
|
+
constructor(output) {
|
|
12
|
+
this.output = output;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 執行 controller action 的統一錯誤處理包裝
|
|
16
|
+
* @param errorPrefix - 錯誤訊息前綴(如 'Installation failed'、'Failed to list instances')
|
|
17
|
+
* @param action - 要執行的非同步操作
|
|
18
|
+
* @param onError - 可選的自訂錯誤處理回呼(用於需要額外 troubleshooting 資訊的場景)
|
|
19
|
+
*/
|
|
20
|
+
async executeAction(errorPrefix, action, onError) {
|
|
21
|
+
try {
|
|
22
|
+
await action();
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (onError) {
|
|
26
|
+
onError(error);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.output.error(`${errorPrefix}: ${(0, errors_1.formatErrorMessage)(error)}`).render();
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.BaseController = BaseController;
|
|
36
|
+
//# sourceMappingURL=base.controller.js.map
|
|
@@ -14,27 +14,26 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ConfigController = void 0;
|
|
16
16
|
const tsyringe_1 = require("tsyringe");
|
|
17
|
-
const tokens_1 = require("
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const error_formatter_util_1 = require("../../infrastructure/utils/error-formatter.util");
|
|
17
|
+
const tokens_1 = require("../../../di/tokens");
|
|
18
|
+
const use_cases_1 = require("../../../application/use-cases");
|
|
19
|
+
const base_controller_1 = require("../../controllers/base.controller");
|
|
21
20
|
/**
|
|
22
21
|
* Config Controller
|
|
23
22
|
*
|
|
24
23
|
* 處理設定相關的 CLI 命令
|
|
25
24
|
*/
|
|
26
|
-
let ConfigController = class ConfigController {
|
|
27
|
-
constructor(
|
|
28
|
-
|
|
25
|
+
let ConfigController = class ConfigController extends base_controller_1.BaseController {
|
|
26
|
+
constructor(getAllConfigUseCase, setConfigUseCase, output) {
|
|
27
|
+
super(output);
|
|
28
|
+
this.getAllConfigUseCase = getAllConfigUseCase;
|
|
29
29
|
this.setConfigUseCase = setConfigUseCase;
|
|
30
|
-
this.output = output;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* 列出所有配置
|
|
34
33
|
*/
|
|
35
|
-
async list(
|
|
36
|
-
|
|
37
|
-
const configs = await this.
|
|
34
|
+
async list() {
|
|
35
|
+
await this.executeAction('Failed to list configurations', async () => {
|
|
36
|
+
const configs = await this.getAllConfigUseCase.execute();
|
|
38
37
|
this.output
|
|
39
38
|
.newline()
|
|
40
39
|
.section('Current Configurations')
|
|
@@ -63,55 +62,17 @@ let ConfigController = class ConfigController {
|
|
|
63
62
|
.newline()
|
|
64
63
|
.divider()
|
|
65
64
|
.render();
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
this.output
|
|
69
|
-
.error(`Failed to list configurations: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
|
|
70
|
-
.render();
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
65
|
+
});
|
|
73
66
|
}
|
|
74
67
|
/**
|
|
75
68
|
* 設定配置值
|
|
76
69
|
*/
|
|
77
70
|
async set(options) {
|
|
78
|
-
|
|
79
|
-
// 驗證 log-level
|
|
80
|
-
if (options.logLevel) {
|
|
81
|
-
const validLevels = ['debug', 'info', 'error'];
|
|
82
|
-
if (!validLevels.includes(options.logLevel)) {
|
|
83
|
-
this.output
|
|
84
|
-
.error(`Invalid log level: ${options.logLevel}. Valid values: ${validLevels.join(', ')}`)
|
|
85
|
-
.render();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// 處理 ACR credentials
|
|
71
|
+
await this.executeAction('Failed to set configuration', async () => {
|
|
90
72
|
const acrName = options['acr.name'];
|
|
91
73
|
const acrAccount = options['acr.account'];
|
|
92
74
|
const acrPassword = options['acr.password'];
|
|
93
|
-
//
|
|
94
|
-
if ((acrName || acrAccount || acrPassword) && !(acrName && acrAccount && acrPassword)) {
|
|
95
|
-
this.output
|
|
96
|
-
.error('ACR credentials require all three: --acr.name, --acr.account, --acr.password')
|
|
97
|
-
.render();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// 檢查是否有任何配置變更
|
|
101
|
-
const hasChanges = options.logLevel || (acrName && acrAccount && acrPassword);
|
|
102
|
-
if (!hasChanges) {
|
|
103
|
-
this.output
|
|
104
|
-
.info('No configuration changes specified')
|
|
105
|
-
.newline()
|
|
106
|
-
.section('Available Options')
|
|
107
|
-
.item('bullet', '--log-level <level> Set log level (debug, info, error)')
|
|
108
|
-
.item('bullet', '--acr.name <name> Set ACR name')
|
|
109
|
-
.item('bullet', '--acr.account <account> Set ACR account')
|
|
110
|
-
.item('bullet', '--acr.password <pass> Set ACR password')
|
|
111
|
-
.render();
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// 使用統一的 execute 方法
|
|
75
|
+
// 委派給 Use Case 執行(包含驗證邏輯)
|
|
115
76
|
await this.setConfigUseCase.execute({
|
|
116
77
|
logLevel: options.logLevel,
|
|
117
78
|
acrName,
|
|
@@ -125,22 +86,16 @@ let ConfigController = class ConfigController {
|
|
|
125
86
|
this.output.success('Default ACR credentials set');
|
|
126
87
|
}
|
|
127
88
|
this.output.render();
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
this.output
|
|
131
|
-
.error(`Failed to set configuration: ${(0, error_formatter_util_1.formatErrorMessage)(error)}`)
|
|
132
|
-
.render();
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
89
|
+
});
|
|
135
90
|
}
|
|
136
91
|
};
|
|
137
92
|
exports.ConfigController = ConfigController;
|
|
138
93
|
exports.ConfigController = ConfigController = __decorate([
|
|
139
94
|
(0, tsyringe_1.injectable)(),
|
|
140
|
-
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.
|
|
95
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.GetAllConfigUseCase)),
|
|
141
96
|
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.SetConfigUseCase)),
|
|
142
97
|
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
|
|
143
|
-
__metadata("design:paramtypes", [
|
|
144
|
-
|
|
98
|
+
__metadata("design:paramtypes", [use_cases_1.GetAllConfigUseCase,
|
|
99
|
+
use_cases_1.SetConfigUseCase, Object])
|
|
145
100
|
], ConfigController);
|
|
146
101
|
//# sourceMappingURL=config.controller.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config 指令群組 Controllers
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./config.controller"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.DevController = void 0;
|
|
49
|
+
/**
|
|
50
|
+
* Dev Controller
|
|
51
|
+
*
|
|
52
|
+
* 處理 dev new / dev generate 相關的 CLI 命令
|
|
53
|
+
*/
|
|
54
|
+
const tsyringe_1 = require("tsyringe");
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
const tokens_1 = require("../../../di/tokens");
|
|
57
|
+
const defaults_1 = require("../../../constants/defaults");
|
|
58
|
+
const use_cases_1 = require("../../../application/use-cases");
|
|
59
|
+
const base_controller_1 = require("../../controllers/base.controller");
|
|
60
|
+
let DevController = class DevController extends base_controller_1.BaseController {
|
|
61
|
+
constructor(newProjectUseCase, generateComponentUseCase, publishPluginUseCase, output, interaction) {
|
|
62
|
+
super(output);
|
|
63
|
+
this.newProjectUseCase = newProjectUseCase;
|
|
64
|
+
this.generateComponentUseCase = generateComponentUseCase;
|
|
65
|
+
this.publishPluginUseCase = publishPluginUseCase;
|
|
66
|
+
this.interaction = interaction;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 建立新專案
|
|
70
|
+
* @param options - 建立選項
|
|
71
|
+
*/
|
|
72
|
+
async newProject(options) {
|
|
73
|
+
await this.executeAction('Failed to create project', async () => {
|
|
74
|
+
const targetPath = options.output || process.cwd();
|
|
75
|
+
this.output
|
|
76
|
+
.info(`Creating new project in: ${targetPath}`)
|
|
77
|
+
.newline()
|
|
78
|
+
.flush();
|
|
79
|
+
const result = await this.newProjectUseCase.execute({
|
|
80
|
+
template: options.template,
|
|
81
|
+
output: options.output,
|
|
82
|
+
skipInstall: options.skipInstall,
|
|
83
|
+
force: options.force,
|
|
84
|
+
}, this.output);
|
|
85
|
+
if (result.success) {
|
|
86
|
+
const projectPath = result.projectPath;
|
|
87
|
+
this.output
|
|
88
|
+
.newline()
|
|
89
|
+
.divider()
|
|
90
|
+
.section('Project Created')
|
|
91
|
+
.divider()
|
|
92
|
+
.newline()
|
|
93
|
+
.item('bullet', `Path: ${projectPath}`);
|
|
94
|
+
if (!result.npmInstallFailed) {
|
|
95
|
+
this.output
|
|
96
|
+
.newline()
|
|
97
|
+
.divider()
|
|
98
|
+
.newline()
|
|
99
|
+
.info('Next steps:');
|
|
100
|
+
const clientAppDir = result.clientAppDirs?.[0];
|
|
101
|
+
const cdTarget = clientAppDir || path.join(projectPath, defaults_1.PROJECT_DEFAULTS.CLIENT_APP_DIR);
|
|
102
|
+
this.output.item('bullet', `cd ${cdTarget}`);
|
|
103
|
+
this.output
|
|
104
|
+
.item('bullet', 'uofx dev component generate --type field --name <field-name>');
|
|
105
|
+
}
|
|
106
|
+
this.output.render();
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.output.render();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 產生元件
|
|
115
|
+
* @param type - 元件類型
|
|
116
|
+
* @param name - 元件名稱
|
|
117
|
+
* @param options - 產生選項
|
|
118
|
+
*/
|
|
119
|
+
async generate(type, name, options) {
|
|
120
|
+
await this.executeAction('Failed to generate component', async () => {
|
|
121
|
+
const baseRequest = {
|
|
122
|
+
type,
|
|
123
|
+
name,
|
|
124
|
+
code: options.code,
|
|
125
|
+
group: options.group,
|
|
126
|
+
displayName: options.displayName,
|
|
127
|
+
pageType: options.layout,
|
|
128
|
+
funcId: options.funcId,
|
|
129
|
+
design: options.design,
|
|
130
|
+
print: options.print,
|
|
131
|
+
view: options.view,
|
|
132
|
+
};
|
|
133
|
+
if (options.force) {
|
|
134
|
+
// --force:直接執行
|
|
135
|
+
const result = await this.generateComponentUseCase.execute({ ...baseRequest, dryRun: false }, this.output);
|
|
136
|
+
if (!result.success) {
|
|
137
|
+
this.output.render();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// 預設模式:dry-run 預覽 → 確認 → 實際執行
|
|
142
|
+
const previewResult = await this.generateComponentUseCase.execute({ ...baseRequest, dryRun: true }, this.output);
|
|
143
|
+
if (!previewResult.success) {
|
|
144
|
+
this.output.render();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.output.newline().render();
|
|
148
|
+
const confirmed = await this.interaction.confirm('Confirm generating the above files?');
|
|
149
|
+
if (!confirmed) {
|
|
150
|
+
this.output.warning('Generation cancelled.').render();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.output.newline().render();
|
|
154
|
+
const result = await this.generateComponentUseCase.execute({ ...baseRequest, dryRun: false }, this.output);
|
|
155
|
+
if (!result.success) {
|
|
156
|
+
this.output.render();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 發布 Plugin
|
|
163
|
+
* @param options - 發布選項
|
|
164
|
+
*/
|
|
165
|
+
async publish(options) {
|
|
166
|
+
await this.executeAction('Failed to publish plugin', async () => {
|
|
167
|
+
this.output
|
|
168
|
+
.info(`Publishing plugin: ${options.serviceName} v${options.serviceVersion}`)
|
|
169
|
+
.newline()
|
|
170
|
+
.flush();
|
|
171
|
+
const result = await this.publishPluginUseCase.execute({
|
|
172
|
+
serviceVersion: options.serviceVersion,
|
|
173
|
+
minUofxVersion: options.minUofxVersion,
|
|
174
|
+
serviceName: options.serviceName,
|
|
175
|
+
output: options.output,
|
|
176
|
+
force: options.force,
|
|
177
|
+
}, this.output);
|
|
178
|
+
if (result.success) {
|
|
179
|
+
this.output
|
|
180
|
+
.newline()
|
|
181
|
+
.success('Plugin published successfully!')
|
|
182
|
+
.render();
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.output.render();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
exports.DevController = DevController;
|
|
191
|
+
exports.DevController = DevController = __decorate([
|
|
192
|
+
(0, tsyringe_1.injectable)(),
|
|
193
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.NewProjectUseCase)),
|
|
194
|
+
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.GenerateComponentUseCase)),
|
|
195
|
+
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.PublishPluginUseCase)),
|
|
196
|
+
__param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
|
|
197
|
+
__param(4, (0, tsyringe_1.inject)(tokens_1.TOKENS.IUserInteractionPort)),
|
|
198
|
+
__metadata("design:paramtypes", [use_cases_1.NewProjectUseCase,
|
|
199
|
+
use_cases_1.GenerateComponentUseCase,
|
|
200
|
+
use_cases_1.PublishPluginUseCase, Object, Object])
|
|
201
|
+
], DevController);
|
|
202
|
+
//# sourceMappingURL=dev.controller.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Dev Controllers
|
|
19
|
+
*
|
|
20
|
+
* 開發工具相關的控制器
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./template.controller"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.TemplateController = void 0;
|
|
49
|
+
const os = __importStar(require("os"));
|
|
50
|
+
const tsyringe_1 = require("tsyringe");
|
|
51
|
+
const tokens_1 = require("../../../di/tokens");
|
|
52
|
+
const use_cases_1 = require("../../../application/use-cases");
|
|
53
|
+
const base_controller_1 = require("../../controllers/base.controller");
|
|
54
|
+
/**
|
|
55
|
+
* Template Controller
|
|
56
|
+
*
|
|
57
|
+
* 處理樣板管理相關的 CLI 命令
|
|
58
|
+
*/
|
|
59
|
+
let TemplateController = class TemplateController extends base_controller_1.BaseController {
|
|
60
|
+
constructor(installTemplateUseCase, listTemplatesUseCase, uninstallTemplateUseCase, output) {
|
|
61
|
+
super(output);
|
|
62
|
+
this.installTemplateUseCase = installTemplateUseCase;
|
|
63
|
+
this.listTemplatesUseCase = listTemplatesUseCase;
|
|
64
|
+
this.uninstallTemplateUseCase = uninstallTemplateUseCase;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 安裝樣板
|
|
68
|
+
*/
|
|
69
|
+
async install(options) {
|
|
70
|
+
await this.executeAction('Failed to install template', async () => {
|
|
71
|
+
this.output.info('Installing template...').newline().render();
|
|
72
|
+
const result = await this.installTemplateUseCase.execute({
|
|
73
|
+
url: options.url,
|
|
74
|
+
name: options.name,
|
|
75
|
+
withSample: options.sample ?? true,
|
|
76
|
+
}, this.output);
|
|
77
|
+
const homeDir = os.homedir();
|
|
78
|
+
if (result.success && result.template) {
|
|
79
|
+
this.output
|
|
80
|
+
.newline()
|
|
81
|
+
.divider()
|
|
82
|
+
.section('Template Information')
|
|
83
|
+
.divider()
|
|
84
|
+
.newline()
|
|
85
|
+
.item('bullet', `Name: ${result.template.name}`)
|
|
86
|
+
.item('bullet', `Version: ${result.template.version}`)
|
|
87
|
+
.item('bullet', `Path: ${result.template.path.replace(homeDir, '~')}`)
|
|
88
|
+
.newline()
|
|
89
|
+
.divider()
|
|
90
|
+
.newline()
|
|
91
|
+
.success('Template installed successfully!')
|
|
92
|
+
.newline()
|
|
93
|
+
.info('To create a new project, run:')
|
|
94
|
+
.item('bullet', 'uofx dev project generate --template <template-name>')
|
|
95
|
+
.render();
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.output.error(result.message).render();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 列出已安裝的樣板
|
|
104
|
+
*/
|
|
105
|
+
async list() {
|
|
106
|
+
await this.executeAction('Failed to list templates', async () => {
|
|
107
|
+
const result = await this.listTemplatesUseCase.execute();
|
|
108
|
+
const homeDir = os.homedir();
|
|
109
|
+
if (result.templates.length === 0) {
|
|
110
|
+
this.output
|
|
111
|
+
.newline()
|
|
112
|
+
.info('No templates installed.')
|
|
113
|
+
.newline()
|
|
114
|
+
.item('bullet', 'Run "uofx dev template install" to install templates.')
|
|
115
|
+
.render();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.output
|
|
119
|
+
.newline()
|
|
120
|
+
.section('Installed Templates')
|
|
121
|
+
.table(['NAME', 'TAG', 'PATH', 'INSTALLED'], result.templates.map((t) => [
|
|
122
|
+
t.name,
|
|
123
|
+
t.version,
|
|
124
|
+
t.path.replace(homeDir, '~'),
|
|
125
|
+
t.installedAt.toLocaleDateString(),
|
|
126
|
+
]))
|
|
127
|
+
.newline()
|
|
128
|
+
.info(`Total: ${result.templates.length} template(s) installed`)
|
|
129
|
+
.render();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 移除樣板
|
|
134
|
+
*/
|
|
135
|
+
async uninstall(name) {
|
|
136
|
+
await this.executeAction('Failed to uninstall template', async () => {
|
|
137
|
+
const result = await this.uninstallTemplateUseCase.execute({ name });
|
|
138
|
+
if (result.success) {
|
|
139
|
+
this.output.success(result.message).render();
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.output.error(result.message).render();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
exports.TemplateController = TemplateController;
|
|
148
|
+
exports.TemplateController = TemplateController = __decorate([
|
|
149
|
+
(0, tsyringe_1.injectable)(),
|
|
150
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.InstallTemplateUseCase)),
|
|
151
|
+
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.ListTemplatesUseCase)),
|
|
152
|
+
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.UninstallTemplateUseCase)),
|
|
153
|
+
__param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
|
|
154
|
+
__metadata("design:paramtypes", [use_cases_1.InstallTemplateUseCase,
|
|
155
|
+
use_cases_1.ListTemplatesUseCase,
|
|
156
|
+
use_cases_1.UninstallTemplateUseCase, Object])
|
|
157
|
+
], TemplateController);
|
|
158
|
+
//# sourceMappingURL=template.controller.js.map
|