文章
· 十一月 26, 2022 阅读大约需 4 分钟

ZPM介绍(3)

建立私服(Porxy-Registry)

这张图解释了您的私服是怎么工作的, 整篇文章在这里: Proxy-Registry

搭建私服

您需要有一台自己的的服务器, 在上面安装IRIS, zpm, 然后用zpm去下载另一个软件包“zpm-registry"。象这样

zpm:DEMO>search -r zpm-registry
registry https://pm.community.intersystems.com:
zpm-registry 1.1.11Repository: https://github.com/intersystems-community/zpm-registry/

zpm:DEMO>install zpm-registry
[DEMO|zpm-registry] Reload START (/usr/irissys/mgr/.modules/DEMO/zpm-registry/1.1.11/)
[DEMO|zpm-registry] Reload SUCCESS
[zpm-registry]  Module object refreshed.
[DEMO|zpm-registry] Validate START
[DEMO|zpm-registry] Validate SUCCESS
[DEMO|zpm-registry] Compile START
[DEMO|zpm-registry] Compile SUCCESS
[DEMO|zpm-registry] Activate START
[DEMO|zpm-registry] Configure START
[DEMO|zpm-registry] Configure SUCCESS
[DEMO|zpm-registry] Activate SUCCESS
zpm:DEMO>

到github页面, https://github.com/intersystems-community/zpm-registry/, 你可以得到更详细的软件信息。

配置私服连接公服, 需要在私服的IRIS的安装目录添加一个yaml文件, 定义uplink:

uplinks:
  pm:
    url: https://pm.community.intersystems.com/
    allow_packages: dsw,zpm*,?u*

几点说明:

  • uplinks的项目可以有多个,pm是intersystems的默认公共registry

  • allow_packages: - a comma-separated list of allowed packages, you can use the exact package name or mask: * - any sequence of characters, ? - any charac

  • registry 提供的rest 接口描述: https://pm.community.intersystems.com/_spec

设置zpm client连接私服

通过repo命令将您的zpm client切换到刚刚配置的私服。repo -n registry里面的 - user, - pass是你搭建的私服的账号密码。您也可以在私服上修改/registryWeb应用不做用户验证。

zpm:DEMO>repo -list
registry
    Source:         https://pm.community.intersystems.com
    Enabled?        Yes
    Available?      Yes
    Use for Snapshots?  Yes
    Use for Prereleases?    Yes
    Is Read-Only?       No
    Deployment Enabled?     No

zpm:DEMO>repo -n registry -r -url http://localhost:52773/registry/ -user superuser -pass demo

registry
    Source:         http://localhost:52773/registry/
    Enabled?        Yes
    Available?      Yes
    Use for Snapshots?  Yes
    Use for Prereleases?    Yes
    Is Read-Only?       No
    Deployment Enabled?     No
    Username:       superuser
    Password:       <set>
zpm:DEMO>

这时的私服时没有连接公服。

发布软件包到私服

发布一个 GitHub 的包

先把软件存在github, 然后用curl命令把包发布在私服的地址。

$ curl -i -X POST -H "Content-Type:application/json" -u superuser:1104 -d '{"repository":"https://github.com/psteiwer/ObjectScript-Math"}' 'http://localhost:52773/registry/package’

使用zpm 客户端先在本地load,然后使用publish 命令

大概像这个样子:

zpm:USER>help load
...
  ■ Examples
    ∙ load C:\module\root\path\
load C:\module\root\path\module-0.0.1.tgz
      Loads the module described in C:\module\root\path\module.xml
    ∙ load -dev -verbose C:\module\root\path\
load -dev -verbose C:\module\root\path\module-0.0.1.tgz
      Loads the module described in C:\module\root\path\module.xml in developer mode and with verbose output.
    ∙ load https://github.com/user/repository.git
load https://github.com/user/repository.git -b branch-name
      Loads the module described in C:\module\root\path\module.xml in developer mode and with verbose output.
zpm:USER> load https://github.com/user/repository.git
zpm: USER> publish <package name>

其他的Feature

在使用中您还会有各种各样的需求, 但我相信看到现在您应该对怎么寻找答案非常清楚了。这里简单的说两个feautre

1. 发布为Delopyed模式

如果您要隐藏自己的代码,只发布编译后的软件, 可以简单的修改Module.xml, 设置““, zpm会自动完成。

2. 包的依赖

因为有朋友问,所以说一些包依赖的功能。是的, zpm是设计了包依赖的功能的,在module.xml里添加Dependencies节点, 可以定被依赖的包的列表。 具体的写法请参见这个例子:module.xml example

虽然但是,对ObjectScript程序来说,定义包依赖的机会并不多。我能想到的应用场景就是, 当您的软件中想用社区其他包,比如上面的bitmap-adoption的包的话,您可以包"bitmap-adoption"打包到module.xml里面。

我对当前发布的200多软件包随便挑了一些,还没有发现有哪个使用了包依赖, 象这样:

zpm:USER>list-dependents yaml-utils
zpm:USER>list-dependents terminal-multiline-editor
zpm:USER>list-dependents bitmap-adoption
zpm:USER>list-dependents global-dump-sql
...

讨论 (0)1
登录或注册以继续