@sap/cli-core 2024.15.0 → 2024.18.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 +6 -0
- package/cache/secrets/utils.js +2 -2
- package/commands/config.command/cache.command/init.command/utils.js +2 -3
- package/commands/handler/fetch/utils.d.ts +0 -1
- package/commands/handler/fetch/utils.js +16 -6
- package/commands/handler/input/file.js +22 -3
- package/dwc/utils.js +2 -2
- package/package.json +8 -7
- package/utils/commands.js +2 -2
- package/utils/openUtils.js +3 -3
- package/utils/utils.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ 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.17.0
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support for binary files. Binary files can be specified as input for a command. The content is send as a buffer to the server. The `Content-Type` header is set to `multipart/form-data`.
|
|
13
|
+
|
|
8
14
|
## 2024.15.0
|
|
9
15
|
|
|
10
16
|
### Changed
|
package/cache/secrets/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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.
|
|
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;
|
|
@@ -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.
|
|
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"));
|
|
@@ -92,10 +95,19 @@ const handleParameterMapping = (config, url, headers, bodyWrapper) => (mapping)
|
|
|
92
95
|
exports.handleParameterMapping = handleParameterMapping;
|
|
93
96
|
const buildParameters = (path, parameterMappings) => {
|
|
94
97
|
const config = (0, config_1.get)();
|
|
95
|
-
const headers = {};
|
|
96
98
|
const bodyWrapper = {
|
|
97
|
-
body:
|
|
99
|
+
body: undefined,
|
|
98
100
|
};
|
|
101
|
+
let headers = {};
|
|
102
|
+
if (config.data?.type === "file") {
|
|
103
|
+
// stackoverflow.com/a/59177066
|
|
104
|
+
headers = config.data.content.getHeaders();
|
|
105
|
+
bodyWrapper.body = config.data.content;
|
|
106
|
+
}
|
|
107
|
+
else if (config.data?.type === "json") {
|
|
108
|
+
headers = { "Content-Type": "application/json" };
|
|
109
|
+
bodyWrapper.body = config.data.content;
|
|
110
|
+
}
|
|
99
111
|
const url = getUrl(path);
|
|
100
112
|
parameterMappings?.forEach((0, exports.handleParameterMapping)(config, url, headers, bodyWrapper));
|
|
101
113
|
return {
|
|
@@ -119,7 +131,6 @@ function getOutputFileName(outputPath = "") {
|
|
|
119
131
|
}
|
|
120
132
|
return config.options[constants_1.OPTION_OUTPUT.longName];
|
|
121
133
|
}
|
|
122
|
-
exports.getOutputFileName = getOutputFileName;
|
|
123
134
|
function checkResponseDataForInvalidLoginData(response) {
|
|
124
135
|
if (
|
|
125
136
|
// jira.tools.sap/browse/DW101-73607
|
|
@@ -132,7 +143,6 @@ function checkResponseDataForInvalidLoginData(response) {
|
|
|
132
143
|
}
|
|
133
144
|
return false;
|
|
134
145
|
}
|
|
135
|
-
exports.checkResponseDataForInvalidLoginData = checkResponseDataForInvalidLoginData;
|
|
136
146
|
const handleResponseData = async (data, outputPath) => {
|
|
137
147
|
checkResponseDataForInvalidLoginData(data);
|
|
138
148
|
const config = (0, config_1.get)();
|
|
@@ -185,7 +195,6 @@ function handleResponseHeaders(headers) {
|
|
|
185
195
|
}
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
|
-
exports.handleResponseHeaders = handleResponseHeaders;
|
|
189
198
|
const handleResponse = async (data, headers) => {
|
|
190
199
|
if (headers?.[constants_1.X_CSRF_TOKEN]) {
|
|
191
200
|
(0, config_1.set)({ [constants_1.X_CSRF_TOKEN]: headers[constants_1.X_CSRF_TOKEN] });
|
|
@@ -212,6 +221,7 @@ const buildHttpConfig = (method, path, parameterMappings) => {
|
|
|
212
221
|
headers: {
|
|
213
222
|
...config.authorization,
|
|
214
223
|
...headers,
|
|
224
|
+
...config.headers,
|
|
215
225
|
publicfqdn: config.publicfqdn,
|
|
216
226
|
},
|
|
217
227
|
};
|
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.create = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
8
10
|
const config_1 = require("../../../config");
|
|
9
11
|
const logger_1 = require("../../../logger");
|
|
10
12
|
const constants_1 = require("../../../constants");
|
|
@@ -19,9 +21,26 @@ const readBodyFromFile = async () => async () => {
|
|
|
19
21
|
const { debug, trace } = logger;
|
|
20
22
|
debug("reading request body from %s", filePath);
|
|
21
23
|
try {
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (filePath.endsWith(".json")) {
|
|
25
|
+
(0, config_1.set)({
|
|
26
|
+
data: {
|
|
27
|
+
type: "json",
|
|
28
|
+
content: JSON.parse(await fs_extra_1.default.readFile(filePath, "utf-8")),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const form = new form_data_1.default();
|
|
34
|
+
form.append("file", fs_extra_1.default.createReadStream(filePath));
|
|
35
|
+
(0, config_1.set)({
|
|
36
|
+
data: {
|
|
37
|
+
type: "file",
|
|
38
|
+
content: form,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const filename = path_1.default.basename(filePath);
|
|
43
|
+
(0, config_1.set)({ headers: { [constants_1.X_OUTPUT_FILE_NAME]: filename } });
|
|
25
44
|
}
|
|
26
45
|
catch (err) {
|
|
27
46
|
(0, utils_1.logVerbose)(logger, `Failed to read content from file ${filePath}. Does the file really exist and does it contain valid JSON?`);
|
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.
|
|
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.
|
|
3
|
+
"version": "2024.18.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,20 @@
|
|
|
17
17
|
"cli-core"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"ajv": "8.
|
|
21
|
-
"axios": "1.7.
|
|
20
|
+
"ajv": "8.17.1",
|
|
21
|
+
"axios": "1.7.3",
|
|
22
22
|
"commander": "12.1.0",
|
|
23
|
-
"compare-versions": "6.1.
|
|
24
|
-
"config": "3.3.
|
|
23
|
+
"compare-versions": "6.1.1",
|
|
24
|
+
"config": "3.3.12",
|
|
25
25
|
"dotenv": "16.4.5",
|
|
26
|
+
"form-data": "4.0.0",
|
|
26
27
|
"fs-extra": "11.2.0",
|
|
27
28
|
"https": "1.0.0",
|
|
28
|
-
"https-proxy-agent": "7.0.
|
|
29
|
+
"https-proxy-agent": "7.0.5",
|
|
29
30
|
"lodash": "4.17.21",
|
|
30
31
|
"open": "8.4.2",
|
|
31
32
|
"path": "0.12.7",
|
|
32
33
|
"prompts": "2.4.2",
|
|
33
|
-
"qs": "6.
|
|
34
|
+
"qs": "6.13.0"
|
|
34
35
|
}
|
|
35
36
|
}
|
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.
|
|
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] ?? {})) {
|
package/utils/openUtils.js
CHANGED
|
@@ -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 =
|
|
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.
|
|
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");
|