UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

233 lines (232 loc) 7.42 kB
import path from "path"; import { GrantType } from "./types.js"; import { getVersion } from "./utils/utils.js"; export const VERSION = getVersion(); export const DEFAULT_TLS_VERSION = "TLSv1.2"; export const DISCOVERY_DOCUMENT_PREFIX = "discovery-"; export var AuthenticationMethod; (function (AuthenticationMethod) { AuthenticationMethod["oauth"] = "oauth"; AuthenticationMethod["passcode"] = "passcode"; })(AuthenticationMethod || (AuthenticationMethod = {})); export const ROOT_COMMAND = { name: () => "ROOT", parent: null }; export const CLI_NAME = "cli-name"; export const CLI_PACKAGE_NAME = "cli-package-name"; export const CLI_DESCRIPTION = "cli-description"; export const CLI_DISCOVERY_PATHS = "cli-discovery-paths"; export const CLI_SAP_HELP = "cli-sap-help"; export const CLI_VERSION = "cli-version"; export const CLI_DEPRECATED = "cli-deprecated"; export const CLI_DEPRECATION_MESSAGE = "cli-deprecation-message"; export const CLI_SUPPORTED_AUTHENTICATION_METHODS = "cli-supported-authentication-methods"; export const CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help"; export const SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = ["dwaas-core"]; export const DISCOVERY_METADATA_PATH = "discovery-metadata.json"; export const X_CSRF_TOKEN = "x-csrf-token"; export const X_DSP_API_DEPRECATED_PROPERTIES = "x-dsp-api-deprecated-properties"; export const X_OUTPUT_FILE_NAME = "x-sap-datasphere-cli-file-name"; export const PATH_TO_SUCCESS_HTML = path.join(import.meta.dirname, "assets", "success.html"); export const PATH_TO_ERROR_HTML = path.join(import.meta.dirname, "assets", "error.html"); export const CACHE_SECRETS_FILE = "secrets.json"; export const OPTION_VERSION = { longName: "version", description: "print version", hidden: true, }; export const OPTION_HELP = { longName: "help", description: "print help for a command", args: [{ name: "command" }], hidden: true, }; export const 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", }, }; export const 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", }, }; export const OPTION_OUTPUT = { longName: "output", description: "specifies the file to store the output of the command", args: [{ name: "output", optional: true }], hidden: true, }; export const OPTION_NO_PRETTY = { longName: "no-pretty", description: "do not pretty-format JSON responses", hidden: true, }; export const OPTION_VERBOSE = { longName: "verbose", description: "print detailed log information to console", hidden: true, }; export const OPTION_FORCE = { longName: "force", description: "force the command execution", }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const 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:`, }, }; export const OPTION_PASSCODE = { longName: "passcode", description: "passcode for interactive session authentication", args: [{ name: "passcode" }], hidden: true, }; export const CONFIG_PASSCODE_FUNCTION = "passcodeFunction"; export const OPTION_OPTIONS_FILE = { longName: "options-file", description: "path to options file", args: [{ name: "file" }], hidden: true, }; export const 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", }, }; export const OPTION_INPUT = { longName: "input", description: "specifies input as string to use for the command", args: [{ name: "input" }], prompts: { message: "Input as string:", type: "text", }, }; export const OPTION_BROWSER = { longName: "browser", description: "specifies the browser to open", args: [{ name: "browser" }], prompts: { message: "Select your browser:", type: "select", }, }; export const OPTION_AUTHORIZATION_FLOW = { longName: "authorization-flow", description: "specifies the authorization flow to use", args: [{ name: "authorization-flow" }], choices: [ GrantType.authorization_code, GrantType.client_credentials, ], default: GrantType.authorization_code, required: true, hidden: true, }; export const OPTION_TLS_VERSION = { longName: "tls-version", description: "specifies the TLS version to use for HTTPS connections", args: [{ name: "version" }], choices: [DEFAULT_TLS_VERSION, "TLSv1.3"], default: DEFAULT_TLS_VERSION, hidden: true, };