@sap/cli-core 2024.14.0 → 2024.16.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.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 2024.15.0
9
+
10
+ ### Changed
11
+
12
+ - When running `<cli> --version` in the past, the CLI exited with exit code `1`. Since this version the CLI now exits with exit code `0` instead.
13
+
14
+ ### Fixed
15
+
16
+ - When using option `--input` with sequential commands and an array is provided as a value, the previous provided array is not overridden, but the previous data was merged with the current data.
17
+
8
18
  ## 2024.11.0
9
19
 
10
20
  ### Added
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSecretConsistent = exports.getTenantUrl = exports.isCustomClient = void 0;
3
+ exports.getTenantUrl = exports.isCustomClient = void 0;
4
+ exports.isSecretConsistent = isSecretConsistent;
4
5
  const config_1 = require("../../config");
5
6
  const constants_1 = require("../../constants");
6
7
  // Pre-delivered OAuth Client ID: 5a638330-5899-366e-ac00-ab62cc32dcda
@@ -23,4 +24,3 @@ function isSecretConsistent(secret) {
23
24
  (!!secret.access_token ||
24
25
  (!!secret.refresh_token && !!secret.client_id && !!secret.client_secret)));
25
26
  }
26
- exports.isSecretConsistent = isSecretConsistent;
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mergeDiscoveries = exports.getLowerVersion = void 0;
6
+ exports.getLowerVersion = getLowerVersion;
7
+ exports.mergeDiscoveries = mergeDiscoveries;
7
8
  const compare_versions_1 = require("compare-versions");
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  function getLowerVersion(a, b) {
10
11
  return [a, b].sort(compare_versions_1.compareVersions)[0];
11
12
  }
12
- exports.getLowerVersion = getLowerVersion;
13
13
  function mergeDiscoveries(discovery, newDiscovery) {
14
14
  lodash_1.default.merge(discovery, newDiscovery);
15
15
  // eslint-disable-next-line no-param-reassign
@@ -17,4 +17,3 @@ function mergeDiscoveries(discovery, newDiscovery) {
17
17
  // eslint-disable-next-line no-param-reassign
18
18
  discovery.info["x-document-version"] = getLowerVersion(discovery.info["x-document-version"], newDiscovery.info["x-document-version"]);
19
19
  }
20
- exports.mergeDiscoveries = mergeDiscoveries;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { URL } from "url";
3
2
  import { AxiosResponseHeaders, RawAxiosResponseHeaders } from "axios";
4
3
  import { HTTPConfig, HTTPMethod, KeyValuePair, ParameterMapping, ParameterMappings } from "../../../types";
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildHttpConfig = exports.configRequiresBody = exports.handleResponse = exports.handleResponseHeaders = exports.handleResponseData = exports.checkResponseDataForInvalidLoginData = exports.getOutputFileName = exports.buildParameters = exports.handleParameterMapping = exports.getValueFromMappping = exports.handleMappingIn = exports.removeLeadingPathSegmentForPasscode = exports.checkConfiguration = void 0;
6
+ exports.buildHttpConfig = exports.configRequiresBody = exports.handleResponse = exports.handleResponseData = exports.buildParameters = exports.handleParameterMapping = exports.getValueFromMappping = exports.handleMappingIn = exports.removeLeadingPathSegmentForPasscode = exports.checkConfiguration = void 0;
7
+ exports.getOutputFileName = getOutputFileName;
8
+ exports.checkResponseDataForInvalidLoginData = checkResponseDataForInvalidLoginData;
9
+ exports.handleResponseHeaders = handleResponseHeaders;
7
10
  const os_1 = require("os");
8
11
  const url_1 = require("url");
9
12
  const lodash_1 = __importDefault(require("lodash"));
@@ -119,7 +122,6 @@ function getOutputFileName(outputPath = "") {
119
122
  }
120
123
  return config.options[constants_1.OPTION_OUTPUT.longName];
121
124
  }
