refactor(v2): move website dir out of v2 for cleaner separations

This commit is contained in:
Yangshun Tay 2019-02-24 14:13:08 -08:00
parent 63851a6f14
commit f559b1dc7c
36 changed files with 38 additions and 47 deletions

View file

@ -151,7 +151,7 @@ jobs:
command: cd v2 && yarn test command: cd v2 && yarn test
- run: - run:
name: Test Static Website Builds name: Test Static Website Builds
command: cd v2/website && yarn build command: cd v2-website && yarn build
publish-npm: publish-npm:
<<: *defaults <<: *defaults

2
.gitignore vendored
View file

@ -8,3 +8,5 @@ node_modules
.eslintcache .eslintcache
yarn-error.log yarn-error.log
build
__generated__

View file

@ -3,7 +3,7 @@ id: installation
title: Installation title: Installation
--- ---
Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly. Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly.
## Installing Docusaurus ## Installing Docusaurus
@ -62,11 +62,11 @@ runnable, example website to use as your site's base. To run:
1. In your root, rename `docs-examples-from-docusaurus` to `docs`. 1. In your root, rename `docs-examples-from-docusaurus` to `docs`.
1. `cd website` 1. `cd website`
1. Rename `blog-examples-from-docusaurus` to `blog`. 1. Rename `blog-examples-from-docusaurus` to `blog`.
1. From within the `website` directory, run the local webserver using 1. From within the `website` directory, run the local webserver using
`yarn start` or `npm start`. `yarn start` or `npm start`.
1. Load the example site at http://localhost:3000 if it did not already open 1. Load the example site at http://localhost:3000 if it did not already open
automatically. automatically.
You should see the example site loaded in your web browser. There's also a LiveReload server running and any changes made to the docs and files in the `website` directory will cause the page to refresh. You should see the example site loaded in your web browser. There's also a LiveReload server running and any changes made to the docs and files in the `website` directory will cause the page to refresh.
![](/img/getting-started-preparation-verify.png) ![](/img/getting-started-preparation-verify.png)
@ -82,7 +82,7 @@ yarn start (or npm run start)
## Updating Your Docusaurus Version ## Updating Your Docusaurus Version
At any time after Docusaurus is installed, you can check your current version of Docusaurus by going into the `website` directory and typing `yarn outdated docusaurus` or `npm outdated docusaurus`. At any time after Docusaurus is installed, you can check your current version of Docusaurus by going into the `website` directory and typing `yarn outdated docusaurus` or `npm outdated docusaurus`.
You will see something like this: You will see something like this:
@ -92,11 +92,11 @@ Using globally installed version of Yarn
yarn outdated v1.5.1 yarn outdated v1.5.1
warning package.json: No license field warning package.json: No license field
warning No license field warning No license field
info Color legend : info Color legend :
"<red>" : Major Update backward-incompatible updates "<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features "<yellow>" : Minor Update backward-compatible features
"<green>" : Patch Update backward-compatible bug fixes "<green>" : Patch Update backward-compatible bug fixes
Package Current Wanted Latest Package Type URL Package Current Wanted Latest Package Type URL
docusaurus 1.0.9 1.2.0 1.2.0 devDependencies https://github.com/facebook/Docusaurus#readme docusaurus 1.0.9 1.2.0 1.2.0 devDependencies https://github.com/facebook/Docusaurus#readme
✨ Done in 0.41s. ✨ Done in 0.41s.
``` ```

View file

