UNPKG

coscribe

Version:

Git code owners file generator and updater

67 lines 3.21 kB
#! /usr/bin/env node "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const branch_class_1 = __importDefault(require("./src/core/branch.class")); const coscribe_config_class_1 = __importDefault(require("./src/core/coscribe-config.class")); const generator_class_1 = __importDefault(require("./src/coscribe-operations/generator.class")); const updater_class_1 = __importDefault(require("./src/coscribe-operations/updater.class")); const shelljs_git_adapter_class_1 = __importDefault(require("./src/git-adapters/shelljs-git-adapter.class")); const cli_progress_adapter_class_1 = __importDefault(require("./src/progress-adapters/cli-progress-adapter.class")); const format_type_enum_1 = require("./src/progress-adapters/format-type.enum"); const coscribe = new commander_1.Command(); coscribe .command('generate') .description('Generate code owners file') .option('--coscribe-file <coscribeFile>', 'Provide another (relative path from command execution dir) location for the config file', 'coscribe') .action(options => { executeGenerate(options); }); coscribe .command('update') .description('Update code owners file') .argument('<base-branch>', 'The base branch used for the comparison of changes', value => { return new branch_class_1.default(value); }) .option('[target-branch]', 'The target branch used for comparison of changes ', value => { return new branch_class_1.default(value); }) .option('--coscribe-file <coscribeFile>', 'Provide another (relative path from command execution dir) location for the config file', 'coscribe') .action((baseBranch, options) => { executeUpdate(baseBranch, options); }); coscribe.parse(process.argv); function executeGenerate(generateConfig) { let progressBar; try { const { coscribeFile } = generateConfig; const gitAdapter = new shelljs_git_adapter_class_1.default(); progressBar = new cli_progress_adapter_class_1.default(format_type_enum_1.FORMAT.DIRECTORIES); const coscribeConfig = new coscribe_config_class_1.default(coscribeFile); const coscribe = new generator_class_1.default(gitAdapter, coscribeConfig); coscribe.execute(progressBar); } catch (error) { progressBar.complete(); console.error(`Error: ${error.message}`); } } function executeUpdate(baseBranch, updateConfig) { let progressBar; try { const { coscribeFile, targetBranch } = updateConfig; const gitAdapter = new shelljs_git_adapter_class_1.default(); progressBar = new cli_progress_adapter_class_1.default(format_type_enum_1.FORMAT.DIRECTORIES); const coscribeConfig = new coscribe_config_class_1.default(coscribeFile); const updater = new updater_class_1.default(gitAdapter, coscribeConfig, baseBranch, targetBranch); updater.execute(progressBar); } catch (error) { progressBar.complete(); console.error(`Error: ${error.message}`); } } //# sourceMappingURL=index.js.map