trm-client 7.3.4 → 7.4.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,25 @@ Legend
8
8
  + : added
9
9
  - : removed
10
10
 
11
+ 2026-03-03 v7.4.0
12
+ -------------------
13
+ ! trm-core ^8.4.0
14
+ ! removed npm global path from settings
15
+ ! update cache usage
16
+ ! info command with latest in range
17
+
18
+ 2026-02-23 v7.3.5
19
+ -------------------
20
+ * info command
21
+
22
+ 2026-02-18 v7.3.4
23
+ -------------------
24
+ ! npm latest version
25
+
26
+ 2026-02-18 v7.3.3
27
+ -------------------
28
+ ! update packages
29
+
11
30
  2026-02-17 v7.3.2
12
31
  -------------------
13
32
  ! upgrade trm dependencies
@@ -162,7 +162,7 @@ class AbstractCommand {
162
162
  return __awaiter(this, void 0, void 0, function* () {
163
163
  if (!this.trmDependenciesCheck) {
164
164
  const packages = yield this.getSystemPackages();
165
- this.trmDependenciesCheck = yield Core.checkCoreTrmDependencies(packages);
165
+ this.trmDependenciesCheck = yield Core.checkCoreTrmDependencies(packages, utils_1.GlobalContext.getInstance().getGlobalNodeModules());
166
166
  }
167
167
  return this.trmDependenciesCheck;
168
168
  });
@@ -252,7 +252,7 @@ class AbstractCommand {
252
252
  checkTrmDependencies() {
253
253
  return __awaiter(this, void 0, void 0, function* () {
254
254
  const trmDependenciesCheck = yield this.getTrmDependenciesCheck();
255
- const trmDependencies = Core.getCoreTrmDependencies();
255
+ const trmDependencies = Core.getCoreTrmDependencies(utils_1.GlobalContext.getInstance().getGlobalNodeModules());
256
256
  trmDependenciesCheck.missingDependencies.forEach(missingDependency => {
257
257
  if (this.onTrmDepMissing(missingDependency)) {
258
258
  throw new Error(`Package "${missingDependency}" is not installed on ${Core.SystemConnector.getDest()}.`);
@@ -4,8 +4,7 @@ export declare class Info extends AbstractCommand {
4
4
  protected init(): void;
5
5
  protected onTrmDepMissing(dependency: string): boolean;
6
6
  protected onTrmDepVersionNotSatisfied(trmPackage: TrmPackage): boolean;
7
- private getDependencyVersion;
8
- private getNodeRfcVersion;
9
7
  private getNpmLatestForText;
8
+ private flat;
10
9
  protected handler(): Promise<void>;
11
10
  }
@@ -21,7 +21,6 @@ const semver_1 = require("semver");
21
21
  const chalk_1 = __importDefault(require("chalk"));
22
22
  const fs_1 = require("fs");
23
23
  const path_1 = require("path");
24
- const get_root_path_1 = require("get-root-path");
25
24
  class Info extends AbstractCommand_1.AbstractCommand {
26
25
  init() {
27
26
  this.registerOpts.requiresConnection = true;
@@ -35,44 +34,21 @@ class Info extends AbstractCommand_1.AbstractCommand {
35
34
  onTrmDepVersionNotSatisfied(trmPackage) {
36
35
  return false;
37
36
  }
38
- getDependencyVersion(moduleName, rootModule = 'trm-client') {
39
- var file;
40
- try {
41
- file = (0, fs_1.readFileSync)((0, path_1.join)(get_root_path_1.rootPath, `/node_modules/${rootModule}/node_modules/${moduleName}/package.json`));
42
- }
43
- catch (e) {
44
- file = (0, fs_1.readFileSync)((0, path_1.join)(get_root_path_1.rootPath, `/node_modules/${moduleName}/package.json`));
45
- }
46
- if (!file) {
47
- trm_commons_1.Logger.warning(`Library ${moduleName} (root ${rootModule}) was not found!`, true);
48
- }
49
- else {
50
- return JSON.parse(file.toString()).version;
51
- }
52
- }
53
- getNodeRfcVersion(npmGlobal) {
54
- var file;
55
- try {
56
- file = (0, fs_1.readFileSync)((0, path_1.join)(npmGlobal, `/node-rfc/package.json`));
57
- }
58
- catch (e) {
59
- }
60
- if (!file) {
61
- trm_commons_1.Logger.warning(`Library node-rfc was not found!`, true);
62
- }
63
- else {
64
- return JSON.parse(file.toString()).version;
65
- }
66
- }
67
- getNpmLatestForText(packageName, installedVersion, text) {
37
+ getNpmLatestForText(packageName, installedVersion, range) {
68
38
  return __awaiter(this, void 0, void 0, function* () {
39
+ var text = ``;
69
40
  try {
70
- const latestVersion = yield (0, utils_1.getNpmPackageLatestVersion)(packageName);
71
- if ((0, semver_1.gte)(installedVersion, latestVersion)) {
72
- text += ` ${chalk_1.default.bgGreen('LATEST')}`;
41
+ const latestVersion = yield (0, utils_1.getNpmPackageLatestVersion)(packageName, range);
42
+ if ((0, semver_1.gte)(installedVersion, latestVersion.latest)) {
43
+ if (!(0, semver_1.eq)(latestVersion.latest, latestVersion.actualLatest)) {
44
+ text += ` ${chalk_1.default.bgGreen('LATEST COMPATIBLE')}`;
45
+ }
46
+ else {
47
+ text += ` ${chalk_1.default.bgGreen('LATEST')}`;
48
+ }
73
49
  }
74
50
  else {
75
- text += ` ${chalk_1.default.bold('v' + latestVersion + ' available')}`;
51
+ text += ` ${chalk_1.default.bold('v' + latestVersion.latest + ' available')}`;
76
52
  }
77
53
  }
78
54
  catch (e) {
@@ -81,43 +57,54 @@ class Info extends AbstractCommand_1.AbstractCommand {
81
57
  return text;
82
58
  });
83
59
  }
60
+ flat(deps, globalNodeModulesPath) {
61
+ var _a;
62
+ const isWanted = (k) => k.startsWith("trm-") || k === "node-r3trans";
63
+ const out = {};
64
+ const seen = new Set();
65
+ const q = Object.entries(deps).filter(([k]) => isWanted(k));
66
+ while (q.length) {
67
+ const [k, v] = q.pop();
68
+ if (seen.has(k))
69
+ continue;
70
+ seen.add(k);
71
+ const pkg = (0, trm_core_1.getNodePackage)(globalNodeModulesPath, k);
72
+ const installedVersion = pkg === null || pkg === void 0 ? void 0 : pkg.version;
73
+ if (!out[k]) {
74
+ out[k] = {
75
+ range: v,
76
+ installedVersion
77
+ };
78
+ }
79
+ const d = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) !== null && _a !== void 0 ? _a : {};
80
+ for (const [kk, vv] of Object.entries(d)) {
81
+ if (isWanted(kk) && !seen.has(kk)) {
82
+ q.push([kk, vv]);
83
+ }
84
+ }
85
+ }
86
+ return out;
87
+ }
84
88
  handler() {
85
89
  return __awaiter(this, void 0, void 0, function* () {
86
90
  trm_commons_1.Logger.loading(`Reading data...`);
87
- const npmGlobal = utils_1.GlobalContext.getInstance().getSettings().globalNodeModules;
91
+ const globalNodeModulesPath = utils_1.GlobalContext.getInstance().getGlobalNodeModules();
88
92
  const clientLatest = yield this.getCliVersionStatus();
89
93
  const clientVersion = (0, utils_1.getClientVersion)();
90
- const clientDependencies = (0, utils_1.getClientNodeDependencies)();
91
- const trmDependencies = (0, trm_core_1.getCoreTrmDependencies)();
94
+ const dependencies = this.flat((0, utils_1.getClientNodeDependencies)(), globalNodeModulesPath);
95
+ const trmDependencies = (0, trm_core_1.getCoreTrmDependencies)(globalNodeModulesPath);
92
96
  const trmDependenciesInstances = (yield this.getTrmDependenciesCheck()).dependencies;
93
97
  const trmMissingDependencies = (yield this.getTrmDependenciesCheck()).missingDependencies;
94
- const nodeRfcVersion = this.getNodeRfcVersion(npmGlobal);
98
+ const nodeRfcPackage = (0, utils_1.getNodeRfcPackage)();
95
99
  const packages = yield this.getSystemPackages();
96
100
  const trmRest = packages.find(o => o.compareName("trm-rest") && o.compareRegistry(trm_core_1.RegistryProvider.getRegistry()));
97
- var nodeR3transVersion;
98
- try {
99
- nodeR3transVersion = this.getDependencyVersion("node-r3trans", "trm-core");
100
- if (!nodeR3transVersion) {
101
- throw new Error();
102
- }
103
- }
104
- catch (e) {
105
- nodeR3transVersion = this.getDependencyVersion("node-r3trans");
106
- }
107
- var clientDependenciesTree = [];
108
- if (clientDependencies) {
109
- for (const d of Object.keys(clientDependencies).filter(k => k.startsWith('trm'))) {
110
- var dText = ``;
111
- var dInstalledVersion = this.getDependencyVersion(d);
112
- if (dInstalledVersion) {
113
- dText = ` -> ${dInstalledVersion}`;
114
- dText = yield this.getNpmLatestForText(d, dInstalledVersion, dText);
115
- }
116
- clientDependenciesTree.push({
117
- text: `${d} ${clientDependencies[d]}${dText}`,
118
- children: []
119
- });
120
- }
101
+ var dependenciesTree = [];
102
+ for (const d of Object.keys(dependencies)) {
103
+ const dText = ` -> ${dependencies[d].installedVersion} ${yield this.getNpmLatestForText(d, dependencies[d].installedVersion, dependencies[d].range)}`;
104
+ dependenciesTree.push({
105
+ text: `${d} ${dependencies[d].range}${dText}`,
106
+ children: []
107
+ });
121
108
  }
122
109
  var serverDependenciesTree = [];
123
110
  if (trmDependencies) {
@@ -135,9 +122,15 @@ class Info extends AbstractCommand_1.AbstractCommand {
135
122
  if (dInstalledVersion) {
136
123
  dText = ` -> ${dInstalledVersion}`;
137
124
  try {
138
- const dLatestVersion = (yield oTrmPackage.registry.getPackage(oTrmPackage.packageName, 'latest')).manifest.version;
139
- if ((0, semver_1.gte)(dInstalledVersion, dLatestVersion)) {
140
- dText += ` ${chalk_1.default.bgGreen('LATEST')}`;
125
+ const dLatestVersion = yield oTrmPackage.registry.getPackage(oTrmPackage.packageName, 'latest');
126
+ const dMax = (0, semver_1.maxSatisfying)(dLatestVersion.versions, trmDependencies[d]);
127
+ if ((0, semver_1.gte)(dInstalledVersion, dMax)) {
128
+ if (!(0, semver_1.eq)(dLatestVersion.dist_tags.latest, dMax)) {
129
+ dText += ` ${chalk_1.default.bgGreen('LATEST COMPATIBLE')}`;
130
+ }
131
+ else {
132
+ dText += ` ${chalk_1.default.bgGreen('LATEST')}`;
133
+ }
141
134
  }
142
135
  else {
143
136
  dText += ` ${chalk_1.default.bold('v' + dLatestVersion + ' available')}`;
@@ -179,11 +172,11 @@ class Info extends AbstractCommand_1.AbstractCommand {
179
172
  }
180
173
  var clientChildrenTree = [{
181
174
  text: `trm-client ${clientVersion} ${(0, semver_1.gte)(clientLatest.localVersion, clientLatest.latestVersion) ? chalk_1.default.bgGreen('LATEST') : chalk_1.default.bold('v' + clientLatest.latestVersion + ' available')}`,
182
- children: clientDependenciesTree
175
+ children: dependenciesTree
183
176
  }];
184
- if (nodeRfcVersion) {
177
+ if (nodeRfcPackage && nodeRfcPackage.version) {
185
178
  clientChildrenTree.push({
186
- text: yield this.getNpmLatestForText('node-rfc', nodeRfcVersion, `node-rfc ${nodeRfcVersion}`),
179
+ text: `node-rfc ${nodeRfcPackage.version} ${yield this.getNpmLatestForText('node-rfc', nodeRfcPackage.version)}`,
187
180
  children: []
188
181
  });
189
182
  }
@@ -193,18 +186,6 @@ class Info extends AbstractCommand_1.AbstractCommand {
193
186
  children: []
194
187
  });
195
188
  }
196
- if (nodeR3transVersion) {
197
- clientChildrenTree.push({
198
- text: yield this.getNpmLatestForText('node-r3trans', nodeR3transVersion, `node-r3trans ${nodeR3transVersion}`),
199
- children: []
200
- });
201
- }
202
- else {
203
- clientChildrenTree.push({
204
- text: `node-r3trans ${chalk_1.default.bold('not found')}`,
205
- children: []
206
- });
207
- }
208
189
  const clientTree = {
209
190
  text: chalk_1.default.bold(`Client`),
210
191
  children: clientChildrenTree
@@ -221,7 +202,7 @@ class Info extends AbstractCommand_1.AbstractCommand {
221
202
  try {
222
203
  const installedVersion = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(plugin.location, 'package.json')).toString()).version;
223
204
  pluginsTree.children.push({
224
- text: yield this.getNpmLatestForText(plugin.name, installedVersion, `${plugin.name} ${installedVersion}`),
205
+ text: `${plugin.name} ${installedVersion} ${yield this.getNpmLatestForText(plugin.name, installedVersion)}`,
225
206
  children: []
226
207
  });
227
208
  }
@@ -49,7 +49,6 @@ class Install extends AbstractCommand_1.AbstractCommand {
49
49
  this.command.argument(`<filename>`, `Name (or path) of the file.`);
50
50
  this.command.description(`Import a package (as a file) into system.`);
51
51
  }
52
- this.command.option(`-t, --timeout <seconds>`, `Transport import timeout (in seconds)`, `180`);
53
52
  this.command.option(`-T, --transport-layer <transport layer>`, `Package transport layer. (default: System default)`);
54
53
  this.command.option(`--no-deps`, `Do not install dependencies.`);
55
54
  this.command.option(`--no-obj-type`, `Do not check object types before import.`);
@@ -58,7 +57,7 @@ class Install extends AbstractCommand_1.AbstractCommand {
58
57
  this.command.option(`--no-lang-tr`, `Do not import language (translation) transport.`);
59
58
  this.command.option(`--no-cust-tr`, `Do not import customizing transports.`);
60
59
  this.command.option(`--no-install-tr`, `Do not create install transport.`);
61
- this.command.option(`--no-namespace`, `Do not import namespace.`);
60
+ this.command.option(`--namespace`, `Import customer namespace.`);
62
61
  this.command.option(`--package-replacements <replacements>`, `SAP Package replacements (JSON or path to JSON file)`);
63
62
  this.command.option(`--install-tr-target <target>`, `Install transport target system`);
64
63
  this.command.option(`--no-prompts`, `No prompts (will force some decisions).`);
@@ -177,7 +176,6 @@ class Install extends AbstractCommand_1.AbstractCommand {
177
176
  import: {
178
177
  noLang: !this.args.langTr,
179
178
  noCust: !this.args.custTr,
180
- timeout: this.parseNumberArg('timeout'),
181
179
  replaceExistingTransports: false
182
180
  },
183
181
  installDevclass: {
@@ -39,7 +39,6 @@ class Publish extends AbstractCommand_1.AbstractCommand {
39
39
  this.command.option(`--no-keep-manifest`, `Don't default to previous release manifest values.`);
40
40
  }
41
41
  this.command.option(`-P, --sap-package <sap package>`, `SAP Package.`);
42
- this.command.option(`-t, --timeout <seconds>`, `Transport release timeout (in seconds)`, `180`);
43
42
  this.command.option(`-T, --target <target>`, `Transport release target.`);
44
43
  this.command.option(`--no-lang-tr`, `Do not generate language (translation) transport.`);
45
44
  this.command.option(`--no-cust-tr`, `Do not generate customizing transport.`);
@@ -134,7 +133,6 @@ class Publish extends AbstractCommand_1.AbstractCommand {
134
133
  readme: this.parseTextArg('readme')
135
134
  },
136
135
  systemData: {
137
- releaseTimeout: this.parseNumberArg('timeout'),
138
136
  transportTarget: this.args.target
139
137
  }
140
138
  });
@@ -71,13 +71,13 @@ function connect(commandArgs_1) {
71
71
  const force = commandArgs.force ? true : false;
72
72
  var type = commandArgs.type;
73
73
  var aInputType = [];
74
- var aSapLogonConnections;
74
+ var aSapLogonConnections = [];
75
75
  const aAlias = systemAlias_1.SystemAlias.getAll();
76
- try {
77
- aSapLogonConnections = yield (0, utils_1.getSapLogonConnections)();
78
- }
79
- catch (e) {
80
- aSapLogonConnections = [];
76
+ if ((0, utils_1.getNodeRfcPackage)()) {
77
+ try {
78
+ aSapLogonConnections = yield (0, utils_1.getSapLogonConnections)();
79
+ }
80
+ catch (_a) { }
81
81
  }
82
82
  if (addNoConnection) {
83
83
  aInputType.push({
@@ -58,7 +58,7 @@ class RegistryAlias {
58
58
  return this;
59
59
  }
60
60
  getRegistry() {
61
- return new trm_core_1.RegistryV2(this._endpoint, this._name);
61
+ return new trm_core_1.RegistryV2(this._endpoint, this._name, (0, utils_1.getCoreVersion)());
62
62
  }
63
63
  static generateFile(content, filePath) {
64
64
  if (!filePath) {
@@ -4,4 +4,5 @@ export type Cache = {
4
4
  };
5
5
  export type CacheData = {
6
6
  latestVersion?: Cache;
7
+ globalNpmPath?: Cache;
7
8
  };
@@ -7,7 +7,7 @@ export declare class DummyConnector implements ISystemConnector {
7
7
  getLogonLanguage: (c: boolean) => "X" | "XX";
8
8
  getLogonUser: () => string;
9
9
  connect: () => Promise<void>;
10
- closeConnection: () => Promise<any>;
10
+ closeConnection: () => Promise<void>;
11
11
  checkConnection: () => Promise<boolean>;
12
12
  ping: () => Promise<string>;
13
13
  getFileSystem: () => Promise<any>;
@@ -88,4 +88,6 @@ export declare class DummyConnector implements ISystemConnector {
88
88
  getObjectDependencies: () => Promise<any>;
89
89
  getTableKeys: () => Promise<any>;
90
90
  getRootDevclass: () => Promise<any>;
91
+ getTransportImportStatus: () => Promise<any>;
92
+ getTimezone: () => Promise<string>;
91
93
  }
@@ -30,7 +30,9 @@ class DummyConnector {
30
30
  this.connect = () => __awaiter(this, void 0, void 0, function* () {
31
31
  return;
32
32
  });
33
- this.closeConnection = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
33
+ this.closeConnection = () => __awaiter(this, void 0, void 0, function* () {
34
+ return;
35
+ });
34
36
  this.checkConnection = () => __awaiter(this, void 0, void 0, function* () { return true; });
35
37
  this.ping = () => __awaiter(this, void 0, void 0, function* () { return 'PONG'; });
36
38
  this.getFileSystem = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
@@ -115,6 +117,10 @@ class DummyConnector {
115
117
  this.getObjectDependencies = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
116
118
  this.getTableKeys = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
117
119
  this.getRootDevclass = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
120
+ this.getTransportImportStatus = () => __awaiter(this, void 0, void 0, function* () { return this._throw(); });
121
+ this.getTimezone = () => __awaiter(this, void 0, void 0, function* () {
122
+ return 'UTC';
123
+ });
118
124
  }
119
125
  _throw() {
120
126
  throw new Error(`No connection to SAP server.`);
@@ -1,4 +1,3 @@
1
- import { CacheData } from ".";
2
1
  import { SettingsData } from ".";
3
2
  import { IConnect, PluginModule } from "trm-commons";
4
3
  export declare class GlobalContext {
@@ -10,7 +9,8 @@ export declare class GlobalContext {
10
9
  private _plugins;
11
10
  constructor();
12
11
  getSettings(): SettingsData;
13
- getCache(): CacheData;
12
+ getGlobalNodeModules(): string;
13
+ getLatestVersion(): string;
14
14
  load(): Promise<void>;
15
15
  getPlugins(): PluginModule[];
16
16
  getConnections(): IConnect[];
@@ -21,6 +21,7 @@ export declare class GlobalContext {
21
21
  private getSettingsFilePath;
22
22
  private getCacheFilePath;
23
23
  private getDefaultSettings;
24
+ private setGlobalNpmPathInternal;
24
25
  private getSettingsInternal;
25
26
  private getCacheInternal;
26
27
  private generateSettingsFile;
@@ -63,7 +63,7 @@ class RESTConnectExtended extends trm_commons_1.RESTConnect {
63
63
  class RFCConnectExtended extends trm_commons_1.RFCConnect {
64
64
  getSystemConnector() {
65
65
  const data = this.getData();
66
- return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)(), GlobalContext.getInstance().getSettings().globalNodeModules);
66
+ return new trm_core_1.RFCSystemConnector(data, data, (0, _1.getTempFolder)(), GlobalContext.getInstance().getGlobalNodeModules());
67
67
  }
68
68
  }
69
69
  class GlobalContext {
@@ -83,15 +83,32 @@ class GlobalContext {
83
83
  getSettings() {
84
84
  return this._settings;
85
85
  }
86
- getCache() {
87
- return this._cache;
86
+ getGlobalNodeModules() {
87
+ if (!this._cache.globalNpmPath) {
88
+ this.setGlobalNpmPathInternal();
89
+ }
90
+ return this._cache.globalNpmPath.data;
91
+ }
92
+ getLatestVersion() {
93
+ return this._cache.latestVersion.data;
88
94
  }
89
95
  load() {
90
96
  return __awaiter(this, void 0, void 0, function* () {
97
+ this.setGlobalNpmPathInternal();
98
+ const latestVersionCache = this._cache.latestVersion;
99
+ if (!latestVersionCache || (latestVersionCache.ts && Date.now() - latestVersionCache.ts > this.getSettings().cliUpdateCheckCache * 1000)) {
100
+ trm_commons_1.Logger.loading(`Cache expired, setting client latest version...`, true);
101
+ const version = (yield (0, _1.getNpmPackageLatestVersion)('trm-client')).latest;
102
+ trm_commons_1.Logger.log(`Client latest version set to ${version}`, true);
103
+ this.setCache('latestVersion', version);
104
+ }
91
105
  if (!this._pluginsLoaded) {
106
+ trm_commons_1.Logger.loading(`Loading plugins...`, true);
92
107
  this._plugins = yield trm_commons_1.Plugin.load({
93
- globalNodeModulesPath: this._settings.globalNodeModules
108
+ globalNodeModulesPath: this.getGlobalNodeModules()
94
109
  });
110
+ trm_commons_1.Logger.log(`Loaded ${this._plugins.length} plugins: ${this._plugins.map(o => o.name).join(', ')}`, true);
111
+ trm_commons_1.Logger.loading(`Calling event onContextLoadConnections...`, true);
95
112
  this._connections = yield trm_commons_1.Plugin.call("client", "onContextLoadConnections", [new RESTConnectExtended(), new RFCConnectExtended()]);
96
113
  this._pluginsLoaded = true;
97
114
  }
@@ -132,39 +149,62 @@ class GlobalContext {
132
149
  return path_1.default.join((0, _1.getRoamingFolder)(), CACHE_FILE_NAME);
133
150
  }
134
151
  getDefaultSettings() {
135
- var sapLandscape = path_1.default.join((0, _1.getRoamingPath)(), process.platform === 'win32' ? 'SAP\\Common\\SAPUILandscape.xml' : 'SAP/SAPGUILandscape.xml');
136
- if (!fs.existsSync(sapLandscape)) {
152
+ var sapLandscape;
153
+ switch (process.platform) {
154
+ case 'win32':
155
+ sapLandscape = path_1.default.join((0, _1.getRoamingPath)(), 'SAP', 'Common', 'SAPUILandscape.xml');
156
+ break;
157
+ case 'darwin':
158
+ sapLandscape = path_1.default.join((0, _1.getRoamingPath)(), 'SAP', 'SAPGUILandscape.xml');
159
+ break;
160
+ default:
161
+ break;
162
+ }
163
+ if (!sapLandscape || !fs.existsSync(sapLandscape)) {
137
164
  sapLandscape = undefined;
138
165
  }
139
166
  return {
140
167
  loggerType: 'CLI',
141
168
  logOutputFolder: 'default',
142
- globalNodeModules: (0, trm_commons_1.getGlobalNodeModules)() || '',
169
+ cliUpdateCheckCache: 60,
170
+ npmGlobalPathCheckCache: 180,
143
171
  sapLandscape
144
172
  };
145
173
  }
174
+ setGlobalNpmPathInternal() {
175
+ const globalNpmPathCache = this._cache.globalNpmPath;
176
+ if (!globalNpmPathCache || (globalNpmPathCache.ts && Date.now() - globalNpmPathCache.ts > this.getSettings().npmGlobalPathCheckCache * 1000)) {
177
+ trm_commons_1.Logger.loading(`Cache expired, setting npm global modules path...`, true);
178
+ const path = (0, trm_commons_1.getGlobalNodeModules)();
179
+ trm_commons_1.Logger.log(`Npm global modules path set to ${path}`, true);
180
+ this.setCache('globalNpmPath', path);
181
+ }
182
+ }
146
183
  getSettingsInternal() {
147
- var defaultSettings;
184
+ const defaultSettings = this.getDefaultSettings();
148
185
  const filePath = this.getSettingsFilePath();
149
- if (fs.existsSync(filePath)) {
150
- try {
151
- const sIni = fs.readFileSync(filePath).toString();
152
- const settingsData = ini.decode(sIni);
153
- if (!settingsData.globalNodeModules || !settingsData.sapLandscape) {
154
- defaultSettings = this.getDefaultSettings();
155
- if (!settingsData.globalNodeModules) {
156
- settingsData.globalNodeModules = defaultSettings.globalNodeModules;
157
- }
158
- if (!settingsData.sapLandscape) {
159
- settingsData.sapLandscape = defaultSettings.sapLandscape;
160
- }
161
- this.generateSettingsFile(settingsData, filePath);
162
- }
163
- return settingsData;
186
+ try {
187
+ const sIni = fs.readFileSync(filePath).toString();
188
+ const settingsData = ini.decode(sIni);
189
+ if (!settingsData.sapLandscape) {
190
+ settingsData.sapLandscape = defaultSettings.sapLandscape;
191
+ this.generateSettingsFile(settingsData, filePath);
164
192
  }
165
- catch (e) { }
193
+ if (!settingsData.cliUpdateCheckCache) {
194
+ settingsData.cliUpdateCheckCache = defaultSettings.cliUpdateCheckCache;
195
+ this.generateSettingsFile(settingsData, filePath);
196
+ }
197
+ if (!settingsData.npmGlobalPathCheckCache) {
198
+ settingsData.npmGlobalPathCheckCache = defaultSettings.npmGlobalPathCheckCache;
199
+ this.generateSettingsFile(settingsData, filePath);
200
+ }
201
+ if (settingsData.globalNodeModules) {
202
+ delete settingsData.globalNodeModules;
203
+ this.generateSettingsFile(settingsData, filePath);
204
+ }
205
+ return settingsData;
166
206
  }
167
- defaultSettings = this.getDefaultSettings();
207
+ catch (e) { }
168
208
  this.generateSettingsFile(defaultSettings, filePath);
169
209
  return defaultSettings;
170
210
  }
@@ -1,7 +1,8 @@
1
1
  export type SettingsData = {
2
2
  loggerType: string;
3
3
  logOutputFolder: string;
4
- globalNodeModules: string;
4
+ cliUpdateCheckCache: number;
5
+ npmGlobalPathCheckCache: number;
5
6
  sapLandscape?: string;
6
7
  r3transDocker?: boolean;
7
8
  r3transDockerName?: string;
@@ -16,26 +16,17 @@ exports.checkCliUpdate = checkCliUpdate;
16
16
  const semver_1 = require("semver");
17
17
  const getClientVersion_1 = require("./getClientVersion");
18
18
  const chalk_1 = __importDefault(require("chalk"));
19
- const getNpmPackageLatestVersion_1 = require("./getNpmPackageLatestVersion");
20
19
  const trm_commons_1 = require("trm-commons");
21
20
  const GlobalContext_1 = require("./GlobalContext");
22
21
  function checkCliUpdate(print) {
23
22
  return __awaiter(this, void 0, void 0, function* () {
24
23
  try {
25
- var latestVersion;
26
- const cache = GlobalContext_1.GlobalContext.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
- GlobalContext_1.GlobalContext.getInstance().setCache('latestVersion', latestVersion);
33
- }
24
+ const latestVersion = GlobalContext_1.GlobalContext.getInstance().getLatestVersion();
34
25
  const localVersion = (0, getClientVersion_1.getClientVersion)();
35
26
  const versionDiff = (0, semver_1.diff)(localVersion, latestVersion);
36
27
  if ((versionDiff === 'minor' || versionDiff === 'major') && (0, semver_1.gt)(latestVersion, localVersion)) {
37
28
  if (print) {
38
- trm_commons_1.Logger.warning(`A newer release of trm-client (v${chalk_1.default.bold(latestVersion)}) is available.`);
29
+ trm_commons_1.Logger.warning(`A new ${chalk_1.default.bold(versionDiff)} release of trm-client (v${chalk_1.default.bold(latestVersion)}) is available.`);
39
30
  trm_commons_1.Logger.warning(`New releases can introduce features and bug fixes.`);
40
31
  trm_commons_1.Logger.warning(`It is recommended to update your client by running the command`);
41
32
  trm_commons_1.Logger.warning(` ${chalk_1.default.bold('trm update')}`);
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getClientNodeDependencies = getClientNodeDependencies;
4
4
  const trm_core_1 = require("trm-core");
5
+ const GlobalContext_1 = require("./GlobalContext");
5
6
  function getClientNodeDependencies() {
6
- const trmClientPackage = (0, trm_core_1.getNodePackage)("trm-client");
7
+ const trmClientPackage = (0, trm_core_1.getNodePackage)(GlobalContext_1.GlobalContext.getInstance().getGlobalNodeModules(), "trm-client");
7
8
  return trmClientPackage.dependencies || {};
8
9
  }
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getClientVersion = getClientVersion;
4
4
  const trm_core_1 = require("trm-core");
5
+ const GlobalContext_1 = require("./GlobalContext");
5
6
  function getClientVersion() {
6
- const trmClientPackage = (0, trm_core_1.getNodePackage)("trm-client");
7
+ const trmClientPackage = (0, trm_core_1.getNodePackage)(GlobalContext_1.GlobalContext.getInstance().getGlobalNodeModules(), "trm-client");
7
8
  return trmClientPackage.version;
8
9
  }
@@ -0,0 +1 @@
1
+ export declare function getCoreVersion(): string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCoreVersion = getCoreVersion;
4
+ const trm_core_1 = require("trm-core");
5
+ const GlobalContext_1 = require("./GlobalContext");
6
+ function getCoreVersion() {
7
+ const trmCorePackage = (0, trm_core_1.getNodePackage)(GlobalContext_1.GlobalContext.getInstance().getGlobalNodeModules());
8
+ return trmCorePackage.version;
9
+ }
@@ -0,0 +1 @@
1
+ export declare function getNodeRfcPackage(): any;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNodeRfcPackage = getNodeRfcPackage;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const GlobalContext_1 = require("./GlobalContext");
7
+ function getNodeRfcPackage() {
8
+ try {
9
+ return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(GlobalContext_1.GlobalContext.getInstance().getGlobalNodeModules(), `/node-rfc/package.json`)).toString());
10
+ }
11
+ catch (_a) { }
12
+ }
@@ -1 +1,4 @@
1
- export declare function getNpmPackageLatestVersion(packageName: string): Promise<string>;
1
+ export declare function getNpmPackageLatestVersion(packageName: string, range?: string): Promise<{
2
+ actualLatest: string;
3
+ latest: string;
4
+ }>;
@@ -14,9 +14,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getNpmPackageLatestVersion = getNpmPackageLatestVersion;
16
16
  const axios_1 = __importDefault(require("axios"));
17
- function getNpmPackageLatestVersion(packageName) {
17
+ const semver_1 = require("semver");
18
+ function getNpmPackageLatestVersion(packageName, range) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
19
20
  const response = yield axios_1.default.get(`https://registry.npmjs.org/${packageName}`);
20
- return response.data['dist-tags'].latest;
21
+ const actualLatest = response.data['dist-tags'].latest;
22
+ if (!range) {
23
+ return { actualLatest, latest: actualLatest };
24
+ }
25
+ else {
26
+ return {
27
+ latest: (0, semver_1.maxSatisfying)(Object.keys(response.data.versions || {}), range),
28
+ actualLatest
29
+ };
30
+ }
21
31
  });
22
32
  }
@@ -5,6 +5,7 @@ export * from "./getSapLogonConnections";
5
5
  export * from "./logError";
6
6
  export * from "./checkCliUpdate";
7
7
  export * from "./getClientVersion";
8
+ export * from "./getCoreVersion";
8
9
  export * from "./getTempFolder";
9
10
  export * from "./getLogFolder";
10
11
  export * from "./getClientNodeDependencies";
@@ -14,3 +15,4 @@ export * from "./SettingsData";
14
15
  export * from "./CacheData";
15
16
  export * from "./GlobalContext";
16
17
  export * from "./isDockerRunning";
18
+ export * from "./getNodeRfcPackage";
@@ -21,6 +21,7 @@ __exportStar(require("./getSapLogonConnections"), exports);
21
21
  __exportStar(require("./logError"), exports);
22
22
  __exportStar(require("./checkCliUpdate"), exports);
23
23
  __exportStar(require("./getClientVersion"), exports);
24
+ __exportStar(require("./getCoreVersion"), exports);
24
25
  __exportStar(require("./getTempFolder"), exports);
25
26
  __exportStar(require("./getLogFolder"), exports);
26
27
  __exportStar(require("./getClientNodeDependencies"), exports);
@@ -30,3 +31,4 @@ __exportStar(require("./SettingsData"), exports);
30
31
  __exportStar(require("./CacheData"), exports);
31
32
  __exportStar(require("./GlobalContext"), exports);
32
33
  __exportStar(require("./isDockerRunning"), exports);
34
+ __exportStar(require("./getNodeRfcPackage"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-client",
3
- "version": "7.3.4",
3
+ "version": "7.4.0",
4
4
  "description": "TRM (Transport Request Manager) Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,18 +42,17 @@
42
42
  "commander": "^11.0.0",
43
43
  "dotenv": "^17.2.2",
44
44
  "execa": "^9.6.0",
45
- "get-root-path": "^2.0.2",
46
45
  "i": "^0.3.7",
47
46
  "ini": "^4.1.1",
48
47
  "lodash": "^4.17.21",
49
- "semver": "^7.5.4",
50
- "trm-commons": "^3.5.0",
51
- "trm-core": "^8.3.0",
48
+ "semver": "^7.7.4",
49
+ "trm-commons": "^3.5.1",
50
+ "trm-core": "^8.4.0",
52
51
  "trm-registry-types": "^2.1.0",
53
52
  "xml2js": "^0.6.2"
54
53
  },
55
54
  "peerDependencies": {
56
- "trm-commons": "^3.5.0"
55
+ "trm-commons": "^3.5.1"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@types/ini": "^1.3.31",