@sap/cli-core 2025.17.0 → 2025.19.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/cache/cache.js +16 -28
  4. package/cache/index.d.ts +2 -2
  5. package/cache/index.js +2 -12
  6. package/cache/secrets/SecretsStorageImpl.d.ts +2 -2
  7. package/cache/secrets/SecretsStorageImpl.js +18 -22
  8. package/cache/secrets/SecretsStorageSingleton.d.ts +1 -1
  9. package/cache/secrets/SecretsStorageSingleton.js +1 -5
  10. package/cache/secrets/types.d.ts +1 -1
  11. package/cache/secrets/types.js +1 -2
  12. package/cache/secrets/utils.d.ts +1 -1
  13. package/cache/secrets/utils.js +20 -27
  14. package/cache/utils.js +8 -15
  15. package/commands/config.command/cache.command/clean.command.d.ts +1 -1
  16. package/commands/config.command/cache.command/clean.command.js +10 -12
  17. package/commands/config.command/cache.command/index.d.ts +1 -1
  18. package/commands/config.command/cache.command/index.js +5 -10
  19. package/commands/config.command/cache.command/init.command/index.d.ts +1 -1
  20. package/commands/config.command/cache.command/init.command/index.js +29 -36
  21. package/commands/config.command/cache.command/init.command/utils.d.ts +1 -1
  22. package/commands/config.command/cache.command/init.command/utils.js +6 -13
  23. package/commands/config.command/cache.command/show.command.d.ts +1 -1
  24. package/commands/config.command/cache.command/show.command.js +7 -9
  25. package/commands/config.command/host.command.d.ts +1 -1
  26. package/commands/config.command/host.command.js +19 -23
  27. package/commands/config.command/index.d.ts +1 -1
  28. package/commands/config.command/index.js +5 -45
  29. package/commands/config.command/passcode.command.d.ts +1 -1
  30. package/commands/config.command/passcode.command.js +12 -16
  31. package/commands/config.command/secrets.command/check.command.d.ts +1 -2
  32. package/commands/config.command/secrets.command/check.command.js +10 -14
  33. package/commands/config.command/secrets.command/index.d.ts +1 -1
  34. package/commands/config.command/secrets.command/index.js +6 -11
  35. package/commands/config.command/secrets.command/refresh.command.d.ts +1 -1
  36. package/commands/config.command/secrets.command/refresh.command.js +5 -7
  37. package/commands/config.command/secrets.command/reset.command.d.ts +1 -1
  38. package/commands/config.command/secrets.command/reset.command.js +6 -8
  39. package/commands/config.command/secrets.command/show.command.d.ts +1 -1
  40. package/commands/config.command/secrets.command/show.command.js +8 -10
  41. package/commands/handler/authentication/index.d.ts +1 -1
  42. package/commands/handler/authentication/index.js +18 -21
  43. package/commands/handler/authentication/oauth/index.d.ts +1 -1
  44. package/commands/handler/authentication/oauth/index.js +13 -16
  45. package/commands/handler/authentication/oauth/secretsProvider/cache.d.ts +1 -1
  46. package/commands/handler/authentication/oauth/secretsProvider/cache.js +5 -9
  47. package/commands/handler/authentication/oauth/secretsProvider/file.d.ts +1 -1
  48. package/commands/handler/authentication/oauth/secretsProvider/file.js +20 -25
  49. package/commands/handler/authentication/oauth/secretsProvider/index.d.ts +1 -1
  50. package/commands/handler/authentication/oauth/secretsProvider/index.js +6 -10
  51. package/commands/handler/authentication/oauth/secretsProvider/options.d.ts +1 -1
  52. package/commands/handler/authentication/oauth/secretsProvider/options.js +25 -29
  53. package/commands/handler/authentication/oauth/tokenProvider/getToken.d.ts +1 -1
  54. package/commands/handler/authentication/oauth/tokenProvider/getToken.js +16 -20
  55. package/commands/handler/authentication/oauth/tokenProvider/index.d.ts +1 -1
  56. package/commands/handler/authentication/oauth/tokenProvider/index.js +7 -11
  57. package/commands/handler/authentication/oauth/tokenProvider/refreshToken.d.ts +1 -1
  58. package/commands/handler/authentication/oauth/tokenProvider/refreshToken.js +5 -9
  59. package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.d.ts +1 -1
  60. package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.js +19 -24
  61. package/commands/handler/authentication/oauth/tokenProvider/utils.js +30 -36
  62. package/commands/handler/authentication/oauth/utils.d.ts +1 -1
  63. package/commands/handler/authentication/oauth/utils.js +15 -24
  64. package/commands/handler/authentication/passcode/function.d.ts +1 -1
  65. package/commands/handler/authentication/passcode/function.js +11 -13
  66. package/commands/handler/authentication/passcode/index.d.ts +1 -1
  67. package/commands/handler/authentication/passcode/index.js +14 -17
  68. package/commands/handler/authentication/passcode/input.d.ts +1 -1
  69. package/commands/handler/authentication/passcode/input.js +13 -20
  70. package/commands/handler/authentication/passcode/setPasscode.d.ts +1 -1
  71. package/commands/handler/authentication/passcode/setPasscode.js +9 -13
  72. package/commands/handler/authentication/passcode/types.js +1 -2
  73. package/commands/handler/authentication/technicalJWT/cf.js +9 -11
  74. package/commands/handler/authentication/technicalJWT/exec.d.ts +5 -6
  75. package/commands/handler/authentication/technicalJWT/exec.js +15 -19
  76. package/commands/handler/authentication/technicalJWT/index.d.ts +1 -1
  77. package/commands/handler/authentication/technicalJWT/index.js +8 -12
  78. package/commands/handler/authentication/technicalJWT/types.d.ts +1 -1
  79. package/commands/handler/authentication/technicalJWT/types.js +1 -4
  80. package/commands/handler/authentication/technicalJWT/utils.js +20 -27
  81. package/commands/handler/authentication/utils.js +3 -7
  82. package/commands/handler/checkOptionsExistence.d.ts +1 -1
  83. package/commands/handler/checkOptionsExistence.js +5 -9
  84. package/commands/handler/error.d.ts +1 -1
  85. package/commands/handler/error.js +4 -8
  86. package/commands/handler/fail.d.ts +1 -1
  87. package/commands/handler/fail.js +3 -7
  88. package/commands/handler/fetch/fetch.d.ts +1 -1
  89. package/commands/handler/fetch/fetch.js +26 -27
  90. package/commands/handler/fetch/index.d.ts +1 -1
  91. package/commands/handler/fetch/index.js +10 -14
  92. package/commands/handler/fetch/utils.d.ts +2 -2
  93. package/commands/handler/fetch/utils.js +56 -75
  94. package/commands/handler/force.d.ts +1 -1
  95. package/commands/handler/force.js +8 -15
  96. package/commands/handler/index.d.ts +18 -18
  97. package/commands/handler/index.js +18 -39
  98. package/commands/handler/input/file.d.ts +1 -1
  99. package/commands/handler/input/file.js +22 -29
  100. package/commands/handler/input/index.d.ts +1 -1
  101. package/commands/handler/input/index.js +4 -8
  102. package/commands/handler/input/input.d.ts +1 -1
  103. package/commands/handler/input/input.js +16 -23
  104. package/commands/handler/mandatoryOptions.d.ts +1 -1
  105. package/commands/handler/mandatoryOptions.js +13 -17
  106. package/commands/handler/next.d.ts +1 -1
  107. package/commands/handler/next.js +4 -8
  108. package/commands/handler/options/env.d.ts +1 -1
  109. package/commands/handler/options/env.js +8 -12
  110. package/commands/handler/options/file.d.ts +1 -1
  111. package/commands/handler/options/file.js +8 -12
  112. package/commands/handler/options/index.d.ts +1 -1
  113. package/commands/handler/options/index.js +15 -19
  114. package/commands/handler/options/option.d.ts +1 -1
  115. package/commands/handler/options/option.js +12 -13
  116. package/commands/handler/options/utils.d.ts +4 -2
  117. package/commands/handler/options/utils.js +18 -26
  118. package/commands/handler/or.d.ts +1 -1
  119. package/commands/handler/or.js +3 -7
  120. package/commands/handler/parseArguments.d.ts +1 -1
  121. package/commands/handler/parseArguments.js +11 -15
  122. package/commands/handler/resilient.d.ts +1 -1
  123. package/commands/handler/resilient.js +3 -7
  124. package/commands/handler/root/index.d.ts +1 -1
  125. package/commands/handler/root/index.js +3 -7
  126. package/commands/handler/stackTrace.d.ts +1 -1
  127. package/commands/handler/stackTrace.js +3 -7
  128. package/commands/handler/succeed.d.ts +1 -1
  129. package/commands/handler/succeed.js +3 -7
  130. package/commands/handler/utils.d.ts +1 -1
  131. package/commands/handler/utils.js +17 -27
  132. package/commands/login.command.d.ts +1 -1
  133. package/commands/login.command.js +41 -45
  134. package/commands/logout.command.d.ts +1 -1
  135. package/commands/logout.command.js +15 -17
  136. package/commands/openAPI.command/index.d.ts +1 -1
  137. package/commands/openAPI.command/index.js +20 -24
  138. package/commands/openAPI.command/utils.d.ts +1 -1
  139. package/commands/openAPI.command/utils.js +47 -97
  140. package/commands/utils.d.ts +1 -1
  141. package/commands/utils.js +6 -11
  142. package/config/core.d.ts +1 -1
  143. package/config/core.js +12 -25
  144. package/config/index.d.ts +1 -1
  145. package/config/index.js +45 -49
  146. package/configureLoggers.js +2 -6
  147. package/constants.d.ts +1 -1
  148. package/constants.js +57 -63
  149. package/discovery/index.d.ts +1 -1
  150. package/discovery/index.js +32 -45
  151. package/discovery/utils.js +5 -12
  152. package/dwc/dwc.js +63 -76
  153. package/dwc/run.js +15 -19
  154. package/dwc/utils.d.ts +1 -1
  155. package/dwc/utils.js +42 -38
  156. package/index.d.ts +4 -4
  157. package/index.js +22 -68
  158. package/logger/index.d.ts +2 -2
  159. package/logger/index.js +17 -22
  160. package/logger/types.js +1 -2
  161. package/logger/utils.d.ts +1 -1
  162. package/logger/utils.js +4 -8
  163. package/module.d.ts +3 -3
  164. package/module.js +10 -48
  165. package/package.json +9 -7
  166. package/result/ResultHandlerFactory.d.ts +1 -1
  167. package/result/ResultHandlerFactory.js +1 -5
  168. package/result/ResultHandlerImpl.d.ts +1 -1
  169. package/result/ResultHandlerImpl.js +1 -5
  170. package/result/types.js +1 -2
  171. package/settings/index.d.ts +1 -1
  172. package/settings/index.js +11 -17
  173. package/types.d.ts +1 -1
  174. package/types.js +6 -9
  175. package/utils/commands.d.ts +3 -3
  176. package/utils/commands.js +23 -36
  177. package/utils/http/httpsAgent.js +16 -26
  178. package/utils/http/index.d.ts +1 -1
  179. package/utils/http/index.js +28 -35
  180. package/utils/http/utils.d.ts +1 -1
  181. package/utils/http/utils.js +4 -9
  182. package/utils/openUtils.js +8 -14
  183. package/utils/options.d.ts +1 -1
  184. package/utils/options.js +5 -10
  185. package/utils/utils.d.ts +2 -2
  186. package/utils/utils.js +42 -94
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const stackTrace_1 = require("./stackTrace");
5
- const logger_1 = require("../../logger");
1
+ import { create as createStackTraceHandler } from "./stackTrace.js";
2
+ import { get } from "../../logger/index.js";
6
3
  function getLogger(origin) {
7
- return (0, logger_1.get)(`commands.handler.next:${origin}`);
4
+ return get(`commands.handler.next:${origin}`);
8
5
  }
