Skip to content

Commit

Permalink
chore(deps): upgrade sharp to latest v0.32.6 (#38374) (#38617)
Browse files Browse the repository at this point in the history
* 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 <misiek.piechowiak@gmail.com>
(cherry picked from commit ca15ef3)

Co-authored-by: Lovell Fuller <lovell@users.noreply.github.com>
  • Loading branch information
gatsbybot and lovell authored Oct 9, 2023
1 parent 4dc464b commit f1a4107
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 35 deletions.
2 changes: 1 addition & 1 deletion benchmarks/source-strapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"sharp": "^0.26.3"
"sharp": "^0.32.6"
},
"devDependencies": {
"prettier": "2.0.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"gatsby-core-utils": "^4.12.0",
"gatsby-plugin-utils": "^4.12.0",
"semver": "^7.5.3",
"sharp": "^0.32.1"
"sharp": "^0.32.6"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lodash": "^4.17.21",
"probe-image-size": "^7.2.3",
"semver": "^7.5.3",
"sharp": "^0.32.1"
"sharp": "^0.32.6"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
Expand Down

Large diffs are not rendered by default.

44 changes: 34 additions & 10 deletions packages/gatsby-plugin-sharp/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const sharp = require(`sharp`)
fs.ensureDirSync = jest.fn()
fs.existsSync = jest.fn().mockReturnValue(false)

const decodeBase64PngAsRaw = async png =>
sharp(Buffer.from(png.replace(`data:image/png;base64,`, ``), `base64`))
.raw()
.toBuffer()

const {
base64,
generateBase64,
Expand Down Expand Up @@ -136,10 +141,13 @@ describe(`gatsby-plugin-sharp`, () => {
})

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

expect(actions.createJobV2).toHaveBeenCalledTimes(1)
expect(result).toMatchSnapshot()

const rawPixelData = await decodeBase64PngAsRaw(base64)
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
})

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

