mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-22 19:17:46 +02:00
chore: remove docusaurus-migrate (#9400)
This commit is contained in:
parent
ae3191654c
commit
336a44f3ea
49 changed files with 27 additions and 3062 deletions
|
@ -1,5 +0,0 @@
|
|||
.tsbuildinfo*
|
||||
tsconfig*
|
||||
__tests__
|
||||
|
||||
src
|
|
@ -1,7 +0,0 @@
|
|||
# `@docusaurus/migrate`
|
||||
|
||||
A CLI tool to migrate from older versions of Docusaurus.
|
||||
|
||||
## Usage
|
||||
|
||||
Please see [the migration documentation](https://docusaurus.io/docs/migration) for more information.
|
|
@ -1,61 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
import path from 'path';
|
||||
import {createRequire} from 'module';
|
||||
import logger from '@docusaurus/logger';
|
||||
import semver from 'semver';
|
||||
import cli from 'commander';
|
||||
|
||||
const moduleRequire = createRequire(import.meta.url);
|
||||
const requiredVersion = /** @type {import("../package.json")} */ (
|
||||
moduleRequire('../package.json')
|
||||
).engines.node;
|
||||
|
||||
if (!semver.satisfies(process.version, requiredVersion)) {
|
||||
logger.error('Minimum Node.js version not met :(');
|
||||
logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// See https://github.com/facebook/docusaurus/pull/6860
|
||||
const {migrateDocusaurusProject, migrateMDToMDX} =
|
||||
/** @type {import("../lib/index.js")} */ (moduleRequire('../lib/index.js'));
|
||||
|
||||
cli
|
||||
.command('migrate [siteDir] [newDir]')
|
||||
.option('--mdx', 'try to migrate MD to MDX too')
|
||||
.option('--page', 'try to migrate pages too')
|
||||
.description('Migrate between versions of Docusaurus website.')
|
||||
.action(async (siteDir = '.', newDir = '.', {mdx, page} = {}) => {
|
||||
const sitePath = path.resolve(siteDir);
|
||||
const newSitePath = path.resolve(newDir);
|
||||
await migrateDocusaurusProject(sitePath, newSitePath, mdx, page);
|
||||
});
|
||||
|
||||
cli
|
||||
.command('mdx [siteDir] [newDir]')
|
||||
.description('Migrate markdown files to MDX.')
|
||||
.action(async (siteDir = '.', newDir = '.') => {
|
||||
const sitePath = path.resolve(siteDir);
|
||||
const newSitePath = path.resolve(newDir);
|
||||
await migrateMDToMDX(sitePath, newSitePath);
|
||||
});
|
||||
|
||||
cli.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
cli.outputHelp();
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"name": "@docusaurus/migrate",
|
||||
"version": "3.0.0-beta.0",
|
||||
"description": "A CLI tool to migrate from older versions of Docusaurus.",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"watch": "tsc --build --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/docusaurus.git",
|
||||
"directory": "packages/docusaurus-migrate"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bin": {
|
||||
"docusaurus-migrate": "bin/index.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.22.9",
|
||||
"@babel/preset-env": "^7.22.9",
|
||||
"@docusaurus/logger": "3.0.0-beta.0",
|
||||
"@docusaurus/utils": "3.0.0-beta.0",
|
||||
"@mapbox/hast-util-to-jsx": "^2.0.0",
|
||||
"color": "^4.2.3",
|
||||
"commander": "^5.1.0",
|
||||
"fs-extra": "^11.1.1",
|
||||
"hast-util-to-string": "^1.0.4",
|
||||
"html-tags": "^3.3.1",
|
||||
"jscodeshift": "^0.14.0",
|
||||
"rehype-parse": "^7.0.1",
|
||||
"remark-parse": "^8.0.3",
|
||||
"remark-stringify": "^8.1.1",
|
||||
"semver": "^7.5.4",
|
||||
"tslib": "^2.6.0",
|
||||
"unified": "^10.1.2",
|
||||
"unist-util-visit": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/color": "^3.0.3",
|
||||
"@types/jscodeshift": "^0.11.6"
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
title: Introducing Docusaurus
|
||||
author: Joel Marcey
|
||||
authorURL: http://twitter.com/JoelMarcey
|
||||
authorImageURL: https://graph.facebook.com/611217057/picture/?height=200&width=200
|
||||
authorFBID: 611217057
|
||||
authorTwitter: JoelMarcey
|
||||
---
|
||||
|
||||
# blog
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"docusaurus": "*"
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
|
||||
|
||||
|
||||
function Index(props) {
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
module.exports = Index;
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"API": [
|
||||
"commands",
|
||||
"doc-markdown",
|
||||
]
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* List of projects/orgs using your project for the users page */
|
||||
const users = {
|
||||
caption: 'DevSpace',
|
||||
image: '/img/users/devspace.svg',
|
||||
infoLink: 'https://devspace.cloud/docs/',
|
||||
fbOpenSource: false,
|
||||
pinned: false,
|
||||
};
|
||||
|
||||
const siteConfig = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Easy to Maintain Open Source Documentation Websites',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
cname: 'docusaurus.io',
|
||||
noIndex: false,
|
||||
users,
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||
headerLinks: [
|
||||
{doc: 'installation', label: 'Docs'},
|
||||
{doc: 'tutorial-setup', label: 'Tutorial'},
|
||||
{page: 'users', label: 'Users'},
|
||||
{blog: true, label: 'Blog'},
|
||||
{
|
||||
href: 'https://github.com/facebook/docusaurus',
|
||||
label: 'GitHub',
|
||||
external: true,
|
||||
},
|
||||
],
|
||||
headerIcon: 'img/docusaurus.svg',
|
||||
footerIcon: 'img/docusaurus_monochrome.svg',
|
||||
favicon: 'img/docusaurus.ico',
|
||||
algolia: {
|
||||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c',
|
||||
indexName: 'docusaurus',
|
||||
algoliaOptions: {
|
||||
facetFilters: ['language:LANGUAGE', 'version:VERSION'],
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
primaryColor: '#2E8555',
|
||||
secondaryColor: '#205C3B',
|
||||
},
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`,
|
||||
usePrism: ['jsx'],
|
||||
highlight: {
|
||||
theme: 'atom-one-dark',
|
||||
},
|
||||
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',
|
||||
],
|
||||
gaTrackingId: 'UA-44373548-31',
|
||||
facebookAppId: '199138890728411',
|
||||
facebookComments: true,
|
||||
twitter: 'true',
|
||||
twitterUsername: 'docusaurus',
|
||||
ogImage: 'img/docusaurus.png',
|
||||
twitterImage: 'img/docusaurus.png',
|
||||
onPageNav: 'separate',
|
||||
cleanUrl: true,
|
||||
scrollToTop: true,
|
||||
scrollToTopOptions: {
|
||||
zIndex: 100,
|
||||
},
|
||||
enableUpdateTime: true,
|
||||
enableUpdateBy: true,
|
||||
docsSideNavCollapsible: true,
|
||||
};
|
||||
|
||||
module.exports = siteConfig;
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.10.x-commands
|
||||
title: CLI Commands
|
||||
original_id: commands
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.9.x-commands
|
||||
title: CLI Commands
|
||||
original_id: commands
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.9.x-doc-markdown
|
||||
title: Markdown Features
|
||||
original_id: doc-markdown
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"version-1.9.x-docs": {
|
||||
"API": [
|
||||
"version-1.9.x-commands",
|
||||
"version-1.9.x-doc-markdown"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
[ "1.10.x", "1.9.x"]
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Easy to Maintain Open Source Documentation Websites',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
noIndex: true,
|
||||
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,
|
||||
},
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
facebookAppId: '199138890728411',
|
||||
},
|
||||
onBrokenLinks: 'log',
|
||||
onBrokenMarkdownLinks: 'log',
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
showLastUpdateAuthor: true,
|
||||
showLastUpdateTime: true,
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||
},
|
||||
blog: {},
|
||||
theme: {},
|
||||
googleAnalytics: {trackingID: 'UA-44373548-31'},
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [],
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
title: 'Docusaurus',
|
||||
logo: {src: 'img/docusaurus.svg'},
|
||||
items: [
|
||||
{to: 'docs/installation', label: 'Docs', position: 'left'},
|
||||
{to: 'docs/tutorial-setup', label: 'Tutorial', position: 'left'},
|
||||
{to: '/users', label: 'Users', position: 'left'},
|
||||
{
|
||||
href: 'https://github.com/facebook/docusaurus',
|
||||
label: 'GitHub',
|
||||
position: 'left',
|
||||
},
|
||||
],
|
||||
},
|
||||
image: 'img/docusaurus.png',
|
||||
footer: {
|
||||
links: [
|
||||
{
|
||||
title: 'Community',
|
||||
items: [{label: 'Twitter', to: 'https://twitter.com/docusaurus'}],
|
||||
},
|
||||
],
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`,
|
||||
logo: {src: 'img/docusaurus_monochrome.svg'},
|
||||
},
|
||||
algolia: {
|
||||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c',
|
||||
indexName: 'docusaurus',
|
||||
algoliaOptions: {facetFilters: ['language:LANGUAGE', 'version:VERSION']},
|
||||
},
|
||||
},
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
title: Introducing Docusaurus
|
||||
author: Joel Marcey
|
||||
authorURL: http://twitter.com/JoelMarcey
|
||||
authorImageURL: https://graph.facebook.com/611217057/picture/?height=200&width=200
|
||||
authorFBID: 611217057
|
||||
authorTwitter: JoelMarcey
|
||||
---
|
||||
|
||||
# Blog
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"docusaurus": "*"
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
|
||||
|
||||
|
||||
function Index(props) {
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
module.exports = Index;
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"API": [
|
||||
"commands",
|
||||
"doc-markdown",
|
||||
]
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* List of projects/orgs using your project for the users page */
|
||||
const users = {
|
||||
caption: 'DevSpace',
|
||||
image: '/img/users/devspace.svg',
|
||||
infoLink: 'https://devspace.cloud/docs/',
|
||||
fbOpenSource: false,
|
||||
pinned: false,
|
||||
};
|
||||
|
||||
const siteConfig = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Easy to Maintain Open Source Documentation Websites',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
cname: 'docusaurus.io',
|
||||
noIndex: false,
|
||||
users,
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||
headerLinks: [
|
||||
{doc: 'installation', label: 'Docs'},
|
||||
{doc: 'tutorial-setup', label: 'Tutorial'},
|
||||
{page: 'users', label: 'Users'},
|
||||
{blog: true, label: 'Blog'},
|
||||
{
|
||||
href: 'https://github.com/facebook/docusaurus',
|
||||
label: 'GitHub',
|
||||
external: true,
|
||||
},
|
||||
],
|
||||
headerIcon: 'img/docusaurus.svg',
|
||||
footerIcon: 'img/docusaurus_monochrome.svg',
|
||||
favicon: 'img/docusaurus.ico',
|
||||
algolia: {
|
||||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c',
|
||||
indexName: 'docusaurus',
|
||||
algoliaOptions: {
|
||||
facetFilters: ['language:LANGUAGE', 'version:VERSION'],
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
primaryColor: '#2E8555',
|
||||
secondaryColor: '#205C3B',
|
||||
},
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`,
|
||||
usePrism: ['jsx'],
|
||||
highlight: {
|
||||
theme: 'atom-one-dark',
|
||||
},
|
||||
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',
|
||||
],
|
||||
gaTrackingId: 'UA-44373548-31',
|
||||
facebookAppId: '199138890728411',
|
||||
facebookComments: true,
|
||||
twitter: 'true',
|
||||
twitterUsername: 'docusaurus',
|
||||
ogImage: 'img/docusaurus.png',
|
||||
twitterImage: 'img/docusaurus.png',
|
||||
onPageNav: 'separate',
|
||||
cleanUrl: true,
|
||||
scrollToTop: true,
|
||||
scrollToTopOptions: {
|
||||
zIndex: 100,
|
||||
},
|
||||
enableUpdateTime: true,
|
||||
enableUpdateBy: true,
|
||||
docsSideNavCollapsible: true,
|
||||
};
|
||||
|
||||
module.exports = siteConfig;
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.10.x-commands
|
||||
title: CLI Commands
|
||||
original_id: commands
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.9.x-commands
|
||||
title: CLI Commands
|
||||
original_id: commands
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
id: version-1.9.x-doc-markdown
|
||||
title: Markdown Features
|
||||
original_id: doc-markdown
|
||||
---
|
||||
|
||||
# Doc
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"version-1.9.x-docs": {
|
||||
"API": [
|
||||
"version-1.9.x-commands",
|
||||
"version-1.9.x-doc-markdown"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
[ "1.10.x","1.9.10", "1.9.x"]
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
id: commands
|
||||
title: CLI Commands
|
||||
---
|
||||
|
||||
## Doc
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
id: doc-markdown
|
||||
title: Markdown Features
|
||||
---
|
||||
|
||||
## Doc
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"docusaurus": "*"
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
|
||||
|
||||
|
||||
function Index(props) {
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
module.exports = Index;
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"API": [
|
||||
"commands",
|
||||
"doc-markdown",
|
||||
]
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* List of projects/orgs using your project for the users page */
|
||||
const users = {
|
||||
caption: 'DevSpace',
|
||||
image: '/img/users/devspace.svg',
|
||||
infoLink: 'https://devspace.cloud/docs/',
|
||||
fbOpenSource: false,
|
||||
pinned: false,
|
||||
};
|
||||
|
||||
const siteConfig = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Easy to Maintain Open Source Documentation Websites',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
cname: 'docusaurus.io',
|
||||
noIndex: false,
|
||||
users,
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||
headerLinks: [
|
||||
{doc: 'installation', label: 'Docs'},
|
||||
{doc: 'tutorial-setup', label: 'Tutorial'},
|
||||
{page: 'users', label: 'Users'},
|
||||
{blog: true, label: 'Blog'},
|
||||
{
|
||||
href: 'https://github.com/facebook/docusaurus',
|
||||
label: 'GitHub',
|
||||
external: true,
|
||||
},
|
||||
],
|
||||
headerIcon: 'img/docusaurus.svg',
|
||||
footerIcon: 'img/docusaurus_monochrome.svg',
|
||||
favicon: 'img/docusaurus.ico',
|
||||
algolia: {
|
||||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c',
|
||||
indexName: 'docusaurus',
|
||||
algoliaOptions: {
|
||||
facetFilters: ['language:LANGUAGE', 'version:VERSION'],
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
primaryColor: '#2E8555',
|
||||
secondaryColor: '#205C3B',
|
||||
},
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`,
|
||||
usePrism: ['jsx'],
|
||||
highlight: {
|
||||
theme: 'atom-one-dark',
|
||||
},
|
||||
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',
|
||||
],
|
||||
gaTrackingId: 'UA-44373548-31',
|
||||
facebookAppId: '199138890728411',
|
||||
facebookComments: true,
|
||||
twitter: 'true',
|
||||
twitterUsername: 'docusaurus',
|
||||
ogImage: 'img/docusaurus.png',
|
||||
twitterImage: 'img/docusaurus.png',
|
||||
onPageNav: 'separate',
|
||||
cleanUrl: true,
|
||||
scrollToTop: true,
|
||||
scrollToTopOptions: {
|
||||
zIndex: 100,
|
||||
},
|
||||
enableUpdateTime: true,
|
||||
enableUpdateBy: true,
|
||||
docsSideNavCollapsible: true,
|
||||
};
|
||||
|
||||
module.exports = siteConfig;
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const users = {
|
||||
caption: 'DevSpace',
|
||||
image: '/img/users/devspace.svg',
|
||||
infoLink: 'https://devspace.cloud/docs/',
|
||||
fbOpenSource: false,
|
||||
pinned: false,
|
||||
};
|
||||
|
||||
const siteConfig = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Easy to Maintain Open Source Documentation Websites',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
cname: 'docusaurus.io',
|
||||
noIndex: true,
|
||||
users,
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/main/docs/',
|
||||
headerLinks: [
|
||||
{doc: 'installation', label: 'Docs'},
|
||||
{doc: 'tutorial-setup', label: 'Tutorial'},
|
||||
{page: 'users', label: 'Users'},
|
||||
{blog: true, label: 'Blog'},
|
||||
{
|
||||
href: 'https://github.com/facebook/docusaurus',
|
||||
label: 'GitHub',
|
||||
external: true,
|
||||
},
|
||||
],
|
||||
headerIcon: 'img/docusaurus.svg',
|
||||
footerIcon: 'img/docusaurus_monochrome.svg',
|
||||
favicon: 'img/docusaurus.ico',
|
||||
algolia: {
|
||||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c',
|
||||
indexName: 'docusaurus',
|
||||
algoliaOptions: {
|
||||
facetFilters: ['language:LANGUAGE', 'version:VERSION'],
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
primaryColor: '#2E8555',
|
||||
secondaryColor: '#205C3B',
|
||||
},
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Facebook Inc.`,
|
||||
usePrism: ['jsx'],
|
||||
highlight: {
|
||||
theme: 'atom-one-dark',
|
||||
},
|
||||
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',
|
||||
],
|
||||
gaTrackingId: 'UA-44373548-31',
|
||||
facebookAppId: '199138890728411',
|
||||
facebookComments: true,
|
||||
twitter: 'true',
|
||||
twitterUsername: 'docusaurus',
|
||||
ogImage: 'img/docusaurus.png',
|
||||
twitterImage: 'img/docusaurus.png',
|
||||
onPageNav: 'separate',
|
||||
cleanUrl: true,
|
||||
scrollToTop: true,
|
||||
scrollToTopOptions: {
|
||||
zIndex: 100,
|
||||
},
|
||||
enableUpdateTime: true,
|
||||
enableUpdateBy: true,
|
||||
docsSideNavCollapsible: true,
|
||||
};
|
||||
|
||||
module.exports = siteConfig;
|
|
@ -1,565 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`migration CLI migrates complex website: copy 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/complex_website/website/blog",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/blog",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/complex_website/website/pages/en",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/src/pages",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/complex_website/website/static",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/static",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates complex website: mkdirp 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/src/pages",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates complex website: mkdirs 1`] = `[]`;
|
||||
|
||||
exports[`migration CLI migrates complex website: write 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
],
|
||||
"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"
|
||||
},
|
||||
"onBrokenLinks": "log",
|
||||
"onBrokenMarkdownLinks": "log",
|
||||
"presets": [
|
||||
[
|
||||
"@docusaurus/preset-classic",
|
||||
{
|
||||
"docs": {
|
||||
"showLastUpdateAuthor": true,
|
||||
"showLastUpdateTime": true,
|
||||
"editUrl": "https://github.com/facebook/docusaurus/edit/main/docs/"
|
||||
},
|
||||
"blog": {},
|
||||
"theme": {
|
||||
"customCss": "../complex_website/src/css/customTheme.css"
|
||||
},
|
||||
"googleAnalytics": {
|
||||
"trackingID": "UA-44373548-31"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": [],
|
||||
"themeConfig": {
|
||||
"navbar": {
|
||||
"title": "Docusaurus",
|
||||
"logo": {
|
||||
"src": "img/docusaurus.svg"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"to": "docs/installation",
|
||||
"label": "Docs",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "docs/tutorial-setup",
|
||||
"label": "Tutorial",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "/users",
|
||||
"label": "Users",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"href": "https://github.com/facebook/docusaurus",
|
||||
"label": "GitHub",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
},
|
||||
"image": "img/docusaurus.png",
|
||||
"footer": {
|
||||
"links": [
|
||||
{
|
||||
"title": "Community",
|
||||
"items": [
|
||||
{
|
||||
"label": "Twitter",
|
||||
"to": "https://twitter.com/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"copyright": "Copyright © 2023 Facebook Inc.",
|
||||
"logo": {
|
||||
"src": "img/docusaurus_monochrome.svg"
|
||||
}
|
||||
},
|
||||
"algolia": {
|
||||
"apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c",
|
||||
"indexName": "docusaurus",
|
||||
"algoliaOptions": {
|
||||
"facetFilters": [
|
||||
"language:LANGUAGE",
|
||||
"version:VERSION"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "<CURRENT_VERSION>",
|
||||
"@docusaurus/preset-classic": "<CURRENT_VERSION>",
|
||||
"clsx": "^1.1.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_complex_site/src/css/customTheme.css",
|
||||
":root{
|
||||
--ifm-color-primary-lightest: #3CAD6E;
|
||||
--ifm-color-primary-lighter: #359962;
|
||||
--ifm-color-primary-light: #33925D;
|
||||
--ifm-color-primary: #2E8555;
|
||||
--ifm-color-primary-dark: #29784C;
|
||||
--ifm-color-primary-darker: #277148;
|
||||
--ifm-color-primary-darkest: #205D3B;
|
||||
}
|
||||
",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates missing versions: copy 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/missing_version_website/website/blog",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/blog",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/missing_version_website/website/pages/en",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/src/pages",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/missing_version_website/website/static",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/static",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates missing versions: mkdirp 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/src/pages",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates missing versions: mkdirs 1`] = `[]`;
|
||||
|
||||
exports[`migration CLI migrates missing versions: write 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
],
|
||||
"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"
|
||||
},
|
||||
"onBrokenLinks": "log",
|
||||
"onBrokenMarkdownLinks": "log",
|
||||
"presets": [
|
||||
[
|
||||
"@docusaurus/preset-classic",
|
||||
{
|
||||
"docs": {
|
||||
"showLastUpdateAuthor": true,
|
||||
"showLastUpdateTime": true,
|
||||
"editUrl": "https://github.com/facebook/docusaurus/edit/main/docs/"
|
||||
},
|
||||
"blog": {},
|
||||
"theme": {
|
||||
"customCss": "../missing_version_website/src/css/customTheme.css"
|
||||
},
|
||||
"googleAnalytics": {
|
||||
"trackingID": "UA-44373548-31"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": [],
|
||||
"themeConfig": {
|
||||
"navbar": {
|
||||
"title": "Docusaurus",
|
||||
"logo": {
|
||||
"src": "img/docusaurus.svg"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"to": "docs/installation",
|
||||
"label": "Docs",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "docs/tutorial-setup",
|
||||
"label": "Tutorial",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "/users",
|
||||
"label": "Users",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"href": "https://github.com/facebook/docusaurus",
|
||||
"label": "GitHub",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
},
|
||||
"image": "img/docusaurus.png",
|
||||
"footer": {
|
||||
"links": [
|
||||
{
|
||||
"title": "Community",
|
||||
"items": [
|
||||
{
|
||||
"label": "Twitter",
|
||||
"to": "https://twitter.com/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"copyright": "Copyright © 2023 Facebook Inc.",
|
||||
"logo": {
|
||||
"src": "img/docusaurus_monochrome.svg"
|
||||
}
|
||||
},
|
||||
"algolia": {
|
||||
"apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c",
|
||||
"indexName": "docusaurus",
|
||||
"algoliaOptions": {
|
||||
"facetFilters": [
|
||||
"language:LANGUAGE",
|
||||
"version:VERSION"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "<CURRENT_VERSION>",
|
||||
"@docusaurus/preset-classic": "<CURRENT_VERSION>",
|
||||
"clsx": "^1.1.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_missing_version_site/src/css/customTheme.css",
|
||||
":root{
|
||||
--ifm-color-primary-lightest: #3CAD6E;
|
||||
--ifm-color-primary-lighter: #359962;
|
||||
--ifm-color-primary-light: #33925D;
|
||||
--ifm-color-primary: #2E8555;
|
||||
--ifm-color-primary-dark: #29784C;
|
||||
--ifm-color-primary-darker: #277148;
|
||||
--ifm-color-primary-darkest: #205D3B;
|
||||
}
|
||||
",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates simple website: copy 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/simple_website/website/pages/en",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/src/pages",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/simple_website/website/static",
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/static",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates simple website: mkdirp 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/src/pages",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`migration CLI migrates simple website: mkdirs 1`] = `[]`;
|
||||
|
||||
exports[`migration CLI migrates simple website: write 1`] = `
|
||||
[
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
],
|
||||
"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"
|
||||
},
|
||||
"onBrokenLinks": "log",
|
||||
"onBrokenMarkdownLinks": "log",
|
||||
"presets": [
|
||||
[
|
||||
"@docusaurus/preset-classic",
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"googleAnalytics": {
|
||||
"trackingID": "UA-44373548-31"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": [],
|
||||
"themeConfig": {
|
||||
"navbar": {
|
||||
"title": "Docusaurus",
|
||||
"logo": {
|
||||
"src": "img/docusaurus.svg"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"to": "docs/installation",
|
||||
"label": "Docs",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "docs/tutorial-setup",
|
||||
"label": "Tutorial",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"to": "/users",
|
||||
"label": "Users",
|
||||
"position": "left"
|
||||
},
|
||||
{
|
||||
"href": "https://github.com/facebook/docusaurus",
|
||||
"label": "GitHub",
|
||||
"position": "left"
|
||||
}
|
||||
]
|
||||
},
|
||||
"image": "img/docusaurus.png",
|
||||
"footer": {
|
||||
"links": [
|
||||
{
|
||||
"title": "Community",
|
||||
"items": [
|
||||
{
|
||||
"label": "Twitter",
|
||||
"to": "https://twitter.com/docusaurus"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"copyright": "Copyright © 2023 Facebook Inc.",
|
||||
"logo": {
|
||||
"src": "img/docusaurus_monochrome.svg"
|
||||
}
|
||||
},
|
||||
"algolia": {
|
||||
"apiKey": "3eb9507824b8be89e7a199ecaa1a9d2c",
|
||||
"indexName": "docusaurus",
|
||||
"algoliaOptions": {
|
||||
"facetFilters": [
|
||||
"language:LANGUAGE",
|
||||
"version:VERSION"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "<CURRENT_VERSION>",
|
||||
"@docusaurus/preset-classic": "<CURRENT_VERSION>",
|
||||
"clsx": "^1.1.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
}
|
||||
}",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/migrated_simple_site/src/css/customTheme.css",
|
||||
":root{
|
||||
--ifm-color-primary-lightest: #3CAD6E;
|
||||
--ifm-color-primary-lighter: #359962;
|
||||
--ifm-color-primary-light: #33925D;
|
||||
--ifm-color-primary: #2E8555;
|
||||
--ifm-color-primary-dark: #29784C;
|
||||
--ifm-color-primary-darker: #277148;
|
||||
--ifm-color-primary-darkest: #205D3B;
|
||||
}
|
||||
",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/simple_website/docs/api-commands.md",
|
||||
"---
|
||||
id: commands
|
||||
title: CLI Commands
|
||||
---
|
||||
## Doc
|
||||
",
|
||||
],
|
||||
[
|
||||
"<PROJECT_ROOT>/packages/docusaurus-migrate/src/__tests__/__fixtures__/simple_website/docs/api-doc-markdown.md",
|
||||
"---
|
||||
id: doc-markdown
|
||||
title: Markdown Features
|
||||
---
|
||||
## Doc
|
||||
",
|
||||
],
|
||||
]
|
||||
`;
|
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {shouldQuotifyFrontMatter} from '../frontMatter';
|
||||
|
||||
describe('shouldQuotifyFrontMatter', () => {
|
||||
it('works', () => {
|
||||
expect(shouldQuotifyFrontMatter(['id', 'value'])).toBe(false);
|
||||
expect(
|
||||
shouldQuotifyFrontMatter([
|
||||
'title',
|
||||
// cSpell:ignore sàáâãäåçèéêëìíîïðòóôõöùúûüýÿ
|
||||
"Some title front matter with allowed special chars like sàáâãäåçèéêëìíîïðòóôõöùúûüýÿ!;,=+-_?'`&#()[]§%€$",
|
||||
]),
|
||||
).toBe(false);
|
||||
|
||||
expect(shouldQuotifyFrontMatter(['title', 'Special char :'])).toBe(true);
|
||||
|
||||
expect(shouldQuotifyFrontMatter(['title', 'value!'])).toBe(false);
|
||||
expect(shouldQuotifyFrontMatter(['title', '!value'])).toBe(true);
|
||||
|
||||
expect(shouldQuotifyFrontMatter(['tags', '[tag1, tag2]'])).toBe(false);
|
||||
});
|
||||
});
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {jest} from '@jest/globals';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import {posixPath} from '@docusaurus/utils';
|
||||
import {migrateDocusaurusProject} from '../index';
|
||||
|
||||
async function testMigration(siteDir: string, newDir: string) {
|
||||
const writeMock = jest.spyOn(fs, 'outputFile').mockImplementation(() => {});
|
||||
const mkdirpMock = jest.spyOn(fs, 'mkdirp').mockImplementation(() => {});
|
||||
const mkdirsMock = jest.spyOn(fs, 'mkdirs').mockImplementation(() => {});
|
||||
const copyMock = jest.spyOn(fs, 'copy').mockImplementation(() => {});
|
||||
await migrateDocusaurusProject(siteDir, newDir, true, true);
|
||||
expect(
|
||||
writeMock.mock.calls.sort((a, b) =>
|
||||
posixPath(a[0]).localeCompare(posixPath(b[0])),
|
||||
),
|
||||
).toMatchSnapshot('write');
|
||||
expect(
|
||||
mkdirpMock.mock.calls.sort((a, b) =>
|
||||
posixPath(a[0]).localeCompare(posixPath(b[0])),
|
||||
),
|
||||
).toMatchSnapshot('mkdirp');
|
||||
expect(
|
||||
mkdirsMock.mock.calls.sort((a, b) =>
|
||||
posixPath(a[0]).localeCompare(posixPath(b[0])),
|
||||
),
|
||||
).toMatchSnapshot('mkdirs');
|
||||
expect(
|
||||
copyMock.mock.calls.sort((a, b) =>
|
||||
posixPath(a[0]).localeCompare(posixPath(b[0])),
|
||||
),
|
||||
).toMatchSnapshot('copy');
|
||||
writeMock.mockRestore();
|
||||
mkdirpMock.mockRestore();
|
||||
mkdirsMock.mockRestore();
|
||||
copyMock.mockRestore();
|
||||
}
|
||||
|
||||
describe('migration CLI', () => {
|
||||
const fixtureDir = path.join(__dirname, '__fixtures__');
|
||||
it('migrates simple website', async () => {
|
||||
const siteDir = path.join(fixtureDir, 'simple_website', 'website');
|
||||
const newDir = path.join(fixtureDir, 'migrated_simple_site');
|
||||
await testMigration(siteDir, newDir);
|
||||
});
|
||||
|
||||
it('migrates complex website', async () => {
|
||||
const siteDir = path.join(fixtureDir, 'complex_website', 'website');
|
||||
const newDir = path.join(fixtureDir, 'migrated_complex_site');
|
||||
await testMigration(siteDir, newDir);
|
||||
});
|
||||
|
||||
it('migrates missing versions', async () => {
|
||||
const siteDir = path.join(fixtureDir, 'missing_version_website', 'website');
|
||||
const newDir = path.join(fixtureDir, 'migrated_missing_version_site');
|
||||
await testMigration(siteDir, newDir);
|
||||
});
|
||||
});
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import importFresh from 'import-fresh';
|
||||
import {createConfigFile} from '../index';
|
||||
import type {VersionOneConfig} from '../types';
|
||||
|
||||
describe('create config', () => {
|
||||
it('simple test', () => {
|
||||
const v1Config: VersionOneConfig = importFresh(
|
||||
`${__dirname}/__fixtures__/sourceSiteConfig.js`,
|
||||
);
|
||||
const siteDir = 'website';
|
||||
const newDir = 'websiteMigrated';
|
||||
|
||||
const result = createConfigFile({v1Config, siteDir, newDir});
|
||||
|
||||
const output = importFresh(
|
||||
`${__dirname}/__fixtures__/expectedSiteConfig.js`,
|
||||
);
|
||||
expect(result).toEqual(output);
|
||||
});
|
||||
});
|
18
packages/docusaurus-migrate/src/deps.d.ts
vendored
18
packages/docusaurus-migrate/src/deps.d.ts
vendored
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
declare module '@mapbox/hast-util-to-jsx' {
|
||||
import type {Node} from 'unist';
|
||||
|
||||
export default function toJsx(node: Node): string;
|
||||
}
|
||||
|
||||
declare module 'hast-util-to-string' {
|
||||
import type {Node} from 'unist';
|
||||
|
||||
export default function toString(node: Node): string;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import type {RawData, Data} from './types';
|
||||
|
||||
function splitHeader(content: string): RawData {
|
||||
// New line characters need to handle all operating systems.
|
||||
const lines = content.split(/\r?\n/);
|
||||
if (lines[0] !== '---') {
|
||||
return {};
|
||||
}
|
||||
let i = 1;
|
||||
for (; i < lines.length - 1; i = 1 + i) {
|
||||
if (lines[i] === '---') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
header: lines.slice(1, i + 1).join('\n'),
|
||||
content: lines.slice(i + 1).join('\n'),
|
||||
};
|
||||
}
|
||||
|
||||
export default function extractMetadata(content: string): Data {
|
||||
const metadata: {[key: string]: string} = {};
|
||||
const both = splitHeader(content);
|
||||
if (!both.content) {
|
||||
if (!both.header) {
|
||||
return {metadata, rawContent: content};
|
||||
}
|
||||
return {metadata, rawContent: both.header};
|
||||
}
|
||||
|
||||
// New line characters => to handle all operating systems.
|
||||
const lines = (both.header ?? '').split(/\r?\n/);
|
||||
lines.slice(0, -1).forEach((line) => {
|
||||
const keyValue = line.split(':') as [string, ...string[]];
|
||||
const key = keyValue[0].trim();
|
||||
const value = keyValue.slice(1).join(':').trim();
|
||||
metadata[key] = value;
|
||||
});
|
||||
return {metadata, rawContent: both.content};
|
||||
}
|
||||
|
||||
// The new front matter parser need some special chars to
|
||||
export function shouldQuotifyFrontMatter([key, value]: [
|
||||
string,
|
||||
string,
|
||||
]): boolean {
|
||||
if (key === 'tags') {
|
||||
return false;
|
||||
}
|
||||
if (String(value).match(/^(?<quote>["']).+\1$/)) {
|
||||
return false;
|
||||
}
|
||||
// title: !something needs quotes because otherwise it's a YAML tag.
|
||||
if (!String(value).trim().match(/^\w.*/)) {
|
||||
return true;
|
||||
}
|
||||
// TODO this is not ideal to have to maintain such a list of allowed chars
|
||||
// maybe we should quotify if gray-matter throws instead?
|
||||
return !String(value).match(
|
||||
// cSpell:ignore àáâãäåçèéêëìíîïðòóôõöùúûüýÿ
|
||||
/^[\w .\-àáâãäåçèéêëìíîïðòóôõöùúûüýÿ!;,=+?'`&#()[\]§%€$]+$/,
|
||||
);
|
||||
}
|
|
@ -1,763 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import logger from '@docusaurus/logger';
|
||||
import {Globby, DOCUSAURUS_VERSION} from '@docusaurus/utils';
|
||||
import Color from 'color';
|
||||
|
||||
import extractMetadata, {shouldQuotifyFrontMatter} from './frontMatter';
|
||||
import migratePage from './transform';
|
||||
import sanitizeMD from './sanitizeMD';
|
||||
|
||||
import type {
|
||||
SidebarEntry,
|
||||
SidebarEntries,
|
||||
VersionOneConfig,
|
||||
VersionTwoConfig,
|
||||
} from './types';
|
||||
|
||||
async function walk(dir: string): Promise<string[]> {
|
||||
const results: string[] = [];
|
||||
const list = await fs.readdir(dir);
|
||||
for (const file of list) {
|
||||
const fullPath = `${dir}/${file}`;
|
||||
const stat = await fs.stat(fullPath);
|
||||
if (stat.isDirectory()) {
|
||||
results.push(...(await walk(fullPath)));
|
||||
} else {
|
||||
results.push(fullPath);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
async function sanitizedFileContent(
|
||||
content: string,
|
||||
migrateMDFiles: boolean,
|
||||
): Promise<string> {
|
||||
const extractedData = extractMetadata(content);
|
||||
const extractedMetaData = Object.entries(extractedData.metadata)
|
||||
.map(
|
||||
([key, value]) =>
|
||||
`${key}: ${
|
||||
shouldQuotifyFrontMatter([key, value]) ? `"${value}"` : value
|
||||
}`,
|
||||
)
|
||||
.join('\n');
|
||||
const sanitizedData = `---
|
||||
${extractedMetaData}
|
||||
---
|
||||
${
|
||||
migrateMDFiles
|
||||
? await sanitizeMD(extractedData.rawContent)
|
||||
: extractedData.rawContent
|
||||
}`;
|
||||
return sanitizedData;
|
||||
}
|
||||
|
||||
type MigrationContext = {
|
||||
siteDir: string;
|
||||
newDir: string;
|
||||
deps: {[key: string]: string};
|
||||
shouldMigrateMdFiles: boolean;
|
||||
shouldMigratePages: boolean;
|
||||
v1Config: VersionOneConfig;
|
||||
v2Config: VersionTwoConfig;
|
||||
};
|
||||
|
||||
export async function migrateDocusaurusProject(
|
||||
siteDir: string,
|
||||
newDir: string,
|
||||
shouldMigrateMdFiles: boolean = false,
|
||||
shouldMigratePages: boolean = false,
|
||||
): Promise<void> {
|
||||
async function createMigrationContext(): Promise<MigrationContext> {
|
||||
const v1Config = (await import(`${siteDir}/siteConfig.js`))
|
||||
.default as VersionOneConfig;
|
||||
logger.info('Starting migration from v1 to v2...');
|
||||
const deps = {
|
||||
'@docusaurus/core': DOCUSAURUS_VERSION,
|
||||
'@docusaurus/preset-classic': DOCUSAURUS_VERSION,
|
||||
clsx: '^1.1.1',
|
||||
react: '^17.0.2',
|
||||
'react-dom': '^17.0.2',
|
||||
};
|
||||
const partialMigrationContext = {
|
||||
siteDir,
|
||||
newDir,
|
||||
deps,
|
||||
shouldMigrateMdFiles,
|
||||
shouldMigratePages,
|
||||
v1Config,
|
||||
};
|
||||
const v2Config = createConfigFile(partialMigrationContext);
|
||||
return {
|
||||
...partialMigrationContext,
|
||||
v2Config,
|
||||
};
|
||||
}
|
||||
|
||||
const migrationContext = await createMigrationContext();
|
||||
let errorCount = 0;
|
||||
try {
|
||||
createClientRedirects(migrationContext);
|
||||
logger.success('Created client redirect for non clean URL');
|
||||
} catch (err) {
|
||||
logger.error(`Failed to creating redirects: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
if (shouldMigratePages) {
|
||||
try {
|
||||
await createPages(migrationContext);
|
||||
logger.success(
|
||||
'Created new doc pages (check migration page for more details)',
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to create new doc pages: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await createDefaultLandingPage(migrationContext);
|
||||
logger.success(
|
||||
'Created landing page (check migration page for more details)',
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to create landing page: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await migrateStaticFiles(migrationContext);
|
||||
logger.success('Migrated static folder');
|
||||
} catch (err) {
|
||||
logger.error(`Failed to copy static folder: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
try {
|
||||
await migrateBlogFiles(migrationContext);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to migrate blogs: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
try {
|
||||
await handleVersioning(migrationContext);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to migrate versioned docs: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
|
||||
try {
|
||||
await migrateLatestDocs(migrationContext);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to migrate docs: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
|
||||
try {
|
||||
await migrateLatestSidebar(migrationContext);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to migrate sidebar: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.outputFile(
|
||||
path.join(newDir, 'docusaurus.config.js'),
|
||||
`module.exports=${JSON.stringify(migrationContext.v2Config, null, 2)}`,
|
||||
);
|
||||
logger.success(
|
||||
`Created a new config file with new navbar and footer config`,
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to create config file: ${err}`);
|
||||
errorCount += 1;
|
||||
}
|
||||
try {
|
||||
await migratePackageFile(migrationContext);
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`Error occurred while creating package.json file for project: ${err}`,
|
||||
);
|
||||
errorCount += 1;
|
||||
}
|
||||
if (errorCount) {
|
||||
logger.warn`Migration from v1 to v2 failed with number=${errorCount} errors: please check the log above`;
|
||||
} else {
|
||||
logger.success('Completed migration from v1 to v2');
|
||||
}
|
||||
}
|
||||
|
||||
export function createConfigFile({
|
||||
v1Config,
|
||||
siteDir,
|
||||
newDir,
|
||||
}: Pick<
|
||||
MigrationContext,
|
||||
'v1Config' | 'siteDir' | 'newDir'
|
||||
>): VersionTwoConfig {
|
||||
const siteConfig = v1Config;
|
||||
const customConfigFields: {[key: string]: unknown} = {};
|
||||
// Add fields that are unknown to v2 to customConfigFields
|
||||
Object.keys(siteConfig).forEach((key) => {
|
||||
const knownFields = [
|
||||
'title',
|
||||
'tagline',
|
||||
'url',
|
||||
'baseUrl',
|
||||
'organizationName',
|
||||
'projectName',
|
||||
'scripts',
|
||||
'stylesheets',
|
||||
'favicon',
|
||||
'cname',
|
||||
'noIndex',
|
||||
'headerLinks',
|
||||
'headerIcon',
|
||||
'footerIcon',
|
||||
'algolia',
|
||||
'colors',
|
||||
'copyright',
|
||||
'editUrl',
|
||||
'customDocsPath',
|
||||
'facebookComments',
|
||||
'usePrism',
|
||||
'highlight',
|
||||
'twitterUsername',
|
||||
'scrollToTopOptions',
|
||||
'twitter',
|
||||
'twitterImage',
|
||||
'onPageNav',
|
||||
'cleanUrl',
|
||||
'ogImage',
|
||||
'scrollToTop',
|
||||
'enableUpdateTime',
|
||||
'enableUpdateBy',
|
||||
'docsSideNavCollapsible',
|
||||
'gaTrackingId',
|
||||
'gaGtag',
|
||||
];
|
||||
const value = siteConfig[key as keyof typeof siteConfig];
|
||||
if (value !== undefined && !knownFields.includes(key)) {
|
||||
customConfigFields[key] = value;
|
||||
}
|
||||
});
|
||||
logger.info`Following Fields from path=${'siteConfig.js'} will be added to path=${'docusaurus.config.js'} in code=${'customFields'}: ${Object.keys(
|
||||
customConfigFields,
|
||||
)}`;
|
||||
|
||||
let v2DocsPath: string | undefined;
|
||||
if (siteConfig.customDocsPath) {
|
||||
const absoluteDocsPath = path.resolve(
|
||||
siteDir,
|
||||
'..',
|
||||
siteConfig.customDocsPath,
|
||||
);
|
||||
v2DocsPath = path.relative(newDir, absoluteDocsPath);
|
||||
}
|
||||
|
||||
return {
|
||||
title: siteConfig.title ?? '',
|
||||
tagline: siteConfig.tagline,
|
||||
url: siteConfig.url ?? '',
|
||||
baseUrl: siteConfig.baseUrl ?? '',
|
||||
organizationName: siteConfig.organizationName,
|
||||
projectName: siteConfig.projectName,
|
||||
noIndex: siteConfig.noIndex,
|
||||
scripts: siteConfig.scripts,
|
||||
stylesheets: siteConfig.stylesheets,
|
||||
favicon: siteConfig.favicon ?? '',
|
||||
customFields: customConfigFields,
|
||||
onBrokenLinks: 'log',
|
||||
onBrokenMarkdownLinks: 'log',
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
docs: {
|
||||
...(v2DocsPath && {path: v2DocsPath}),
|
||||
showLastUpdateAuthor: true,
|
||||
showLastUpdateTime: true,
|
||||
editUrl: siteConfig.editUrl,
|
||||
},
|
||||
blog: {},
|
||||
theme: {},
|
||||
...(() => {
|
||||
if (siteConfig.gaTrackingId) {
|
||||
if (siteConfig.gaGtag) {
|
||||
return {gtag: {trackingID: siteConfig.gaTrackingId}};
|
||||
}
|
||||
return {googleAnalytics: {trackingID: siteConfig.gaTrackingId}};
|
||||
}
|
||||
return undefined;
|
||||
})(),
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [],
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
title: siteConfig.title,
|
||||
logo: siteConfig.headerIcon
|
||||
? {
|
||||
src: siteConfig.headerIcon,
|
||||
}
|
||||
: undefined,
|
||||
items: (siteConfig.headerLinks ?? [])
|
||||
.map((link) => {
|
||||
const {doc, href, label, page} = link;
|
||||
const position = 'left';
|
||||
if (doc) {
|
||||
return {
|
||||
to: `docs/${doc}`,
|
||||
label,
|
||||
position,
|
||||
};
|
||||
}
|
||||
if (page) {
|
||||
return {
|
||||
to: `/${page}`,
|
||||
label,
|
||||
position,
|
||||
};
|
||||
}
|
||||
if (href) {
|
||||
return {href, label, position};
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean),
|
||||
},
|
||||
image: siteConfig.ogImage ? siteConfig.ogImage : undefined,
|
||||
footer: {
|
||||
links: siteConfig.twitterUsername
|
||||
? [
|
||||
{
|
||||
title: 'Community',
|
||||
items: [
|
||||
{
|
||||
label: 'Twitter',
|
||||
to: `https://twitter.com/${siteConfig.twitterUsername}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
: [],
|
||||
copyright: siteConfig.copyright,
|
||||
logo: {
|
||||
src: siteConfig.footerIcon,
|
||||
},
|
||||
},
|
||||
algolia: siteConfig.algolia ? siteConfig.algolia : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function createClientRedirects(context: MigrationContext): void {
|
||||
if (!context.v1Config.cleanUrl) {
|
||||
context.deps['@docusaurus/plugin-client-redirects'] = DOCUSAURUS_VERSION;
|
||||
context.v2Config.plugins.push([
|
||||
'@docusaurus/plugin-client-redirects',
|
||||
{fromExtensions: ['html']},
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
async function createPages(context: MigrationContext) {
|
||||
const {newDir, siteDir} = context;
|
||||
await fs.mkdirp(path.join(newDir, 'src', 'pages'));
|
||||
if (await fs.pathExists(path.join(siteDir, 'pages', 'en'))) {
|
||||
try {
|
||||
await fs.copy(
|
||||
path.join(siteDir, 'pages', 'en'),
|
||||
path.join(newDir, 'src', 'pages'),
|
||||
);
|
||||
const files = await Globby('**/*.js', {
|
||||
cwd: path.join(newDir, 'src', 'pages'),
|
||||
});
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
const filePath = path.join(newDir, 'src', 'pages', file);
|
||||
const content = await fs.readFile(filePath, 'utf-8');
|
||||
await fs.outputFile(filePath, migratePage(content));
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(`Unable to migrate Pages: ${err}`);
|
||||
await createDefaultLandingPage(context);
|
||||
}
|
||||
} else {
|
||||
logger.info('Ignoring Pages');
|
||||
}
|
||||
}
|
||||
|
||||
async function createDefaultLandingPage({newDir}: MigrationContext) {
|
||||
const indexPage = `import Layout from "@theme/Layout";
|
||||
import React from "react";
|
||||
|
||||
export default () => {
|
||||
return <Layout />;
|
||||
};
|
||||
`;
|
||||
await fs.outputFile(`${newDir}/src/pages/index.js`, indexPage);
|
||||
}
|
||||
|
||||
async function migrateStaticFiles({siteDir, newDir}: MigrationContext) {
|
||||
if (await fs.pathExists(path.join(siteDir, 'static'))) {
|
||||
await fs.copy(path.join(siteDir, 'static'), path.join(newDir, 'static'));
|
||||
} else {
|
||||
await fs.mkdir(path.join(newDir, 'static'));
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateBlogFiles(context: MigrationContext) {
|
||||
const {siteDir, newDir, shouldMigrateMdFiles} = context;
|
||||
if (await fs.pathExists(path.join(siteDir, 'blog'))) {
|
||||
await fs.copy(path.join(siteDir, 'blog'), path.join(newDir, 'blog'));
|
||||
const files = await walk(path.join(newDir, 'blog'));
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
const content = await fs.readFile(file, 'utf-8');
|
||||
await fs.outputFile(
|
||||
file,
|
||||
await sanitizedFileContent(content, shouldMigrateMdFiles),
|
||||
);
|
||||
}),
|
||||
);
|
||||
context.v2Config.presets[0][1].blog.path = 'blog';
|
||||
logger.success('Migrated blogs to version 2 with change in front matter');
|
||||
} else {
|
||||
logger.warn('Blog not found. Skipping migration for blog');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleVersioning(context: MigrationContext) {
|
||||
const {siteDir, newDir} = context;
|
||||
if (await fs.pathExists(path.join(siteDir, 'versions.json'))) {
|
||||
const loadedVersions = (await fs.readJSON(
|
||||
path.join(siteDir, 'versions.json'),
|
||||
)) as string[];
|
||||
await fs.copyFile(
|
||||
path.join(siteDir, 'versions.json'),
|
||||
path.join(newDir, 'versions.json'),
|
||||
);
|
||||
const versions = loadedVersions.reverse();
|
||||
const versionRegex = new RegExp(`version-(${versions.join('|')})-`, 'gim');
|
||||
await migrateVersionedSidebar(context, versions, versionRegex);
|
||||
await fs.mkdirp(path.join(newDir, 'versioned_docs'));
|
||||
await migrateVersionedDocs(context, versions, versionRegex);
|
||||
logger.success`Migrated version docs and sidebar. The following doc versions have been created:name=${loadedVersions}`;
|
||||
} else {
|
||||
logger.warn(
|
||||
'Versioned docs not found. Skipping migration for versioned docs',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateVersionedDocs(
|
||||
context: MigrationContext,
|
||||
versions: string[],
|
||||
versionRegex: RegExp,
|
||||
) {
|
||||
const {siteDir, newDir, shouldMigrateMdFiles} = context;
|
||||
await Promise.all(
|
||||
versions.reverse().map(async (version, index) => {
|
||||
if (index === 0) {
|
||||
await fs.copy(
|
||||
path.join(siteDir, '..', context.v1Config.customDocsPath ?? 'docs'),
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(siteDir, 'versioned_docs', `version-${version}`),
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await fs.mkdirs(
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(
|
||||
newDir,
|
||||
'versioned_docs',
|
||||
`version-${versions[index - 1]!}`,
|
||||
),
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(siteDir, 'versioned_docs', `version-${version}`),
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
} catch {
|
||||
await fs.copy(
|
||||
path.join(
|
||||
newDir,
|
||||
'versioned_docs',
|
||||
`version-${versions[index - 1]!}`,
|
||||
),
|
||||
path.join(newDir, 'versioned_docs', `version-${version}`),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
const files = await walk(path.join(newDir, 'versioned_docs'));
|
||||
await Promise.all(
|
||||
files.map(async (pathToFile) => {
|
||||
if (path.extname(pathToFile) === '.md') {
|
||||
const content = await fs.readFile(pathToFile, 'utf-8');
|
||||
await fs.outputFile(
|
||||
pathToFile,
|
||||
await sanitizedFileContent(
|
||||
content.replace(versionRegex, ''),
|
||||
shouldMigrateMdFiles,
|
||||
),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function migrateVersionedSidebar(
|
||||
context: MigrationContext,
|
||||
versions: string[],
|
||||
versionRegex: RegExp,
|
||||
) {
|
||||
const {siteDir, newDir} = context;
|
||||
if (await fs.pathExists(path.join(siteDir, 'versioned_sidebars'))) {
|
||||
await fs.mkdirp(path.join(newDir, 'versioned_sidebars'));
|
||||
const sidebars: {
|
||||
entries: SidebarEntries;
|
||||
version: string;
|
||||
}[] = [];
|
||||
// Order matters: if a sidebar file doesn't exist, we have to use the
|
||||
// previous version's
|
||||
for (let i = 0; i < versions.length; i += 1) {
|
||||
const version = versions[i]!;
|
||||
let sidebarEntries: SidebarEntries;
|
||||
const sidebarPath = path.join(
|
||||
siteDir,
|
||||
'versioned_sidebars',
|
||||
`version-${version}-sidebars.json`,
|
||||
);
|
||||
try {
|
||||
sidebarEntries = (await fs.readJSON(sidebarPath)) as SidebarEntries;
|
||||
} catch {
|
||||
sidebars.push({version, entries: sidebars[i - 1]!.entries});
|
||||
return;
|
||||
}
|
||||
const newSidebar = Object.entries(sidebarEntries).reduce(
|
||||
(topLevel: SidebarEntries, value) => {
|
||||
const key = value[0].replace(versionRegex, '');
|
||||
topLevel[key] = Object.entries(value[1]).reduce<{
|
||||
[key: string]: (string | {[key: string]: unknown})[];
|
||||
}>((acc, val) => {
|
||||
acc[val[0].replace(versionRegex, '')] = (
|
||||
val[1] as SidebarEntry[]
|
||||
).map((item) => {
|
||||
if (typeof item === 'string') {
|
||||
return item.replace(versionRegex, '');
|
||||
}
|
||||
return {
|
||||
type: 'category',
|
||||
label: item.label,
|
||||
ids: item.ids.map((id) => id.replace(versionRegex, '')),
|
||||
};
|
||||
});
|
||||
return acc;
|
||||
}, {});
|
||||
return topLevel;
|
||||
},
|
||||
{},
|
||||
);
|
||||
sidebars.push({version, entries: newSidebar});
|
||||
}
|
||||
await Promise.all(
|
||||
sidebars.map(async (sidebar) => {
|
||||
const newSidebar = Object.entries(
|
||||
sidebar.entries,
|
||||
).reduce<SidebarEntries>((acc, val) => {
|
||||
const key = `version-${sidebar.version}/${val[0]}`;
|
||||
acc[key] = Object.entries(val[1]).map((value) => ({
|
||||
type: 'category',
|
||||
label: value[0],
|
||||
items: (value[1] as SidebarEntry[]).map((sidebarItem) => {
|
||||
if (typeof sidebarItem === 'string') {
|
||||
return {
|
||||
type: 'doc',
|
||||
id: `version-${sidebar.version}/${sidebarItem}`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: 'category',
|
||||
label: sidebarItem.label,
|
||||
items: sidebarItem.ids.map((id) => ({
|
||||
type: 'doc',
|
||||
id: `version-${sidebar.version}/${id}`,
|
||||
})),
|
||||
};
|
||||
}),
|
||||
}));
|
||||
return acc;
|
||||
}, {});
|
||||
await fs.outputFile(
|
||||
path.join(
|
||||
newDir,
|
||||
'versioned_sidebars',
|
||||
`version-${sidebar.version}-sidebars.json`,
|
||||
),
|
||||
JSON.stringify(newSidebar, null, 2),
|
||||
);
|
||||
}),
|
||||
);
|
||||
context.v2Config.themeConfig.navbar.items.push({
|
||||
label: 'Version',
|
||||
to: 'docs',
|
||||
position: 'right',
|
||||
items: [
|
||||
{
|
||||
label: versions[versions.length - 1],
|
||||
to: 'docs/',
|
||||
activeBaseRegex: `docs/(?!${versions.join('|')}|next)`,
|
||||
},
|
||||
...versions
|
||||
.reverse()
|
||||
.slice(1)
|
||||
.map((version) => ({
|
||||
label: version,
|
||||
to: `docs/${version}/`,
|
||||
})),
|
||||
{
|
||||
label: 'Main/Unreleased',
|
||||
to: `docs/next/`,
|
||||
activeBaseRegex: `docs/next/(?!support|team|resources)`,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateLatestSidebar(context: MigrationContext) {
|
||||
const {siteDir, newDir} = context;
|
||||
try {
|
||||
await fs.copyFile(
|
||||
path.join(siteDir, 'sidebars.json'),
|
||||
path.join(newDir, 'sidebars.json'),
|
||||
);
|
||||
context.v2Config.presets[0][1].docs.sidebarPath = path.join(
|
||||
path.relative(newDir, siteDir),
|
||||
'sidebars.json',
|
||||
);
|
||||
} catch {
|
||||
logger.warn('Sidebar not found. Skipping migration for sidebar');
|
||||
}
|
||||
if (context.v1Config.colors) {
|
||||
const primaryColor = Color(context.v1Config.colors.primaryColor);
|
||||
const css = `:root{
|
||||
--ifm-color-primary-lightest: ${primaryColor.darken(-0.3).hex()};
|
||||
--ifm-color-primary-lighter: ${primaryColor.darken(-0.15).hex()};
|
||||
--ifm-color-primary-light: ${primaryColor.darken(-0.1).hex()};
|
||||
--ifm-color-primary: ${primaryColor.hex()};
|
||||
--ifm-color-primary-dark: ${primaryColor.darken(0.1).hex()};
|
||||
--ifm-color-primary-darker: ${primaryColor.darken(0.15).hex()};
|
||||
--ifm-color-primary-darkest: ${primaryColor.darken(0.3).hex()};
|
||||
}
|
||||
`;
|
||||
await fs.outputFile(
|
||||
path.join(newDir, 'src', 'css', 'customTheme.css'),
|
||||
css,
|
||||
);
|
||||
context.v2Config.presets[0][1].theme.customCss = path.join(
|
||||
path.relative(newDir, path.join(siteDir, '..')),
|
||||
'src/css/customTheme.css',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateLatestDocs(context: MigrationContext) {
|
||||
const {siteDir, newDir, shouldMigrateMdFiles} = context;
|
||||
if (await fs.pathExists(path.join(siteDir, '..', 'docs'))) {
|
||||
context.v2Config.presets[0][1].docs.path = path.join(
|
||||
path.relative(newDir, path.join(siteDir, '..')),
|
||||
'docs',
|
||||
);
|
||||
const files = await walk(path.join(siteDir, '..', 'docs'));
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
if (path.extname(file) === '.md') {
|
||||
const content = await fs.readFile(file, 'utf-8');
|
||||
await fs.outputFile(
|
||||
file,
|
||||
await sanitizedFileContent(content, shouldMigrateMdFiles),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
logger.success('Migrated docs to version 2');
|
||||
} else {
|
||||
logger.warn('Docs folder not found. Skipping migration for docs');
|
||||
}
|
||||
}
|
||||
|
||||
async function migratePackageFile(context: MigrationContext): Promise<void> {
|
||||
const {deps, siteDir, newDir} = context;
|
||||
// eslint-disable-next-line global-require, import/no-dynamic-require
|
||||
const packageFile = (await require(`${siteDir}/package.json`)) as {
|
||||
scripts?: {[key: string]: string};
|
||||
dependencies?: {[key: string]: string};
|
||||
devDependencies?: {[key: string]: string};
|
||||
[otherKey: string]: unknown;
|
||||
};
|
||||
packageFile.scripts = {
|
||||
...packageFile.scripts,
|
||||
start: 'docusaurus start',
|
||||
build: 'docusaurus build',
|
||||
swizzle: 'docusaurus swizzle',
|
||||
deploy: 'docusaurus deploy',
|
||||
docusaurus: 'docusaurus',
|
||||
};
|
||||
if (packageFile.dependencies) {
|
||||
delete packageFile.dependencies.docusaurus;
|
||||
}
|
||||
if (packageFile.devDependencies) {
|
||||
delete packageFile.devDependencies.docusaurus;
|
||||
}
|
||||
|
||||
packageFile.dependencies = {
|
||||
...packageFile.dependencies,
|
||||
...deps,
|
||||
};
|
||||
await fs.outputFile(
|
||||
path.join(newDir, 'package.json'),
|
||||
JSON.stringify(packageFile, null, 2),
|
||||
);
|
||||
logger.success('Migrated package.json file');
|
||||
}
|
||||
|
||||
export async function migrateMDToMDX(
|
||||
siteDir: string,
|
||||
newDir: string,
|
||||
): Promise<void> {
|
||||
await fs.mkdirp(newDir);
|
||||
await fs.copy(siteDir, newDir);
|
||||
const files = await walk(newDir);
|
||||
await Promise.all(
|
||||
files.map(async (filePath) => {
|
||||
if (path.extname(filePath) === '.md') {
|
||||
const content = await fs.readFile(filePath, 'utf-8');
|
||||
await fs.outputFile(
|
||||
filePath,
|
||||
await sanitizedFileContent(content, true),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
logger.success`Successfully migrated path=${siteDir} to path=${newDir}`;
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import markdown from 'remark-parse';
|
||||
import toJsx from '@mapbox/hast-util-to-jsx';
|
||||
import parse from 'rehype-parse';
|
||||
import visit from 'unist-util-visit';
|
||||
import remarkStringify from 'remark-stringify';
|
||||
import htmlTags from 'html-tags';
|
||||
import toText from 'hast-util-to-string';
|
||||
import type {Code, InlineCode} from 'mdast';
|
||||
import type {Element, Text} from 'hast';
|
||||
|
||||
const tags = htmlTags.reduce((acc: {[key: string]: boolean}, tag) => {
|
||||
acc[tag] = true;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
export default async function sanitizeMD(code: string): Promise<string> {
|
||||
const {unified} = await import('unified');
|
||||
|
||||
const markdownTree = unified().use(markdown).parse(code);
|
||||
visit(markdownTree, 'code', (node: Code) => {
|
||||
node.value = `\n<!--${node.value}-->\n`;
|
||||
});
|
||||
visit(markdownTree, 'inlineCode', (node: InlineCode) => {
|
||||
node.value = `<!--${node.value}-->`;
|
||||
});
|
||||
|
||||
// @ts-expect-error: :/
|
||||
const markdownString: string = await unified()
|
||||
.use(remarkStringify, {fence: '`', fences: true})
|
||||
.stringify(markdownTree);
|
||||
|
||||
const htmlTree = unified().use(parse).parse(markdownString);
|
||||
|
||||
visit(htmlTree, 'element', (node: Element) => {
|
||||
if (!tags[node.tagName]) {
|
||||
(node as Element | Text).type = 'text';
|
||||
(node as Element & Partial<Omit<Text, 'type'>>).value =
|
||||
node.tagName + toText(node);
|
||||
delete (node as Partial<Element>).children;
|
||||
delete (node as Partial<Element>).tagName;
|
||||
}
|
||||
});
|
||||
|
||||
return toJsx(htmlTree)
|
||||
.replace(/\{\/\*|\*\/\}/g, '')
|
||||
.replace(/\{\/\*|\*\/\}/g, '')
|
||||
.replace(/<html><head \/><body>|<\/body><\/html>/g, '');
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import jscodeshift, {
|
||||
type ArrowFunctionExpression,
|
||||
AssignmentExpression,
|
||||
type ASTPath,
|
||||
type Collection,
|
||||
type TemplateElement,
|
||||
VariableDeclarator,
|
||||
type CallExpression,
|
||||
type MemberExpression,
|
||||
type Identifier,
|
||||
} from 'jscodeshift';
|
||||
|
||||
const empty = () =>
|
||||
jscodeshift.arrowFunctionExpression(
|
||||
[jscodeshift.identifier('props')],
|
||||
jscodeshift.jsxElement(
|
||||
jscodeshift.jsxOpeningElement(jscodeshift.jsxIdentifier('div'), [
|
||||
jscodeshift.jsxSpreadAttribute(jscodeshift.identifier('props')),
|
||||
]),
|
||||
jscodeshift.jsxClosingElement(jscodeshift.jsxIdentifier('div')),
|
||||
),
|
||||
);
|
||||
|
||||
const property = (key: string, value: ArrowFunctionExpression) =>
|
||||
jscodeshift.objectProperty(jscodeshift.identifier(key), value);
|
||||
|
||||
const processCallExpression = (node: ASTPath<VariableDeclarator>) => {
|
||||
const args = (node?.value?.init as CallExpression)?.arguments[0];
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
if (args.type === 'Literal') {
|
||||
if (
|
||||
typeof args.value === 'string' &&
|
||||
args.value.includes('../../core/CompLibrary')
|
||||
) {
|
||||
const newDeclarator = jscodeshift.variableDeclarator(
|
||||
node.value.id,
|
||||
jscodeshift.objectExpression([
|
||||
property('Container', empty()),
|
||||
property('GridBlock', empty()),
|
||||
property('MarkdownBlock', empty()),
|
||||
]),
|
||||
);
|
||||
jscodeshift(node).replaceWith(newDeclarator);
|
||||
}
|
||||
}
|
||||
if (args.type === 'TemplateLiteral') {
|
||||
if (
|
||||
args.quasis
|
||||
.map((element: TemplateElement) => element.value.raw)
|
||||
.join('')
|
||||
.match(/\/core\//)
|
||||
) {
|
||||
const newDeclarator = jscodeshift.variableDeclarator(
|
||||
node.value.id,
|
||||
empty(),
|
||||
);
|
||||
jscodeshift(node).replaceWith(newDeclarator);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const processMemberExpression = (node: ASTPath<VariableDeclarator>) => {
|
||||
const object = (node?.value?.init as MemberExpression)?.object;
|
||||
if (!(object.type === 'CallExpression')) {
|
||||
return;
|
||||
}
|
||||
const args = object.arguments[0];
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
if (args.type === 'Literal') {
|
||||
if (args.value === '../../core/CompLibrary.js') {
|
||||
const newDeclarator = jscodeshift.variableDeclarator(
|
||||
node.value.id,
|
||||
jscodeshift.objectExpression([
|
||||
property('Container', empty()),
|
||||
property('GridBlock', empty()),
|
||||
property('MarkdownBlock', empty()),
|
||||
]),
|
||||
);
|
||||
jscodeshift(node).replaceWith(newDeclarator);
|
||||
} else if (typeof args.value === 'string' && args.value.match(/server/)) {
|
||||
const newDeclarator = jscodeshift.variableDeclarator(
|
||||
node.value.id,
|
||||
empty(),
|
||||
);
|
||||
jscodeshift(node).replaceWith(newDeclarator);
|
||||
}
|
||||
}
|
||||
if (args.type === 'TemplateLiteral') {
|
||||
if (
|
||||
args.quasis
|
||||
.map((ele: TemplateElement) => ele.value.raw)
|
||||
.join('')
|
||||
.match(/\/core\//)
|
||||
) {
|
||||
const newDeclarator = jscodeshift.variableDeclarator(
|
||||
node.value.id,
|
||||
empty(),
|
||||
);
|
||||
jscodeshift(node).replaceWith(newDeclarator);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default function transformer(file: string): string {
|
||||
const root = jscodeshift(file);
|
||||
const r = getImportDeclaratorPaths(root);
|
||||
r.forEach((node) => {
|
||||
if (node?.value?.init?.type === 'CallExpression') {
|
||||
processCallExpression(node);
|
||||
} else if (node?.value?.init?.type === 'MemberExpression') {
|
||||
processMemberExpression(node);
|
||||
}
|
||||
});
|
||||
if (r[r.length - 1]) {
|
||||
jscodeshift(r[r.length - 1]!.parent).insertAfter(
|
||||
jscodeshift.importDeclaration(
|
||||
[jscodeshift.importDefaultSpecifier(jscodeshift.identifier('Layout'))],
|
||||
jscodeshift.literal('@theme/Layout'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
root
|
||||
.find(AssignmentExpression, {
|
||||
operator: '=',
|
||||
left: {
|
||||
type: 'MemberExpression',
|
||||
object: {
|
||||
name: 'module',
|
||||
},
|
||||
property: {
|
||||
name: 'exports',
|
||||
},
|
||||
},
|
||||
right: {
|
||||
type: 'Identifier',
|
||||
},
|
||||
})
|
||||
.filter((p) => p.parentPath.parentPath.name === 'body')
|
||||
.forEach((p) => {
|
||||
const exportDecl = jscodeshift.exportDeclaration(
|
||||
true,
|
||||
jscodeshift.arrowFunctionExpression(
|
||||
[jscodeshift.identifier('props')],
|
||||
jscodeshift.jsxElement(
|
||||
jscodeshift.jsxOpeningElement(
|
||||
jscodeshift.jsxIdentifier('Layout'),
|
||||
[],
|
||||
),
|
||||
jscodeshift.jsxClosingElement(jscodeshift.jsxIdentifier('Layout')),
|
||||
[
|
||||
jscodeshift.jsxElement(
|
||||
jscodeshift.jsxOpeningElement(
|
||||
jscodeshift.jsxIdentifier((p.value.right as Identifier).name),
|
||||
[
|
||||
jscodeshift.jsxSpreadAttribute(
|
||||
jscodeshift.identifier('props'),
|
||||
),
|
||||
],
|
||||
true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
exportDecl.comments = p.parentPath.value.comments;
|
||||
jscodeshift(p.parentPath).replaceWith(exportDecl);
|
||||
});
|
||||
return root.toSource();
|
||||
}
|
||||
|
||||
function getDefaultImportDeclarations(rootAst: Collection) {
|
||||
// var ... = require('y')
|
||||
return rootAst
|
||||
.find(VariableDeclarator, {
|
||||
init: {
|
||||
callee: {
|
||||
name: 'require',
|
||||
},
|
||||
},
|
||||
})
|
||||
.filter((variableDeclarator) => !!variableDeclarator.value);
|
||||
}
|
||||
|
||||
function getNamedImportDeclarations(rootAst: Collection) {
|
||||
// var ... = require('y').x
|
||||
return rootAst.find(VariableDeclarator, {
|
||||
init: {
|
||||
object: {
|
||||
callee: {
|
||||
name: 'require',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function getImportDeclaratorPaths(variableDeclaration: Collection) {
|
||||
const defaultImports = getDefaultImportDeclarations(variableDeclaration);
|
||||
|
||||
const namedImports = getNamedImportDeclarations(variableDeclaration);
|
||||
|
||||
return [...defaultImports.paths(), ...namedImports.paths()];
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
export type RawData = {
|
||||
header?: string;
|
||||
content?: string;
|
||||
};
|
||||
|
||||
export type Data = {
|
||||
metadata: {[key: string]: string};
|
||||
rawContent: string;
|
||||
};
|
||||
|
||||
export type ClassicPresetEntries = {
|
||||
docs: {[key: string]: unknown};
|
||||
blog: {[key: string]: unknown};
|
||||
gtag?: {trackingID: string} | undefined;
|
||||
googleAnalytics?: {trackingID: string} | undefined;
|
||||
theme: {[key: string]: unknown};
|
||||
};
|
||||
|
||||
export type SidebarEntry =
|
||||
| string
|
||||
| {
|
||||
type: string;
|
||||
label: string;
|
||||
ids: string[];
|
||||
};
|
||||
|
||||
export type SidebarEntries = {
|
||||
[key: string]:
|
||||
| {[key: string]: unknown}
|
||||
| ({[key: string]: unknown} | string)[];
|
||||
};
|
||||
|
||||
export type VersionTwoConfig = {
|
||||
baseUrl: string;
|
||||
favicon: string;
|
||||
tagline?: string;
|
||||
title: string;
|
||||
url: string;
|
||||
organizationName?: string;
|
||||
projectName?: string;
|
||||
noIndex?: boolean;
|
||||
githubHost?: string;
|
||||
onBrokenLinks: string;
|
||||
onBrokenMarkdownLinks: string;
|
||||
plugins: [string, {[key: string]: unknown}][];
|
||||
themes?: [];
|
||||
presets: [[string, ClassicPresetEntries]];
|
||||
themeConfig: {
|
||||
navbar: {
|
||||
title?: string;
|
||||
logo?: {
|
||||
src?: string;
|
||||
};
|
||||
items: ({[key: string]: unknown} | null)[];
|
||||
};
|
||||
image?: string;
|
||||
footer: {
|
||||
links: {
|
||||
title: string;
|
||||
items: {label: string; to: string}[];
|
||||
}[];
|
||||
copyright?: string;
|
||||
logo: {
|
||||
src?: string;
|
||||
};
|
||||
};
|
||||
algolia?: {[key: string]: unknown};
|
||||
};
|
||||
customFields: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
scripts?: (
|
||||
| string
|
||||
| {
|
||||
src: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
)[];
|
||||
stylesheets?: (
|
||||
| string
|
||||
| {
|
||||
href: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
)[];
|
||||
};
|
||||
|
||||
export type VersionOneConfig = {
|
||||
title?: string;
|
||||
tagline?: string;
|
||||
url?: string;
|
||||
baseUrl?: string;
|
||||
defaultVersionShown?: string;
|
||||
organizationName?: string;
|
||||
projectName?: string;
|
||||
noIndex?: boolean;
|
||||
headerLinks?: {doc: string; href: string; label: string; page: string}[];
|
||||
headerIcon?: string;
|
||||
favicon?: string;
|
||||
colors?: {primaryColor: string};
|
||||
copyright?: string;
|
||||
editUrl?: string;
|
||||
customDocsPath?: string;
|
||||
users?: {[key: string]: unknown}[];
|
||||
disableHeaderTitle?: string;
|
||||
disableTitleTagline?: string;
|
||||
separateCss?: {[key: string]: unknown}[];
|
||||
footerIcon?: string;
|
||||
translationRecruitingLink?: string;
|
||||
algolia?: {[key: string]: unknown};
|
||||
gaTrackingId?: string;
|
||||
gaGtag?: boolean;
|
||||
highlight?: {[key: string]: unknown};
|
||||
markdownPlugins?: (() => void)[];
|
||||
scripts?: ({src: string; [key: string]: unknown} | string)[];
|
||||
stylesheets?: ({href: string; [key: string]: unknown} | string)[];
|
||||
facebookAppId?: string;
|
||||
facebookComments?: true;
|
||||
facebookPixelId?: string;
|
||||
twitter?: string;
|
||||
twitterUsername?: string;
|
||||
twitterImage?: string;
|
||||
ogImage?: string;
|
||||
cleanUrl?: boolean;
|
||||
scrollToTop?: boolean;
|
||||
scrollToTopOptions?: {[key: string]: unknown};
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"composite": true,
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||
"rootDir": "src",
|
||||
"outDir": "lib"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["**/__tests__/**"]
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"references": [{"path": "./tsconfig.build.json"}],
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["bin"],
|
||||
"exclude": ["**/__tests__/**"]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue