trm-client 6.1.0 → 7.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.
Files changed (182) hide show
  1. package/changelog.txt +18 -0
  2. package/dist/command/AbstractCommand.d.ts +42 -0
  3. package/dist/command/AbstractCommand.js +418 -0
  4. package/dist/command/InquirerType.d.ts +3 -0
  5. package/dist/command/InquirerType.js +7 -0
  6. package/dist/{utils/executeCommand.d.ts → command/LoggerType.d.ts} +0 -4
  7. package/dist/command/LoggerType.js +11 -0
  8. package/dist/{utils/registerCommand.d.ts → command/RegisterCommandOpts.d.ts} +4 -3
  9. package/dist/command/implementations/Alias.d.ts +8 -0
  10. package/dist/command/implementations/Alias.js +172 -0
  11. package/dist/command/implementations/Compare.d.ts +7 -0
  12. package/dist/command/implementations/Compare.js +133 -0
  13. package/dist/command/implementations/Content.d.ts +5 -0
  14. package/dist/command/implementations/Content.js +195 -0
  15. package/dist/command/implementations/Deprecate.d.ts +5 -0
  16. package/dist/command/implementations/Deprecate.js +33 -0
  17. package/dist/command/implementations/DistTag.d.ts +5 -0
  18. package/dist/command/implementations/DistTag.js +48 -0
  19. package/dist/command/implementations/FindDependencies.d.ts +5 -0
  20. package/dist/command/implementations/FindDependencies.js +42 -0
  21. package/dist/command/implementations/Info.d.ts +11 -0
  22. package/dist/command/implementations/Info.js +245 -0
  23. package/dist/command/implementations/Install.d.ts +13 -0
  24. package/dist/command/implementations/Install.js +201 -0
  25. package/dist/command/implementations/List.d.ts +5 -0
  26. package/dist/command/implementations/List.js +116 -0
  27. package/dist/command/implementations/Lock.d.ts +5 -0
  28. package/dist/command/implementations/Lock.js +40 -0
  29. package/dist/command/implementations/Login.d.ts +5 -0
  30. package/dist/command/implementations/Login.js +66 -0
  31. package/dist/command/implementations/Logout.d.ts +5 -0
  32. package/dist/command/implementations/Logout.js +37 -0
  33. package/dist/command/implementations/Ping.d.ts +5 -0
  34. package/dist/{commands/findDependencies.js → command/implementations/Ping.js} +15 -16
  35. package/dist/command/implementations/Publish.d.ts +6 -0
  36. package/dist/command/implementations/Publish.js +145 -0
  37. package/dist/command/implementations/Registry.d.ts +5 -0
  38. package/dist/command/implementations/Registry.js +88 -0
  39. package/dist/command/implementations/Settings.d.ts +5 -0
  40. package/dist/command/implementations/Settings.js +42 -0
  41. package/dist/command/implementations/Unpublish.d.ts +5 -0
  42. package/dist/command/implementations/Unpublish.js +34 -0
  43. package/dist/command/implementations/View.d.ts +9 -0
  44. package/dist/command/implementations/View.js +237 -0
  45. package/dist/command/implementations/WhoAmI.d.ts +5 -0
  46. package/dist/command/implementations/WhoAmI.js +36 -0
  47. package/dist/command/implementations/index.d.ts +19 -0
  48. package/dist/command/implementations/index.js +35 -0
  49. package/dist/command/index.d.ts +4 -0
  50. package/dist/{commands/commons → command}/index.js +4 -2
  51. package/dist/{commands/arguments/ConnectArguments.d.ts → command/prompts/connect.d.ts} +2 -0
  52. package/dist/{commands → command}/prompts/connect.js +3 -3
  53. package/dist/command/prompts/createAlias.d.ts +1 -0
  54. package/dist/{commands → command/prompts}/createAlias.js +8 -8
  55. package/dist/command/prompts/deleteAlias.d.ts +1 -0
  56. package/dist/{commands → command/prompts}/deleteAlias.js +3 -4
  57. package/dist/command/prompts/index.d.ts +4 -0
  58. package/dist/{commands → command}/prompts/index.js +2 -0
  59. package/dist/index.js +30 -274
  60. package/dist/registryAlias/RegistryAlias.js +1 -1
  61. package/dist/systemAlias/SystemAlias.js +5 -5
  62. package/dist/utils/{Context.d.ts → GlobalContext.d.ts} +3 -3
  63. package/dist/utils/{Context.js → GlobalContext.js} +6 -6
  64. package/dist/utils/checkCliUpdate.d.ts +3 -2
  65. package/dist/utils/checkCliUpdate.js +3 -3
  66. package/dist/utils/getSapLogonConnections.js +3 -3
  67. package/dist/utils/index.d.ts +1 -4
  68. package/dist/utils/index.js +1 -4
  69. package/package.json +5 -3
  70. package/dist/commands/addRegistry.d.ts +0 -2
  71. package/dist/commands/addRegistry.js +0 -66
  72. package/dist/commands/alias.d.ts +0 -2
  73. package/dist/commands/alias.js +0 -156
  74. package/dist/commands/arguments/AddRegistryArguments.d.ts +0 -5
  75. package/dist/commands/arguments/AliasArguments.d.ts +0 -3
  76. package/dist/commands/arguments/AliasArguments.js +0 -2
  77. package/dist/commands/arguments/CheckArguments.d.ts +0 -4
  78. package/dist/commands/arguments/CheckArguments.js +0 -2
  79. package/dist/commands/arguments/CompareArguments.d.ts +0 -4
  80. package/dist/commands/arguments/CompareArguments.js +0 -2
  81. package/dist/commands/arguments/ConnectArguments.js +0 -2
  82. package/dist/commands/arguments/ContentArguments.d.ts +0 -6
  83. package/dist/commands/arguments/ContentArguments.js +0 -2
  84. package/dist/commands/arguments/CreateAliasArguments.d.ts +0 -3
  85. package/dist/commands/arguments/CreateAliasArguments.js +0 -2
  86. package/dist/commands/arguments/DeleteAliasArguments.d.ts +0 -3
  87. package/dist/commands/arguments/DeleteAliasArguments.js +0 -2
  88. package/dist/commands/arguments/FindDependenciesArguments.d.ts +0 -5
  89. package/dist/commands/arguments/FindDependenciesArguments.js +0 -2
  90. package/dist/commands/arguments/ImportArguments.d.ts +0 -19
  91. package/dist/commands/arguments/ImportArguments.js +0 -2
  92. package/dist/commands/arguments/InfoArguments.d.ts +0 -1
  93. package/dist/commands/arguments/InfoArguments.js +0 -2
  94. package/dist/commands/arguments/InstallArguments.d.ts +0 -20
  95. package/dist/commands/arguments/InstallArguments.js +0 -2
  96. package/dist/commands/arguments/ListArguments.d.ts +0 -3
  97. package/dist/commands/arguments/ListArguments.js +0 -2
  98. package/dist/commands/arguments/LockArguments.d.ts +0 -4
  99. package/dist/commands/arguments/LockArguments.js +0 -2
  100. package/dist/commands/arguments/LoginArguments.d.ts +0 -4
  101. package/dist/commands/arguments/LoginArguments.js +0 -2
  102. package/dist/commands/arguments/LogoutArguments.d.ts +0 -1
  103. package/dist/commands/arguments/LogoutArguments.js +0 -2
  104. package/dist/commands/arguments/PackArguments.d.ts +0 -22
  105. package/dist/commands/arguments/PackArguments.js +0 -2
  106. package/dist/commands/arguments/PingArguments.d.ts +0 -1
  107. package/dist/commands/arguments/PingArguments.js +0 -2
  108. package/dist/commands/arguments/PublishArguments.d.ts +0 -24
  109. package/dist/commands/arguments/PublishArguments.js +0 -2
  110. package/dist/commands/arguments/RemoveRegistryArguments.d.ts +0 -4
  111. package/dist/commands/arguments/RemoveRegistryArguments.js +0 -2
  112. package/dist/commands/arguments/SettingsArgument.d.ts +0 -3
  113. package/dist/commands/arguments/SettingsArgument.js +0 -2
  114. package/dist/commands/arguments/UnpublishArguments.d.ts +0 -4
  115. package/dist/commands/arguments/UnpublishArguments.js +0 -2
  116. package/dist/commands/arguments/UpdateArguments.d.ts +0 -2
  117. package/dist/commands/arguments/UpdateArguments.js +0 -2
  118. package/dist/commands/arguments/ViewArguments.d.ts +0 -3
  119. package/dist/commands/arguments/ViewArguments.js +0 -2
  120. package/dist/commands/arguments/WhoAmIArguments.d.ts +0 -1
  121. package/dist/commands/arguments/WhoAmIArguments.js +0 -2
  122. package/dist/commands/arguments/index.d.ts +0 -24
  123. package/dist/commands/arguments/index.js +0 -40
  124. package/dist/commands/check.d.ts +0 -2
  125. package/dist/commands/check.js +0 -87
  126. package/dist/commands/commons/CommandContext.d.ts +0 -9
  127. package/dist/commands/commons/CommandContext.js +0 -41
  128. package/dist/commands/commons/index.d.ts +0 -2
  129. package/dist/commands/commons/viewRegistryPackage.d.ts +0 -2
  130. package/dist/commands/commons/viewRegistryPackage.js +0 -48
  131. package/dist/commands/compare.d.ts +0 -2
  132. package/dist/commands/compare.js +0 -167
  133. package/dist/commands/content.d.ts +0 -2
  134. package/dist/commands/content.js +0 -182
  135. package/dist/commands/createAlias.d.ts +0 -2
  136. package/dist/commands/deleteAlias.d.ts +0 -2
  137. package/dist/commands/findDependencies.d.ts +0 -2
  138. package/dist/commands/import.d.ts +0 -2
  139. package/dist/commands/import.js +0 -84
  140. package/dist/commands/index.d.ts +0 -27
  141. package/dist/commands/index.js +0 -43
  142. package/dist/commands/info.d.ts +0 -2
  143. package/dist/commands/info.js +0 -233
  144. package/dist/commands/install.d.ts +0 -2
  145. package/dist/commands/install.js +0 -85
  146. package/dist/commands/list.d.ts +0 -2
  147. package/dist/commands/list.js +0 -70
  148. package/dist/commands/lock.d.ts +0 -2
  149. package/dist/commands/lock.js +0 -64
  150. package/dist/commands/login.d.ts +0 -2
  151. package/dist/commands/login.js +0 -59
  152. package/dist/commands/logout.d.ts +0 -2
  153. package/dist/commands/logout.js +0 -27
  154. package/dist/commands/pack.d.ts +0 -2
  155. package/dist/commands/pack.js +0 -95
  156. package/dist/commands/ping.d.ts +0 -2
  157. package/dist/commands/ping.js +0 -21
  158. package/dist/commands/prompts/connect.d.ts +0 -3
  159. package/dist/commands/prompts/index.d.ts +0 -2
  160. package/dist/commands/publish.d.ts +0 -2
  161. package/dist/commands/publish.js +0 -128
  162. package/dist/commands/removeRegistry.d.ts +0 -2
  163. package/dist/commands/removeRegistry.js +0 -36
  164. package/dist/commands/selfUpdate.d.ts +0 -1
  165. package/dist/commands/selfUpdate.js +0 -77
  166. package/dist/commands/settings.d.ts +0 -2
  167. package/dist/commands/settings.js +0 -32
  168. package/dist/commands/unpublish.d.ts +0 -2
  169. package/dist/commands/unpublish.js +0 -61
  170. package/dist/commands/update.d.ts +0 -2
  171. package/dist/commands/update.js +0 -20
  172. package/dist/commands/view.d.ts +0 -2
  173. package/dist/commands/view.js +0 -219
  174. package/dist/commands/whoami.d.ts +0 -2
  175. package/dist/commands/whoami.js +0 -34
  176. package/dist/utils/checkTrmDependencies.d.ts +0 -1
  177. package/dist/utils/checkTrmDependencies.js +0 -43
  178. package/dist/utils/executeCommand.js +0 -213
  179. package/dist/utils/registerCommand.js +0 -93
  180. /package/dist/{commands/arguments/AddRegistryArguments.js → command/RegisterCommandOpts.js} +0 -0
  181. /package/dist/{commands → command}/prompts/pickRegistry.d.ts +0 -0
  182. /package/dist/{commands → command}/prompts/pickRegistry.js +0 -0
