-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28e7517
commit a74b9d7
Showing
60 changed files
with
4,004 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/cmds | ||
/demo | ||
/global | ||
/util | ||
/.bookignore | ||
/go.* | ||
/LICENSE | ||
/makefile | ||
/*.go | ||
/.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
tmp | ||
gbook* | ||
gbook* | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
# gbook | ||
仅support gitbook 3.2.3, 解决gitbook太慢的问题 | ||
|
||
support gitbook 3.2.3, 其他版本自测, 解决 gitbook 太慢的问题 | ||
|
||
## 开启此项目初衷 | ||
|
||
gitbook 3.2.3 为历史项目,插件下载需要整体拉取,非常缓慢,也不支持单个拉取,这样`gbook`就应运而生了, | ||
如果不想频繁切换 node 版本,`gbook`也适合你 | ||
|
||
## 依赖 | ||
|
||
- `node` <= 10, 建议 Node 版本 10.24.1 | ||
- `gitbook-cli` 必须 | ||
- 请自行设置好 npm 加速镜像,如淘宝镜像,建议使用 `nrm` 设置 | ||
|
||
## 稳定运行 gbook | ||
|
||
将 BOOK_NODE_HOME 变量设置为需要的 node 版本路径,加入到系统变量中, 这样`gbook`会使用对应 node 版本执行命令了,不再受全局其他版本 node 影响。 | ||
|
||
## 详细说明 | ||
|
||
参考 https://gofulljs.github.io/gbook/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Summary | ||
|
||
- [Introduction](README.md) | ||
- [命令概览](book/index.md) | ||
- [ready 命令](book/ready.md) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"author": "gofulljs", | ||
"plugins": [ | ||
"back-to-top-button", | ||
"-lunr", | ||
"-search", | ||
"search-plus", | ||
"a-import", | ||
"code", | ||
"anchor-navigation-ex", | ||
"ga", | ||
"3-ba", | ||
"github" | ||
], | ||
"pluginsConfig": { | ||
"code": { | ||
"copyButtons": false | ||
}, | ||
"anchor-navigation-ex": { | ||
"tocLevel1Icon": "fa fa-hand-o-right", | ||
"tocLevel2Icon": "fa fa-hand-o-right", | ||
"tocLevel3Icon": "fa fa-hand-o-right", | ||
"multipleH1": false, | ||
"multipleH2": false, | ||
"multipleH3": false, | ||
"multipleH4": false, | ||
"showLevelIcon": false, | ||
"showLevel": false | ||
}, | ||
"ga": { | ||
"token": "G-VMFJ3KGT9" | ||
}, | ||
"3-ba": { | ||
"token": "4c1823e87df49c9e304623b546c910fd" | ||
}, | ||
"github": { | ||
"url": "https://github.com/gofulljs" | ||
}, | ||
"disqus": { | ||
"shortName": "gopher-1" | ||
} | ||
}, | ||
"styles": { | ||
"website": "styles/website.css" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 命令概览 | ||
|
||
```sh | ||
$ gbook -h | ||
NAME: | ||
gbook - uniswap tick update, other command will forward gitbook * | ||
|
||
USAGE: | ||
gbook [global options] command [command options] [arguments...] | ||
|
||
VERSION: | ||
v1.0.0 | ||
|
||
COMMANDS: | ||
ready check env is ready | ||
sync sync gitbook | ||
sync2 sync2 gitbook, 不包含node_modules, suggest | ||
install, i install plugin | ||
`install`: install all plugins from gitbook | ||
`install [plugins...]`: install plugin you want, eg: `gbook install code ga` | ||
help, h Shows a list of commands or help for one command | ||
|
||
GLOBAL OPTIONS: | ||
--bookVersion value, --bv value (default: "3.2.3") [%BOOK_VERSION%] | ||
--bookHome value, --bh value gitbook path, default is $HOME/.gitbook/versions/ | ||
--nodePath value nodejs home, if not specified, use current node [%BOOK_NODE_HOME%] | ||
--help, -h show help | ||
--version, -v print the version | ||
``` | ||
- `bookVersion`: 默认使用 gitbook 引擎为 3.2.3 | ||
- `bookHome`: 默认 gitbook 引擎存放位置 | ||
- `nodePath`: `gbook` 使用指定路径的 node 版本,可使用`BOOK_NODE_HOME`配置到环境变量中 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ready | ||
|
||
```sh | ||
gbook ready | ||
``` | ||
|
||
- 依赖检测,检测 node 版本和 gitbook 引擎版本是否安装正确 | ||
- 请确保当前 node 版本正常或已配置好 `BOOK_NODE_HOME` 环境变量 | ||
- 若不报错表示环境正常 | ||
- `install` 命令会默认执行一次次命令 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# sync | ||
|
||
```sh | ||
gbook -h | ||
NAME: | ||
gbook sync - sync gitbook | ||
|
||
USAGE: | ||
gbook sync [command options] [arguments...] | ||
|
||
OPTIONS: | ||
--source value gitbook数据源(包含node_modules) (default: "https://github.com/gofulljs/gitbook/releases/download/3.2.3/3.2.3.tar.gz") | ||
--proxy1 value 自定义加速源(前缀+source), 不传采用以下 | ||
[https://ghps.cc/ https://gh.api.99988866.xyz/ https://github.abskoop.workers.dev/] | ||
--proxy2 value 自定义加速源(替换https://github.com前缀) | ||
--help, -h show help | ||
|
||
``` | ||
|
||
拉取 gitbook 引擎到 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package app | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os/exec" | ||
"time" | ||
|
||
"github.com/gofulljs/gbook/cmds/cmdutil" | ||
"github.com/gofulljs/gbook/cmds/ctest" | ||
"github.com/gofulljs/gbook/cmds/install" | ||
"github.com/gofulljs/gbook/cmds/ready" | ||
"github.com/gofulljs/gbook/cmds/sync" | ||
"github.com/gofulljs/gbook/cmds/sync2" | ||
"github.com/gofulljs/gbook/global" | ||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
var LogDetail = false | ||
|
||
func InitApp() *cli.App { | ||
return &cli.App{ | ||
Name: global.AppName, | ||
Usage: "uniswap tick update, other command will forward gitbook *", | ||
Version: "v1.0.0", | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "bookVersion", | ||
Aliases: []string{"bv"}, | ||
Value: global.BOOK_VERSION, | ||
EnvVars: []string{"BOOK_VERSION"}, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "bookHome", | ||
Aliases: []string{"bh"}, | ||
Usage: "gitbook path, default is $HOME/.gitbook/versions/", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "nodePath", | ||
Usage: "nodejs home, if not specified, use current node", | ||
EnvVars: []string{"BOOK_NODE_HOME"}, | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "logDetail", | ||
Usage: "print log Detail for development", | ||
Hidden: true, | ||
Aliases: []string{"ld"}, | ||
Destination: &LogDetail, | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
|
||
//check | ||
err := cmdutil.Check(cctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
args := cctx.Args().Slice() | ||
fmt.Print("forward:\n", "gitbook ") | ||
for _, v := range args { | ||
fmt.Print(v + " ") | ||
} | ||
fmt.Println() | ||
|
||
return gitbookForward(args) | ||
}, | ||
Commands: []*cli.Command{ | ||
ready.Run, | ||
sync.Run, | ||
sync2.Run, | ||
install.Run, | ||
ctest.Run, | ||
}, | ||
} | ||
} | ||
|
||
func gitbookForward(args []string) (err error) { | ||
|
||
cmd := exec.Command("gitbook", args...) | ||
|
||
stdout, err := cmd.StdoutPipe() | ||
if err != nil { | ||
return xerrors.Errorf("%w", err) | ||
} | ||
cmd.Stderr = cmd.Stdout | ||
|
||
if err = cmd.Start(); err != nil { | ||
return xerrors.Errorf("%w", err) | ||
} | ||
// 从管道中实时获取输出并打印到终端 | ||
for { | ||
tmp := make([]byte, 4096) | ||
n, err := stdout.Read(tmp) | ||
fmt.Print(string(tmp[:n])) | ||
if err != nil { | ||
if err == io.EOF { | ||
break | ||
} | ||
return xerrors.Errorf("%w", err) | ||
} | ||
time.Sleep(100 * time.Millisecond) | ||
} | ||
if err = cmd.Wait(); err != nil { | ||
return xerrors.Errorf("%w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ctest | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gofulljs/gbook/global" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var Run = &cli.Command{ | ||
Name: global.CmdTest, | ||
Usage: "for test", | ||
Hidden: true, | ||
Action: func(cctx *cli.Context) error { | ||
|
||
fmt.Println("test") | ||
|
||
return nil | ||
}, | ||
} |
Oops, something went wrong.