diff --git a/jest.config.mjs b/jest.config.mjs index 479ebd5948b3..5c241b301ed8 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -69,6 +69,7 @@ export default { 'jest-serializer-react-helmet-async', ], snapshotFormat: { + escapeString: false, printBasicPrototype: false, }, }; diff --git a/jest/snapshotPathNormalizer.ts b/jest/snapshotPathNormalizer.ts index d8b2d7a14e45..084abc14a6cc 100644 --- a/jest/snapshotPathNormalizer.ts +++ b/jest/snapshotPathNormalizer.ts @@ -10,6 +10,7 @@ import _ from 'lodash'; import {escapePath} from '@docusaurus/utils'; +import stripAnsi from 'strip-ansi'; import {version} from '@docusaurus/core/package.json'; import os from 'os'; import path from 'path'; @@ -76,6 +77,7 @@ function normalizePaths(value: T): T { const homeRealRelativeToTemp = path.relative(tempDir, homeDirReal); const runner: ((val: string) => string)[] = [ + (val) => (val.includes('keepAnsi') ? val : stripAnsi(val)), // Replace process.cwd with (val) => val.split(cwdReal).join(''), (val) => val.split(cwd).join(''), diff --git a/package.json b/package.json index bc377a1193fb..f0a14ca0c702 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "remark-parse": "^8.0.2", "rimraf": "^3.0.2", "sharp": "^0.30.3", + "strip-ansi": "^6.0.1", "stylelint": "^14.6.1", "stylelint-config-prettier": "^9.0.3", "stylelint-config-standard": "^25.0.0", diff --git a/packages/docusaurus-logger/src/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-logger/src/__tests__/__snapshots__/index.test.ts.snap index cf55c3083aea..5980bd3de212 100644 --- a/packages/docusaurus-logger/src/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-logger/src/__tests__/__snapshots__/index.test.ts.snap @@ -3,16 +3,16 @@ exports[`error prints objects 1`] = ` [ [ - "[ERROR] {\\"a\\":1}", + "[ERROR] {"a":1}", ], [ - "[ERROR] undefined", + "[ERROR] undefined", ], [ - "[ERROR] 1,2,3", + "[ERROR] 1,2,3", ], [ - "[ERROR] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", + "[ERROR] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", ], ] `; @@ -20,16 +20,16 @@ exports[`error prints objects 1`] = ` exports[`info prints objects 1`] = ` [ [ - "[INFO] {\\"a\\":1}", + "[INFO] {"a":1}", ], [ - "[INFO] undefined", + "[INFO] undefined", ], [ - "[INFO] 1,2,3", + "[INFO] 1,2,3", ], [ - "[INFO] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", + "[INFO] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", ], ] `; @@ -37,16 +37,16 @@ exports[`info prints objects 1`] = ` exports[`success prints objects 1`] = ` [ [ - "[SUCCESS] {\\"a\\":1}", + "[SUCCESS] {"a":1}", ], [ - "[SUCCESS] undefined", + "[SUCCESS] undefined", ], [ - "[SUCCESS] 1,2,3", + "[SUCCESS] 1,2,3", ], [ - "[SUCCESS] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", + "[SUCCESS] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", ], ] `; @@ -54,16 +54,16 @@ exports[`success prints objects 1`] = ` exports[`warn prints objects 1`] = ` [ [ - "[WARNING] {\\"a\\":1}", + "[WARNING] {"a":1}", ], [ - "[WARNING] undefined", + "[WARNING] undefined", ], [ - "[WARNING] 1,2,3", + "[WARNING] 1,2,3", ], [ - "[WARNING] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", + "[WARNING] Sat Nov 13 2021 00:00:00 GMT+0000 (Coordinated Universal Time)", ], ] `; diff --git a/packages/docusaurus-logger/src/__tests__/index.test.ts b/packages/docusaurus-logger/src/__tests__/index.test.ts index 0b2b710769fd..59a8f9c0d1d9 100644 --- a/packages/docusaurus-logger/src/__tests__/index.test.ts +++ b/packages/docusaurus-logger/src/__tests__/index.test.ts @@ -8,24 +8,25 @@ import {jest} from '@jest/globals'; import logger from '../index'; +// cSpell:ignore mkeep + describe('formatters', () => { it('path', () => { - // cSpell:ignore mhey - expect(logger.path('hey')).toMatchInlineSnapshot(`"\\"hey\\""`); + expect(logger.path('keepAnsi')).toMatchInlineSnapshot(`""keepAnsi""`); }); it('url', () => { - expect(logger.url('https://docusaurus.io/')).toMatchInlineSnapshot( - `"https://docusaurus.io/"`, + expect(logger.url('https://docusaurus.io/keepAnsi')).toMatchInlineSnapshot( + `"https://docusaurus.io/keepAnsi"`, ); }); it('id', () => { - expect(logger.name('hey')).toMatchInlineSnapshot(`"hey"`); + expect(logger.name('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`); }); it('code', () => { - expect(logger.code('hey')).toMatchInlineSnapshot(`"\`hey\`"`); + expect(logger.code('keepAnsi')).toMatchInlineSnapshot(`"\`keepAnsi\`"`); }); it('subdue', () => { - expect(logger.subdue('hey')).toMatchInlineSnapshot(`"hey"`); + expect(logger.subdue('keepAnsi')).toMatchInlineSnapshot(`"keepAnsi"`); }); }); @@ -33,9 +34,10 @@ describe('interpolate', () => { it('formats text with variables & arrays', () => { const name = 'Josh'; const items = [1, 'hi', 'Hmmm']; - expect(logger.interpolate`Hello ${name}! Here are your goodies:${items}`) - .toMatchInlineSnapshot(` - "Hello Josh! Here are your goodies: + expect( + logger.interpolate`(keepAnsi) Hello ${name}! Here are your goodies:${items}`, + ).toMatchInlineSnapshot(` + "(keepAnsi) Hello Josh! Here are your goodies: - 1 - hi - Hmmm" @@ -43,20 +45,20 @@ describe('interpolate', () => { }); it('recognizes valid flags', () => { expect( - logger.interpolate`The package at path=${'packages/docusaurus'} has number=${10} files. name=${'Babel'} is exported here subdue=${'(as a preset)'} that you can with code=${"require.resolve('@docusaurus/core/lib/babel/preset')"}`, + logger.interpolate`(keepAnsi) The package at path=${'packages/docusaurus'} has number=${10} files. name=${'Babel'} is exported here subdue=${'(as a preset)'} that you can with code=${"require.resolve('@docusaurus/core/lib/babel/preset')"}`, ).toMatchInlineSnapshot( - `"The package at \\"packages/docusaurus\\" has 10 files. Babel is exported here (as a preset) that you can with \`require.resolve('@docusaurus/core/lib/babel/preset')\`"`, + `"(keepAnsi) The package at "packages/docusaurus" has 10 files. Babel is exported here (as a preset) that you can with \`require.resolve('@docusaurus/core/lib/babel/preset')\`"`, ); }); it('interpolates arrays with flags', () => { expect( - logger.interpolate`The following commands are available:code=${[ + logger.interpolate`(keepAnsi) The following commands are available:code=${[ 'docusaurus start', 'docusaurus build', 'docusaurus deploy', ]}`, ).toMatchInlineSnapshot(` - "The following commands are available: + "(keepAnsi) The following commands are available: - \`docusaurus start\` - \`docusaurus build\` - \`docusaurus deploy\`" @@ -64,15 +66,15 @@ describe('interpolate', () => { }); it('prints detached flags as-is', () => { expect( - logger.interpolate`You can use placeholders like code= ${'and it will'} be replaced with the succeeding arguments`, + logger.interpolate`(keepAnsi) You can use placeholders like code= ${'and it will'} be replaced with the succeeding arguments`, ).toMatchInlineSnapshot( - `"You can use placeholders like code= and it will be replaced with the succeeding arguments"`, + `"(keepAnsi) You can use placeholders like code= and it will be replaced with the succeeding arguments"`, ); }); it('throws with bad flags', () => { expect( () => - logger.interpolate`I mistyped this: cde=${'this code'} and I will be damned`, + logger.interpolate`(keepAnsi) I mistyped this: cde=${'this code'} and I will be damned`, ).toThrowErrorMatchingInlineSnapshot( `"Bad Docusaurus logging message. This is likely an internal bug, please report it."`, ); diff --git a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap index e8540eda835d..8366a7b23e19 100644 --- a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`transformImage plugin does not choke on invalid image 1`] = ` -"{\\"invalid/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/invalid.png\\").default} /> +"{"invalid/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/invalid.png").default} /> " `; @@ -9,7 +9,7 @@ exports[`transformImage plugin fail if image does not exist 1`] = `"Image packag exports[`transformImage plugin fail if image relative path does not exist 1`] = `"Image packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/notFound.png used in packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/fail2.md not found."`; -exports[`transformImage plugin fail if image url is absent 1`] = `"Markdown image URL is mandatory in \\"packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/noUrl.md\\" file"`; +exports[`transformImage plugin fail if image url is absent 1`] = `"Markdown image URL is mandatory in "packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/noUrl.md" file"`; exports[`transformImage plugin pathname protocol 1`] = ` "![img](/img/unchecked.png) @@ -19,29 +19,29 @@ exports[`transformImage plugin pathname protocol 1`] = ` exports[`transformImage plugin transform md images to 1`] = ` "![img](https://example.com/img.png) -/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} width=\\"200\\" height=\\"200\\" /> +/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} width="200" height="200" /> -{\\"img\\"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} width=\\"200\\" height=\\"200\\" /> +{"img"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} width="200" height="200" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2.png\\").default} width=\\"256\\" height=\\"82\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2.png").default} width="256" height="82" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2.png\\").default} width=\\"256\\" height=\\"82\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2.png").default} width="256" height="82" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2 copy.png\\").default} width=\\"256\\" height=\\"82\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static2/img2 copy.png").default} width="256" height="82" /> -{\\"img\\"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} title=\\"Title\\" width=\\"200\\" height=\\"200\\" /> {\\"img\\"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} width=\\"200\\" height=\\"200\\" /> +{"img"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} title="Title" width="200" height="200" /> {"img"}/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} width="200" height="200" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} title=\\"'Quoted' title\\" width=\\"200\\" height=\\"200\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} title="'Quoted' title" width="200" height="200" /> -{\\"site/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default} width=\\"200\\" height=\\"200\\" /> +{"site/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default} width="200" height="200" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default + '#light'} width=\\"200\\" height=\\"200\\" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png\\").default + '#dark'} width=\\"200\\" height=\\"200\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default + '#light'} width="200" height="200" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png").default + '#dark'} width="200" height="200" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10\\").default} width=\\"200\\" height=\\"200\\" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10&h=10\\").default} width=\\"200\\" height=\\"200\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10").default} width="200" height="200" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10&h=10").default} width="200" height="200" /> -{\\"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10&h=10\\").default + '#light'} width=\\"200\\" height=\\"200\\" /> +{"img/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/img.png?w=10&h=10").default + '#light'} width="200" height="200" /> ## Heading diff --git a/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap index 810a5542ed2b..0daf646c0574 100644 --- a/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`transformAsset plugin fail if asset url is absent 1`] = `"Markdown link URL is mandatory in \\"packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__fixtures__/noUrl.md\\" file (title: asset, line: 1)."`; +exports[`transformAsset plugin fail if asset url is absent 1`] = `"Markdown link URL is mandatory in "packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__fixtures__/noUrl.md" file (title: asset, line: 1)."`; exports[`transformAsset plugin fail if asset with site alias does not exist 1`] = `"Asset packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__fixtures__/foo.pdf used in packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__fixtures__/nonexistentSiteAlias.md not found."`; @@ -12,15 +12,15 @@ exports[`transformAsset plugin pathname protocol 1`] = ` exports[`transformAsset plugin transform md links to 1`] = ` "[asset](https://example.com/asset.pdf) -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}> +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}> -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>asset +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>asset -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset (2).pdf').default}>asset with URL encoded chars +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset (2).pdf').default}>asset with URL encoded chars -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default + '#page=2'}>asset with hash +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default + '#page=2'}>asset with hash -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default} title=\\"Title\\">asset +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default} title="Title">asset [page](noUrl.md) @@ -34,24 +34,24 @@ exports[`transformAsset plugin transform md links to 1`] = ` [assets](/github/!file-loader!/assets.pdf) -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>asset +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>asset -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static2/asset2.pdf').default}>asset2 +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static2/asset2.pdf').default}>asset2 -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>staticAsset.pdf +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>staticAsset.pdf -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>@site/static/staticAsset.pdf +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>@site/static/staticAsset.pdf -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default + '#page=2'} title=\\"Title\\">@site/static/staticAsset.pdf +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default + '#page=2'} title="Title">@site/static/staticAsset.pdf -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>Just staticAsset.pdf, and /node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>awesome staticAsset 2.pdf 'It is really "AWESOME"', but also /node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>coded staticAsset 3.pdf +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>Just staticAsset.pdf, and /node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>awesome staticAsset 2.pdf 'It is really "AWESOME"', but also /node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAsset.pdf').default}>coded staticAsset 3.pdf -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAssetImage.png').default}>{\\"Clickable/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/staticAssetImage.png\\").default} width=\\"200\\" height=\\"200\\" /> +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/staticAssetImage.png').default}>{"Clickable/node_modules/url-loader/dist/cjs.js?limit=10000&name=assets/images/[name]-[contenthash].[ext]&fallback=/node_modules/file-loader/dist/cjs.js!./static/staticAssetImage.png").default} width="200" height="200" /> -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>Stylized link to asset file +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./asset.pdf').default}>Stylized link to asset file -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./data.json').default}>json +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./data.json').default}>json -/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/static-json.json').default}>static json +/node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[contenthash].[ext]!./static/static-json.json').default}>static json " `; diff --git a/packages/docusaurus-mdx-loader/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-mdx-loader/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.ts.snap index 35011f30c986..9b8ed7b0ada3 100644 --- a/packages/docusaurus-mdx-loader/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-mdx-loader/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.ts.snap @@ -17,7 +17,7 @@ text import XYZ from 'xyz'; - + Test @@ -32,30 +32,30 @@ import Avatar from 'avatar'; ## Some complex MDX with nested code blocks - + \`\`\`bash GIT_USER= yarn deploy \`\`\` - + \`\`\`batch - cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" + cmd /C "set "GIT_USER=" && yarn deploy" \`\`\` - + \`\`\`powershell -cmd /C 'set \\"GIT_USER=\\" && yarn deploy' +cmd /C 'set "GIT_USER=" && yarn deploy' \`\`\` @@ -64,30 +64,30 @@ cmd /C 'set \\"GIT_USER=\\" && yarn deploy' ## Some complex MDX code block with nested code blocks - + \`\`\`bash GIT_USER= yarn deploy \`\`\` - + \`\`\`batch -cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" +cmd /C "set "GIT_USER=" && yarn deploy" \`\`\` - + \`\`\`powershell -cmd /C 'set \\"GIT_USER=\\" && yarn deploy' +cmd /C 'set "GIT_USER=" && yarn deploy' \`\`\` @@ -421,7 +421,7 @@ exports[`unwrapMdxCodeBlocks remark plugin unwraps the mdx code blocks AST 1`] = }, }, "type": "jsx", - "value": " + "value": " Test ", }, @@ -551,13 +551,13 @@ exports[`unwrapMdxCodeBlocks remark plugin unwraps the mdx code blocks AST 1`] = }, "type": "jsx", "value": " - ", + ", }, { "lang": "bash", @@ -599,7 +599,7 @@ exports[`unwrapMdxCodeBlocks remark plugin unwraps the mdx code blocks AST 1`] = }, "type": "jsx", "value": " - ", + ", }, { "lang": null, @@ -622,7 +622,7 @@ exports[`unwrapMdxCodeBlocks remark plugin unwraps the mdx code blocks AST 1`] = }, "type": "code", "value": "\`\`\`batch -cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" +cmd /C "set "GIT_USER=" && yarn deploy" \`\`\`", }, { @@ -643,7 +643,7 @@ cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" }, "type": "jsx", "value": " - ", + ", }, { "lang": "powershell", @@ -665,7 +665,7 @@ cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" }, }, "type": "code", - "value": "cmd /C 'set \\"GIT_USER=\\" && yarn deploy'", + "value": "cmd /C 'set "GIT_USER=" && yarn deploy'", }, { "position": Position { @@ -772,30 +772,30 @@ cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" }, "type": "code", "value": " - + \`\`\`bash GIT_USER= yarn deploy \`\`\` - + \`\`\`batch -cmd /C \\"set \\"GIT_USER=\\" && yarn deploy\\" +cmd /C "set "GIT_USER=" && yarn deploy" \`\`\` - + \`\`\`powershell -cmd /C 'set \\"GIT_USER=\\" && yarn deploy' +cmd /C 'set "GIT_USER=" && yarn deploy' \`\`\` diff --git a/packages/docusaurus-migrate/src/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-migrate/src/__tests__/__snapshots__/index.test.ts.snap index 6bb29e50da09..4fd3d63d75ff 100644 --- a/packages/docusaurus-migrate/src/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-migrate/src/__tests__/__snapshots__/index.test.ts.snap @@ -32,106 +32,106 @@ exports[`migration CLI migrates complex website: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/docusaurus.config.js", "module.exports={ - \\"title\\": \\"Docusaurus\\", - \\"tagline\\": \\"Easy to Maintain Open Source Documentation Websites\\", - \\"url\\": \\"https://docusaurus.io\\", - \\"baseUrl\\": \\"/\\", - \\"organizationName\\": \\"facebook\\", - \\"projectName\\": \\"docusaurus\\", - \\"noIndex\\": false, - \\"scripts\\": [ - \\"https://buttons.github.io/buttons.js\\", - \\"https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js\\", - \\"/js/code-blocks-buttons.js\\" + "title": "Docusaurus", + "tagline": "Easy to Maintain Open Source Documentation Websites", + "url": "https://docusaurus.io", + "baseUrl": "/", + "organizationName": "facebook", + "projectName": "docusaurus", + "noIndex": false, + "scripts": [ + "https://buttons.github.io/buttons.js", + "https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js", + "/js/code-blocks-buttons.js" ], - \\"favicon\\": \\"img/docusaurus.ico\\", - \\"customFields\\": { - \\"users\\": { - \\"caption\\": \\"DevSpace\\", - \\"image\\": \\"/img/users/devspace.svg\\", - \\"infoLink\\": \\"https://devspace.cloud/docs/\\", - \\"fbOpenSource\\": false, - \\"pinned\\": false + "favicon": "img/docusaurus.ico", + "customFields": { + "users": { + "caption": "DevSpace", + "image": "/img/users/devspace.svg", + "infoLink": "https://devspace.cloud/docs/", + "fbOpenSource": false, + "pinned": false }, - \\"translationRecruitingLink\\": \\"https://crowdin.com/project/docusaurus\\", - \\"facebookAppId\\": \\"199138890728411\\" + "translationRecruitingLink": "https://crowdin.com/project/docusaurus", + "facebookAppId": "199138890728411" }, - \\"onBrokenLinks\\": \\"log\\", - \\"onBrokenMarkdownLinks\\": \\"log\\", - \\"presets\\": [ + "onBrokenLinks": "log", + "onBrokenMarkdownLinks": "log", + "presets": [ [ - \\"@docusaurus/preset-classic\\", + "@docusaurus/preset-classic", { - \\"docs\\": { - \\"showLastUpdateAuthor\\": true, - \\"showLastUpdateTime\\": true, - \\"editUrl\\": \\"https://github.com/facebook/docusaurus/edit/main/docs/\\" + "docs": { + "showLastUpdateAuthor": true, + "showLastUpdateTime": true, + "editUrl": "https://github.com/facebook/docusaurus/edit/main/docs/" }, - \\"blog\\": {}, - \\"theme\\": { - \\"customCss\\": \\"../complex_website/src/css/customTheme.css\\" + "blog": {}, + "theme": { + "customCss": "../complex_website/src/css/customTheme.css" }, - \\"googleAnalytics\\": { - \\"trackingID\\": \\"UA-44373548-31\\" + "googleAnalytics": { + "trackingID": "UA-44373548-31" } } ] ], - \\"plugins\\": [], - \\"themeConfig\\": { - \\"navbar\\": { - \\"title\\": \\"Docusaurus\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus.svg\\" + "plugins": [], + "themeConfig": { + "navbar": { + "title": "Docusaurus", + "logo": { + "src": "img/docusaurus.svg" }, - \\"items\\": [ + "items": [ { - \\"to\\": \\"docs/installation\\", - \\"label\\": \\"Docs\\", - \\"position\\": \\"left\\" + "to": "docs/installation", + "label": "Docs", + "position": "left" }, { - \\"to\\": \\"docs/tutorial-setup\\", - \\"label\\": \\"Tutorial\\", - \\"position\\": \\"left\\" + "to": "docs/tutorial-setup", + "label": "Tutorial", + "position": "left" }, { - \\"to\\": \\"/users\\", - \\"label\\": \\"Users\\", - \\"position\\": \\"left\\" + "to": "/users", + "label": "Users", + "position": "left" }, { - \\"href\\": \\"https://github.com/facebook/docusaurus\\", - \\"label\\": \\"GitHub\\", - \\"position\\": \\"left\\" + "href": "https://github.com/facebook/docusaurus", + "label": "GitHub", + "position": "left" } ] }, - \\"image\\": \\"img/docusaurus.png\\", - \\"footer\\": { - \\"links\\": [ + "image": "img/docusaurus.png", + "footer": { + "links": [ { - \\"title\\": \\"Community\\", - \\"items\\": [ + "title": "Community", + "items": [ { - \\"label\\": \\"Twitter\\", - \\"to\\": \\"https://twitter.com/docusaurus\\" + "label": "Twitter", + "to": "https://twitter.com/docusaurus" } ] } ], - \\"copyright\\": \\"Copyright © 2022 Facebook Inc.\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus_monochrome.svg\\" + "copyright": "Copyright © 2022 Facebook Inc.", + "logo": { + "src": "img/docusaurus_monochrome.svg" } }, - \\"algolia\\": { - \\"apiKey\\": \\"3eb9507824b8be89e7a199ecaa1a9d2c\\", - \\"indexName\\": \\"docusaurus\\", - \\"algoliaOptions\\": { - \\"facetFilters\\": [ - \\"language:LANGUAGE\\", - \\"version:VERSION\\" + "algolia": { + "apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c", + "indexName": "docusaurus", + "algoliaOptions": { + "facetFilters": [ + "language:LANGUAGE", + "version:VERSION" ] } } @@ -141,29 +141,29 @@ exports[`migration CLI migrates complex website: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/package.json", "{ - \\"name\\": \\"docusaurus-1-website\\", - \\"version\\": \\"2.0.0-alpha.58\\", - \\"private\\": true, - \\"scripts\\": { - \\"start\\": \\"docusaurus start\\", - \\"build\\": \\"docusaurus build\\", - \\"publish-gh-pages\\": \\"docusaurus-publish\\", - \\"examples\\": \\"docusaurus-examples\\", - \\"write-translations\\": \\"docusaurus-write-translations\\", - \\"docusaurus-version\\": \\"docusaurus-version\\", - \\"rename-version\\": \\"docusaurus-rename-version\\", - \\"crowdin-upload\\": \\"crowdin --config ../crowdin.yaml upload sources --auto-update -b master\\", - \\"crowdin-download\\": \\"crowdin --config ../crowdin.yaml download -b master\\", - \\"swizzle\\": \\"docusaurus swizzle\\", - \\"deploy\\": \\"docusaurus deploy\\", - \\"docusaurus\\": \\"docusaurus\\" + "name": "docusaurus-1-website", + "version": "2.0.0-alpha.58", + "private": true, + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "publish-gh-pages": "docusaurus-publish", + "examples": "docusaurus-examples", + "write-translations": "docusaurus-write-translations", + "docusaurus-version": "docusaurus-version", + "rename-version": "docusaurus-rename-version", + "crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master", + "crowdin-download": "crowdin --config ../crowdin.yaml download -b master", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "docusaurus": "docusaurus" }, - \\"dependencies\\": { - \\"@docusaurus/core\\": \\"\\", - \\"@docusaurus/preset-classic\\": \\"\\", - \\"clsx\\": \\"^1.1.1\\", - \\"react\\": \\"^17.0.2\\", - \\"react-dom\\": \\"^17.0.2\\" + "dependencies": { + "@docusaurus/core": "", + "@docusaurus/preset-classic": "", + "clsx": "^1.1.1", + "react": "^17.0.2", + "react-dom": "^17.0.2" } }", ], @@ -215,106 +215,106 @@ exports[`migration CLI migrates missing versions: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/docusaurus.config.js", "module.exports={ - \\"title\\": \\"Docusaurus\\", - \\"tagline\\": \\"Easy to Maintain Open Source Documentation Websites\\", - \\"url\\": \\"https://docusaurus.io\\", - \\"baseUrl\\": \\"/\\", - \\"organizationName\\": \\"facebook\\", - \\"projectName\\": \\"docusaurus\\", - \\"noIndex\\": false, - \\"scripts\\": [ - \\"https://buttons.github.io/buttons.js\\", - \\"https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js\\", - \\"/js/code-blocks-buttons.js\\" + "title": "Docusaurus", + "tagline": "Easy to Maintain Open Source Documentation Websites", + "url": "https://docusaurus.io", + "baseUrl": "/", + "organizationName": "facebook", + "projectName": "docusaurus", + "noIndex": false, + "scripts": [ + "https://buttons.github.io/buttons.js", + "https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js", + "/js/code-blocks-buttons.js" ], - \\"favicon\\": \\"img/docusaurus.ico\\", - \\"customFields\\": { - \\"users\\": { - \\"caption\\": \\"DevSpace\\", - \\"image\\": \\"/img/users/devspace.svg\\", - \\"infoLink\\": \\"https://devspace.cloud/docs/\\", - \\"fbOpenSource\\": false, - \\"pinned\\": false + "favicon": "img/docusaurus.ico", + "customFields": { + "users": { + "caption": "DevSpace", + "image": "/img/users/devspace.svg", + "infoLink": "https://devspace.cloud/docs/", + "fbOpenSource": false, + "pinned": false }, - \\"translationRecruitingLink\\": \\"https://crowdin.com/project/docusaurus\\", - \\"facebookAppId\\": \\"199138890728411\\" + "translationRecruitingLink": "https://crowdin.com/project/docusaurus", + "facebookAppId": "199138890728411" }, - \\"onBrokenLinks\\": \\"log\\", - \\"onBrokenMarkdownLinks\\": \\"log\\", - \\"presets\\": [ + "onBrokenLinks": "log", + "onBrokenMarkdownLinks": "log", + "presets": [ [ - \\"@docusaurus/preset-classic\\", + "@docusaurus/preset-classic", { - \\"docs\\": { - \\"showLastUpdateAuthor\\": true, - \\"showLastUpdateTime\\": true, - \\"editUrl\\": \\"https://github.com/facebook/docusaurus/edit/main/docs/\\" + "docs": { + "showLastUpdateAuthor": true, + "showLastUpdateTime": true, + "editUrl": "https://github.com/facebook/docusaurus/edit/main/docs/" }, - \\"blog\\": {}, - \\"theme\\": { - \\"customCss\\": \\"../missing_version_website/src/css/customTheme.css\\" + "blog": {}, + "theme": { + "customCss": "../missing_version_website/src/css/customTheme.css" }, - \\"googleAnalytics\\": { - \\"trackingID\\": \\"UA-44373548-31\\" + "googleAnalytics": { + "trackingID": "UA-44373548-31" } } ] ], - \\"plugins\\": [], - \\"themeConfig\\": { - \\"navbar\\": { - \\"title\\": \\"Docusaurus\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus.svg\\" + "plugins": [], + "themeConfig": { + "navbar": { + "title": "Docusaurus", + "logo": { + "src": "img/docusaurus.svg" }, - \\"items\\": [ + "items": [ { - \\"to\\": \\"docs/installation\\", - \\"label\\": \\"Docs\\", - \\"position\\": \\"left\\" + "to": "docs/installation", + "label": "Docs", + "position": "left" }, { - \\"to\\": \\"docs/tutorial-setup\\", - \\"label\\": \\"Tutorial\\", - \\"position\\": \\"left\\" + "to": "docs/tutorial-setup", + "label": "Tutorial", + "position": "left" }, { - \\"to\\": \\"/users\\", - \\"label\\": \\"Users\\", - \\"position\\": \\"left\\" + "to": "/users", + "label": "Users", + "position": "left" }, { - \\"href\\": \\"https://github.com/facebook/docusaurus\\", - \\"label\\": \\"GitHub\\", - \\"position\\": \\"left\\" + "href": "https://github.com/facebook/docusaurus", + "label": "GitHub", + "position": "left" } ] }, - \\"image\\": \\"img/docusaurus.png\\", - \\"footer\\": { - \\"links\\": [ + "image": "img/docusaurus.png", + "footer": { + "links": [ { - \\"title\\": \\"Community\\", - \\"items\\": [ + "title": "Community", + "items": [ { - \\"label\\": \\"Twitter\\", - \\"to\\": \\"https://twitter.com/docusaurus\\" + "label": "Twitter", + "to": "https://twitter.com/docusaurus" } ] } ], - \\"copyright\\": \\"Copyright © 2022 Facebook Inc.\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus_monochrome.svg\\" + "copyright": "Copyright © 2022 Facebook Inc.", + "logo": { + "src": "img/docusaurus_monochrome.svg" } }, - \\"algolia\\": { - \\"apiKey\\": \\"3eb9507824b8be89e7a199ecaa1a9d2c\\", - \\"indexName\\": \\"docusaurus\\", - \\"algoliaOptions\\": { - \\"facetFilters\\": [ - \\"language:LANGUAGE\\", - \\"version:VERSION\\" + "algolia": { + "apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c", + "indexName": "docusaurus", + "algoliaOptions": { + "facetFilters": [ + "language:LANGUAGE", + "version:VERSION" ] } } @@ -324,29 +324,29 @@ exports[`migration CLI migrates missing versions: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/package.json", "{ - \\"name\\": \\"docusaurus-1-website\\", - \\"version\\": \\"2.0.0-alpha.58\\", - \\"private\\": true, - \\"scripts\\": { - \\"start\\": \\"docusaurus start\\", - \\"build\\": \\"docusaurus build\\", - \\"publish-gh-pages\\": \\"docusaurus-publish\\", - \\"examples\\": \\"docusaurus-examples\\", - \\"write-translations\\": \\"docusaurus-write-translations\\", - \\"docusaurus-version\\": \\"docusaurus-version\\", - \\"rename-version\\": \\"docusaurus-rename-version\\", - \\"crowdin-upload\\": \\"crowdin --config ../crowdin.yaml upload sources --auto-update -b master\\", - \\"crowdin-download\\": \\"crowdin --config ../crowdin.yaml download -b master\\", - \\"swizzle\\": \\"docusaurus swizzle\\", - \\"deploy\\": \\"docusaurus deploy\\", - \\"docusaurus\\": \\"docusaurus\\" + "name": "docusaurus-1-website", + "version": "2.0.0-alpha.58", + "private": true, + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "publish-gh-pages": "docusaurus-publish", + "examples": "docusaurus-examples", + "write-translations": "docusaurus-write-translations", + "docusaurus-version": "docusaurus-version", + "rename-version": "docusaurus-rename-version", + "crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master", + "crowdin-download": "crowdin --config ../crowdin.yaml download -b master", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "docusaurus": "docusaurus" }, - \\"dependencies\\": { - \\"@docusaurus/core\\": \\"\\", - \\"@docusaurus/preset-classic\\": \\"\\", - \\"clsx\\": \\"^1.1.1\\", - \\"react\\": \\"^17.0.2\\", - \\"react-dom\\": \\"^17.0.2\\" + "dependencies": { + "@docusaurus/core": "", + "@docusaurus/preset-classic": "", + "clsx": "^1.1.1", + "react": "^17.0.2", + "react-dom": "^17.0.2" } }", ], @@ -394,107 +394,107 @@ exports[`migration CLI migrates simple website: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/docusaurus.config.js", "module.exports={ - \\"title\\": \\"Docusaurus\\", - \\"tagline\\": \\"Easy to Maintain Open Source Documentation Websites\\", - \\"url\\": \\"https://docusaurus.io\\", - \\"baseUrl\\": \\"/\\", - \\"organizationName\\": \\"facebook\\", - \\"projectName\\": \\"docusaurus\\", - \\"noIndex\\": false, - \\"scripts\\": [ - \\"https://buttons.github.io/buttons.js\\", - \\"https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js\\", - \\"/js/code-blocks-buttons.js\\" + "title": "Docusaurus", + "tagline": "Easy to Maintain Open Source Documentation Websites", + "url": "https://docusaurus.io", + "baseUrl": "/", + "organizationName": "facebook", + "projectName": "docusaurus", + "noIndex": false, + "scripts": [ + "https://buttons.github.io/buttons.js", + "https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js", + "/js/code-blocks-buttons.js" ], - \\"favicon\\": \\"img/docusaurus.ico\\", - \\"customFields\\": { - \\"users\\": { - \\"caption\\": \\"DevSpace\\", - \\"image\\": \\"/img/users/devspace.svg\\", - \\"infoLink\\": \\"https://devspace.cloud/docs/\\", - \\"fbOpenSource\\": false, - \\"pinned\\": false + "favicon": "img/docusaurus.ico", + "customFields": { + "users": { + "caption": "DevSpace", + "image": "/img/users/devspace.svg", + "infoLink": "https://devspace.cloud/docs/", + "fbOpenSource": false, + "pinned": false }, - \\"translationRecruitingLink\\": \\"https://crowdin.com/project/docusaurus\\", - \\"facebookAppId\\": \\"199138890728411\\" + "translationRecruitingLink": "https://crowdin.com/project/docusaurus", + "facebookAppId": "199138890728411" }, - \\"onBrokenLinks\\": \\"log\\", - \\"onBrokenMarkdownLinks\\": \\"log\\", - \\"presets\\": [ + "onBrokenLinks": "log", + "onBrokenMarkdownLinks": "log", + "presets": [ [ - \\"@docusaurus/preset-classic\\", + "@docusaurus/preset-classic", { - \\"docs\\": { - \\"showLastUpdateAuthor\\": true, - \\"showLastUpdateTime\\": true, - \\"editUrl\\": \\"https://github.com/facebook/docusaurus/edit/main/docs/\\", - \\"path\\": \\"../simple_website/docs\\" + "docs": { + "showLastUpdateAuthor": true, + "showLastUpdateTime": true, + "editUrl": "https://github.com/facebook/docusaurus/edit/main/docs/", + "path": "../simple_website/docs" }, - \\"blog\\": {}, - \\"theme\\": { - \\"customCss\\": \\"../simple_website/src/css/customTheme.css\\" + "blog": {}, + "theme": { + "customCss": "../simple_website/src/css/customTheme.css" }, - \\"googleAnalytics\\": { - \\"trackingID\\": \\"UA-44373548-31\\" + "googleAnalytics": { + "trackingID": "UA-44373548-31" } } ] ], - \\"plugins\\": [], - \\"themeConfig\\": { - \\"navbar\\": { - \\"title\\": \\"Docusaurus\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus.svg\\" + "plugins": [], + "themeConfig": { + "navbar": { + "title": "Docusaurus", + "logo": { + "src": "img/docusaurus.svg" }, - \\"items\\": [ + "items": [ { - \\"to\\": \\"docs/installation\\", - \\"label\\": \\"Docs\\", - \\"position\\": \\"left\\" + "to": "docs/installation", + "label": "Docs", + "position": "left" }, { - \\"to\\": \\"docs/tutorial-setup\\", - \\"label\\": \\"Tutorial\\", - \\"position\\": \\"left\\" + "to": "docs/tutorial-setup", + "label": "Tutorial", + "position": "left" }, { - \\"to\\": \\"/users\\", - \\"label\\": \\"Users\\", - \\"position\\": \\"left\\" + "to": "/users", + "label": "Users", + "position": "left" }, { - \\"href\\": \\"https://github.com/facebook/docusaurus\\", - \\"label\\": \\"GitHub\\", - \\"position\\": \\"left\\" + "href": "https://github.com/facebook/docusaurus", + "label": "GitHub", + "position": "left" } ] }, - \\"image\\": \\"img/docusaurus.png\\", - \\"footer\\": { - \\"links\\": [ + "image": "img/docusaurus.png", + "footer": { + "links": [ { - \\"title\\": \\"Community\\", - \\"items\\": [ + "title": "Community", + "items": [ { - \\"label\\": \\"Twitter\\", - \\"to\\": \\"https://twitter.com/docusaurus\\" + "label": "Twitter", + "to": "https://twitter.com/docusaurus" } ] } ], - \\"copyright\\": \\"Copyright © 2022 Facebook Inc.\\", - \\"logo\\": { - \\"src\\": \\"img/docusaurus_monochrome.svg\\" + "copyright": "Copyright © 2022 Facebook Inc.", + "logo": { + "src": "img/docusaurus_monochrome.svg" } }, - \\"algolia\\": { - \\"apiKey\\": \\"3eb9507824b8be89e7a199ecaa1a9d2c\\", - \\"indexName\\": \\"docusaurus\\", - \\"algoliaOptions\\": { - \\"facetFilters\\": [ - \\"language:LANGUAGE\\", - \\"version:VERSION\\" + "algolia": { + "apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c", + "indexName": "docusaurus", + "algoliaOptions": { + "facetFilters": [ + "language:LANGUAGE", + "version:VERSION" ] } } @@ -504,29 +504,29 @@ exports[`migration CLI migrates simple website: write 1`] = ` [ "/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/package.json", "{ - \\"name\\": \\"docusaurus-1-website\\", - \\"version\\": \\"2.0.0-alpha.58\\", - \\"private\\": true, - \\"scripts\\": { - \\"start\\": \\"docusaurus start\\", - \\"build\\": \\"docusaurus build\\", - \\"publish-gh-pages\\": \\"docusaurus-publish\\", - \\"examples\\": \\"docusaurus-examples\\", - \\"write-translations\\": \\"docusaurus-write-translations\\", - \\"docusaurus-version\\": \\"docusaurus-version\\", - \\"rename-version\\": \\"docusaurus-rename-version\\", - \\"crowdin-upload\\": \\"crowdin --config ../crowdin.yaml upload sources --auto-update -b master\\", - \\"crowdin-download\\": \\"crowdin --config ../crowdin.yaml download -b master\\", - \\"swizzle\\": \\"docusaurus swizzle\\", - \\"deploy\\": \\"docusaurus deploy\\", - \\"docusaurus\\": \\"docusaurus\\" + "name": "docusaurus-1-website", + "version": "2.0.0-alpha.58", + "private": true, + "scripts": { + "start": "docusaurus start", + "build": "docusaurus build", + "publish-gh-pages": "docusaurus-publish", + "examples": "docusaurus-examples", + "write-translations": "docusaurus-write-translations", + "docusaurus-version": "docusaurus-version", + "rename-version": "docusaurus-rename-version", + "crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master", + "crowdin-download": "crowdin --config ../crowdin.yaml download -b master", + "swizzle": "docusaurus swizzle", + "deploy": "docusaurus deploy", + "docusaurus": "docusaurus" }, - \\"dependencies\\": { - \\"@docusaurus/core\\": \\"\\", - \\"@docusaurus/preset-classic\\": \\"\\", - \\"clsx\\": \\"^1.1.1\\", - \\"react\\": \\"^17.0.2\\", - \\"react-dom\\": \\"^17.0.2\\" + "dependencies": { + "@docusaurus/core": "", + "@docusaurus/preset-classic": "", + "clsx": "^1.1.1", + "react": "^17.0.2", + "react-dom": "^17.0.2" } }", ], diff --git a/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/collectRedirects.test.ts.snap b/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/collectRedirects.test.ts.snap index 7c9cd4ee9de9..a9ce789f9861 100644 --- a/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/collectRedirects.test.ts.snap +++ b/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/collectRedirects.test.ts.snap @@ -14,14 +14,14 @@ Valid paths you can redirect to: exports[`collectRedirects throws if redirect creator creates array of array redirect 1`] = ` "Some created redirects are invalid: -- {\\"from\\":[\\"/fromPath\\"],\\"to\\":\\"/\\"} => Validation error: \\"from\\" must be a string +- {"from":["/fromPath"],"to":"/"} => Validation error: "from" must be a string " `; exports[`collectRedirects throws if redirect creator creates invalid redirects 1`] = ` "Some created redirects are invalid: -- {\\"from\\":\\"https://google.com/\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. -- {\\"from\\":\\"//abc\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. -- {\\"from\\":\\"/def?queryString=toto\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. +- {"from":"https://google.com/","to":"/"} => Validation error: "from" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. +- {"from":"//abc","to":"/"} => Validation error: "from" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. +- {"from":"/def?queryString=toto","to":"/"} => Validation error: "from" is not a valid pathname. Pathname should start with slash and not contain any domain or query string. " `; diff --git a/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap b/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap index 7882ae877ad0..a98e1c3f7ed7 100644 --- a/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap +++ b/packages/docusaurus-plugin-client-redirects/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap @@ -4,9 +4,9 @@ exports[`createRedirectPageContent encodes uri special chars 1`] = ` " - - - + + + ", + "headTags": " + + ", "postBodyTags": "", "preBodyTags": "", } @@ -114,7 +114,7 @@ describe('loadHtmlTags', () => { { "headTags": "", "postBodyTags": "", - "preBodyTags": "", + "preBodyTags": "", } `); }); @@ -139,12 +139,12 @@ describe('loadHtmlTags', () => { ]); expect(htmlTags).toMatchInlineSnapshot(` { - "headTags": " - - ", + "headTags": " + + ", "postBodyTags": "
Test content
", - "preBodyTags": "", + "preBodyTags": "", } `); }); @@ -158,9 +158,9 @@ describe('loadHtmlTags', () => { ]); expect(htmlTags).toMatchInlineSnapshot(` { - "headTags": " - - ", + "headTags": " + + ", "postBodyTags": "
Test content
", "preBodyTags": "", @@ -184,7 +184,7 @@ describe('loadHtmlTags', () => { }, ]), ).toThrowErrorMatchingInlineSnapshot( - `"Error loading {\\"tagName\\":\\"endiliey\\",\\"attributes\\":{\\"this\\":\\"is invalid\\"}}, \\"endiliey\\" is not a valid HTML tag."`, + `"Error loading {"tagName":"endiliey","attributes":{"this":"is invalid"}}, "endiliey" is not a valid HTML tag."`, ); }); @@ -202,7 +202,7 @@ describe('loadHtmlTags', () => { }, ]), ).toThrowErrorMatchingInlineSnapshot( - `"{\\"tagName\\":true} is not a valid HTML tag object. \\"tagName\\" must be defined as a string."`, + `"{"tagName":true} is not a valid HTML tag object. "tagName" must be defined as a string."`, ); }); @@ -218,7 +218,7 @@ describe('loadHtmlTags', () => { }, ]), ).toThrowErrorMatchingInlineSnapshot( - `"\\"2\\" is not a valid HTML tag object."`, + `""2" is not a valid HTML tag object."`, ); }); }); diff --git a/packages/docusaurus/src/server/__tests__/routes.test.ts b/packages/docusaurus/src/server/__tests__/routes.test.ts index b18f0ccca679..a2f22058da4b 100644 --- a/packages/docusaurus/src/server/__tests__/routes.test.ts +++ b/packages/docusaurus/src/server/__tests__/routes.test.ts @@ -183,9 +183,9 @@ describe('loadRoutes', () => { expect(() => loadRoutes([routeConfigWithoutPath], '/', 'ignore')) .toThrowErrorMatchingInlineSnapshot(` - "Invalid route config: path must be a string and component is required. - {\\"component\\":\\"hello/world.js\\"}" - `); + "Invalid route config: path must be a string and component is required. + {"component":"hello/world.js"}" + `); const routeConfigWithoutComponent = { path: '/hello/world', @@ -193,9 +193,9 @@ describe('loadRoutes', () => { expect(() => loadRoutes([routeConfigWithoutComponent], '/', 'ignore')) .toThrowErrorMatchingInlineSnapshot(` - "Invalid route config: path must be a string and component is required. - {\\"path\\":\\"/hello/world\\"}" - `); + "Invalid route config: path must be a string and component is required. + {"path":"/hello/world"}" + `); }); it('loads route config with empty (but valid) path string', () => { diff --git a/packages/docusaurus/src/server/__tests__/siteMetadata.test.ts b/packages/docusaurus/src/server/__tests__/siteMetadata.test.ts index 12c62dcd54cd..d33e301382be 100644 --- a/packages/docusaurus/src/server/__tests__/siteMetadata.test.ts +++ b/packages/docusaurus/src/server/__tests__/siteMetadata.test.ts @@ -55,11 +55,10 @@ describe('loadSiteMetadata', () => { siteDir: path.join(__dirname, '__fixtures__/siteMetadata'), }), ).resolves.toMatchSnapshot(); - // cSpell:ignore mdocusaurus expect(consoleMock.mock.calls[0][0]).toMatchInlineSnapshot(` - "[ERROR] Invalid docusaurus-plugin-content-docs version 1.0.0. - All official @docusaurus/* packages should have the exact same version as @docusaurus/core (). - Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?" + "[ERROR] Invalid docusaurus-plugin-content-docs version 1.0.0. + All official @docusaurus/* packages should have the exact same version as @docusaurus/core (). + Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?" `); }); }); diff --git a/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/init.test.ts.snap b/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/init.test.ts.snap index 3c982b11453f..b900cdd18224 100644 --- a/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/init.test.ts.snap +++ b/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/init.test.ts.snap @@ -5,9 +5,9 @@ exports[`initPlugins throws user-friendly error message for plugins with bad val Example valid plugin config: { plugins: [ - [\\"@docusaurus/plugin-content-docs\\",options], - \\"./myPlugin\\", - [\\"./myPlugin\\",{someOption: 42}], + ["@docusaurus/plugin-content-docs",options], + "./myPlugin", + ["./myPlugin",{someOption: 42}], function myPlugin() { }, [function myPlugin() { },options] ], @@ -17,9 +17,9 @@ Example valid plugin config: Example valid plugin config: { plugins: [ - [\\"@docusaurus/plugin-content-docs\\",options], - \\"./myPlugin\\", - [\\"./myPlugin\\",{someOption: 42}], + ["@docusaurus/plugin-content-docs",options], + "./myPlugin", + ["./myPlugin",{someOption: 42}], function myPlugin() { }, [function myPlugin() { },options] ], diff --git a/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/pluginIds.test.ts.snap b/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/pluginIds.test.ts.snap index 4952facb6eaf..c8b4f56954da 100644 --- a/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/pluginIds.test.ts.snap +++ b/packages/docusaurus/src/server/plugins/__tests__/__snapshots__/pluginIds.test.ts.snap @@ -1,20 +1,20 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ensureUniquePluginInstanceIds reject multi instance plugins with same id 1`] = ` -"Plugin \\"plugin-docs\\" is used 2 times with ID \\"sameId\\". +"Plugin "plugin-docs" is used 2 times with ID "sameId". To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance." `; exports[`ensureUniquePluginInstanceIds reject multi instance plugins with some without id 1`] = ` -"Plugin \\"plugin-docs\\" is used 2 times with ID \\"default\\". +"Plugin "plugin-docs" is used 2 times with ID "default". To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance. -The plugin ID is \\"default\\" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)." +The plugin ID is "default" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)." `; exports[`ensureUniquePluginInstanceIds reject multi instance plugins without id 1`] = ` -"Plugin \\"plugin-docs\\" is used 2 times with ID \\"default\\". +"Plugin "plugin-docs" is used 2 times with ID "default". To use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance. -The plugin ID is \\"default\\" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)." +The plugin ID is "default" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances)." `; diff --git a/packages/docusaurus/src/server/plugins/__tests__/moduleShorthand.test.ts b/packages/docusaurus/src/server/plugins/__tests__/moduleShorthand.test.ts index 239811e3427b..c149e117d8d5 100644 --- a/packages/docusaurus/src/server/plugins/__tests__/moduleShorthand.test.ts +++ b/packages/docusaurus/src/server/plugins/__tests__/moduleShorthand.test.ts @@ -72,7 +72,7 @@ describe('resolveModuleName', () => { expect(() => resolveModuleName('@docusaurus/plugin-content-doc', require, 'plugin'), ).toThrowErrorMatchingInlineSnapshot(` - "Docusaurus was unable to resolve the \\"@docusaurus/plugin-content-doc\\" plugin. Make sure one of the following packages are installed: + "Docusaurus was unable to resolve the "@docusaurus/plugin-content-doc" plugin. Make sure one of the following packages are installed: - @docusaurus/plugin-content-doc - @docusaurus/docusaurus-plugin-plugin-content-doc" `); @@ -81,7 +81,7 @@ describe('resolveModuleName', () => { it('throws good error message for shorthand', () => { expect(() => resolveModuleName('content-doc', require, 'plugin')) .toThrowErrorMatchingInlineSnapshot(` - "Docusaurus was unable to resolve the \\"content-doc\\" plugin. Make sure one of the following packages are installed: + "Docusaurus was unable to resolve the "content-doc" plugin. Make sure one of the following packages are installed: - content-doc - @docusaurus/plugin-content-doc - docusaurus-plugin-content-doc" diff --git a/packages/docusaurus/src/server/translations/__tests__/translations.test.ts b/packages/docusaurus/src/server/translations/__tests__/translations.test.ts index b4dda430760b..89240e3ea05e 100644 --- a/packages/docusaurus/src/server/translations/__tests__/translations.test.ts +++ b/packages/docusaurus/src/server/translations/__tests__/translations.test.ts @@ -259,10 +259,11 @@ describe('writeCodeTranslations', () => { { key1: {message: 'key1 message'}, }, + {}, ), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"bad\\" must be of type object"`, + `""bad" must be of type object"`, ); }); }); @@ -403,7 +404,7 @@ describe('writePluginTranslations', () => { options: {}, }), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"Translation file path at \\"my/translation/file.json\\" does not need to end with \\".json\\", we add the extension automatically."`, + `"Translation file path at "my/translation/file.json" does not need to end with ".json", we add the extension automatically."`, ); }); }); @@ -522,29 +523,27 @@ describe('readCodeTranslationFileContent', () => { await expect(() => testReadTranslation('HEY'), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"value\\" must be of type object"`, + `""value" must be of type object"`, ); await expect(() => testReadTranslation(42), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"value\\" must be of type object"`, + `""value" must be of type object"`, ); await expect(() => testReadTranslation({key: {description: 'no message'}}), - ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"key.message\\" is required"`, - ); + ).rejects.toThrowErrorMatchingInlineSnapshot(`""key.message" is required"`); await expect(() => testReadTranslation({key: {message: 42}}), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"key.message\\" must be a string"`, + `""key.message" must be a string"`, ); await expect(() => testReadTranslation({ key: {message: 'Message', description: 42}, }), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"\\"key.description\\" must be a string"`, + `""key.description" must be a string"`, ); }); }); diff --git a/packages/docusaurus/src/webpack/__tests__/utils.test.ts b/packages/docusaurus/src/webpack/__tests__/utils.test.ts index 1a388ed4e4f8..afcc1477f782 100644 --- a/packages/docusaurus/src/webpack/__tests__/utils.test.ts +++ b/packages/docusaurus/src/webpack/__tests__/utils.test.ts @@ -335,7 +335,7 @@ describe('getHttpsConfig', () => { ); process.env.SSL_KEY_FILE = path.join(__dirname, '__fixtures__/host.key'); await expect(getHttpsConfig()).rejects.toThrowErrorMatchingInlineSnapshot( - `"You specified SSL_CRT_FILE in your env, but the file \\"/packages/docusaurus/src/webpack/__tests__/__fixtures__/nonexistent.crt\\" can't be found."`, + `"You specified SSL_CRT_FILE in your env, but the file "/packages/docusaurus/src/webpack/__tests__/__fixtures__/nonexistent.crt" can't be found."`, ); });