mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
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:
parent
c6961b9a0b
commit
bb8b4430cf
@ -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());
|
||||
|
@ -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!,
|
||||
),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user