浏览代码

feat(bazel): add bzlmod integrity gen function (#12797)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Markus Hofbauer 6 天之前
父节点
当前提交
9991822f8c
共有 2 个文件被更改,包括 18 次插入7 次删除
  1. 14 7
      plugins/bazel/README.md
  2. 4 0
      plugins/bazel/bazel.plugin.zsh

+ 14 - 7
plugins/bazel/README.md

@@ -1,6 +1,7 @@
 # Bazel plugin
 
-This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
+This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool
+that scalably supports multi-language and multi-platform projects.
 
 To use it, add `bazel` to the plugins array in your zshrc file:
 
@@ -14,9 +15,15 @@ The plugin has a copy of [the completion script from the git repository][1].
 
 ## Aliases
 
-| Alias   | Command                                | Description                                            |
-| ------- | -------------------------------------- | ------------------------------------------------------ |
-| bzb      | `bazel build`                          | The `bazel build` command                              |
-| bzt      | `bazel test`                           | The `bazel test` command                               |
-| bzr      | `bazel run`                            | The `bazel run` command                                |
-| bzq      | `bazel query`                          | The `bazel query` command                              |
+| Alias | Command       | Description               |
+| ----- | ------------- | ------------------------- |
+| bzb   | `bazel build` | The `bazel build` command |
+| bzt   | `bazel test`  | The `bazel test` command  |
+| bzr   | `bazel run`   | The `bazel run` command   |
+| bzq   | `bazel query` | The `bazel query` command |
+
+## Functions
+
+| Function | Description                      |
+| -------- | -------------------------------- |
+| sri-hash | Generate SRI hash used by bzlmod |

+ 4 - 0
plugins/bazel/bazel.plugin.zsh

@@ -3,3 +3,7 @@ alias bzb='bazel build'
 alias bzt='bazel test'
 alias bzr='bazel run'
 alias bzq='bazel query'
+
+sri-hash() {
+    openssl dgst -sha256 -binary $1 | openssl base64 -A | sed 's/^/sha256-/'
+}