@ -11,7 +11,7 @@ module.exports = {
organizationName: 'facebook', organizationName: 'facebook',
projectName: 'docusaurus', projectName: 'docusaurus',
baseUrl: '/', baseUrl: '/',
customDocsPath: '../docs', customDocsPath: './docs',
url: 'https://docusaurus.io', url: 'https://docusaurus.io',
headerLinks: [ headerLinks: [
{doc: 'installation', label: 'Docs'}, {doc: 'installation', label: 'Docs'},

15
v2-website/package.json Normal file
View file

@ -0,0 +1,15 @@
{
"scripts": {
"start": "node ../v2/bin/docusaurus start",
"build": "node ../v2/bin/docusaurus build",
"eject": "node ../v2/bin/docusaurus eject",
"deploy": "node ../v2/bin/docusaurus deploy"
},
"dependencies": {
"classnames": "^2.2.6",
"docusaurus": "../v2",
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"react-youtube": "^7.6.0"
}
}

View file

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 224 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 796 B

After

Width:  |  Height:  |  Size: 796 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 7 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 804 B

After

Width:  |  Height:  |  Size: 804 B

Before After
Before After

View file

@ -2354,7 +2354,7 @@ docsearch.js@^2.5.2:
to-factory "^1.0.0" to-factory "^1.0.0"
zepto "^1.2.0" zepto "^1.2.0"
docusaurus@../: docusaurus@../v2:
version "2.0.0" version "2.0.0"
dependencies: dependencies:
"@babel/core" "^7.0.0" "@babel/core" "^7.0.0"
@ -2385,6 +2385,7 @@ docusaurus@../:
koa-range "^0.3.0" koa-range "^0.3.0"
koa-static "^5.0.0" koa-static "^5.0.0"
loader-utils "^1.1.0" loader-utils "^1.1.0"
lodash "^4.17.11"
mini-css-extract-plugin "^0.4.1" mini-css-extract-plugin "^0.4.1"
portfinder "^1.0.13" portfinder "^1.0.13"
prismjs "^1.15.0" prismjs "^1.15.0"

10
v2/.gitignore vendored
View file

@ -1,10 +0,0 @@
.DS_Store
.vscode
.idea
.eslintcache
node_modules
dist
yarn-error.log
__generated__
website/node_modules
build

View file

@ -36,10 +36,10 @@ async function getPort(reqPort) {
module.exports = async function start(siteDir, cliOptions = {}) { module.exports = async function start(siteDir, cliOptions = {}) {
console.log('Start command invoked ...'); console.log('Start command invoked ...');
// Process all related files as a prop // Process all related files as a prop.
const props = await load(siteDir); const props = await load(siteDir);
// Reload files processing // Reload files processing.
if (!cliOptions.noWatch) { if (!cliOptions.noWatch) {
const reload = () => { const reload = () => {
load(siteDir).catch(err => { load(siteDir).catch(err => {
@ -71,7 +71,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
const host = getHost(cliOptions.host); const host = getHost(cliOptions.host);
const {baseUrl} = props; const {baseUrl} = props;
// create compiler from generated webpack config // Create compiler from generated webpack config.
let config = createClientConfig(props); let config = createClientConfig(props);
const {siteConfig} = props; const {siteConfig} = props;
@ -86,7 +86,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
]); ]);
config = config.toConfig(); config = config.toConfig();
// apply user webpack config // Apply user webpack config.
const { const {
siteConfig: {configureWebpack}, siteConfig: {configureWebpack},
} = props; } = props;
@ -94,7 +94,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
const compiler = webpack(config); const compiler = webpack(config);
// webpack-serve // Run webpack serve.
await serve( await serve(
{}, {},
{ {
@ -111,16 +111,16 @@ module.exports = async function start(siteDir, cliOptions = {}) {
port, port,
host, host,
add: app => { add: app => {
// serve static files // Serve static files.
const staticDir = path.resolve(siteDir, 'static'); const staticDir = path.resolve(siteDir, 'static');
if (fs.existsSync(staticDir)) { if (fs.existsSync(staticDir)) {
app.use(mount(baseUrl, serveStatic(staticDir))); app.use(mount(baseUrl, serveStatic(staticDir)));
} }
// enable HTTP range requests // Enable HTTP range requests.
app.use(range); app.use(range);
// rewrite request to `/` since dev is only a SPA // Rewrite request to `/` since dev is only a SPA.
app.use( app.use(
convert( convert(
history({ history({

View file

@ -21,12 +21,8 @@
}, },
"scripts": { "scripts": {
"docusaurus": "node bin/docusaurus", "docusaurus": "node bin/docusaurus",
"start": "node bin/docusaurus start website",
"build": "node bin/docusaurus build website",
"eject": "node bin/docusaurus eject website",
"deploy": "node bin/docusaurus deploy website",
"prettier": "prettier --config ../.prettierrc --write \"**/*.js\"", "prettier": "prettier --config ../.prettierrc --write \"**/*.js\"",
"lint": "eslint --cache \"{lib,bin,test,website}/**/*.js\"", "lint": "eslint --cache \"{lib,bin,test}/**/*.js\"",
"test": "jest --config test/jest.config.js" "test": "jest --config test/jest.config.js"
}, },
"bugs": { "bugs": {

View file

@ -1,13 +0,0 @@
{
"scripts": {
"start": "node ../bin/docusaurus start",
"build": "node ../bin/docusaurus build"
},
"dependencies": {
"classnames": "^2.2.6",
"docusaurus": "../",
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"react-youtube": "^7.6.0"
}
}