package/changelog.txt CHANGED
@@ -8,6 +8,24 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2025-11-07 v7.0.0
12
+ -------------------
13
+ ! trm-core ^8.1.3
14
+ ! command handler
15
+ ! commands arguments
16
+ + deprecate command
17
+ ! createAlias/deleteAlias -> alias create/alias delete
18
+ ! addRegistry/removeRegistry -> registry add/registry rm
19
+
20
+ 2025-11-04 v6.2.0
21
+ -------------------
22
+ ! trm-core ^8.1.1
23
+ + dist-tag commands
24
+
25
+ 2025-10-29 v6.1.1
26
+ -------------------
27
+ * fallback to this._data for backward compatibility
28
+
11
29
  2025-10-26 v6.1.0
12
30
  -------------------
13
31
  + lock command
@@ -0,0 +1,42 @@
1
+ import { Command } from "commander";
2
+ import { RegisterCommandOpts } from "./RegisterCommandOpts";
3
+ import { CliVersionStatus } from "../utils";
4
+ import * as Core from "trm-core";
5
+ import { Package } from "trm-registry-types";
6
+ export declare abstract class AbstractCommand {
7
+ protected readonly name: string;
8
+ protected readonly aliases?: string[];
9
+ protected command: Command;
10
+ protected registerOpts: RegisterCommandOpts;
11
+ protected args: any;
12
+ private cliVersionStatus;
13
+ private registry;
14
+ private registryAuthData;
15
+ private registryAuthFailed;
16
+ private systemPackages;
17
+ private trmDependenciesCheck;
18
+ constructor(program: Command, name: string, aliases?: string[]);
19
+ getCliVersionStatus(): Promise<CliVersionStatus>;
20
+ getRegistry(): Core.AbstractRegistry;
21
+ hasRegistryAuthData(): boolean;
22
+ getRegistryAuthError(): Error;
23
+ registryWhoAmI(): Promise<void>;
24
+ viewRegistryPackage(packageName: string, print?: boolean): Promise<Package>;
25
+ getSystemPackages(): Promise<Core.TrmPackage[]>;
26
+ getTrmDependenciesCheck(): Promise<Core.CheckTrmDependencies>;
27
+ protected abstract init(): void;
28
+ protected abstract handler(): Promise<void>;
29
+ register(): void;
30
+ private getLogger;
31
+ private getInquirer;
32
+ private parseCommandArgs;
33
+ protected onArgs(): void;
34
+ protected onTrmDepMissing(dependency: string): boolean;
35
+ protected onTrmDepVersionNotSatisfied(trmPackage: Core.TrmPackage): boolean;
36
+ private checkTrmDependencies;
37
+ parseTextArg(name: string): string;
38
+ parseJsonArg(name: string): any;
39
+ parseArrayArg(name: string): string[];
40
+ parseNumberArg(name: string): number;
41
+ private execute;
42
+ }
@@ -0,0 +1,418 @@
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 __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.AbstractCommand = void 0;
49
+ const utils_1 = require("../utils");
50
+ const LoggerType_1 = require("./LoggerType");
51
+ const InquirerType_1 = require("./InquirerType");
52
+ const Core = __importStar(require("trm-core"));
53
+ const Commons = __importStar(require("trm-commons"));
54
+ const registryAlias_1 = require("../registryAlias");
55
+ const systemAlias_1 = require("../systemAlias");
56
+ const chalk_1 = __importDefault(require("chalk"));
57
+ const prompts_1 = require("./prompts");
58
+ const fs_1 = require("fs");
59
+ class AbstractCommand {
60
+ constructor(program, name, aliases) {
61
+ this.name = name;
62
+ this.aliases = aliases;
63
+ this.registerOpts = {};
64
+ this.args = {};
65
+ this.registryAuthData = false;
66
+ this.command = program.command(this.name);
67
+ if (aliases) {
68
+ this.command.aliases(aliases);
69
+ }
70
+ this.init();
71
+ }
72
+ getCliVersionStatus() {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ if (!this.cliVersionStatus) {
75
+ this.cliVersionStatus = yield (0, utils_1.checkCliUpdate)(true);
76
+ }
77
+ return this.cliVersionStatus;
78
+ });
79
+ }
80
+ getRegistry() {
81
+ return this.registry;
82
+ }
83
+ hasRegistryAuthData() {
84
+ return this.registryAuthData;
85
+ }
86
+ getRegistryAuthError() {
87
+ return this.registryAuthFailed;
88
+ }
89
+ registryWhoAmI() {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const registry = this.getRegistry();
92
+ if (registry) {
93
+ Commons.Logger.loading(`Authenticating...`);
94
+ const whoAmI = yield registry.whoAmI();
95
+ Commons.Logger.info(`Username: ${whoAmI.user}`);
96
+ if (whoAmI.messages) {
97
+ whoAmI.messages.forEach(m => Commons.Logger.registryResponse(m));
98
+ }
99
+ }
100
+ });
101
+ }
102
+ viewRegistryPackage(packageName_1) {
103
+ return __awaiter(this, arguments, void 0, function* (packageName, print = true) {
104
+ Commons.Logger.loading(`Reading registry...`);
105
+ var oRegistryView;
106
+ try {
107
+ oRegistryView = yield this.getRegistry().getPackage(packageName, 'latest');
108
+ }
109
+ catch (e) {
110
+ Commons.Logger.error(e, true);
111
+ oRegistryView = null;
112
+ }
113
+ if (print) {
114
+ if (!oRegistryView) {
115
+ Commons.Logger.warning(`${chalk_1.default.bold('WARNING')}: This package was not found on the registry.`);
116
+ Commons.Logger.warning(`${chalk_1.default.bold('WARNING')}: This package may have been deleted!`);
117
+ }
118
+ else {
119
+ if (oRegistryView.deprecated) {
120
+ if (oRegistryView.deprecated_message) {
121
+ Commons.Logger.warning(`${chalk_1.default.bold('WARNING deprecate')}: ${oRegistryView.deprecated_message}`);
122
+ }
123
+ else {
124
+ Commons.Logger.warning(`${chalk_1.default.bold('WARNING deprecate')}: v${oRegistryView.manifest.version} is deprecated`);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return oRegistryView;
130
+ });
131
+ }
132
+ getSystemPackages() {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ if (!this.systemPackages) {
135
+ Commons.Logger.loading(`Reading "${Core.SystemConnector.getDest()}" packages...`);
136
+ this.systemPackages = yield Core.SystemConnector.getInstalledPackages(true, true, true);
137
+ }
138
+ return this.systemPackages;
139
+ });
140
+ }
141
+ getTrmDependenciesCheck() {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ if (!this.trmDependenciesCheck) {
144
+ const packages = yield this.getSystemPackages();
145
+ this.trmDependenciesCheck = yield Core.checkCoreTrmDependencies(packages);
146
+ }
147
+ return this.trmDependenciesCheck;
148
+ });
149
+ }
150
+ register() {
151
+ const defaultLogger = utils_1.GlobalContext.getInstance().getSettings().loggerType;
152
+ const logOutputFolder = utils_1.GlobalContext.getInstance().getSettings().logOutputFolder;
153
+ this.command
154
+ .option(`--logger <logger type>`, `Logger type.`, defaultLogger)
155
+ .option(`--logger-out-dir <logger out dir>`, `Logger output directory.`, logOutputFolder)
156
+ .option(`--debug`, `Debug.`, false);
157
+ if (this.registerOpts.requiresConnection) {
158
+ this.command
159
+ .option(`-d, --dest <destination>`, `RFC System ID (Destination).`)
160
+ .option(`-u, --user <username>`, `Logon username.`)
161
+ .option(`-p, --password <password>`, `Logon password.`)
162
+ .option(`-m, --mandt <mandt>`, `Logon client.`)
163
+ .option(`-l, --lang <language>`, `Logon language.`)
164
+ .option(`-h, --application-server <address>`, `RFC Application server address.`)
165
+ .option(`-r, --sap-router <sap router>`, `RFC SAP Router.`)
166
+ .option(`-n, --sys-nr <sysnr>`, `Instance number.`)
167
+ .option(`-e, --endpoint <endpoint>`, `REST endpoint.`)
168
+ .option(`-x, --forward-rfc-dest [destination]`, `REST forward destination.`, `NONE`);
169
+ if (!this.registerOpts.noSystemAlias) {
170
+ this.command
171
+ .option(`-a, --alias <alias>`, `System Alias.`);
172
+ }
173
+ }
174
+ if (this.registerOpts.requiresRegistry) {
175
+ this.command
176
+ .option(`-R, --registry <registry>`, `Registry.`);
177
+ if (!this.registerOpts.onlyRegistryAlias) {
178
+ this.command
179
+ .option(`-E, --registry-endpoint <endpoint>`, `Registry endpoint.`)
180
+ .option(`-A, --registry-auth <authentication>`, `Registry authentication (JSON or path to JSON file).`);
181
+ }
182
+ }
183
+ if (this.registerOpts.requiresR3trans) {
184
+ this.command
185
+ .option(`--r3trans-path <path>`, `R3trans program path. (default: Environment variable R3TRANS_HOME)`);
186
+ }
187
+ this.command.action(this.execute.bind(this));
188
+ }
189
+ getLogger(type, debug, logOutputFolder) {
190
+ if (!logOutputFolder || logOutputFolder.trim().toLowerCase() === 'default') {
191
+ logOutputFolder = (0, utils_1.getLogFolder)();
192
+ }
193
+ switch (type) {
194
+ case LoggerType_1.LoggerType.CLI: return new Commons.CliLogger(debug);
195
+ case LoggerType_1.LoggerType.CLI_LOG: return new Commons.CliLogFileLogger(logOutputFolder, debug);
196
+ case LoggerType_1.LoggerType.CONSOLE: return new Commons.ConsoleLogger(debug);
197
+ case LoggerType_1.LoggerType.VOID: return new Commons.DummyLogger();
198
+ default: throw new Error(`Unknown logger type "${type}". Possible values are ${Object.keys(LoggerType_1.LoggerType).map(k => LoggerType_1.LoggerType[k]).join(', ')}.`);
199
+ }
200
+ }
201
+ getInquirer(type) {
202
+ switch (type) {
203
+ case InquirerType_1.InquirerType.CLI: return new Commons.CliInquirer();
204
+ default: throw new Error(`Unknown inquirer type "${type}". Possible values are ${Object.keys(InquirerType_1.InquirerType).map(k => InquirerType_1.InquirerType[k]).join(', ')}.`);
205
+ }
206
+ }
207
+ parseCommandArgs(args1, args2) {
208
+ var args = this.command['_optionValues'] || {};
209
+ if (!args1) {
210
+ args1 = {};
211
+ }
212
+ if (!args2) {
213
+ args2 = {};
214
+ }
215
+ if (typeof (args1) === 'string') {
216
+ const oArg1 = this.command["_args"][0];
217
+ args[oArg1.name()] = args1;
218
+ if (typeof (args2) === 'string') {
219
+ const oArg2 = this.command["_args"][1];
220
+ args[oArg2.name()] = args2;
221
+ }
222
+ else {
223
+ args = Object.assign(Object.assign({}, args), args2);
224
+ }
225
+ }
226
+ else {
227
+ args = Object.assign(Object.assign({}, args), args1);
228
+ }
229
+ args = Object.entries(args).reduce((acc, [key, value]) => {
230
+ const newKey = key.includes(" ") ? key.replace(/ (\w)/g, (_, char) => char.toUpperCase()) : key;
231
+ acc[newKey] = value;
232
+ return acc;
233
+ }, {});
234
+ return args;
235
+ }
236
+ onArgs() {
237
+ }
238
+ onTrmDepMissing(dependency) {
239
+ return true;
240
+ }
241
+ onTrmDepVersionNotSatisfied(trmPackage) {
242
+ return true;
243
+ }
244
+ checkTrmDependencies() {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ const trmDependenciesCheck = yield this.getTrmDependenciesCheck();
247
+ const trmDependencies = Core.getCoreTrmDependencies();
248
+ trmDependenciesCheck.missingDependencies.forEach(missingDependency => {
249
+ if (this.onTrmDepMissing(missingDependency)) {
250
+ throw new Error(`Package "${missingDependency}" is not installed on ${Core.SystemConnector.getDest()}.`);
251
+ }
252
+ });
253
+ trmDependenciesCheck.versionNotSatisfiedDependencies.forEach(dependency => {
254
+ if (this.onTrmDepVersionNotSatisfied(dependency)) {
255
+ const versionRange = trmDependencies[dependency.packageName];
256
+ throw new Error(`Package "${dependency.packageName}" version ${dependency.manifest.get().version} is installed on ${Core.SystemConnector.getDest()}, but does not satisfy dependency version ${versionRange}. Update with command ${chalk_1.default.italic('trm update ' + dependency.packageName)}`);
257
+ }
258
+ });
259
+ });
260
+ }
261
+ parseTextArg(name) {
262
+ if (this.args[name]) {
263
+ try {
264
+ return (0, fs_1.readFileSync)(this.args[name]).toString();
265
+ }
266
+ catch (_a) {
267
+ return this.args[name];
268
+ }
269
+ }
270
+ }
271
+ parseJsonArg(name) {
272
+ if (this.args[name]) {
273
+ var sValue;
274
+ try {
275
+ sValue = (0, fs_1.readFileSync)(this.args[name]).toString();
276
+ }
277
+ catch (_a) {
278
+ sValue = this.args[name];
279
+ }
280
+ try {
281
+ return JSON.parse(sValue);
282
+ }
283
+ catch (_b) { }
284
+ }
285
+ }
286
+ parseArrayArg(name) {
287
+ if (this.args[name]) {
288
+ try {
289
+ return this.args[name].split(',').map(s => s.trim());
290
+ }
291
+ catch (_a) { }
292
+ }
293
+ }
294
+ parseNumberArg(name) {
295
+ if (this.args[name]) {
296
+ try {
297
+ return Number(this.args[name]);
298
+ }
299
+ catch (_a) { }
300
+ }
301
+ }
302
+ execute(args1, args2) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ this.args = this.parseCommandArgs(args1, args2);
305
+ this.onArgs();
306
+ var exitCode;
307
+ try {
308
+ if (this.registerOpts.requiresR3trans && process.platform === 'darwin') {
309
+ }
310
+ yield utils_1.GlobalContext.getInstance().load();
311
+ yield Commons.Plugin.call("client", "loadCore", { core: Core });
312
+ yield Commons.Plugin.call("client", "loadCommons", { commons: Commons });
313
+ Commons.Inquirer.inquirer = this.getInquirer(InquirerType_1.InquirerType.CLI);
314
+ Commons.Logger.logger = this.getLogger(this.args.logger, this.args.debug, this.args.loggerOutDir);
315
+ if (process.platform !== 'win32' && process.platform !== 'darwin') {
316
+ Commons.Logger.warning(`Running on untested OS "${process.platform}"! Some features aren't tested yet.`);
317
+ }
318
+ yield this.getCliVersionStatus();
319
+ if (this.registerOpts.requiresRegistry) {
320
+ var registryAlias;
321
+ var registry;
322
+ if (this.args.registry) {
323
+ registryAlias = registryAlias_1.RegistryAlias.get(this.args.registry);
324
+ }
325
+ else if (this.args.registryEndpoint) {
326
+ registryAlias = registryAlias_1.RegistryAlias.getTemporaryInstance(this.args.registryEndpoint, this.parseJsonArg('registryAuth'));
327
+ }
328
+ else {
329
+ registryAlias = yield (0, prompts_1.pickRegistry)();
330
+ }
331
+ registry = registryAlias.getRegistry();
332
+ try {
333
+ const registryPing = yield registry.ping();
334
+ if (this.registerOpts.registryAuthBlacklist && this.registerOpts.registryAuthBlacklist.includes(registryPing.authentication_type)) {
335
+ throw new Error(`This command is not supported by registry "${registry.name}".`);
336
+ }
337
+ if (registryPing.messages) {
338
+ registryPing.messages.forEach(m => Commons.Logger.registryResponse(m));
339
+ }
340
+ }
341
+ catch (e) {
342
+ Commons.Logger.error(e, true);
343
+ if (!this.registerOpts.ignoreRegistryUnreachable) {
344
+ throw new Error(`Registry "${registry.name}" is unreachable.`);
345
+ }
346
+ }
347
+ if (registryAlias.authData) {
348
+ try {
349
+ yield registry.authenticate(registryAlias.authData);
350
+ }
351
+ catch (e) {
352
+ this.registryAuthFailed = e;
353
+ Commons.Logger.error(e, true);
354
+ Commons.Logger.warning(`Registry "${registry.name}" login failed.`);
355
+ }
356
+ }
357
+ this.registry = registry;
358
+ this.registryAuthData = !!registryAlias.authData;
359
+ Core.RegistryProvider.registry.push(registry);
360
+ }
361
+ registryAlias_1.RegistryAlias.getAll().forEach(o => {
362
+ var append = true;
363
+ var aliasRegistry = registryAlias_1.RegistryAlias.get(o.alias).getRegistry();
364
+ Core.RegistryProvider.registry.forEach(k => {
365
+ if (append) {
366
+ append = !k.compare(aliasRegistry);
367
+ }
368
+ });
369
+ if (append) {
370
+ Core.RegistryProvider.registry.push(aliasRegistry);
371
+ }
372
+ });
373
+ if (this.registerOpts.requiresConnection) {
374
+ var system;
375
+ if (this.args.alias) {
376
+ system = systemAlias_1.SystemAlias.get(this.args.alias).getConnection();
377
+ }
378
+ else {
379
+ system = (yield (0, prompts_1.connect)(this.args, true, this.registerOpts.addNoConnection)).getSystemConnector();
380
+ }
381
+ yield system.connect();
382
+ Core.SystemConnector.systemConnector = system;
383
+ yield Commons.Plugin.call("client", "onInitializeSystemConnector", Core.SystemConnector.systemConnector);
384
+ if (this.registerOpts.requiresTrmDependencies) {
385
+ yield this.checkTrmDependencies();
386
+ }
387
+ }
388
+ yield this.handler();
389
+ if (Commons.Logger.logger instanceof Commons.CliLogger || Commons.Logger.logger instanceof Commons.CliLogFileLogger) {
390
+ Commons.Logger.logger.forceStop();
391
+ }
392
+ exitCode = 0;
393
+ }
394
+ catch (e) {
395
+ yield (0, utils_1.logError)(e);
396
+ exitCode = 1;
397
+ }
398
+ finally {
399
+ if (Core.SystemConnector.systemConnector) {
400
+ try {
401
+ yield Core.SystemConnector.closeConnection();
402
+ }
403
+ catch (e) {
404
+ Commons.Logger.error(`Couldn't close system connection!`, true);
405
+ Commons.Logger.log(e.toString(), true);
406
+ }
407
+ }
408
+ if (Commons.Logger.logger instanceof Commons.CliLogFileLogger) {
409
+ const sessionId = Commons.Logger.logger.getSessionId();
410
+ const logFilePath = Commons.Logger.logger.getFilePath();
411
+ Commons.Logger.info(`Saved log output "${logFilePath}" for session ID ${sessionId}.`);
412
+ }
413
+ process.exit(exitCode);
414
+ }
415
+ });
416
+ }
417
+ }
418
+ exports.AbstractCommand = AbstractCommand;
@@ -0,0 +1,3 @@
1
+ export declare enum InquirerType {
2
+ CLI = "CLI"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InquirerType = void 0;
4
+ var InquirerType;
5
+ (function (InquirerType) {
6
+ InquirerType["CLI"] = "CLI";
7
+ })(InquirerType || (exports.InquirerType = InquirerType = {}));
@@ -5,7 +5,3 @@ export declare enum LoggerType {
5
5
  VOID = "VOID",
6
6
  KEY = "VALUE"
7
7
  }
8
- export declare enum InquirerType {
9
- CLI = "CLI"
10
- }
11
- export declare function executeCommand(args: any): Promise<void>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerType = void 0;
4
+ var LoggerType;
5
+ (function (LoggerType) {
6
+ LoggerType["CLI"] = "CLI";
7
+ LoggerType["CLI_LOG"] = "CLI_LOG";
8
+ LoggerType["CONSOLE"] = "CONSOLE";
9
+ LoggerType["VOID"] = "VOID";
10
+ LoggerType["KEY"] = "VALUE";
11
+ })(LoggerType || (exports.LoggerType = LoggerType = {}));
@@ -1,11 +1,12 @@
1
- import { Command } from "commander";
2
1
  import { AuthenticationType } from "trm-registry-types";
3
- export declare function registerCommand(command: Command, args?: {
2
+ export interface RegisterCommandOpts {
4
3
  requiresConnection?: boolean;
5
4
  addNoConnection?: boolean;
6
5
  requiresTrmDependencies?: boolean;
7
6
  requiresRegistry?: boolean;
7
+ onlyRegistryAlias?: boolean;
8
8
  registryAuthBlacklist?: AuthenticationType[];
9
9
  noSystemAlias?: boolean;
10
10
  ignoreRegistryUnreachable?: boolean;
11
- }): void;
11
+ requiresR3trans?: boolean;
12
+ }
@@ -0,0 +1,8 @@
1
+ import { AbstractCommand } from "../AbstractCommand";
2
+ export declare class Alias extends AbstractCommand {
3
+ protected init(): void;
4
+ private view;
5
+ private check;
6
+ private edit;
7
+ protected handler(): Promise<void>;
8
+ }