Skip to content

Commit

Permalink
[1.0] Small fixes (gatsbyjs#1025)
Browse files Browse the repository at this point in the history
* Only show 'plugins have changed' message if the old plugins hash is found

* Restore original invalid key replacer

* Fix test snapshots

* Map graphql-skip-limit for Jest to get around it not resolving Lerna paths

* Remove resolve paths from snapshots as they vary depending on machine

* Fix moduleNameMapper

* Map gatsby-plugin-sharp

* try again

* Add suggested appveyor.yml file

* install windows build tools so leveldown installs
  • Loading branch information
KyleAMathews authored May 23, 2017
1 parent b5e095e commit 94fac7a
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 17 deletions.
22 changes: 22 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "6"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
- npm install --global windows-build-tools
# install modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

# Don't actually build.
build: off
4 changes: 2 additions & 2 deletions examples/client-only-paths/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-example-using-drupal",
"name": "gatsby-example-client-only-paths",
"private": true,
"description": "Gatsby example site using the Drupal source plugin",
"description": "Gatsby example site demoing client only paths",
"version": "1.0.0",
"author": "Kyle Mathews <[email protected]>",
"dependencies": {
Expand Down
12 changes: 11 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ module.exports = {
roots: pkgs,
modulePathIgnorePatterns: distDirs,
coveragePathIgnorePatterns: distDirs,
testPathIgnorePatterns: [`/dist/`, `/node_modules/`, `__tests__/fixtures`],
testPathIgnorePatterns: [
`/examples/`,
`/www/`,
`/dist/`,
`/node_modules/`,
`__tests__/fixtures`,
],
moduleNameMapper: {
"^graphql-skip-limit$": `<rootDir>/packages/graphql-skip-limit/src/index.js`,
"^gatsby-plugin-sharp$": `<rootDir>/packages/gatsby-plugin-sharp/src/index.js`,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ Array [
"pluginOptions": Object {
"plugins": Array [],
},
"resolve": "/Users/kylemathews/programs/gatsby/packages/gatsby/src/bootstrap/internal-plugins/component-page-creator",
"resolve": "",
"version": "1.0.0",
},
Object {
"name": "internal-data-bridge",
"pluginOptions": Object {
"plugins": Array [],
},
"resolve": "/Users/kylemathews/programs/gatsby/packages/gatsby/src/bootstrap/internal-plugins/internal-data-bridge",
"resolve": "",
"version": "1.0.0",
},
Object {
"name": "defaultSitePlugin",
"pluginOptions": Object {
"plugins": Array [],
},
"resolve": "/Users/kylemathews/programs/gatsby",
"resolve": "",
"version": "n/a",
},
]
Expand Down
9 changes: 8 additions & 1 deletion packages/gatsby/src/bootstrap/__tests__/load-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ const loadPlugins = require(`../load-plugins`)

describe(`Load plugins`, () => {
it(`load plugins for a site`, async () => {
const plugins = await loadPlugins({ plugins: [] })
let plugins = await loadPlugins({ plugins: [] })

// Delete the resolve path as that varies depending
// on platform so will cause snapshots to differ.
plugins = plugins.map(plugin => ({
...plugin,
resolve: ``,
}))

expect(plugins).toMatchSnapshot()
})
Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby/src/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ module.exports = async (program: any) => {
//
// Also if the hash isn't there, then delete things just in case something
// is weird.
if (!oldPluginsHash || pluginsHash !== oldPluginsHash) {
if (oldPluginsHash && pluginsHash !== oldPluginsHash) {
console.log(
`
One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's not any stale
data
`
)
}

if (!oldPluginsHash || pluginsHash !== oldPluginsHash) {
try {
await fs.remove(`${program.directory}/.cache`)
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ Object {
"date": Object {
"field": "date",
},
"frontmatter_blue": Object {
"frontmatter___blue": Object {
"field": "frontmatter.blue",
},
"frontmatter_circle": Object {
"frontmatter___circle": Object {
"field": "frontmatter.circle",
},
"frontmatter_date": Object {
"frontmatter___date": Object {
"field": "frontmatter.date",
},
"frontmatter_draft": Object {
"frontmatter___draft": Object {
"field": "frontmatter.draft",
},
"frontmatter_title": Object {
"frontmatter___title": Object {
"field": "frontmatter.title",
},
"hair": Object {
"field": "hair",
},
"key_with__unsupported_values": Object {
"key___with______unsupported___values": Object {
"field": "key-with..unsupported-values",
},
"name": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe(`GraphQL Input args`, () => {
],
})

expect(Object.keys(fields.foo.type.getFields())[2]).toEqual(`foo_moo`)
expect(Object.keys(fields.foo.type.getFields())[2]).toEqual(`foo___moo`)
})
it(`Removes specific root fields`, () => {
let fields = inferInputObjectStructureFromNodes({
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/create-key.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const regex = new RegExp(`[^a-zA-Z0-9_]`, `g`)

module.exports = key => key.replace(regex, `_`)
module.exports = key => key.replace(regex, `___`)
2 changes: 1 addition & 1 deletion packages/gatsby/src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = () =>
console.log(`deleting stale nodes`, staleNodes.length)
deleteNodes(staleNodes.map(n => n.id))
}
} else {
} else if (builtSchema) {
// If we've already built the schema before already, check if
// there's been any new node types added.
const newTypesBuilt = _.map(
Expand Down

0 comments on commit 94fac7a

Please sign in to comment.