Skip to content
22 changes: 19 additions & 3 deletions scripts/dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
parseRangedDateString,
setLogger,
} from "compute-baseline";
import { Compat, Feature } from "compute-baseline/browser-compat-data";
import { Compat, feature, Feature } from "compute-baseline/browser-compat-data";
import { fdir } from "fdir";
import fs from "node:fs";
import path from "node:path";
Expand Down Expand Up @@ -238,12 +238,12 @@ function toDist(sourcePath: string): YAML.Document {

if (!source.draft_date) {
logger.error(
`${id}: contains at least one deprecated compat feature and can never be Baseline. This is forbidden for published features.`,
`${id}: contains at least one deprecated compat feature. This is forbidden for published features.`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda annoying in some cases, because you never get the one key that caused it. I should refactor this a bit, to conditionally check deprecated for each key up here.

);
exitStatus = 1;
} else {
logger.warn(
`${id}: draft contains at least one deprecated compat feature and can never be Baseline. Was this intentional?`,
`${id}: draft contains at least one deprecated compat feature. Was this intentional?`,
);
}
}
Expand Down Expand Up @@ -282,6 +282,22 @@ function toDist(sourcePath: string): YAML.Document {
);
exitStatus = 1;
}

for (const key of compatFeatures) {
const f = feature(key);
if (f.deprecated) {
if (!source.draft_date) {
logger.error(
`${id}: contains contains deprecated compat feature ${f.id}. This is forbidden for published features.`,
);
exitStatus = 1;
} else {
logger.warn(
`${id}: draft contains deprecated compat feature ${f.id}. Was this intentional?`,
);
}
}
}
}

const sortedStatus = Array.from(groups.keys()).sort(compareStatus);
Expand Down