npm包開發(whale-makelink)

whale-makelink是一個npm工具,是強業務的工具,能夠將當前工程目錄下的項目文件夾,在README中生成項目的連接地址。Demonode

 

1、npm initgit

使用npm init生成package.jsongithub

{
"name": "whale-makelink",
"version": "1.0.5",
"description": "Make-link can get all the project folders of the current directory, and generate the project link directory in the readme.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@github.com:jingwhale/whale-makelink.git"
},
"keywords": [
"makelink"
],
"author": "jingwhale@yeah.net",
"license": "ISC"
}

 

2、自定義命令npm

2.一、在package.json的bin下定義一個對象,這裏makelink就是須要的命令,內容交給index.jsjson

{
"name": "whale-makelink",
"version": "1.0.5",
"description": "Make-link can get all the project folders of the current directory, and generate the project link directory in the readme.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@github.com:jingwhale/whale-makelink.git"
},
"bin": {
"makelink": "./index.js"
},
"keywords": [
"makelink"
],
"author": "jingwhale@yeah.net",
"license": "ISC"
}

 

2.二、在index.js中添加'#!/usr/bin/env node'svg

#!/usr/bin/env node

const path = require('path');
const makelink = require('./makelink');

const pathName = path.resolve(__dirname, '../..');
const srcFile = pathName + '/README.md';

makelink(srcFile,pathName);

 

3、發佈npm包工具

3.一、註冊ui

npm官網註冊,而且經過郵件驗證後,才能發npm包。url

 

3.二、登陸spa

npm login

輸入用戶名、密碼和郵箱。

 

3.三、發佈

npm publish

 

3.四、版本更新

1)、變動版本號-自動改變版本

npm version <update_type>

update_type爲patch, minor, or major其中之一,分別表示補丁,小改,大改

如果patch,變爲1.0.1
如果minor,變爲1.1.0
如果major,變爲2.0.0

 

2)、發佈

npm publish

 

3.五、發佈出錯

1)、驗證郵箱

2)、修正npm源

npm config get registry
npm config set registry=http://registry.npmjs.org

 

4、更新package.json

更新package.json後,須要先提交到github,再進行版本的升級。

 

5、版本展現

建立

 

readme中使用

![verion](https://img.shields.io/badge/npm-1.0.8-brightgreen.svg)

 

策略

每次代碼更新完畢,在進行版本的升級操做。

 

6、npm whale-makelink

相關文章
相關標籤/搜索