Skip to content

Commit

Permalink
Order tagged features properly and not with fix linter (#25761)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elchi3 authored Jan 24, 2025
1 parent 817aceb commit 0078ac0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@
"traverse": "tsx scripts/traverse.ts",
"update-browser-releases": "tsx scripts/update-browser-releases/index.ts",
"bcd": "tsx scripts/bulk-editor/index.ts",
"tag-web-features": "tsx scripts/tag-web-features.ts && npm run fix"
"tag-web-features": "tsx scripts/tag-web-features.ts"
}
}
16 changes: 14 additions & 2 deletions scripts/tag-web-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import esMain from 'es-main';
import { fdir } from 'fdir';
import { features } from 'web-features';

import stringifyAndOrderProperties from '../scripts/lib/stringify-and-order-properties.js';

const dirname = fileURLToPath(new URL('.', import.meta.url));

// Map from api.CoolThing.something to cool-thing
Expand All @@ -29,6 +31,9 @@ for (const [feature, { compat_features }] of Object.entries(features)) {

// FixMe: The idea of scripts/bulk-editor is to have utilities for bulk updating BCD files programmatically. It also features an implementation to update tags which is not used here as the bulk-editor scripts aren't used and/or maintained properly at the moment.

/**
* Add web-feature tags to BCD keys
*/
const main = async () => {
const bcdJsons = new fdir()
.withBasePath()
Expand All @@ -42,6 +47,12 @@ const main = async () => {
.crawl(path.resolve(dirname, '..'))
.sync();

/**
* Lookup data at a specified key
* @param root JSON object
* @param key BCD key
* @returns BCD data at the specified key
*/
const lookup = (root, key) => {
const parts = key.split('.');
let node = root;
Expand Down Expand Up @@ -99,8 +110,9 @@ const main = async () => {
updated = true;
}
if (updated) {
const src = JSON.stringify(data, null, ' ') + '\n';
await fs.writeFile(fp, src, { encoding: 'utf-8' });
await fs.writeFile(fp, stringifyAndOrderProperties(data) + '\n', {
encoding: 'utf-8',
});
}
}

Expand Down

0 comments on commit 0078ac0

Please sign in to comment.