Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ci pipeline #36544

Merged
merged 7 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"
}
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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