npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stock-plugin

v1.0.0

Published

进销存业务中台化插件仓库

Readme

业务中台化插件仓库

一般情况下预置业务类型只有预置按钮,其他业务类型包含预置按钮或和预置类型一样即不区分类型

一、本地开发编译 stock-plugin 项目

1. 环境准备

(1)node 版本:node >= 16

比如:

nvm install 16.20.0

备注:

# 建议使用 nvm 进行 node 多版本管理
# 下载安装 nvm.exe 进销存前端群云文档也有,下载地址:https://github.com/coreybutler/nvm-windows/releases

$ nvm node_mirror https://npmmirror.com/mirrors/node/
$ nvm npm_mirror  https://npmmirror.com/mirrors/npm/

# 安装最新版本nodejs,注意观察打印信息
$ nvm install latest

# 检查 nodejs,npm是否都成功安装了
$ nvm list 列出所有已安装的nodejs版本
$ nvm use "版本号" 切换到指定版本nodejs

(2)需要 pnpm >=7 的版本:

# 全局安装 pnpm
npm i -g pnpm

# 如果安装失败,可以指定一下镜像源
npm install -g pnpm --registry=https://registry.npmjs.org/

# 检查 pnpm的版本
$ pnpm --version
# 打印结果:比如 8.3.0 是符合要求的
8.3.0

(3)安装依赖:

建议用 pnpm 命令,在本项目中统一规范:

# 安装根目录、子目录下(packages)的 npm 包
cd stock-plugin
pnpm i

2. Web 端本地开发:设置软连接

软连接基本上只需要设置一次,一劳永逸。

如果在 vcrm 仓库里通过 npm i 更新了 npm 包之后,则需要重新设置软连接。

(1)编译生成 Web 端的 dist 代码:

# 编译生成 stock-plugin-web 目录。此目录已被加入 .ignore 忽略文件
cd stock-plugin
pnpm run dev-web

执行完上方命令后,会在 stock-plugin/stock-plugin-web 目录下,生成编译后的 Web 端 npm 包源码:

image-20230420161950863

命令中的dev-web选项,具备在本地 watch 监听的能力:

image-20230420161447664

如上图所示,出现"waiting for changes"之后,代表 stock-plugin 仓库在本地编译成功。

(2)设置 stock-plugin 仓库的软连接:

# 设置软连接
cd stock-plugin/stock-plugin-web
npm link

(3)设置 vcrm 仓库的软连接:

# 到 vcrm 仓库下
cd vcrm
# 要先切换到与 stock-plugin 仓库一致的npm版本,再设置软连接
nvm use 16
# 设置 软连接
npm link @stock-plugin/web

image-20230420165416969

上方命令执行完成后,即可将 node 版本切换回 node 10.x,继续编译 vcrm 仓库。

然后本地编译 vcrm 仓库:

cd vcrm
npm run dev

(4)web 端软连接的原理:把 stock-plugin 代码仓库的 @stock-plugin/web 包映射到全局 node_modules,然后在 vcrm 项目中引用软连接 @stock-plugin/web 的 npm 包。

image-20230420162806756

比如,我们打开 vcrm 仓库的某个进销存对象的文件 vcrm/src/modules/plugin/stock/sparepartsconsumptionobj/index.js :

image-20230420170152166

点击之后,会跳转到 stock-plugin 代码仓库的 stock-plugin-web/dist 目录下:

image-20230426142233935

然后,我们就可以在 stock-plugin 仓库中,写本地代码并调试了。

3. 小程序开发和发布

小程序尚无法进行本地调试开发。需要提交 stock-plugin/stock-plugin-mini目录下的代码到远程分支。然后在小程序 object_form_paas 仓库的 subproject.config.json文件中,引入 stock-plugin 仓库的 stock-plugin-mini 目录和指定分支

具体步骤如下:

(1)在 stock-plugin 仓库中写完代码之后,执行如下命令编译小程序代码:

# 编译生成 stock-plugin-mini 目录(即小程序分包需要的源码)
pnpm run dev-mini

执行完上方命令后,会在 stock-plugin/stock-plugin-mini 目录下,生成编译后的小程序端源码。

(2)在终端 commit 代码:

# 请修改为你自己的 commit 信息
git commit -m 'stock_test'

执行完上方命令后,stock-plugin/.husky/pre-commit文件中的脚本,会自动检查 stock-plugin-mini 目录下的代码是否编译完整。如果不完整,脚本会自动执行 pnpm run dev-mini命令然后一并 stock-plugin-mini 下的文件 提交到 git。

image-20230426145944281

(3)git push:将指定分支的代码提交到 stock-plugin 远程仓库。

(4)在 object_form 仓库的 subproject.config.json 文件中,将 stock-plugin 修改为指定分支。然后发布 object_form 小程序,即可完成发布任务。

image-20230426151301482

二、Web 端:发布 stock-plugin 的 npm 包

每次发布 stock-plugin 的 npm 包时,需要更新 npm 包的版本号:

  • 主版本号(major):与大版本保持一致。比如 850 版本、865 版本。
  • 次版本号(minor):当前大版本中,添加了新的 feature;记得需要向后兼容,不破会现有的 API。
  • 修订号(patch):当前大版本中,进行 bug 修复。记得需要向后兼容,且不添加新的功能或更改任何 API。

1. 生成变更记录

