@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
|
@@ -1,22 +1,42 @@
|
|
|
1
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
|
+
};
|
|
2
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
16
|
};
|
|
5
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
18
|
exports.AcrCredentialsPrompt = void 0;
|
|
19
|
+
const tsyringe_1 = require("tsyringe");
|
|
7
20
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
|
-
const
|
|
21
|
+
const tokens_1 = require("../../di/tokens");
|
|
9
22
|
const value_objects_1 = require("../../domain/value-objects");
|
|
10
23
|
/**
|
|
11
24
|
* ACR 憑證互動 Prompt
|
|
12
25
|
* 負責從使用者獲取 Azure Container Registry 憑證
|
|
13
26
|
*/
|
|
14
|
-
class AcrCredentialsPrompt {
|
|
27
|
+
let AcrCredentialsPrompt = class AcrCredentialsPrompt {
|
|
28
|
+
constructor(output) {
|
|
29
|
+
this.output = output;
|
|
30
|
+
}
|
|
15
31
|
/**
|
|
16
32
|
* 提示使用者輸入 ACR 憑證
|
|
17
33
|
*/
|
|
18
34
|
async prompt() {
|
|
19
|
-
|
|
35
|
+
this.output
|
|
36
|
+
.newline()
|
|
37
|
+
.info('Azure Container Registry credentials required')
|
|
38
|
+
.newline()
|
|
39
|
+
.flush();
|
|
20
40
|
try {
|
|
21
41
|
const response = await (0, prompts_1.default)([
|
|
22
42
|
{
|
|
@@ -46,7 +66,7 @@ class AcrCredentialsPrompt {
|
|
|
46
66
|
}
|
|
47
67
|
catch (error) {
|
|
48
68
|
// 使用者取消輸入
|
|
49
|
-
|
|
69
|
+
this.output.newline().warning('Prompt cancelled').flush();
|
|
50
70
|
return null;
|
|
51
71
|
}
|
|
52
72
|
}
|
|
@@ -54,10 +74,13 @@ class AcrCredentialsPrompt {
|
|
|
54
74
|
* 確認是否使用預設憑證
|
|
55
75
|
*/
|
|
56
76
|
async confirmUseDefault(defaultCredentials) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
this.output
|
|
78
|
+
.newline()
|
|
79
|
+
.info('Found stored ACR credentials:')
|
|
80
|
+
.item('bullet', `ACR Name: ${defaultCredentials.name}`)
|
|
81
|
+
.item('bullet', `Account: ${defaultCredentials.account}`)
|
|
82
|
+
.newline()
|
|
83
|
+
.flush();
|
|
61
84
|
try {
|
|
62
85
|
const response = await (0, prompts_1.default)({
|
|
63
86
|
type: 'confirm',
|
|
@@ -71,6 +94,11 @@ class AcrCredentialsPrompt {
|
|
|
71
94
|
return false;
|
|
72
95
|
}
|
|
73
96
|
}
|
|
74
|
-
}
|
|
97
|
+
};
|
|
75
98
|
exports.AcrCredentialsPrompt = AcrCredentialsPrompt;
|
|
99
|
+
exports.AcrCredentialsPrompt = AcrCredentialsPrompt = __decorate([
|
|
100
|
+
(0, tsyringe_1.injectable)(),
|
|
101
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.IOutputPort)),
|
|
102
|
+
__metadata("design:paramtypes", [Object])
|
|
103
|
+
], AcrCredentialsPrompt);
|
|
76
104
|
//# sourceMappingURL=acr-credentials.prompt.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
|
+
* UI 常數模組
|
|
19
|
+
*
|
|
20
|
+
* 匯出 CLI 輸出使用的符號、縮排配置等常數定義
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./output-symbols"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -76,7 +76,7 @@ class SimpleProgressIndicator {
|
|
|
76
76
|
}
|
|
77
77
|
render() {
|
|
78
78
|
if (!process.stdout.isTTY) {
|
|
79
|
-
|
|
79
|
+
process.stdout.write(`${this.prefix}${this.currentMessage}\n`);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
const spinner = this.useSpinner
|
|
@@ -235,7 +235,7 @@ let UserInteraction = class UserInteraction {
|
|
|
235
235
|
}
|
|
236
236
|
// 如果密碼不匹配
|
|
237
237
|
if (response.value !== confirmResponse.value) {
|
|
238
|
-
|
|
238
|
+
process.stderr.write('Passwords do not match\n');
|
|
239
239
|
return undefined;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -251,13 +251,13 @@ let UserInteraction = class UserInteraction {
|
|
|
251
251
|
* 顯示一般訊息
|
|
252
252
|
*/
|
|
253
253
|
log(message) {
|
|
254
|
-
|
|
254
|
+
process.stdout.write(message + '\n');
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
257
|
* 顯示空白行
|
|
258
258
|
*/
|
|
259
259
|
newLine() {
|
|
260
|
-
|
|
260
|
+
process.stdout.write('\n');
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
263
|
* 清除當前行
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_STATUS_COLORS = void 0;
|
|
4
|
+
var output_formatter_interface_1 = require("./output-formatter.interface");
|
|
5
|
+
Object.defineProperty(exports, "DEFAULT_STATUS_COLORS", { enumerable: true, get: function () { return output_formatter_interface_1.DEFAULT_STATUS_COLORS; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uofx/cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CLI tool for installing and managing the UOFX development environment on WSL",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,12 +28,15 @@
|
|
|
28
28
|
"dist",
|
|
29
29
|
"!dist/**/*.map",
|
|
30
30
|
"!dist/**/*.ts",
|
|
31
|
+
"templates",
|
|
31
32
|
"README.md",
|
|
32
33
|
"LICENSE",
|
|
33
34
|
"THIRD-PARTY-NOTICES.txt"
|
|
34
35
|
],
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@types/adm-zip": "^0.5.7",
|
|
36
38
|
"@types/cli-progress": "^3.11.6",
|
|
39
|
+
"@types/cross-spawn": "^6.0.6",
|
|
37
40
|
"@types/jest": "^29.5.0",
|
|
38
41
|
"@types/node": "^18.19.0",
|
|
39
42
|
"@types/prompts": "^2.4.9",
|
|
@@ -53,10 +56,12 @@
|
|
|
53
56
|
"typescript": "^5.9.3"
|
|
54
57
|
},
|
|
55
58
|
"dependencies": {
|
|
59
|
+
"adm-zip": "^0.5.16",
|
|
56
60
|
"axios": "^1.13.2",
|
|
57
61
|
"chalk": "^4.1.2",
|
|
58
62
|
"cli-progress": "^3.12.0",
|
|
59
63
|
"commander": "^12.1.0",
|
|
64
|
+
"cross-spawn": "^7.0.6",
|
|
60
65
|
"prompts": "^2.4.2",
|
|
61
66
|
"reflect-metadata": "^0.2.2",
|
|
62
67
|
"semver": "^7.7.3",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetConfigRequestDto = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Set Config Request DTO
|
|
6
|
-
*/
|
|
7
|
-
class SetConfigRequestDto {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.logLevel = options.logLevel;
|
|
10
|
-
this.acrName = options.acrName;
|
|
11
|
-
this.acrAccount = options.acrAccount;
|
|
12
|
-
this.acrPassword = options.acrPassword;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.SetConfigRequestDto = SetConfigRequestDto;
|
|
16
|
-
//# sourceMappingURL=set-config.request.dto.js.map
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBuilder = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 命令建構器 - 支援安全的命令建構與執行
|
|
6
|
-
*
|
|
7
|
-
* 特性:
|
|
8
|
-
* - 自動區分安全參數與敏感參數
|
|
9
|
-
* - 生成兩個版本: 實際執行命令 & 安全記錄命令
|
|
10
|
-
* - Fluent API 設計
|
|
11
|
-
*
|
|
12
|
-
* 注意:此類別用於非 DI 場景(如環境檢查服務)。
|
|
13
|
-
* 對於 WSL 實例內的命令執行,請使用 IExecutionEnvironmentFactory。
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // 基本使用
|
|
17
|
-
* const result = await CommandBuilder
|
|
18
|
-
* .create('wsl')
|
|
19
|
-
* .arg('--list')
|
|
20
|
-
* .arg('--verbose')
|
|
21
|
-
* .exec(commandExecutor);
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* // PowerShell 命令
|
|
25
|
-
* const result = await CommandBuilder
|
|
26
|
-
* .create('powershell')
|
|
27
|
-
* .arg('-NoProfile')
|
|
28
|
-
* .arg('-Command')
|
|
29
|
-
* .arg('Get-Process')
|
|
30
|
-
* .exec(commandExecutor);
|
|
31
|
-
*/
|
|
32
|
-
class CommandBuilder {
|
|
33
|
-
constructor() {
|
|
34
|
-
this.executable = '';
|
|
35
|
-
this.commandArgs = [];
|
|
36
|
-
this.isSensitiveInput = false;
|
|
37
|
-
this._inheritStdio = false;
|
|
38
|
-
}
|
|
39
|
-
// ========== 工廠方法 (Factory Methods) ==========
|
|
40
|
-
/**
|
|
41
|
-
* 建立一般命令
|
|
42
|
-
* @param executable 可執行檔名稱或路徑
|
|
43
|
-
* @returns CommandBuilder 實例
|
|
44
|
-
* @example CommandBuilder.create('wsl').arg('--list').arg('--verbose')
|
|
45
|
-
*/
|
|
46
|
-
static create(executable) {
|
|
47
|
-
const builder = new CommandBuilder();
|
|
48
|
-
builder.executable = executable;
|
|
49
|
-
return builder;
|
|
50
|
-
}
|
|
51
|
-
// ========== 命令輔助方法 (Command Helper Methods) ==========
|
|
52
|
-
/**
|
|
53
|
-
* PowerShell 命令 (Windows 專用)
|
|
54
|
-
* @param command PowerShell 命令字串
|
|
55
|
-
* @returns this (支援方法鏈)
|
|
56
|
-
* @example CommandBuilder.create('powershell').powershell('Get-Process')
|
|
57
|
-
*/
|
|
58
|
-
powershell(command) {
|
|
59
|
-
this.executable = 'powershell';
|
|
60
|
-
this.arg('-NoProfile');
|
|
61
|
-
this.arg('-NoLogo');
|
|
62
|
-
this.arg('-Command');
|
|
63
|
-
this.arg(command);
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* WSL 管理命令 (不包裝實例)
|
|
68
|
-
* @param subcommand WSL 子命令
|
|
69
|
-
* @returns this (支援方法鏈)
|
|
70
|
-
* @example CommandBuilder.create('wsl.exe').wslCmd('--list').arg('--verbose')
|
|
71
|
-
*/
|
|
72
|
-
wslCmd(subcommand) {
|
|
73
|
-
// 使用 wsl.exe 而非 wsl,因為當 WSL 未安裝時 wsl 只是 stub
|
|
74
|
-
this.executable = 'wsl.exe';
|
|
75
|
-
this.arg(subcommand);
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
// ========== 參數方法 (Argument Methods) ==========
|
|
79
|
-
/**
|
|
80
|
-
* 新增一般參數 (安全,會被記錄)
|
|
81
|
-
* @param flag 參數名稱或值
|
|
82
|
-
* @param value 參數值 (可選)
|
|
83
|
-
* @returns this (支援方法鏈)
|
|
84
|
-
* @example .arg('--wait')
|
|
85
|
-
* @example .arg('--namespace', 'mssql')
|
|
86
|
-
*/
|
|
87
|
-
arg(flag, value) {
|
|
88
|
-
if (value !== undefined) {
|
|
89
|
-
this.commandArgs.push({ type: 'safe', flag, value });
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
this.commandArgs.push({ type: 'safe', value: flag });
|
|
93
|
-
}
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 新增敏感參數 (會被遮罩)
|
|
98
|
-
* @param flag 參數名稱
|
|
99
|
-
* @param value 參數值 (含敏感資料)
|
|
100
|
-
* @returns this (支援方法鏈)
|
|
101
|
-
* @example .sensitiveArg('--set', `sa_password='${password}'`)
|
|
102
|
-
* @example .sensitiveArg('-P', password)
|
|
103
|
-
*/
|
|
104
|
-
sensitiveArg(flag, value) {
|
|
105
|
-
this.commandArgs.push({ type: 'sensitive', flag, value });
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* 新增條件參數
|
|
110
|
-
* @param condition 條件判斷
|
|
111
|
-
* @param flag 參數名稱
|
|
112
|
-
* @param value 參數值 (可選)
|
|
113
|
-
* @returns this (支援方法鏈)
|
|
114
|
-
* @example .argIf(enableDebug, '--debug')
|
|
115
|
-
*/
|
|
116
|
-
argIf(condition, flag, value) {
|
|
117
|
-
if (condition) {
|
|
118
|
-
this.arg(flag, value);
|
|
119
|
-
}
|
|
120
|
-
return this;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* 新增多個參數
|
|
124
|
-
* @param values 參數值陣列
|
|
125
|
-
* @returns this (支援方法鏈)
|
|
126
|
-
* @example .args('--wait', '--timeout', '300s')
|
|
127
|
-
*/
|
|
128
|
-
args(...values) {
|
|
129
|
-
values.forEach(v => this.arg(v));
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
// ========== 標準輸入方法 (Stdin Methods) ==========
|
|
133
|
-
/**
|
|
134
|
-
* 透過 stdin 傳入一般資料
|
|
135
|
-
* @param input stdin 輸入內容
|
|
136
|
-
* @returns this (支援方法鏈)
|
|
137
|
-
* @example .stdin(jsonContent)
|
|
138
|
-
*/
|
|
139
|
-
stdin(input) {
|
|
140
|
-
this.stdinInput = input;
|
|
141
|
-
this.isSensitiveInput = false;
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 透過 stdin 傳入敏感資料 (如密碼、keys)
|
|
146
|
-
* @param input stdin 輸入內容 (含敏感資料)
|
|
147
|
-
* @returns this (支援方法鏈)
|
|
148
|
-
* @example .sensitiveStdin(password)
|
|
149
|
-
*/
|
|
150
|
-
sensitiveStdin(input) {
|
|
151
|
-
this.stdinInput = input;
|
|
152
|
-
this.isSensitiveInput = true;
|
|
153
|
-
return this;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* 設定直接繼承終端的 stdio
|
|
157
|
-
* 用於需要終端訪問的命令(如 WSL 安裝)
|
|
158
|
-
* @returns this (支援方法鏈)
|
|
159
|
-
*/
|
|
160
|
-
inheritStdio() {
|
|
161
|
-
this._inheritStdio = true;
|
|
162
|
-
return this;
|
|
163
|
-
}
|
|
164
|
-
// ========== 建構方法 (Build Methods) ==========
|
|
165
|
-
/**
|
|
166
|
-
* 建構實際執行的命令字串
|
|
167
|
-
* @returns 完整命令字串 (含敏感資料)
|
|
168
|
-
*/
|
|
169
|
-
buildActual() {
|
|
170
|
-
return this.buildCommand(false);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* 建構用於記錄的安全命令字串 (敏感參數已遮罩)
|
|
174
|
-
* @returns 安全命令字串 (敏感資料已遮罩為 ***REDACTED***)
|
|
175
|
-
*/
|
|
176
|
-
buildSafe() {
|
|
177
|
-
let cmd = this.buildCommand(true);
|
|
178
|
-
if (this.isSensitiveInput) {
|
|
179
|
-
cmd += ' < [STDIN: ***REDACTED***]';
|
|
180
|
-
}
|
|
181
|
-
return cmd;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 內部方法:建構命令字串
|
|
185
|
-
* @param maskSensitive 是否遮罩敏感參數
|
|
186
|
-
* @returns 命令字串
|
|
187
|
-
*/
|
|
188
|
-
buildCommand(maskSensitive) {
|
|
189
|
-
const parts = [this.executable];
|
|
190
|
-
for (const arg of this.commandArgs) {
|
|
191
|
-
if (arg.type === 'sensitive' && maskSensitive) {
|
|
192
|
-
// 遮罩敏感參數
|
|
193
|
-
if (arg.flag) {
|
|
194
|
-
parts.push(`${arg.flag} ***REDACTED***`);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
parts.push('***REDACTED***');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
// 正常輸出
|
|
202
|
-
if (arg.flag && arg.value !== undefined) {
|
|
203
|
-
parts.push(`${arg.flag} ${arg.value}`);
|
|
204
|
-
}
|
|
205
|
-
else if (arg.value !== undefined) {
|
|
206
|
-
parts.push(arg.value);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return parts.join(' ');
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* 取得 CommandExecutor 的執行選項
|
|
214
|
-
* @returns 包含 command, options, safeCommand 的物件
|
|
215
|
-
*/
|
|
216
|
-
getExecutionOptions() {
|
|
217
|
-
return {
|
|
218
|
-
command: this.buildActual(),
|
|
219
|
-
options: {
|
|
220
|
-
shell: true,
|
|
221
|
-
...(this.stdinInput && { input: this.stdinInput }),
|
|
222
|
-
...(this._inheritStdio && { inheritStdio: true }),
|
|
223
|
-
},
|
|
224
|
-
safeCommand: this.buildSafe(),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
// ========== 執行方法 (Execute Methods) ==========
|
|
228
|
-
/**
|
|
229
|
-
* 執行命令 (同步)
|
|
230
|
-
* @param executor CommandExecutor 實例
|
|
231
|
-
* @param showOutput 是否顯示輸出
|
|
232
|
-
* @param suppressStderr 是否隱藏 stderr
|
|
233
|
-
* @returns 命令執行結果
|
|
234
|
-
*/
|
|
235
|
-
execSync(executor, showOutput = false, suppressStderr = false) {
|
|
236
|
-
const { command, options, safeCommand } = this.getExecutionOptions();
|
|
237
|
-
return executor.execSync(command, options, showOutput, suppressStderr, safeCommand);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* 執行命令 (異步)
|
|
241
|
-
* @param executor CommandExecutor 實例
|
|
242
|
-
* @param onStdout stdout 回調函式
|
|
243
|
-
* @param onStderr stderr 回調函式
|
|
244
|
-
* @returns Promise<命令執行結果>
|
|
245
|
-
*/
|
|
246
|
-
async exec(executor, onStdout, onStderr) {
|
|
247
|
-
const { command, options, safeCommand } = this.getExecutionOptions();
|
|
248
|
-
return executor.exec(command, onStdout, onStderr, options, safeCommand);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.CommandBuilder = CommandBuilder;
|
|
252
|
-
//# sourceMappingURL=command-builder.js.map
|