Skip to content

Commit

Permalink
fix(gatsby-recipes): Allow .filter(Boolean) and && in gatsby-conf…
Browse files Browse the repository at this point in the history
…ig.js (#27041)

Co-authored-by: Peter van der Zee <209817+pvdz@users.noreply.github.com>
  • Loading branch information
LekoArts and pvdz committed Sep 29, 2020
1 parent 48fb7d1 commit ecd69c8
Show file tree
Hide file tree
Showing 6 changed files with 589 additions and 46 deletions.
21 changes: 18 additions & 3 deletions packages/gatsby-admin/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,32 @@ function Index(): JSX.Element {
`,
})

let errMsg: string | false = false

if (error) {
const errMsg =
errMsg =
(error.networkError && error.networkError.message) ||
(Array.isArray(error.graphQLErrors) &&
error.graphQLErrors.map(e => e.message).join(` | `))

return <p>Error: {errMsg}</p>
}

return (
<Fragment>
{error && (
<Fragment>
<Spacer size={9} />
<div
sx={{
p: 4,
backgroundColor: `red.10`,
border: (t: any): string => `1px solid ${t.colors.red[`80`]}`,
borderRadius: 2,
}}
>
<strong>Error:</strong> {errMsg}
</div>
</Fragment>
)}
<Spacer size={9} />
<Flex gap={13}>
<Flex flexDirection="column" gap={13} flex="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,333 @@ Object {
}
`;

exports[`gatsby-plugin resource e2e plugin resource test with edge-casy starter: GatsbyPlugin create 1`] = `
Object {
"_message": "Installed gatsby-source-filesystem in gatsby-config.js",
"description": Any<String>,
"id": "gatsby-source-filesystem",
"name": "gatsby-source-filesystem",
"options": undefined,
"readme": Any<String>,
"shadowableFiles": Any<Array>,
"shadowedFiles": Array [],
}
`;

exports[`gatsby-plugin resource e2e plugin resource test with edge-casy starter: GatsbyPlugin create plan 1`] = `
Object {
"currentState": "require(\`dotenv\`).config({
path: \`.env\`,
});

const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE;

module.exports = {
siteMetadata: {
siteTitleAlt: \`Minimal Blog - Gatsby Theme\`,
},
plugins: [
{
resolve: \`@lekoarts/gatsby-theme-minimal-blog\`,
options: {
navigation: [
{
title: \`Blog\`,
slug: \`/blog\`,
},
{
title: \`About\`,
slug: \`/about\`,
},
],
externalLinks: [
{
name: \`Twitter\`,
url: \`https://twitter.com/lekoarts_de\`,
},
{
name: \`Instagram\`,
url: \`https://www.instagram.com/lekoarts.de/\`,
},
],
},
},
{
resolve: \`gatsby-plugin-google-analytics\`,
options: {
trackingId: process.env.GOOGLE_ANALYTICS_ID,
},
},
\`gatsby-plugin-sitemap\`,
\`gatsby-plugin-offline\`,
\`gatsby-plugin-netlify\`,
shouldAnalyseBundle && {
resolve: \`gatsby-plugin-webpack-bundle-analyser-v2\`,
options: {
analyzerMode: \`static\`,
reportFilename: \`_bundle.html\`,
openAnalyzer: false,
},
},
].filter(Boolean),
};
",
"dependsOn": Array [
Object {
"name": "gatsby-source-filesystem",
"resourceName": "NPMPackage",
},
],
"describe": "Install gatsby-source-filesystem in gatsby-config.js",
"diff": "- Original - 1
+ Modified + 5

@@ -3,7 +3,6 @@
});

const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE;
-
module.exports = {
siteMetadata: {
siteTitleAlt: \`Minimal Blog - Gatsby Theme\`,
@@ -50,6 +49,11 @@
reportFilename: \`_bundle.html\`,
openAnalyzer: false,
},
+ },
+ {
+ resolve: \\"gatsby-source-filesystem\\",
+ options: undefined,
+ __key: \\"gatsby-source-filesystem\\",
},
].filter(Boolean),
};",
"id": "gatsby-source-filesystem",
"name": "gatsby-source-filesystem",
"newState": "require(\`dotenv\`).config({
path: \`.env\`,
});

const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE;
module.exports = {
siteMetadata: {
siteTitleAlt: \`Minimal Blog - Gatsby Theme\`,
},
plugins: [
{
resolve: \`@lekoarts/gatsby-theme-minimal-blog\`,
options: {
navigation: [
{
title: \`Blog\`,
slug: \`/blog\`,
},
{
title: \`About\`,
slug: \`/about\`,
},
],
externalLinks: [
{
name: \`Twitter\`,
url: \`https://twitter.com/lekoarts_de\`,
},
{
name: \`Instagram\`,
url: \`https://www.instagram.com/lekoarts.de/\`,
},
],
},
},
{
resolve: \`gatsby-plugin-google-analytics\`,
options: {
trackingId: process.env.GOOGLE_ANALYTICS_ID,
},
},
\`gatsby-plugin-sitemap\`,
\`gatsby-plugin-offline\`,
\`gatsby-plugin-netlify\`,
shouldAnalyseBundle && {
resolve: \`gatsby-plugin-webpack-bundle-analyser-v2\`,
options: {
analyzerMode: \`static\`,
reportFilename: \`_bundle.html\`,
openAnalyzer: false,
},
},
{
resolve: \\"gatsby-source-filesystem\\",
options: undefined,
__key: \\"gatsby-source-filesystem\\",
},
].filter(Boolean),
};
",
}
`;

exports[`gatsby-plugin resource e2e plugin resource test with edge-casy starter: GatsbyPlugin destroy 1`] = `undefined`;

exports[`gatsby-plugin resource e2e plugin resource test with edge-casy starter: GatsbyPlugin update 1`] = `
Object {
"_message": "Installed gatsby-source-filesystem in gatsby-config.js",
"description": Any<String>,
"id": "gatsby-source-filesystem",
"name": "gatsby-source-filesystem",
"options": undefined,
"readme": Any<String>,
"shadowableFiles": Any<Array>,
"shadowedFiles": Array [],
}
`;

exports[`gatsby-plugin resource e2e plugin resource test with edge-casy starter: GatsbyPlugin update plan 1`] = `
Object {
"currentState": "require(\`dotenv\`).config({
path: \`.env\`,
});

const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE;
module.exports = {
siteMetadata: {
siteTitleAlt: \`Minimal Blog - Gatsby Theme\`,
},
plugins: [
{
resolve: \`@lekoarts/gatsby-theme-minimal-blog\`,
options: {
navigation: [
{
title: \`Blog\`,
slug: \`/blog\`,
},
{
title: \`About\`,
slug: \`/about\`,
},
],
externalLinks: [
{
name: \`Twitter\`,
url: \`https://twitter.com/lekoarts_de\`,
},
{
name: \`Instagram\`,
url: \`https://www.instagram.com/lekoarts.de/\`,
},
],
},
},
{
resolve: \`gatsby-plugin-google-analytics\`,
options: {
trackingId: process.env.GOOGLE_ANALYTICS_ID,
},
},
\`gatsby-plugin-sitemap\`,
\`gatsby-plugin-offline\`,
\`gatsby-plugin-netlify\`,
shouldAnalyseBundle && {
resolve: \`gatsby-plugin-webpack-bundle-analyser-v2\`,
options: {
analyzerMode: \`static\`,
reportFilename: \`_bundle.html\`,
openAnalyzer: false,
},
},
\\"gatsby-source-filesystem\\",
].filter(Boolean),
};
",
"dependsOn": Array [
Object {
"name": "gatsby-source-filesystem",
"resourceName": "NPMPackage",
},
],
"describe": "Install gatsby-source-filesystem in gatsby-config.js",
"diff": "- Original - 0
+ Modified + 5

@@ -51,6 +51,11 @@
},
},
\\"gatsby-source-filesystem\\",
+ {
+ resolve: \\"gatsby-source-filesystem\\",
+ options: undefined,
+ __key: \\"gatsby-source-filesystem\\",
+ },
].filter(Boolean),
};
",
"id": "gatsby-source-filesystem",
"name": "gatsby-source-filesystem",
"newState": "require(\`dotenv\`).config({
path: \`.env\`,
});

const shouldAnalyseBundle = process.env.ANALYSE_BUNDLE;
module.exports = {
siteMetadata: {
siteTitleAlt: \`Minimal Blog - Gatsby Theme\`,
},
plugins: [
{
resolve: \`@lekoarts/gatsby-theme-minimal-blog\`,
options: {
navigation: [
{
title: \`Blog\`,
slug: \`/blog\`,
},
{
title: \`About\`,
slug: \`/about\`,
},
],
externalLinks: [
{
name: \`Twitter\`,
url: \`https://twitter.com/lekoarts_de\`,
},
{
name: \`Instagram\`,
url: \`https://www.instagram.com/lekoarts.de/\`,
},
],
},
},
{
resolve: \`gatsby-plugin-google-analytics\`,
options: {
trackingId: process.env.GOOGLE_ANALYTICS_ID,
},
},
\`gatsby-plugin-sitemap\`,
\`gatsby-plugin-offline\`,
\`gatsby-plugin-netlify\`,
shouldAnalyseBundle && {
resolve: \`gatsby-plugin-webpack-bundle-analyser-v2\`,
options: {
analyzerMode: \`static\`,
reportFilename: \`_bundle.html\`,
openAnalyzer: false,
},
},
\\"gatsby-source-filesystem\\",
{
resolve: \\"gatsby-source-filesystem\\",
options: undefined,
__key: \\"gatsby-source-filesystem\\",
},
].filter(Boolean),
};
",
}
`;

exports[`gatsby-plugin resource e2e plugin resource test with hello world starter: GatsbyPlugin create 1`] = `
Object {
"_message": "Installed gatsby-source-filesystem in gatsby-config.js",
Expand Down

0 comments on commit ecd69c8

Please sign in to comment.