@sap/cli-core 2023.19.0 → 2023.23.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,34 @@ 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
+ ## 2023.23.0
9
+
10
+ ### Fixed
11
+
12
+ - Trailing single quotes (`'`) were removed from option values even though there was no leading single quote. This version contains a fix that trailing single quotes are only removed if there is a leading single quote.
13
+
14
+ Trailing single quote is not removed: `some 'value'` stays `some 'value'`.
15
+
16
+ Trailing single quote is removed: `'some value'` becomes `some value`.
17
+
18
+ - The help output did not mention the correct CLI name. Instead the output showed the name 'terminal'.
19
+
20
+ ```javascript
21
+ Usage: terminal [options] [command]
22
+
23
+ Command-Line Interface for <product name>.
24
+ ...
25
+ ```
26
+
27
+ Since this version, the name is shown correctly.
28
+
29
+ ```javascript
30
+ Usage: <cli> [options] [command]
31
+
32
+ Command-Line Interface for <product name>.
33
+ ...
34
+ ```
35
+
8
36
  ## 2023.19.0
9
37
 
10
38
  ### Fixed
@@ -49,9 +49,10 @@ class SecretsStorageImpl {
49
49
  }
50
50
  async getDefaultSecretId() {
51
51
  const tenantUrl = (0, utils_2.getTenantUrl)();
52
- const secret = this.secrets.find((s) => new URL(s.tenantUrl).host === new URL(tenantUrl).host);
52
+ const { host } = new URL(tenantUrl);
53
+ const secret = this.secrets.find((s) => new URL(s.tenantUrl).host === host);
53
54
  if (!secret) {
54
- throw new Error("Method not implemented.");
55
+ throw new Error(`No secret found for host ${host}`);
55
56
  }
56
57
  return secret.id;
57
58
  }
@@ -30,5 +30,5 @@ const readBodyFromFile = async () => async () => {
30
30
  throw err;
31
31
  }
32
32
  };
33
- const create = () => (0, next_1.create)((0, checkOptionsExistence_1.create)(constants_1.OPTION_INPUT), (0, options_1.create)(constants_1.OPTION_FILE_PATH, { readEnv: true, readFile: true, readOptions: true, readPipe: true }, true, true), readBodyFromFile);
33
+ const create = () => (0, next_1.create)((0, checkOptionsExistence_1.create)(constants_1.OPTION_INPUT), (0, options_1.create)(constants_1.OPTION_FILE_PATH, { readEnv: true, readFile: true, readOptions: true }, true, true), readBodyFromFile);
34
34
  exports.create = create;
@@ -1,6 +1,5 @@
1
1
  import { Handler, Option } from "../../../types";
