Skip to content

Commit 138e297

Browse files
Release v5.0.0-rc.1 (#224)
Co-authored-by: Koy Zhuang <[email protected]>
1 parent 29d310a commit 138e297

File tree

16 files changed

+6288
-5625
lines changed

16 files changed

+6288
-5625
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ npm i docsify-cli -g
5050
Use `init` to generate your docs.
5151

5252
```shell
53-
docsify init [path] [--local false] [--theme vue] [--plugins false]
53+
docsify init [path] [--local false] [--rcMode] [--theme vue] [--plugins]
5454

55-
# docsify i [path] [-l false] [-t vue] [--plugins false]
55+
# docsify i [path] [-l false] [--rc] [-t vue] [-p]
5656
```
5757

5858
`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
@@ -62,11 +62,16 @@ docsify init [path] [--local false] [--theme vue] [--plugins false]
6262
- Type: boolean
6363
- Default: `false`
6464
- Description: Copy `docsify` files to the docs path, defaults to `false` using `cdn.jsdelivr.net` as the content delivery network (CDN). To explicitly set this option to `false` use `--no-local`.
65+
- `--rcMode` option:
66+
- Shorthand: `--rc`
67+
- Type: boolean
68+
- Default: `false`
69+
- Description: Try `docsify` preview release version (`rc` resource).
6570
- `--theme` option:
6671
- Shorthand: `-t`
6772
- Type: string
6873
- Default: `vue`
69-
- Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.
74+
- Description: Choose a theme, defaults to `vue`.
7075
- `--plugins` option:
7176
- Shorthand: `-p`
7277
- Type: boolean
@@ -114,7 +119,7 @@ docsify generate [path] [--sidebar _sidebar.md] [--overwrite]
114119
- Shorthand: `-o`
115120
- Type: boolean
116121
- Default: `false`
117-
- Description: Allow overwrite generated files.
122+
- Description: Allow to overwrite generated files.
118123

119124
## Contributing
120125
Please see the [Contributing Guidelines](./CONTRIBUTING.md)

ava.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export default {
1+
module.exports = {
22
files: ['e2e/**/*.test.js']
33
}

docs/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ npm i docsify-cli -g
3535
Use `init` to generate your docs.
3636

3737
```shell
38-
docsify init [path] [--local false] [--theme vue] [--plugins false]
38+
docsify init [path] [--local false] [--rcMode] [--theme vue] [--plugins]
3939

40-
# docsify i [path] [-l false] [-t vue] [--plugins false]
40+
# docsify i [path] [-l false] [--rc] [-t vue] [-p]
4141
```
4242

4343
`[path]` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
@@ -47,11 +47,16 @@ docsify init [path] [--local false] [--theme vue] [--plugins false]
4747
- Type: boolean
4848
- Default: `false`
4949
- Description: Copy `docsify` files to the docs path, defaults to `false` using `cdn.jsdelivr.net` as the content delivery network (CDN). To explicitly set this option to `false` use `--no-local`.
50+
- `--rcMode` option:
51+
- Shorthand: `--rc`
52+
- Type: boolean
53+
- Default: `false`
54+
- Description: Try `docsify` preview release version (`rc` resource).
5055
- `--theme` option:
5156
- Shorthand: `-t`
5257
- Type: string
5358
- Default: `vue`
54-
- Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.
59+
- Description: Choose a theme, defaults to `vue`.
5560
- `--plugins` option:
5661
- Shorthand: `-p`
5762
- Type: boolean
@@ -99,7 +104,7 @@ docsify generate [path] [--sidebar _sidebar.md] [--overwrite]
99104
- Shorthand: `-o`
100105
- Type: boolean
101106
- Default: `false`
102-
- Description: Allow overwrite generated files.
107+
- Description: Allow to overwrite generated files.
103108

104109
## License
105110

e2e/cli.test.js.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Generated by [AVA](https://avajs.dev).
1313
Commands:␊
1414
docsify init [path] Creates new docs [aliases: i]␊
1515
docsify serve [path] Run local server to preview site. [aliases: s]␊
16-
docsify start [path] Server for SSR␊
1716
docsify generate [path] Docsify's generators [aliases: g]␊
1817
1918
Global Options␊
@@ -38,7 +37,6 @@ Generated by [AVA](https://avajs.dev).
3837
Commands:␊
3938
docsify init [path] Creates new docs [aliases: i]␊
4039
docsify serve [path] Run local server to preview site. [aliases: s]␊
41-
docsify start [path] Server for SSR␊
4240
docsify generate [path] Docsify's generators [aliases: g]␊
4341
4442
Global Options␊
@@ -61,7 +59,6 @@ Generated by [AVA](https://avajs.dev).
6159
Commands:␊
6260
docsify init [path] Creates new docs [aliases: i]␊
6361
docsify serve [path] Run local server to preview site. [aliases: s]␊
64-
docsify start [path] Server for SSR␊
6562
docsify generate [path] Docsify's generators [aliases: g]␊
6663
6764
Global Options␊
@@ -81,7 +78,7 @@ Generated by [AVA](https://avajs.dev).
8178
8279
`␊
8380
docsify-cli version:␊
84-
4.4.4
81+
5.0.0-rc.1
8582
`
8683

8784
## shows version information with --version flag
@@ -90,7 +87,7 @@ Generated by [AVA](https://avajs.dev).
9087
9188
`␊
9289
docsify-cli version:␊
93-
4.4.4
90+
5.0.0-rc.1
9491
`
9592

9693
## rejects promise due to error on passing in an unknown command
@@ -102,7 +99,6 @@ Generated by [AVA](https://avajs.dev).
10299
Commands:␊
103100
docsify init [path] Creates new docs [aliases: i]␊
104101
docsify serve [path] Run local server to preview site. [aliases: s]␊
105-
docsify start [path] Server for SSR␊
106102
docsify generate [path] Docsify's generators [aliases: g]␊
107103
108104
Global Options␊

e2e/cli.test.js.snap

-18 Bytes
Binary file not shown.

lib/cli.js

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
const chalk = require('chalk')
2-
const updateNotifier = require('update-notifier')
32

43
const pkg = require('../package.json')
54
const run = require('../lib')
65

7-
updateNotifier({pkg: pkg}).notify()
8-
96
const Locales = require('../tools/locales')
107
const y18n = new Locales()
118

@@ -33,11 +30,19 @@ require('yargs')
3330
requiresArg: false,
3431
type: 'boolean'
3532
},
33+
rcMode: {
34+
alias: 'rc',
35+
default: false,
36+
desc: chalk.gray(y18n.__('init.rc')),
37+
nargs: 0,
38+
requiresArg: false,
39+
type: 'boolean'
40+
},
3641
theme: {
3742
alias: 't',
3843
default: 'vue',
3944
desc: chalk.gray(y18n.__('init.theme')),
40-
choices: ['vue', 'buble', 'dark', 'pure'],
45+
choices: ['vue'],
4146
nargs: 1,
4247
requiresArg: true,
4348
type: 'string'
@@ -51,7 +56,7 @@ require('yargs')
5156
type: 'boolean'
5257
}
5358
}),
54-
handler: argv => run.init(argv.path, argv.local, argv.theme, argv.plugins)
59+
handler: argv => run.init(argv.path, argv.local, argv.rcMode, argv.theme, argv.plugins)
5560
})
5661
.command({
5762
command: 'serve [path]',
@@ -93,30 +98,6 @@ require('yargs')
9398
}),
9499
handler: argv => run.serve(argv.path, argv.open, argv.port, argv.P, argv.i)
95100
})
96-
.command({
97-
command: 'start [path]',
98-
desc: chalk.gray(y18n.__('start')),
99-
builder: yargs =>
100-
yargs.options({
101-
config: {
102-
alias: 'c',
103-
default: false,
104-
desc: chalk.gray(y18n.__('start.config')),
105-
nargs: 1,
106-
requiresArg: false,
107-
type: 'string'
108-
},
109-
port: {
110-
alias: 'p',
111-
default: 4000,
112-
desc: chalk.gray(y18n.__('start.port')),
113-
nargs: 1,
114-
requiresArg: true,
115-
type: 'number'
116-
}
117-
}),
118-
handler: argv => run.start(argv.path, argv.config, argv.port)
119-
})
120101
.command({
121102
command: 'generate [path]',
122103
aliases: 'g',

lib/commands/init.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
const fs = require('fs')
44
const cp = require('cp-file').sync
55
const chalk = require('chalk')
6-
const {version} = require('../../package.json')
6+
const {version: cliVersion} = require('../../package.json')
77
const logger = require('../util/logger')
88
const {prompt, MultiSelect} = require('enquirer')
99
const {cwd, exists, pkg, pwd, read, resolve} = require('../util')
1010
const colors = require('ansi-colors')
11+
const semver = require('semver')
1112

1213
const replace = function (file, tpl, replace) {
1314
fs.writeFileSync(file, read(file).replace(tpl, replace), 'utf-8')
1415
}
1516

17+
const replaceAll = function (file, tpl, replace) {
18+
fs.writeFileSync(file, read(file).replaceAll(tpl, replace), 'utf-8')
19+
}
20+
1621
// eslint-disable-next-line
17-
module.exports = async function (path = '', local, theme, plugins) {
22+
module.exports = async function (path = '', local, rcMode, theme, plugins) {
1823
const msg =
1924
'\n' +
2025
chalk.green('Initialization succeeded!') +
@@ -47,11 +52,11 @@ module.exports = async function (path = '', local, theme, plugins) {
4752
}
4853
}
4954

50-
await createFile(cwdPath, local, theme, plugins)
55+
await createFile(cwdPath, local, rcMode, theme, plugins)
5156
console.log(msg)
5257
}
5358

54-
async function createFile(path, local, theme, plugins) {
59+
async function createFile(path, local, rcMode, theme, plugins) {
5560
const target = file => resolve(path, file)
5661
const readme = exists(cwd('README.md')) || pwd('template/README.md')
5762
let main = pwd('template/index.html')
@@ -62,10 +67,11 @@ async function createFile(path, local, theme, plugins) {
6267
const vendor =
6368
exists(cwd('node_modules/docsify')) || pwd('../node_modules/docsify')
6469

65-
cp(resolve(vendor, 'lib/docsify.min.js'), target('vendor/docsify.js'))
70+
cp(resolve(vendor, 'dist/docsify.min.js'), target('vendor/docsify.js'))
71+
cp(resolve(vendor, 'dist/themes/core.css'), target('vendor/themes/core.css'))
6672
cp(
67-
resolve(vendor, `lib/themes/${theme}.css`),
68-
target(`vendor/themes/${theme}.css`)
73+
resolve(vendor, `dist/themes/addons/${theme}.css`),
74+
target(`vendor/themes/addons/${theme}.css`)
6975
)
7076
}
7177

@@ -75,8 +81,6 @@ async function createFile(path, local, theme, plugins) {
7581
cp(main, target(filename))
7682
cp(pwd('template/.nojekyll'), target('.nojekyll'))
7783

78-
replace(target(filename), 'vue.css', `${theme}.css`)
79-
8084
if (pkg.name) {
8185
replace(
8286
target(filename),
@@ -97,20 +101,30 @@ async function createFile(path, local, theme, plugins) {
97101
replace(target(filename), 'repo: \'\'', `repo: '${repo}'`)
98102
}
99103

104+
let resourceVersion = 'rc'
105+
106+
if (!rcMode) {
107+
const {major, prerelease = [], version} = semver.parse(cliVersion) || {}
108+
resourceVersion = prerelease.length ? version : String(major)
109+
}
110+
111+
replaceAll(target(filename), '__docsifyVersion__', `${resourceVersion}`)
112+
100113
// Return early if not opted for plugins
101114
if (!plugins) {
102115
return replace(target(filename), '\n _plugins_', '')
103116
}
104117

105118
const officialPlugins = [
106-
'front-matter',
107-
'search',
108119
'disqus',
109120
'emoji',
110121
'external-script',
122+
'front-matter',
111123
'ga',
112124
'gitalk',
125+
'gtag',
113126
'matomo',
127+
'search',
114128
'zoom-image'
115129
]
116130

@@ -147,7 +161,7 @@ async function createFile(path, local, theme, plugins) {
147161
replace(target(filename), ' _plugins_', '_plugin'.repeat(answers.length + 1))
148162

149163
answers.forEach(plugin => {
150-
const url = `//cdn.jsdelivr.net/npm/docsify@${version[0]}/lib/plugins/${plugin}.min.js`
164+
const url = `//cdn.jsdelivr.net/npm/docsify@${resourceVersion}/dist/plugins/${plugin}.min.js`
151165
replace(target(filename), '_plugin', ` <script src="${url}"></script>\n`)
152166
})
153167

0 commit comments

Comments
 (0)