写点什么

简化插件的添加和更新流程

作者:NocoBase
  • 2024-09-19
    上海
  • 本文字数:2728 字

    阅读完需:约 9 分钟

简化插件的添加和更新流程

NocoBase 是一个极易扩展的开源无代码开发平台。完全掌控,无限扩展,助力你的开发团队快速响应变化,显著降低成本,不必投入几年时间和数百万资金研发,只需要花几分钟部署 NocoBase。

    NocoBase 中文官网

    官方文档

    在线 Demo


为了提升插件管理的体验,我们近期对插件管理器模块进行了重要更新,主要改进了插件的添加和升级流程。请注意这些功能仅在 1.4.0-alpha 及以上版本中提供。当前的 main 分支为 v1.3,若要体验这些新功能,请切换至 next 分支(v1.4)。


本次版本(v1.4.0-alpha.20240914235554)更新的具体内容如下:

插件列表直接读取本地插件


插件列表不再从数据库插件表里读取,而是直接读取以下环境变量或目录下的所有插件:


  • 环境变量

  • APPEND_PRESET_BUILT_IN_PLUGINS

  • APPEND_PRESET_LOCAL_PLUGINS

  • 插件目录

  • packages/plugins:开发中的插件,必须包含插件源码

  • storage/plugins:独立插件,编译之后的插件


插件以 npm package 的形式组织,目录结构如下:


|- /packages/  |- /plugins/    |- /@nocobase/      |- /plugin-hello1/      |- /plugin-hello2/    |- /my-nocobase-plugin-hello1/    |- /my-nocobase-plugin-hello2/|- /storage/  |- /plugins/    |- /@nocobase/      |- /plugin-hello3/      |- /plugin-hello4/    |- /my-nocobase-plugin-hello3/    |- /my-nocobase-plugin-hello4/
复制代码

解压插件包

直接将插件包解压放到指定目录,插件管理器界面也会自动读取。例如:


mkdir -p /my-nocobase/storage/plugins/@nocobase/plugin-auth-cas && \  tar -xvzf /downloads/plugin-auth-cas-1.3.15-beta.tgz \  -C /my-nocobase/storage/plugins/@nocobase/plugin-auth-cas \  --strip-components=1
复制代码


这个命令确保插件解压到 /my-nocobase/storage/plugins/@nocobase/plugin-auth-cas,并且不会包含 package 目录,正确的目录结构如下:


./plugin-auth-cas/dist/server/migrations/20240425200816-change-locale-module.js./plugin-auth-cas/dist/server/auth.js./plugin-auth-cas/client.js./plugin-auth-cas/dist/constants.js./plugin-auth-cas/dist/externalVersion.js./plugin-auth-cas/dist/client/index.js./plugin-auth-cas/dist/index.js./plugin-auth-cas/dist/server/index.js./plugin-auth-cas/dist/server/actions/login.js./plugin-auth-cas/dist/server/plugin.js./plugin-auth-cas/server.js./plugin-auth-cas/dist/server/actions/service.js./plugin-auth-cas/dist/locale/en-US.json./plugin-auth-cas/dist/locale/ko_KR.json./plugin-auth-cas/package.json./plugin-auth-cas/dist/locale/zh-CN.json./plugin-auth-cas/README.md./plugin-auth-cas/README.zh-CN.md./plugin-auth-cas/dist/server/migrations/20240425200816-change-locale-module.d.ts./plugin-auth-cas/dist/server/auth.d.ts./plugin-auth-cas/client.d.ts./plugin-auth-cas/dist/constants.d.ts./plugin-auth-cas/dist/client/index.d.ts./plugin-auth-cas/dist/client/locale/index.d.ts./plugin-auth-cas/dist/index.d.ts./plugin-auth-cas/dist/server/index.d.ts./plugin-auth-cas/dist/server/actions/login.d.ts./plugin-auth-cas/dist/client/Options.d.ts./plugin-auth-cas/dist/server/plugin.d.ts./plugin-auth-cas/server.d.ts./plugin-auth-cas/dist/server/actions/service.d.ts./plugin-auth-cas/dist/client/SigninPage.d.ts./plugin-auth-cas/LICENSE.txt
复制代码

将插件添加和更新流程合并

界面统一通过右上角 Add & Update 按钮添加或更新



也可以使用 pm add 命令添加或更新,流程如下:


商业插件的安装流程

不需要一个一个下载了,直接配置以下环境变量即可


NOCOBASE_PKG_URL=https://pkg.nocobase.com/NOCOBASE_PKG_USERNAME=your-usernameNOCOBASE_PKG_PASSWORD=your-password
复制代码


应用的安装或升级时,将自动下载并升级插件(自动识别版本)


yarn nocobase installyarn nocobase upgrade
复制代码


例如,升级命令日志:


nocobase git:(main) yarn nocobase upgrade$ nocobase upgradeWAIT: TypeScript compiling...$ nocobase pkg download-proDownload success: @nocobase/plugin-custom-brand@1.3.22-betaDownload success: @nocobase/plugin-verdaccio@1.3.22-betaDownload success: @nocobase/plugin-workflow-response-message@1.3.22-betaDownload success: @nocobase/plugin-workflow-request-interceptor@1.3.22-betaDownload success: @nocobase/plugin-workflow-json-query@1.3.22-betaDownload success: @nocobase/plugin-workflow-approval@1.3.22-betaDownload success: @nocobase/plugin-telemetry-prometheus@1.3.22-betaDownload success: @nocobase/plugin-data-source-external-postgres@1.3.22-betaDownload success: @nocobase/plugin-embed@1.3.22-betaDownload success: @nocobase/plugin-data-source-external-mysql@1.3.22-betaDownload success: @nocobase/plugin-workflow-variable@1.3.22-betaDownload success: @nocobase/plugin-collection-fdw@1.3.22-betaDownload success: @nocobase/plugin-demo-platform@1.3.22-betaDownload success: @nocobase/plugin-departments@1.3.22-betaDownload success: @nocobase/plugin-data-source-external-mariadb@1.3.22-betaDownload success: @nocobase/plugin-auth-cas@1.3.22-betaDownload success: @nocobase/plugin-auth-saml@1.3.22-betaDownload success: @nocobase/plugin-auth-oidc@1.3.22-betaDownload success: @nocobase/plugin-comments@1.3.22-betaDownload success: @nocobase/plugin-workflow-custom-action-trigger@1.3.22-betaDownload success: @nocobase/plugin-auth-ldap@1.3.22-betaDownload success: @nocobase/plugin-block-tree@1.3.22-betaDownload success: @nocobase/plugin-auth-dingtalk@1.3.22-betaDownload success: @nocobase/plugin-data-source-rest-api@1.3.22-betaDownload success: @nocobase/plugin-data-source-external-mssql@1.3.22-beta
复制代码


内网服务器,可以先在本地环境下载好插件,然后再将 ./storage/plugins 文件夹上传到内网服务器,最后再执行 NocoBase 安装或升级命令。例如:


scp -r /nocobase1/storage/plugins user2@ip2:/nocobase2/storage/plugins
yarn nocobase install# oryarn nocobase upgrade
复制代码

删除插件

因为插件列表不再从数据库插件表里读取,而是直接读取本地插件,删除插件等同于删除插件文件夹,也就是说删除插件文件夹即为删除插件。

用户头像

NocoBase

关注

还未添加个人签名 2018-05-29 加入

还未添加个人简介

评论

发布
暂无评论
简化插件的添加和更新流程_开源_NocoBase_InfoQ写作社区