从零系列--开发npm包(二)

一、利用shell简化组合命令

set -e

CVERSION=$(git tag | tail -1) 
echo "current version:$CVERSION"

echo "Enter release version: "
read VERSION

read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r
echo    # (optional) move to a new line

if [[ $REPLY =~ ^[Yy]$ ]]
then
  echo "Releasing $VERSION ..."
  
  # commit
  git add -A
  git commit -m "[build] $VERSION"
  npm version $VERSION --message "[release] $VERSION"

  # publish
  git push -u origin master
  git push
  npm publish
fi

二、利用gitbook编写文档

1、安装gitbook

npm i -g gitbook-cli -d 

2、docs目录结构

.
├── book.json
├── README.md
├── SUMMARY.md
├── part1/
|   ├── README.md
|   └── something.md
└── part2/
    ├── README.md
    └── something.md

3、特殊文件描述

文件                描述
book.json          配置数据 (optional)
README.md          电子书的前言或简介 (required)
SUMMARY.md         电子书目录 (optional)
GLOSSARY.md        词汇/注释术语列表 (optional)

4、SUMMARY.md文件内容

# xx* [Introduction](README.md)
* [Part I](part1/README.md)
    * [Writing is nice](part1/writing.md)
    * [GitBook is nice](part1/gitbook.md)
* [Part II](part2/README.md)
    * [We love feedback](part2/feedback_please.md)
    * [Better tools for authors](part2/better_tools.md)

5、利用shell组合命令

cd docs
rm -rf _book
gitbook install
gitbook build

cd _book
git init
git add -A
git commit -m 'update book'
git push -f git@gitlab.com:xxx/xxxx.git master:gh-pages
原文地址:https://www.cnblogs.com/sjptech/p/9581472.html