Skip to content

Commit

Permalink
fix: ci pipeline (#36544)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
  • Loading branch information
wardpeet and pieh committed Sep 6, 2022
1 parent 7fe8e51 commit 1125e58
Show file tree
Hide file tree
Showing 27 changed files with 194 additions and 366 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Expand Up @@ -169,7 +169,7 @@ commands:
command: "REACT_VERSION=<< parameters.react_version >> TEST_PATH=<< parameters.test_path >> node ./scripts/upgrade-react"
- run:
name: Install gatsby-dev@next
command: yarn global add gatsby-dev-cli@next
command: yarn global add gatsby-dev-cli@next --ignore-engines
- run:
name: Run tests (using defaults)
command: ./scripts/e2e-test.sh "<< parameters.test_path >>" "<< parameters.test_command >>"
Expand Down Expand Up @@ -280,7 +280,9 @@ jobs:
test_path: integration-tests/gatsby-pipeline

integration_tests_gatsby_cli:
executor: node
executor:
name: node
image: "14.16.0"
steps:
- e2e-test:
test_path: integration-tests/gatsby-cli
Expand Down
6 changes: 5 additions & 1 deletion e2e-tests/contentful/package.json
Expand Up @@ -46,5 +46,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
}
4 changes: 4 additions & 0 deletions e2e-tests/development-runtime/package.json
Expand Up @@ -75,5 +75,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions e2e-tests/mdx/package.json
Expand Up @@ -46,5 +46,9 @@
"is-ci": "^2.0.0",
"prettier": "2.0.4",
"start-server-and-test": "^1.7.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions e2e-tests/path-prefix/package.json
Expand Up @@ -51,5 +51,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
8 changes: 6 additions & 2 deletions e2e-tests/production-runtime/package.json
Expand Up @@ -28,7 +28,7 @@
"license": "MIT",
"scripts": {
"build": "cross-env GATSBY_PREFIXED_FROM_COMMAND_LINE=YES FROM_COMMAND_LINE=YES CYPRESS_SUPPORT=y NODE_OPTIONS='--require ./polyfill-node-protocol-imports.js' gatsby build",
"build:offline": "cross-env GATSBY_PREFIXED_FROM_COMMAND_LINE=YES FROM_COMMAND_LINE=YES TEST_PLUGIN_OFFLINE=y CYPRESS_SUPPORT=y gatsby build",
"build:offline": "cross-env GATSBY_PREFIXED_FROM_COMMAND_LINE=YES FROM_COMMAND_LINE=YES TEST_PLUGIN_OFFLINE=y CYPRESS_SUPPORT=y NODE_OPTIONS='--require ./polyfill-node-protocol-imports.js' gatsby build",
"develop": "cross-env CYPRESS_SUPPORT=y gatsby develop",
"format": "prettier --write '**/*.js' --ignore-path .gitignore",
"serve": "gatsby serve",
Expand Down Expand Up @@ -65,5 +65,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
}
6 changes: 5 additions & 1 deletion e2e-tests/themes/package.json
Expand Up @@ -4,5 +4,9 @@
"gatsby-theme-about",
"production-runtime",
"development-runtime"
]
],
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions e2e-tests/trailing-slash/package.json
Expand Up @@ -38,5 +38,9 @@
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
"start-server-and-test": "^1.14.0"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions e2e-tests/visual-regression/package.json
Expand Up @@ -41,5 +41,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/artifacts/package.json
Expand Up @@ -20,5 +20,9 @@
"devDependencies": {
"fs-extra": "^10.1.0",
"jest": "^27.2.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/cache-resilience/package.json
Expand Up @@ -26,5 +26,9 @@
"lodash": "^4.17.20",
"slash": "^3.0.0",
"snapshot-diff": "^0.6.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/functions/package.json
Expand Up @@ -32,5 +32,9 @@
"gatsby-plugin-gatsby-cloud": "next",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/gatsby-cli/package.json
Expand Up @@ -23,5 +23,9 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/gatsby-pipeline/package.json
Expand Up @@ -41,5 +41,9 @@
},
"engines": {
"node": ">=12.13.0"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/gatsby-source-wordpress/package.json
Expand Up @@ -27,5 +27,9 @@
"jest": "^27.2.1",
"node-fetch": "^2.6.1",
"rimraf": "^3.0.2"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/head-function-export/package.json
Expand Up @@ -26,5 +26,9 @@
"gatsby": "next",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
6 changes: 5 additions & 1 deletion integration-tests/images/package.json
Expand Up @@ -23,5 +23,9 @@
"babel-jest": "^27.2.1",
"jest": "^27.2.1",
"pixelmatch": "^5.2.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
}
6 changes: 5 additions & 1 deletion integration-tests/long-term-caching/package.json
Expand Up @@ -17,5 +17,9 @@
"devDependencies": {
"babel-plugin-dynamic-import-node-sync": "^2.0.1",
"jest": "^27.2.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
}
4 changes: 4 additions & 0 deletions integration-tests/node-manifest/package.json
Expand Up @@ -20,5 +20,9 @@
"jest": "^27.2.1",
"rimraf": "^3.0.2",
"urling": "^1.0.7"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
4 changes: 4 additions & 0 deletions integration-tests/ssr/package.json
Expand Up @@ -45,5 +45,9 @@
"test": "cross-env GATSBY_EXPERIMENTAL_DEV_SSR=true npm-run-all -s build capture-prod-dsg-and-ssr start-dev-server",
"test-output": "node test-output.js",
"test:jest": "jest --runInBand"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
6 changes: 5 additions & 1 deletion integration-tests/structured-logging/package.json
Expand Up @@ -23,5 +23,9 @@
"joi": "^17.4.0",
"lodash": "^4.17.20",
"node-fetch": "^2.6.1"
},
"//": "we need to add fixed version of @types/responsible because it's 14.16+ and the package is configured wrongly",
"resolutions": {
"responselike": "^2.0.0"
}
}
}
Expand Up @@ -56,7 +56,12 @@ export default function ({
path.parent.id.elements.reduce(
(acc: Array<BabelTypes.ObjectProperty>, element, i) => {
if (element) {
acc.push(t.objectProperty(t.numericLiteral(i), element))
acc.push(
t.objectProperty(
t.numericLiteral(i),
element as BabelTypes.Identifier
)
)
}
return acc
},
Expand Down
72 changes: 49 additions & 23 deletions packages/gatsby-plugin-mdx/src/remark-infer-toc-meta.ts
Expand Up @@ -10,7 +10,16 @@ import type { IMdxVFile } from "./types"
import type { Options, toc } from "mdast-util-toc"
import type { visit } from "unist-util-visit"

type TocNodeType = BlockContent | DefinitionContent | ListItem
interface ITocNodeEntry {
url?: string
title?: string
}

type TocNodeType =
| ITocNodeEntry
| {
items: Array<TocNodeType>
}

interface IRemarkTocOptions {
maxDepth?: Options["maxDepth"]
Expand All @@ -25,33 +34,50 @@ const remarkInferTocMeta: Plugin<[IRemarkTocOptions]> = options => {
}

const processToC = (
node: TocNodeType,
current: Partial<TocNodeType>
): Partial<TocNodeType> => {
node: BlockContent | DefinitionContent | ListItem | null,
current: TocNodeType
): TocNodeType => {
if (!node) {
return {}
} else if (node.type === `paragraph`) {
visit(node, item => {
if (item.type === `link`) {
current.url = item.url
}
if (item.type === `text`) {
current.title = item.value
}
})
return current
} else if (Array.isArray(node.children)) {
if (node.type === `list`) {
current.items = node.children.map(i => processToC(i, {}))
}

switch (node.type) {
case `paragraph`: {
const typedCurrent = current as ITocNodeEntry

visit(node, item => {
if (item.type === `link`) {
typedCurrent.url = item.url
}
if (item.type === `text`) {
typedCurrent.title = item.value
}
})

return current
} else if (node.type === `listItem`) {
const heading = processToC(node.children[0], {})
if (node.children.length > 1) {
processToC(node.children[1], heading)
}

case `list`: {
const typedCurrent = current as { items: Array<TocNodeType> }

typedCurrent.items = node.children.map(item => processToC(item, {}))

return typedCurrent
}

case `listItem`: {
if (node.children.length) {
const heading = processToC(node.children[0], {})

if (node.children.length > 1) {
processToC(node.children[1], heading)
}

return heading
}
return heading
}
}

return {}
}

Expand All @@ -62,7 +88,7 @@ const remarkInferTocMeta: Plugin<[IRemarkTocOptions]> = options => {
mdxFile.data.meta = {}
}

mdxFile.data.meta.toc = processToC(generatedToC.map as TocNodeType, {})
mdxFile.data.meta.toc = processToC(generatedToC.map, {})
}
}

Expand Down
18 changes: 10 additions & 8 deletions packages/gatsby-plugin-mdx/src/remark-mdx-html-plugin.ts
@@ -1,9 +1,10 @@
import type { Node } from "unist-util-visit"
import type { Definition } from "mdast"
import toHast from "mdast-util-to-hast"

import { cachedImport } from "./cache-helpers"

import type { Node } from "unist-util-visit"
import type { Definition, Literal } from "mdast"
import type { MdxJsxAttribute, MdxJsxFlowElement } from "mdast-util-mdx"

// This plugin replaces html nodes with JSX divs that render given HTML via dangerouslySetInnerHTML
// We have to find out if this is really a good idea, but its processing footprint is very low
// compared to other solutions that would traverse the given HTML.
Expand Down Expand Up @@ -33,9 +34,10 @@ export const remarkMdxHtmlPlugin = () =>
return
}

node.type = `mdxJsxFlowElement`
node.name = `div`
node.attributes = [
const typedNode = node as MdxJsxFlowElement
typedNode.type = `mdxJsxFlowElement`
typedNode.name = `div`
typedNode.attributes = [
{
type: `mdxJsxAttribute`,
name: `dangerouslySetInnerHTML`,
Expand All @@ -61,7 +63,7 @@ export const remarkMdxHtmlPlugin = () =>
},
value: {
type: `Literal`,
value: node.value,
value: (node as Literal).value,
},
kind: `init`,
},
Expand All @@ -73,7 +75,7 @@ export const remarkMdxHtmlPlugin = () =>
},
},
},
},
} as MdxJsxAttribute,
]
})

Expand Down

0 comments on commit 1125e58

Please sign in to comment.