Browse Source

Gitbook Auto Published

Willin Wang 8 years ago
parent
commit
c7082d4abb
3 changed files with 135 additions and 59 deletions
  1. 1 0
      SUMMARY.md
  2. 58 59
      book.json
  3. 76 0
      project/tool/tool.md

+ 1 - 0
SUMMARY.md

@@ -28,6 +28,7 @@
     - [包管理NPM](project/tool/npm.md)
     - [Babel](project/tool/babel.md)
     - [守护进程PM2](project/tool/pm2.md)
+    - [造轮子(NPM)篇](project/tool/tool.md)
   - [开发指南](project/develop.md)
     - [功能模块设计](project/user/module.md)
     - [数据库设计](project/user/db.md)

+ 58 - 59
book.json

@@ -1,62 +1,61 @@
-
 {
-    "title": "可替代的团队领袖培养计划",
-    "description": "Author: Willin Wang",
-    "language": "zh-cn",
-    "gitbook": "=2.5.2",
-    "structure": {
-        "readme": "INTRO.md"
-    },
-    "plugins": [
-      "addcssjs",
-      "atoc",
-      "fancybox",
-      "donate",
-      "github",
-      "-disqus",
-      "-duoshuo",
-      "-edit-link",
-      "adsense",
-      "-maxiang"
-    ],
-    "pluginsConfig": {
-        "donate": {
-          "wechat": "http://go.sh.gg/images/wx.png",
-          "alipay": "http://go.sh.gg/images/alipay.png",
-          "title": "如果您觉得受益,请打赏支持!",
-          "button": "赏"
-        },
-        "fontsettings": {
-            "family": "sans",
-            "size": 2
-        },
-        "fancybox":{
+  "title": "可替代的团队领袖培养计划",
+  "description": "Author: Willin Wang",
+  "language": "zh-cn",
+  "gitbook": "=3.2.0",
+  "structure": {
+    "readme": "INTRO.md"
+  },
+  "plugins": [
+    "addcssjs",
+    "atoc",
+    "fancybox",
+    "donate",
+    "github",
+    "-disqus",
+    "-duoshuo",
+    "-edit-link",
+    "adsense",
+    "-maxiang"
+  ],
+  "pluginsConfig": {
+    "donate": {
+      "wechat": "http://go.sh.gg/images/wx.png",
+      "alipay": "http://go.sh.gg/images/alipay.png",
+      "title": "如果您觉得受益,请打赏支持!",
+      "button": "赏"
+    },
+    "fontsettings": {
+      "family": "sans",
+      "size": 2
+    },
+    "fancybox": {
 
-        },
-        "github": {
-            "url": "https://coding.net/u/willin/p/leader.js.cool/git"
-        },
-        "edit-link": {
-            "base": "https://coding.net/u/willin/p/leader.js.cool/git/edit/master/",
-            "label": "编辑此页"
-        },
-        "duoshuo": {
-          "short_name": "leader-js",
-          "theme": "default"
-        },
-        "atoc": {
-          "addClass": true,
-          "className": "atoc"
-        },
-        "addcssjs": {
-          "js": ["_static/main.js"]
-        },
-        "adsense": {
-          "client": "ca-pub-5059418763237956",
-          "slot": "2139110924",
-          "format": "auto",
-          "element": ".page-inner section"
-        },
-        "introduction-text": "封面"
-    }
+    },
+    "github": {
+      "url": "https://coding.net/u/willin/p/leader.js.cool/git"
+    },
+    "edit-link": {
+      "base": "https://coding.net/u/willin/p/leader.js.cool/git/edit/master/",
+      "label": "编辑此页"
+    },
+    "duoshuo": {
+      "short_name": "leader-js",
+      "theme": "default"
+    },
+    "atoc": {
+      "addClass": true,
+      "className": "atoc"
+    },
+    "addcssjs": {
+      "js": ["_static/main.js"]
+    },
+    "adsense": {
+      "client": "ca-pub-5059418763237956",
+      "slot": "2139110924",
+      "format": "auto",
+      "element": ".page-inner section"
+    },
+    "introduction-text": "封面"
+  }
 }

+ 76 - 0
project/tool/tool.md

@@ -0,0 +1,76 @@
+# 造轮子(NPM)篇
+
+注册npm账号,并登陆。
+
+```bash
+npm login
+```
+
+## 初始化项目
+
+```bash
+mkdir xxx-tool
+cd xxx-tool
+npm init
+```
+
+创建各类配置文件,如果使用`ES2015`及之后特性,需要用到`Babel.js`的,需要编译发布。
+
+参考项目: <https://github.com/willin/waliyun>
+
+package.json:
+
+```js
+"scripts": {
+  "compile": "./node_modules/.bin/babel src --out-dir dist",
+  "prepublish": "npm run compile"
+}
+```
+
+## 发布至NPM
+
+### 1.检查`.gitignore`和`.npmignore`文件是否配置好
+
+通常两者内容相近。如:
+
+```
+node_modules/
+*.log
+.DS_Store
+```
+
+`.gitignore`中一般忽略生产环境编译输出的目录`dist/`,`.npmignore`中忽略源码目录`src/`。
+
+### 2.检查`package.json`中的版本号
+
+相同版本号不能反复发布。不能降级发布。每次需要更新并累加版本。
+
+### 3.发布
+
+```bash
+npm publish
+```
+
+发布测试版本:
+
+```bash
+npm publish --tag beta
+```
+
+## 发布私有模块到NPM
+
+初始化项目的时候可以加入参数:
+
+```bash
+npm init --scope=<your_scope>
+```
+
+或者直接修改`package.json`中的项目名称为:
+
+```bash
+@scope/project-name
+# 或
+@username/project-name
+```
+
+参考文档: <https://docs.npmjs.com/private-modules/intro>