trm-client 5.0.2 → 5.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![trm-client Latest version](https://img.shields.io/npm/v/trm-client)](https://www.npmjs.com/package/trm-client)
6
6
  [![trm-client Installs](https://img.shields.io/npm/dt/trm-client)](https://www.npmjs.com/package/trm-client)
7
7
 
8
- | 🚀 This project is funded and maintained by 🏦 | 🔗 |
8
+ | 🚀 This project is funded and maintained by 🏦 | 🔗 |
9
9
  |-------------------------------------------------|----------------------------------------------------------------|
10
10
  | Regesta S.p.A. | [https://www.regestaitalia.eu/](https://www.regestaitalia.eu/) |
11
11
  | Clarex S.r.l. | [https://www.clarex.it/](https://www.clarex.it/) |
package/changelog.txt CHANGED
@@ -8,6 +8,17 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2025-09-24 v5.1.0
12
+ -------------------
13
+
14
+ * alias command view/edit
15
+ ! npm global path in settings
16
+ ! sap landscape in settings
17
+ * sap landscape for mac
18
+ + add plugins in info command
19
+ ! trm-commons ^3.3.2
20
+ ! trm-core ^7.5.3
21
+
11
22
  2025-09-09 v5.0.2
12
23
  -------------------
13
24
 
@@ -31,6 +31,7 @@ const _view = (alias) => {
31
31
  if (!connection) {
32
32
  throw new Error(`Unknown connection type "${alias.type}".`);
33
33
  }
34
+ connection.setData(alias.data);
34
35
  if (connection.logData) {
35
36
  connection.logData();
36
37
  }
@@ -57,9 +58,10 @@ const _edit = (alias) => __awaiter(void 0, void 0, void 0, function* () {
57
58
  noSystemAlias: true,
58
59
  force: true
59
60
  }), false);
61
+ const newData = connectionArgs.getData();
60
62
  try {
61
63
  systemAlias_1.SystemAlias.delete(alias.alias);
62
- yield systemAlias_1.SystemAlias.create(alias.alias, connectionArgs.name, connectionArgs.getData()).getConnection().connect();
64
+ yield systemAlias_1.SystemAlias.create(alias.alias, connectionArgs.name, newData).getConnection().connect();
63
65
  }
64
66
  catch (e) {
65
67
  connectionSuccess = false;
@@ -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 = yield (0, trm_core_1.getNpmGlobalPath)();
72
+ const npmGlobal = utils_1.Context.getInstance().settings.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)();
@@ -207,5 +207,18 @@ function info(commandArgs) {
207
207
  if (!(trm_core_1.SystemConnector.systemConnector instanceof utils_1.DummyConnector)) {
208
208
  trm_commons_1.Logger.tree(serverTree);
209
209
  }
210
+ const pluginsTree = {
211
+ text: chalk_1.default.bold(`Plugins`),
212
+ children: []
213
+ };
214
+ utils_1.Context.getInstance().plugins.forEach(p => {
215
+ pluginsTree.children.push({
216
+ text: p,
217
+ children: []
218
+ });
219
+ });
220
+ if (pluginsTree.children.length > 0) {
221
+ trm_commons_1.Logger.tree(pluginsTree);
222
+ }
210
223
  });
211
224
  }
@@ -4,10 +4,12 @@ export declare class Context {
4
4
  private static _instance;
5
5
  settings: SettingsData;
6
6
  connections: IConnect[];
7
+ plugins: string[];
7
8
  constructor();
8
9
  load(): Promise<void>;
9
10
  setSetting(key: string, value: string): void;
10
11
  private getSettingsFilePath;
12
+ private getDefaultSettings;
11
13
  private getSettings;
12
14
  private generateSettingsFile;
13
15
  static getInstance(): Context;
@@ -53,10 +53,6 @@ const ini = __importStar(require("ini"));
53
53
  const trm_commons_1 = require("trm-commons");
54
54
  const trm_core_1 = require("trm-core");
55
55
  const SETTINGS_FILE_NAME = "settings.ini";
56
- const defaultSettings = {
57
- loggerType: 'CLI',
58
- logOutputFolder: 'default'
59
- };
60
56
  class RESTConnectExtended extends trm_commons_1.RESTConnect {
61
57
  getSystemConnector() {
62
58
  const data = this.getData();
@@ -66,7 +62,7 @@ class RESTConnectExtended extends trm_commons_1.RESTConnect {
66
62
  class RFCConnectExtended extends trm_commons_1.RFCConnect {
67
63
  getSystemConnector() {
68
64
  const data = this.getData();
69
- return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)());
65
+ return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)(), Context.getInstance().settings.globalNodeModules);
70
66
  }
71
67
  }
72
68
  class Context {
@@ -81,7 +77,10 @@ class Context {
81
77
  }
82
78
  load() {
83
79
  return __awaiter(this, void 0, void 0, function* () {
84
- yield trm_commons_1.Plugin.load();
80
+ const plugins = yield trm_commons_1.Plugin.load({
81
+ globalNodeModulesPath: this.settings.globalNodeModules
82
+ });
83
+ this.plugins = [...new Set(plugins)];
85
84
  if (!this.connections) {
86
85
  this.connections = yield trm_commons_1.Plugin.call("client", "onContextLoadConnections", [new RESTConnectExtended(), new RFCConnectExtended()]);
87
86
  }
@@ -98,16 +97,40 @@ class Context {
98
97
  getSettingsFilePath() {
99
98
  return path_1.default.join((0, _1.getRoamingFolder)(), SETTINGS_FILE_NAME);
100
99
  }
100
+ getDefaultSettings() {
101
+ var sapLandscape = path_1.default.join((0, _1.getRoamingPath)(), process.platform === 'win32' ? 'SAP\\Common\\SAPUILandscape.xml' : 'SAP/SAPGUILandscape.xml');
102
+ if (!fs.existsSync(sapLandscape)) {
103
+ sapLandscape = undefined;
104
+ }
105
+ return {
106
+ loggerType: 'CLI',
107
+ logOutputFolder: 'default',
108
+ globalNodeModules: (0, trm_commons_1.getGlobalNodeModules)() || '',
109
+ sapLandscape
110
+ };
111
+ }
101
112
  getSettings() {
113
+ var defaultSettings;
102
114
  const filePath = this.getSettingsFilePath();
103
115
  if (fs.existsSync(filePath)) {
104
116
  try {
105
117
  const sIni = fs.readFileSync(filePath).toString();
106
118
  const settingsData = ini.decode(sIni);
119
+ if (!settingsData.globalNodeModules || !settingsData.sapLandscape) {
120
+ defaultSettings = this.getDefaultSettings();
121
+ if (!settingsData.globalNodeModules) {
122
+ settingsData.globalNodeModules = defaultSettings.globalNodeModules;
123
+ }
124
+ if (!settingsData.sapLandscape) {
125
+ settingsData.sapLandscape = defaultSettings.sapLandscape;
126
+ }
127
+ this.generateSettingsFile(settingsData, filePath);
128
+ }
107
129
  return settingsData;
108
130
  }
109
131
  catch (e) { }
110
132
  }
133
+ defaultSettings = this.getDefaultSettings();
111
134
  this.generateSettingsFile(defaultSettings, filePath);
112
135
  return defaultSettings;
113
136
  }
@@ -1,6 +1,8 @@
1
1
  export type SettingsData = {
2
2
  loggerType: string;
3
3
  logOutputFolder: string;
4
+ globalNodeModules: string;
5
+ sapLandscape?: string;
4
6
  r3transDocker?: boolean;
5
7
  r3transDockerName?: string;
6
8
  };
@@ -41,46 +41,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
42
  });
43
43
  };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
44
  Object.defineProperty(exports, "__esModule", { value: true });
48
45
  exports.getSapLogonConnections = getSapLogonConnections;
49
- const path_1 = __importDefault(require("path"));
50
46
  const fs = __importStar(require("fs"));
51
47
  const xml2js_1 = require("./xml2js");
52
- const getRoamingPath_1 = require("./getRoamingPath");
48
+ const Context_1 = require("./Context");
53
49
  function getSapLogonConnections() {
54
50
  return __awaiter(this, void 0, void 0, function* () {
55
- const landscapePath = path_1.default.join((0, getRoamingPath_1.getRoamingPath)(), `SAP\\Common\\SAPUILandscape.xml`);
56
- const sXml = fs.readFileSync(landscapePath, { encoding: 'utf8', flag: 'r' });
57
- const result = yield (0, xml2js_1.xml2js)(sXml);
58
51
  var systems = [];
59
- try {
60
- result.Landscape.Services[0].Service.forEach((xmlObj) => {
61
- var obj = xmlObj['$'];
62
- var addrMatches = obj.server.match(/(.*)\:(\d*)$/);
63
- var ashost = addrMatches[1];
64
- var port = addrMatches[2];
65
- var sysnr = port.slice(-2);
66
- var saprouter;
67
- if (obj.routerid) {
68
- const router = result.Landscape.Routers[0].Router.find((o) => o['$'].uuid === obj.routerid);
69
- if (router) {
70
- saprouter = router['$'].router;
52
+ const sapLandscape = Context_1.Context.getInstance().settings.sapLandscape;
53
+ if (sapLandscape) {
54
+ const sXml = fs.readFileSync(Context_1.Context.getInstance().settings.sapLandscape, { encoding: 'utf8', flag: 'r' });
55
+ const result = yield (0, xml2js_1.xml2js)(sXml);
56
+ try {
57
+ result.Landscape.Services[0].Service.forEach((xmlObj) => {
58
+ var obj = xmlObj['$'];
59
+ var addrMatches = obj.server.match(/(.*)\:(\d*)$/);
60
+ var ashost = addrMatches[1];
61
+ var port = addrMatches[2];
62
+ var sysnr = port.slice(-2);
63
+ var saprouter;
64
+ if (obj.routerid) {
65
+ const router = result.Landscape.Routers[0].Router.find((o) => o['$'].uuid === obj.routerid);
66
+ if (router) {
67
+ saprouter = router['$'].router;
68
+ }
71
69
  }
72
- }
73
- systems.push({
74
- id: obj.uuid,
75
- name: obj.name,
76
- dest: obj.systemid,
77
- sysnr,
78
- ashost,
79
- saprouter
70
+ systems.push({
71
+ id: obj.uuid,
72
+ name: obj.name,
73
+ dest: obj.systemid,
74
+ sysnr,
75
+ ashost,
76
+ saprouter
77
+ });
80
78
  });
81
- });
79
+ }
80
+ catch (_a) { }
82
81
  }
83
- catch (e) { }
84
82
  return systems;
85
83
  });
86
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-client",
3
- "version": "5.0.2",
3
+ "version": "5.1.0",
4
4
  "description": "TRM (Transport Request Manager) Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,13 +45,13 @@
45
45
  "get-root-path": "^2.0.2",
46
46
  "ini": "^4.1.1",
47
47
  "semver": "^7.5.4",
48
- "trm-commons": "^3.2.0",
49
- "trm-core": "^7.5.1",
48
+ "trm-commons": "^3.3.2",
49
+ "trm-core": "^7.5.3",
50
50
  "trm-registry-types": "^1.2.0",
51
51
  "xml2js": "^0.6.2"
52
52
  },
53
53
  "peerDependencies": {
54
- "trm-commons": "^3.2.0"
54
+ "trm-commons": "^3.3.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/ini": "^1.3.31",