export function findReposInProdWithoutProductionTopic()

in packages/repocop/src/remediation/topics/topic-monitor-production.ts [96:129]


export function findReposInProdWithoutProductionTopic(
	unarchivedRepos: Repository[],
	stacks: AwsCloudFormationStack[],
): AwsCloudFormationStack[] {
	console.log('Discovering Cloudformation stacks with PROD or INFRA tags.');

	const repoNamesWithoutProductionTopic: string[] =
		getRepoNamesWithoutProductionTopic(unarchivedRepos);

	const prodStacks = stacks.filter(isProdStack);

	const threeMonths = new Date();
	threeMonths.setMonth(threeMonths.getMonth() - 3);
	const cutoffDate = new Date();
	cutoffDate.setMonth(cutoffDate.getMonth() - MONTHS);
	const oldProdStacks: AwsCloudFormationStack[] = prodStacks.filter((stack) =>
		stackIsOlderThan(stack, cutoffDate),
	);
	console.log(
		`Found ${oldProdStacks.length} Cloudformation stacks with a Stage tag of PROD or INFRA that are over ${MONTHS} months old.`,
	);

	const reposInProdWithoutProductionTopic =
		getReposInProdWithoutProductionTopic(
			repoNamesWithoutProductionTopic,
			oldProdStacks,
		);

	console.log(
		`Found ${reposInProdWithoutProductionTopic.length} repos without a production/interactive topic that have a PROD/INFRA Cloudformation Stage tag.`,
	);

	return reposInProdWithoutProductionTopic;
}