2
- export declare const create: (options: Array<Option> | Option, { readPipe, readEnv, readFile, readOptions }?: {
3
- readPipe: boolean;
2
+ export declare const create: (options: Array<Option> | Option, { readEnv, readFile, readOptions }?: {
4
3
  readEnv: boolean;
5
4
  readFile: boolean;
6
5
  readOptions: boolean;
@@ -6,15 +6,13 @@ const utils_1 = require("./utils");
6
6
  const or_1 = require("../or");
7
7
  const next_1 = require("../next");
8
8
  const checkOptionsExistence_1 = require("../checkOptionsExistence");
9
- const pipe_1 = require("./pipe");
10
9
  const file_1 = require("./file");
11
10
  const option_1 = require("./option");
12
11
  const succeed_1 = require("../succeed");
13
12
  const fail_1 = require("../fail");
14
13
  const env_1 = require("./env");
15
14
  const createHandler = (use, option, handler) => (0, next_1.create)((0, checkOptionsExistence_1.create)(option), use ? handler : (0, succeed_1.create)());
16
- const create = (options, { readPipe, readEnv, readFile, readOptions } = {
17
- readPipe: true,
15
+ const create = (options, { readEnv, readFile, readOptions } = {
18
16
  readEnv: true,
19
17
  readFile: true,
20
18
  readOptions: true,
@@ -23,7 +21,7 @@ const create = (options, { readPipe, readEnv, readFile, readOptions } = {
23
21
  await (0, utils_1.checkOptions)(intOptions, command);
24
22
  return async () => {
25
23
  for (const option of intOptions) {
26
- const handler = (0, or_1.create)((0, checkOptionsExistence_1.create)(option, false), (0, or_1.create)(createHandler(readPipe, option, (0, pipe_1.create)(option)), createHandler(readEnv, option, (0, env_1.create)(option)), createHandler(readFile, option, (0, file_1.create)(option)), createHandler(readOptions, option, (0, option_1.create)(option, promptAlways))), throwIfHandlersFailed
24
+ const handler = (0, or_1.create)((0, checkOptionsExistence_1.create)(option, false), (0, or_1.create)(createHandler(readEnv, option, (0, env_1.create)(option)), createHandler(readFile, option, (0, file_1.create)(option)), createHandler(readOptions, option, (0, option_1.create)(option, promptAlways))), throwIfHandlersFailed
27
25
  ? (0, fail_1.create)()
28
26
  : (0, succeed_1.create)());
29
27
  await (await handler(command))();
@@ -4,6 +4,7 @@ exports.getTargetHost = exports.setTargetHost = exports.getAuthenticationMethod
4
4
  const logger_1 = require("../../logger");
5
5
  const config_1 = require("../../config");
6
6
  const constants_1 = require("../../constants");
7
+ const REGEX_LEADING_TRAILING_SINGLE_QUOTE = /^'.*'$/;
7
8
  const getLogger = () => (0, logger_1.get)("commands.handler.utils");
8
9
  const getBooleanOption = (value) => !!value;
9
10
  exports.getBooleanOption = getBooleanOption;
@@ -17,7 +18,12 @@ const decodeURIComponentInt = (value) => {
17
18
  throw err;
18
19
  }
19
20
  };
20
- const replaceLeadingTrailingSingleQuotes = (value) => value.replace(/^'/, "").replace(/'$/, "");
21
+ const replaceLeadingTrailingSingleQuotes = (value) => {
22
+ if (REGEX_LEADING_TRAILING_SINGLE_QUOTE.test(value)) {
23
+ return value.replace(/^'/, "").replace(/'$/, "");
24
+ }
25
+ return value;
26
+ };
21
27
  const parseOption = (value) => {
22
28
  if (typeof value !== "string") {
23
29
  return value;
package/dwc/dwc.js CHANGED
@@ -115,11 +115,15 @@ const init = async () => {
115
115
  await setTenant();
116
116
  await initCacheTolerant();
117
117
  await setupSecretsStorage();
118
+ const cliName = (0, config_1.get)()[constants_1.CLI_NAME];
118
119
  program = (0, commands_1.createCommand)();
120
+ program.name(cliName);
119
121
  program.version((0, core_1.getVersion)(), "-v, --version", "output the current version");
120
122
  program.description((0, config_1.get)()[constants_1.CLI_DESCRIPTION]);
121
- program.showHelpAfterError(`Did you initialize the CLI by running ${(0, config_1.get)()[constants_1.CLI_NAME]} config cache init --host "<Server_URL>"?` +
122
- ` Add --help, -h or go to ${(0, config_1.get)()[constants_1.CLI_SAP_HELP]} for additional information.`);
123
+ program.showHelpAfterError(`Make sure to always define the host using the --host option or by running ${cliName}` +
124
+ ` config host set "<Server_URL>". Did you initialize the CLI by running ${cliName} config` +
125
+ ` cache init --host "<Server_URL>"?` +
126
+ ` Add option --help, -h or go to ${(0, config_1.get)()[constants_1.CLI_SAP_HELP]} for additional information.`);
123
127
  program.addOption(await (0, commands_1.buildOption)(constants_1.OPTION_HOST));
124
128
  program.addOption(await (0, commands_1.buildOption)(constants_1.OPTION_OPTIONS_FILE));
125
129
  program.configureHelp({ sortSubcommands: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cli-core",
3
- "version": "2023.19.0",
3
+ "version": "2023.23.0",
4
4
  "description": "Command-Line Interface (CLI) Core Module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "SAP SE",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "ajv": "8.12.0",
21
- "axios": "1.4.0",
21
+ "axios": "1.5.1",
22
22
  "commander": "11.0.0",
23
23
  "config": "3.3.9",
24
24
  "dotenv": "16.3.1",
@@ -1,2 +0,0 @@
1
- import { Handler, Option } from "../../../types";
2
- export declare const create: (option: Option) => Handler;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const logger_1 = require("../../../logger");
6
- const utils_1 = require("./utils");
7
- const getLogger = () => (0, logger_1.get)("commands.handler.options.pipe");
8
- let data;
9
- const getDataFromPipe = () => {
10
- if (data === undefined) {
11
- try {
12
- data = JSON.parse((0, fs_extra_1.readFileSync)(0, "utf-8"));
13
- }
14
- catch (err) {
15
- const { error } = getLogger();
16
- error("failed to read from pipe", err);
17
- data = null;
18
- return getDataFromPipe();
19
- }
20
- }
21
- else if (data === null) {
22
- throw new Error("no data received from pipe");
23
- }
24
- return data;
25
- };
26
- /* jscpd:ignore-start */
27
- const create = (option) => async () => async () => {
28
- const { debug } = getLogger();
29
- /* jscpd:ignore-end */
30
- debug(`reading option ${option.longName} from pipe`);
31
- const options = getDataFromPipe();
32
- (0, utils_1.setOption)(option, options[option.longName]);
33
- };
34
- exports.create = create;