import chalk from 'chalk'; import { v4 as uuidv4 } from 'uuid'; import trelloConnectionConfigYaml from '../components/TrelloConnection.yaml'; import { normalizeName } from '../../../../helpers/profileGeneratorHelper'; import { mergeVariables } from '../../../../helpers/variablesHelper'; import { saveConnection } from '../../../../helpers/connectionHelper'; export function generateConnection(type: 'trello' | 'lark' | 'email') { var connectionConfigYaml = trelloConnectionConfigYaml; switch (type) { case 'trello': connectionConfigYaml = trelloConnectionConfigYaml; break; case 'lark': // TODO: Add Lark connection config case 'email': // TODO: Add Email connection config default: console.error( chalk.red( `Connection type ${type} is not supported. Skipping creating connection.`, ), ); return; } var typeName = normalizeName(type); mergeVariables( [ { key: `**${typeName.camelCaseName}ConnectionId**`, value: uuidv4() }, { key: `**${typeName.camelCaseName}ConnectionName**`, value: `${typeName.displayName} Connection`, }, ], false, ); saveConnection( connectionConfigYaml, `${typeName.camelCaseName}Connection.yaml`, false, ); }