Skip to content

Commit caaf7a5

Browse files
Apprentice76wardpeetpieh
authored
fix(gatsby-source-filesystem): Update createRemoteFileNode args (#35422)
* fixes issue #35363 and CreateFileNodeFromBufferArgs * modified tests for remote-file-node and file-node-from-buffer * updated function calls in dependencies * removed unused typescript imports Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Michal Piechowiak <[email protected]>
1 parent 4c180eb commit caaf7a5

File tree

15 files changed

+7
-55
lines changed

15 files changed

+7
-55
lines changed

benchmarks/image-processing/plugins/gatsby-source-remote-images/gatsby-node.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ exports.sourceNodes = ({ actions, createNodeId, store, cache }) =>
1616
fileNode = await createRemoteFileNode({
1717
url: url,
1818
parentNodeId: nodeId,
19-
store,
2019
cache,
2120
createNode: actions.createNode,
2221
createNodeId,

benchmarks/source-agilitycms/gatsby-node.js

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ exports.onCreateNode = async ({
4646
createNode, // helper function in gatsby-node to generate the node
4747
createNodeId, // helper function in gatsby-node to generate the node id
4848
cache, // Gatsby's cache
49-
store, // Gatsby's redux store
5049
})
5150
// if the file was created, attach the new node to the parent node
5251
if (fileNode) {

examples/using-gatsby-image/plugins/gatsby-source-remote-images/gatsby-node.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ exports.onCreateNode = async (
1414
if (filter(node)) {
1515
const fileNode = await createRemoteFileNode({
1616
url: node.url,
17-
store,
1817
cache,
1918
createNode,
2019
createNodeId: createContentDigest,
21-
reporter,
2220
})
2321

2422
if (fileNode) {

examples/using-gatsby-source-graphql/gatsby-node.js

-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ exports.createResolvers = ({
5959
resolve(source, args, context, info) {
6060
return createRemoteFileNode({
6161
url: source.url,
62-
store,
6362
cache,
6463
createNode,
6564
createNodeId,
66-
reporter,
6765
})
6866
},
6967
},

packages/gatsby-plugin-image/src/node-apis/image-processing.ts

-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export async function writeImages({
6969
sourceDir,
7070
createNodeId,
7171
createNode,
72-
store,
7372
filename,
7473
}: {
7574
images: Map<string, IStaticImageProps>
@@ -80,7 +79,6 @@ export async function writeImages({
8079
sourceDir: string
8180
createNodeId: ParentSpanPluginArgs["createNodeId"]
8281
createNode: Actions["createNode"]
83-
store: Store
8482
filename: string
8583
}): Promise<void> {
8684
const promises = [...images.entries()].map(
@@ -103,11 +101,9 @@ export async function writeImages({
103101
try {
104102
file = await createRemoteFileNode({
105103
url: src,
106-
store,
107104
cache,
108105
createNode,
109106
createNodeId,
110-
reporter,
111107
})
112108
} catch (err) {
113109
reporter.error(`Error loading image ${src}`, err)

packages/gatsby-plugin-image/src/node-apis/preprocess-source.ts

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export async function preprocessSource({
7474
sourceDir,
7575
createNodeId,
7676
createNode,
77-
store,
7877
filename,
7978
})
8079

packages/gatsby-source-contentful/src/download-contentful-assets.js

-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ export async function downloadContentfulAssets(gatsbyFunctions) {
7878
if (!fileNodeID) {
7979
const fileNode = await createRemoteFileNode({
8080
url,
81-
store,
8281
cache,
8382
createNode,
8483
createNodeId,
85-
reporter,
8684
})
8785

8886
if (fileNode) {

packages/gatsby-source-drupal/src/normalize.js

-2
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,12 @@ exports.downloadFile = async (
263263
const fileNode = await createRemoteFileNode({
264264
url: url.href,
265265
name: path.parse(decodeURIComponent(url.pathname)).name,
266-
store,
267266
cache,
268267
createNode,
269268
createNodeId,
270269
getCache,
271270
parentNodeId: node.id,
272271
auth,
273-
reporter,
274272
})
275273
if (fileNode) {
276274
node.localFile___NODE = fileNode.id

packages/gatsby-source-filesystem/index.d.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Node, Store, NodePluginArgs } from "gatsby"
1+
import { Node, GatsbyCache } from "gatsby"
22

33
/**
44
* @see https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/?=files#createfilepath
@@ -28,9 +28,8 @@ export interface CreateFilePathArgs {
2828

2929
export interface CreateRemoteFileNodeArgs {
3030
url: string
31-
store: Store
32-
// TODO: use GatsbyCache type (requires [email protected])
33-
cache: NodePluginArgs["cache"]
31+
cache?: GatsbyCache
32+
getCache?: Function
3433
createNode: Function
3534
createNodeId: Function
3635
parentNodeId?: string
@@ -41,14 +40,12 @@ export interface CreateRemoteFileNodeArgs {
4140
httpHeaders?: object
4241
ext?: string
4342
name?: string
44-
reporter: object
4543
}
4644

4745
export interface CreateFileNodeFromBufferArgs {
4846
buffer: Buffer
49-
store: Store
50-
// TODO: use GatsbyCache type (requires [email protected])
51-
cache: NodePluginArgs["cache"]
47+
cache?: GatsbyCache
48+
getCache?: Function
5249
createNode: Function
5350
createNodeId: Function
5451
parentNodeId?: string

packages/gatsby-source-filesystem/src/__tests__/create-file-node-from-buffer.js

-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ const bufferEq = (b1, b2) => Buffer.compare(b1, b2) === 0
4040

4141
describe(`create-file-node-from-buffer`, () => {
4242
const defaultArgs = {
43-
store: {
44-
getState: jest.fn(() => {
45-
return {
46-
program: {
47-
directory: `__whatever__`,
48-
},
49-
}
50-
}),
51-
},
5243
createNode: jest.fn(),
5344
createNodeId: jest.fn(),
5445
}

packages/gatsby-source-filesystem/src/__tests__/create-remote-file-node.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { fetchRemoteFile } from "gatsby-core-utils/fetch-remote-file"
22

3-
const reporter = {}
4-
53
const createRemoteFileNode = require(`../create-remote-file-node`)
64

75
jest.mock(`gatsby-core-utils/fetch-remote-file`, () => {
@@ -33,11 +31,9 @@ describe(`create-remote-file-node`, () => {
3331

3432
const defaultArgs = {
3533
url: `https://external.com/dog.jpg`,
36-
store: {},
3734
getCache: () => cache,
3835
createNode: jest.fn(),
3936
createNodeId: jest.fn(() => String(uuid++)),
40-
reporter,
4137
ext: `.jpg`,
4238
name: `dog-thumbnail`,
4339
}

packages/gatsby-source-filesystem/src/create-remote-file-node.js

-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ const { createFileNode } = require(`./create-file-node`)
1111
* @see gatsby/packages/gatsby/utils/cache.js
1212
*/
1313

14-
/**
15-
* @typedef {Reporter}
16-
* @see gatsby/packages/gatsby-cli/lib/reporter.js
17-
*/
18-
1914
/**
2015
* @typedef {Auth}
2116
* @type {Object}
@@ -33,7 +28,6 @@ const { createFileNode } = require(`./create-file-node`)
3328
* @param {Function} options.createNode
3429
* @param {Function} options.getCache
3530
* @param {Auth} [options.auth]
36-
* @param {Reporter} [options.reporter]
3731
*/
3832

3933
/******************

packages/gatsby-source-shopify/src/helpers.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,7 @@ export function decorateBulkObject(input: unknown): unknown {
9595
}
9696

9797
export async function processShopifyImages(
98-
{
99-
actions: { createNode },
100-
createNodeId,
101-
cache,
102-
store,
103-
reporter,
104-
}: SourceNodesArgs,
98+
{ actions: { createNode }, createNodeId, cache }: SourceNodesArgs,
10599
node: IShopifyNode
106100
): Promise<void> {
107101
const type = parseShopifyId(node.shopifyId)[1]
@@ -122,8 +116,6 @@ export async function processShopifyImages(
122116
createNode,
123117
createNodeId,
124118
parentNodeId: node.id,
125-
store,
126-
reporter,
127119
})
128120

129121
image.localFile___NODE = fileNode.id

packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-local-file-node.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,9 @@ export const createLocalFileNode = async ({
265265

266266
const createFileNodeRequirements = {
267267
parentNodeId: mediaItemNode.id,
268-
store: gatsbyStore,
269268
cache,
270269
createNode,
271270
createNodeId,
272-
reporter,
273271
}
274272

275273
let remoteFileNode
@@ -322,6 +320,7 @@ export const createLocalFileNode = async ({
322320
url: mediaItemUrl,
323321
auth,
324322
...createFileNodeRequirements,
323+
reporter,
325324
pluginOptions,
326325
})
327326

packages/gatsby-transformer-screenshot/src/gatsby-node.js

-2
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ const createScreenshotNode = async ({
152152

153153
fileNode = await createRemoteFileNode({
154154
url: screenshotResponse.data.url,
155-
store,
156155
cache,
157156
createNode,
158157
createNodeId,
159158
getCache,
160159
parentNodeId,
161-
reporter,
162160
})
163161
expires = screenshotResponse.data.expires
164162

0 commit comments

Comments
 (0)