gatsby-source-filesystem 2.1.53 → 2.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +7 -18
- package/create-file-node-from-buffer.js +8 -18
- package/create-remote-file-node.js +7 -17
- package/extend-file-node.js +1 -1
- package/package.json +10 -10
- package/utils.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.1.57](https://github.com/gatsbyjs/gatsby/compare/gatsby-source-filesystem@2.1.56...gatsby-source-filesystem@2.1.57) (2020-03-18)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **gatsby-source-filesystem:** Unify publicURL ([#22328](https://github.com/gatsbyjs/gatsby/issues/22328)) ([756d386](https://github.com/gatsbyjs/gatsby/commit/756d386))
|
|
11
|
+
|
|
12
|
+
## [2.1.56](https://github.com/gatsbyjs/gatsby/compare/gatsby-source-filesystem@2.1.55...gatsby-source-filesystem@2.1.56) (2020-03-16)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package gatsby-source-filesystem
|
|
15
|
+
|
|
16
|
+
## [2.1.55](https://github.com/gatsbyjs/gatsby/compare/gatsby-source-filesystem@2.1.54...gatsby-source-filesystem@2.1.55) (2020-03-13)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package gatsby-source-filesystem
|
|
19
|
+
|
|
20
|
+
## [2.1.54](https://github.com/gatsbyjs/gatsby/compare/gatsby-source-filesystem@2.1.53...gatsby-source-filesystem@2.1.54) (2020-03-12)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package gatsby-source-filesystem
|
|
23
|
+
|
|
6
24
|
## [2.1.53](https://github.com/gatsbyjs/gatsby/compare/gatsby-source-filesystem@2.1.52...gatsby-source-filesystem@2.1.53) (2020-03-11)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package gatsby-source-filesystem
|
package/README.md
CHANGED
|
@@ -169,11 +169,8 @@ createRemoteFileNode({
|
|
|
169
169
|
// The id of the parent node (i.e. the node to which the new remote File node will be linked to.
|
|
170
170
|
parentNodeId,
|
|
171
171
|
|
|
172
|
-
// The redux store which is passed to all Node APIs.
|
|
173
|
-
store,
|
|
174
|
-
|
|
175
172
|
// Gatsby's cache which the helper uses to check if the file has been downloaded already. It's passed to all Node APIs.
|
|
176
|
-
|
|
173
|
+
getCache,
|
|
177
174
|
|
|
178
175
|
// The action used to create nodes
|
|
179
176
|
createNode,
|
|
@@ -204,8 +201,7 @@ const { createRemoteFileNode } = require(`gatsby-source-filesystem`)
|
|
|
204
201
|
|
|
205
202
|
exports.downloadMediaFiles = ({
|
|
206
203
|
nodes,
|
|
207
|
-
|
|
208
|
-
cache,
|
|
204
|
+
getCache,
|
|
209
205
|
createNode,
|
|
210
206
|
createNodeId,
|
|
211
207
|
_auth,
|
|
@@ -219,8 +215,7 @@ exports.downloadMediaFiles = ({
|
|
|
219
215
|
fileNode = await createRemoteFileNode({
|
|
220
216
|
url: node.source_url,
|
|
221
217
|
parentNodeId: node.id,
|
|
222
|
-
|
|
223
|
-
cache,
|
|
218
|
+
getCache,
|
|
224
219
|
createNode,
|
|
225
220
|
createNodeId,
|
|
226
221
|
auth: _auth,
|
|
@@ -250,8 +245,7 @@ createRemoteFileNode({
|
|
|
250
245
|
// The source url of the remote file
|
|
251
246
|
url: `https://example.com/a-file-without-an-extension`,
|
|
252
247
|
parentNodeId: node.id,
|
|
253
|
-
|
|
254
|
-
cache,
|
|
248
|
+
getCache,
|
|
255
249
|
createNode,
|
|
256
250
|
createNodeId,
|
|
257
251
|
// if necessary!
|
|
@@ -274,10 +268,7 @@ The following example is adapted from the source of [`gatsby-source-mysql`](http
|
|
|
274
268
|
// gatsby-node.js
|
|
275
269
|
const createMySqlNodes = require(`./create-nodes`)
|
|
276
270
|
|
|
277
|
-
exports.sourceNodes = async (
|
|
278
|
-
{ actions, createNodeId, store, cache },
|
|
279
|
-
config
|
|
280
|
-
) => {
|
|
271
|
+
exports.sourceNodes = async ({ actions, createNodeId, getCache }, config) => {
|
|
281
272
|
const { createNode } = actions
|
|
282
273
|
const { conn, queries } = config
|
|
283
274
|
const { db, results } = await query(conn, queries)
|
|
@@ -289,8 +280,7 @@ exports.sourceNodes = async (
|
|
|
289
280
|
createMySqlNodes(result, results, createNode, {
|
|
290
281
|
createNode,
|
|
291
282
|
createNodeId,
|
|
292
|
-
|
|
293
|
-
cache,
|
|
283
|
+
getCache,
|
|
294
284
|
})
|
|
295
285
|
)
|
|
296
286
|
db.end()
|
|
@@ -311,8 +301,7 @@ function attach(node, key, value, ctx) {
|
|
|
311
301
|
ctx.linkChildren.push(parentNodeId =>
|
|
312
302
|
createFileNodeFromBuffer({
|
|
313
303
|
buffer: value,
|
|
314
|
-
|
|
315
|
-
cache: ctx.cache,
|
|
304
|
+
getCache: ctx.getCache,
|
|
316
305
|
createNode: ctx.createNode,
|
|
317
306
|
createNodeId: ctx.createNodeId,
|
|
318
307
|
})
|
|
@@ -23,11 +23,6 @@ const cacheId = hash => `create-file-node-from-buffer-${hash}`;
|
|
|
23
23
|
* Type Definitions *
|
|
24
24
|
********************/
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {Redux}
|
|
28
|
-
* @see [Redux Docs]{@link https://redux.js.org/api-reference}
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
26
|
/**
|
|
32
27
|
* @typedef {GatsbyCache}
|
|
33
28
|
* @see gatsby/packages/gatsby/utils/cache.js
|
|
@@ -40,14 +35,11 @@ const cacheId = hash => `create-file-node-from-buffer-${hash}`;
|
|
|
40
35
|
*
|
|
41
36
|
* @param {Buffer} options.buffer
|
|
42
37
|
* @param {String} options.hash
|
|
43
|
-
* @param {Redux} options.store
|
|
44
38
|
* @param {GatsbyCache} options.cache
|
|
39
|
+
* @param {Function} options.getCache
|
|
45
40
|
* @param {Function} options.createNode
|
|
46
41
|
*/
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
const CACHE_DIR = `.cache`;
|
|
50
|
-
const FS_PLUGIN_DIR = `gatsby-source-filesystem`;
|
|
51
43
|
/**
|
|
52
44
|
* writeBuffer
|
|
53
45
|
* --
|
|
@@ -59,6 +51,7 @@ const FS_PLUGIN_DIR = `gatsby-source-filesystem`;
|
|
|
59
51
|
* @returns {Promise<void>}
|
|
60
52
|
*/
|
|
61
53
|
|
|
54
|
+
|
|
62
55
|
const writeBuffer = (filename, buffer) => new Promise((resolve, reject) => {
|
|
63
56
|
fs.writeFile(filename, buffer, err => err ? reject(err) : resolve());
|
|
64
57
|
});
|
|
@@ -75,7 +68,6 @@ const writeBuffer = (filename, buffer) => new Promise((resolve, reject) => {
|
|
|
75
68
|
async function processBufferNode({
|
|
76
69
|
buffer,
|
|
77
70
|
hash,
|
|
78
|
-
store,
|
|
79
71
|
cache,
|
|
80
72
|
createNode,
|
|
81
73
|
parentNodeId,
|
|
@@ -83,9 +75,7 @@ async function processBufferNode({
|
|
|
83
75
|
ext,
|
|
84
76
|
name
|
|
85
77
|
}) {
|
|
86
|
-
//
|
|
87
|
-
const pluginCacheDir = path.join(store.getState().program.directory, CACHE_DIR, FS_PLUGIN_DIR);
|
|
88
|
-
await fs.ensureDir(pluginCacheDir); // See if there's a cache file for this buffer's contents from
|
|
78
|
+
const pluginCacheDir = cache.directory; // See if there's a cache file for this buffer's contents from
|
|
89
79
|
// a previous run
|
|
90
80
|
|
|
91
81
|
let filename = await cache.get(cacheId(hash));
|
|
@@ -144,9 +134,9 @@ const processingCache = {};
|
|
|
144
134
|
module.exports = ({
|
|
145
135
|
buffer,
|
|
146
136
|
hash,
|
|
147
|
-
store,
|
|
148
137
|
cache,
|
|
149
138
|
createNode,
|
|
139
|
+
getCache,
|
|
150
140
|
parentNodeId = null,
|
|
151
141
|
createNodeId,
|
|
152
142
|
ext,
|
|
@@ -163,12 +153,13 @@ module.exports = ({
|
|
|
163
153
|
throw new Error(`createNode must be a function, was ${typeof createNode}`);
|
|
164
154
|
}
|
|
165
155
|
|
|
166
|
-
if (typeof
|
|
167
|
-
|
|
156
|
+
if (typeof getCache === `function`) {
|
|
157
|
+
// use cache of this plugin and not cache of function caller
|
|
158
|
+
cache = getCache(`gatsby-source-filesystem`);
|
|
168
159
|
}
|
|
169
160
|
|
|
170
161
|
if (typeof cache !== `object`) {
|
|
171
|
-
throw new Error(`cache must be the Gatsby cache, was ${typeof cache}`);
|
|
162
|
+
throw new Error(`Neither "cache" or "getCache" was passed. getCache must be function that return Gatsby cache, "cache" must be the Gatsby cache, was ${typeof cache}`);
|
|
172
163
|
}
|
|
173
164
|
|
|
174
165
|
if (!buffer) {
|
|
@@ -188,7 +179,6 @@ module.exports = ({
|
|
|
188
179
|
const bufferCachePromise = processBufferNode({
|
|
189
180
|
buffer,
|
|
190
181
|
hash,
|
|
191
|
-
store,
|
|
192
182
|
cache,
|
|
193
183
|
createNode,
|
|
194
184
|
parentNodeId,
|
|
@@ -43,11 +43,6 @@ let totalJobs = 0;
|
|
|
43
43
|
* Type Definitions *
|
|
44
44
|
********************/
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {Redux}
|
|
48
|
-
* @see [Redux Docs]{@link https://redux.js.org/api-reference}
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
46
|
/**
|
|
52
47
|
* @typedef {GatsbyCache}
|
|
53
48
|
* @see gatsby/packages/gatsby/utils/cache.js
|
|
@@ -71,15 +66,13 @@ let totalJobs = 0;
|
|
|
71
66
|
* @description Create Remote File Node Payload
|
|
72
67
|
*
|
|
73
68
|
* @param {String} options.url
|
|
74
|
-
* @param {Redux} options.store
|
|
75
69
|
* @param {GatsbyCache} options.cache
|
|
76
70
|
* @param {Function} options.createNode
|
|
71
|
+
* @param {Function} options.getCache
|
|
77
72
|
* @param {Auth} [options.auth]
|
|
78
73
|
* @param {Reporter} [options.reporter]
|
|
79
74
|
*/
|
|
80
75
|
|
|
81
|
-
const CACHE_DIR = `.cache`;
|
|
82
|
-
const FS_PLUGIN_DIR = `gatsby-source-filesystem`;
|
|
83
76
|
const STALL_RETRY_LIMIT = 3;
|
|
84
77
|
const STALL_TIMEOUT = 30000;
|
|
85
78
|
const CONNECTION_RETRY_LIMIT = 5;
|
|
@@ -220,7 +213,6 @@ const requestRemoteNode = (url, headers, tmpFilename, httpOpts, attempt = 1) =>
|
|
|
220
213
|
|
|
221
214
|
async function processRemoteNode({
|
|
222
215
|
url,
|
|
223
|
-
store,
|
|
224
216
|
cache,
|
|
225
217
|
createNode,
|
|
226
218
|
parentNodeId,
|
|
@@ -230,9 +222,7 @@ async function processRemoteNode({
|
|
|
230
222
|
ext,
|
|
231
223
|
name
|
|
232
224
|
}) {
|
|
233
|
-
|
|
234
|
-
const pluginCacheDir = path.join(store.getState().program.directory, CACHE_DIR, FS_PLUGIN_DIR);
|
|
235
|
-
await fs.ensureDir(pluginCacheDir); // See if there's response headers for this url
|
|
225
|
+
const pluginCacheDir = cache.directory; // See if there's response headers for this url
|
|
236
226
|
// from a previous request.
|
|
237
227
|
|
|
238
228
|
const cachedHeaders = await cache.get(cacheId(url));
|
|
@@ -346,9 +336,9 @@ const pushTask = task => new Promise((resolve, reject) => {
|
|
|
346
336
|
|
|
347
337
|
module.exports = ({
|
|
348
338
|
url,
|
|
349
|
-
store,
|
|
350
339
|
cache,
|
|
351
340
|
createNode,
|
|
341
|
+
getCache,
|
|
352
342
|
parentNodeId = null,
|
|
353
343
|
auth = {},
|
|
354
344
|
httpHeaders = {},
|
|
@@ -368,12 +358,13 @@ module.exports = ({
|
|
|
368
358
|
throw new Error(`createNode must be a function, was ${typeof createNode}`);
|
|
369
359
|
}
|
|
370
360
|
|
|
371
|
-
if (typeof
|
|
372
|
-
|
|
361
|
+
if (typeof getCache === `function`) {
|
|
362
|
+
// use cache of this plugin and not cache of function caller
|
|
363
|
+
cache = getCache(`gatsby-source-filesystem`);
|
|
373
364
|
}
|
|
374
365
|
|
|
375
366
|
if (typeof cache !== `object`) {
|
|
376
|
-
throw new Error(`cache must be the Gatsby cache, was ${typeof cache}`);
|
|
367
|
+
throw new Error(`Neither "cache" or "getCache" was passed. getCache must be function that return Gatsby cache, "cache" must be the Gatsby cache, was ${typeof cache}`);
|
|
377
368
|
} // Check if we already requested node for this remote file
|
|
378
369
|
// and return stored promise if we did.
|
|
379
370
|
|
|
@@ -395,7 +386,6 @@ module.exports = ({
|
|
|
395
386
|
bar.total = totalJobs;
|
|
396
387
|
const fileDownloadPromise = pushTask({
|
|
397
388
|
url,
|
|
398
|
-
store,
|
|
399
389
|
cache,
|
|
400
390
|
createNode,
|
|
401
391
|
parentNodeId,
|
package/extend-file-node.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = ({
|
|
|
24
24
|
description: `Copy file to static directory and return public url to it`,
|
|
25
25
|
resolve: (file, fieldArgs, context) => {
|
|
26
26
|
const details = getNodeAndSavePathDependency(file.id, context.path);
|
|
27
|
-
const fileName = `${file.
|
|
27
|
+
const fileName = `${file.internal.contentDigest}/${details.base}`;
|
|
28
28
|
const publicPath = path.join(process.cwd(), `public`, `static`, fileName);
|
|
29
29
|
|
|
30
30
|
if (!fs.existsSync(publicPath)) {
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-source-filesystem",
|
|
3
3
|
"description": "Gatsby plugin which parses files within a directory for further parsing by other plugins",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.57",
|
|
5
5
|
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/gatsbyjs/gatsby/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@babel/runtime": "^7.7
|
|
10
|
+
"@babel/runtime": "^7.8.7",
|
|
11
11
|
"better-queue": "^3.8.10",
|
|
12
12
|
"bluebird": "^3.7.2",
|
|
13
|
-
"chokidar": "3.3.
|
|
14
|
-
"file-type": "^12.4.
|
|
13
|
+
"chokidar": "3.3.1",
|
|
14
|
+
"file-type": "^12.4.2",
|
|
15
15
|
"fs-extra": "^8.1.0",
|
|
16
|
-
"gatsby-core-utils": "^1.0.
|
|
16
|
+
"gatsby-core-utils": "^1.0.34",
|
|
17
17
|
"got": "^8.3.2",
|
|
18
18
|
"md5-file": "^3.2.3",
|
|
19
19
|
"mime": "^2.4.4",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"progress": "^2.0.3",
|
|
22
22
|
"read-chunk": "^3.2.0",
|
|
23
23
|
"valid-url": "^1.0.9",
|
|
24
|
-
"xstate": "^4.
|
|
24
|
+
"xstate": "^4.8.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/cli": "^7.
|
|
28
|
-
"@babel/core": "^7.7
|
|
29
|
-
"babel-preset-gatsby-package": "^0.2.
|
|
27
|
+
"@babel/cli": "^7.8.4",
|
|
28
|
+
"@babel/core": "^7.8.7",
|
|
29
|
+
"babel-preset-gatsby-package": "^0.2.18",
|
|
30
30
|
"cross-env": "^5.2.1"
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem#readme",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=8.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d2d32d4f61619da5200f2dd15a034cd51f5e9932"
|
|
56
56
|
}
|