Skip to content

Commit 2380f42

Browse files
SukkaWJounQin
authored andcommitted
replace json-stable-stringify
1 parent a1aecf9 commit 2380f42

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"@types/cross-spawn": "^6.0.0",
6060
"@types/fs-extra": "^9.0.0",
6161
"@types/jest": "^24.0.11",
62-
"@types/json-stable-stringify": "^1.0.34",
6362
"@types/minimist": "^1.2.2",
6463
"@types/node": "^12.0.0",
6564
"@types/rimraf": "^2.0.2",
@@ -78,12 +77,12 @@
7877
"typescript": "^4.2.2"
7978
},
8079
"dependencies": {
80+
"@nolyfill/json-stable-stringify": "^1.0.30",
8181
"@yarnpkg/lockfile": "^1.1.0",
8282
"ci-info": "^3.7.0",
8383
"cross-spawn": "^7.0.3",
8484
"find-yarn-workspace-root": "^2.0.0",
8585
"fs-extra": "^10.0.0",
86-
"json-stable-stringify": "^1.0.2",
8786
"klaw-sync": "^6.0.0",
8887
"minimist": "^1.2.6",
8988
"open": "^7.4.2",

src/stateFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "fs"
22
import { join } from "path"
33
import { PackageDetails } from "./PackageDetails"
4-
import stringify from "json-stable-stringify"
4+
import stringify from "@nolyfill/json-stable-stringify"
55
import { hashFile } from "./hash"
66
import picocolors from "picocolors"
77
export interface PatchState {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// copied temporarily from https://github.com/ljharb/json-stable-stringify/blob/main/index.d.ts
2+
declare module "@nolyfill/json-stable-stringify" {
3+
namespace stableStringify {
4+
type Key = string | number
5+
6+
type NonArrayNode = Record<Key, unknown>
7+
type Node = unknown[] | NonArrayNode
8+
9+
type Getter = { get(key: Key): unknown }
10+
11+
type Comparator = (
12+
a: { key: string; value: unknown },
13+
b: { key: string; value: unknown },
14+
getter: Getter,
15+
) => number
16+
17+
type StableStringifyOptions = {
18+
cmp?: Comparator
19+
cycles?: boolean
20+
replacer?: (this: Node, key: Key, value: unknown) => unknown
21+
space?: string | number
22+
}
23+
}
24+
25+
function stableStringify(
26+
obj: unknown,
27+
options?:
28+
| (stableStringify.Comparator & stableStringify.StableStringifyOptions)
29+
| stableStringify.StableStringifyOptions,
30+
): string | undefined
31+
32+
export = stableStringify
33+
}

yarn.lock

+5-23
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,11 @@
607607
"@nodelib/fs.scandir" "2.1.5"
608608
fastq "^1.6.0"
609609

610+
"@nolyfill/json-stable-stringify@^1.0.30":
611+
version "1.0.30"
612+
resolved "https://registry.yarnpkg.com/@nolyfill/json-stable-stringify/-/json-stable-stringify-1.0.30.tgz#edff60da41cee9dd7f81028c527acf7f7b91df64"
613+
integrity sha512-o1iEMo6ad7T2cKxZTzAb3u+Q3/H21SSsKFf5oAVn7PjmT7MJ0Ek2SeVcEdgVUmLmj31/jKo7U5zJWcTaC10Qow==
614+
610615
"@samverschueren/stream-to-observable@^0.3.0", "@samverschueren/stream-to-observable@^0.3.1":
611616
version "0.3.1"
612617
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz#a21117b19ee9be70c379ec1877537ef2e1c63301"
@@ -745,13 +750,6 @@
745750
dependencies:
746751
jest-diff "^24.3.0"
747752

748-
"@types/json-stable-stringify@^1.0.34":
749-
version "1.2.0"
750-
resolved "https://registry.yarnpkg.com/@types/json-stable-stringify/-/json-stable-stringify-1.2.0.tgz#fda9291c45a8ec79ed195883fb2bb09f0aa95854"
751-
integrity sha512-PEHY3ohqolHqAzDyB1+31tFaAMnoLN7x/JgdcGmNZ2uvtEJ6rlFCUYNQc0Xe754xxCYLNGZbLUGydSE6tS4S9A==
752-
dependencies:
753-
json-stable-stringify "*"
754-
755753
"@types/keyv@^3.1.1", "@types/keyv@^3.1.4":
756754
version "3.1.4"
757755
resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6"
@@ -4027,17 +4025,6 @@ [email protected]:
40274025
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5"
40284026
integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==
40294027

4030-
json-stable-stringify@*, json-stable-stringify@^1.0.2:
4031-
version "1.2.1"
4032-
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.2.1.tgz#addb683c2b78014d0b78d704c2fcbdf0695a60e2"
4033-
integrity sha512-Lp6HbbBgosLmJbjx0pBLbgvx68FaFU1sdkmBuckmhhJ88kL13OA51CDtR2yJB50eCNMH9wRqtQNNiAqQH4YXnA==
4034-
dependencies:
4035-
call-bind "^1.0.8"
4036-
call-bound "^1.0.3"
4037-
isarray "^2.0.5"
4038-
jsonify "^0.0.1"
4039-
object-keys "^1.1.1"
4040-
40414028
json-stringify-safe@~5.0.1:
40424029
version "5.0.1"
40434030
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
@@ -4064,11 +4051,6 @@ jsonfile@^6.0.1:
40644051
optionalDependencies:
40654052
graceful-fs "^4.1.6"
40664053

4067-
jsonify@^0.0.1:
4068-
version "0.0.1"
4069-
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978"
4070-
integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==
4071-
40724054
jsprim@^1.2.2:
40734055
version "1.4.2"
40744056
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb"

0 commit comments

Comments
 (0)