{"size": 4783, "ext": "js", "max_stars_repo_path": "docs/.vuepress/dist/assets/js/11.3457136c.js", "max_stars_repo_name": "G-Tristin/vuepress", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "docs/.vuepress/dist/assets/js/11.3457136c.js", "max_issues_repo_name": "G-Tristin/vuepress", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "docs/.vuepress/dist/assets/js/11.3457136c.js", "max_forks_repo_name": "G-Tristin/vuepress", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 4783.0, "max_line_length": 4783, "alphanum_fraction": 0.6383023207}
(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{215:function(t,e,n){"use strict";n.r(e);var s=n(0),r=Object(s.a)({},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"content"},[t._m(0),t._v(" "),n("p",[n("a",{attrs:{href:"https://www.cnblogs.com/vok-think/p/7475073.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("文档"),n("OutboundLink")],1)]),t._v(" "),n("p",[t._v('注:第一个文档当中有一个错误 就是"bin"字段后面应该是一个对象')]),t._v(" "),n("p",[n("a",{attrs:{href:"https://www.npmjs.cn/",target:"_blank",rel:"noopener noreferrer"}},[t._v("官方文档"),n("OutboundLink")],1)]),t._v(" "),t._m(1),t._v(" "),t._m(2),t._v(" "),t._m(3),t._m(4),t._v(" "),t._m(5),t._v(" "),t._m(6),t._v(" "),t._m(7),t._v(" "),n("p",[t._v("我们可以使用自定义的命令来实现制作自己的脚手架等等")]),t._v(" "),t._m(8),t._v(" "),t._m(9),t._v(" "),n("p",[t._v('加入"bin"字段')]),t._v(" "),t._m(10),t._m(11),t._v(" "),n("p",[t._v("在目前使用的例子当中,我先在同级目录下创建了一个bin的文件夹,里面包含了一个定义命令行的文件host.js, 注意我们要告诉系统这个host文件是使用node执行的所以这个文件必须添加 #!/usr/bin/env node")]),t._v(" "),t._m(12),t._m(13)])},[function(){var t=this.$createElement,e=this._self._c||t;return e("h1",{attrs:{id:"如何发布包"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#如何发布包","aria-hidden":"true"}},[this._v("#")]),this._v(" 如何发布包")])},function(){var t=this.$createElement,e=this._self._c||t;return e("h2",{attrs:{id:"发布一个自定义包的步骤"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#发布一个自定义包的步骤","aria-hidden":"true"}},[this._v("#")]),this._v(" 发布一个自定义包的步骤")])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[this._v("通过npm init -y 创建一个默认的page.json文件")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[this._v("name:  vsv  // 模块名称\nversion: (1.0.0) 1.0.1 // 基础版本号\ndescription: 描述 // 模块描述\nentry point: (index.js) index.js // 默认入口\ntest command: none // 测试指令\ngit repository: https://github.com/vok123....  // 个人git仓库地址\nkeywords: server // 关键字\nauthor: vok // 作者\nlicense: (ISC) //默认值\n")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[e("p",[this._v("在该目录下创建功能型文件或者文件夹(包含功能型文件),并将功能型代码的API导出模块")])]),this._v(" "),e("li",[e("p",[this._v("在同级目录下创建一个index.js文件,该文件的作用引入功能型文件(单个或多个有利于模块化开发),并将其导出.")])]),this._v(" "),e("li",[e("p",[this._v("最好写一个README.md文件来说明包的使用方法和作用")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("h3",{attrs:{id:"publish发布代码的注意事项"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#publish发布代码的注意事项","aria-hidden":"true"}},[this._v("#")]),this._v(" publish发布代码的注意事项")])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[e("p",[this._v("切换包的源地址到npm")])]),this._v(" "),e("li",[e("p",[this._v("确认有npm的账户")])]),this._v(" "),e("li",[e("p",[this._v("通过npm login登录")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("h2",{attrs:{id:"通过发布包来自定义命令"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#通过发布包来自定义命令","aria-hidden":"true"}},[this._v("#")]),this._v(" 通过发布包来自定义命令")])},function(){var t=this.$createElement,e=this._self._c||t;return e("h3",{attrs:{id:"如何自定义命令"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#如何自定义命令","aria-hidden":"true"}},[this._v("#")]),this._v(" 如何自定义命令")])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[this._v("编辑package.json文件")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[this._v('{\n  "name": "tristan-page",\n  "version": "1.0.10",\n  "description": "",\n  "main": "index.js",\n  "bin":{"jan":"./bin/host.js"}, // 是一个对象类型的json.jan代表命令名称 后面代表要执行的文件 全局安装必备\n  "scripts": {\n    "test": "echo \\"Error: no test specified\\" && exit 1"\n  },\n  "keywords": [],\n  "author": "G-tristan",\n  "license": "ISC",\n  "dependencies": {\n    "commander": "^2.19.0"\n  }\n}\n')])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[this._v("创建生成命令的文件(在node中我们一般使用commander包来编辑命令 下载commander要使用 -S 因为这个依赖被包内部应用只有使用-S才能会下载包的时候把这个模块带上)")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[this._v("#!/usr/bin/env node\nconst program = require('commander')\nprogram\n  .version(require('../package').version)\n  .option('-p, --port [port]', 'Input port!')\n  .parse(process.argv)\nconsole.log(program.port)\n")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("ul",[e("li",[e("p",[this._v("发布之后全局安装这个包 -g")])]),this._v(" "),e("li",[e("p",[this._v("使用命令 jan -p 8999")])])])}],!1,null,null,null);e.default=r.exports}}]);