Skip to content

Commit

Permalink
refactor(v2): move website dir out of v2 for cleaner separations
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun committed Feb 24, 2019
1 parent 63851a6 commit f559b1d
Show file tree
Hide file tree
Showing 36 changed files with 38 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
command: cd v2 && yarn test
- run:
name: Test Static Website Builds
command: cd v2/website && yarn build
command: cd v2-website && yarn build

publish-npm:
<<: *defaults
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ node_modules
.eslintcache

yarn-error.log
build
__generated__
16 changes: 8 additions & 8 deletions docs/getting-started-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: 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

Expand Down Expand Up @@ -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. `cd website`
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`.
1. Load the example site at http://localhost:3000 if it did not already open
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.

![](/img/getting-started-preparation-verify.png)
Expand All @@ -82,7 +82,7 @@ yarn start (or npm run start)

## 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:

Expand All @@ -92,11 +92,11 @@ Using globally installed version of Yarn
yarn outdated v1.5.1
warning package.json: No license field
warning No license field
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
"<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
✨ Done in 0.41s.
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
organizationName: 'facebook',
projectName: 'docusaurus',
baseUrl: '/',
customDocsPath: '../docs',
customDocsPath: './docs',
url: 'https://docusaurus.io',
headerLinks: [
{doc: 'installation', label: 'Docs'},
Expand Down
15 changes: 15 additions & 0 deletions v2-website/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 2 additions & 1 deletion v2/website/yarn.lock → v2-website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ docsearch.js@^2.5.2:
to-factory "^1.0.0"
zepto "^1.2.0"

docusaurus@../:
docusaurus@../v2:
version "2.0.0"
dependencies:
"@babel/core" "^7.0.0"
Expand Down Expand Up @@ -2385,6 +2385,7 @@ docusaurus@../:
koa-range "^0.3.0"
koa-static "^5.0.0"
loader-utils "^1.1.0"
lodash "^4.17.11"
mini-css-extract-plugin "^0.4.1"
portfinder "^1.0.13"
prismjs "^1.15.0"
Expand Down
10 changes: 0 additions & 10 deletions v2/.gitignore

This file was deleted.

16 changes: 8 additions & 8 deletions v2/lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ async function getPort(reqPort) {
module.exports = async function start(siteDir, cliOptions = {}) {
console.log('Start command invoked ...');

// Process all related files as a prop
// Process all related files as a prop.
const props = await load(siteDir);

// Reload files processing
// Reload files processing.
if (!cliOptions.noWatch) {
const reload = () => {
load(siteDir).catch(err => {
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
const host = getHost(cliOptions.host);
const {baseUrl} = props;

// create compiler from generated webpack config
// Create compiler from generated webpack config.
let config = createClientConfig(props);

const {siteConfig} = props;
Expand All @@ -86,15 +86,15 @@ module.exports = async function start(siteDir, cliOptions = {}) {
]);
config = config.toConfig();

// apply user webpack config
// Apply user webpack config.
const {
siteConfig: {configureWebpack},
} = props;
config = applyConfigureWebpack(configureWebpack, config, false);

const compiler = webpack(config);

// webpack-serve
// Run webpack serve.
await serve(
{},
{
Expand All @@ -111,16 +111,16 @@ module.exports = async function start(siteDir, cliOptions = {}) {
port,
host,
add: app => {
// serve static files
// Serve static files.
const staticDir = path.resolve(siteDir, 'static');
if (fs.existsSync(staticDir)) {
app.use(mount(baseUrl, serveStatic(staticDir)));
}

// enable HTTP range requests
// Enable HTTP range requests.
app.use(range);

// rewrite request to `/` since dev is only a SPA
// Rewrite request to `/` since dev is only a SPA.
app.use(
convert(
history({
Expand Down
6 changes: 1 addition & 5 deletions v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
},
"scripts": {
"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\"",
"lint": "eslint --cache \"{lib,bin,test,website}/**/*.js\"",
"lint": "eslint --cache \"{lib,bin,test}/**/*.js\"",
"test": "jest --config test/jest.config.js"
},
"bugs": {
Expand Down
13 changes: 0 additions & 13 deletions v2/website/package.json

This file was deleted.

0 comments on commit f559b1d

Please sign in to comment.