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

Alphabetically sort scrape result keys before writing to file #4

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

MillanWangGadget
Copy link
Contributor

@MillanWangGadget MillanWangGadget commented Nov 21, 2024

  • The result of a scrape is non-deterministic which makes for some HUGE diffs with no functional changes
  • To counteract this. the resulting JSON objects from a scrape will have their properties sorted alphabetically so the resulting diff will only account for functional differences
  • Aside from the added lines in the scrape file, the net line difference in this PR should be zero

CleanShot 2024-11-21 at 10 55 18

  • Net neutral line change diff in json files
  • 21 net new lines added in the scrape file

@MillanWangGadget MillanWangGadget marked this pull request as draft November 21, 2024 15:05
@MillanWangGadget MillanWangGadget force-pushed the mill/alphabeticallySortResultFromScrape branch from 18b11c7 to 5829ce9 Compare November 21, 2024 15:49
@MillanWangGadget MillanWangGadget marked this pull request as ready for review November 21, 2024 15:49
@MillanWangGadget MillanWangGadget force-pushed the mill/alphabeticallySortResultFromScrape branch from 5829ce9 to 27b59d4 Compare November 21, 2024 15:54
src/scrape.ts Outdated
@@ -68,6 +68,25 @@ const docsWebhooksPageForVersion = (version: string) => `https://shopify.dev/doc

let warnings = 0;
let errors = 0;
const alphabeticallySortObjectByKeys = (obj: Object): Object => {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth using safe-stable-stringify for this so we don't have to maintain this code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use a lib to do the stable object key sorting, although I had to add a small lodash based utility to make sort string arrays

@MillanWangGadget MillanWangGadget force-pushed the mill/alphabeticallySortResultFromScrape branch from 27b59d4 to 7a7fe72 Compare November 21, 2024 16:37
@MillanWangGadget MillanWangGadget merged commit 8c1e1f8 into main Nov 21, 2024
@MillanWangGadget MillanWangGadget deleted the mill/alphabeticallySortResultFromScrape branch November 21, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants