This commit is contained in:
@@ -29,17 +29,39 @@ function statusTone(status: string): 'neutral' | 'green' | 'amber' | 'red' | 'bl
|
||||
type ImageTags = {
|
||||
images?: Record<string, string>;
|
||||
artifacts?: Record<string, string>;
|
||||
buildJobs?: Array<{
|
||||
component?: string;
|
||||
type?: string;
|
||||
}>;
|
||||
error?: string;
|
||||
promotion?: {
|
||||
sourceBuildJobIds?: string[];
|
||||
};
|
||||
};
|
||||
|
||||
function releaseBuildComponentTypes(imageTags: ImageTags | null | undefined) {
|
||||
const map = new Map<string, string>();
|
||||
for (const job of imageTags?.buildJobs ?? []) {
|
||||
if (job.component && job.type) map.set(job.component, job.type);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function isReleaseArtifactVisible(componentName: string, componentTypes: Map<string, string>) {
|
||||
const type = componentTypes.get(componentName);
|
||||
return type !== 'DATABASE' && type !== 'MIGRATION';
|
||||
}
|
||||
|
||||
function releaseArtifacts(release: AppRelease) {
|
||||
const imageTags = release.imageTags as ImageTags | null | undefined;
|
||||
const componentTypes = releaseBuildComponentTypes(imageTags);
|
||||
const values = [
|
||||
...Object.values(imageTags?.images ?? {}),
|
||||
...Object.values(imageTags?.artifacts ?? {})
|
||||
...Object.entries(imageTags?.images ?? {})
|
||||
.filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes))
|
||||
.map(([, value]) => value),
|
||||
...Object.entries(imageTags?.artifacts ?? {})
|
||||
.filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes))
|
||||
.map(([, value]) => value)
|
||||
].filter(Boolean);
|
||||
|
||||
if (values.length) return values;
|
||||
@@ -137,7 +159,9 @@ function nextReleaseVersion(releases: AppRelease[], appId: string, builds: Build
|
||||
|
||||
function buildCount(release: AppRelease) {
|
||||
const imageTags = release.imageTags as ImageTags | null | undefined;
|
||||
const count = Object.keys(imageTags?.images ?? {}).length + Object.keys(imageTags?.artifacts ?? {}).length;
|
||||
const componentTypes = releaseBuildComponentTypes(imageTags);
|
||||
const count = Object.keys(imageTags?.images ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length
|
||||
+ Object.keys(imageTags?.artifacts ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length;
|
||||
return count || (release.artifact ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user