trm-client 5.1.0 → 5.2.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/changelog.txt CHANGED
@@ -8,6 +8,21 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2025-10-01 v5.2.0
12
+ -------------------
13
+
14
+ ! trm-core ^7.5.5
15
+ ! trm-commons ^3.4.2
16
+ * connection data problems
17
+ + cache time consuming data
18
+ + on after login update alias on changes
19
+
20
+ 2025-09-25 v5.1.1
21
+ -------------------
22
+
23
+ * create alias command
24
+ * keep original abap packages name selection
25
+
11
26
  2025-09-24 v5.1.0
12
27
  -------------------
13
28
 
@@ -27,7 +27,7 @@ const _create = () => __awaiter(void 0, void 0, void 0, function* () {
27
27
  });
28
28
  });
29
29
  const _view = (alias) => {
30
- const connection = utils_1.Context.getInstance().connections.find(o => o.name === alias.type);
30
+ const connection = utils_1.Context.getInstance().getConnections().find(o => o.name === alias.type);
31
31
  if (!connection) {
32
32
  throw new Error(`Unknown connection type "${alias.type}".`);
33
33
  }
@@ -30,9 +30,9 @@ function content(commandArgs) {
30
30
  const packageContent = yield remotePackage.fetchRemoteContent(commandArgs.version, {
31
31
  tempDirPath: (0, utils_1.getTempFolder)(),
32
32
  r3transDirPath: commandArgs.r3transPath,
33
- useDocker: utils_1.Context.getInstance().settings.r3transDocker,
33
+ useDocker: utils_1.Context.getInstance().getSettings().r3transDocker,
34
34
  dockerOptions: {
35
- name: utils_1.Context.getInstance().settings.r3transDockerName
35
+ name: utils_1.Context.getInstance().getSettings().r3transDockerName
36
36
  }
37
37
  });
38
38
  if (!commandArgs.all) {
@@ -39,9 +39,9 @@ function _import(commandArgs) {
39
39
  r3transOptions: {
40
40
  tempDirPath: (0, utils_1.getTempFolder)(),
41
41
  r3transDirPath: commandArgs.r3transPath,
42
- useDocker: utils_1.Context.getInstance().settings.r3transDocker,
42
+ useDocker: utils_1.Context.getInstance().getSettings().r3transDocker,
43
43
  dockerOptions: {
44
- name: utils_1.Context.getInstance().settings.r3transDockerName
44
+ name: utils_1.Context.getInstance().getSettings().r3transDockerName
45
45
  }
46
46
  },
47
47
  noInquirer: commandArgs.noPrompts,
@@ -17,7 +17,7 @@ const trm_core_1 = require("trm-core");
17
17
  const utils_1 = require("../utils");
18
18
  const commons_1 = require("./commons");
19
19
  const fs_1 = require("fs");
20
- const path_1 = __importDefault(require("path"));
20
+ const path_1 = require("path");
21
21
  const get_root_path_1 = require("get-root-path");
22
22
  const chalk_1 = __importDefault(require("chalk"));
23
23
  const semver_1 = require("semver");
@@ -25,10 +25,10 @@ const trm_commons_1 = require("trm-commons");
25
25
  const _getDependencyVersion = (moduleName, rootModule = 'trm-client') => {
26
26
  var file;
27
27
  try {
28
- file = (0, fs_1.readFileSync)(path_1.default.join(get_root_path_1.rootPath, `/node_modules/${rootModule}/node_modules/${moduleName}/package.json`));
28
+ file = (0, fs_1.readFileSync)((0, path_1.join)(get_root_path_1.rootPath, `/node_modules/${rootModule}/node_modules/${moduleName}/package.json`));
29
29
  }
30
30
  catch (e) {
31
- file = (0, fs_1.readFileSync)(path_1.default.join(get_root_path_1.rootPath, `/node_modules/${moduleName}/package.json`));
31
+ file = (0, fs_1.readFileSync)((0, path_1.join)(get_root_path_1.rootPath, `/node_modules/${moduleName}/package.json`));
32
32
  }
33
33
  if (!file) {
34
34
  trm_commons_1.Logger.warning(`Library ${moduleName} (root ${rootModule}) was not found!`, true);
@@ -40,7 +40,7 @@ const _getDependencyVersion = (moduleName, rootModule = 'trm-client') => {
40
40
  const _getNodeRfcVersion = (npmGlobal) => {
41
41
  var file;
42
42
  try {
43
- file = (0, fs_1.readFileSync)(path_1.default.join(npmGlobal, `/node-rfc/package.json`));
43
+ file = (0, fs_1.readFileSync)((0, path_1.join)(npmGlobal, `/node-rfc/package.json`));
44
44
  }
45
45
  catch (e) {
46
46
  }
@@ -69,7 +69,7 @@ const _getNpmLatestForText = (packageName, installedVersion, text) => __awaiter(
69
69
  function info(commandArgs) {
70
70
  return __awaiter(this, void 0, void 0, function* () {
71
71
  trm_commons_1.Logger.loading(`Reading data...`);
72
- const npmGlobal = utils_1.Context.getInstance().settings.globalNodeModules;
72
+ const npmGlobal = utils_1.Context.getInstance().getSettings().globalNodeModules;
73
73
  const clientLatest = yield (0, utils_1.checkCliUpdate)(false);
74
74
  const clientVersion = (0, utils_1.getClientVersion)();
75
75
  const clientDependencies = (0, utils_1.getClientNodeDependencies)();
@@ -199,24 +199,33 @@ function info(commandArgs) {
199
199
  text: chalk_1.default.bold(`Client`),
200
200
  children: clientChildrenTree
201
201
  };
202
- trm_commons_1.Logger.tree(clientTree);
203
202
  const serverTree = {
204
203
  text: chalk_1.default.bold(`Server (${trm_core_1.SystemConnector.getDest()})`),
205
204
  children: serverDependenciesTree
206
205
  };
207
- if (!(trm_core_1.SystemConnector.systemConnector instanceof utils_1.DummyConnector)) {
208
- trm_commons_1.Logger.tree(serverTree);
209
- }
210
206
  const pluginsTree = {
211
207
  text: chalk_1.default.bold(`Plugins`),
212
208
  children: []
213
209
  };
214
- utils_1.Context.getInstance().plugins.forEach(p => {
215
- pluginsTree.children.push({
216
- text: p,
217
- children: []
218
- });
219
- });
210
+ for (const plugin of utils_1.Context.getInstance().getPlugins()) {
211
+ try {
212
+ const installedVersion = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(plugin.location, 'package.json')).toString()).version;
213
+ pluginsTree.children.push({
214
+ text: yield _getNpmLatestForText(plugin.name, installedVersion, `${plugin.name} ${installedVersion}`),
215
+ children: []
216
+ });
217
+ }
218
+ catch (_a) {
219
+ pluginsTree.children.push({
220
+ text: plugin.name,
221
+ children: []
222
+ });
223
+ }
224
+ }
225
+ trm_commons_1.Logger.tree(clientTree);
226
+ if (!(trm_core_1.SystemConnector.systemConnector instanceof utils_1.DummyConnector)) {
227
+ trm_commons_1.Logger.tree(serverTree);
228
+ }
220
229
  if (pluginsTree.children.length > 0) {
221
230
  trm_commons_1.Logger.tree(pluginsTree);
222
231
  }
@@ -38,9 +38,9 @@ function install(commandArgs) {
38
38
  r3transOptions: {
39
39
  tempDirPath: (0, utils_1.getTempFolder)(),
40
40
  r3transDirPath: commandArgs.r3transPath,
41
- useDocker: utils_1.Context.getInstance().settings.r3transDocker,
41
+ useDocker: utils_1.Context.getInstance().getSettings().r3transDocker,
42
42
  dockerOptions: {
43
- name: utils_1.Context.getInstance().settings.r3transDockerName
43
+ name: utils_1.Context.getInstance().getSettings().r3transDockerName
44
44
  }
45
45
  },
46
46
  noInquirer: commandArgs.noPrompts,
@@ -13,6 +13,7 @@ exports.connect = connect;
13
13
  const systemAlias_1 = require("../../systemAlias");
14
14
  const utils_1 = require("../../utils");
15
15
  const trm_commons_1 = require("trm-commons");
16
+ const lodash_1 = require("lodash");
16
17
  const languageList = [
17
18
  { value: 'AR', name: 'AR (Arabic)' },
18
19
  { value: 'BG', name: 'BG (Bulgarian)' },
@@ -120,30 +121,36 @@ function connect(commandArgs_1) {
120
121
  };
121
122
  })
122
123
  })).alias;
123
- const connection = utils_1.Context.getInstance().connections.find(o => o.name === inq2.type);
124
+ const connection = utils_1.Context.getInstance().getConnections().find(o => o.name === inq2.type);
124
125
  if (!connection) {
125
126
  throw new Error(`Unknown connection type "${inq2.type}" in alias "${inq2.name}"`);
126
127
  }
127
128
  connection.setData(inq2.data);
129
+ if (connection.onAfterLoginData) {
130
+ yield connection.onAfterLoginData(force, commandArgs);
131
+ }
132
+ if (!(0, lodash_1.isEqual)(inq2.data, connection.getData())) {
133
+ systemAlias_1.SystemAlias.delete(inq2.alias);
134
+ systemAlias_1.SystemAlias.create(inq2.alias, inq2.type, connection.getData());
135
+ }
128
136
  return connection;
129
137
  }
130
138
  else {
131
139
  if (inputType === 'logon') {
132
- const inq3 = yield trm_commons_1.Inquirer.prompt({
140
+ const logonConnection = (yield trm_commons_1.Inquirer.prompt({
133
141
  type: `list`,
134
- name: `logonConnection`,
142
+ name: `data`,
135
143
  message: `Select connection`,
136
144
  choices: aSapLogonConnections.map(o => {
137
145
  return {
138
- value: o.id, name: o.name
146
+ value: o, name: o.name
139
147
  };
140
148
  })
141
- });
142
- const logonConnection = aSapLogonConnections.find(o => o.id === inq3.logonConnection);
149
+ })).data;
143
150
  commandArgs.ashost = logonConnection.ashost;
144
151
  commandArgs.dest = logonConnection.dest;
145
152
  commandArgs.sysnr = logonConnection.sysnr;
146
- commandArgs.saprouter = logonConnection.saprouter;
153
+ commandArgs.saprouter = logonConnection.saprouter || ' ';
147
154
  type = 'RFC';
148
155
  }
149
156
  if (!type || force) {
@@ -151,7 +158,7 @@ function connect(commandArgs_1) {
151
158
  type: `list`,
152
159
  name: `type`,
153
160
  message: `Connection type`,
154
- choices: utils_1.Context.getInstance().connections.map(o => {
161
+ choices: utils_1.Context.getInstance().getConnections().map(o => {
155
162
  return {
156
163
  name: o.description,
157
164
  value: o.name
@@ -159,7 +166,7 @@ function connect(commandArgs_1) {
159
166
  })
160
167
  })).type;
161
168
  }
162
- const connectionType = utils_1.Context.getInstance().connections.find(o => o.name === type);
169
+ const connectionType = utils_1.Context.getInstance().getConnections().find(o => o.name === type);
163
170
  if (!connectionType) {
164
171
  throw new Error(`Invalid connection type "${type}"`);
165
172
  }
@@ -209,7 +216,7 @@ function connect(commandArgs_1) {
209
216
  return (commandArgs.lang ? false : true) || force;
210
217
  },
211
218
  validate: (input) => {
212
- return languageList.includes(input.trim().toUpperCase());
219
+ return languageList.find(o => o.value === input.trim().toUpperCase()) ? true : `Unknown language "${input}".`;
213
220
  },
214
221
  choices: languageList
215
222
  }
@@ -24,7 +24,7 @@ function settings(commandArgs) {
24
24
  const value = aSplit[1];
25
25
  utils_1.Context.getInstance().setSetting(key, value);
26
26
  }
27
- const settingsData = utils_1.Context.getInstance().settings;
27
+ const settingsData = utils_1.Context.getInstance().getSettings();
28
28
  Object.keys(settingsData).forEach(k => {
29
29
  trm_commons_1.Logger.log(`${k}: ${settingsData[k]}`);
30
30
  });
package/dist/index.js CHANGED
@@ -153,7 +153,7 @@ const install = program.command(`install`)
153
153
  .option(`-nl, --noLanguageTransport`, `Skip install of language (translations) transport (if exists).`, false)
154
154
  .option(`-nc, --noCustomizingTransport`, `Skip install of customizing transport (if exists).`, false)
155
155
  .option(`-to, --importTimeout <timeout>`, `Install transports import timeout (in seconds).`, '180')
156
- .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`, false)
156
+ .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`)
157
157
  .option(`-it, --createInstallTransport`, `Create/update install transport (used for landscape transports).`, true)
158
158
  .option(`-r3, --r3transPath <path>`, `R3trans program path. (default: Environment variable R3TRANS_HOME)`)
159
159
  .option(`-sha, --integrity <sha>`, `Package integrity.`)
@@ -179,7 +179,7 @@ const update = program.command(`update`)
179
179
  .option(`-nl, --noLanguageTransport`, `Skip install of language (translations) transport (if exists).`, false)
180
180
  .option(`-nc, --noCustomizingTransport`, `Skip install of customizing transport (if exists).`, false)
181
181
  .option(`-to, --importTimeout <timeout>`, `Install transports import timeout (in seconds).`, '180')
182
- .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`, false)
182
+ .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`)
183
183
  .option(`-it, --createInstallTransport`, `Create/update install transport (used for landscape transports).`, true)
184
184
  .option(`-r3, --r3transPath <path>`, `R3trans program path. (default: Environment variable R3TRANS_HOME)`)
185
185
  .option(`-sha, --integrity <sha>`, `Package integrity.`)
@@ -203,7 +203,7 @@ const _import = program.command(`import <file>`)
203
203
  .option(`-nl, --noLanguageTransport`, `Skip install of language (translations) transport (if exists).`, false)
204
204
  .option(`-nc, --noCustomizingTransport`, `Skip install of customizing transport (if exists).`, false)
205
205
  .option(`-to, --importTimeout <timeout>`, `Install transports import timeout (in seconds).`, '180')
206
- .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`, false)
206
+ .option(`-kd, --keepOriginalPackages`, `Keep original ABAP packages names.`)
207
207
  .option(`-it, --createInstallTransport`, `Create/update install transport (used for landscape transports).`, true)
208
208
  .option(`-r3, --r3transPath <path>`, `R3trans program path. (default: Environment variable R3TRANS_HOME)`)
209
209
  .option(`-sha, --integrity <sha>`, `Package integrity.`)
@@ -58,9 +58,9 @@ class SystemAlias {
58
58
  this._data = _data;
59
59
  }
60
60
  getConnection() {
61
- const connection = utils_1.Context.getInstance().connections.find(o => o.name === this.type);
61
+ const connection = utils_1.Context.getInstance().getConnections().find(o => o.name === this.type);
62
62
  if (!connection) {
63
- throw new Error(`Unknown connection type "${this.type}". Possible values are ${utils_1.Context.getInstance().connections.map(k => k.name).join(', ')}.`);
63
+ throw new Error(`Unknown connection type "${this.type}". Possible values are ${utils_1.Context.getInstance().getConnections().map(k => k.name).join(', ')}.`);
64
64
  }
65
65
  connection.setData(this._data);
66
66
  return connection.getSystemConnector();
@@ -71,7 +71,7 @@ class SystemAlias {
71
71
  }
72
72
  var oContent = {};
73
73
  content.forEach(o => {
74
- const connection = utils_1.Context.getInstance().connections.find(k => k.name === o.type);
74
+ const connection = utils_1.Context.getInstance().getConnections().find(k => k.name === o.type);
75
75
  if (connection) {
76
76
  oContent[o.alias] = o.data;
77
77
  oContent[o.alias].type = o.type;
@@ -95,13 +95,12 @@ class SystemAlias {
95
95
  if (!oIni[sAlias].type) {
96
96
  oIni[sAlias].type = 'RFC';
97
97
  }
98
- const connection = utils_1.Context.getInstance().connections.find(o => o.name === oIni[sAlias].type);
98
+ const connection = utils_1.Context.getInstance().getConnections().find(o => o.name === oIni[sAlias].type);
99
99
  if (connection) {
100
- connection.setData(oIni[sAlias]);
101
100
  aAlias.push({
102
101
  alias: sAlias,
103
102
  type: oIni[sAlias].type,
104
- data: connection.getData()
103
+ data: oIni[sAlias]
105
104
  });
106
105
  }
107
106
  });
@@ -0,0 +1,7 @@
1
+ export type Cache = {
2
+ ts: number;
3
+ data: any;
4
+ };
5
+ export type CacheData = {
6
+ latestVersion?: Cache;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +1,29 @@
1
+ import { CacheData } from ".";
1
2
  import { SettingsData } from "./";
2
- import { IConnect } from "trm-commons";
3
+ import { IConnect, PluginModule } from "trm-commons";
3
4
  export declare class Context {
4
5
  private static _instance;
5
- settings: SettingsData;
6
- connections: IConnect[];
7
- plugins: string[];
6
+ private _pluginsLoaded;
7
+ private _settings;
8
+ private _cache;
9
+ private _connections;
10
+ private _plugins;
8
11
  constructor();
12
+ getSettings(): SettingsData;
13
+ getCache(): CacheData;
9
14
  load(): Promise<void>;
15
+ getPlugins(): PluginModule[];
16
+ getConnections(): IConnect[];
10
17
  setSetting(key: string, value: string): void;
18
+ setCache(key: string, value: any): void;
19
+ private cloneInstance;
20
+ private cloneArrayOfInstances;
11
21
  private getSettingsFilePath;
22
+ private getCacheFilePath;
12
23
  private getDefaultSettings;
13
- private getSettings;
24
+ private getSettingsInternal;
25
+ private getCacheInternal;
14
26
  private generateSettingsFile;
27
+ private generateCacheFile;
15
28
  static getInstance(): Context;
16
29
  }
@@ -52,6 +52,7 @@ const fs = __importStar(require("fs"));
52
52
  const ini = __importStar(require("ini"));
53
53
  const trm_commons_1 = require("trm-commons");
54
54
  const trm_core_1 = require("trm-core");
55
+ const CACHE_FILE_NAME = ".cache";
55
56
  const SETTINGS_FILE_NAME = "settings.ini";
56
57
  class RESTConnectExtended extends trm_commons_1.RESTConnect {
57
58
  getSystemConnector() {
@@ -62,41 +63,74 @@ class RESTConnectExtended extends trm_commons_1.RESTConnect {
62
63
  class RFCConnectExtended extends trm_commons_1.RFCConnect {
63
64
  getSystemConnector() {
64
65
  const data = this.getData();
65
- return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)(), Context.getInstance().settings.globalNodeModules);
66
+ return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)(), Context.getInstance().getSettings().globalNodeModules);
66
67
  }
67
68
  }
68
69
  class Context {
69
70
  constructor() {
70
- this.settings = this.getSettings();
71
- if (typeof (this.settings.r3transDocker) !== 'boolean') {
71
+ this._pluginsLoaded = false;
72
+ this._connections = [];
73
+ this._plugins = [];
74
+ this._settings = this.getSettingsInternal();
75
+ this._cache = this.getCacheInternal();
76
+ if (typeof (this._settings.r3transDocker) !== 'boolean') {
72
77
  if (process.platform === 'darwin') {
73
78
  trm_commons_1.Logger.info(`R3trans defaults to docker in darwin os.`, true);
74
- this.settings.r3transDocker = true;
79
+ this._settings.r3transDocker = true;
75
80
  }
76
81
  }
77
82
  }
83
+ getSettings() {
84
+ return this._settings;
85
+ }
86
+ getCache() {
87
+ return this._cache;
88
+ }
78
89
  load() {
79
90
  return __awaiter(this, void 0, void 0, function* () {
80
- const plugins = yield trm_commons_1.Plugin.load({
81
- globalNodeModulesPath: this.settings.globalNodeModules
82
- });
83
- this.plugins = [...new Set(plugins)];
84
- if (!this.connections) {
85
- this.connections = yield trm_commons_1.Plugin.call("client", "onContextLoadConnections", [new RESTConnectExtended(), new RFCConnectExtended()]);
91
+ if (!this._pluginsLoaded) {
92
+ this._plugins = yield trm_commons_1.Plugin.load({
93
+ globalNodeModulesPath: this._settings.globalNodeModules
94
+ });
95
+ this._connections = yield trm_commons_1.Plugin.call("client", "onContextLoadConnections", [new RESTConnectExtended(), new RFCConnectExtended()]);
96
+ this._pluginsLoaded = true;
86
97
  }
87
98
  });
88
99
  }
100
+ getPlugins() {
101
+ return this._plugins;
102
+ }
103
+ getConnections() {
104
+ return this.cloneArrayOfInstances(this._connections);
105
+ }
89
106
  setSetting(key, value) {
90
- if (this.settings[key] === undefined) {
107
+ if (this._settings[key] === undefined) {
91
108
  throw new Error(`Invalid key ${key}.`);
92
109
  }
93
110
  const filePath = this.getSettingsFilePath();
94
- this.settings[key] = value;
95
- this.generateSettingsFile(this.settings, filePath);
111
+ this._settings[key] = value;
112
+ this.generateSettingsFile(this._settings, filePath);
113
+ }
114
+ setCache(key, value) {
115
+ const filePath = this.getCacheFilePath();
116
+ this._cache[key] = {
117
+ ts: Date.now(),
118
+ data: value
119
+ };
120
+ this.generateCacheFile(this._cache, filePath);
121
+ }
122
+ cloneInstance(obj) {
123
+ return Object.assign(Object.create(Object.getPrototypeOf(obj)), obj);
124
+ }
125
+ cloneArrayOfInstances(arr) {
126
+ return arr.map(this.cloneInstance);
96
127
  }
97
128
  getSettingsFilePath() {
98
129
  return path_1.default.join((0, _1.getRoamingFolder)(), SETTINGS_FILE_NAME);
99
130
  }
131
+ getCacheFilePath() {
132
+ return path_1.default.join((0, _1.getRoamingFolder)(), CACHE_FILE_NAME);
133
+ }
100
134
  getDefaultSettings() {
101
135
  var sapLandscape = path_1.default.join((0, _1.getRoamingPath)(), process.platform === 'win32' ? 'SAP\\Common\\SAPUILandscape.xml' : 'SAP/SAPGUILandscape.xml');
102
136
  if (!fs.existsSync(sapLandscape)) {
@@ -109,7 +143,7 @@ class Context {
109
143
  sapLandscape
110
144
  };
111
145
  }
112
- getSettings() {
146
+ getSettingsInternal() {
113
147
  var defaultSettings;
114
148
  const filePath = this.getSettingsFilePath();
115
149
  if (fs.existsSync(filePath)) {
@@ -134,9 +168,23 @@ class Context {
134
168
  this.generateSettingsFile(defaultSettings, filePath);
135
169
  return defaultSettings;
136
170
  }
171
+ getCacheInternal() {
172
+ const filePath = this.getCacheFilePath();
173
+ if (fs.existsSync(filePath)) {
174
+ try {
175
+ return JSON.parse(fs.readFileSync(filePath).toString());
176
+ }
177
+ catch (e) { }
178
+ }
179
+ this.generateCacheFile({}, filePath);
180
+ return {};
181
+ }
137
182
  generateSettingsFile(data, filePath) {
138
183
  fs.writeFileSync(filePath, ini.encode(data), { encoding: 'utf8', flag: 'w' });
139
184
  }
185
+ generateCacheFile(data, filePath) {
186
+ fs.writeFileSync(filePath, JSON.stringify(data), { encoding: 'utf8', flag: 'w' });
187
+ }
140
188
  static getInstance() {
141
189
  if (!this._instance) {
142
190
  this._instance = new Context();
@@ -18,10 +18,19 @@ const getClientVersion_1 = require("./getClientVersion");
18
18
  const chalk_1 = __importDefault(require("chalk"));
19
19
  const getNpmPackageLatestVersion_1 = require("./getNpmPackageLatestVersion");
20
20
  const trm_commons_1 = require("trm-commons");
21
+ const Context_1 = require("./Context");
21
22
  function checkCliUpdate(print) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  try {
24
- const latestVersion = yield (0, getNpmPackageLatestVersion_1.getNpmPackageLatestVersion)('trm-client');
25
+ var latestVersion;
26
+ const cache = Context_1.Context.getInstance().getCache().latestVersion;
27
+ if (cache && cache.ts && Date.now() - cache.ts <= 60000) {
28
+ latestVersion = cache.data;
29
+ }
30
+ else {
31
+ latestVersion = yield (0, getNpmPackageLatestVersion_1.getNpmPackageLatestVersion)('trm-client');
32
+ Context_1.Context.getInstance().setCache('latestVersion', latestVersion);
33
+ }
25
34
  const localVersion = (0, getClientVersion_1.getClientVersion)();
26
35
  const versionDiff = (0, semver_1.diff)(localVersion, latestVersion);
27
36
  if ((versionDiff === 'minor' || versionDiff === 'major') && (0, semver_1.gt)(latestVersion, localVersion)) {
@@ -49,9 +49,9 @@ const Context_1 = require("./Context");
49
49
  function getSapLogonConnections() {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
51
  var systems = [];
52
- const sapLandscape = Context_1.Context.getInstance().settings.sapLandscape;
52
+ const sapLandscape = Context_1.Context.getInstance().getSettings().sapLandscape;
53
53
  if (sapLandscape) {
54
- const sXml = fs.readFileSync(Context_1.Context.getInstance().settings.sapLandscape, { encoding: 'utf8', flag: 'r' });
54
+ const sXml = fs.readFileSync(Context_1.Context.getInstance().getSettings().sapLandscape, { encoding: 'utf8', flag: 'r' });
55
55
  const result = yield (0, xml2js_1.xml2js)(sXml);
56
56
  try {
57
57
  result.Landscape.Services[0].Service.forEach((xmlObj) => {
@@ -15,4 +15,5 @@ export * from "./getClientNodeDependencies";
15
15
  export * from "./DummyConnector";
16
16
  export * from "./getNpmPackageLatestVersion";
17
17
  export * from "./SettingsData";
18
+ export * from "./CacheData";
18
19
  export * from "./Context";
@@ -31,4 +31,5 @@ __exportStar(require("./getClientNodeDependencies"), exports);
31
31
  __exportStar(require("./DummyConnector"), exports);
32
32
  __exportStar(require("./getNpmPackageLatestVersion"), exports);
33
33
  __exportStar(require("./SettingsData"), exports);
34
+ __exportStar(require("./CacheData"), exports);
34
35
  __exportStar(require("./Context"), exports);
@@ -24,8 +24,8 @@ function registerCommand(command, args) {
24
24
  const ignoreRegistryUnreachable = args.ignoreRegistryUnreachable ? true : false;
25
25
  const noSystemAlias = args.noSystemAlias ? true : false;
26
26
  const registryAuthBlacklist = args.registryAuthBlacklist || [];
27
- const defaultLogger = Context_1.Context.getInstance().settings.loggerType;
28
- const logOutputFolder = Context_1.Context.getInstance().settings.logOutputFolder;
27
+ const defaultLogger = Context_1.Context.getInstance().getSettings().loggerType;
28
+ const logOutputFolder = Context_1.Context.getInstance().getSettings().logOutputFolder;
29
29
  if (requiresConnection) {
30
30
  command.option(`-de, --dest <dest>`, `System ID.`)
31
31
  .option(`-us, --user <user>`, `System User Logon.`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-client",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "TRM (Transport Request Manager) Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,17 +44,19 @@
44
44
  "get-latest-version": "^5.1.0",
45
45
  "get-root-path": "^2.0.2",
46
46
  "ini": "^4.1.1",
47
+ "lodash": "^4.17.21",
47
48
  "semver": "^7.5.4",
48
- "trm-commons": "^3.3.2",
49
- "trm-core": "^7.5.3",
49
+ "trm-commons": "^3.4.2",
50
+ "trm-core": "^7.5.5",
50
51
  "trm-registry-types": "^1.2.0",
51
52
  "xml2js": "^0.6.2"
52
53
  },
53
54
  "peerDependencies": {
54
- "trm-commons": "^3.3.2"
55
+ "trm-commons": "^3.4.2"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/ini": "^1.3.31",
59
+ "@types/lodash": "^4.17.20",
58
60
  "@types/node": "^20.4.8",
59
61
  "@types/semver": "^7.5.3",
60
62
  "@types/xml2js": "^0.4.11",