(1)执行如下命令:

# Web 端发布 npm 包。会自动生成版本号。
pnpm changeset:add

(2)按空格键,选择要发布的内容:用上下箭头选择需要发布的内容选项;然后按空格,命中这条选项,然后按 enter 键,执行命令:

image-20230421103046986

(3)按空格,选择更新“主版本号 major“ ;或者,按 enter,直接跳过,不更新主版本号:

image-20230421103108825

image-20230421103253081

(4)按空格,选择更新“次版本号 minor“ ;或者,按 enter,直接跳过,不更新次版本号:

image-20230421103352999

(5)手动输入版本变更的文案备注,比如:

image-20230421103557067

然后按 enter 键:

image-20230421103723237

再按 Y,表示确认:

image-20230421103752779

之后会在 .changeset 目录下生成一个 md 文件:

odd-buses-yawn.md 这个文件记录了变更的内容和版本。之后,你每次的 git commit,都会被记录。

(备注:git commit,可以每生成一次变更就提交,也可以生成多次记录再统一 git commit。)

2. 生成版本号(消耗变更记录)

根据在上面第 1 步的设置的版本号要求,输入如下命令,生成 npm 版本号:

pnpm changeset:version

image-20230421104248703

上面的命令,会消耗第 1 步的变更记录(可以看到,第 1 步中的.chagneset/odd-buses-yawn.md自动消失了),自动生成 CHANGELOG.md文件。举例如下:

上面的 CHANGELOG.md 文件中生成的版本号,就是我们即将要发布的 npm 包的版本。如果你想手动修改版本号,可以直接改这个 CHANGELOG.md 文件里的版本号数字

然后执行 git commit,生成的版本号改动:

git add .
git commit -m 'release'

3. 注册 npm 私有仓库的账号

如果此前已经注册过 npm 私有仓库的账号,请跳过此步。

(1)注册 npm 私有仓库的账号,并输入邮箱号和密码:

npm adduser --registry https://registry-npm.firstshare.cn

(2)登录 npm 私有仓库主页,如果登录成功,则说明账号注册成功:

  • npm 私有仓库主页:https://registry-npm.firstshare.cn/

这里集中存放了进销存所有业务中台插件。

补充说明:

# 大家在发布npm包时需要重新执行adduser操作
# 注册 npm 私有仓库的账号(可以用自己的域账号注册)
npm adduser --registry https://registry-npm.firstshare.cn

#发布命令
npm publish --registry https://registry-npm.firstshare.cn

#发布后,可以登录网页,确认是否发布成功了
https://registry-npm.firstshare.cn/

4. 发布 npm 包到 npm 仓库

执行如下命令,发布 npm 包到 npm 仓库:

pnpm release

case1、如果发布失败,可能是以下情况:(解决办法:需要本地代码提交到 git。如果 pnpm-lock.yaml 文件被自动修改了,也可以临时提交一下,大不了后面再换回来)

image-20230421105128079

case2、如果上方命令不报错,则会出现下方提示:

image-20230421110405658

上图中,直接输入 y 即可,npm 包的新版本就发布成功了:

image-20230421110519462

然后去 npm 仓库主页 瞧一眼,看看发布成功的版本记录:

image-20230421110942924

三、小程序端发布 stock-plugin 的原理

1、在 stock-plugin 仓库中生成小程序端的源码目录 stock-plugin/stock-plugin-mini。

2、在 stock-plugin 仓库中,将 stock-plugin/stock-plugin-mini 设置为出口目录:

image-20230426151552989

3、在 object_form_paas 仓库中,下载 stock-plugin 仓库指定分支的源码:

image-20230426151711134

4、在 object_form_paas 仓库中编译小程序项目时,将 stock-plugin-mini 作为分包。这个子包是小程序中真正需要的进销存 md2.0 源码:

image-20230426151858687

小结:通过 git clone 指定仓库和分支,判断 subproject.config.json 的出口目录 ./stock-plugin-mini,作为 object_form 分包引入小程序:

https://git.firstshare.cn/fe-tools/watcher  可以使用这个工具进行文件拷贝同步
$ pnpm run dev-mini 会生成 ./stock-plugin-mini 小程序分包

Docs

业务中台化插件机制 表单页业务插件 api 文档 server 插件配置

How to use

npm 包引入

插件如何下发

web vcrm 代码写死

src/modules/action/view/myobject/pluginconfig.js

server 下发

112 配置中心

线上配置中心

web 会和 server 下发的做一次 merge,理论上两种方式都可行,但是依赖后台的插件必须在配置中心配置

StockCheckNoteObj md=> (batch_stock_id, batch_sn, stock_id) 隐藏整一列 RequisitionNoteObj md=> (batch_stock_id, batch_sn, stock_id) 隐藏整一列

excel 导入

md2.0 从对象,支持从本地导入 excel 的前提条件:(即:从对象右上角展示 "从本地 Excel 导入"按钮) 1、已灰度 excel 导入功能;灰度变量:isGrayExcelCopy。112 环境可灵活添加企业 EA,线上环境需发起申请流程。 2、业务侧的从对象,已灰度 md2.0 插件。 3、业务侧的从对象,前端代码中未使用 retain 等属性写死按钮逻辑。

符合以上条件后,从对象引入 md2.0 插件之后,默认就会有 excel 导入的按钮