describe(`base64`, () => {
it(`converts image to base64`, async () => {
const result = await base64({
const { src, ...result } = await base64({
file,
args,
})

expect(result).toMatchSnapshot()

const rawPixelData = await decodeBase64PngAsRaw(src)
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
})

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

const fixedSvg = await fixed({
const { tracedSVG: fixedTracedSVG, ...fixedSvg } = await fixed({
file,
args,
})

expect(fixedSvg).toMatchSnapshot(`fixed`)

expect(fixedSvg.tracedSVG).toMatch(`data:image/png;base64`)
expect(fixedSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
expect(fixedTracedSVG).toMatch(`data:image/png;base64`)
expect(fixedTracedSVG).not.toMatch(`data:image/svg+xml`)

const fixedRawPixelData = await decodeBase64PngAsRaw(fixedTracedSVG)
expect(fixedRawPixelData.toString(`hex`)).toMatchSnapshot()

const fluidSvg = await fluid({
const { tracedSVG: fluidTracedSVG, ...fluidSvg } = await fluid({
file,
args,
})

expect(fluidSvg).toMatchSnapshot(`fluid`)

expect(fluidSvg.tracedSVG).toMatch(`data:image/png;base64`)
expect(fluidSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
expect(fluidTracedSVG).toMatch(`data:image/png;base64`)
expect(fluidTracedSVG).not.toMatch(`data:image/svg+xml`)

const fluidRawPixelData = await decodeBase64PngAsRaw(fluidTracedSVG)
expect(fluidRawPixelData.toString(`hex`)).toMatchSnapshot()
})
})

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

it(`fixed`, async () => {
const result = await fixed({ file, args })
const { base64, ...result } = await fixed({ file, args })

expect(result).toMatchSnapshot()

const rawPixelData = await decodeBase64PngAsRaw(base64)
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
})

it(`fluid`, async () => {
const result = await fluid({ file, args })
const { base64, ...result } = await fluid({ file, args })
expect(result).toMatchSnapshot()

const rawPixelData = await decodeBase64PngAsRaw(base64)
expect(rawPixelData.toString(`hex`)).toMatchSnapshot()
})

it(`creates two different images for different duotone settings`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-remark-images-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"is-relative-url": "^3.0.0",
"lodash": "^4.17.21",
"semver": "^7.5.3",
"sharp": "^0.32.1",
"sharp": "^0.32.6",
"unist-util-select": "^3.0.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"types": "dist/index.d.ts",
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-sharp#readme",
"dependencies": {
"sharp": "^0.32.1"
"sharp": "^0.32.6"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"gatsby": "^5.0.0-next",
"gatsby-plugin-image": "^3.0.0-next",
"gatsby-plugin-sharp": "^5.0.0-next",
"sharp": "^0.30.1"
"sharp": "^0.32.6"
},
"repository": {
"type": "git",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/gatsby-source-shopify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"gatsby-plugin-utils": "^4.12.0",
"gatsby-source-filesystem": "^5.12.0",
"node-fetch": "^2.6.11",
"sharp": "^0.32.1",
"sharp": "^0.32.6",
"shift-left": "^0.1.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-wordpress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"read-chunk": "^3.2.0",
"replaceall": "^0.1.6",
"semver": "^7.5.3",
"sharp": "^0.32.1",
"sharp": "^0.32.6",
"valid-url": "^1.0.9"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-transformer-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"gatsby-plugin-utils": "^4.12.0",
"probe-image-size": "^7.2.3",
"semver": "^7.5.3",
"sharp": "^0.32.1"
"sharp": "^0.32.6"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
Expand Down
73 changes: 63 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6474,6 +6474,11 @@ axobject-query@^3.1.1:
dependencies:
deep-equal "^2.0.5"

b4a@^1.6.4:
version "1.6.4"
resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.4.tgz#ef1c1422cae5ce6535ec191baeed7567443f36c9"
integrity sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==

babel-core@^7.0.0-bridge.0:
version "7.0.0-bridge.0"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
Expand Down Expand Up @@ -9638,11 +9643,16 @@ detect-libc@^1.0.3:
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=

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

detect-libc@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d"
integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==

detect-newline@^3.0.0, detect-newline@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
Expand Down Expand Up @@ -11213,6 +11223,11 @@ fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"

fast-fifo@^1.1.0, fast-fifo@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.0.tgz#03e381bcbfb29932d7c3afde6e15e83e05ab4d8b"
integrity sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw==

fast-glob@^2.2.6:
version "2.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d"
Expand Down Expand Up @@ -20089,6 +20104,11 @@ querystringify@^2.1.1:
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==

queue-tick@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/queue-tick/-/queue-tick-1.0.1.tgz#f6f07ac82c1fd60f82e098b417a80e52f1f4c142"
integrity sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==

quick-format-unescaped@^4.0.3:
version "4.0.4"
resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz#93ef6dd8d3453cbc7970dd614fad4c5954d6b5a7"
Expand Down Expand Up @@ -21698,13 +21718,20 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

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:
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:
version "7.5.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
dependencies:
lru-cache "^6.0.0"

semver@^7.5.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

send@0.18.0:
version "0.18.0"
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
Expand Down Expand Up @@ -21826,18 +21853,18 @@ shallow-copy@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170"

sharp@^0.32.1:
version "0.32.1"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.32.1.tgz#41aa0d0b2048b2e0ee453d9fcb14ec1f408390fe"
integrity sha512-kQTFtj7ldpUqSe8kDxoGLZc1rnMFU0AO2pqbX6pLy3b7Oj8ivJIdoKNwxHVQG2HN6XpHPJqCSM2nsma2gOXvOg==
sharp@^0.32.6:
version "0.32.6"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.32.6.tgz#6ad30c0b7cd910df65d5f355f774aa4fce45732a"
integrity sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==
dependencies:
color "^4.2.3"
detect-libc "^2.0.1"
detect-libc "^2.0.2"
node-addon-api "^6.1.0"
prebuild-install "^7.1.1"
semver "^7.5.0"
semver "^7.5.4"
simple-get "^4.0.1"
tar-fs "^2.1.1"
tar-fs "^3.0.4"
tunnel-agent "^0.6.0"

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

streamx@^2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.15.0.tgz#f58c92e6f726b5390dcabd6dd9094d29a854d698"
integrity sha512-HcxY6ncGjjklGs1xsP1aR71INYcsXFJet5CU1CHqihQ2J5nOsbd4OjgjHO42w/4QNv9gZb3BueV+Vxok5pLEXg==
dependencies:
fast-fifo "^1.1.0"
queue-tick "^1.0.1"

strict-event-emitter@^0.2.4:
version "0.2.8"
resolved "https://registry.yarnpkg.com/strict-event-emitter/-/strict-event-emitter-0.2.8.tgz#b4e768927c67273c14c13d20e19d5e6c934b47ca"
Expand Down Expand Up @@ -23086,7 +23121,7 @@ tapable@^2.0, tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b"
integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==

tar-fs@^2.0.0, tar-fs@^2.1.1:
tar-fs@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784"
integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==
Expand All @@ -23096,6 +23131,15 @@ tar-fs@^2.0.0, tar-fs@^2.1.1:
pump "^3.0.0"
tar-stream "^2.1.4"

tar-fs@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.0.4.tgz#a21dc60a2d5d9f55e0089ccd78124f1d3771dbbf"
integrity sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==
dependencies:
mkdirp-classic "^0.5.2"
pump "^3.0.0"
tar-stream "^3.1.5"

tar-stream@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.1.4.tgz#c4fb1a11eb0da29b893a5b25476397ba2d053bfa"
Expand All @@ -23107,6 +23151,15 @@ tar-stream@^2.1.4:
inherits "^2.0.3"
readable-stream "^3.1.1"

tar-stream@^3.1.5:
version "3.1.6"
resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-3.1.6.tgz#6520607b55a06f4a2e2e04db360ba7d338cc5bab"
integrity sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==
dependencies:
b4a "^1.6.4"
fast-fifo "^1.2.0"
streamx "^2.15.0"

tar@^4.4.10, tar@^4.4.12, tar@^4.4.8:
version "4.4.19"
resolved "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3"
Expand Down

0 comments on commit f1a4107

Please sign in to comment.