halo icon indicating copy to clipboard operation
halo copied to clipboard

feat: support validate requires version for theme

Open guqing opened this issue 3 years ago • 1 comments

What type of PR is this?

/kind feature /milestone 2.2.x /kind api-change

What this PR does / why we need it:

主题支持 requires 版本验证

  • 主题安装和更新时会校验 requires,如果不通过则抛出异常。
  • 主题重载或者 halo 升级后导致主题 requires 不满足条件,则会在 status 中将 phase 标记为 failed

⚠️ 特别说明:

  • 由于之前主题的 require 字段沿用了 1.x 版本,并没有发现与插件的 requires 属性命名不相同,因此添加了一个 requires 属性,并将 require 标记为过时,后续移除它,这个改动不算是破坏性,但如果主题需要版本校验则需要更改 theme.yaml 为 requires
  • 校验后如果有错误则 console 端应该提示插件升级,这样可以避免用户不知情导致很长时间主题端模板都渲染错误问题。可以通过判断 status.phase 是否为 FAILED 来展示 conditions 的第一个 item 的信息。
  • 例如 halo 升级后 requires 不满足条件这种情况,并且这个主题被启用,也不会去取消激活(requires 不满足条件不会导致主题无法激活)。

Console 需要做适配 综上,console 应该需要:

  • 修改 Halo 版本要求 的字段取值,从 require -> requires
  • 提供错误信息展示,让用户知道主题不适配应该升级等错误。

Which issue(s) this PR fixes:

Fixes #3088

Special notes for your reviewer:

how to test it?

  • 测试安装、升级在 requires 满足条件和不满足时的状况是否符合描述中所述情况。
  • 主题重载时加载了一个新的 requires 值触发不满足系统要求条件会在 status 中有错误信息,但不影响主题激活

/cc @halo-dev/sig-halo

Does this PR introduce a user-facing change?

主题支持 requires 版本验证,原 Halo 版本要求属性从 require 更名为 requires

guqing avatar Jan 13 '23 09:01 guqing

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

f2c-ci-robot[bot] avatar Jan 18 '23 07:01 f2c-ci-robot[bot]