feat(events,catalog/bitbucketCloud): handle repo:push events

Relates-to: #10866
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
Patrick Jungermann
2022-09-17 02:01:00 +02:00
parent b8f913096c
commit d089fbe7dc
15 changed files with 571 additions and 31 deletions
@@ -30,6 +30,14 @@ const modelsModule = modelsFile.getModuleOrThrow('Models');
const clientFile = project.getSourceFile('src/BitbucketCloudClient.ts');
const clientClass = clientFile.getClassOrThrow('BitbucketCloudClient');
const eventsFile = project.getSourceFile('src/events/index.ts');
const eventsModule = eventsFile.getModuleOrThrow('Events');
const eventsStmts = [
...eventsModule.getClasses(),
...eventsModule.getInterfaces(),
...eventsModule.getTypeAliases(),
];
/**
* Returns an array of the unique items of the provided array.
*
@@ -79,7 +87,11 @@ function referencedModelsIdentifiers(stmt, processed) {
}
// all directly or transitively referenced/used `Models.[...]` are allowed to stay
const allowed = referencedModelsIdentifiers(clientClass);
const processed = [];
const allowed = referencedModelsIdentifiers(clientClass, processed);
allowed.push(
...eventsStmts.flatMap(stmt => referencedModelsIdentifiers(stmt, processed)),
);
// remove everything not part of the "allow list"
modelsModule