9
6
  const nextHandler = (origin, ...handlers) => async (command) => {
10
7
  getLogger(origin).trace(`next:${origin}: preparing handlers`);
@@ -21,6 +18,5 @@ const nextHandler = (origin, ...handlers) => async (command) => {
21
18
  }
22
19
  };
23
20
  };
24
- const create = (origin, ...handlers) => (0, stackTrace_1.create)(nextHandler(origin, ...handlers));
25
- exports.create = create;
21
+ export const create = (origin, ...handlers) => createStackTraceHandler(nextHandler(origin, ...handlers));
26
22
  /* jscpd:ignore-end */
@@ -1,2 +1,2 @@
1
- import { Handler, Option } from "../../../types";
1
+ import { Handler, Option } from "../../../types.js";
2
2
  export declare const create: (option: Option) => Handler;
@@ -1,17 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../../logger");
5
- const utils_1 = require("../../../utils/utils");
6
- const utils_2 = require("./utils");
1
+ import { get } from "../../../logger/index.js";
2
+ import { toConstantCase } from "../../../utils/utils.js";
3
+ import { setOption } from "./utils.js";
7
4
  /* jscpd:ignore-start */
8
- const create = (option) => async () => async () => {
9
- const { debug } = (0, logger_1.get)("commands.handler.options.env");
5
+ export const create = (option) => async () => async () => {
6
+ const { debug } = get("commands.handler.options.env");
10
7
  /* jscpd:ignore-end */
11
8
  debug(`reading option ${option.longName} from env`);
12
- if (!process.env[(0, utils_1.toConstantCase)(option.longName)]) {
13
- throw new Error(`env variable process.env.${(0, utils_1.toConstantCase)(option.longName)} is not set`);
9
+ if (!process.env[toConstantCase(option.longName)]) {
10
+ throw new Error(`env variable process.env.${toConstantCase(option.longName)} is not set`);
14
11
  }
15
- (0, utils_2.setOption)(option, process.env[(0, utils_1.toConstantCase)(option.longName)]);
12
+ setOption(option, process.env[toConstantCase(option.longName)]);
16
13
  };
17
- exports.create = create;
@@ -1,2 +1,2 @@
1
- import { Handler, Option } from "../../../types";
1
+ import { Handler, Option } from "../../../types.js";
2
2
  export declare const create: (option: Option) => Handler;
@@ -1,21 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const constants_1 = require("../../../constants");
5
- const logger_1 = require("../../../logger");
6
- const options_1 = require("../../../utils/options");
7
- const utils_1 = require("./utils");
1
+ import { OPTION_OPTIONS_FILE } from "../../../constants.js";
2
+ import { get } from "../../../logger/index.js";
3
+ import { getOptionValueFromConfig } from "../../../utils/options.js";
4
+ import { getValueFromOptionsFile, setOption } from "./utils.js";
8
5
  /* jscpd:ignore-start */
9
- const create = (option) => async () => async () => {
10
- const { debug, trace } = (0, logger_1.get)("commands.handler.options.file");
6
+ export const create = (option) => async () => async () => {
7
+ const { debug, trace } = get("commands.handler.options.file");
11
8
  /* jscpd:ignore-end */
12
9
  debug(`reading option ${option.longName} from file`);
13
- const filePath = (0, options_1.getOptionValueFromConfig)(constants_1.OPTION_OPTIONS_FILE);
10
+ const filePath = getOptionValueFromConfig(OPTION_OPTIONS_FILE);
14
11
  try {
15
- (0, utils_1.setOption)(option, await (0, utils_1.getValueFromOptionsFile)(filePath, option));
12
+ setOption(option, await getValueFromOptionsFile(filePath, option));
16
13
  }
17
14
  catch (err) {
18
15
  trace(`failed to read option ${option.longName} from options file ${filePath}`, err);
19
16
  }
20
17
  };
21
- exports.create = create;
@@ -1,4 +1,4 @@
1
- import { Handler, Option } from "../../../types";
1
+ import { Handler, Option } from "../../../types.js";
2
2
  export declare const create: (options: Array<Option> | Option, { readEnv, readFile, readOptions }?: {
3
3
  readEnv: boolean;
4
4
  readFile: boolean;
@@ -1,31 +1,27 @@
1
- "use strict";
2
1
  /* eslint-disable no-await-in-loop */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.create = void 0;
5
- const utils_1 = require("./utils");
6
- const or_1 = require("../or");
7
- const next_1 = require("../next");
8
- const checkOptionsExistence_1 = require("../checkOptionsExistence");
9
- const file_1 = require("./file");
10
- const option_1 = require("./option");
11
- const succeed_1 = require("../succeed");
12
- const fail_1 = require("../fail");
13
- const env_1 = require("./env");
14
- const createHandler = (use, option, handler) => (0, next_1.create)("commands.handler.options", (0, checkOptionsExistence_1.create)(option), use ? handler : (0, succeed_1.create)());
15
- const create = (options, { readEnv, readFile, readOptions } = {
2
+ import { checkOptions } from "./utils.js";
3
+ import { create as createOrHandler } from "../or.js";
4
+ import { create as createNextHandler } from "../next.js";
5
+ import { create as createCheckOptionsExistenceHandler } from "../checkOptionsExistence.js";
6
+ import { create as createFileHandler } from "./file.js";
7
+ import { create as createOptionHandler } from "./option.js";
8
+ import { create as createDummyHandler } from "../succeed.js";
9
+ import { create as createFailAlwaysHandler } from "../fail.js";
10
+ import { create as createEnvHandler } from "./env.js";
11
+ const createHandler = (use, option, handler) => createNextHandler("commands.handler.options", createCheckOptionsExistenceHandler(option), use ? handler : createDummyHandler());
12
+ export const create = (options, { readEnv, readFile, readOptions } = {
16
13
  readEnv: true,
17
14
  readFile: true,
18
15
  readOptions: true,
19
16
  }, promptAlways = false, throwIfHandlersFailed = false) => async (command) => {
20
17
  const intOptions = Array.isArray(options) ? options : [options];
21
- await (0, utils_1.checkOptions)(intOptions, command);
18
+ await checkOptions(intOptions, command);
22
19
  return async () => {
23
20
  for (const option of intOptions) {
24
- const handler = (0, or_1.create)("commands.handler.options$outer", (0, checkOptionsExistence_1.create)(option, false), (0, or_1.create)("commands.handler.options$inner", 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
25
- ? (0, fail_1.create)()
26
- : (0, succeed_1.create)());
21
+ const handler = createOrHandler("commands.handler.options$outer", createCheckOptionsExistenceHandler(option, false), createOrHandler("commands.handler.options$inner", createHandler(readEnv, option, createEnvHandler(option)), createHandler(readFile, option, createFileHandler(option)), createHandler(readOptions, option, createOptionHandler(option, promptAlways))), throwIfHandlersFailed
22
+ ? createFailAlwaysHandler()
23
+ : createDummyHandler());
27
24
  await (await handler(command))();
28
25
  }
29
26
  };
30
27
  };
31
- exports.create = create;
@@ -1,2 +1,2 @@
1
- import { Handler, Option } from "../../../types";
1
+ import { Handler, Option } from "../../../types.js";
2
2
  export declare const create: (option: Option, promptAlways?: boolean) => Handler;
@@ -1,20 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../../logger");
5
- const utils_1 = require("./utils");
6
- const create = (option, promptAlways = false) => async () => async () => {
7
- const { debug } = (0, logger_1.get)("commands.handler.options.option");
1
+ import { get } from "../../../logger/index.js";
2
+ import { promptForValue, setOption } from "./utils.js";
3
+ function assertPromptsAreDefined(option) {
4
+ if (!option.prompts) {
5
+ throw new Error(`inconsistent option ${option.longName}, no prompts configuration available`);
6
+ }
7
+ }
8
+ export const create = (option, promptAlways = false) => async () => async () => {
9
+ const { debug } = get("commands.handler.options.option");
8
10
  debug(`reading option ${option.longName} from options`);
9
11
  if (option.required || promptAlways) {
10
- if (!option.prompts) {
11
- throw new Error(`inconsistent option ${option.longName}, no prompts configuration available`);
12
- }
13
- const value = await (0, utils_1.promptForValue)(option);
14
- (0, utils_1.setOption)(option, value);
12
+ assertPromptsAreDefined(option);
13
+ const value = await promptForValue(option);
14
+ setOption(option, value);
15
15
  }
16
16
  else {
17
17
  throw new Error(`option ${option.longName} is not required and promptAlways is false`);
18
18
  }
19
19
  };
20
- exports.create = create;
@@ -1,6 +1,8 @@
1
1
  import { Command } from "commander";
2
- import { Option } from "../../../types";
2
+ import { Option } from "../../../types.js";
3
3
  export declare const checkOptions: (options: Array<Option> | Option, command: Command) => Promise<void>;
4
- export declare const promptForValue: <ResponseType = string>(option: Option) => Promise<ResponseType>;
4
+ export declare const promptForValue: <ResponseType = string>(option: Option & {
5
+ prompts: NonNullable<Option["prompts"]>;
6
+ }) => Promise<ResponseType>;
5
7
  export declare const setOption: (option: Option, value: string) => void;
6
8
  export declare const getValueFromOptionsFile: (filePath: string, { longName }: Option) => Promise<string>;
@@ -1,26 +1,21 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getValueFromOptionsFile = exports.setOption = exports.promptForValue = exports.checkOptions = void 0;
7
- const prompts_1 = __importDefault(require("prompts"));
8
- const fs_extra_1 = require("fs-extra");
9
- const logger_1 = require("../../../logger");
10
- const commands_1 = require("../../../utils/commands");
11
- const config_1 = require("../../../config");
12
- const checkOptions = async (options, command) => {
1
+ import prompts from "prompts";
2
+ import fs from "fs-extra";
3
+ import { get } from "../../../logger/index.js";
4
+ import { buildOption, isOptionAlreadyRegistered, } from "../../../utils/commands.js";
5
+ import { set as setConfig } from "../../../config/index.js";
6
+ export const checkOptions = async (options, command) => {
13
7
  const intOptions = Array.isArray(options) ? options : [options];
14
8
  for (const option of intOptions) {
15
- if (!(0, commands_1.isOptionAlreadyRegistered)(option, command)) {
9
+ if (!isOptionAlreadyRegistered(option, command)) {
16
10
  command.addOption(
17
11
  // eslint-disable-next-line no-await-in-loop
18
- await (0, commands_1.buildOption)(command, { ...option, required: false }));
12
+ await buildOption(command, { ...option, required: false }));
19
13
  }
20
14
  }
21
15
  };
22
- exports.checkOptions = checkOptions;
23
- const promptForValue = async (option) => {
16
+ export const promptForValue = async (
17
+ // This function expects that the `prompts` property is always defined
18
+ option) => {
24
19
  let choices = [];
25
20
  if (option.choices) {
26
21
  choices =
@@ -28,7 +23,7 @@ const promptForValue = async (option) => {
28
23
  ? await option.choices()
29
24
  : option.choices;
30
25
  }
31
- const { value } = await prompts_1.default.prompt({
26
+ const { value } = await prompts.prompt({
32
27
  type: option.prompts.type,
33
28
  choices: choices.map((choice) => ({
34
29
  title: choice,
@@ -40,32 +35,29 @@ const promptForValue = async (option) => {
40
35
  : option.prompts.message(),
41
36
  name: "value",
42
37
  });
43
- if (option.prompts?.inputValidator) {
38
+ if (option.prompts.inputValidator) {
44
39
  if (!option.prompts.inputValidator(value)) {
45
40
  throw new Error(`input validator returned false for value ${value}`);
46
41
  }
47
42
  }
48
43
  return value;
49
44
  };
50
- exports.promptForValue = promptForValue;
51
45
  const buildOptionName = (option) => `--${option.longName}`;
52
- const setOption = (option, value) => {
53
- const { output } = (0, logger_1.get)("handler.options");
46
+ export const setOption = (option, value) => {
47
+ const { output } = get("handler.options");
54
48
  if (!value && (option.args || []).length > 0) {
55
49
  const name = buildOptionName(option);
56
50
  output(`error: required option '${name}' not specified`);
57
51
  throw new Error(`no value provided for option ${option.longName}`);
58
52
  }
59
- (0, config_1.set)({
53
+ setConfig({
60
54
  options: { [option.longName]: value },
61
55
  });
62
56
  };
63
- exports.setOption = setOption;
64
- const getValueFromOptionsFile = async (filePath, { longName }) => {
65
- const options = JSON.parse(await (0, fs_extra_1.readFile)(filePath, { encoding: "utf8" }));
57
+ export const getValueFromOptionsFile = async (filePath, { longName }) => {
58
+ const options = JSON.parse(await fs.readFile(filePath, { encoding: "utf8" }));
66
59
  if (options[longName]) {
67
60
  return options[longName];
68
61
  }
69
62
  throw new Error(`no value for option ${longName} found in file ${filePath}`);
70
63
  };
71
- exports.getValueFromOptionsFile = getValueFromOptionsFile;
@@ -1,2 +1,2 @@
1
- import { Handler } from "../../types";
1
+ import { Handler } from "../../types.js";
2
2
  export declare const create: (origin: string, ...handlers: Array<Handler>) => Handler;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../logger");
1
+ import { get } from "../../logger/index.js";
5
2
  function getLogger(origin) {
6
- return (0, logger_1.get)(`commands.handler.or:${origin}`);
3
+ return get(`commands.handler.or:${origin}`);
7
4
  }
8
- const create = (origin, ...handlers) => {
5
+ export const create = (origin, ...handlers) => {
9
6
  const { stack } = new Error();
10
7
  return async (command) => {
11
8
  const { trace } = getLogger(origin);
@@ -39,5 +36,4 @@ const create = (origin, ...handlers) => {
39
36
  };
40
37
  };
41
38
  };
42
- exports.create = create;
43
39
  /* jscpd:ignore-end */
@@ -1,4 +1,4 @@
1
- import { Handler } from "../../types";
1
+ import { Handler } from "../../types.js";
2
2
  export declare const create: (handlerArgs?: Array<{
3
3
  argument: string;
4
4
  }>) => Handler;
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const lodash_1 = require("lodash");
5
- const config_1 = require("../../config");
6
- const utils_1 = require("./utils");
7
- const constants_1 = require("../../constants");
8
- const logger_1 = require("../../logger");
9
- const create = (handlerArgs) => async () => async (...args) => {
10
- const { debug } = (0, logger_1.get)("commands.handler.parseArguments");
1
+ import { kebabCase } from "lodash-es";
2
+ import { set as setConfig } from "../../config/index.js";
3
+ import { getBooleanOption, parseOption } from "./utils.js";
4
+ import { OPTION_VERBOSE } from "../../constants.js";
5
+ import { get as getLogger } from "../../logger/index.js";
6
+ export const create = (handlerArgs) => async () => async (...args) => {
7
+ const { debug } = getLogger("commands.handler.parseArguments");
11
8
  const command = args[args.length - 1].name();
12
9
  const options = Object.entries(args[args.length - 2])
13
- .map((o) => [o[0], (0, utils_1.parseOption)(o[1])])
14
- .reduce((prev, curr) => ({ ...prev, [(0, lodash_1.kebabCase)(curr[0])]: curr[1] }), {});
10
+ .map((o) => [o[0], parseOption(o[1])])
11
+ .reduce((prev, curr) => ({ ...prev, [kebabCase(curr[0])]: curr[1] }), {});
15
12
  const commandArgs = handlerArgs
16
13
  ? handlerArgs.reduce((p, c, i) => ({ ...p, [c.argument]: args[i] }), {})
17
14
  : {};
18
- const verbose = (0, utils_1.getBooleanOption)(options[constants_1.OPTION_VERBOSE.longName]);
15
+ const verbose = getBooleanOption(options[OPTION_VERBOSE.longName]);
19
16
  debug("setting command: %s, options: %s, arguments: %s, verbose: %s", command, JSON.stringify(options), JSON.stringify(commandArgs), verbose);
20
- (0, config_1.set)({ command, options, arguments: commandArgs, verbose });
17
+ setConfig({ command, options, arguments: commandArgs, verbose });
21
18
  };
22
- exports.create = create;
@@ -1,2 +1,2 @@
1
- import { Handler } from "../../types";
1
+ import { Handler } from "../../types.js";
2
2
  export declare const create: (handler: Handler) => Handler;
@@ -1,18 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../logger");
5
- const create = (handler) => async (command) => {
1
+ import { get } from "../../logger/index.js";
2
+ export const create = (handler) => async (command) => {
6
3
  const commandHandler = await handler(command);
7
4
  return async (...args) => {
8
5
  try {
9
6
  await commandHandler(...args);
10
7
  }
11
8
  catch (err) {
12
- const { error } = (0, logger_1.get)("commands.handler.resilient");
9
+ const { error } = get("commands.handler.resilient");
13
10
  error("handler failed, ignoring it silently", err);
14
11
  }
15
12
  };
16
13
  };
17
- exports.create = create;
18
14
  /* jscpd:ignore-end */
@@ -1,2 +1,2 @@
1
- import { Handler, LeafCommand } from "../../../types";
1
+ import { Handler, LeafCommand } from "../../../types.js";
2
2
  export declare const create: (command: LeafCommand, errorMessage?: string) => Handler;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../../logger");
5
- const create = (command, errorMessage = "Command failed") => async (cCommand) => {
6
- const { output } = (0, logger_1.get)("handler.root");
1
+ import { get as getLogger } from "../../../logger/index.js";
2
+ export const create = (command, errorMessage = "Command failed") => async (cCommand) => {
3
+ const { output } = getLogger("handler.root");
7
4
  const hdlr = await command.handler(cCommand);
8
5
  return async (...args) => {
9
6
  try {
@@ -35,4 +32,3 @@ const create = (command, errorMessage = "Command failed") => async (cCommand) =>
35
32
  }
36
33
  };
37
34
  };
38
- exports.create = create;
@@ -1,2 +1,2 @@
1
- import { Handler } from "../../types";
1
+ import { Handler } from "../../types.js";
2
2
  export declare const create: (handler: Handler) => Handler;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../logger");
5
- const create = (handler) => {
1
+ import { get } from "../../logger/index.js";
2
+ export const create = (handler) => {
6
3
  const { stack } = new Error();
7
4
  return async (command) => {
8
5
  const commandHandler = await handler(command);
@@ -11,12 +8,11 @@ const create = (handler) => {
11
8
  await commandHandler(...args);
12
9
  }
13
10
  catch (err) {
14
- const { trace } = (0, logger_1.get)("commands.handler.stackTrace");
11
+ const { trace } = get("commands.handler.stackTrace");
15
12
  trace("handler was created from:", stack);
16
13
  throw err;
17
14
  }
18
15
  };
19
16
  };
20
17
  };
21
- exports.create = create;
22
18
  /* jscpd:ignore-end */
@@ -1,2 +1,2 @@
1
- import { Handler } from "../../types";
1
+ import { Handler } from "../../types.js";
2
2
  export declare const create: () => Handler;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.create = void 0;
4
- const logger_1 = require("../../logger");
5
- const create = () => async () => async () => {
6
- const { debug } = (0, logger_1.get)("commands.handler.succeed");
1
+ import { get } from "../../logger/index.js";
2
+ export const create = () => async () => async () => {
3
+ const { debug } = get("commands.handler.succeed");
7
4
  debug(`running succeed handler`);
8
5
  };
9
- exports.create = create;
@@ -1,4 +1,4 @@
1
- import { AuthenticationMethod } from "../../constants";
1
+ import { AuthenticationMethod } from "../../constants.js";
2
2
  export declare const getBooleanOption: (value: unknown) => boolean;
3
3
  export declare const replaceLeadingTrailingSingleQuotes: (value: string) => string;
4
4
  export declare const parseOption: (value: string) => string;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTargetHost = exports.setTargetHost = exports.getAuthenticationMethod = exports.setAuthenticationMethod = exports.parseOption = exports.replaceLeadingTrailingSingleQuotes = exports.getBooleanOption = void 0;
4
- const logger_1 = require("../../logger");
5
- const config_1 = require("../../config");
6
- const constants_1 = require("../../constants");
1
+ import { get } from "../../logger/index.js";
2
+ import { get as getConfig, set } from "../../config/index.js";
3
+ import { AuthenticationMethod } from "../../constants.js";
7
4
  const REGEX_LEADING_TRAILING_SINGLE_QUOTE = /^'.*'$/;
8
- const getLogger = () => (0, logger_1.get)("commands.handler.utils");
9
- const getBooleanOption = (value) => !!value;
10
- exports.getBooleanOption = getBooleanOption;
5
+ const getLogger = () => get("commands.handler.utils");
6
+ export const getBooleanOption = (value) => !!value;
11
7
  const decodeURIComponentInt = (value) => {
12
8
  const { error } = getLogger();
13
9
  try {
@@ -18,41 +14,36 @@ const decodeURIComponentInt = (value) => {
18
14
  throw err;
19
15
  }
20
16
  };
21
- const replaceLeadingTrailingSingleQuotes = (value) => {
17
+ export const replaceLeadingTrailingSingleQuotes = (value) => {
22
18
  if (REGEX_LEADING_TRAILING_SINGLE_QUOTE.test(value)) {
23
19
  return value.replace(/^'/, "").replace(/'$/, "");
24
20
  }
25
21
  return value;
26
22
  };
27
- exports.replaceLeadingTrailingSingleQuotes = replaceLeadingTrailingSingleQuotes;
28
- const parseOption = (value) => {
23
+ export const parseOption = (value) => {
29
24
  if (typeof value !== "string") {
30
25
  return value;
31
26
  }
32
27
  let v = value.trim();
33
28
  v = decodeURIComponentInt(v);
34
- v = (0, exports.replaceLeadingTrailingSingleQuotes)(v);
29
+ v = replaceLeadingTrailingSingleQuotes(v);
35
30
  return v;
36
31
  };
37
- exports.parseOption = parseOption;
38
- const setAuthenticationMethod = (authenticationMethod) => {
39
- (0, config_1.set)({ authenticationMethod });
32
+ export const setAuthenticationMethod = (authenticationMethod) => {
33
+ set({ authenticationMethod });
40
34
  };
41
- exports.setAuthenticationMethod = setAuthenticationMethod;
42
- const getAuthenticationMethod = () => (0, config_1.get)().authenticationMethod;
43
- exports.getAuthenticationMethod = getAuthenticationMethod;
44
- const setTargetHost = (targetHost) => {
45
- (0, config_1.set)({ targetHost });
35
+ export const getAuthenticationMethod = () => getConfig().authenticationMethod;
36
+ export const setTargetHost = (targetHost) => {
37
+ set({ targetHost });
46
38
  };
47
- exports.setTargetHost = setTargetHost;
48
- const getTargetHost = () => {
49
- const config = (0, config_1.get)();
39
+ export const getTargetHost = () => {
40
+ const config = getConfig();
50
41
  if (!config.targetHost) {
51
42
  throw new Error("no target host set");
52
43
  }
53
44
  if (config.hostSetFromCustomConfig) {
54
- const authenticationMethod = (0, exports.getAuthenticationMethod)();
55
- if (authenticationMethod === constants_1.AuthenticationMethod.oauth) {
45
+ const authenticationMethod = getAuthenticationMethod();
46
+ if (authenticationMethod === AuthenticationMethod.oauth) {
56
47
  const { warn } = getLogger();
57
48
  warn("Are you sure you want to use a custom configuration in combination with OAuth-based authentication?");
58
49
  }
@@ -60,4 +51,3 @@ const getTargetHost = () => {
60
51
  }
61
52
  return config.targetHost;
62
53
  };
63
- exports.getTargetHost = getTargetHost;
@@ -1,4 +1,4 @@
1
- import { CommanderHandler, LeafCommand } from "../types";
1
+ import { CommanderHandler, LeafCommand } from "../types.js";
2
2
  export declare const verifyHost: () => Promise<CommanderHandler>;
3
3
  declare const loginCommand: LeafCommand;
4
4
  export default loginCommand;