@sap/cli-core 2023.22.0 → 2023.24.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 +40 -0
- package/cache/secrets/SecretsStorageImpl.js +3 -2
- package/commands/handler/fetch/utils.d.ts +8 -1
- package/commands/handler/fetch/utils.js +21 -5
- package/commands/handler/input/file.js +1 -1
- package/commands/handler/options/index.d.ts +1 -2
- package/commands/handler/options/index.js +2 -4
- package/commands/handler/utils.js +7 -1
- package/constants.d.ts +1 -0
- package/constants.js +3 -2
- package/dwc/dwc.js +2 -1
- package/package.json +4 -3
- package/utils/http/index.js +12 -1
- package/utils/utils.js +2 -2
- package/commands/handler/options/pipe.d.ts +0 -2
- package/commands/handler/options/pipe.js +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,46 @@ 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.24.0
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- The defined HTTP protocol was not applied to calculated authorization URL and token URL. No matter which HTTP protocol (`http` or `https`) was used, the automatically calculated authorization URL and token URL always used the `https` protocol.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- HTTPS proxy support via environment variable `https_proxy`. When using an HTTPS proxy to communicate with the public internet, you can configure the environment variable `https_proxy`. The CLI uses the value from the environment variable to establish a correct connection to the HTTPS proxy.
|
|
17
|
+
|
|
18
|
+
- Support for response header `x-sap-datasphere-cli-file-name`. When the user adds option `--output` and provides a path to a file location, this value is always used to store the response data, no matter whether response header `x-sap-datasphere-cli-file-name` is present. If the user adds option `--output` without providing a path to a file location and the response header `x-sap-datasphere-cli-file-name` is present, the response data is stored in the location mentioned in `x-sap-datasphere-cli-file-name`. In all other cases, the response data is printed to the console.
|
|
19
|
+
|
|
20
|
+
## 2023.23.0
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- 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.
|
|
25
|
+
|
|
26
|
+
Trailing single quote is not removed: `some 'value'` stays `some 'value'`.
|
|
27
|
+
|
|
28
|
+
Trailing single quote is removed: `'some value'` becomes `some value`.
|
|
29
|
+
|
|
30
|
+
- The help output did not mention the correct CLI name. Instead the output showed the name 'terminal'.
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
Usage: terminal [options] [command]
|
|
34
|
+
|
|
35
|
+
Command-Line Interface for <product name>.
|
|
36
|
+
...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Since this version, the name is shown correctly.
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
Usage: <cli> [options] [command]
|
|
43
|
+
|
|
44
|
+
Command-Line Interface for <product name>.
|
|
45
|
+
...
|
|
46
|
+
```
|
|
47
|
+
|
|
8
48
|
## 2023.19.0
|
|
9
49
|
|
|
10
50
|
### Fixed
|
|
@@ -49,9 +49,10 @@ class SecretsStorageImpl {
|
|
|
49
49
|
}
|
|
50
50
|
async getDefaultSecretId() {
|
|
51
51
|
const tenantUrl = (0, utils_2.getTenantUrl)();
|
|
52
|
-
const
|
|
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(
|
|
55
|
+
throw new Error(`No secret found for host ${host}`);
|
|
55
56
|
}
|
|
56
57
|
return secret.id;
|
|
57
58
|
}
|
|
@@ -8,7 +8,14 @@ export declare const buildParameters: (path: string, parameterMappings?: Paramet
|
|
|
8
8
|
headers: KeyValuePair;
|
|
9
9
|
body: any;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* If --output is present: Return value of --output if defined, otherwise take value from outputPath.
|
|
13
|
+
* If --output is not present, print response to console
|
|
14
|
+
* @param outputPath Optional path defined by server
|
|
15
|
+
* @returns Path to output file
|
|
16
|
+
*/
|
|
17
|
+
export declare function getOutputFileName(outputPath?: string): string;
|
|
18
|
+
export declare const handleResponseData: (data: any, outputPath?: string) => Promise<void>;
|
|
12
19
|
export declare const handleResponse: (data: any, headers?: RawAxiosResponseHeaders | AxiosResponseHeaders) => Promise<void>;
|
|
13
20
|
export declare const configRequiresBody: (method: HTTPMethod) => boolean;
|
|
14
21
|
export declare const buildHttpConfig: (method: HTTPMethod, path: string, parameterMappings?: ParameterMappings) => HTTPConfig;
|
|
@@ -3,7 +3,7 @@ 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.handleResponseData = exports.buildParameters = exports.removeLeadingPathSegmentForPasscode = exports.checkConfiguration = void 0;
|
|
6
|
+
exports.buildHttpConfig = exports.configRequiresBody = exports.handleResponse = exports.handleResponseData = exports.getOutputFileName = exports.buildParameters = exports.removeLeadingPathSegmentForPasscode = exports.checkConfiguration = void 0;
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -103,7 +103,22 @@ const buildParameters = (path, parameterMappings) => {
|
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
105
|
exports.buildParameters = buildParameters;
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* If --output is present: Return value of --output if defined, otherwise take value from outputPath.
|
|
108
|
+
* If --output is not present, print response to console
|
|
109
|
+
* @param outputPath Optional path defined by server
|
|
110
|
+
* @returns Path to output file
|
|
111
|
+
*/
|
|
112
|
+
function getOutputFileName(outputPath = "") {
|
|
113
|
+
const config = (0, config_1.get)();
|
|
114
|
+
if (typeof config.options[constants_1.OPTION_OUTPUT.longName] === "boolean" &&
|
|
115
|
+
config.options[constants_1.OPTION_OUTPUT.longName]) {
|
|
116
|
+
return outputPath;
|
|
117
|
+
}
|
|
118
|
+
return config.options[constants_1.OPTION_OUTPUT.longName];
|
|
119
|
+
}
|
|
120
|
+
exports.getOutputFileName = getOutputFileName;
|
|
121
|
+
const handleResponseData = async (data, outputPath) => {
|
|
107
122
|
const config = (0, config_1.get)();
|
|
108
123
|
if (!config.doNotStoreResult) {
|
|
109
124
|
ResultHandlerFactory_1.ResultHandlerFactory.get().setResult(data);
|
|
@@ -112,8 +127,9 @@ const handleResponseData = async (data) => {
|
|
|
112
127
|
const formatted = config.options.pretty
|
|
113
128
|
? JSON.stringify(data, null, 2)
|
|
114
129
|
: JSON.stringify(data);
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
const outputFileName = getOutputFileName(outputPath);
|
|
131
|
+
if (outputFileName) {
|
|
132
|
+
await fs_extra_1.default.writeFile(outputFileName, formatted);
|
|
117
133
|
}
|
|
118
134
|
else {
|
|
119
135
|
output(formatted);
|
|
@@ -125,7 +141,7 @@ const handleResponse = async (data, headers) => {
|
|
|
125
141
|
(0, config_1.set)({ [constants_1.X_CSRF_TOKEN]: headers[constants_1.X_CSRF_TOKEN] });
|
|
126
142
|
}
|
|
127
143
|
else if (data) {
|
|
128
|
-
await (0, exports.handleResponseData)(data);
|
|
144
|
+
await (0, exports.handleResponseData)(data, headers?.[constants_1.X_OUTPUT_FILE_NAME]);
|
|
129
145
|
}
|
|
130
146
|
};
|
|
131
147
|
exports.handleResponse = handleResponse;
|
|
@@ -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
|
|
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, {
|
|
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, {
|
|
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(
|
|
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) =>
|
|
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/constants.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare const CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
|
|
|
18
18
|
export declare const SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH: string[];
|
|
19
19
|
export declare const DISCOVERY_METADATA_PATH = "discovery-metadata.json";
|
|
20
20
|
export declare const X_CSRF_TOKEN = "x-csrf-token";
|
|
21
|
+
export declare const X_OUTPUT_FILE_NAME = "x-sap-datasphere-cli-file-name";
|
|
21
22
|
export declare const PATH_TO_SUCCESS_HTML: string;
|
|
22
23
|
export declare const PATH_TO_ERROR_HTML: string;
|
|
23
24
|
export declare const CACHE_SECRETS_FILE = "secrets.json";
|
package/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.OPTION_INPUT = exports.OPTION_FILE_PATH = exports.OPTION_OPTIONS_FILE = exports.CONFIG_PASSCODE_FUNCTION = exports.OPTION_PASSCODE = exports.OPTION_CODE = exports.OPTION_SECRETS_FILE = exports.OPTION_EXPIRES_IN = exports.OPTION_REFRESH_TOKEN = exports.OPTION_ACCESS_TOKEN = exports.OPTION_TOKEN_URL = exports.OPTION_AUTHORIZATION_URL = exports.OPTION_CLIENT_SECRET = exports.OPTION_CLIENT_ID = exports.OPTION_FORCE = exports.OPTION_VERBOSE = exports.OPTION_NO_PRETTY = exports.OPTION_OUTPUT = exports.OPTION_LOGIN_ID = exports.OPTION_HOST = exports.OPTION_HELP = exports.OPTION_VERSION = exports.CACHE_SECRETS_FILE = exports.PATH_TO_ERROR_HTML = exports.PATH_TO_SUCCESS_HTML = exports.X_CSRF_TOKEN = exports.DISCOVERY_METADATA_PATH = exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = exports.CLI_GENERIC_OPTIONS_HELP = exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = exports.CLI_DEPRECATION_MESSAGE = exports.CLI_DEPRECATED = exports.CLI_VERSION = exports.CLI_SAP_HELP = exports.CLI_DISCOVERY_PATH = exports.CLI_DESCRIPTION = exports.CLI_PACKAGE_NAME = exports.CLI_NAME = exports.AuthenticationMethod = exports.DISCOVERY_DOCUMENT_PREFIX = exports.VERSION = void 0;
|
|
6
|
+
exports.OPTION_INPUT = exports.OPTION_FILE_PATH = exports.OPTION_OPTIONS_FILE = exports.CONFIG_PASSCODE_FUNCTION = exports.OPTION_PASSCODE = exports.OPTION_CODE = exports.OPTION_SECRETS_FILE = exports.OPTION_EXPIRES_IN = exports.OPTION_REFRESH_TOKEN = exports.OPTION_ACCESS_TOKEN = exports.OPTION_TOKEN_URL = exports.OPTION_AUTHORIZATION_URL = exports.OPTION_CLIENT_SECRET = exports.OPTION_CLIENT_ID = exports.OPTION_FORCE = exports.OPTION_VERBOSE = exports.OPTION_NO_PRETTY = exports.OPTION_OUTPUT = exports.OPTION_LOGIN_ID = exports.OPTION_HOST = exports.OPTION_HELP = exports.OPTION_VERSION = exports.CACHE_SECRETS_FILE = exports.PATH_TO_ERROR_HTML = exports.PATH_TO_SUCCESS_HTML = exports.X_OUTPUT_FILE_NAME = exports.X_CSRF_TOKEN = exports.DISCOVERY_METADATA_PATH = exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = exports.CLI_GENERIC_OPTIONS_HELP = exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = exports.CLI_DEPRECATION_MESSAGE = exports.CLI_DEPRECATED = exports.CLI_VERSION = exports.CLI_SAP_HELP = exports.CLI_DISCOVERY_PATH = exports.CLI_DESCRIPTION = exports.CLI_PACKAGE_NAME = exports.CLI_NAME = exports.AuthenticationMethod = exports.DISCOVERY_DOCUMENT_PREFIX = exports.VERSION = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_1 = require("./utils/utils");
|
|
9
9
|
exports.VERSION = (0, utils_1.getVersion)();
|
|
@@ -26,6 +26,7 @@ exports.CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
|
|
|
26
26
|
exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = ["dwaas-core"];
|
|
27
27
|
exports.DISCOVERY_METADATA_PATH = "discovery-metadata.json";
|
|
28
28
|
exports.X_CSRF_TOKEN = "x-csrf-token";
|
|
29
|
+
exports.X_OUTPUT_FILE_NAME = "x-sap-datasphere-cli-file-name";
|
|
29
30
|
exports.PATH_TO_SUCCESS_HTML = path_1.default.join(__dirname, "assets", "success.html");
|
|
30
31
|
exports.PATH_TO_ERROR_HTML = path_1.default.join(__dirname, "assets", "error.html");
|
|
31
32
|
exports.CACHE_SECRETS_FILE = "secrets.json";
|
|
@@ -64,7 +65,7 @@ exports.OPTION_LOGIN_ID = {
|
|
|
64
65
|
exports.OPTION_OUTPUT = {
|
|
65
66
|
longName: "output",
|
|
66
67
|
description: "specifies the file to store the output of the command",
|
|
67
|
-
args: [{ name: "output" }],
|
|
68
|
+
args: [{ name: "output", optional: true }],
|
|
68
69
|
hidden: true,
|
|
69
70
|
};
|
|
70
71
|
exports.OPTION_NO_PRETTY = {
|
package/dwc/dwc.js
CHANGED
|
@@ -115,10 +115,11 @@ 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
|
-
const cliName = (0, config_1.get)()[constants_1.CLI_NAME];
|
|
122
123
|
program.showHelpAfterError(`Make sure to always define the host using the --host option or by running ${cliName}` +
|
|
123
124
|
` config host set "<Server_URL>". Did you initialize the CLI by running ${cliName} config` +
|
|
124
125
|
` cache init --host "<Server_URL>"?` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cli-core",
|
|
3
|
-
"version": "2023.
|
|
3
|
+
"version": "2023.24.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,13 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"ajv": "8.12.0",
|
|
21
|
-
"axios": "1.5.
|
|
22
|
-
"commander": "11.
|
|
21
|
+
"axios": "1.5.1",
|
|
22
|
+
"commander": "11.1.0",
|
|
23
23
|
"config": "3.3.9",
|
|
24
24
|
"dotenv": "16.3.1",
|
|
25
25
|
"fs-extra": "11.1.1",
|
|
26
26
|
"https": "1.0.0",
|
|
27
|
+
"https-proxy-agent": "7.0.2",
|
|
27
28
|
"lodash": "4.17.21",
|
|
28
29
|
"open": "8.4.2",
|
|
29
30
|
"path": "0.12.7",
|
package/utils/http/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetch = exports.DEFAULTS = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
8
9
|
const config_1 = require("../../config");
|
|
9
10
|
const logger_1 = require("../../logger");
|
|
10
11
|
const constants_1 = require("../../constants");
|
|
@@ -13,10 +14,11 @@ const core_1 = require("../../config/core");
|
|
|
13
14
|
exports.DEFAULTS = {
|
|
14
15
|
maxBodyLength: -1,
|
|
15
16
|
maxContentLength: -1,
|
|
16
|
-
maxRedirects: 0, // must be set to 0 because maxBodyLength: -1 won't work otherwise, see github.com/axios/axios/issues/4263
|
|
17
|
+
maxRedirects: 0, // must be set to 0 because maxBodyLength: -1 won't work otherwise, see github.com/axios/axios/issues/4263,
|
|
17
18
|
};
|
|
18
19
|
const HEADERS_ETAG = "x-sap-cli-core-discovery-etag";
|
|
19
20
|
const getLogger = () => (0, logger_1.get)("http");
|
|
21
|
+
const HTTPS_PROXY = process.env.https_proxy ?? process.env.HTTPS_PROXY;
|
|
20
22
|
const setEtag = (headers) => {
|
|
21
23
|
const { debug } = getLogger();
|
|
22
24
|
if (headers?.[HEADERS_ETAG]) {
|
|
@@ -38,7 +40,16 @@ const fetch = async (config) => {
|
|
|
38
40
|
output("%s %s", config.method.toUpperCase(), config.url);
|
|
39
41
|
}
|
|
40
42
|
debug("http config: %s", JSON.stringify(config));
|
|
43
|
+
const httpsAgent = HTTPS_PROXY ? new https_proxy_agent_1.HttpsProxyAgent(HTTPS_PROXY) : null;
|
|
44
|
+
if (httpsAgent && cnfg.verbose) {
|
|
45
|
+
output(`using https proxy agent for https proxy`);
|
|
46
|
+
debug(`using https proxy agent for https proxy ${HTTPS_PROXY}`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
debug("no https proxy defined via environment variable https_proxy");
|
|
50
|
+
}
|
|
41
51
|
const res = await (0, axios_1.default)({
|
|
52
|
+
httpsAgent,
|
|
42
53
|
...config,
|
|
43
54
|
...exports.DEFAULTS,
|
|
44
55
|
headers: {
|
package/utils/utils.js
CHANGED
|
@@ -148,8 +148,8 @@ const getInfoFromTenant = (tenant, verbose, printOutput = true) => {
|
|
|
148
148
|
host: `${protocol}//dwaas-core.sac${region}.cfapps.orca.net.sap`,
|
|
149
149
|
publicfqdn: parsedTenant,
|
|
150
150
|
passcodeUrl: `https://${hostname}.authentication.${region}.hana.ondemand.com/passcode`,
|
|
151
|
-
authorizationUrl:
|
|
152
|
-
tokenUrl:
|
|
151
|
+
authorizationUrl: `${protocol}//${hostname}.authentication.${region}.hana.ondemand.com/oauth/authorize`,
|
|
152
|
+
tokenUrl: `${protocol}//${hostname}.authentication.${region}.hana.ondemand.com/oauth/token`,
|
|
153
153
|
tenantUrl: `${protocol}//${parsedTenant}`,
|
|
154
154
|
};
|
|
155
155
|
};
|
|
@@ -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;
|