From d196aac17cc9919d4ddb889b572459bd0a19ce7d Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Tue, 7 Apr 2020 15:03:41 +0000 Subject: [PATCH] Enhance CLI experience. Signed-off-by: Reece Dunham --- admin/extending-remarkable.md | 12 ++++---- docs/api-site-config.md | 2 +- packages/docusaurus/bin/docusaurus.js | 19 +++++++----- packages/docusaurus/src/commands/deploy.ts | 30 ++++++++++++------- .../version-1.10.x/api-site-config.md | 2 +- .../version-1.11.x/api-site-config.md | 2 +- .../version-1.13.0/api-site-config.md | 2 +- .../version-1.14.4/api-site-config.md | 2 +- .../version-1.9.x/api-site-config.md | 2 +- website/docs/lifecycle-apis.md | 22 +++++++------- .../version-2.0.0-alpha.40/lifecycle-apis.md | 22 +++++++------- .../version-2.0.0-alpha.43/lifecycle-apis.md | 22 +++++++------- .../version-2.0.0-alpha.48/lifecycle-apis.md | 22 +++++++------- .../version-2.0.0-alpha.50/lifecycle-apis.md | 22 +++++++------- 14 files changed, 97 insertions(+), 86 deletions(-) diff --git a/admin/extending-remarkable.md b/admin/extending-remarkable.md index 6332a3937283..3606dd643612 100644 --- a/admin/extending-remarkable.md +++ b/admin/extending-remarkable.md @@ -53,11 +53,11 @@ Now that you have a better idea of how parsing/rendering works, we can proceed t The default heading renderers may look like this (you can refer to the Remarkable source code here): ```js -md.renderer.rules.heading_open = function(tokens, idx /*, options, env */) { +md.renderer.rules.heading_open = function (tokens, idx /*, options, env */) { return ''; }; -md.renderer.rules.heading_close = function(tokens, idx /*, options, env */) { +md.renderer.rules.heading_close = function (tokens, idx /*, options, env */) { return '\n'; }; ``` @@ -74,7 +74,7 @@ That's pretty straightforward: whenever these tokens are found, we render a ` You won ${prizes[index]} ; @@ -151,7 +151,7 @@ You may use them to return your webpack configures conditionally. For example, this plugin below modify the webpack config to transpile `.foo` file. ```js {4-11} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'custom-docusaurus-plugin', configureWebpack(config, isServer, utils) { @@ -193,12 +193,12 @@ type Props = { Example: ```js {4-9} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async postBuild({siteConfig = {}, routesPaths = [], outDir}) { // Print out to console all the rendered routes - routesPaths.map(route => { + routesPaths.map((route) => { console.log(route); }); }, @@ -213,7 +213,7 @@ Register an extra command to enhance the CLI of docusaurus. `cli` is [commander] Example: ```js {4-11} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', extendCli(cli) { @@ -263,7 +263,7 @@ interface HtmlTagObject { Example: ```js {4-28} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', injectHtmlTags() { @@ -302,7 +302,7 @@ If you use the folder directory above, your `getThemePath` can be: ```js {6-8} title="my-theme/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'name-of-my-theme', getThemePath() { @@ -321,7 +321,7 @@ As an example, to make your theme load a `customCss` object from `options` passe ```js {7-9} title="my-theme/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { const {customCss} = options || {}; return { name: 'name-of-my-theme', @@ -351,7 +351,7 @@ const DEFAULT_OPTIONS = { // A JavaScript function that returns an object. // `context` is provided by Docusaurus. Example: siteConfig can be accessed from context. // `opts` is the user-defined options. -module.exports = function(context, opts) { +module.exports = function (context, opts) { // Merge defaults with user-defined options. const options = {...DEFAULT_OPTIONS, ...options}; diff --git a/website/versioned_docs/version-2.0.0-alpha.40/lifecycle-apis.md b/website/versioned_docs/version-2.0.0-alpha.40/lifecycle-apis.md index b6b3ee322028..fb048c095143 100644 --- a/website/versioned_docs/version-2.0.0-alpha.40/lifecycle-apis.md +++ b/website/versioned_docs/version-2.0.0-alpha.40/lifecycle-apis.md @@ -16,7 +16,7 @@ Example: ```js {6-8} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', getPathsToWatch() { @@ -36,7 +36,7 @@ For example, this plugin below return a random integer between 1 to 10 as conten ```js {6-7} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async loadContent() { @@ -93,7 +93,7 @@ For example, this plugin below create a `/roll` page which display "You won xxxx // website/src/components/roll.js import React from 'react'; -export default function(props) { +export default function (props) { const {prizes} = props; const index = Math.floor(Math.random() * 3); return
You won ${prizes[index]}
; @@ -152,7 +152,7 @@ For example, this plugin below modify the webpack config to transpile `.foo` fil ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', configureWebpack(config, isServer, utils) { @@ -190,12 +190,12 @@ Example: ```js {5-10} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async postBuild({siteConfig = {}, routesPaths = [], outDir}) { // Print out to console all the rendered routes - routesPaths.map(route => { + routesPaths.map((route) => { console.log(route); }); }, @@ -211,7 +211,7 @@ Example: ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', extendCli(cli) { @@ -262,7 +262,7 @@ Example: ```js {5-29} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', injectHtmlTags() { @@ -302,7 +302,7 @@ If you use the folder directory above, your `getThemePath` can be: // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'name-of-my-theme', getThemePath() { @@ -322,7 +322,7 @@ As an example, to make your theme load a `customCss` object from `options` passe // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { const {customCss} = options || {}; return { name: 'name-of-my-theme', @@ -352,7 +352,7 @@ const DEFAULT_OPTIONS = { // A JavaScript function that returns an object. // `context` is provided by Docusaurus. Example: siteConfig can be accessed from context. // `opts` is the user-defined options. -module.exports = function(context, opts) { +module.exports = function (context, opts) { // Merge defaults with user-defined options. const options = {...DEFAULT_OPTIONS, ...options}; diff --git a/website/versioned_docs/version-2.0.0-alpha.43/lifecycle-apis.md b/website/versioned_docs/version-2.0.0-alpha.43/lifecycle-apis.md index 7fe24f2c54f6..cabb68a1ebf8 100644 --- a/website/versioned_docs/version-2.0.0-alpha.43/lifecycle-apis.md +++ b/website/versioned_docs/version-2.0.0-alpha.43/lifecycle-apis.md @@ -16,7 +16,7 @@ Example: ```js {6-8} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', getPathsToWatch() { @@ -36,7 +36,7 @@ For example, this plugin below return a random integer between 1 to 10 as conten ```js {6-7} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async loadContent() { @@ -93,7 +93,7 @@ For example, this plugin below create a `/roll` page which display "You won xxxx // website/src/components/roll.js import React from 'react'; -export default function(props) { +export default function (props) { const {prizes} = props; const index = Math.floor(Math.random() * 3); return
You won ${prizes[index]}
; @@ -152,7 +152,7 @@ For example, this plugin below modify the webpack config to transpile `.foo` fil ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'custom-docusaurus-plugin', configureWebpack(config, isServer, utils) { @@ -195,12 +195,12 @@ Example: ```js {5-10} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async postBuild({siteConfig = {}, routesPaths = [], outDir}) { // Print out to console all the rendered routes - routesPaths.map(route => { + routesPaths.map((route) => { console.log(route); }); }, @@ -216,7 +216,7 @@ Example: ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', extendCli(cli) { @@ -267,7 +267,7 @@ Example: ```js {5-29} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', injectHtmlTags() { @@ -307,7 +307,7 @@ If you use the folder directory above, your `getThemePath` can be: // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'name-of-my-theme', getThemePath() { @@ -327,7 +327,7 @@ As an example, to make your theme load a `customCss` object from `options` passe // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { const {customCss} = options || {}; return { name: 'name-of-my-theme', @@ -357,7 +357,7 @@ const DEFAULT_OPTIONS = { // A JavaScript function that returns an object. // `context` is provided by Docusaurus. Example: siteConfig can be accessed from context. // `opts` is the user-defined options. -module.exports = function(context, opts) { +module.exports = function (context, opts) { // Merge defaults with user-defined options. const options = {...DEFAULT_OPTIONS, ...options}; diff --git a/website/versioned_docs/version-2.0.0-alpha.48/lifecycle-apis.md b/website/versioned_docs/version-2.0.0-alpha.48/lifecycle-apis.md index d058b9e81882..1354122a7fd5 100644 --- a/website/versioned_docs/version-2.0.0-alpha.48/lifecycle-apis.md +++ b/website/versioned_docs/version-2.0.0-alpha.48/lifecycle-apis.md @@ -20,7 +20,7 @@ Example: ```js {6-8} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', getPathsToWatch() { @@ -40,7 +40,7 @@ For example, this plugin below return a random integer between 1 to 10 as conten ```js {6-7} // docusaurus-plugin/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async loadContent() { @@ -97,7 +97,7 @@ For example, this plugin below create a `/roll` page which display "You won xxxx // website/src/components/roll.js import React from 'react'; -export default function(props) { +export default function (props) { const {prizes} = props; const index = Math.floor(Math.random() * 3); return
You won ${prizes[index]}
; @@ -156,7 +156,7 @@ For example, this plugin below modify the webpack config to transpile `.foo` fil ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'custom-docusaurus-plugin', configureWebpack(config, isServer, utils) { @@ -199,12 +199,12 @@ Example: ```js {5-10} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async postBuild({siteConfig = {}, routesPaths = [], outDir}) { // Print out to console all the rendered routes - routesPaths.map(route => { + routesPaths.map((route) => { console.log(route); }); }, @@ -220,7 +220,7 @@ Example: ```js {5-12} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', extendCli(cli) { @@ -271,7 +271,7 @@ Example: ```js {5-29} // docusaurus-plugin/src/index.js -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', injectHtmlTags() { @@ -311,7 +311,7 @@ If you use the folder directory above, your `getThemePath` can be: // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'name-of-my-theme', getThemePath() { @@ -331,7 +331,7 @@ As an example, to make your theme load a `customCss` object from `options` passe // my-theme/src/index.js const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { const {customCss} = options || {}; return { name: 'name-of-my-theme', @@ -361,7 +361,7 @@ const DEFAULT_OPTIONS = { // A JavaScript function that returns an object. // `context` is provided by Docusaurus. Example: siteConfig can be accessed from context. // `opts` is the user-defined options. -module.exports = function(context, opts) { +module.exports = function (context, opts) { // Merge defaults with user-defined options. const options = {...DEFAULT_OPTIONS, ...options}; diff --git a/website/versioned_docs/version-2.0.0-alpha.50/lifecycle-apis.md b/website/versioned_docs/version-2.0.0-alpha.50/lifecycle-apis.md index 12e53d3068e2..c841d9770a5b 100644 --- a/website/versioned_docs/version-2.0.0-alpha.50/lifecycle-apis.md +++ b/website/versioned_docs/version-2.0.0-alpha.50/lifecycle-apis.md @@ -19,7 +19,7 @@ Example: ```js {5-7} title="docusaurus-plugin/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', getPathsToWatch() { @@ -38,7 +38,7 @@ For example, this plugin below return a random integer between 1 to 10 as conten ```js {5-6} title="docusaurus-plugin/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async loadContent() { @@ -94,7 +94,7 @@ For example, this plugin below create a `/roll` page which display "You won xxxx ```jsx title="website/src/components/roll.js" import React from 'react'; -export default function(props) { +export default function (props) { const {prizes} = props; const index = Math.floor(Math.random() * 3); return
You won ${prizes[index]}
; @@ -151,7 +151,7 @@ You may use them to return your webpack configures conditionally. For example, this plugin below modify the webpack config to transpile `.foo` file. ```js {4-11} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'custom-docusaurus-plugin', configureWebpack(config, isServer, utils) { @@ -193,12 +193,12 @@ type Props = { Example: ```js {4-9} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', async postBuild({siteConfig = {}, routesPaths = [], outDir}) { // Print out to console all the rendered routes - routesPaths.map(route => { + routesPaths.map((route) => { console.log(route); }); }, @@ -213,7 +213,7 @@ Register an extra command to enhance the CLI of docusaurus. `cli` is [commander] Example: ```js {4-11} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', extendCli(cli) { @@ -263,7 +263,7 @@ interface HtmlTagObject { Example: ```js {4-28} title="docusaurus-plugin/src/index.js" -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'docusaurus-plugin', injectHtmlTags() { @@ -302,7 +302,7 @@ If you use the folder directory above, your `getThemePath` can be: ```js {6-8} title="my-theme/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { return { name: 'name-of-my-theme', getThemePath() { @@ -321,7 +321,7 @@ As an example, to make your theme load a `customCss` object from `options` passe ```js {7-9} title="my-theme/src/index.js" const path = require('path'); -module.exports = function(context, options) { +module.exports = function (context, options) { const {customCss} = options || {}; return { name: 'name-of-my-theme', @@ -351,7 +351,7 @@ const DEFAULT_OPTIONS = { // A JavaScript function that returns an object. // `context` is provided by Docusaurus. Example: siteConfig can be accessed from context. // `opts` is the user-defined options. -module.exports = function(context, opts) { +module.exports = function (context, opts) { // Merge defaults with user-defined options. const options = {...DEFAULT_OPTIONS, ...options};