refactor: Update ServiceFileTypesUtil to use TechStack instead of ServiceLanguage

This commit updates the ServiceFileTypesUtil class to use the TechStack enum instead of the ServiceLanguage enum. It modifies the method names and parameters accordingly, ensuring consistency and clarity in the codebase. This refactoring improves the maintainability and extensibility of the application.
This commit is contained in:
Simon Larsen 2024-07-16 16:52:40 -06:00
parent c6961b9a0b
commit bb8b4430cf
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
2 changed files with 35 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export default class ServiceFileTypesUtil {
return [".DS_Store", "Thumbs.db", ".gitignore", ".gitattributes"];
}
public static getCommonFilesToIgnoreByServiceLanguage(
public static getCommonFilesToIgnoreByTechStackItem(
techStack: TechStack,
): string[] {
let filesToIgnore: string[] = [];
@ -85,6 +85,20 @@ export default class ServiceFileTypesUtil {
filesToIgnore = [];
}
return filesToIgnore;
}
public static getCommonFilesToIgnoreByTechStack(
techStack: Array<TechStack>,
): string[] {
let filesToIgnore: string[] = [];
for (const stack of techStack) {
filesToIgnore = filesToIgnore.concat(
this.getCommonFilesToIgnoreByTechStackItem(stack),
);
}
return filesToIgnore
.concat(this.getCommonFilesToIgnore())
.concat(this.getCommonDirectoriesToIgnore());
@ -95,7 +109,7 @@ export default class ServiceFileTypesUtil {
return [".md", "dockerfile", ".yml", ".yaml", ".sh", ".gitignore"];
}
public static getFileExtentionsByServiceLanguage(
public static getFileExtentionsByTechStackItem(
techStack: TechStack,
): string[] {
let fileExtentions: Array<string> = [];
@ -153,6 +167,23 @@ export default class ServiceFileTypesUtil {
fileExtentions = [];
}
return fileExtentions;
}
public static getFileExtentionsByTechStack(
techStack: Array<TechStack>,
): string[] {
let fileExtentions: Array<string> = [];
for (let i: number = 0; i < techStack.length; i++) {
if (!techStack[i]) {
continue;
}
fileExtentions = fileExtentions.concat(
this.getFileExtentionsByTechStackItem(techStack[i]!),
);
}
// add common files extentions
return fileExtentions.concat(this.getCommonFilesExtentions());

View File

@ -54,11 +54,11 @@ export default class ServiceCopilotCodeRepositoryUtil {
repoPath: CodeRepositoryUtil.getLocalRepositoryPath(),
directoryPath: serviceRepository.servicePathInRepository || ".",
acceptedFileExtensions:
ServiceFileTypesUtil.getFileExtentionsByServiceLanguage(
ServiceFileTypesUtil.getFileExtentionsByTechStack(
serviceRepository.serviceCatalog!.techStack!,
),
ignoreFilesOrDirectories:
ServiceFileTypesUtil.getCommonFilesToIgnoreByServiceLanguage(
ServiceFileTypesUtil.getCommonFilesToIgnoreByTechStack(
serviceRepository.serviceCatalog!.techStack!,
),
});