in src/support.ts [41:95]
export async function emitSupportPolicyInformation() {
if (process.env[SILENCE_ENV_VAR]) {
return;
}
const data = await getReleasesDocument();
if (data.current == RELEASE_LINE) {
// Current release is not close to deprecation
return;
}
const endOfSupportDate = data.endOfSupport?.includes(RELEASE_LINE) ? new Date(0) : data.maintenance[RELEASE_LINE];
if (endOfSupportDate == null) {
// Don't know the status, so don't say anything...
return;
}
const now = new Date();
const inThirtyDays = new Date(now.getTime() + THIRTY_DAYS_IN_MILLIS);
const alternatives = Object.entries(data.maintenance)
.flatMap(([release, dateStr]) => {
const date = new Date(dateStr);
if (date <= inThirtyDays) {
return [];
}
return [{ release, date }];
})
.reduce((acc, { release, date }) => {
if (acc.length === 0) {
acc.push('', 'Other actively supported release lines include:');
}
acc.push(`- ${release} (planned End-of-Support date: ${date.toISOString().split('T')[0]})`);
return acc;
}, new Array<string>());
if (endOfSupportDate <= now) {
// End-of-Support already!
veryVisibleMessage(
chalk.bgRed.white.bold,
`The ${RELEASE_LINE} release line of jsii has reached End-of-Support.`,
`We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`,
...alternatives,
);
} else if (endOfSupportDate <= inThirtyDays) {
// End-of-Support within 30 days!
veryVisibleMessage(
chalk.bgYellow.black,
`The ${RELEASE_LINE} release line of jsii will reach End-of-Support soon, on ${
endOfSupportDate.toISOString().split('T')[0]
}.`,
`We strongly recommend you upgrade to the current release line (${data.current}) at your earliest convenience.`,
...alternatives,
);
}
}