From 170750be512f3cc0aebf14ca817ceaab710ed375 Mon Sep 17 00:00:00 2001 From: "Daniel D. Beck" Date: Wed, 13 Nov 2024 13:18:02 +0100 Subject: [PATCH] `update-drafts`: clean up completed specs This works even if the specification has been superseded. --- features/draft/spec/css-grid-2.yml | 53 ------------------------------ scripts/update-drafts.ts | 29 ++++++++++++++-- 2 files changed, 27 insertions(+), 55 deletions(-) delete mode 100644 features/draft/spec/css-grid-2.yml diff --git a/features/draft/spec/css-grid-2.yml b/features/draft/spec/css-grid-2.yml deleted file mode 100644 index be99a69d7c7..00000000000 --- a/features/draft/spec/css-grid-2.yml +++ /dev/null @@ -1,53 +0,0 @@ -draft_date: 2024-10-07 -name: CSS Grid Layout Module Level 2 -description: TODO -spec: https://drafts.csswg.org/css-grid-2/ -compat_features: - - css.properties.column-gap - - css.properties.column-gap.multicol_context - -# The following features in the spec are already part of web-features: -# - Grid: -# - css.properties.align-content.grid_context -# - css.properties.column-gap.grid_context -# - css.properties.grid -# - css.properties.grid-area -# - css.properties.grid-auto-columns -# - css.properties.grid-auto-flow -# - css.properties.grid-auto-flow.column -# - css.properties.grid-auto-flow.dense -# - css.properties.grid-auto-flow.row -# - css.properties.grid-auto-rows -# - css.properties.grid-column -# - css.properties.grid-column-end -# - css.properties.grid-column-start -# - css.properties.grid-row -# - css.properties.grid-row-end -# - css.properties.grid-row-start -# - css.properties.grid-template -# - css.properties.grid-template.none -# - css.properties.grid-template-areas -# - css.properties.grid-template-areas.none -# - css.properties.grid-template-columns -# - css.properties.grid-template-columns.auto -# - css.properties.grid-template-columns.max-content -# - css.properties.grid-template-columns.min-content -# - css.properties.grid-template-columns.minmax -# - css.properties.grid-template-columns.none -# - css.properties.grid-template-columns.repeat -# - css.properties.grid-template-rows -# - css.properties.grid-template-rows.auto -# - css.properties.grid-template-rows.max-content -# - css.properties.grid-template-rows.min-content -# - css.properties.grid-template-rows.minmax -# - css.properties.grid-template-rows.none -# - css.properties.grid-template-rows.repeat -# - css.types.flex -# - Flexbox gap: -# - css.properties.column-gap.flex_context -# - Masonry: -# - css.properties.grid-template-columns.masonry -# - css.properties.grid-template-rows.masonry -# - Subgrid: -# - css.properties.grid-template-columns.subgrid -# - css.properties.grid-template-rows.subgrid diff --git a/scripts/update-drafts.ts b/scripts/update-drafts.ts index a7b6356fe25..3024aeec99f 100644 --- a/scripts/update-drafts.ts +++ b/scripts/update-drafts.ts @@ -7,10 +7,10 @@ import { fileURLToPath } from "node:url"; import Path from "path"; import webSpecs from "web-specs" assert { type: "json" }; import winston from "winston"; -import { Document } from "yaml"; +import { Document, parse } from "yaml"; import yargs from "yargs"; - import { features } from "../index.js"; +import { FeatureData } from "../types.js"; type WebSpecsSpec = (typeof webSpecs)[number]; @@ -270,6 +270,31 @@ async function main() { await fs.writeFile(destination, proposedFile); logger.info(`${destination}: updated`); } + + // Clean up completed specs + const assignedKeys = Object.values(features).flatMap( + (f) => f.compat_features ?? [], + ); + for (const spec of webSpecs) { + const id = formatIdentifier(spec.shortname); + const destination = `features/draft/spec/${id}.yml`; + + if (!fsSync.existsSync(destination)) { + continue; + } + + const source = fsSync.readFileSync(destination, { encoding: "utf-8" }); + const draft = parse(source) as FeatureData; + + if ( + (draft.compat_features ?? []).some((key) => !assignedKeys.includes(key)) + ) { + continue; + } + + fsSync.rmSync(destination); + logger.warn(`${destination}: deleted (all keys accounted for)`); + } } if (process.argv[1] === fileURLToPath(import.meta.url)) {