Skip to content

Commit ca15ef3

Browse files
lovellpieh
andauthored
chore(deps): upgrade sharp to latest v0.32.6 (#38374)
* chore(deps): upgrade sharp to latest v0.32.5 Ensures some PNG-related test snapshots use deterministic raw pixel data rather than non-deterministic compressed byte streams. * chore(deps): upgrade sharp to latest v0.32.6 --------- Co-authored-by: Michal Piechowiak <[email protected]>
1 parent e86b36b commit ca15ef3

File tree

17 files changed

+118
-35
lines changed

17 files changed

+118
-35
lines changed

benchmarks/source-strapi/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"prop-types": "^15.7.2",
1515
"react": "^16.12.0",
1616
"react-dom": "^16.12.0",
17-
"sharp": "^0.26.3"
17+
"sharp": "^0.32.6"
1818
},
1919
"devDependencies": {
2020
"prettier": "2.0.5"

packages/gatsby-plugin-manifest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"gatsby-core-utils": "^4.13.0-next.0",
1212
"gatsby-plugin-utils": "^4.13.0-next.0",
1313
"semver": "^7.5.3",
14-
"sharp": "^0.32.1"
14+
"sharp": "^0.32.6"
1515
},
1616
"devDependencies": {
1717
"@babel/cli": "^7.20.7",

packages/gatsby-plugin-sharp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"lodash": "^4.17.21",
1919
"probe-image-size": "^7.2.3",
2020
"semver": "^7.5.3",
21-
"sharp": "^0.32.1"
21+
"sharp": "^0.32.6"
2222
},
2323
"devDependencies": {
2424
"@babel/cli": "^7.20.7",

packages/gatsby-plugin-sharp/src/__tests__/__snapshots__/index.js.snap

+12-6
Large diffs are not rendered by default.

packages/gatsby-plugin-sharp/src/__tests__/index.js

+34-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const sharp = require(`sharp`)
1818
fs.ensureDirSync = jest.fn()
1919
fs.existsSync = jest.fn().mockReturnValue(false)
2020

21+
const decodeBase64PngAsRaw = async png =>
22+
sharp(Buffer.from(png.replace(`data:image/png;base64,`, ``), `base64`))
23+
.raw()
24+
.toBuffer()
25+
2126
const {
2227
base64,
2328
generateBase64,
@@ -136,10 +141,13 @@ describe(`gatsby-plugin-sharp`, () => {
136141
})
137142

138143
it(`includes responsive image properties, e.g. sizes, srcset, etc.`, async () => {
139-
const result = await fluid({ file })
144+
const { base64, ...result } = await fluid({ file })
140145

141146
expect(actions.createJobV2).toHaveBeenCalledTimes(1)
142147
expect(result).toMatchSnapshot()
148+
149+
const rawPixelData = await decodeBase64PngAsRaw(base64)
150+
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
143151
})
144152

145153
it(`adds pathPrefix if defined`, async () => {
@@ -400,12 +408,15 @@ describe(`gatsby-plugin-sharp`, () => {
400408

401409
describe(`base64`, () => {
402410
it(`converts image to base64`, async () => {
403-
const result = await base64({
411+
const { src, ...result } = await base64({
404412
file,
405413
args,
406414
})
407415

408416
expect(result).toMatchSnapshot()
417+
418+
const rawPixelData = await decodeBase64PngAsRaw(src)
419+
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
409420
})
410421

411422
it(`should cache same image`, async () => {
@@ -597,25 +608,31 @@ describe(`gatsby-plugin-sharp`, () => {
597608
base64: false,
598609
}
599610

600-
const fixedSvg = await fixed({
611+
const { tracedSVG: fixedTracedSVG, ...fixedSvg } = await fixed({
601612
file,
602613
args,
603614
})
604615

605616
expect(fixedSvg).toMatchSnapshot(`fixed`)
606617

607-
expect(fixedSvg.tracedSVG).toMatch(`data:image/png;base64`)
608-
expect(fixedSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
618+
expect(fixedTracedSVG).toMatch(`data:image/png;base64`)
619+
expect(fixedTracedSVG).not.toMatch(`data:image/svg+xml`)
620+
621+
const fixedRawPixelData = await decodeBase64PngAsRaw(fixedTracedSVG)
622+
expect(fixedRawPixelData.toString(`hex`)).toMatchSnapshot()
609623

610-
const fluidSvg = await fluid({
624+
const { tracedSVG: fluidTracedSVG, ...fluidSvg } = await fluid({
611625
file,
612626
args,
613627
})
614628

615629
expect(fluidSvg).toMatchSnapshot(`fluid`)
616630

617-
expect(fluidSvg.tracedSVG).toMatch(`data:image/png;base64`)
618-
expect(fluidSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
631+
expect(fluidTracedSVG).toMatch(`data:image/png;base64`)
632+
expect(fluidTracedSVG).not.toMatch(`data:image/svg+xml`)
633+
634+
const fluidRawPixelData = await decodeBase64PngAsRaw(fluidTracedSVG)
635+
expect(fluidRawPixelData.toString(`hex`)).toMatchSnapshot()
619636
})
620637
})
621638

@@ -627,13 +644,20 @@ describe(`gatsby-plugin-sharp`, () => {
627644
}
628645

629646
it(`fixed`, async () => {
630-
const result = await fixed({ file, args })
647+
const { base64, ...result } = await fixed({ file, args })
648+
631649
expect(result).toMatchSnapshot()
650+
651+
const rawPixelData = await decodeBase64PngAsRaw(base64)
652+
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
632653
})
633654

634655
it(`fluid`, async () => {
635-
const result = await fluid({ file, args })
656+
const { base64, ...result } = await fluid({ file, args })
636657
expect(result).toMatchSnapshot()
658+
659+
const rawPixelData = await decodeBase64PngAsRaw(base64)
660+
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
637661
})
638662

639663
it(`creates two different images for different duotone settings`, async () => {

packages/gatsby-remark-images-contentful/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"is-relative-url": "^3.0.0",
2323
"lodash": "^4.17.21",
2424
"semver": "^7.5.3",
25-
"sharp": "^0.32.1",
25+
"sharp": "^0.32.6",
2626
"unist-util-select": "^3.0.4"
2727
},
2828
"devDependencies": {

packages/gatsby-sharp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"types": "dist/index.d.ts",
1515
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-sharp#readme",
1616
"dependencies": {
17-
"sharp": "^0.32.1"
17+
"sharp": "^0.32.6"
1818
},
1919
"devDependencies": {
2020
"@babel/cli": "^7.20.7",

packages/gatsby-source-contentful/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"gatsby": "^5.0.0-next",
4545
"gatsby-plugin-image": "^3.0.0-next",
4646
"gatsby-plugin-sharp": "^5.0.0-next",
47-
"sharp": "^0.30.1"
47+
"sharp": "^0.32.6"
4848
},
4949
"repository": {
5050
"type": "git",

packages/gatsby-source-shopify/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"gatsby-plugin-utils": "^4.13.0-next.0",
2929
"gatsby-source-filesystem": "^5.13.0-next.0",
3030
"node-fetch": "^2.6.11",
31-
"sharp": "^0.32.1",
31+
"sharp": "^0.32.6",
3232
"shift-left": "^0.1.5"
3333
},
3434
"devDependencies": {

packages/gatsby-source-wordpress/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"read-chunk": "^3.2.0",
4343
"replaceall": "^0.1.6",
4444
"semver": "^7.5.3",
45-
"sharp": "^0.32.1",
45+
"sharp": "^0.32.6",
4646
"valid-url": "^1.0.9"
4747
},
4848
"devDependencies": {

packages/gatsby-transformer-sharp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"gatsby-plugin-utils": "^4.13.0-next.0",
1515
"probe-image-size": "^7.2.3",
1616
"semver": "^7.5.3",
17-
"sharp": "^0.32.1"
17+
"sharp": "^0.32.6"
1818
},
1919
"devDependencies": {
2020
"@babel/cli": "^7.20.7",

yarn.lock

+63-10
Original file line numberDiff line numberDiff line change
@@ -6474,6 +6474,11 @@ axobject-query@^3.1.1:
64746474
dependencies:
64756475
deep-equal "^2.0.5"
64766476

6477+
b4a@^1.6.4:
6478+
version "1.6.4"
6479+
resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.4.tgz#ef1c1422cae5ce6535ec191baeed7567443f36c9"
6480+
integrity sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==
6481+
64776482
babel-core@^7.0.0-bridge.0:
64786483
version "7.0.0-bridge.0"
64796484
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
@@ -9638,11 +9643,16 @@ detect-libc@^1.0.3:
96389643
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
96399644
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=
96409645

9641-
detect-libc@^2.0.0, detect-libc@^2.0.1:
9646+
detect-libc@^2.0.0:
96429647
version "2.0.1"
96439648
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd"
96449649
integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==
96459650

9651+
detect-libc@^2.0.2:
9652+
version "2.0.2"
9653+
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d"
9654+
integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==
9655+
96469656
detect-newline@^3.0.0, detect-newline@^3.1.0:
96479657
version "3.1.0"
96489658
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
@@ -11213,6 +11223,11 @@ fast-diff@^1.1.2:
1121311223
version "1.2.0"
1121411224
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
1121511225

11226+
fast-fifo@^1.1.0, fast-fifo@^1.2.0:
11227+
version "1.3.0"
11228+
resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.0.tgz#03e381bcbfb29932d7c3afde6e15e83e05ab4d8b"
11229+
integrity sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw==
11230+
1121611231
fast-glob@^2.2.6:
1121711232
version "2.2.7"
1121811233
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d"
@@ -20089,6 +20104,11 @@ querystringify@^2.1.1:
2008920104
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
2009020105
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==
2009120106

20107+
queue-tick@^1.0.1:
20108+
version "1.0.1"
20109+
resolved "https://registry.yarnpkg.com/queue-tick/-/queue-tick-1.0.1.tgz#f6f07ac82c1fd60f82e098b417a80e52f1f4c142"
20110+
integrity sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==
20111+
2009220112
quick-format-unescaped@^4.0.3:
2009320113
version "4.0.4"
2009420114
resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz#93ef6dd8d3453cbc7970dd614fad4c5954d6b5a7"
@@ -21698,13 +21718,20 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
2169821718
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
2169921719
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
2170021720

21701-
semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0, semver@^7.5.3:
21721+
semver@^7.1.1, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3:
2170221722
version "7.5.3"
2170321723
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
2170421724
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
2170521725
dependencies:
2170621726
lru-cache "^6.0.0"
2170721727

21728+
semver@^7.5.4:
21729+
version "7.5.4"
21730+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
21731+
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
21732+
dependencies:
21733+
lru-cache "^6.0.0"
21734+
2170821735
2170921736
version "0.18.0"
2171021737
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
@@ -21826,18 +21853,18 @@ shallow-copy@~0.0.1:
2182621853
version "0.0.1"
2182721854
resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170"
2182821855

21829-
sharp@^0.32.1:
21830-
version "0.32.1"
21831-
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.32.1.tgz#41aa0d0b2048b2e0ee453d9fcb14ec1f408390fe"
21832-
integrity sha512-kQTFtj7ldpUqSe8kDxoGLZc1rnMFU0AO2pqbX6pLy3b7Oj8ivJIdoKNwxHVQG2HN6XpHPJqCSM2nsma2gOXvOg==
21856+
sharp@^0.32.6:
21857+
version "0.32.6"
21858+
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.32.6.tgz#6ad30c0b7cd910df65d5f355f774aa4fce45732a"
21859+
integrity sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==
2183321860
dependencies:
2183421861
color "^4.2.3"
21835-
detect-libc "^2.0.1"
21862+
detect-libc "^2.0.2"
2183621863
node-addon-api "^6.1.0"
2183721864
prebuild-install "^7.1.1"
21838-
semver "^7.5.0"
21865+
semver "^7.5.4"
2183921866
simple-get "^4.0.1"
21840-
tar-fs "^2.1.1"
21867+
tar-fs "^3.0.4"
2184121868
tunnel-agent "^0.6.0"
2184221869

2184321870
shebang-command@^1.2.0:
@@ -22460,6 +22487,14 @@ streamsearch@^1.1.0:
2246022487
resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764"
2246122488
integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==
2246222489

22490+
streamx@^2.15.0:
22491+
version "2.15.0"
22492+
resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.15.0.tgz#f58c92e6f726b5390dcabd6dd9094d29a854d698"
22493+
integrity sha512-HcxY6ncGjjklGs1xsP1aR71INYcsXFJet5CU1CHqihQ2J5nOsbd4OjgjHO42w/4QNv9gZb3BueV+Vxok5pLEXg==
22494+
dependencies:
22495+
fast-fifo "^1.1.0"
22496+
queue-tick "^1.0.1"
22497+
2246322498
strict-event-emitter@^0.2.4:
2246422499
version "0.2.8"
2246522500
resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.2.8.tgz#b4e768927c67273c14c13d20e19d5e6c934b47ca"
@@ -23086,7 +23121,7 @@ tapable@^2.0, tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0:
2308623121
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b"
2308723122
integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==
2308823123

23089-
tar-fs@^2.0.0, tar-fs@^2.1.1:
23124+
tar-fs@^2.0.0:
2309023125
version "2.1.1"
2309123126
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784"
2309223127
integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==
@@ -23096,6 +23131,15 @@ tar-fs@^2.0.0, tar-fs@^2.1.1:
2309623131
pump "^3.0.0"
2309723132
tar-stream "^2.1.4"
2309823133

23134+
tar-fs@^3.0.4:
23135+
version "3.0.4"
23136+
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.0.4.tgz#a21dc60a2d5d9f55e0089ccd78124f1d3771dbbf"
23137+
integrity sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==
23138+
dependencies:
23139+
mkdirp-classic "^0.5.2"
23140+
pump "^3.0.0"
23141+
tar-stream "^3.1.5"
23142+
2309923143
tar-stream@^2.1.4:
2310023144
version "2.1.4"
2310123145
resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.1.4.tgz#c4fb1a11eb0da29b893a5b25476397ba2d053bfa"
@@ -23107,6 +23151,15 @@ tar-stream@^2.1.4:
2310723151
inherits "^2.0.3"
2310823152
readable-stream "^3.1.1"
2310923153

23154+
tar-stream@^3.1.5:
23155+
version "3.1.6"
23156+
resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-3.1.6.tgz#6520607b55a06f4a2e2e04db360ba7d338cc5bab"
23157+
integrity sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==
23158+
dependencies:
23159+
b4a "^1.6.4"
23160+
fast-fifo "^1.2.0"
23161+
streamx "^2.15.0"
23162+
2311023163
tar@^4.4.10, tar@^4.4.12, tar@^4.4.8:
2311123164
version "4.4.19"
2311223165
resolved "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3"

0 commit comments

Comments
 (0)