Skip to content

Commit

Permalink
chore(*): Use new createContentDigest helper (gatsbyjs#8992)
Browse files Browse the repository at this point in the history
* add createContentDigest helper for gatsby-transformer-remark

* add createContentDigest helper for gatsby-source-filesystem

* Added createContentDigest in test

* Added missing createContentDigest param

* update createContentDigest helper tests for gatsby-transformer-remark

* update createContentDigest helper tests for gatsby-source-filesystem

* update createContentDigest helper tests for gatsby-transformer-csv

* add createContentDigest helper for internal-plugins/internal-data-bridge

* add createContentDigest helper for gatsby-source-hacker-news

* add createContentDigest helper for gatsby-transformer-excel

* add createContentDigest helper for gatsby-source-mongodb

* add createContentDigest helper for gatsby-source-lever

* add createContentDigest helper for internal-plugins/query-runner

* Updated gatsby dep

gatsby-source-hacker-news
gatsby-source-lever
gatsby-source-mongodb
gatsby-transformer-excel

* add createContentDigest helper for gatsby-source-contentful

* add createContentDigest helper for gatsby-transformer-hjson

* add createContentDigest helper for gatsby-transformer-sqip

* add createContentDigest helper for gatsby-source-npm-package-search

* add createContentDigest helper for gatsby-transformer-toml

* update createContentDigest helper for gatsby-source-mongodb

remove direct import

* update createContentDigest helper for gatsby-source-lever

could not find import for createGraphQLNode, added helper anyways

* update createContentDigest helper for internal-plugins/query-runner

modify src/bootstrap (imports writeRedirects)

* update createContentDigest helper for gatsby-source-npm-package-search

* update createContentDigest helper for gatsby-source-contentful*

TODO add ccd (createContentDigest) in cache-image

* update createContentDigest helper for gatsby-transformer-sqip*

TODO add ccd (createContentDigest) in generate-sqip

* update createContentDigest helper for gatsby-transformer-sqip

removed ccd from tests

* use caret version selector

* no need to import it - it's passed to `sourceNodes`

* merge again

* update to pass tests

* update hash to use createContentDigest

* move createContentDigest to import

* move createContentDigest to import for gatsby-source-contentful

* remove createContentDigest import in gatsby-source-filesystem test

* rereplace createContentDigest with crypto in gatsby-source-filesystem

* revert createContentDigest to crypto for create-file-node in gatsby-source-filesystem

* revert createContentDigest for gatsby-plugin-sharp

* update crypto misspell

* revert gatsby-remark-contentful and gatsby-source-contentful

* fix old code

* fix old code v2

* update gatsby pkg

* revert gatsby-transformer-remark

* add export for gatsby utils

* update gatsby-source-filesystem

* revert gatsby-source-graphql

* revert gatsby-source-graphql

* revert gatsby-source-hacker-news

* revert gatsby-source-lever

* revert gatsby-source-medium

* revert gatsby-source-mongodb

* revert gatsby-source-mongodb mapping

* revert gatsby-source-npm-package-search

* revert gatsby-source-wikipedia

* revert gatsby-source-wordpress

* revert gatsby-transformer-csv

* revert gatsby-transformer-documentationjs

* revert gatsby-transformer-excel

* revert gatsby-transformer-hjson

* revert other packages

* revert some pkgs

* add gatsby

* move gatsby to peerdeps
  • Loading branch information
samscha authored and KyleAMathews committed Apr 23, 2019
1 parent e435fc3 commit 27555f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"license": "MIT",
"peerDependencies": {
"gatsby": "^2.0.0"
"gatsby": "^2.0.15"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem",
"scripts": {
Expand Down
12 changes: 5 additions & 7 deletions src/create-file-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mime = require(`mime`)
const prettyBytes = require(`pretty-bytes`)

const md5File = require(`bluebird`).promisify(require(`md5-file`))
const crypto = require(`crypto`)
const { createContentDigest } = require(`gatsby/utils`)

exports.createFileNode = async (
pathToFile,
Expand All @@ -27,12 +27,10 @@ exports.createFileNode = async (
const stats = await fs.stat(slashedFile.absolutePath)
let internal
if (stats.isDirectory()) {
const contentDigest = crypto
.createHash(`md5`)
.update(
JSON.stringify({ stats: stats, absolutePath: slashedFile.absolutePath })
)
.digest(`hex`)
const contentDigest = createContentDigest({
stats: stats,
absolutePath: slashedFile.absolutePath,
})
internal = {
contentDigest,
type: `Directory`,
Expand Down
22 changes: 2 additions & 20 deletions src/create-remote-file-node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require(`fs-extra`)
const got = require(`got`)
const crypto = require(`crypto`)
const { createContentDigest } = require(`gatsby/utils`)
const path = require(`path`)
const { isWebUri } = require(`valid-url`)
const Queue = require(`better-queue`)
Expand Down Expand Up @@ -53,24 +53,6 @@ const bar = new ProgressBar(
* @param {Auth} [options.auth]
*/

/*********
* utils *
*********/

/**
* createHash
* --
*
* Create an md5 hash of the given str
* @param {Stringq} str
* @return {String}
*/
const createHash = str =>
crypto
.createHash(`md5`)
.update(str)
.digest(`hex`)

const CACHE_DIR = `.cache`
const FS_PLUGIN_DIR = `gatsby-source-filesystem`

Expand Down Expand Up @@ -215,7 +197,7 @@ async function processRemoteNode({
}

// Create the temp and permanent file names for the url.
const digest = createHash(url)
const digest = createContentDigest(url)
if (!name) {
name = getRemoteFileName(url)
}
Expand Down

0 comments on commit 27555f4

Please sign in to comment.