chore: move to monorepo (#1297)
* chore: move to monorepo * lint all js file * simplify circleCI * fix failing tests * fix tests due to folder rename * fix test since v1 website is renamed
|
@ -14,40 +14,6 @@ aliases:
|
|||
- ~/.cache/yarn
|
||||
key: root-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
|
||||
- &v1-yarn |
|
||||
cd v1
|
||||
yarn install --non-interactive --cache-folder ~/.cache/yarn
|
||||
|
||||
- &v1-restore-yarn-cache
|
||||
keys:
|
||||
- v1-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
# Fallback in case checksum fails
|
||||
- v1-yarn-{{ .Branch }}-
|
||||
|
||||
- &v1-save-yarn-cache
|
||||
paths:
|
||||
- v1/node_modules
|
||||
- ~/.cache/yarn
|
||||
key: v1-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
|
||||
- &v2-yarn |
|
||||
cd v2
|
||||
yarn install --non-interactive --cache-folder ~/.cache/yarn
|
||||
cd ../v2-website
|
||||
yarn install --non-interactive --cache-folder ~/.cache/yarn
|
||||
|
||||
- &v2-restore-yarn-cache
|
||||
keys:
|
||||
- v2-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
# Fallback in case checksum fails
|
||||
- v2-yarn-{{ .Branch }}-
|
||||
|
||||
- &v2-save-yarn-cache
|
||||
paths:
|
||||
- v2/node_modules
|
||||
- ~/.cache/yarn
|
||||
key: v2-yarn-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
|
||||
- &filter-only-master
|
||||
branches:
|
||||
only:
|
||||
|
@ -65,45 +31,43 @@ defaults: &defaults
|
|||
|
||||
version: 2
|
||||
jobs:
|
||||
prettier:
|
||||
lint-prettier:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *root-restore-yarn-cache
|
||||
- run: *root-yarn
|
||||
- save-cache: *root-save-yarn-cache
|
||||
- run:
|
||||
name: Check ESLint
|
||||
command: yarn lint
|
||||
- run:
|
||||
name: Check Prettier
|
||||
command: |
|
||||
yarn install
|
||||
yarn prettier:diff
|
||||
command: yarn prettier:diff
|
||||
|
||||
v1-tests:
|
||||
tests:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *v1-restore-yarn-cache
|
||||
- run: *v1-yarn
|
||||
- save-cache: *v1-save-yarn-cache
|
||||
- run:
|
||||
name: Check ESLint
|
||||
command: cd v1 && yarn lint
|
||||
- restore-cache: *root-restore-yarn-cache
|
||||
- run: *root-yarn
|
||||
- save-cache: *root-save-yarn-cache
|
||||
- run:
|
||||
name: Run Test Suites
|
||||
command: cd v1 && yarn test
|
||||
command: yarn test
|
||||
- run:
|
||||
name: Test Static Website Builds
|
||||
command: cd v1/website && yarn build
|
||||
name: Test v1 static website Builds
|
||||
command: cd website-1.x && yarn build
|
||||
- run:
|
||||
name: Test v2 static website Builds
|
||||
command: cd website && yarn build
|
||||
|
||||
# The CIRCLE_ variables are defined during the CircleCI build process
|
||||
# https://circleci.com/docs/1.0/environment-variables/
|
||||
v1-deploy-website:
|
||||
deploy-website:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *v1-restore-yarn-cache
|
||||
- run: *v1-yarn
|
||||
- save-cache: *v1-save-yarn-cache
|
||||
- run:
|
||||
name: Configure GitHub Bot
|
||||
# Do not do this if we don't have the right org (facebook), or if this is just a pull request
|
||||
|
@ -120,7 +84,7 @@ jobs:
|
|||
if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
|
||||
echo "Deploying website..."
|
||||
# install Docusaurus and generate file of English strings
|
||||
cd v1 && yarn && cd website && yarn run write-translations
|
||||
cd website-1.x && yarn run write-translations
|
||||
# install Crowdin
|
||||
sudo apt-get update
|
||||
sudo apt-get install default-jre rsync
|
||||
|
@ -136,68 +100,20 @@ jobs:
|
|||
echo "Skipping deploy."
|
||||
fi
|
||||
|
||||
v2-tests:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *v2-restore-yarn-cache
|
||||
- run: *v2-yarn
|
||||
- save-cache: *v2-save-yarn-cache
|
||||
- run:
|
||||
name: Check ESLint
|
||||
command: cd v2 && yarn lint
|
||||
- run:
|
||||
name: Run Test Suites
|
||||
command: cd v2 && yarn test
|
||||
- run:
|
||||
name: Test Static Website Builds
|
||||
command: cd v2-website && yarn build
|
||||
|
||||
publish-npm:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *v1-restore-yarn-cache
|
||||
- run: *v1-yarn
|
||||
- save-cache: *v1-save-yarn-cache
|
||||
- ? run
|
||||
name: Publish Docusaurus Package
|
||||
command: |
|
||||
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
|
||||
echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
|
||||
node ./scripts/publish-npm.js
|
||||
else
|
||||
echo "Skipping publication."
|
||||
fi
|
||||
|
||||
# Workflows enables us to run multiple jobs in parallel
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
prettier:
|
||||
lint-prettier:
|
||||
jobs:
|
||||
- prettier:
|
||||
- lint-prettier:
|
||||
filters: *filter-ignore-gh-pages
|
||||
|
||||
v1:
|
||||
tests-and-deploy:
|
||||
jobs:
|
||||
- v1-tests:
|
||||
- tests:
|
||||
filters: *filter-ignore-gh-pages
|
||||
- v1-deploy-website:
|
||||
- deploy-website:
|
||||
requires:
|
||||
- v1-tests
|
||||
filters: *filter-only-master
|
||||
|
||||
v2:
|
||||
jobs:
|
||||
- v2-tests:
|
||||
filters: *filter-ignore-gh-pages
|
||||
|
||||
deploy:
|
||||
jobs:
|
||||
- hold:
|
||||
type: approval
|
||||
- publish-npm:
|
||||
requires:
|
||||
- hold
|
||||
filters: *filter-only-master
|
||||
- tests
|
||||
filters: *filter-only-master
|
9
.eslintignore
Normal file
|
@ -0,0 +1,9 @@
|
|||
__fixtures__
|
||||
dist
|
||||
node_modules
|
||||
build
|
||||
jest.config.js
|
||||
jest.transform.js
|
||||
website-1.x/
|
||||
website/
|
||||
scripts
|
|
@ -7,4 +7,8 @@
|
|||
|
||||
module.exports = {
|
||||
presets: ['@babel/env', '@babel/react'],
|
||||
plugins: [
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
'@babel/plugin-proposal-object-rest-spread',
|
||||
],
|
||||
};
|
22
jest.config.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
rootDir: path.resolve(__dirname),
|
||||
verbose: true,
|
||||
testURL: 'http://localhost/',
|
||||
testEnvironment: 'node',
|
||||
moduleNameMapper: {
|
||||
'^@lib/(.*)$': '<rootDir>/packages/docusaurus/lib/$1',
|
||||
},
|
||||
testPathIgnorePatterns: ['/node_modules/', '__fixtures__'],
|
||||
transform: {
|
||||
'^.+\\.js$': '<rootDir>/jest.transform.js',
|
||||
},
|
||||
};
|
6
lerna.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"lerna": "3.13.1",
|
||||
"version": "independent",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true
|
||||
}
|
43
package.json
|
@ -1,27 +1,42 @@
|
|||
{
|
||||
"keywords": ["documentation", "websites", "open source", "docusaurus"],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/Docusaurus.git"
|
||||
},
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"website",
|
||||
"website-1.x"
|
||||
],
|
||||
"scripts": {
|
||||
"lint:v1": "cd v1 && yarn lint",
|
||||
"lint:v2": "cd v2 && yarn lint",
|
||||
"prettier:v1": "cd v1 && yarn prettier",
|
||||
"prettier:v2": "cd v2 && yarn prettier",
|
||||
"prettier": "yarn prettier:v1 && yarn prettier:v2",
|
||||
"prettier": "prettier --config .prettierrc --write \"**/*.js\"",
|
||||
"prettier:diff": "prettier --config .prettierrc --list-different \"**/*.js\"",
|
||||
"start": "cd v1/website && yarn start"
|
||||
"lint": "eslint --cache \"**/*.js\"",
|
||||
"lerna": "lerna",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lerna": "^3.13.1",
|
||||
"husky": "^1.3.1",
|
||||
"lint-staged": "^7.2.0",
|
||||
"prettier": "^1.13.7"
|
||||
"prettier": "^1.13.7",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-eslint": "8",
|
||||
"eslint": "4.x",
|
||||
"eslint-config-airbnb": "17.1.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.3",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"eslint-plugin-react-hooks": "^0.0.0",
|
||||
"jest": "^24.1.0",
|
||||
"react": "^16.8.4",
|
||||
"react-dom": "^16.8.4",
|
||||
"filepath": "^1.1.0",
|
||||
"front-matter": "^2.3.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"glob-promise": "^3.3.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"linters": {
|
||||
"v1/**/*.js": ["yarn lint:v1 --fix", "yarn prettier:v1", "git add"],
|
||||
"v2/**/*.js": ["yarn lint:v2 --fix", "yarn prettier:v2", "git add"]
|
||||
"*.js": ["yarn lint --fix", "yarn prettier", "git add"]
|
||||
}
|
||||
},
|
||||
"husky": {
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/docusaurus"><a href="#backers" alt="sponsors on Open Collective"><img src="https://opencollective.com/Docusaurus/backers/badge.svg" /></a> <a href="#sponsors" alt="Sponsors on Open Collective"><img src="https://opencollective.com/Docusaurus/sponsors/badge.svg" /></a> <img src="https://img.shields.io/npm/v/docusaurus.svg?style=flat" alt="npm version"></a>
|
||||
<a href="#backers" alt="sponsors on Open Collective"><img src="https://opencollective.com/Docusaurus/backers/badge.svg" /></a>
|
||||
<a href="#sponsors" alt="Sponsors on Open Collective"><img src="https://opencollective.com/Docusaurus/sponsors/badge.svg" /></a>
|
||||
<a href="https://www.npmjs.com/package/docusaurus"><img src="https://img.shields.io/npm/v/docusaurus.svg?style=flat" alt="npm version"></a>
|
||||
<a href="https://circleci.com/gh/facebook/Docusaurus"><img src="https://circleci.com/gh/facebook/Docusaurus.svg?style=shield" alt="CircleCI Status"></a>
|
||||
<a href="CONTRIBUTING.md#pull-requests"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome"></a>
|
||||
<a href="https://discord.gg/docusaurus"><img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg" alt="Chat"></a>
|
||||
<a href="https://github.com/prettier/prettier"><img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a>
|
||||
<a href="https://github.com/facebook/jest"><img src="https://img.shields.io/badge/tested_with-jest-99424f.svg" alt="Tested with Jest"></a>
|
||||
<a href="https://app.netlify.com/sites/docusaurus-preview/deploys"><img src="https://api.netlify.com/api/v1/badges/57ebb454-c937-4c1d-a228-d9dccb494f49/deploy-status" alt="Netlify Status"></a>
|
||||
</p>
|
||||
|
||||
## Introduction
|
||||
|
@ -26,6 +29,22 @@ Docusaurus is available as the [`docusaurus` package](https://www.npmjs.com/pack
|
|||
|
||||
We have also released the [`docusaurus-init` package](https://www.npmjs.com/package/docusaurus-init) to make [getting started](https://docusaurus.io/docs/en/installation.html) with Docusaurus even easier.
|
||||
|
||||
## Contributing
|
||||
|
||||
We've released Docusaurus because it helps us better scale and support the many OSS projects at Facebook. We hope that other organizations can benefit from the project. We are thankful for any contributions from the community.
|
||||
|
||||
### [Code of Conduct](https://code.fb.com/codeofconduct)
|
||||
|
||||
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
|
||||
|
||||
### Contributing Guide
|
||||
|
||||
Read our [contributing guide](https://github.com/facebook/Docusaurus/blob/master/CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Docusaurus.
|
||||
|
||||
### Beginner Friendly Bugs
|
||||
|
||||
To help you get your feet wet and get you familiar with our contribution process, we have a list of [beginner friendly bugs](https://github.com/facebook/Docusaurus/labels/good%20first%20issue) that contain bugs which are fairly easy to fix. This is a great place to get started.
|
||||
|
||||
## Contact
|
||||
|
||||
We have a few channels for contact:
|
0
v1/examples/basics/pages/en/help.js → packages/docusaurus-1.x/examples/basics/pages/en/help.js
Executable file → Normal file
0
v1/examples/basics/pages/en/index.js → packages/docusaurus-1.x/examples/basics/pages/en/index.js
Executable file → Normal file
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 984 B After Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
@ -17,8 +17,8 @@ const CWD = process.cwd();
|
|||
|
||||
const loadConfig = require('../server/config');
|
||||
|
||||
const siteConfig = loadConfig(`${CWD}/website/siteConfig.js`);
|
||||
const buildDir = `${CWD}/website/build`;
|
||||
const siteConfig = loadConfig(`${CWD}/website-1.x/siteConfig.js`);
|
||||
const buildDir = `${CWD}/website-1.x/build`;
|
||||
const docsDir = `${CWD}/docs`;
|
||||
|
||||
let inputMarkdownFiles = [];
|
||||
|
@ -27,7 +27,7 @@ let outputHTMLFiles = [];
|
|||
let outputAssetsFiles = [];
|
||||
|
||||
function generateSite() {
|
||||
shell.cd('website');
|
||||
shell.cd('website-1.x');
|
||||
shell.exec('yarn build', {silent: true});
|
||||
}
|
||||
|
0
v1/lib/build-files.js → packages/docusaurus-1.x/lib/build-files.js
Executable file → Normal file
0
v1/lib/copy-examples.js → packages/docusaurus-1.x/lib/copy-examples.js
Executable file → Normal file
0
v1/lib/core/GridBlock.js → packages/docusaurus-1.x/lib/core/GridBlock.js
Executable file → Normal file
|
@ -96,33 +96,30 @@ class Head extends React.Component {
|
|||
title={`${this.props.config.title} Blog RSS Feed`}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId &&
|
||||
this.props.config.gaGtag && (
|
||||
<script
|
||||
async
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${
|
||||
this.props.config.gaTrackingId
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId &&
|
||||
this.props.config.gaGtag && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
{this.props.config.gaTrackingId && this.props.config.gaGtag && (
|
||||
<script
|
||||
async
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${
|
||||
this.props.config.gaTrackingId
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId && this.props.config.gaGtag && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
gtag('config', '${this.props.config.gaTrackingId}');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId &&
|
||||
!this.props.config.gaGtag && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId && !this.props.config.gaGtag && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
|
@ -131,28 +128,26 @@ class Head extends React.Component {
|
|||
ga('create', '${this.props.config.gaTrackingId}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* External resources */}
|
||||
{this.props.config.stylesheets &&
|
||||
this.props.config.stylesheets.map(
|
||||
source =>
|
||||
source.href ? (
|
||||
<link rel="stylesheet" key={source.href} {...source} />
|
||||
) : (
|
||||
<link rel="stylesheet" key={source} href={source} />
|
||||
),
|
||||
this.props.config.stylesheets.map(source =>
|
||||
source.href ? (
|
||||
<link rel="stylesheet" key={source.href} {...source} />
|
||||
) : (
|
||||
<link rel="stylesheet" key={source} href={source} />
|
||||
),
|
||||
)}
|
||||
{this.props.config.scripts &&
|
||||
this.props.config.scripts.map(
|
||||
source =>
|
||||
source.src ? (
|
||||
<script type="text/javascript" key={source.src} {...source} />
|
||||
) : (
|
||||
<script type="text/javascript" src={source} key={source} />
|
||||
),
|
||||
this.props.config.scripts.map(source =>
|
||||
source.src ? (
|
||||
<script type="text/javascript" key={source.src} {...source} />
|
||||
) : (
|
||||
<script type="text/javascript" src={source} key={source} />
|
||||
),
|
||||
)}
|
||||
|
||||
{this.props.config.scrollToTop && (
|
|
@ -185,8 +185,9 @@ class Site extends React.Component {
|
|||
/>
|
||||
))}
|
||||
|
||||
{process.env.NODE_ENV === 'development' &&
|
||||
liveReloadScriptUrl && <script src={liveReloadScriptUrl} />}
|
||||
{process.env.NODE_ENV === 'development' && liveReloadScriptUrl && (
|
||||
<script src={liveReloadScriptUrl} />
|
||||
)}
|
||||
</body>
|
||||
</html>
|
||||
);
|