@controlplane/cli
Version:
Control Plane Corporation CLI
99 lines • 3.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SOURCE_LINE_CONFIGS = exports.DEFAULT_PARSER_CONFIG = exports.SHELL_CHOICES = exports.DEFAULT_SHELL_PATHS = exports.SUPPORTED_SHELLS = exports.SHELL_CONFIGS = exports.BUILTIN_OPTIONS = exports.HELP_OPTION = exports.EXCLUDED_COMMANDS = exports.SCRIPTS_DIR = exports.COMPLETION_DIR = exports.CACHE_FILE = exports.CACHE_DIR = void 0;
const path = require("path");
const io_1 = require("../../util/io");
/**
* Directory where completion cache is stored (same as cpln config dir)
*/
exports.CACHE_DIR = (0, io_1.getRootDir)();
/**
* Path to the completion cache file
*/
exports.CACHE_FILE = path.join(exports.CACHE_DIR, 'completion-cache');
/**
* Directory where completion scripts are stored
*/
exports.COMPLETION_DIR = path.join(exports.CACHE_DIR, 'completions');
/**
* Directory where shell completion scripts are stored
*/
exports.SCRIPTS_DIR = path.join(__dirname, 'scripts');
/**
* Commands to exclude from completion cache
*/
exports.EXCLUDED_COMMANDS = ['help'];
/**
* Yargs built-in option available on all commands
*/
exports.HELP_OPTION = '--help';
/**
* Yargs built-in options to include at root level
* These are not part of the command model but are always available
*/
exports.BUILTIN_OPTIONS = ['--version', exports.HELP_OPTION];
/**
* Shell-specific configuration map
*/
exports.SHELL_CONFIGS = {
bash: {
displayName: 'Bash',
path: '~/.bashrc',
scriptExtension: '.sh',
reloadCommand: 'source ~/.bashrc',
},
zsh: {
displayName: 'Zsh',
path: '~/.zshrc',
scriptExtension: '.sh',
reloadCommand: 'source ~/.zshrc',
},
fish: {
displayName: 'Fish',
path: '~/.config/fish/config.fish',
scriptExtension: '.sh',
reloadCommand: 'source ~/.config/fish/config.fish',
},
};
/**
* Supported shell types (derived from SHELL_CONFIGS keys)
*/
exports.SUPPORTED_SHELLS = Object.keys(exports.SHELL_CONFIGS);
/**
* Default RC file paths for each shell type (derived from SHELL_CONFIGS)
*/
exports.DEFAULT_SHELL_PATHS = Object.fromEntries(Object.entries(exports.SHELL_CONFIGS).map(([shell, config]) => [shell, config.path]));
/**
* Shell choices for inquirer prompts (derived from SHELL_CONFIGS)
*/
exports.SHELL_CHOICES = Object.entries(exports.SHELL_CONFIGS).map(([value, config]) => ({
name: config.displayName,
value: value,
}));
/**
* Default parser configuration for command introspection
*/
exports.DEFAULT_PARSER_CONFIG = {
showHelpOnFail: false,
exitProcess: false,
strict: false,
};
/**
* Source line templates for each shell type
* Used by both addSourceLineToRc and removeSourceLineFromRc to stay in sync
*/
exports.SOURCE_LINE_CONFIGS = {
fish: {
template: '\n# {name} completion\nif test -f {path}\n source {path}\nend\n',
removalPattern: '\\n# {name} completion\\nif test -f [^\\n]+\\.fish\\n source [^\\n]+\\.fish\\nend\\n',
},
bash: {
template: '\n# {name} completion\n[ -f {path} ] && source {path}\n',
removalPattern: '\\n# {name} completion\\n\\[ -f [^\\]]+ \\] && source [^\\n]+\\n',
},
zsh: {
template: '\n# {name} completion\n[ -f {path} ] && source {path}\n',
removalPattern: '\\n# {name} completion\\n\\[ -f [^\\]]+ \\] && source [^\\n]+\\n',
},
};
//# sourceMappingURL=constants.js.map