Skip to content

Commit 0174567

Browse files
committed
release: v1.0.1
1 parent 020cb3d commit 0174567

File tree

4 files changed

+236
-465
lines changed

4 files changed

+236
-465
lines changed

README.md

+76-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,99 @@
11
# echarts-offline-doc-cli
2+
[![NPM version](https://img.shields.io/npm/v/echarts-offline-doc-cli.svg?style=flat)](https://www.npmjs.org/package/echarts-offline-doc-cli)
3+
[![Auto Deploy](https://github.com/plainheart/echarts-offline-doc-cli/actions/workflows/deploy.yaml/badge.svg)](https://github.com/plainheart/echarts-offline-doc-cli/actions/workflows/deploy.yaml)
4+
[![NPM Downloads](https://img.shields.io/npm/dm/echarts-offline-doc-cli.svg)](https://npmcharts.com/compare/echarts-offline-doc-cli?minimal=true)
5+
[![License](https://img.shields.io/npm/l/echarts-offline-doc-cli.svg)](https://github.com/plainheart/echarts-offline-doc-cli/blob/main/LICENSE)
6+
27
A CLI tool for offline documentation of Apache ECharts.
38

4-
# Build Steps
9+
[Preview on GitHub Pages](https://plainheart.github.io/echarts-offline-doc-cli)
10+
11+
![Screenshot](https://user-images.githubusercontent.com/26999792/229869304-4a782121-4324-4e68-9f3d-a956d0c60ee6.png)
12+
13+
# Get Started
14+
15+
## Install Globally
16+
17+
```sh
18+
npm i echarts-offline-doc-cli -g
19+
```
20+
21+
### Build Offline Documentation
22+
23+
```sh
24+
echarts-offline-doc --build
25+
# Equivalent to:
26+
echarts-offline-doc -b
27+
28+
# If it's slow to clone the echarts-doc repo
29+
# you can specify a proxy URL
30+
echarts-offline-doc --build --proxy https://hub.fgit.gq/apache/echarts-doc
31+
# Equivalent to:
32+
echarts-offline-doc -b -p https://hub.fgit.gq/apache/echarts-doc
33+
34+
# If it's slow to install dependencies
35+
# you can optionally use `cnpm`
36+
echarts-offline-doc --build --cnpm
37+
# Equivalent to:
38+
echarts-offline-doc -b -c
39+
40+
# View Help
41+
echarts-offline-doc --help
42+
# Equivalent to:
43+
echarts-offline-doc -h
44+
```
45+
46+
### View Offline Documentation With an HTTP Server
47+
48+
```sh
49+
echarts-offline-doc
50+
# Equivalent to:
51+
echarts-offline-doc --serve
52+
# Equivalent to:
53+
echarts-offline-doc -s
54+
```
55+
56+
### View Offline Documentation Locally
57+
58+
```sh
59+
echarts-offline-doc --local
60+
# Equivalent to:
61+
echarts-offline-doc -l
62+
```
63+
64+
## Build From Source
565

666
```sh
767
# clone the repo
8-
git clone https://github.com/plainheart/echarts-offline-doc-cli.git --depth=1
68+
git clone https://github.com/plainheart/echarts-offline-doc-cli --depth=1
969

1070
# install dependencies
1171
npm i
1272

1373
# build offline documentation
1474
npm run build
1575

16-
# If it's slow to clone the echarts-doc repo or install dependencies
76+
# If it's slow to clone the echarts-doc repo
1777
# you can specify a proxy URL
18-
npm run build -- --proxy=https://hub.fgit.gq/apache/echarts-doc
78+
npm run build -- --proxy https://hub.fgit.gq/apache/echarts-doc
79+
# Equivalent to:
80+
npm run build -- -p https://hub.fgit.gq/apache/echarts-doc
1981

2082
# If it's slow to install dependencies
2183
# you can optionally use `cnpm`
2284
npm run build -- --cnpm
85+
# Equivalent to:
86+
npm run build -- -c
2387

24-
# start a local server to view the documentation offline
25-
npm run start:server
88+
# start an HTTP server to view the documentation offline
89+
npm start
90+
# Equivalent to:
91+
npm run serve
2692

27-
# or run the following command to open the static pages without a server
28-
npm run start
93+
# or run the following command to open the static pages locally without a server
94+
npm run local
2995
```
3096

97+
## License
3198

99+
MIT © 2021-2023 [plainheart](https://github.com/plainheart).

bin/echarts-offline-doc.js

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
#!/usr/bin/env node
22

3+
'use strict'
4+
35
const program = require('commander')
4-
const { version } = require('../package.json')
6+
const { version, scripts } = require('../package.json')
57

68
const config = require('../config')
79

810
program
911
.version(version, '-v, --version')
1012
.usage('[options]')
11-
.option('-p, --proxy [url]', 'URL of the proxy repo')
12-
.option('-c, --cnpm', 'Whether to use `cnpm` to install dependencies')
13+
.option('-b, --build', 'build/rebuild the offline documentation')
14+
.option('-p, --proxy [url]', 'URL of the proxy repo to be used when building the offline documentation')
15+
.option('-c, --cnpm', 'whether to use `cnpm` to install dependencies when building the offline documentation')
16+
.option('-s, --serve', 'start an HTTP server and open the default browser to view the documentation')
17+
.option('-l, --local', 'open the static pages locally without a server')
1318
.parse(process.argv)
1419

1520
const options = program.opts()
1621

17-
if (options.proxy) {
18-
config.DOC_REPO = options.proxy
22+
if (options.build) {
23+
if (options.proxy) {
24+
config.DOC_REPO = options.proxy
25+
}
26+
27+
config.USE_CNPM = options.cnpm
28+
29+
require('..')()
30+
}
31+
else {
32+
require('cross-spawn')
33+
.spawn(scripts[options.local ? 'local' : 'serve'], {
34+
cwd: require('node:path').resolve(__dirname, '../'),
35+
stdio: 'inherit',
36+
windowsHide: true,
37+
detached: false
38+
})
1939
}
2040

21-
config.USE_CNPM = options.cnpm
2241

23-
require('..')()

0 commit comments

Comments
 (0)