diff --git a/Common/jest.config.json b/Common/jest.config.json index 52628ecd4f..663a75a20c 100644 --- a/Common/jest.config.json +++ b/Common/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/CommonServer/Utils/CodeRepository/CodeRepository.ts b/CommonServer/Utils/CodeRepository/CodeRepository.ts index eaa1dd577b..414da90dd7 100644 --- a/CommonServer/Utils/CodeRepository/CodeRepository.ts +++ b/CommonServer/Utils/CodeRepository/CodeRepository.ts @@ -1,13 +1,12 @@ import Execute from '../Execute'; import CodeRepositoryFile from './CodeRepositoryFile'; +import Dictionary from 'Common/Types/Dictionary'; export default class CodeRepositoryUtil { public static async getGitCommitHashForFile(data: { - repoPath: string, - filePath: string - } - ): Promise { - + repoPath: string; + filePath: string; + }): Promise { const { repoPath, filePath } = data; return await Execute.executeCommand( @@ -16,16 +15,15 @@ export default class CodeRepositoryUtil { } public static async getFilesInDirectory(data: { - directoryPath: string, - repoPath: string + directoryPath: string; + repoPath: string; }): Promise<{ - files: Array; + files: Dictionary; subDirectories: Array; }> { - const { directoryPath, repoPath } = data; - const files: Array = []; + const files: Dictionary = {}; const output: string = await Execute.executeCommand( `ls ${directoryPath}` ); @@ -41,7 +39,7 @@ export default class CodeRepositoryUtil { const isDirectory: boolean = ( await Execute.executeCommand( - `file ${directoryPath}/${fileName}` + `file "${directoryPath}/${fileName}"` ) ).includes('directory'); @@ -53,15 +51,15 @@ export default class CodeRepositoryUtil { const filePath: string = `${directoryPath}/${fileName}`; const gitCommitHash: string = await this.getGitCommitHashForFile({ filePath, - repoPath - }); + repoPath, + }); const fileExtension: string = fileName.split('.').pop() || ''; - files.push({ + files[filePath] = { filePath, gitCommitHash, fileExtension, fileName, - }); + }; } return { @@ -71,25 +69,30 @@ export default class CodeRepositoryUtil { } public static async getFilesInDirectoryRecursive(data: { - repoPath: string, - directoryPath: string - }): Promise> { - const files: Array = []; + repoPath: string; + directoryPath: string; + }): Promise> { + let files: Dictionary = {}; const { files: filesInDirectory, subDirectories } = await this.getFilesInDirectory({ directoryPath: data.directoryPath, - repoPath: data.repoPath + repoPath: data.repoPath, }); - files.push(...filesInDirectory); + + files = { + ...files, + ...filesInDirectory, + }; for (const subDirectory of subDirectories) { - files.push( + files = { + ...files, ...(await this.getFilesInDirectoryRecursive({ repoPath: data.repoPath, - directoryPath: subDirectory - })) - ); + directoryPath: subDirectory, + })), + }; } return files; diff --git a/CommonServer/jest.config.json b/CommonServer/jest.config.json index 5b08bd193a..cd7cb74981 100644 --- a/CommonServer/jest.config.json +++ b/CommonServer/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/CommonUI/jest.config.json b/CommonUI/jest.config.json index 71806da463..33aa1a5eee 100644 --- a/CommonUI/jest.config.json +++ b/CommonUI/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/CommonUI/package-lock.json b/CommonUI/package-lock.json index 8d5c14d989..924d71612a 100644 --- a/CommonUI/package-lock.json +++ b/CommonUI/package-lock.json @@ -78,12 +78,12 @@ "dependencies": { "@types/crypto-js": "^4.2.2", "@types/uuid": "^8.3.4", - "axios": "^1.6.8", + "axios": "^1.7.1", "crypto-js": "^4.1.1", "json5": "^2.2.3", "moment": "^2.30.1", "moment-timezone": "^0.5.45", - "posthog-js": "^1.130.2", + "posthog-js": "^1.131.4", "reflect-metadata": "^0.2.2", "slugify": "^1.6.5", "typeorm": "^0.3.20", diff --git a/CommonUI/src/Tests/Components/DuplicateModel.test.tsx b/CommonUI/src/Tests/Components/DuplicateModel.test.tsx index 0cc0dc4c27..dda191c2b6 100644 --- a/CommonUI/src/Tests/Components/DuplicateModel.test.tsx +++ b/CommonUI/src/Tests/Components/DuplicateModel.test.tsx @@ -165,7 +165,9 @@ describe('DuplicateModel', () => { await waitFor(() => { return expect( require('../../Utils/Navigation').navigate - ).toBeCalledWith(new Route('/done/foobar')); + ).toBeCalledWith(new Route('/done/foobar'), { + forceNavigate: true, + }); }); }); it('closes confirmation dialog when close button is clicked', () => { diff --git a/Copilot/Index.ts b/Copilot/Index.ts index bfbd12af13..a5fc282b8c 100644 --- a/Copilot/Index.ts +++ b/Copilot/Index.ts @@ -1,28 +1,30 @@ +import { GetLocalRepositoryPath } from './Config'; import CodeRepositoryUtil from './Utils/CodeRepository'; +import Dictionary from 'Common/Types/Dictionary'; import { PromiseVoidFunction } from 'Common/Types/FunctionTypes'; +import CodeRepositoryCommonServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository'; +import CodeRepositoryFile from 'CommonServer/Utils/CodeRepository/CodeRepositoryFile'; 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...'); +logger.info('OneUptime Copilot is starting...'); const init: PromiseVoidFunction = async (): Promise => { const codeRepository: CodeRepository = await CodeRepositoryUtil.getCodeRepository(); - + logger.info(`Code Repository found: ${codeRepository.name}`); - const allFiles: Array = await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({ - repoPath: GetLocalRepositoryPath(), - directoryPath: GetLocalRepositoryPath() - }); + const allFiles: Dictionary = + await CodeRepositoryCommonServerUtil.getFilesInDirectoryRecursive({ + repoPath: GetLocalRepositoryPath(), + directoryPath: GetLocalRepositoryPath(), + }); - logger.info(`All files found: ${allFiles.length}`); + logger.info(`All files found: ${Object.keys(allFiles).length}`); }; init() diff --git a/Copilot/jest.config.json b/Copilot/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/Copilot/jest.config.json +++ b/Copilot/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/Ingestor/jest.config.json b/Ingestor/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/Ingestor/jest.config.json +++ b/Ingestor/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/IsolatedVM/jest.config.json b/IsolatedVM/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/IsolatedVM/jest.config.json +++ b/IsolatedVM/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/Model/jest.config.json b/Model/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/Model/jest.config.json +++ b/Model/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/Probe/jest.config.json b/Probe/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/Probe/jest.config.json +++ b/Probe/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/TestServer/jest.config.json b/TestServer/jest.config.json index 7c066d401e..4ea0f190e9 100644 --- a/TestServer/jest.config.json +++ b/TestServer/jest.config.json @@ -1,5 +1,10 @@ { - "preset": "ts-jest", + + "preset": "ts-jest", +"testPathIgnorePatterns": [ + "node_modules", + "dist" + ], "verbose": true, "globals": { "ts-jest": { diff --git a/package.json b/package.json index 1ac6833282..2c20328fc8 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "prerun": "bash configure.sh", "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js", "uninstall": "bash uninstall.sh", - "lint": "ejslint **/*.ejs && eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore ", - "fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore --fix --cache", + "lint": "ejslint **/*.ejs && eslint '**/*.{ts,tsx,json}' -c .eslintrc.json --ignore-path .eslintignore ", + "fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.{ts,tsx,json}' -c .eslintrc.json --ignore-path .eslintignore --fix --cache", "fix": "npm run fix-lint", "status-check": "bash ./Tests/Scripts/status-check.sh $npm_config_services", "start": "export $(grep -v '^#' config.env | xargs) && docker compose up --remove-orphans -d $npm_config_services && npm run status-check",