diff --git a/CommonServer/Utils/CodeRepository/CodeRepository.ts b/CommonServer/Utils/CodeRepository/CodeRepository.ts index 623cb9b3f5..a53cbdce64 100644 --- a/CommonServer/Utils/CodeRepository/CodeRepository.ts +++ b/CommonServer/Utils/CodeRepository/CodeRepository.ts @@ -5,36 +5,28 @@ import CodeRepositoryFile from './CodeRepositoryFile'; import Dictionary from 'Common/Types/Dictionary'; export default class CodeRepositoryUtil { - public static async createOrCheckoutBranch(data: { repoPath: string; branchName: string; }): Promise { - const command: string = `cd ${data.repoPath} && git checkout ${data.branchName} || git checkout -b ${data.branchName}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } - // discard all changes in the working directory public static async discardChanges(data: { repoPath: string; }): Promise { - const command: string = `cd ${data.repoPath} && git checkout .`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -44,16 +36,15 @@ export default class CodeRepositoryUtil { repoPath: string; content: string; }): Promise { - - const totalPath: string = LocalFile.sanitizeFilePath(`${data.repoPath}/${data.filePath}`); + const totalPath: string = LocalFile.sanitizeFilePath( + `${data.repoPath}/${data.filePath}` + ); const command: string = `echo "${data.content}" > ${totalPath}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -62,16 +53,15 @@ export default class CodeRepositoryUtil { repoPath: string; directoryPath: string; }): Promise { + const totalPath: string = LocalFile.sanitizeFilePath( + `${data.repoPath}/${data.directoryPath}` + ); - const totalPath: string = LocalFile.sanitizeFilePath(`${data.repoPath}/${data.directoryPath}`); - const command: string = `mkdir ${totalPath}`; - logger.debug("Executing command: " + command); - - const stdout = await Execute.executeCommand( - command - ); + logger.debug('Executing command: ' + command); + + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -80,17 +70,15 @@ export default class CodeRepositoryUtil { repoPath: string; filePath: string; }): Promise { - - const totalPath: string = LocalFile.sanitizeFilePath(`${data.repoPath}/${data.filePath}`); - + const totalPath: string = LocalFile.sanitizeFilePath( + `${data.repoPath}/${data.filePath}` + ); const command: string = `rm ${totalPath}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -99,33 +87,28 @@ export default class CodeRepositoryUtil { repoPath: string; directoryPath: string; }): Promise { - - const totalPath: string = LocalFile.sanitizeFilePath(`${data.repoPath}/${data.directoryPath}`); + const totalPath: string = LocalFile.sanitizeFilePath( + `${data.repoPath}/${data.directoryPath}` + ); const command: string = `rm -rf ${totalPath}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } - public static async createBranch(data: { repoPath: string; branchName: string; }): Promise { - const command: string = `cd ${data.repoPath} && git checkout -b ${data.branchName}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -134,14 +117,11 @@ export default class CodeRepositoryUtil { repoPath: string; branchName: string; }): Promise { - const command: string = `cd ${data.repoPath} && git checkout ${data.branchName}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -150,25 +130,25 @@ export default class CodeRepositoryUtil { repoPath: string; filePaths: Array; }): Promise { + const filePaths: Array = data.filePaths.map( + (filePath: string) => { + if (filePath.startsWith('/')) { + // remove the leading slash and return + return filePath.substring(1); + } - const filePaths = data.filePaths.map((filePath) => { - if(filePath.startsWith('/')){ - // remove the leading slash and return - return filePath.substring(1); - }else{ return filePath; } - }); - - - const command: string = `cd ${data.repoPath} && git add ${filePaths.join(' ')}`; - - logger.debug("Executing command: " + command); - - const stdout = await Execute.executeCommand( - command ); + const command: string = `cd ${ + data.repoPath + } && git add ${filePaths.join(' ')}`; + + logger.debug('Executing command: ' + command); + + const stdout: string = await Execute.executeCommand(command); + logger.debug(stdout); } @@ -176,14 +156,11 @@ export default class CodeRepositoryUtil { repoPath: string; message: string; }): Promise { - const command: string = `cd ${data.repoPath} && git commit -m "${data.message}"`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const stdout = await Execute.executeCommand( - command - ); + const stdout: string = await Execute.executeCommand(command); logger.debug(stdout); } @@ -204,11 +181,9 @@ export default class CodeRepositoryUtil { const command: string = `cd ${repoPath} && git log -1 --pretty=format:"%H" ".${filePath}"`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); - const hash: string = await Execute.executeCommand( - command - ); + const hash: string = await Execute.executeCommand(command); logger.debug(hash); @@ -250,15 +225,14 @@ export default class CodeRepositoryUtil { continue; } - const filePath: string = LocalFile.sanitizeFilePath( `${directoryPath}/${fileName}` ); - if(data.ignoreFilesOrDirectories.includes(fileName)){ + if (data.ignoreFilesOrDirectories.includes(fileName)) { continue; } - + const isDirectory: boolean = ( await Execute.executeCommand( `file "${LocalFile.sanitizeFilePath( @@ -272,24 +246,22 @@ export default class CodeRepositoryUtil { LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`) ); continue; - }else{ - if ( - data.acceptedFileExtensions && - data.acceptedFileExtensions.length > 0 - ) { - let shouldSkip: boolean = true; - - for (const fileExtension of data.acceptedFileExtensions) { - if (fileName.endsWith(fileExtension)) { - shouldSkip = false; - break; - } - } - - if (shouldSkip) { - continue; + } else if ( + data.acceptedFileExtensions && + data.acceptedFileExtensions.length > 0 + ) { + let shouldSkip: boolean = true; + + for (const fileExtension of data.acceptedFileExtensions) { + if (fileName.endsWith(fileExtension)) { + shouldSkip = false; + break; } } + + if (shouldSkip) { + continue; + } } const gitCommitHash: string = await this.getGitCommitHashForFile({ diff --git a/CommonServer/Utils/CodeRepository/GitHub/GitHub.ts b/CommonServer/Utils/CodeRepository/GitHub/GitHub.ts index 64039aec13..2afa4225a6 100644 --- a/CommonServer/Utils/CodeRepository/GitHub/GitHub.ts +++ b/CommonServer/Utils/CodeRepository/GitHub/GitHub.ts @@ -1,3 +1,5 @@ +import Execute from '../../Execute'; +import logger from '../../Logger'; import HostedCodeRepository from '../HostedCodeRepository/HostedCodeRepository'; import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse'; import HTTPResponse from 'Common/Types/API/HTTPResponse'; @@ -7,11 +9,8 @@ import PullRequestState from 'Common/Types/CodeRepository/PullRequestState'; import OneUptimeDate from 'Common/Types/Date'; import { JSONArray, JSONObject } from 'Common/Types/JSON'; import API from 'Common/Utils/API'; -import Execute from '../../Execute'; -import logger from '../../Logger'; export default class GitHubUtil extends HostedCodeRepository { - private getPullRequestFromJSONObject(data: { pullRequest: JSONObject; organizationName: string; @@ -153,45 +152,48 @@ export default class GitHubUtil extends HostedCodeRepository { return allPullRequests; } - - public override async addRemote(data: { remoteName: string; organizationName: string; repositoryName: string; }): Promise { - + public override async addRemote(data: { + remoteName: string; + organizationName: string; + repositoryName: string; + }): Promise { const url: URL = URL.fromString( `https://github.com/${data.organizationName}/${data.repositoryName}.git` ); - const command: string = `git remote add ${data.remoteName} ${url.toString()}`; + const command: string = `git remote add ${ + data.remoteName + } ${url.toString()}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); const result: string = await Execute.executeCommand(command); logger.debug(result); } - public override async pushChanges(data: { branchName: string; organizationName: string; - repoName: string; - }){ - + repositoryName: string; + }): Promise { const branchName: string = data.branchName; - const username: string = this.username; + const username: string = this.username; const password: string = this.authToken; - logger.debug("Pushing changes to remote repository with username: " + username); + logger.debug( + 'Pushing changes to remote repository with username: ' + username + ); const command: string = `git push -u https://${username}:${password}@github.com/${data.organizationName}/${data.repositoryName}.git ${branchName}`; - logger.debug("Executing command: " + command); + logger.debug('Executing command: ' + command); const result: string = await Execute.executeCommand(command); logger.debug(result); } - public override async createPullRequest(data: { baseBranchName: string; headBranchName: string; diff --git a/CommonServer/Utils/CodeRepository/HostedCodeRepository/HostedCodeRepository.ts b/CommonServer/Utils/CodeRepository/HostedCodeRepository/HostedCodeRepository.ts index 852ea5b347..8066fc00a7 100644 --- a/CommonServer/Utils/CodeRepository/HostedCodeRepository/HostedCodeRepository.ts +++ b/CommonServer/Utils/CodeRepository/HostedCodeRepository/HostedCodeRepository.ts @@ -5,10 +5,7 @@ import NotImplementedException from 'Common/Types/Exception/NotImplementedExcept import ServiceRepository from 'Model/Models/ServiceRepository'; export default class HostedCodeRepository { - public constructor(data: { - authToken: string, - username: string, - }) { + public constructor(data: { authToken: string; username: string }) { if (!data.authToken) { throw new BadDataException('authToken is required'); } @@ -103,7 +100,7 @@ export default class HostedCodeRepository { public async pushChanges(_data: { branchName: string; organizationName: string; - repoName: string; + repositoryName: string; }): Promise { throw new NotImplementedException(); } diff --git a/Copilot/Config.ts b/Copilot/Config.ts index 58f77f67a8..faab4c9414 100644 --- a/Copilot/Config.ts +++ b/Copilot/Config.ts @@ -28,4 +28,4 @@ export const GetGitHubToken: GetStringOrNullFunction = (): string | null => { export const GetGitHubUsername: GetStringOrNullFunction = (): string | null => { const username: string | null = process.env['GITHUB_USERNAME'] || null; return username; -} +}; diff --git a/Copilot/Index.ts b/Copilot/Index.ts index c2d236f153..b92c16c952 100644 --- a/Copilot/Index.ts +++ b/Copilot/Index.ts @@ -1,4 +1,6 @@ -import CodeRepositoryUtil, { CodeRepositoryResult } from './Utils/CodeRepository'; +import CodeRepositoryUtil, { + CodeRepositoryResult, +} from './Utils/CodeRepository'; import InitUtil from './Utils/Init'; import ServiceRepositoryUtil from './Utils/ServiceRepository'; import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse'; @@ -22,30 +24,31 @@ const init: PromiseVoidFunction = async (): Promise => { }); logger.info( - `Files found in ${serviceRepository.serviceCatalog?.name}: ${Object.keys(filesInService).length + `Files found in ${serviceRepository.serviceCatalog?.name}: ${ + Object.keys(filesInService).length }` ); - const branchName = 'test-branch-4'; - + const branchName: string = 'test-branch-5'; await CodeRepositoryUtil.createOrCheckoutBranch({ serviceRepository: serviceRepository, branchName: branchName, }); - // test code from here. - const file = filesInService[Object.keys(filesInService)[0]!]; + // test code from here. + const file: CodeRepositoryFile | undefined = + filesInService[Object.keys(filesInService)[0]!]; await CodeRepositoryUtil.writeToFile({ - filePath: file?.filePath!, + filePath: file!.filePath!, content: 'Hello World', }); // commit the changes await CodeRepositoryUtil.addFilesToGit({ - filePaths: [file?.filePath!], + filePaths: [file!.filePath!], }); await CodeRepositoryUtil.commitChanges({ @@ -54,6 +57,7 @@ const init: PromiseVoidFunction = async (): Promise => { await CodeRepositoryUtil.pushChanges({ branchName: branchName, + serviceRepository: serviceRepository, }); // create a pull request @@ -62,8 +66,8 @@ const init: PromiseVoidFunction = async (): Promise => { title: 'Test PR', body: 'Test PR body', branchName: branchName, + serviceRepository: serviceRepository, }); - } }; @@ -73,15 +77,12 @@ init() }) .catch(async (error: Error | HTTPErrorResponse) => { try { - await CodeRepositoryUtil.discardChanges(); - // change back to main branch. - await CodeRepositoryUtil.checkoutBranch({ - branchName: 'main', - }); + // change back to main branch. + await CodeRepositoryUtil.checkoutMainBranch(); } catch (e) { - // do nothing. + // do nothing. } logger.error('Error in starting OneUptime Copilot: '); diff --git a/Copilot/Utils/CodeRepository.ts b/Copilot/Utils/CodeRepository.ts index eb3306c076..82c9127933 100644 --- a/Copilot/Utils/CodeRepository.ts +++ b/Copilot/Utils/CodeRepository.ts @@ -9,16 +9,16 @@ import HTTPErrorResponse from 'Common/Types/API/HTTPErrorResponse'; import HTTPResponse from 'Common/Types/API/HTTPResponse'; import URL from 'Common/Types/API/URL'; import CodeRepositoryType from 'Common/Types/CodeRepository/CodeRepositoryType'; +import PullRequest from 'Common/Types/CodeRepository/PullRequest'; import PullRequestState from 'Common/Types/CodeRepository/PullRequestState'; import BadDataException from 'Common/Types/Exception/BadDataException'; import { JSONArray, JSONObject } from 'Common/Types/JSON'; import API from 'Common/Utils/API'; +import CodeRepositoryServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository'; import GitHubUtil from 'CommonServer/Utils/CodeRepository/GitHub/GitHub'; import logger from 'CommonServer/Utils/Logger'; import CodeRepositoryModel from 'Model/Models/CodeRepository'; import ServiceRepository from 'Model/Models/ServiceRepository'; -import CodeRepositoryServerUtil from 'CommonServer/Utils/CodeRepository/CodeRepository' -import PullRequest from 'Common/Types/CodeRepository/PullRequest'; export interface CodeRepositoryResult { codeRepository: CodeRepositoryModel; @@ -29,7 +29,6 @@ export default class CodeRepositoryUtil { public static codeRepositoryResult: CodeRepositoryResult | null = null; public static gitHubUtil: GitHubUtil | null = null; - public static getGitHubUtil(): GitHubUtil { if (!this.gitHubUtil) { const gitHubToken: string | null = GetGitHubToken(); @@ -39,13 +38,11 @@ export default class CodeRepositoryUtil { if (!gitHubUsername) { throw new BadDataException('GitHub Username is required'); } - if (!gitHubToken) { throw new BadDataException('GitHub Token is required'); } - this.gitHubUtil = new GitHubUtil({ authToken: gitHubToken, username: gitHubUsername!, @@ -55,30 +52,54 @@ export default class CodeRepositoryUtil { return this.gitHubUtil; } + public static getBranchName(data: { + branchName: string; + serviceRepository: ServiceRepository; + }): string { + if (!data.serviceRepository.serviceCatalog) { + throw new BadDataException('Service Catalog is required'); + } + + if (!data.serviceRepository.serviceCatalog.name) { + throw new BadDataException('Service Catalog Name is required'); + } + + return ( + 'oneuptime-' + + data.serviceRepository.serviceCatalog?.name?.toLowerCase() + + '-' + + data.branchName + ); + } + public static async createBranch(data: { branchName: string; serviceRepository: ServiceRepository; }): Promise { - - const branchName = 'oneuptime-' + (data.serviceRepository.serviceCatalog?.name?.toLowerCase()) + '-' + data.branchName; + const branchName: string = this.getBranchName({ + branchName: data.branchName, + serviceRepository: data.serviceRepository, + }); await CodeRepositoryServerUtil.createBranch({ repoPath: GetLocalRepositoryPath(), branchName: branchName, - }) + }); } public static async createOrCheckoutBranch(data: { serviceRepository: ServiceRepository; branchName: string; }): Promise { - - const branchName = 'oneuptime-' + (data.serviceRepository.serviceCatalog?.name?.toLowerCase()) + '-' + data.branchName; + const branchName: string = this.getBranchName({ + branchName: data.branchName, + serviceRepository: data.serviceRepository, + }); await CodeRepositoryServerUtil.createOrCheckoutBranch({ repoPath: GetLocalRepositoryPath(), branchName: branchName, - }) + }); } public static async writeToFile(data: { @@ -89,7 +110,7 @@ export default class CodeRepositoryUtil { repoPath: GetLocalRepositoryPath(), filePath: data.filePath, content: data.content, - }) + }); } public static async createDirectory(data: { @@ -98,16 +119,14 @@ export default class CodeRepositoryUtil { await CodeRepositoryServerUtil.createDirectory({ repoPath: GetLocalRepositoryPath(), directoryPath: data.directoryPath, - }) + }); } - public static async deleteFile(data: { - filePath: string; - }): Promise { + public static async deleteFile(data: { filePath: string }): Promise { await CodeRepositoryServerUtil.deleteFile({ repoPath: GetLocalRepositoryPath(), filePath: data.filePath, - }) + }); } public static async deleteDirectory(data: { @@ -116,13 +135,13 @@ export default class CodeRepositoryUtil { await CodeRepositoryServerUtil.deleteDirectory({ repoPath: GetLocalRepositoryPath(), directoryPath: data.directoryPath, - }) + }); } public static async discardChanges(): Promise { await CodeRepositoryServerUtil.discardChanges({ repoPath: GetLocalRepositoryPath(), - }) + }); } public static async checkoutBranch(data: { @@ -131,11 +150,12 @@ export default class CodeRepositoryUtil { await CodeRepositoryServerUtil.checkoutBranch({ repoPath: GetLocalRepositoryPath(), branchName: data.branchName, - }) + }); } public static async checkoutMainBranch(): Promise { - const codeRepository: CodeRepositoryModel = await this.getCodeRepository(); + const codeRepository: CodeRepositoryModel = + await this.getCodeRepository(); if (!codeRepository.mainBranchName) { throw new BadDataException('Main Branch Name is required'); @@ -152,7 +172,7 @@ export default class CodeRepositoryUtil { await CodeRepositoryServerUtil.addFilesToGit({ repoPath: GetLocalRepositoryPath(), filePaths: data.filePaths, - }) + }); } public static async commitChanges(data: { @@ -161,45 +181,20 @@ export default class CodeRepositoryUtil { await CodeRepositoryServerUtil.commitChanges({ repoPath: GetLocalRepositoryPath(), message: data.message, - }) + }); } public static async pushChanges(data: { branchName: string; + serviceRepository: ServiceRepository; }): Promise { + const branchName: string = this.getBranchName({ + branchName: data.branchName, + serviceRepository: data.serviceRepository, + }); - const codeRepository: CodeRepositoryModel = await this.getCodeRepository(); - - if (!codeRepository.mainBranchName) { - throw new BadDataException('Main Branch Name is required'); - } - - - if(!codeRepository.organizationName){ - throw new BadDataException('Organization Name is required'); - } - - if(!codeRepository.repositoryName){ - throw new BadDataException('Repository Name is required'); - } - - if (codeRepository.repositoryHostedAt === CodeRepositoryType.GitHub) { - return await this.getGitHubUtil().pushChanges({ - branchName: data.branchName, - organizationName: codeRepository.organizationName, - repoName: codeRepository.repositoryName, - }); - } - } - - - public static async createPullRequest(data: { - branchName: string; - title: string; - body: string; - }): Promise { - - const codeRepository: CodeRepositoryModel = await this.getCodeRepository(); + const codeRepository: CodeRepositoryModel = + await this.getCodeRepository(); if (!codeRepository.mainBranchName) { throw new BadDataException('Main Branch Name is required'); @@ -213,25 +208,54 @@ export default class CodeRepositoryUtil { throw new BadDataException('Repository Name is required'); } + if (codeRepository.repositoryHostedAt === CodeRepositoryType.GitHub) { + return await this.getGitHubUtil().pushChanges({ + branchName: branchName, + organizationName: codeRepository.organizationName, + repositoryName: codeRepository.repositoryName, + }); + } + } + + public static async createPullRequest(data: { + branchName: string; + title: string; + body: string; + serviceRepository: ServiceRepository; + }): Promise { + const branchName: string = this.getBranchName({ + branchName: data.branchName, + serviceRepository: data.serviceRepository, + }); + + const codeRepository: CodeRepositoryModel = + await this.getCodeRepository(); + + if (!codeRepository.mainBranchName) { + throw new BadDataException('Main Branch Name is required'); + } + + if (!codeRepository.organizationName) { + throw new BadDataException('Organization Name is required'); + } + + if (!codeRepository.repositoryName) { + throw new BadDataException('Repository Name is required'); + } if (codeRepository.repositoryHostedAt === CodeRepositoryType.GitHub) { return await this.getGitHubUtil().createPullRequest({ - headBranchName: data.branchName, + headBranchName: branchName, baseBranchName: codeRepository.mainBranchName, organizationName: codeRepository.organizationName, repositoryName: codeRepository.repositoryName, title: data.title, body: data.body, }); - - } else { - throw new BadDataException('Code Repository type not supported'); } - + throw new BadDataException('Code Repository type not supported'); } - - public static async getServicesToImproveCode(data: { codeRepository: CodeRepositoryModel; services: Array; @@ -268,13 +292,16 @@ export default class CodeRepositoryUtil { } const numberOfPullRequestForThisService: number = - await this.getGitHubUtil().getNumberOfPullRequestsExistForService({ - serviceRepository: service, - pullRequestState: PullRequestState.Open, - baseBranchName: data.codeRepository.mainBranchName, - organizationName: data.codeRepository.organizationName, - repositoryName: data.codeRepository.repositoryName, - }); + await this.getGitHubUtil().getNumberOfPullRequestsExistForService( + { + serviceRepository: service, + pullRequestState: PullRequestState.Open, + baseBranchName: data.codeRepository.mainBranchName, + organizationName: + data.codeRepository.organizationName, + repositoryName: data.codeRepository.repositoryName, + } + ); if ( numberOfPullRequestForThisService < diff --git a/Copilot/Utils/ServiceFileTypes.ts b/Copilot/Utils/ServiceFileTypes.ts index e687d07ab4..244c127416 100644 --- a/Copilot/Utils/ServiceFileTypes.ts +++ b/Copilot/Utils/ServiceFileTypes.ts @@ -1,9 +1,20 @@ import ServiceLanguage from 'Common/Types/ServiceCatalog/ServiceLanguage'; export default class ServiceFileTypesUtil { - private static getCommonDirectoriesToIgnore(): string[] { - return ['node_modules', '.git', 'build', 'dist', 'coverage', 'logs', 'tmp', 'temp', 'temporal', 'tempfiles', 'tempfiles']; + return [ + 'node_modules', + '.git', + 'build', + 'dist', + 'coverage', + 'logs', + 'tmp', + 'temp', + 'temporal', + 'tempfiles', + 'tempfiles', + ]; } private static getCommonFilesToIgnore(): string[] { @@ -38,7 +49,12 @@ export default class ServiceFileTypesUtil { filesToIgnore = ['packages', 'bin', 'obj']; break; case ServiceLanguage.CPlusPlus: - filesToIgnore = ['build', 'CMakeFiles', 'CMakeCache.txt', 'Makefile']; + filesToIgnore = [ + 'build', + 'CMakeFiles', + 'CMakeCache.txt', + 'Makefile', + ]; break; case ServiceLanguage.Rust: filesToIgnore = ['Cargo.lock']; @@ -47,7 +63,13 @@ export default class ServiceFileTypesUtil { filesToIgnore = ['Podfile.lock']; break; case ServiceLanguage.Kotlin: - filesToIgnore = ['gradle', 'build', 'gradlew', 'gradlew.bat', 'gradle.properties']; + filesToIgnore = [ + 'gradle', + 'build', + 'gradlew', + 'gradlew.bat', + 'gradle.properties', + ]; break; case ServiceLanguage.TypeScript: filesToIgnore = ['node_modules', 'package-lock.json']; @@ -68,7 +90,9 @@ export default class ServiceFileTypesUtil { filesToIgnore = []; } - return filesToIgnore.concat(this.getCommonFilesToIgnore()).concat(this.getCommonDirectoriesToIgnore()); + return filesToIgnore + .concat(this.getCommonFilesToIgnore()) + .concat(this.getCommonDirectoriesToIgnore()); } private static getCommonFilesExtentions(): string[] { diff --git a/Copilot/Utils/ServiceRepository.ts b/Copilot/Utils/ServiceRepository.ts index 562b0a5f02..b8a97a4e52 100644 --- a/Copilot/Utils/ServiceRepository.ts +++ b/Copilot/Utils/ServiceRepository.ts @@ -26,9 +26,10 @@ export default class ServiceRepositoryUtil { ServiceFileTypesUtil.getFileExtentionsByServiceLanguage( serviceRepository.serviceCatalog!.serviceLanguage! ), - ignoreFilesOrDirectories: ServiceFileTypesUtil.getCommonFilesToIgnoreByServiceLanguage( + ignoreFilesOrDirectories: + ServiceFileTypesUtil.getCommonFilesToIgnoreByServiceLanguage( serviceRepository.serviceCatalog!.serviceLanguage! - ) + ), }); return allFiles;