From e5e7442b931b2a1e18c289e51a124ed834a3120a Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Wed, 13 Nov 2024 17:43:11 +0100 Subject: [PATCH 1/7] Check every key (even in compute_from) for discouraged --- scripts/dist.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/dist.ts b/scripts/dist.ts index 22ac8a3b3f4..1c21a697f6c 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -282,6 +282,20 @@ function toDist(sourcePath: string): YAML.Document { ); exitStatus = 1; } + + for (const key of compatFeatures) { + // This is super slow and wasteful. We already run `getStatus` for all these keys, but getStatus doesn't include discouraged. + const { discouraged } = computeBaseline({ + compatKeys: [key], + checkAncestors: true, + }); + if (discouraged) { + logger.error( + `${id}: contains deprecated compat feature ${key}, which can never be Baseline. This is forbidden.`, + ); + exitStatus = 1; + } + } } const sortedStatus = Array.from(groups.keys()).sort(compareStatus); From 7aa82657069238b65662b3f4b5b5d4303b4cb865 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 09:45:03 +0100 Subject: [PATCH 2/7] Just check the underlying compat data --- scripts/dist.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index 1c21a697f6c..49e80c91686 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -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"; @@ -284,12 +284,8 @@ function toDist(sourcePath: string): YAML.Document { } for (const key of compatFeatures) { - // This is super slow and wasteful. We already run `getStatus` for all these keys, but getStatus doesn't include discouraged. - const { discouraged } = computeBaseline({ - compatKeys: [key], - checkAncestors: true, - }); - if (discouraged) { + const f = feature(key); + if (f.deprecated) { logger.error( `${id}: contains deprecated compat feature ${key}, which can never be Baseline. This is forbidden.`, ); From 6bcde4d2e0003850b1ade850bee9b67ee23bcb92 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 09:52:24 +0100 Subject: [PATCH 3/7] Check deprecatedness in one place only --- scripts/dist.ts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index 49e80c91686..a03ddad9e16 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -233,21 +233,6 @@ function toDist(sourcePath: string): YAML.Document { checkAncestors: true, }); - if (computedStatus.discouraged) { - const isDraft: boolean = source.draft_date ?? false; - - 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.`, - ); - exitStatus = 1; - } else { - logger.warn( - `${id}: draft contains at least one deprecated compat feature and can never be Baseline. Was this intentional?`, - ); - } - } - computedStatus = JSON.parse(computedStatus.toJSON()); if (source.status) { @@ -286,10 +271,16 @@ function toDist(sourcePath: string): YAML.Document { for (const key of compatFeatures) { const f = feature(key); if (f.deprecated) { - logger.error( - `${id}: contains deprecated compat feature ${key}, which can never be Baseline. This is forbidden.`, - ); - exitStatus = 1; + if (source.draft_date) { + logger.warn( + `${id}: draft contains deprecated compat feature ${f.id}. Was this intentional?`, + ); + } else { + logger.error( + `${id}: contains deprecated compat feature ${f.id}. This is forbidden for published features.`, + ); + exitStatus = 1; + } } } } From 7698b0a23ad3d31e23b5ec724233f83ec35416e3 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 09:56:58 +0100 Subject: [PATCH 4/7] Revert "Check deprecatedness in one place only" This reverts commit 6bcde4d2e0003850b1ade850bee9b67ee23bcb92. --- scripts/dist.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index a03ddad9e16..49e80c91686 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -233,6 +233,21 @@ function toDist(sourcePath: string): YAML.Document { checkAncestors: true, }); + if (computedStatus.discouraged) { + const isDraft: boolean = source.draft_date ?? false; + + 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.`, + ); + exitStatus = 1; + } else { + logger.warn( + `${id}: draft contains at least one deprecated compat feature and can never be Baseline. Was this intentional?`, + ); + } + } + computedStatus = JSON.parse(computedStatus.toJSON()); if (source.status) { @@ -271,16 +286,10 @@ function toDist(sourcePath: string): YAML.Document { for (const key of compatFeatures) { const f = feature(key); if (f.deprecated) { - if (source.draft_date) { - logger.warn( - `${id}: draft contains deprecated compat feature ${f.id}. Was this intentional?`, - ); - } else { - logger.error( - `${id}: contains deprecated compat feature ${f.id}. This is forbidden for published features.`, - ); - exitStatus = 1; - } + logger.error( + `${id}: contains deprecated compat feature ${key}, which can never be Baseline. This is forbidden.`, + ); + exitStatus = 1; } } } From 7268252af139d6e057e1a572a4b25327575d1870 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 10:00:34 +0100 Subject: [PATCH 5/7] Warn only for drafts --- scripts/dist.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index 49e80c91686..293074e2c66 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -286,10 +286,16 @@ function toDist(sourcePath: string): YAML.Document { for (const key of compatFeatures) { const f = feature(key); if (f.deprecated) { - logger.error( - `${id}: contains deprecated compat feature ${key}, which can never be Baseline. This is forbidden.`, - ); - exitStatus = 1; + if (source.draft_date) { + logger.warn( + `${id}: draft contains deprecated compat feature ${f.id} and can never be Baseline. Was this intentional?`, + ); + } else { + logger.error( + `${id}: contains contains deprecated compat feature ${f.id} and can never be Baseline. This is forbidden for published features.`, + ); + exitStatus = 1; + } } } } From 432c982ce770484bc5086b5125c9626aa7ae4fb4 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 10:02:01 +0100 Subject: [PATCH 6/7] Make messages shorter --- scripts/dist.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index 293074e2c66..39810cd1099 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -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.`, ); 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?`, ); } } @@ -288,11 +288,11 @@ function toDist(sourcePath: string): YAML.Document { if (f.deprecated) { if (source.draft_date) { logger.warn( - `${id}: draft contains deprecated compat feature ${f.id} and can never be Baseline. Was this intentional?`, + `${id}: draft contains deprecated compat feature ${f.id}. Was this intentional?`, ); } else { logger.error( - `${id}: contains contains deprecated compat feature ${f.id} and can never be Baseline. This is forbidden for published features.`, + `${id}: contains contains deprecated compat feature ${f.id}. This is forbidden for published features.`, ); exitStatus = 1; } From c2e57bb529a841c6cafe9d3faef957ba2e627627 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Thu, 14 Nov 2024 10:02:57 +0100 Subject: [PATCH 7/7] Make structure more consistent --- scripts/dist.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/dist.ts b/scripts/dist.ts index 39810cd1099..e664a0f52a4 100644 --- a/scripts/dist.ts +++ b/scripts/dist.ts @@ -286,15 +286,15 @@ function toDist(sourcePath: string): YAML.Document { for (const key of compatFeatures) { const f = feature(key); if (f.deprecated) { - if (source.draft_date) { - logger.warn( - `${id}: draft contains deprecated compat feature ${f.id}. Was this intentional?`, - ); - } else { + 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?`, + ); } } }