Skip to content

Commit

Permalink
Merge branch 'master' into renovate/major-fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Aug 30, 2021
2 parents 8dc2980 + e547dc3 commit eff8790
Show file tree
Hide file tree
Showing 43 changed files with 188 additions and 63 deletions.
8 changes: 5 additions & 3 deletions docs/docs/tutorial/part-1/index.mdx
Expand Up @@ -115,16 +115,18 @@ But in this first site, you'll set things up manually to learn about how Gatsby'
· No (or I'll add it later)
```
7. When the prompt asks, **"Would you like to install additional features with other plugins?"** use the arrow and Space keys to select **"Build and host for free on Gatsby Cloud"**, then use the arrow and Enter keys to select **"Done"**.
7. When the prompt asks, **"Would you like to install additional features with other plugins?"** use the arrow and Enter keys to select **"Done"**.
This tells `gatsby new` to add a plugin called `gatsby-plugin-gatsby-cloud` to your site. Don't worry about the details of this just yet. You'll learn about plugins later on in the Tutorial. For now, all you need to know is that this plugin will help your site work better when you deploy it with Gatsby Cloud.
```shell
✔ Would you like to install additional features with other plugins?
· Done
```
8. The prompt will show you a summary of what `gatsby new` will do. It should look something like the output below.
```shell
Thanks! Here's what we'll now do:
🛠 Create a new Gatsby site in the folder my-first-gatsby-site
🔌 Install gatsby-plugin-gatsby-cloud
? Shall we do this? (Y/n) › Yes
Expand Down
1 change: 0 additions & 1 deletion docs/docs/tutorial/part-4/index.mdx
Expand Up @@ -618,7 +618,6 @@ module.exports = {
title: "My First Gatsby Site",
},
plugins: [
"gatsby-plugin-gatsby-cloud",
"gatsby-plugin-image",
"gatsby-plugin-sharp",
// highlight-start
Expand Down
3 changes: 3 additions & 0 deletions packages/babel-plugin-remove-graphql-queries/package.json
Expand Up @@ -28,5 +28,8 @@
},
"engines": {
"node": ">=12.13.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
1 change: 1 addition & 0 deletions packages/babel-preset-gatsby-package/package.json
Expand Up @@ -17,6 +17,7 @@
"@babel/preset-env": "^7.14.9",
"@babel/preset-flow": "^7.14.0",
"@babel/preset-react": "^7.14.0",
"@babel/runtime": "^7.14.8",
"babel-plugin-dynamic-import-node": "^2.3.3",
"core-js": "^3.10.0"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/create-gatsby/package.json
Expand Up @@ -42,5 +42,8 @@
"url": "https://github.com/gatsbyjs/gatsby.git",
"directory": "packages/create-gatsby"
},
"author": "Matt Kane <matt@gatsbyjs.com>"
"author": "Matt Kane <matt@gatsbyjs.com>",
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
3 changes: 0 additions & 3 deletions packages/create-gatsby/src/features.json
@@ -1,7 +1,4 @@
{
"gatsby-plugin-gatsby-cloud": {
"message": "Build and host for free on Gatsby Cloud"
},
"gatsby-plugin-image": {
"message": "Add responsive images",
"plugins": [
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-admin/package.json
Expand Up @@ -63,5 +63,8 @@
"build": "node ../gatsby/dist/bin/gatsby.js build --prefix-paths",
"postbuild": "ncp public ../gatsby/gatsby-admin-public",
"watch": "nodemon --watch src --ext js,ts,tsx,json --exec \"yarn run build\""
},
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
1 change: 1 addition & 0 deletions packages/gatsby-cli/package.json
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@babel/code-frame": "^7.14.0",
"@babel/runtime": "^7.14.8",
"@types/common-tags": "^1.8.0",
"better-opn": "^2.0.0",
"chalk": "^4.1.2",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-core-utils/package.json
Expand Up @@ -29,6 +29,7 @@
"dist/"
],
"dependencies": {
"@babel/runtime": "^7.14.8",
"ci-info": "2.0.0",
"configstore": "^5.0.1",
"file-type": "^16.5.3",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-design-tokens/package.json
Expand Up @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-design-tokens#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"hex2rgba": "^0.0.1"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-legacy-polyfills/package.json
Expand Up @@ -24,6 +24,7 @@
"watch:polyfills": "microbundle -f iife -i src/polyfills.js --no-sourcemap --external=none --watch"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"core-js-compat": "3.9.0"
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-benchmark-reporting/package.json
Expand Up @@ -19,6 +19,7 @@
"babel-preset-gatsby-package": "^1.14.0-next.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"fast-glob": "^3.2.7",
"node-fetch": "^2.6.1",
"uuid": "3.4.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-plugin-google-tagmanager/README.md
Expand Up @@ -39,6 +39,8 @@ plugins: [
routeChangeEventName: "YOUR_ROUTE_CHANGE_EVENT_NAME",
// Defaults to false
enableWebVitalsTracking: true,
// Defaults to https://www.googletagmanager.com
selfHostedOrigin: "YOUR_SELF_HOSTED_ORIGIN",
},
},
]
Expand Down
Expand Up @@ -12,6 +12,7 @@ describe(`pluginOptionsSchema`, () => {
dataLayerName: `YOUR_DATA_LAYER_NAME`,
routeChangeEventName: `YOUR_ROUTE_CHANGE_EVENT_NAME`,
enableWebVitalsTracking: true,
selfHostedOrigin: `YOUR_SELF_HOSTED_ORIGIN`,
})

expect(isValid).toEqual(true)
Expand Down
Expand Up @@ -180,5 +180,53 @@ describe(`gatsby-plugin-google-tagmanager`, () => {
expect(mocks.setHeadComponents.mock.calls[0].length).toBe(1)
expect(headConfig.key).toBe(`plugin-google-tagmanager`)
})

it(`should set selfHostedOrigin as googletagmanager.com by default`, () => {
const mocks = {
setHeadComponents: jest.fn(),
setPreBodyComponents: jest.fn(),
}
const pluginOptions = {
id: `123`,
includeInDevelopment: true,
}

onRenderBody(mocks, pluginOptions)
const [headConfig] = mocks.setHeadComponents.mock.calls[0][0]
const [preBodyConfig] = mocks.setPreBodyComponents.mock.calls[0][0]

// eslint-disable-next-line no-useless-escape
expect(headConfig.props.dangerouslySetInnerHTML.__html).toContain(
`https://www.googletagmanager.com/gtm.js`
)
expect(preBodyConfig.props.dangerouslySetInnerHTML.__html).toContain(
`https://www.googletagmanager.com/ns.html`
)
})

it(`should set selfHostedOrigin`, () => {
const selfHostedOrigin = `YOUR_SELF_HOSTED_ORIGIN`
const mocks = {
setHeadComponents: jest.fn(),
setPreBodyComponents: jest.fn(),
}
const pluginOptions = {
id: `123`,
includeInDevelopment: true,
selfHostedOrigin: selfHostedOrigin,
}

onRenderBody(mocks, pluginOptions)
const [headConfig] = mocks.setHeadComponents.mock.calls[0][0]
const [preBodyConfig] = mocks.setPreBodyComponents.mock.calls[0][0]

// eslint-disable-next-line no-useless-escape
expect(headConfig.props.dangerouslySetInnerHTML.__html).toContain(
`${selfHostedOrigin}/gtm.js`
)
expect(preBodyConfig.props.dangerouslySetInnerHTML.__html).toContain(
`${selfHostedOrigin}/ns.html`
)
})
})
})
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-google-tagmanager/src/gatsby-node.js
Expand Up @@ -41,4 +41,7 @@ exports.pluginOptionsSchema = ({ Joi }) =>
`Name of the event that is triggered on every Gatsby route change.`
),
enableWebVitalsTracking: Joi.boolean().default(false),
selfHostedOrigin: Joi.string()
.default(`https://www.googletagmanager.com`)
.description(`The origin where GTM is hosted.`),
})
29 changes: 23 additions & 6 deletions packages/gatsby-plugin-google-tagmanager/src/gatsby-ssr.js
@@ -1,15 +1,20 @@
import React from "react"
import { oneLine, stripIndent } from "common-tags"

