From c78a8d39e54d4f6e2d50b748a530c3738f541fdc Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Wed, 15 May 2024 22:45:40 +0800 Subject: [PATCH] update `update.nu` --- README.md | 16 +++++++++++++--- update.nu | 9 ++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c4a9db5..73456bc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ -## Usage +## Setup First of all, you need to initialize the repository to equip with githooks helping you manage packages: @@ -22,11 +22,21 @@ First of all, you need to initialize the repository to equip with githooks helpi $ aurpublish setup ``` +Then install nushell plugin [nu_plugin_query](https://crates.io/crates/nu_plugin_query) using nushell: + +```nushell +$ plugin add +``` + + + +## Usage + When you make sure the upstream has upgraded, use `update.nu` to update the specified package: ```bash -# Check(-c) and update -$ ./update.nu -c +# Check and update +$ ./update.nu ``` > You can read the help of `update.nu`: diff --git a/update.nu b/update.nu index 659faba..dd83235 100755 --- a/update.nu +++ b/update.nu @@ -1,5 +1,7 @@ #!/usr/bin/nu +plugin use query + # Check the new version of package and update it. def main [ package: path, # Package going to update @@ -20,14 +22,11 @@ def main [ nvchecker -c nvchecker.toml -l warning --failures -e $project nvcmp -c nvchecker.toml - let old_ver = (open old_ver.json) - let new_ver = (open new_ver.json) + let old_ver = (open -r old_ver.json | query json $"data.($project).version") + let new_ver = (open -r new_ver.json | query json $"data.($project).version") cd $package - let old_ver = ($old_ver | get $project) - let new_ver = ($new_ver | get $project) - if $old_ver != $new_ver { open -r PKGBUILD | str replace -r $"pkgver=($old_ver)" $"pkgver=($new_ver)"