Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper script for sorting browser versions #1314

Closed

Conversation

enjikaka
Copy link
Contributor

@enjikaka enjikaka commented Mar 8, 2018

Making own PR for the helper script after this comment: #1122 (comment)

This add a script that sorts browser versions in reverse chronological for you, since it's a little bit annoying to keep that in mind yourself when making the JSON, and more so when having to change it later! :)

To be run like this; npm run sort-versions api/URL.json

@enjikaka enjikaka mentioned this pull request Mar 8, 2018
enjikaka added a commit to Vufuzi/browser-compat-data that referenced this pull request Mar 8, 2018
@teoli2003 teoli2003 added the data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Mar 8, 2018
@Elchi3 Elchi3 added infra Infrastructure issues (npm, GitHub Actions, releases) of this project and removed data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API labels Apr 11, 2018
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

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

Looks good overall, though I would actually suggest to integrate this as a check into the lint task, so that the check would fail, if there is an unsorted list of versions.

blind-review

const compatData = JSON.parse(data.toString());

const apiName = Object.keys(compatData.api);
const methods = Object.keys(compatData.api[apiName]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This means it only works for compat data in the api/ hierarchy, right?

@@ -0,0 +1,45 @@
/* eslint-env node */
Copy link
Contributor

Choose a reason for hiding this comment

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

The filename sort-versions.js does not imply that it "only" sorts compat data by version_added.


const api = compatData.api[apiName];

methods.forEach(method => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Actually these are features, not necessarily only methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also you could replace the assignment to const methods by Object.keys(api).forEach(feature => { here.

@enjikaka
Copy link
Contributor Author

enjikaka commented Jul 13, 2018 via email

@Elchi3
Copy link
Member

Elchi3 commented Aug 30, 2018

Thanks for your work, @enjikaka, and your review @caugner 👍
We're going to add this as a lint task at some point as part of #1596. I'm closing this for now.

@Elchi3 Elchi3 closed this Aug 30, 2018
@queengooborg queengooborg added the scripts Issues or pull requests regarding the scripts in scripts/. label Jan 24, 2020
@mdn mdn deleted a comment Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra Infrastructure issues (npm, GitHub Actions, releases) of this project scripts Issues or pull requests regarding the scripts in scripts/.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants