oneuptime/Copilot/Index.ts
Simon Larsen c53b14f88f
refactor: Update CodeRepositoryUtil methods to accept repoPath parameter
The CodeRepositoryUtil methods getGitCommitHashForFile and getFilesInDirectory have been updated to accept a repoPath parameter. This change allows for specifying the repository path when retrieving the git commit hash for a file or getting the files in a directory. It improves the flexibility and reusability of the CodeRepositoryUtil class.
2024-06-11 14:24:19 +01:00

37 lines
1.3 KiB
TypeScript

import CodeRepositoryUtil from './Utils/CodeRepository';
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
import logger from 'CommonServer/Utils/Logger';
import CodeRepository from 'Model/Models/CodeRepository';
import dotenv from 'dotenv';
import CodeRepositoryFile from 'CommonServer/Utils/CodeRepository/CodeRepositoryFile'
import CodeRepositoryCommonServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository';
import { GetLocalRepositoryPath } from './Config';
dotenv.config();
logger.info('OneUptime Copilot is started...');
const init: PromiseVoidFunction = async (): Promise<void> => {
const codeRepository: CodeRepository =
await CodeRepositoryUtil.getCodeRepository();
logger.info(`Code Repository found: ${codeRepository.name}`);
const allFiles: Array<CodeRepositoryFile> = await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({
repoPath: GetLocalRepositoryPath(),
directoryPath: GetLocalRepositoryPath()
});
logger.info(`All files found: ${allFiles.length}`);
};
init()
.then(() => {
process.exit(0);
})
.catch((error: Error) => {
logger.error('Error in starting OneUptime Copilot: ');
logger.error(error);
process.exit(1);
});