@sap/cli-core 2026.4.0 → 2026.6.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
+ ## 2026.5.0
9
+
10
+ ### Added
11
+
12
+ - Added `--force` option to the `login` command to skip the confirmation prompt when overwriting existing secrets. This is useful when running the CLI programmatically or in scripts.
13
+
14
+ ### Fixed
15
+
16
+ - Fixed config state leakage between commands when using `getCommands()` programmatically. Previously, `config.data` and `config.headers` from one command (e.g., file content from `--file` option) would persist and leak into subsequent commands, causing incorrect request payloads.
17
+
8
18
  ## 2026.3.0
9
19
 
10
20
  ### Fixed
@@ -1,10 +1,22 @@
1
1
  import { kebabCase } from "lodash-es";
2
- import { set as setConfig } from "../../config/index.js";
2
+ import { get as getConfig, set as setConfig } from "../../config/index.js";
3
3
  import { getBooleanOption, parseOption } from "./utils.js";
4
4
  import { OPTION_TLS_VERSION, OPTION_VERBOSE } from "../../constants.js";
5
5
  import { get as getLogger } from "../../logger/index.js";
6
+ /**
7
+ * Clears command-specific config properties that should not persist between commands.
8
+ * This prevents data from one command (e.g., file content from --file option) from
9
+ * leaking into subsequent commands when using getCommands() programmatically.
10
+ */
11
+ const clearCommandSpecificConfig = () => {
12
+ const config = getConfig();
13
+ delete config.data;
14
+ delete config.headers;
15
+ };
6
16
  export const create = (handlerArgs) => async () => async (...args) => {
7
17
  const { debug } = getLogger("commands.handler.parseArguments");
18
+ // Clear command-specific config from previous commands to prevent state leakage
19
+ clearCommandSpecificConfig();
8
20
  const command = args[args.length - 1].name();
9
21
  const options = Object.entries(args[args.length - 2])
10
22
  .map((o) => [o[0], parseOption(o[1])])
@@ -1,6 +1,7 @@
1
1
  import { SecretsStorageSingleton } from "../cache/secrets/SecretsStorageSingleton.js";
2
2
  import { getTenantUrl } from "../cache/secrets/utils.js";
3
- import { OPTION_ACCESS_TOKEN, OPTION_AUTHORIZATION_FLOW, OPTION_AUTHORIZATION_URL, OPTION_BROWSER, OPTION_CLIENT_ID, OPTION_CLIENT_SECRET, OPTION_CODE, OPTION_HOST, OPTION_OPTIONS_FILE, OPTION_REFRESH_TOKEN, OPTION_SECRETS_FILE, OPTION_TLS_VERSION, OPTION_TOKEN_URL, OPTION_VERBOSE, ROOT_COMMAND, } from "../constants.js";
3
+ import { get as getConfig } from "../config/index.js";
4
+ import { OPTION_ACCESS_TOKEN, OPTION_AUTHORIZATION_FLOW, OPTION_AUTHORIZATION_URL, OPTION_BROWSER, OPTION_CLIENT_ID, OPTION_CLIENT_SECRET, OPTION_CODE, OPTION_FORCE, OPTION_HOST, OPTION_OPTIONS_FILE, OPTION_REFRESH_TOKEN, OPTION_SECRETS_FILE, OPTION_TLS_VERSION, OPTION_TOKEN_URL, OPTION_VERBOSE, ROOT_COMMAND, } from "../constants.js";
4
5
  import { get } from "../logger/index.js";
5
6
  import { logVerbose } from "../logger/utils.js";
6
7
  import { getDefaultBrowser, getSupportedBrowsers } from "../utils/openUtils.js";
@@ -22,7 +23,15 @@ export const verifyHost = async () => async () => {
22
23
  throw new Error("tenant URL not defined. use option -H, --host");
23
24
  }
24
25
  };
26
+ const isForceOptionSet = () => {
27
+ const config = getConfig();
28
+ return config.options?.[OPTION_FORCE.longName] === true;
29
+ };
25
30
  const confirmSecretsOverwrite = async (tenantUrl) => {
31
+ // Skip prompt if --force option is set
32
+ if (isForceOptionSet()) {
33
+ return true;
34
+ }
26
35
  const promptResponse = await promptForValue({
27
36
  prompts: {
28
37
  type: "confirm",
@@ -100,6 +109,10 @@ const loginCommand = {
100
109
  default: getDefaultBrowser,
101
110
  },
102
111
  { ...OPTION_AUTHORIZATION_FLOW, hidden: false },
112
+ {
113
+ ...OPTION_FORCE,
114
+ description: "skip confirmation prompt when overwriting existing secrets",
115
+ },
103
116
  ]), createMandatoryOptionsHandler(), verifyHost, createOrHandler("commands.login", warnIfSecretExistsInCache, createNextHandler("commands.login", createOauthHandler(), initializeCache, saveSecrets))),
104
117
  };
105
118
  export default loginCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cli-core",
3
- "version": "2026.4.0",
3
+ "version": "2026.6.0",
4
4
  "description": "Command-Line Interface (CLI) Core Module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "SAP SE",
@@ -18,12 +18,12 @@
18
18
  "cli-core"
19
19
  ],
20
20
  "dependencies": {
21
- "ajv": "8.17.1",
22
- "axios": "1.13.3",
23
- "commander": "14.0.2",
21
+ "ajv": "8.18.0",
22
+ "axios": "1.13.5",
23
+ "commander": "14.0.3",
24
24
  "compare-versions": "6.1.1",
25
- "config": "4.2.0",
26
- "dotenv": "17.2.3",
25
+ "config": "4.3.0",
26
+ "dotenv": "17.3.1",
27
27
  "form-data": "4.0.5",
28
28
  "fs-extra": "11.3.3",
29
29
  "https-proxy-agent": "7.0.6",
@@ -32,6 +32,6 @@
32
32
  "open": "11.0.0",
33
33
  "path": "0.12.7",
34
34
  "prompts": "2.4.2",
35
- "qs": "6.14.1"
35
+ "qs": "6.15.0"
36
36
  }
37
37
  }