Skip to content

Commit a08e390

Browse files
authored
Update vendor positions handling (old positionsUrl is broken) (#405)
Only the parts of the data we need were added to the schema.
1 parent ce76252 commit a08e390

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

scripts/update-issues.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ const pattern = /<!--\s*web-features\s*:\s*([a-z0-9-]+)\s*-->/;
1818
// standards position that matches the below strings, we skip the feature. Note
1919
// that Mozilla uses "negative" while WebKit uses "oppose".
2020
//
21-
// TODO: Migrate to https://github.com/web-platform-dx/web-features-mappings/
22-
// once that is published to NPM.
23-
const positionsUrl =
24-
"https://raw.githubusercontent.com/web-platform-dx/web-features-explorer/refs/heads/main/additional-data/standard-positions.json";
21+
// TODO: Migrate to NPM package once published:
22+
// https://github.com/web-platform-dx/web-features-mappings/issues/5
23+
const mappingsUrl =
24+
"https://raw.githubusercontent.com/web-platform-dx/web-features-mappings/refs/heads/main/mappings/combined-data.json";
2525

2626
interface VendorPosition {
27-
url?: string;
28-
position?:
27+
vendor: "mozilla" | "webkit";
28+
url: string;
29+
position:
2930
| ""
3031
| "positive"
3132
| "support"
@@ -36,11 +37,10 @@ interface VendorPosition {
3637
| "blocked";
3738
}
3839

39-
type PositionsData = Record<
40+
type MappingsData = Record<
4041
string,
4142
{
42-
mozilla: VendorPosition;
43-
webkit: VendorPosition;
43+
"standards-positions"?: VendorPosition[];
4444
}
4545
>;
4646

@@ -66,9 +66,9 @@ async function* iterateIssues(octokit: Octokit, params: IterateIssuesParams) {
6666
}
6767
}
6868

69-
const dateFormat = new Intl.DateTimeFormat("en", {
69+
const dateFormat = new Intl.DateTimeFormat("en", {
7070
dateStyle: "medium",
71-
timeZone: "UTC"
71+
timeZone: "UTC",
7272
});
7373

7474
function issueBody(id: string, data: (typeof features)[string]) {
@@ -137,17 +137,21 @@ function issueBody(id: string, data: (typeof features)[string]) {
137137
async function getFeaturesToSkip(): Promise<Map<string, string>> {
138138
const map = new Map<string, string>();
139139

140-
const resp = await fetch(positionsUrl);
140+
const resp = await fetch(mappingsUrl);
141141
if (!resp.ok) {
142-
throw new Error(`Failed to fetch ${positionsUrl}: ${resp.statusText}`);
142+
throw new Error(`Failed to fetch ${mappingsUrl}: ${resp.statusText}`);
143143
}
144144

145-
const featurePositions = (await resp.json()) as PositionsData;
146-
for (const [feature, vendorPositions] of Object.entries(featurePositions)) {
145+
const mappings = (await resp.json()) as MappingsData;
146+
for (const [feature, data] of Object.entries(mappings)) {
147+
const positions = data["standards-positions"];
148+
if (!positions) {
149+
continue;
150+
}
147151
let reason;
148-
for (const { position, url } of Object.values(vendorPositions)) {
152+
for (const { vendor, position, url } of positions) {
149153
if (position && positionsToIgnore.includes(position)) {
150-
const message = `${position} position at ${url}`;
154+
const message = `${vendor} position is ${position}: ${url}`;
151155
if (reason) {
152156
reason = `${reason}; ${message}`;
153157
} else {
@@ -303,7 +307,7 @@ async function update() {
303307
const title = data.name;
304308
const body = issueBody(id, data);
305309
const issue = openIssues.get(id);
306-
310+
307311
if (data.status.baseline && !issue) {
308312
console.log(
309313
`Skipping ${id}. Reason: Baseline since ${data.status.baseline_low_date}`,

0 commit comments

Comments
 (0)