Keine Beschreibung

zhangweicheng 2e1bc949fd feat(types): 添加定额类型,以及甚而的枚举类型 vor 5 Jahren
crypto 5b88685e8f feat: 加密工具 vor 5 Jahren
handsontable 8337d528d1 chore(handsontable): 类型文件更改 vor 5 Jahren
mathUtil 68817bb2c3 feat(math): 添加getNumberFromUnit方法,获取单位前的数字 vor 5 Jahren
report d3eb3db8cb report code first check in vor 5 Jahren
tree 9866f213e9 fix(tree): nodeContext visible bug vor 5 Jahren
types 2e1bc949fd feat(types): 添加定额类型,以及甚而的枚举类型 vor 5 Jahren
.gitignore 7b3546615a feat: 数学计算4舍5入包 vor 5 Jahren
README.md 9d5fb81f87 docs: add README.md vor 5 Jahren

README.md

npm私服搭建

qa

verdaccio + pm2

内网地址:http://192.168.1.90:4873

内网穿透:http://smartcost.in.8866.org:26904/

客户端使用

在指定了私服地址后执行npm install,package.json中特定前缀的包(比如"@sc/**")会从私服中下载,其他前缀的包从taobao下载。(verdaccio config.yml中配置)

npm设置

将npm registry设置为私服地址http://192.168.1.90:4873,设置了npm registry后才能安装、发布、取消发布、更新私服的包。

npm config set registry http://192.168.1.90:4873

nrm

由于npm的私服包的安装或发布都需要指定registry,为了方便,可以使用nrm来管理registry。

安装

npm install -g nrm

使用

  • 将registry地址用别名来取代: nrm add smartcost http://192.168.1.90:4873
  • 切换npm registry: nrm use smartcost

使用nrm use命令切换registry后,npm install等命令不需要带上--registry选项了。

使用nrm ls可以查看当前npm registry地址

  • 添加用户 npm adduser

npm包开发、发布流程

开发

  1. 克隆SCCommon项目 http://192.168.1.41:3000/SmartCost/SCCommon ,用于各库的git管理,所有库作为SCCommon项目的子目录,如test库:SCCommon/test/...
  2. 基于JavaScript编写库或TypeScript编写库,从git拷贝相应工程目录到SCCommon项目的对应库目录下。

    js-template:

    http://192.168.1.41:3000/SmartCost/javascript-package-template

    ts-template:

    http://192.168.1.41:3000/SmartCost/typescript-package-template

  3. 在对应库目录下(如SCCommon/test/)安装依赖npm install

  4. 修改package.json文件,将name字段修改为包名称。必须以“@sc/”开头。

  5. 在对应库目录下的src文件夹下开始开发(注意src文件夹必须要有index入口文件(.js、.ts))。

  6. 在对应库目录下执行打包命令npm run build,打包后的文件会被输出到dist文件夹。

  7. 如果库基于JavaScript开发,且库需要被TypeScript项目引入。由于TypeScript是强类型语言,必须要有类型声明。因此,必须要在dist文件夹下,编写index.d.ts声明文件。参考: https://www.tslang.cn/docs/handbook/declaration-files/introduction.html

注意:rollup打包模块基于ESModule,因此在开发包的时候,模块规范为ESModule(import... export...)

发布

在npm注册了私服地址后,在对应库目录下(如SCCommon/test/)下执行命令:

npm publish

若报错提示缺少权限,则执行npm adduser添加新用户或登陆npm login

更新

本地代码

本地代码通过git方式提交至SCCommon仓库(每个库都为SCCommon的一个子目录)

npm包

  1. 更新npm包时,应对npm包版本号(package.json version字段)进行迭代:npm version x.x.x
  2. 重新发布npm publish(当前版本号与远程包版本号一样的情况下无法更新)

    使用了相关包的项目

    执行npm update libName

若更新失败,可删除package-lock.json后重新执行安装命令。