npm包的發佈

.npmignore和.gitignore

Use a .npmignore file to keep stuff out of your package. If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it.

.npmignore決定publish之後哪些文件被髮布。

.gitignore決定哪些文件被git跟蹤

npmignore不存在時,發佈時匹配.gitignore中忽略文件

.npmignore.gitignore同時存在,優先讀取.npmignore

若希望被.gitignore忽略的文件,發佈之後還有,則建一個空的.npmignore文件來覆蓋.gitignore

測試.npmignore忽略的文件

可以在本地運行npm pack命令,該命令將在工作目錄中生成壓縮包,與發佈時相同

README.md

編寫包的介紹文檔

發佈

#登錄
npm login
#輸入用戶名密碼
#發佈
npm publish

語義化版本

發佈包應該遵循語義化版本規範
點擊查看詳情

包版本的更新

當前版本爲1.0.0,修改本地版本

  1. npm version patch 版本變爲1.0.1
  2. npm version minor版本變爲1.1.0
  3. npm version major版本變爲2.0.0

git tag

#附註標籤
git tag -a 標籤(一般是版本號) -m "詳細解釋" 
#輕量標籤
git tag 標籤
#查看某一個標籤
git show [標籤]
#列出所有的標籤
git tag
#給某個歷史提交(commitId)打標籤
git tag 標籤 commitId
#刪除標籤
git branch -d 標籤名
#將某個標籤提交到遠程
git push origin 標籤名
#將所有的標籤提交到遠程
git push origin --tags
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章