@sap/cli-core
Version:
Command-Line Interface (CLI) Core Module
230 lines (229 loc) • 8.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OPTION_AUTHORIZATION_FLOW = exports.OPTION_BROWSER = 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_DSP_API_DEPRECATED_PROPERTIES = 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_PATHS = exports.CLI_DESCRIPTION = exports.CLI_PACKAGE_NAME = exports.CLI_NAME = exports.ROOT_COMMAND = exports.AuthenticationMethod = exports.DISCOVERY_DOCUMENT_PREFIX = exports.VERSION = void 0;
const path_1 = __importDefault(require("path"));
const types_1 = require("./types");
const utils_1 = require("./utils/utils");
exports.VERSION = (0, utils_1.getVersion)();
exports.DISCOVERY_DOCUMENT_PREFIX = "discovery-";
var AuthenticationMethod;
(function (AuthenticationMethod) {
AuthenticationMethod["oauth"] = "oauth";
AuthenticationMethod["passcode"] = "passcode";
})(AuthenticationMethod || (exports.AuthenticationMethod = AuthenticationMethod = {}));
exports.ROOT_COMMAND = { name: () => "ROOT", parent: null };
exports.CLI_NAME = "cli-name";
exports.CLI_PACKAGE_NAME = "cli-package-name";
exports.CLI_DESCRIPTION = "cli-description";
exports.CLI_DISCOVERY_PATHS = "cli-discovery-paths";
exports.CLI_SAP_HELP = "cli-sap-help";
exports.CLI_VERSION = "cli-version";
exports.CLI_DEPRECATED = "cli-deprecated";
exports.CLI_DEPRECATION_MESSAGE = "cli-deprecation-message";
exports.CLI_SUPPORTED_AUTHENTICATION_METHODS = "cli-supported-authentication-methods";
exports.CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
exports.SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = ["dwaas-core"];
exports.DISCOVERY_METADATA_PATH = "discovery-metadata.json";
exports.X_CSRF_TOKEN = "x-csrf-token";
exports.X_DSP_API_DEPRECATED_PROPERTIES = "x-dsp-api-deprecated-properties";
exports.X_OUTPUT_FILE_NAME = "x-sap-datasphere-cli-file-name";
exports.PATH_TO_SUCCESS_HTML = path_1.default.join(__dirname, "assets", "success.html");
exports.PATH_TO_ERROR_HTML = path_1.default.join(__dirname, "assets", "error.html");
exports.CACHE_SECRETS_FILE = "secrets.json";
exports.OPTION_VERSION = {
longName: "version",
description: "print version",
hidden: true,
};
exports.OPTION_HELP = {
longName: "help",
description: "print help for a command",
args: [{ name: "command" }],
hidden: true,
};
exports.OPTION_HOST = {
longName: "host",
description: "specifies the url where the tenant is hosted",
args: [{ name: "host" }],
hidden: true,
prompts: {
message: "URL of the system to connect to:",
type: "text",
},
};
exports.OPTION_LOGIN_ID = {
longName: "login-id",
description: "specifies the login ID",
args: [{ name: "id" }],
default: "0",
required: true,
prompts: {
message: "ID of the login to logout from",
type: "select",
},
};
exports.OPTION_OUTPUT = {
longName: "output",
description: "specifies the file to store the output of the command",
args: [{ name: "output", optional: true }],
hidden: true,
};
exports.OPTION_NO_PRETTY = {
longName: "no-pretty",
description: "do not pretty-format JSON responses",
hidden: true,
};
exports.OPTION_VERBOSE = {
longName: "verbose",
description: "print detailed log information to console",
hidden: true,
};
exports.OPTION_FORCE = {
longName: "force",
description: "force the command execution",
};
exports.OPTION_CLIENT_ID = {
longName: "client-id",
description: "client id for interactive oauth session authentication",
args: [{ name: "id" }],
hidden: true,
prompts: {
type: "text",
message: `Please enter your client ID:`,
},
};
exports.OPTION_CLIENT_SECRET = {
longName: "client-secret",
description: "client secret for interactive oauth session authentication",
args: [{ name: "secret" }],
hidden: true,
prompts: {
type: "password",
message: `Please enter your client secret:`,
},
};
exports.OPTION_AUTHORIZATION_URL = {
longName: "authorization-url",
description: "authorization url for interactive oauth session authentication",
args: [{ name: "url" }],
hidden: true,
prompts: {
type: "text",
message: `Please enter your authorization URL:`,
},
};
exports.OPTION_TOKEN_URL = {
longName: "token-url",
description: "token url for interactive oauth session authentication",
args: [{ name: "url" }],
hidden: true,
prompts: {
type: "text",
message: `Please enter your token URL:`,
},
};
exports.OPTION_ACCESS_TOKEN = {
longName: "access-token",
description: "access token for interactive oauth session authentication",
args: [{ name: "token" }],
hidden: true,
prompts: {
type: "password",
message: `Please enter your access token:`,
},
};
exports.OPTION_REFRESH_TOKEN = {
longName: "refresh-token",
description: "refresh token for interactive oauth session authentication",
args: [{ name: "token" }],
hidden: true,
prompts: {
type: "password",
message: `Please enter your refresh token:`,
},
};
exports.OPTION_EXPIRES_IN = {
longName: "expires-in",
description: "expires in information for interactive oauth session authentication",
args: [{ name: "expires" }],
hidden: true,
prompts: {
type: "number",
message: `Please enter a value for expires in:`,
},
};
exports.OPTION_SECRETS_FILE = {
longName: "secrets-file",
description: "path to secrets file",
args: [{ name: "file" }],
hidden: true,
prompts: {
type: "text",
message: `Please enter the path to the secrets file:`,
},
};
exports.OPTION_CODE = {
longName: "code",
description: "code for oauth token retrieval",
args: [{ name: "code" }],
hidden: true,
prompts: {
type: "text",
message: `Please enter the code for retrieving the oauth access_token and refresh_token:`,
},
};
exports.OPTION_PASSCODE = {
longName: "passcode",
description: "passcode for interactive session authentication",
args: [{ name: "passcode" }],
hidden: true,
};
exports.CONFIG_PASSCODE_FUNCTION = "passcodeFunction";
exports.OPTION_OPTIONS_FILE = {
longName: "options-file",
description: "path to options file",
args: [{ name: "file" }],
hidden: true,
};
exports.OPTION_FILE_PATH = {
longName: "file-path",
description: "specifies the file to use as input for the command",
args: [{ name: "path" }],
prompts: {
message: "Path to input file:",
type: "text",
},
};
exports.OPTION_INPUT = {
longName: "input",
description: "specifies input as string to use for the command",
args: [{ name: "input" }],
prompts: {
message: "Input as string:",
type: "text",
},
};
exports.OPTION_BROWSER = {
longName: "browser",
description: "specifies the browser to open",
args: [{ name: "browser" }],
prompts: {
message: "Select your browser:",
type: "select",
},
};
exports.OPTION_AUTHORIZATION_FLOW = {
longName: "authorization-flow",
description: "specifies the authorization flow to use",
args: [{ name: "authorization-flow" }],
choices: [
types_1.GrantType.authorization_code,
types_1.GrantType.client_credentials,
],
default: types_1.GrantType.authorization_code,
required: true,
hidden: true,
};