const generateGTM = ({ id, environmentParamStr, dataLayerName }) => stripIndent`
const generateGTM = ({
id,
environmentParamStr,
dataLayerName,
selfHostedOrigin,
}) => stripIndent`
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl+'${environmentParamStr}';f.parentNode.insertBefore(j,f);
'${selfHostedOrigin}/gtm.js?id='+i+dl+'${environmentParamStr}';f.parentNode.insertBefore(j,f);
})(window,document,'script','${dataLayerName}', '${id}');`

const generateGTMIframe = ({ id, environmentParamStr }) =>
oneLine`<iframe src="https://www.googletagmanager.com/ns.html?id=${id}${environmentParamStr}" height="0" width="0" style="display: none; visibility: hidden" aria-hidden="true"></iframe>`
const generateGTMIframe = ({ id, environmentParamStr, selfHostedOrigin }) =>
oneLine`<iframe src="${selfHostedOrigin}/ns.html?id=${id}${environmentParamStr}" height="0" width="0" style="display: none; visibility: hidden" aria-hidden="true"></iframe>`

const generateDefaultDataLayer = (dataLayer, reporter, dataLayerName) => {
let result = `window.${dataLayerName} = window.${dataLayerName} || [];`
Expand Down Expand Up @@ -41,6 +46,7 @@ exports.onRenderBody = (
defaultDataLayer,
dataLayerName = `dataLayer`,
enableWebVitalsTracking = false,
selfHostedOrigin = `https://www.googletagmanager.com`,
}
) => {
if (process.env.NODE_ENV === `production` || includeInDevelopment) {
Expand All @@ -60,6 +66,8 @@ exports.onRenderBody = (
)
}

selfHostedOrigin = selfHostedOrigin.replace(/\/$/, ``)

const inlineScripts = []
if (enableWebVitalsTracking) {
// web-vitals/polyfill (necessary for non chromium browsers)
Expand All @@ -83,7 +91,12 @@ exports.onRenderBody = (
dangerouslySetInnerHTML={{
__html: oneLine`
${defaultDataLayerCode}
${generateGTM({ id, environmentParamStr, dataLayerName })}`,
${generateGTM({
id,
environmentParamStr,
dataLayerName,
selfHostedOrigin,
})}`,
}}
/>
)
Expand All @@ -94,7 +107,11 @@ exports.onRenderBody = (
<noscript
key="plugin-google-tagmanager"
dangerouslySetInnerHTML={{
__html: generateGTMIframe({ id, environmentParamStr }),
__html: generateGTMIframe({
id,
environmentParamStr,
selfHostedOrigin,
}),
}}
/>,
])
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-graphql-config/package.json
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"fs-extra": "^10.0.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-image/package.json
Expand Up @@ -74,6 +74,7 @@
"dependencies": {
"@babel/code-frame": "^7.14.0",
"@babel/parser": "^7.14.9",
"@babel/runtime": "^7.14.8",
"@babel/traverse": "^7.14.9",
"babel-jsx-utils": "^1.1.0",
"babel-plugin-remove-graphql-queries": "^3.14.0-next.0",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-mdx/package.json
Expand Up @@ -26,6 +26,7 @@
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/preset-env": "^7.14.9",
"@babel/preset-react": "^7.14.0",
"@babel/runtime": "^7.14.8",
"@babel/types": "^7.14.9",
"camelcase-css": "^2.0.1",
"change-case": "^3.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-netlify-cms/package.json
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"@soda/friendly-errors-webpack-plugin": "1.8.0",
"copy-webpack-plugin": "^7.0.0",
"html-webpack-plugin": "^5.3.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-no-sourcemaps/package.json
Expand Up @@ -25,5 +25,8 @@
},
"engines": {
"node": ">=12.13.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
1 change: 1 addition & 0 deletions packages/gatsby-plugin-page-creator/package.json
Expand Up @@ -24,6 +24,7 @@
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-page-creator#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@babel/traverse": "^7.14.9",
"@sindresorhus/slugify": "^1.1.2",
"chokidar": "^3.5.1",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-preact/package.json
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"@gatsbyjs/webpack-hot-middleware": "^2.25.2",
"@prefresh/babel-plugin": "^0.4.1",
"@prefresh/webpack": "^3.3.2"
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-preload-fonts/package.json
Expand Up @@ -11,6 +11,7 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"@babel/runtime": "^7.14.8",
"chalk": "^4.1.2",
"date-fns": "^2.21.1",
"fs-extra": "^10.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-schema-snapshot/package.json
Expand Up @@ -18,5 +18,8 @@
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-schema-snapshot#readme",
"peerDependencies": {
"gatsby": "^3.0.0-next.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
3 changes: 3 additions & 0 deletions packages/gatsby-plugin-styletron/package.json
Expand Up @@ -39,5 +39,8 @@
},
"engines": {
"node": ">=12.13.0"
},
"dependencies": {
"@babel/runtime": "^7.14.8"
}
}
1 change: 1 addition & 0 deletions packages/gatsby-plugin-subfont/package.json
Expand Up @@ -24,6 +24,7 @@
},
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.14.8",
"subfont": "^5.4.1"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-utils/package.json
Expand Up @@ -21,6 +21,7 @@
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-utils#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"joi": "^17.2.1"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-recipes/package.json
Expand Up @@ -12,6 +12,7 @@
"@babel/helper-plugin-utils": "^7.14.0",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@babel/runtime": "^7.14.8",
"@babel/standalone": "^7.14.9",
"@babel/template": "^7.14.0",
"@babel/types": "^7.14.9",
Expand Down
Expand Up @@ -99,7 +99,7 @@ describe(`contentful extend node type`, () => {
test(`keeps image format`, async () => {
const result = await getBase64Image(imageProps)
expect(result).toMatch(
`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAMAAAC5ge+kAAAAllBMVEUAAABHl745rOE7tOc7tOcqMDkqMDkqMDkqMDnfzG9Pm7o7tOc7tOcqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDn4wF/eXWDtXGjtXGgqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDnbVmDpWGbtXGjtXGh1tTylAAAAMnRSTlMATd3gVSUjTCDgHRIscF+MeqB8qpqbk4ienYAxr+AeEipyZI9/aW+No4WJeWuuTdzgVnu3oiUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQflCAUMNjFcK/NJAAAAMklEQVQI12NkBII/DCDA+htIsDEy/mBj4WDEBCwiyLwnIpyMjL/ZWASB7PMMMPAZTAIALlUHKTqI1/MAAAAASUVORK5CYII=`
`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAMAAAC5ge+kAAAAllBMVEUAAABHl745rOE7tOc7tOcqMDkqMDkqMDkqMDnfzG9Pm7o7tOc7tOcqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDn4wF/eXWDtXGjtXGgqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDnbVmDpWGbtXGjtXGh1tTylAAAAMnRSTlMATd3gVSUjTCDgHRIscF+MeqB8qpqbk4ienYAxr+AeEipyZI9/aW+No4WJeWuuTdzgVnu3oiUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQflCBQANxNx70pyAAAAMklEQVQI12NkBII/DCDA+htIsDEy/mBj4WDEBCwiyLwnIpyMjL/ZWASB7PMMMPAZTAIALlUHKTqI1/MAAAAASUVORK5CYII=`
)
})
test(`uses given image format`, async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-source-shopify/package.json
Expand Up @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-shopify#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"gatsby-core-utils": "^2.14.0-next.0",
"gatsby-source-filesystem": "^3.14.0-next.0",
"node-fetch": "^2.6.1",
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-source-wikipedia/package.json
Expand Up @@ -29,6 +29,7 @@
},
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.14.8",
"bluebird": "^3.7.2",
"node-fetch": "^2.6.1",
"query-string": "^6.13.3"
Expand Down

0 comments on commit eff8790

Please sign in to comment.