UNPKG

ng-afelio

Version:
32 lines (31 loc) 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConnectorBuilder = void 0; const schematics_1 = require("@angular-devkit/schematics"); const util_1 = require("../../scripts/check-files/util"); const connectors_1 = require("./connectors"); class ConnectorBuilder { static build(repoName) { const pluginRepoConfig = this.getPluginsConfig(repoName); let connector; if (pluginRepoConfig.type === 'gitlab') { connector = new connectors_1.GitlabConnector(pluginRepoConfig.url, pluginRepoConfig.token); } else if (pluginRepoConfig.type === 'github') { connector = new connectors_1.GithubConnector(pluginRepoConfig.url, pluginRepoConfig.token); } else { throw new schematics_1.SchematicsException(`Connector "${pluginRepoConfig.type}" not found.`); } return connector; } static getPluginsConfig(repoName) { const pluginRepoConfigs = (0, util_1.getConfig)('plugins'); const pluginRepoConfig = pluginRepoConfigs === null || pluginRepoConfigs === void 0 ? void 0 : pluginRepoConfigs.repos.find(pr => pr.name === repoName); if (!pluginRepoConfig) { throw new schematics_1.SchematicsException(`Plugin repo "${repoName}" not found into your "ng-afelio.json" file.`); } return pluginRepoConfig; } } exports.ConnectorBuilder = ConnectorBuilder;