diff --git a/package.json b/package.json index b071bdc..08bd48d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "chalk": "^5.3.0", "cheerio": "1.0.0-rc.12", "eslint": "^8.52.0", - "fast-safe-stringify": "^2.1.1", "fs-extra": "^11.2.0", "gitpkg": "1.0.0-beta.4", "globby": "^14.0.1", @@ -52,6 +51,7 @@ "lodash": "^4.17.21", "prettier": "^2.8.8", "publint": "^0.2.7", + "safe-stable-stringify": "^2.5.0", "traverse": "^0.6.9", "tsx": "^4.7.3", "typescript": "^5.4.5" diff --git a/src/scrape.ts b/src/scrape.ts index 178ad15..7cb70f6 100644 --- a/src/scrape.ts +++ b/src/scrape.ts @@ -2,15 +2,17 @@ import { getVocabulary, schemaWalk } from "@cloudflare/json-schema-walker"; import { inferSchema } from "@jsonhero/schema-infer"; import chalk from "chalk"; import cheerio from "cheerio"; -import safeStringify from "fast-safe-stringify"; import fs from "fs-extra"; import { globby } from "globby"; import got from "got"; import { cloneDeep, cloneDeepWith, isEqual, merge, pick, uniq } from "lodash"; import path from "path"; +import { configure } from "safe-stable-stringify"; import { getPackageRootDir } from "src"; import { startDecoding } from "./shopify.js"; +const stringify = configure({ deterministic: true }); + const startVersion = "2024-04"; function assert(value: T | false | undefined | null, message?: string): T { @@ -79,8 +81,8 @@ const sortStringArrays = (obj: Object) => { }; const getDeterministicObject = (obj: Object): Object => { - const stableString = safeStringify.stableStringify(sortStringArrays(obj)); - return JSON.parse(stableString); + const stableString = stringify(sortStringArrays(obj)); + return JSON.parse(stableString!); }; const inferSchemaFromExamplePayload = (examplePayload: Record, metadata: { name: string }) => {