From 8b716223fed2e8ac70da7fdf0fb48ae99127460c Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 10 Jun 2023 09:12:16 +0800 Subject: [PATCH 1/3] fix: Cannot read property 'indexOf' of undefined --- .github/FUNDING.yml | 1 - lib/cli.js | 6 +++--- lib/commands/generate.js | 3 +-- tools/locales/en.json | 3 ++- tools/locales/zh.json | 3 ++- 5 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 2b34450..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -open_collective: docsify diff --git a/lib/cli.js b/lib/cli.js index 11de63d..a0a7651 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -18,7 +18,7 @@ require('yargs') .demandCommand(1, chalk.red('[ERROR] 0 arguments passed. Please specify a command')) .strict() .recommendCommands() - .usage(chalk.bold(y18n.__('usage') + ': docsify ')) + .usage(chalk.bold(y18n.__('usage') + ': docsify [path]')) .command({ command: 'init [path]', aliases: 'i', @@ -94,7 +94,7 @@ require('yargs') handler: argv => run.serve(argv.path, argv.open, argv.port, argv.P, argv.i) }) .command({ - command: 'start ', + command: 'start [path]', desc: chalk.gray(y18n.__('start')), builder: yargs => yargs.options({ @@ -118,7 +118,7 @@ require('yargs') handler: argv => run.start(argv.path, argv.config, argv.port) }) .command({ - command: 'generate ', + command: 'generate [path]', aliases: 'g', desc: chalk.gray(y18n.__('generate')), builder: yargs => diff --git a/lib/commands/generate.js b/lib/commands/generate.js index eb43fbc..0ab850c 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -7,8 +7,7 @@ const path = require('path') const logger = require('../util/logger') const ignoreFiles = ['_navbar', '_coverpage', '_sidebar'] -// eslint-disable-next-line -module.exports = function (path = '', sidebar) { +module.exports = function (path, sidebar) { const cwdPath = cwd(path || '.') if (exists(cwdPath)) { diff --git a/tools/locales/en.json b/tools/locales/en.json index 9488e4f..cc742fb 100644 --- a/tools/locales/en.json +++ b/tools/locales/en.json @@ -15,5 +15,6 @@ "generate.sidebar": "Generate sidebar file", "livereload.port": "livereload Listen port.", "usage": "Usage", - "version": "Show version number" + "version": "Show version number", + "gen.sidebar": "Generate sidebar" } diff --git a/tools/locales/zh.json b/tools/locales/zh.json index 162179e..7deab30 100644 --- a/tools/locales/zh.json +++ b/tools/locales/zh.json @@ -15,5 +15,6 @@ "generate.sidebar": "生成侧边栏文件", "livereload.port": "设置 livereload 端口", "usage": "例子", - "version": "当前版本号" + "version": "当前版本号", + "gen.sidebar": "生成侧边栏" } From 1a0913e87d2ae9f7a1bdd3e85c22f31d4143b7ed Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 10 Jun 2023 09:18:25 +0800 Subject: [PATCH 2/3] docs: change to [path] --- README.md | 14 +++++++------- docs/README.md | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 577100d..23957a8 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,12 @@ npm i docsify-cli -g Use `init` to generate your docs. ```shell -docsify init [--local false] [--theme vue] [--plugins false] +docsify init [path] [--local false] [--theme vue] [--plugins false] -# docsify i [-l false] [-t vue] [--plugins false] +# docsify i [path] [-l false] [-t vue] [--plugins false] ``` -`` defaults to the current directory. Use relative paths like `./docs` (or `docs`). +`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`). - `--local` option: - Shorthand: `-l` @@ -78,9 +78,9 @@ docsify init [--local false] [--theme vue] [--plugins false] Run a server on `localhost` with livereload. ```shell -docsify serve [--open false] [--port 3000] +docsify serve [path] [--open false] [--port 3000] -# docsify s [-o false] [-p 3000] +# docsify s [path] [-o false] [-p 3000] ``` - `--open` option: @@ -99,9 +99,9 @@ docsify serve [--open false] [--port 3000] Docsify's generators. ```shell -docsify generate [--sidebar _sidebar.md] +docsify generate [path] [--sidebar _sidebar.md] -# docsify g [-s _sidebar.md] +# docsify g [path] [-s _sidebar.md] ``` - `--sidebar` option: diff --git a/docs/README.md b/docs/README.md index d4772b7..32e8231 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,12 +35,12 @@ npm i docsify-cli -g Use `init` to generate your docs. ```shell -docsify init [--local false] [--theme vue] [--plugins false] +docsify init [path] [--local false] [--theme vue] [--plugins false] -# docsify i [-l false] [-t vue] [--plugins false] +# docsify i [path] [-l false] [-t vue] [--plugins false] ``` -`` defaults to the current directory. Use relative paths like `./docs` (or `docs`). +`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`). - `--local` option: - Shorthand: `-l` @@ -63,9 +63,9 @@ docsify init [--local false] [--theme vue] [--plugins false] Run a server on `localhost` with livereload. ```shell -docsify serve [--open false] [--port 3000] +docsify serve [path] [--open false] [--port 3000] -# docsify s [-o false] [-p 3000] +# docsify s [path] [-o false] [-p 3000] ``` - `--open` option: @@ -84,9 +84,9 @@ docsify serve [--open false] [--port 3000] Docsify's generators. ```shell -docsify generate [--sidebar _sidebar.md] +docsify generate [path] [--sidebar _sidebar.md] -# docsify g [-s _sidebar.md] +# docsify g [path] [-s _sidebar.md] ``` - `--sidebar` option: From cf8e35077e47a5d437f9575afd5a9dfd9445f65a Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Sat, 10 Jun 2023 09:20:16 +0800 Subject: [PATCH 3/3] test: update snap --- e2e/cli.test.js.md | 72 +++++++++++++++++++++---------------------- e2e/cli.test.js.snap | Bin 655 -> 658 bytes 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/e2e/cli.test.js.md b/e2e/cli.test.js.md index 1b025b9..007f219 100644 --- a/e2e/cli.test.js.md +++ b/e2e/cli.test.js.md @@ -4,17 +4,17 @@ The actual snapshot is saved in `cli.test.js.snap`. Generated by [AVA](https://avajs.dev). -## rejects promise due to error on passing in an unknown command +## shows up help message without any args > Snapshot 1 - `Usage: docsify ␊ + `Usage: docsify [path]␊ ␊ Commands:␊ docsify init [path] Creates new docs [aliases: i]␊ docsify serve [path] Run local server to preview site. [aliases: s]␊ - docsify start Server for SSR␊ - docsify generate Docsify's generators [aliases: g]␊ + docsify start [path] Server for SSR␊ + docsify generate [path] Docsify's generators [aliases: g]␊ ␊ Global Options␊ --help, -h Show help [boolean]␊ @@ -27,19 +27,19 @@ Generated by [AVA](https://avajs.dev). Development:␊ https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊ ␊ - Unknown argument: junkcmd` + [ERROR] 0 arguments passed. Please specify a command` -## shows help with --help flag +## shows help with -h flag > Snapshot 1 - `Usage: docsify ␊ + `Usage: docsify [path]␊ ␊ Commands:␊ docsify init [path] Creates new docs [aliases: i]␊ docsify serve [path] Run local server to preview site. [aliases: s]␊ - docsify start Server for SSR␊ - docsify generate Docsify's generators [aliases: g]␊ + docsify start [path] Server for SSR␊ + docsify generate [path] Docsify's generators [aliases: g]␊ ␊ Global Options␊ --help, -h Show help [boolean]␊ @@ -52,17 +52,17 @@ Generated by [AVA](https://avajs.dev). Development:␊ https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md` -## shows help with -h flag +## shows help with --help flag > Snapshot 1 - `Usage: docsify ␊ + `Usage: docsify [path]␊ ␊ Commands:␊ docsify init [path] Creates new docs [aliases: i]␊ docsify serve [path] Run local server to preview site. [aliases: s]␊ - docsify start Server for SSR␊ - docsify generate Docsify's generators [aliases: g]␊ + docsify start [path] Server for SSR␊ + docsify generate [path] Docsify's generators [aliases: g]␊ ␊ Global Options␊ --help, -h Show help [boolean]␊ @@ -75,17 +75,35 @@ Generated by [AVA](https://avajs.dev). Development:␊ https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md` -## shows up help message without any args +## shows version information with -v flag + +> Snapshot 1 + + `␊ + docsify-cli version:␊ + 4.4.4␊ + ` + +## shows version information with --version flag + +> Snapshot 1 + + `␊ + docsify-cli version:␊ + 4.4.4␊ + ` + +## rejects promise due to error on passing in an unknown command > Snapshot 1 - `Usage: docsify ␊ + `Usage: docsify [path]␊ ␊ Commands:␊ docsify init [path] Creates new docs [aliases: i]␊ docsify serve [path] Run local server to preview site. [aliases: s]␊ - docsify start Server for SSR␊ - docsify generate Docsify's generators [aliases: g]␊ + docsify start [path] Server for SSR␊ + docsify generate [path] Docsify's generators [aliases: g]␊ ␊ Global Options␊ --help, -h Show help [boolean]␊ @@ -98,22 +116,4 @@ Generated by [AVA](https://avajs.dev). Development:␊ https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md␊ ␊ - [ERROR] 0 arguments passed. Please specify a command` - -## shows version information with --version flag - -> Snapshot 1 - - `␊ - docsify-cli version:␊ - 4.4.4␊ - ` - -## shows version information with -v flag - -> Snapshot 1 - - `␊ - docsify-cli version:␊ - 4.4.4␊ - ` + Unknown argument: junkcmd` diff --git a/e2e/cli.test.js.snap b/e2e/cli.test.js.snap index 02e125fdf83a6c97549608e33edf161b93188173..6cb284e8b8a6435ef06b407169b02393fa1fecd4 100644 GIT binary patch literal 658 zcmV;D0&V?4RzV*}ci#Cc87s%-kLRpoNW{ zg(4PLsEJ@mWnr2aQixU5N>MChAvOwDDIz$#x0mc;0;W9JS*CgO=6yf&X4q#4p#vzv zhu6QnKDCf`M&Ca@vH4a*{z$25d|Slpzn15ZwA#hBS0C}GMb~r8buq09U!+U)c_9IUk>dnQB7l-s zK!UwS89O!>L}bCPLaH-tO^qZghwp@WHDGB@AkOMDeuv4&*6cL==`^g3qP`k)}%QSD^yzgh;z|I2z_5uC# z5?=e(S~%2b7FVCG-_bxAKT-fJe(ZbjzIpLj~b71x8 z%k;pdyCp3`>jwZx^OI{Io*!S#dc$uX^>4h=B6MD@n@3D@li$yLy1nrD8autBMd-R( zWTW+@cr`u!@ay1mUvv1D7NJWAl^WO|RikCV;nbH@Nno4gQI%Q3owd8f zi}9WN*-C9!ARPCYsmd(`(q&Yr1lg=ZykHPzopu2ZYoHL>bv8TZFd6d*rjXi@ zD8NFHs*WzG#sonkAXa#@7+G!aZgc(9#Px~m_m=Au|0e$ZU;L|`fU#5ENrais>gt34 p%1yma-bL~*_SU