@sap/cli-core 2024.16.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
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
|
|
@@ -95,10 +95,19 @@ const handleParameterMapping = (config, url, headers, bodyWrapper) => (mapping)
|
|
|
95
95
|
exports.handleParameterMapping = handleParameterMapping;
|
|
96
96
|
const buildParameters = (path, parameterMappings) => {
|
|
97
97
|
const config = (0, config_1.get)();
|
|
98
|
-
const headers = {};
|
|
99
98
|
const bodyWrapper = {
|
|
100
|
-
body:
|
|
99
|
+
body: undefined,
|
|
101
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
|
+
}
|
|
102
111
|
const url = getUrl(path);
|
|
103
112
|
parameterMappings?.forEach((0, exports.handleParameterMapping)(config, url, headers, bodyWrapper));
|
|
104
113
|
return {
|
|
@@ -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/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,12 +17,13 @@
|
|
|
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.
|
|
23
|
+
"compare-versions": "6.1.1",
|
|
24
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
29
|
"https-proxy-agent": "7.0.5",
|
|
@@ -30,6 +31,6 @@
|
|
|
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
|
}
|