trm-client 9.4.1 → 10.0.1

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 (67) hide show
  1. package/changelog.txt +19 -0
  2. package/dist/command/AbstractCommand.d.ts +9 -4
  3. package/dist/command/AbstractCommand.js +82 -34
  4. package/dist/command/implementations/Alias.d.ts +2 -1
  5. package/dist/command/implementations/Alias.js +45 -13
  6. package/dist/command/implementations/Cg3y.d.ts +2 -1
  7. package/dist/command/implementations/Cg3y.js +19 -7
  8. package/dist/command/implementations/Cg3z.d.ts +2 -1
  9. package/dist/command/implementations/Cg3z.js +19 -7
  10. package/dist/command/implementations/ClearCache.d.ts +2 -1
  11. package/dist/command/implementations/ClearCache.js +11 -3
  12. package/dist/command/implementations/Compare.d.ts +2 -1
  13. package/dist/command/implementations/Compare.js +20 -7
  14. package/dist/command/implementations/Content.d.ts +2 -1
  15. package/dist/command/implementations/Content.js +22 -9
  16. package/dist/command/implementations/Deprecate.d.ts +2 -1
  17. package/dist/command/implementations/Deprecate.js +19 -7
  18. package/dist/command/implementations/Dirty.d.ts +2 -1
  19. package/dist/command/implementations/Dirty.js +21 -8
  20. package/dist/command/implementations/DistTag.d.ts +2 -1
  21. package/dist/command/implementations/DistTag.js +40 -14
  22. package/dist/command/implementations/FindDependencies.d.ts +2 -1
  23. package/dist/command/implementations/FindDependencies.js +21 -8
  24. package/dist/command/implementations/Info.d.ts +2 -1
  25. package/dist/command/implementations/Info.js +16 -6
  26. package/dist/command/implementations/Install.d.ts +4 -1
  27. package/dist/command/implementations/Install.js +118 -43
  28. package/dist/command/implementations/List.d.ts +2 -1
  29. package/dist/command/implementations/List.js +19 -6
  30. package/dist/command/implementations/Lock.d.ts +2 -1
  31. package/dist/command/implementations/Lock.js +21 -8
  32. package/dist/command/implementations/Login.d.ts +2 -1
  33. package/dist/command/implementations/Login.js +26 -8
  34. package/dist/command/implementations/Logout.d.ts +2 -1
  35. package/dist/command/implementations/Logout.js +17 -7
  36. package/dist/command/implementations/Ping.d.ts +2 -1
  37. package/dist/command/implementations/Ping.js +15 -5
  38. package/dist/command/implementations/Publish.d.ts +3 -1
  39. package/dist/command/implementations/Publish.js +70 -40
  40. package/dist/command/implementations/Registry.d.ts +2 -1
  41. package/dist/command/implementations/Registry.js +41 -12
  42. package/dist/command/implementations/Settings.d.ts +2 -1
  43. package/dist/command/implementations/Settings.js +18 -6
  44. package/dist/command/implementations/Unpublish.d.ts +2 -1
  45. package/dist/command/implementations/Unpublish.js +18 -6
  46. package/dist/command/implementations/View.d.ts +2 -1
  47. package/dist/command/implementations/View.js +22 -11
  48. package/dist/command/implementations/WhoAmI.d.ts +2 -1
  49. package/dist/command/implementations/WhoAmI.js +17 -7
  50. package/dist/command/implementations/index.d.ts +27 -0
  51. package/dist/command/implementations/index.js +65 -0
  52. package/dist/command/index.d.ts +2 -0
  53. package/dist/command/index.js +2 -0
  54. package/dist/command/metadata/CommandMetadata.d.ts +57 -0
  55. package/dist/command/metadata/CommandMetadata.js +2 -0
  56. package/dist/command/metadata/applyCommandMetadata.d.ts +3 -0
  57. package/dist/command/metadata/applyCommandMetadata.js +26 -0
  58. package/dist/command/metadata/helpers.d.ts +6 -0
  59. package/dist/command/metadata/helpers.js +45 -0
  60. package/dist/command/metadata/index.d.ts +3 -0
  61. package/dist/command/metadata/index.js +19 -0
  62. package/dist/command/runCommandHandler.d.ts +2 -0
  63. package/dist/command/runCommandHandler.js +24 -0
  64. package/dist/utils/GlobalContext.d.ts +3 -1
  65. package/dist/utils/GlobalContext.js +28 -20
  66. package/dist/utils/SettingsData.d.ts +4 -0
  67. package/package.json +4 -5
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.argument = argument;
4
+ exports.option = option;
5
+ function argument(position, args) {
6
+ var _a, _b;
7
+ return {
8
+ kind: "argument",
9
+ position,
10
+ name: args.name,
11
+ cliName: args.cliName,
12
+ label: args.label,
13
+ description: args.description,
14
+ required: (_a = args.required) !== null && _a !== void 0 ? _a : true,
15
+ control: (_b = args.control) !== null && _b !== void 0 ? _b : "text-input",
16
+ pickerType: args.pickerType,
17
+ defaultValue: args.defaultValue,
18
+ choices: args.choices,
19
+ placeholder: args.placeholder,
20
+ multiple: args.multiple,
21
+ sensitive: args.sensitive,
22
+ guiRelevant: args.guiRelevant
23
+ };
24
+ }
25
+ function option(flags, args) {
26
+ var _a, _b;
27
+ return {
28
+ kind: "option",
29
+ flags,
30
+ negated: args.negated,
31
+ name: args.name,
32
+ cliName: args.cliName,
33
+ label: args.label,
34
+ description: args.description,
35
+ required: (_a = args.required) !== null && _a !== void 0 ? _a : false,
36
+ control: (_b = args.control) !== null && _b !== void 0 ? _b : "text-input",
37
+ pickerType: args.pickerType,
38
+ defaultValue: args.defaultValue,
39
+ choices: args.choices,
40
+ placeholder: args.placeholder,
41
+ multiple: args.multiple,
42
+ sensitive: args.sensitive,
43
+ guiRelevant: args.guiRelevant
44
+ };
45
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./CommandMetadata";
2
+ export * from "./applyCommandMetadata";
3
+ export * from "./helpers";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CommandMetadata"), exports);
18
+ __exportStar(require("./applyCommandMetadata"), exports);
19
+ __exportStar(require("./helpers"), exports);
@@ -0,0 +1,2 @@
1
+ export type CommandHandlerValues = Record<string, unknown>;
2
+ export declare function runCommandHandler(id: string, values?: CommandHandlerValues): Promise<void>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runCommandHandler = runCommandHandler;
13
+ const implementations_1 = require("./implementations");
14
+ function runCommandHandler(id_1) {
15
+ return __awaiter(this, arguments, void 0, function* (id, values = {}) {
16
+ const commandClass = (0, implementations_1.getCommand)(id);
17
+ const metadata = (0, implementations_1.getCommandMetadata)(id);
18
+ if (!commandClass || !metadata) {
19
+ throw new Error(`Unknown command metadata id "${id}".`);
20
+ }
21
+ const command = new commandClass(metadata.command, metadata.aliases, metadata.subcommand);
22
+ yield command.run(values);
23
+ });
24
+ }
@@ -7,7 +7,6 @@ export declare class GlobalContext {
7
7
  private _cache;
8
8
  private _connections;
9
9
  private _plugins;
10
- private _dockerized;
11
10
  constructor();
12
11
  getSettings(): SettingsData;
13
12
  getGlobalNodeModules(): string;
@@ -26,6 +25,9 @@ export declare class GlobalContext {
26
25
  private getSettingsInternal;
27
26
  clearCache(): void;
28
27
  private getCacheInternal;
28
+ private isCacheData;
29
+ private isCacheEntryValid;
30
+ private isStringCacheEntryValid;
29
31
  private generateSettingsFile;
30
32
  private generateCacheFile;
31
33
  static getInstance(): GlobalContext;
@@ -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 registryAlias_1 = require("../registryAlias");
55
56
  const CACHE_FILE_NAME = ".cache";
56
57
  const SETTINGS_FILE_NAME = "settings.ini";
57
58
  class RESTConnectExtended extends trm_commons_1.RESTConnect {
@@ -71,7 +72,6 @@ class GlobalContext {
71
72
  this._pluginsLoaded = false;
72
73
  this._connections = [];
73
74
  this._plugins = [];
74
- this._dockerized = process.env.TRM_DOCKERIZED === 'true';
75
75
  this._settings = this.getSettingsInternal();
76
76
  this._cache = this.getCacheInternal();
77
77
  if (typeof (this._settings.r3transDocker) !== 'boolean') {
@@ -85,19 +85,22 @@ class GlobalContext {
85
85
  return this._settings;
86
86
  }
87
87
  getGlobalNodeModules() {
88
- if (!this._cache.globalNpmPath) {
88
+ if (!this.isStringCacheEntryValid(this._cache.globalNpmPath, this.getSettings().npmGlobalPathCheckCache)) {
89
89
  this.setGlobalNpmPathInternal();
90
90
  }
91
91
  return this._cache.globalNpmPath.data;
92
92
  }
93
93
  getLatestVersion() {
94
+ if (!this.isStringCacheEntryValid(this._cache.latestVersion)) {
95
+ throw new Error(`Client latest version cache is not loaded.`);
96
+ }
94
97
  return this._cache.latestVersion.data;
95
98
  }
96
99
  load() {
97
100
  return __awaiter(this, void 0, void 0, function* () {
98
101
  this.setGlobalNpmPathInternal();
99
102
  const latestVersionCache = this._cache.latestVersion;
100
- if (!latestVersionCache || (latestVersionCache.ts && Date.now() - latestVersionCache.ts > this.getSettings().cliUpdateCheckCache * 1000)) {
103
+ if (!this.isStringCacheEntryValid(latestVersionCache, this.getSettings().cliUpdateCheckCache)) {
101
104
  trm_commons_1.Logger.loading(`Cache expired, setting client latest version...`, true);
102
105
  const version = (yield (0, _1.getNpmPackageLatestVersion)('trm-client')).latest;
103
106
  trm_commons_1.Logger.log(`Client latest version set to ${version}`, true);
@@ -164,29 +167,22 @@ class GlobalContext {
164
167
  if (!sapLandscape || !fs.existsSync(sapLandscape)) {
165
168
  sapLandscape = undefined;
166
169
  }
170
+ const registryAliases = registryAlias_1.RegistryAlias.getAll();
167
171
  return {
168
172
  loggerType: 'CLI',
169
173
  logOutputFolder: 'default',
170
174
  cliUpdateCheckCache: 60,
171
175
  npmGlobalPathCheckCache: 180,
176
+ guiRegistryAutoconnect: registryAliases.length === 1,
177
+ guiRegistryAutoconnectAlias: registryAliases.length === 1 ? registryAliases[0].alias : undefined,
178
+ guiSystemAutoconnect: false,
172
179
  sapLandscape
173
180
  };
174
181
  }
175
182
  setGlobalNpmPathInternal() {
176
183
  var path;
177
- if (this._dockerized) {
178
- trm_commons_1.Logger.log(`TRM running in docker environment, ignoring cache and recalculating NPM global path`, true);
179
- path = (0, trm_commons_1.getGlobalNodeModules)();
180
- this._cache['globalNpmPath'] = {
181
- ts: -1,
182
- data: path
183
- };
184
- trm_commons_1.Logger.log(`Npm global modules path set to ${path}`, true);
185
- return;
186
- }
187
184
  const globalNpmPathCache = this._cache.globalNpmPath;
188
- const isValid = !!globalNpmPathCache && !!globalNpmPathCache.ts && (Date.now() - globalNpmPathCache.ts) < this.getSettings().npmGlobalPathCheckCache * 1000;
189
- if (isValid) {
185
+ if (this.isStringCacheEntryValid(globalNpmPathCache, this.getSettings().npmGlobalPathCheckCache)) {
190
186
  return globalNpmPathCache.data;
191
187
  }
192
188
  trm_commons_1.Logger.loading(`Cache expired, setting npm global modules path...`, true);
@@ -224,23 +220,35 @@ class GlobalContext {
224
220
  }
225
221
  clearCache() {
226
222
  const filePath = this.getCacheFilePath();
227
- this.generateCacheFile({}, filePath);
223
+ this._cache = {};
224
+ this.generateCacheFile(this._cache, filePath);
228
225
  }
229
226
  getCacheInternal() {
230
227
  const filePath = this.getCacheFilePath();
231
228
  if (fs.existsSync(filePath)) {
232
229
  try {
233
- var data = JSON.parse(fs.readFileSync(filePath).toString());
234
- if (this._dockerized) {
235
- delete data.globalNpmPath;
230
+ const data = JSON.parse(fs.readFileSync(filePath).toString());
231
+ if (this.isCacheData(data)) {
232
+ return data;
236
233
  }
237
- return data;
238
234
  }
239
235
  catch (e) { }
240
236
  }
241
237
  this.generateCacheFile({}, filePath);
242
238
  return {};
243
239
  }
240
+ isCacheData(data) {
241
+ return !!data && typeof data === 'object' && !Array.isArray(data);
242
+ }
243
+ isCacheEntryValid(cache, ttlSeconds) {
244
+ if (!cache || typeof cache !== 'object' || typeof cache.ts !== 'number' || Number.isNaN(cache.ts) || cache.data === undefined || cache.data === null) {
245
+ return false;
246
+ }
247
+ return ttlSeconds === undefined || Date.now() - cache.ts < ttlSeconds * 1000;
248
+ }
249
+ isStringCacheEntryValid(cache, ttlSeconds) {
250
+ return this.isCacheEntryValid(cache, ttlSeconds) && typeof cache.data === 'string' && cache.data.length > 0;
251
+ }
244
252
  generateSettingsFile(data, filePath) {
245
253
  fs.writeFileSync(filePath, ini.encode(data), { encoding: 'utf8', flag: 'w' });
246
254
  }
@@ -3,6 +3,10 @@ export type SettingsData = {
3
3
  logOutputFolder: string;
4
4
  cliUpdateCheckCache: number;
5
5
  npmGlobalPathCheckCache: number;
6
+ guiRegistryAutoconnect: boolean;
7
+ guiRegistryAutoconnectAlias?: string;
8
+ guiSystemAutoconnect: boolean;
9
+ guiSystemAutoconnectAlias?: string;
6
10
  sapLandscape?: string;
7
11
  r3transDocker?: boolean;
8
12
  r3transDockerName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-client",
3
- "version": "9.4.1",
3
+ "version": "10.0.1",
4
4
  "description": "TRM (Transport Request Manager) Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,19 +41,18 @@
41
41
  "chalk": "^4.1.2",
42
42
  "commander": "^11.0.0",
43
43
  "dotenv": "^17.2.2",
44
- "execa": "^9.6.0",
45
44
  "i": "^0.3.7",
46
45
  "ini": "^4.1.1",
47
46
  "lodash": "^4.17.21",
48
47
  "sanitize-filename": "^1.6.3",
49
48
  "semver": "^7.7.4",
50
- "trm-commons": "^5.0.0",
51
- "trm-core": "^9.8.0",
49
+ "trm-commons": "^5.0.1",
50
+ "trm-core": "^9.8.1",
52
51
  "trm-registry-types": "^2.1.0",
53
52
  "xml2js": "^0.6.2"
54
53
  },
55
54
  "peerDependencies": {
56
- "trm-commons": "^5.0.0"
55
+ "trm-commons": "^5.0.1"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@types/ini": "^1.3.31",