@sap/cli-core 2024.9.0 → 2024.12.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 +95 -0
- package/cache/secrets/SecretsStorageImpl.d.ts +2 -0
- package/cache/secrets/SecretsStorageImpl.js +37 -12
- package/cache/secrets/utils.d.ts +2 -0
- package/cache/secrets/utils.js +9 -1
- package/commands/config.command/cache.command/clean.command.js +16 -3
- package/commands/config.command/index.js +25 -2
- package/commands/config.command/secrets.command/index.js +2 -1
- package/commands/config.command/secrets.command/refresh.command.d.ts +3 -0
- package/commands/config.command/secrets.command/refresh.command.js +13 -0
- package/commands/handler/authentication/oauth/tokenProvider/getToken.js +1 -0
- package/commands/handler/authentication/oauth/tokenProvider/utils.js +66 -58
- package/commands/handler/authentication/oauth/utils.js +8 -0
- package/commands/handler/authentication/technicalJWT/index.js +1 -1
- package/commands/handler/authentication/technicalJWT/utils.js +1 -1
- package/commands/handler/fetch/utils.d.ts +6 -1
- package/commands/handler/fetch/utils.js +60 -8
- package/commands/handler/input/file.js +4 -5
- package/commands/handler/input/input.js +5 -7
- package/commands/handler/next.js +1 -1
- package/commands/handler/options/utils.js +1 -1
- package/commands/handler/or.js +1 -1
- package/commands/handler/root/index.d.ts +2 -2
- package/commands/handler/root/index.js +22 -2
- package/commands/login.command.js +1 -1
- package/commands/openAPI.command/index.js +3 -2
- package/commands/openAPI.command/utils.d.ts +2 -1
- package/commands/openAPI.command/utils.js +22 -9
- package/constants.d.ts +2 -1
- package/constants.js +3 -24
- package/discovery/index.d.ts +1 -1
- package/discovery/index.js +7 -3
- package/dwc/dwc.js +5 -5
- package/dwc/run.js +1 -1
- package/dwc/utils.d.ts +1 -1
- package/dwc/utils.js +4 -4
- package/index.d.ts +3 -3
- package/package.json +5 -5
- package/schemas/discovery.json +13 -1
- package/types.d.ts +21 -1
- package/types.js +21 -1
- package/utils/commands.d.ts +4 -4
- package/utils/commands.js +64 -29
- package/utils/http/index.js +5 -5
- package/utils/utils.d.ts +2 -1
- package/utils/utils.js +2 -2
package/dwc/dwc.js
CHANGED
|
@@ -43,9 +43,9 @@ const setTenant = async () => {
|
|
|
43
43
|
if (config.host) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const readHostFromArgv = async () => (0, utils_1.getOptionValueFromArgv)(constants_1.
|
|
46
|
+
const readHostFromArgv = async () => (0, utils_1.getOptionValueFromArgv)(constants_1.ROOT_COMMAND, constants_1.OPTION_HOST);
|
|
47
47
|
const readHostFromOptionsFile = async () => {
|
|
48
|
-
const filePath = (0, utils_1.getOptionValueFromArgv)(constants_1.
|
|
48
|
+
const filePath = (0, utils_1.getOptionValueFromArgv)(constants_1.ROOT_COMMAND, constants_1.OPTION_OPTIONS_FILE);
|
|
49
49
|
return (0, utils_2.getValueFromOptionsFile)(filePath, constants_1.OPTION_HOST);
|
|
50
50
|
};
|
|
51
51
|
const readHostFromOptions = async () => {
|
|
@@ -100,7 +100,7 @@ const initCacheTolerant = async () => {
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
102
|
const registerMandatoryOptions = () => {
|
|
103
|
-
MANDATORY_OPTIONS.forEach((option) => (0, commands_1.registerLongName)(constants_1.
|
|
103
|
+
MANDATORY_OPTIONS.forEach((option) => (0, commands_1.registerLongName)(constants_1.ROOT_COMMAND, option));
|
|
104
104
|
};
|
|
105
105
|
async function setupSecretsStorage() {
|
|
106
106
|
const instance = new SecretsStorageImpl_1.SecretsStorageImpl();
|
|
@@ -129,8 +129,8 @@ const init = async () => {
|
|
|
129
129
|
` config host set "<Server_URL>". Did you initialize the CLI by running ${cliName} config` +
|
|
130
130
|
` cache init --host "<Server_URL>"?` +
|
|
131
131
|
` Add option --help, -h or go to ${(0, config_1.get)()[constants_1.CLI_SAP_HELP]} for additional information.`);
|
|
132
|
-
program.addOption(await (0, commands_1.buildOption)(constants_1.
|
|
133
|
-
program.addOption(await (0, commands_1.buildOption)(constants_1.
|
|
132
|
+
program.addOption(await (0, commands_1.buildOption)(constants_1.ROOT_COMMAND, constants_1.OPTION_HOST));
|
|
133
|
+
program.addOption(await (0, commands_1.buildOption)(constants_1.ROOT_COMMAND, constants_1.OPTION_OPTIONS_FILE));
|
|
134
134
|
program.configureHelp({ sortSubcommands: true });
|
|
135
135
|
program.addHelpText("afterAll", `Only command-specific options are listed here. To learn more about available generic options,` +
|
|
136
136
|
` visit ${(0, core_1.getGenericOptionsHelp)()}`);
|
package/dwc/run.js
CHANGED
|
@@ -26,7 +26,7 @@ const run = async () => {
|
|
|
26
26
|
finally {
|
|
27
27
|
await (0, utils_1.compareEtags)();
|
|
28
28
|
if ((0, core_1.isDeprecated)()) {
|
|
29
|
-
const message = (0, core_1.getDeprecationMessage)()
|
|
29
|
+
const message = (0, core_1.getDeprecationMessage)() ??
|
|
30
30
|
"WARNING: This package has been deprecated. Please consult the README or CHANGELOG for more information.";
|
|
31
31
|
output(message);
|
|
32
32
|
}
|
package/dwc/utils.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export declare const addCommandsFromFolder: (pathToFolder: string, program: Comm
|
|
|
4
4
|
export declare function verifyNodeVersion(): void;
|
|
5
5
|
export declare const checkVersion: () => Promise<void>;
|
|
6
6
|
export declare const compareEtags: () => Promise<void>;
|
|
7
|
-
export declare const getOptionValueFromArgv: (
|
|
7
|
+
export declare const getOptionValueFromArgv: (command: Command, option: Option) => string;
|
package/dwc/utils.js
CHANGED
|
@@ -20,11 +20,11 @@ const addCommandsFromFolder = async (pathToFolder, program) => {
|
|
|
20
20
|
withFileTypes: false,
|
|
21
21
|
})).filter((f) => f.includes(".command") && !f.endsWith(".d.ts"))) {
|
|
22
22
|
try {
|
|
23
|
-
// eslint-disable-next-line
|
|
23
|
+
// eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires
|
|
24
24
|
const content = require(path_1.default.join(pathToFolder, file));
|
|
25
25
|
if (content.addCommands) {
|
|
26
26
|
debug("adding commands from file %s.addCommands", file);
|
|
27
|
-
// eslint-disable-next-line
|
|
27
|
+
// eslint-disable-next-line no-await-in-loop
|
|
28
28
|
await content.addCommands(program);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
@@ -69,8 +69,8 @@ const compareEtags = async () => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
exports.compareEtags = compareEtags;
|
|
72
|
-
const getOptionValueFromArgv = (
|
|
73
|
-
const shortFlag = (0, commands_1.getShortFlagForLongName)(
|
|
72
|
+
const getOptionValueFromArgv = (command, option) => {
|
|
73
|
+
const shortFlag = (0, commands_1.getShortFlagForLongName)(command, option);
|
|
74
74
|
const index = process.argv.findIndex((a) => a === `-${shortFlag}` || a === `--${option.longName}`);
|
|
75
75
|
if (index > -1) {
|
|
76
76
|
return process.argv[index + 1];
|
package/index.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ export declare const configureCoreModule: ({ name, packageName, discoveryPaths,
|
|
|
9
9
|
discoveryPaths: Array<string>;
|
|
10
10
|
description: string;
|
|
11
11
|
sapHelpLink: string;
|
|
12
|
-
authenticationMethods?: AuthenticationMethod
|
|
12
|
+
authenticationMethods?: Array<AuthenticationMethod>;
|
|
13
13
|
version: string;
|
|
14
14
|
genericOptionsHelp: string;
|
|
15
|
-
deprecated?: boolean
|
|
16
|
-
deprecationMessage?: string
|
|
15
|
+
deprecated?: boolean;
|
|
16
|
+
deprecationMessage?: string;
|
|
17
17
|
}) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cli-core",
|
|
3
|
-
"version": "2024.
|
|
3
|
+
"version": "2024.12.0",
|
|
4
4
|
"description": "Command-Line Interface (CLI) Core Module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "SAP SE",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"cli-core"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"ajv": "8.
|
|
21
|
-
"axios": "1.
|
|
22
|
-
"commander": "
|
|
20
|
+
"ajv": "8.13.0",
|
|
21
|
+
"axios": "1.7.1",
|
|
22
|
+
"commander": "12.1.0",
|
|
23
23
|
"compare-versions": "6.1.0",
|
|
24
24
|
"config": "3.3.11",
|
|
25
25
|
"dotenv": "16.4.5",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"open": "8.4.2",
|
|
31
31
|
"path": "0.12.7",
|
|
32
32
|
"prompts": "2.4.2",
|
|
33
|
-
"qs": "6.12.
|
|
33
|
+
"qs": "6.12.1"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/schemas/discovery.json
CHANGED
|
@@ -93,9 +93,21 @@
|
|
|
93
93
|
"description": {
|
|
94
94
|
"type": "string"
|
|
95
95
|
},
|
|
96
|
-
"
|
|
96
|
+
"deprecated": {
|
|
97
97
|
"type": "boolean"
|
|
98
98
|
},
|
|
99
|
+
"x-deprecated-with-wave": {
|
|
100
|
+
"type": "string"
|
|
101
|
+
},
|
|
102
|
+
"x-decommissioned-after-wave": {
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"x-deprecation-new-command": {
|
|
106
|
+
"type": "string"
|
|
107
|
+
},
|
|
108
|
+
"x-deprecation-sap-help-url": {
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
99
111
|
"x-user-to-confirm": {
|
|
100
112
|
"type": "string"
|
|
101
113
|
},
|
package/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type Secret = {
|
|
|
17
17
|
scope: string;
|
|
18
18
|
id_token: string;
|
|
19
19
|
};
|
|
20
|
+
export declare const ALLOWED_SECRET_TYPES: string[];
|
|
20
21
|
export { HTTPMethod, HTTPConfig, HTTPResponse };
|
|
21
22
|
export type In = "query" | "body" | "header" | "path";
|
|
22
23
|
export type DataType = "boolean" | "string" | "number";
|
|
@@ -76,6 +77,11 @@ export type Operation = {
|
|
|
76
77
|
parameters?: Array<JSONReference | Parameter>;
|
|
77
78
|
summary?: string;
|
|
78
79
|
description?: string;
|
|
80
|
+
deprecated?: boolean;
|
|
81
|
+
"x-deprecation-new-command"?: string;
|
|
82
|
+
"x-deprecated-with-wave"?: string;
|
|
83
|
+
"x-decommissioned-after-wave"?: string;
|
|
84
|
+
"x-deprecation-sap-help-url"?: string;
|
|
79
85
|
"x-requestbody-fileonly"?: boolean;
|
|
80
86
|
"x-user-to-confirm"?: string;
|
|
81
87
|
"x-read-path"?: string;
|
|
@@ -136,6 +142,7 @@ export type PackageJson = {
|
|
|
136
142
|
export type DiscoveryMetadata = {
|
|
137
143
|
tenant: string;
|
|
138
144
|
addedAt: number;
|
|
145
|
+
hash: string;
|
|
139
146
|
};
|
|
140
147
|
export type KeyValuePair = {
|
|
141
148
|
[key: string]: any;
|
|
@@ -144,7 +151,6 @@ export type DefaultFunction = () => Promise<string>;
|
|
|
144
151
|
export type ChoicesFunction = () => Promise<Array<string>>;
|
|
145
152
|
export type Choices = Array<string>;
|
|
146
153
|
export type Option = {
|
|
147
|
-
commandName?: string;
|
|
148
154
|
longName: string;
|
|
149
155
|
description: string;
|
|
150
156
|
default?: string | DefaultFunction;
|
|
@@ -185,9 +191,23 @@ export type LeafCommand = {
|
|
|
185
191
|
command: string;
|
|
186
192
|
description: string;
|
|
187
193
|
options?: Array<Option>;
|
|
194
|
+
deprecationInfo?: {
|
|
195
|
+
deprecated: boolean;
|
|
196
|
+
newCommand?: string;
|
|
197
|
+
deprecatedWithWave?: string;
|
|
198
|
+
decommissionedAfterWave?: string;
|
|
199
|
+
sapHelpUrl?: string;
|
|
200
|
+
};
|
|
188
201
|
args?: Array<CommandsArgument>;
|
|
189
202
|
handler: Handler;
|
|
190
203
|
};
|
|
204
|
+
export type DeprecatedProperties = Array<{
|
|
205
|
+
name: string;
|
|
206
|
+
deprecatedWithWave?: string;
|
|
207
|
+
decommissionedAfterWave?: string;
|
|
208
|
+
sapHelpUrl?: string;
|
|
209
|
+
customMessage?: string;
|
|
210
|
+
}>;
|
|
191
211
|
export type Command = TopCommand | LeafCommand;
|
|
192
212
|
export type AddCommands = (program: CommandType) => Promise<void>;
|
|
193
213
|
export type ResponsePostProcessor = (response: HTTPResponse) => Promise<void>;
|
package/types.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHARACTERS = exports.LogLevel = void 0;
|
|
3
|
+
exports.CHARACTERS = exports.LogLevel = exports.ALLOWED_SECRET_TYPES = void 0;
|
|
4
|
+
// unfortunately there does not seem to be a good solution to automatically
|
|
5
|
+
// create the below array from a statically defined type. Thus, the array must
|
|
6
|
+
// always be kept in sync with the type Secret defined above.
|
|
7
|
+
exports.ALLOWED_SECRET_TYPES = [
|
|
8
|
+
"id",
|
|
9
|
+
"tenantUrl",
|
|
10
|
+
"customClient",
|
|
11
|
+
"client_id",
|
|
12
|
+
"client_secret",
|
|
13
|
+
"access_token",
|
|
14
|
+
"expires_in",
|
|
15
|
+
"expires_after",
|
|
16
|
+
"refresh_token",
|
|
17
|
+
"token_url",
|
|
18
|
+
"authorization_url",
|
|
19
|
+
"token_type",
|
|
20
|
+
"jti",
|
|
21
|
+
"scope",
|
|
22
|
+
"id_token",
|
|
23
|
+
];
|
|
4
24
|
var LogLevel;
|
|
5
25
|
(function (LogLevel) {
|
|
6
26
|
LogLevel[LogLevel["INACTIVE"] = 1] = "INACTIVE";
|
package/utils/commands.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import commander, { Command, Option } from "commander";
|
|
2
2
|
import { Command as CommandType, Option as OptionType } from "../types";
|
|
3
3
|
export declare const createCommand: (name?: string) => Command;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare const getShortFlagForLongName: (
|
|
4
|
+
export declare function getAbsoluteCommandName(command: Command): string;
|
|
5
|
+
export declare const getShortFlagForLongName: (command: Command, option: OptionType) => string;
|
|
6
6
|
export declare const isOptionAlreadyRegistered: ({ longName }: OptionType, command: Command) => boolean;
|
|
7
|
-
export declare const registerLongName: (
|
|
8
|
-
export declare const buildOption: (
|
|
7
|
+
export declare const registerLongName: (command: Command, option: OptionType) => string;
|
|
8
|
+
export declare const buildOption: (command: Command, option: OptionType) => Promise<Option>;
|
|
9
9
|
export declare const buildCommand: (topCommand: commander.Command, command: CommandType) => Promise<commander.Command>;
|
package/utils/commands.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildCommand = exports.buildOption = exports.registerLongName = exports.isOptionAlreadyRegistered = exports.getShortFlagForLongName = exports.
|
|
6
|
+
exports.buildCommand = exports.buildOption = exports.registerLongName = exports.isOptionAlreadyRegistered = exports.getShortFlagForLongName = exports.getAbsoluteCommandName = exports.createCommand = void 0;
|
|
4
7
|
const commander_1 = require("commander");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
5
9
|
const types_1 = require("../types");
|
|
6
10
|
const root_1 = require("../commands/handler/root");
|
|
7
11
|
const logger_1 = require("../logger");
|
|
@@ -34,18 +38,21 @@ const createCommand = (name) => {
|
|
|
34
38
|
return command;
|
|
35
39
|
};
|
|
36
40
|
exports.createCommand = createCommand;
|
|
37
|
-
function
|
|
38
|
-
|
|
41
|
+
function getAbsoluteCommandName(command) {
|
|
42
|
+
if (!command.parent) {
|
|
43
|
+
return command.name();
|
|
44
|
+
}
|
|
45
|
+
return `${getAbsoluteCommandName(command.parent)}.${command.name()}`;
|
|
39
46
|
}
|
|
40
|
-
exports.
|
|
41
|
-
const getShortFlagForLongName = (
|
|
42
|
-
const
|
|
43
|
-
for (const s of Object.keys(registeredOptions[
|
|
44
|
-
if (registeredOptions[
|
|
47
|
+
exports.getAbsoluteCommandName = getAbsoluteCommandName;
|
|
48
|
+
const getShortFlagForLongName = (command, option) => {
|
|
49
|
+
const commandName = getAbsoluteCommandName(command);
|
|
50
|
+
for (const s of Object.keys(registeredOptions[commandName] ?? {})) {
|
|
51
|
+
if (registeredOptions[commandName][s] === option.longName) {
|
|
45
52
|
return s;
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
|
-
throw new Error(`no short flag registered for command ${
|
|
55
|
+
throw new Error(`no short flag registered for command ${commandName}, long name ${option.longName}`);
|
|
49
56
|
};
|
|
50
57
|
exports.getShortFlagForLongName = getShortFlagForLongName;
|
|
51
58
|
const isOptionAlreadyRegistered = ({ longName }, command) => {
|
|
@@ -53,32 +60,60 @@ const isOptionAlreadyRegistered = ({ longName }, command) => {
|
|
|
53
60
|
return !!opts?.includes(longName);
|
|
54
61
|
};
|
|
55
62
|
exports.isOptionAlreadyRegistered = isOptionAlreadyRegistered;
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
function shortFlagFromAnyCommand(optionLongName) {
|
|
64
|
+
let shortFlag;
|
|
65
|
+
Object.keys(registeredOptions).find((c) => {
|
|
66
|
+
shortFlag = Object.entries(registeredOptions[c]).find(([_command, longName]) => optionLongName === longName)?.[0];
|
|
67
|
+
return !!shortFlag;
|
|
68
|
+
});
|
|
69
|
+
return shortFlag;
|
|
70
|
+
}
|
|
71
|
+
function removeUsedShortFlags(possibleShortFlags) {
|
|
72
|
+
const usedShortFlags = lodash_1.default.uniq(Object.keys(registeredOptions).reduce((p1, c1) => {
|
|
73
|
+
return p1.concat(Object.keys(registeredOptions[c1]));
|
|
74
|
+
}, []));
|
|
75
|
+
return possibleShortFlags.filter((s) => !usedShortFlags.includes(s));
|
|
76
|
+
}
|
|
77
|
+
const getInitialShortFlagOptions = (option) => {
|
|
78
|
+
return [
|
|
79
|
+
option.longName[0],
|
|
80
|
+
option.longName[0].toUpperCase() === option.longName[0]
|
|
81
|
+
? option.longName[0].toLowerCase()
|
|
82
|
+
: option.longName[0].toUpperCase(),
|
|
83
|
+
...types_1.CHARACTERS,
|
|
84
|
+
];
|
|
85
|
+
};
|
|
86
|
+
const registerLongName = (command, option) => {
|
|
58
87
|
try {
|
|
59
|
-
return (0, exports.getShortFlagForLongName)(
|
|
88
|
+
return (0, exports.getShortFlagForLongName)(command, option);
|
|
60
89
|
}
|
|
61
90
|
catch (err) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
let possibleShortFlags = getInitialShortFlagOptions(option);
|
|
92
|
+
possibleShortFlags = removeUsedShortFlags(possibleShortFlags);
|
|
93
|
+
if (possibleShortFlags.length === 0) {
|
|
94
|
+
// no short flag is left (possibleShortFlags.length === 0),
|
|
95
|
+
// fall back to the initial set of options
|
|
96
|
+
possibleShortFlags = getInitialShortFlagOptions(option);
|
|
97
|
+
}
|
|
98
|
+
const alreadyUsedShortFlag = shortFlagFromAnyCommand(option.longName);
|
|
99
|
+
if (alreadyUsedShortFlag) {
|
|
100
|
+
possibleShortFlags.unshift(alreadyUsedShortFlag);
|
|
101
|
+
}
|
|
102
|
+
const commandName = getAbsoluteCommandName(command);
|
|
103
|
+
for (const c of possibleShortFlags) {
|
|
104
|
+
if (!registeredOptions[commandName]?.[c]) {
|
|
105
|
+
registeredOptions[commandName] = registeredOptions[commandName] ?? {};
|
|
106
|
+
registeredOptions[commandName][c] = option.longName;
|
|
72
107
|
return c;
|
|
73
108
|
}
|
|
74
109
|
}
|
|
75
|
-
throw new Error(`no short flag found for name ${option.longName}, command ${
|
|
110
|
+
throw new Error(`no short flag found for name ${option.longName}, command ${commandName}`);
|
|
76
111
|
}
|
|
77
112
|
};
|
|
78
113
|
exports.registerLongName = registerLongName;
|
|
79
|
-
const buildOption = async (
|
|
114
|
+
const buildOption = async (command, option) => {
|
|
80
115
|
const mandatory = !!option.required;
|
|
81
|
-
const shortFlag = (0, exports.registerLongName)(
|
|
116
|
+
const shortFlag = (0, exports.registerLongName)(command, option);
|
|
82
117
|
let newDescr = option.description;
|
|
83
118
|
if (!mandatory) {
|
|
84
119
|
newDescr = newDescr ? `${newDescr} (optional)` : "(optional)";
|
|
@@ -114,11 +149,12 @@ const buildCommand = async (topCommand, command) => {
|
|
|
114
149
|
.forEach((c) => checkCommand(c));
|
|
115
150
|
const { command: name, description, options } = command;
|
|
116
151
|
const comm = (0, exports.createCommand)(name);
|
|
152
|
+
topCommand.addCommand(comm);
|
|
117
153
|
comm.description(description);
|
|
118
154
|
comm.enablePositionalOptions();
|
|
119
155
|
for (const option of options ?? []) {
|
|
120
156
|
// eslint-disable-next-line no-await-in-loop
|
|
121
|
-
comm.addOption(await (0, exports.buildOption)(
|
|
157
|
+
comm.addOption(await (0, exports.buildOption)(comm, option));
|
|
122
158
|
}
|
|
123
159
|
if (command.type === "topCommand") {
|
|
124
160
|
const { subCommands } = command;
|
|
@@ -129,14 +165,13 @@ const buildCommand = async (topCommand, command) => {
|
|
|
129
165
|
}
|
|
130
166
|
else {
|
|
131
167
|
// command.type === "command"
|
|
132
|
-
const { args
|
|
168
|
+
const { args } = command;
|
|
133
169
|
if (args) {
|
|
134
170
|
args.forEach((a) => comm.argument(`<${a.argument}>`, a.description));
|
|
135
171
|
}
|
|
136
|
-
const rootHandler = await (0, root_1.create)(
|
|
172
|
+
const rootHandler = await (0, root_1.create)(command, `Failed to ${command.description}`)(comm);
|
|
137
173
|
comm.action(rootHandler);
|
|
138
174
|
}
|
|
139
|
-
topCommand.addCommand(comm);
|
|
140
175
|
return comm;
|
|
141
176
|
};
|
|
142
177
|
exports.buildCommand = buildCommand;
|
package/utils/http/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const logger_1 = require("../../logger");
|
|
|
11
11
|
const constants_1 = require("../../constants");
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
const core_1 = require("../../config/core");
|
|
14
|
+
const utils_2 = require("../../logger/utils");
|
|
14
15
|
exports.DEFAULTS = {
|
|
15
16
|
maxBodyLength: -1,
|
|
16
17
|
maxContentLength: -1,
|
|
@@ -34,11 +35,10 @@ const getCsrfTokenFromConfig = () => {
|
|
|
34
35
|
};
|
|
35
36
|
const fetch = async (config) => {
|
|
36
37
|
const cnfg = (0, config_1.get)();
|
|
37
|
-
const
|
|
38
|
+
const logger = getLogger();
|
|
39
|
+
const { debug, output, trace, error } = logger;
|
|
38
40
|
try {
|
|
39
|
-
|
|
40
|
-
output("%s %s", config.method.toUpperCase(), config.url);
|
|
41
|
-
}
|
|
41
|
+
(0, utils_2.logVerbose)(logger, "%s %s", config.method.toUpperCase(), config.url);
|
|
42
42
|
debug("http config: %s", JSON.stringify(config));
|
|
43
43
|
const httpsAgent = HTTPS_PROXY ? new https_proxy_agent_1.HttpsProxyAgent(HTTPS_PROXY) : null;
|
|
44
44
|
if (httpsAgent && cnfg.verbose) {
|
|
@@ -60,7 +60,7 @@ const fetch = async (config) => {
|
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
if (cnfg.verbose) {
|
|
63
|
-
|
|
63
|
+
(0, utils_2.logVerbose)(logger, "%d %s", res.status, res.statusText);
|
|
64
64
|
(0, utils_1.printCorrelationId)(res);
|
|
65
65
|
}
|
|
66
66
|
trace("response", res);
|
package/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
1
2
|
import { Option, PackageJson } from "../types";
|
|
2
|
-
export declare function buildOptionName(
|
|
3
|
+
export declare function buildOptionName(command: Command, option: Option): string;
|
|
3
4
|
export declare const parseVersion: (version: string) => {
|
|
4
5
|
major: number;
|
|
5
6
|
minor: number;
|
package/utils/utils.js
CHANGED
|
@@ -35,8 +35,8 @@ const commands_1 = require("./commands");
|
|
|
35
35
|
let pgk;
|
|
36
36
|
const getLogger = () => (0, logger_1.get)("utils.utils");
|
|
37
37
|
const REGEX_HTTPS = /http(s)*:\/\//;
|
|
38
|
-
function buildOptionName(
|
|
39
|
-
const shortFlag = (0, commands_1.getShortFlagForLongName)(
|
|
38
|
+
function buildOptionName(command, option) {
|
|
39
|
+
const shortFlag = (0, commands_1.getShortFlagForLongName)(command, option);
|
|
40
40
|
return `-${shortFlag}, --${option.longName}`;
|
|
41
41
|
}
|
|
42
42
|
exports.buildOptionName = buildOptionName;
|