import { Command } from 'commander'; import { getGlobalConfig, useProfile } from '../../helpers/cluserHelper'; import { fixVariables } from '../../helpers/variablesHelper'; import { fixTaskAssociations } from '../../helpers/taskAssociationHelper'; import { cacheEntities } from '../../helpers/entityHelper'; import { cacheTaskRelations } from '../../helpers/taskHelper'; import fs from 'fs'; export async function switchProfile(folder: string, options) { var success = useProfile(folder, options); if (!success) { return; } await fixVariables(); await fixTaskAssociations(); await cacheEntities('task'); await cacheEntities('puller'); await cacheEntities('pusher'); await cacheEntities('report'); await cacheEntities('table'); await cacheEntities('schema'); await cacheEntities('connection'); await cacheTaskRelations('dependencies'); await cacheTaskRelations('transformations'); await cacheTaskRelations('validations'); } export function SwitchProfileCommand(): Command { const cmd = new Command('set-context') .alias('sc') .description('Chooses a profile to work with.') .argument('folder', 'Path to the target project') .action(async (folder, options) => { await switchProfile(folder, options); }); return cmd; }