122
- exports.getOutputFileName = getOutputFileName;
123
125
  function checkResponseDataForInvalidLoginData(response) {
124
126
  if (
125
127
  // jira.tools.sap/browse/DW101-73607
@@ -132,7 +134,6 @@ function checkResponseDataForInvalidLoginData(response) {
132
134
  }
133
135
  return false;
134
136
  }
135
- exports.checkResponseDataForInvalidLoginData = checkResponseDataForInvalidLoginData;
136
137
  const handleResponseData = async (data, outputPath) => {
137
138
  checkResponseDataForInvalidLoginData(data);
138
139
  const config = (0, config_1.get)();
@@ -185,7 +186,6 @@ function handleResponseHeaders(headers) {
185
186
  }
186
187
  }
187
188
  }
188
- exports.handleResponseHeaders = handleResponseHeaders;
189
189
  const handleResponse = async (data, headers) => {
190
190
  if (headers?.[constants_1.X_CSRF_TOKEN]) {
191
191
  (0, config_1.set)({ [constants_1.X_CSRF_TOKEN]: headers[constants_1.X_CSRF_TOKEN] });
package/config/index.js CHANGED
@@ -81,6 +81,9 @@ const set = (c) => {
81
81
  config.tenant = config.newTenant;
82
82
  delete config.newTenant;
83
83
  }
84
+ if (c.data) {
85
+ config.data = c.data;
86
+ }
84
87
  if (!lodash_1.default.isEqual(prev, config)) {
85
88
  trace("configuration changed. previous: %s, current: %s", JSON.stringify(prev), JSON.stringify(config));
86
89
  }
package/dwc/run.js CHANGED
@@ -15,13 +15,15 @@ const run = async () => {
15
15
  await (0, dwc_1.executeCommand)();
16
16
  }
17
17
  catch (err) {
18
- if (err.code === "commander.helpDisplayed") {
18
+ if (err.code === "commander.helpDisplayed" ||
19
+ err.code === "commander.version") {
19
20
  debug("Error while running CLI", err.stack);
20
21
  }
21
22
  else {
22
23
  error("Error while running CLI", err.stack);
23
24
  exitCode = 1;
24
25
  }
26
+ exitCode = err.exitCode ?? exitCode;
25
27
  }
26
28
  finally {
27
29
  await (0, utils_1.compareEtags)();
package/dwc/utils.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOptionValueFromArgv = exports.compareEtags = exports.checkVersion = exports.verifyNodeVersion = exports.addCommandsFromFolder = void 0;
6
+ exports.getOptionValueFromArgv = exports.compareEtags = exports.checkVersion = exports.addCommandsFromFolder = void 0;
7
+ exports.verifyNodeVersion = verifyNodeVersion;
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
10
  const compare_versions_1 = require("compare-versions");
@@ -48,7 +49,6 @@ function verifyNodeVersion() {
48
49
  ` The CLI might not behave as expected. Please make sure to install a matching node version.`);
49
50
  }
50
51
  }
51
- exports.verifyNodeVersion = verifyNodeVersion;
52
52
  const checkVersion = async () => {
53
53
  const { output, error } = getLogger();
54
54
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cli-core",
3
- "version": "2024.14.0",
3
+ "version": "2024.16.0",
4
4
  "description": "Command-Line Interface (CLI) Core Module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "SAP SE",
@@ -17,19 +17,19 @@
17
17
  "cli-core"
18
18
  ],
19
19
  "dependencies": {
20
- "ajv": "8.15.0",
20
+ "ajv": "8.16.0",
21
21
  "axios": "1.7.2",
22
22
  "commander": "12.1.0",
23
23
  "compare-versions": "6.1.0",
24
- "config": "3.3.11",
24
+ "config": "3.3.12",
25
25
  "dotenv": "16.4.5",
26
26
  "fs-extra": "11.2.0",
27
27
  "https": "1.0.0",
28
- "https-proxy-agent": "7.0.4",
28
+ "https-proxy-agent": "7.0.5",
29
29
  "lodash": "4.17.21",
30
30
  "open": "8.4.2",
31
31
  "path": "0.12.7",
32
32
  "prompts": "2.4.2",
33
- "qs": "6.12.1"
33
+ "qs": "6.12.2"
34
34
  }
35
35
  }
package/utils/commands.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildCommand = exports.buildOption = exports.registerLongName = exports.isOptionAlreadyRegistered = exports.getShortFlagForLongName = exports.getAbsoluteCommandName = exports.createCommand = void 0;
6
+ exports.buildCommand = exports.buildOption = exports.registerLongName = exports.isOptionAlreadyRegistered = exports.getShortFlagForLongName = exports.createCommand = void 0;
7
+ exports.getAbsoluteCommandName = getAbsoluteCommandName;
7
8
  const commander_1 = require("commander");
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  const types_1 = require("../types");
@@ -44,7 +45,6 @@ function getAbsoluteCommandName(command) {
44
45
  }
45
46
  return `${getAbsoluteCommandName(command.parent)}.${command.name()}`;
46
47
  }
47
- exports.getAbsoluteCommandName = getAbsoluteCommandName;
48
48
  const getShortFlagForLongName = (command, option) => {
49
49
  const commandName = getAbsoluteCommandName(command);
50
50
  for (const s of Object.keys(registeredOptions[commandName] ?? {})) {
@@ -23,7 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.openUrlInBrowser = exports.getDefaultBrowser = exports.getSupportedBrowsers = void 0;
26
+ exports.openUrlInBrowser = void 0;
27
+ exports.getSupportedBrowsers = getSupportedBrowsers;
28
+ exports.getDefaultBrowser = getDefaultBrowser;
27
29
  const open_1 = __importStar(require("open"));
28
30
  const constants_1 = require("../constants");
29
31
  const options_1 = require("./options");
@@ -35,11 +37,9 @@ function getSupportedBrowsers() {
35
37
  app: value,
36
38
  }));
37
39
  }
38
- exports.getSupportedBrowsers = getSupportedBrowsers;
39
40
  async function getDefaultBrowser() {
40
41
  return getSupportedBrowsers()[0].name;
41
42
  }
42
- exports.getDefaultBrowser = getDefaultBrowser;
43
43
  async function getBrowser() {
44
44
  const browser = (0, options_1.getOptionValueFromConfig)(constants_1.OPTION_BROWSER, await getDefaultBrowser());
45
45
  return open_1.apps[browser];
package/utils/utils.js CHANGED
@@ -26,7 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.toConstantCase = exports.sha256 = exports.removeQueryParametersFromUrl = exports.getInfoFromTenant = exports.parseTenant = exports.removeScopeFromPackageName = exports.getBin = exports.getEngines = exports.getDescription = exports.getPackageName = exports.getName = exports.getVersion = exports.readPackageJson = exports.requireFile = exports.parseVersion = exports.buildOptionName = void 0;
29
+ exports.toConstantCase = exports.sha256 = exports.getInfoFromTenant = exports.parseTenant = exports.removeScopeFromPackageName = exports.getBin = exports.getEngines = exports.getDescription = exports.getPackageName = exports.getName = exports.getVersion = exports.readPackageJson = exports.requireFile = exports.parseVersion = void 0;
30
+ exports.buildOptionName = buildOptionName;
31
+ exports.removeQueryParametersFromUrl = removeQueryParametersFromUrl;
30
32
  const crypto = __importStar(require("crypto"));
31
33
  const path_1 = __importDefault(require("path"));
32
34
  const lodash_1 = require("lodash");
@@ -39,7 +41,6 @@ function buildOptionName(command, option) {
39
41
  const shortFlag = (0, commands_1.getShortFlagForLongName)(command, option);
40
42
  return `-${shortFlag}, --${option.longName}`;
41
43
  }
42
- exports.buildOptionName = buildOptionName;
43
44
  const parseVersion = (version) => {
44
45
  const segments = version.split(".");
45
46
  return { major: parseInt(segments[0], 10), minor: parseInt(segments[1], 10) };
@@ -161,7 +162,6 @@ function removeQueryParametersFromUrl(sUrl) {
161
162
  const url = new URL(sUrl);
162
163
  return `${url.protocol}//${url.host}${url.pathname}`;
163
164
  }
164
- exports.removeQueryParametersFromUrl = removeQueryParametersFromUrl;
165
165
  const sha256 = (string) =>
166
166
  // NOSONAR actually sha256 (or SHA-256) is considered secure according to SonarQube
167
167
  crypto.createHash("sha256").update(string).digest("base64");