From d1949a2e1a9452d93b59c86cabfaaed3535df9b6 Mon Sep 17 00:00:00 2001 From: Erin van der Veen Date: Fri, 17 May 2024 17:33:39 +0200 Subject: [PATCH] use topiary's published crates over git --- Cargo.lock | 20 +++++++----- Cargo.toml | 4 +-- README.md | 6 ---- lsp/nls/README.md | 9 ------ scripts/release.sh | 81 ---------------------------------------------- 5 files changed, 14 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9577c251..a86a5021b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3010,8 +3010,9 @@ dependencies = [ [[package]] name = "topiary-core" -version = "0.3.0" -source = "git+https://github.com/tweag/topiary.git?rev=82a94a9f57104b89d4316afaeeab271cc51f7698#82a94a9f57104b89d4316afaeeab271cc51f7698" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b26541394bdbcd5a039deb917b2096a69c6604f733f0d41f534fc6975987040d" dependencies = [ "futures", "itertools 0.11.0", @@ -3028,13 +3029,15 @@ dependencies = [ [[package]] name = "topiary-queries" -version = "0.3.0" -source = "git+https://github.com/tweag/topiary.git?rev=82a94a9f57104b89d4316afaeeab271cc51f7698#82a94a9f57104b89d4316afaeeab271cc51f7698" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b69a72f4ca5e209f3bfecf544acd96a4351070f48bc41629bbcdc20a50fc880" [[package]] name = "topiary-tree-sitter-facade" -version = "0.3.0" -source = "git+https://github.com/tweag/topiary.git?rev=82a94a9f57104b89d4316afaeeab271cc51f7698#82a94a9f57104b89d4316afaeeab271cc51f7698" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea7c870d9a844bbba0f55be40eaa89624a9f627c155cd22eea70dd808bd71b3d" dependencies = [ "js-sys", "topiary-web-tree-sitter-sys", @@ -3045,8 +3048,9 @@ dependencies = [ [[package]] name = "topiary-web-tree-sitter-sys" -version = "0.3.0" -source = "git+https://github.com/tweag/topiary.git?rev=82a94a9f57104b89d4316afaeeab271cc51f7698#82a94a9f57104b89d4316afaeeab271cc51f7698" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9e35caeeb7f07e97b71ee7ea204c89516e7cc490d1c2ae318eca3ff3c08d46" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 7d92042d7..ef20ac329 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,8 +98,8 @@ void = "1" metrics = "0.21" metrics-util = "0.15" -topiary-core = { git = "https://github.com/tweag/topiary.git", rev = "82a94a9f57104b89d4316afaeeab271cc51f7698", package = "topiary-core" } -topiary-queries = { git = "https://github.com/tweag/topiary.git", rev = "82a94a9f57104b89d4316afaeeab271cc51f7698", package = "topiary-queries", default-features = false, features = ["nickel"] } +topiary-core = "0.4.0" +topiary-queries = { version = "0.4.0", default-features = false, features = ["nickel"] } # This should be kept in sync with the revision in topiary tree-sitter-nickel = { git = "https://github.com/nickel-lang/tree-sitter-nickel", rev = "58baf89db8fdae54a84bcf22c80ff10ee3f929ed" } tempfile = "3.5.0" diff --git a/README.md b/README.md index 8172d7a22..c36ffc72a 100644 --- a/README.md +++ b/README.md @@ -168,12 +168,6 @@ highlighting and NLS. #### Formatting -**Warning**: because the cargo registry (crates.io) requires that all -dependencies of Nickel are published there as well, the `format` feature isn't -enabled when installing nickel with `cargo install` as of Nickel version 1.5.0. -In this case, please use [Topiary](https://github.com/tweag/topiary/) separately -to format Nickel source code. - To format one or several Nickel source files, use `nickel format`: ```console diff --git a/lsp/nls/README.md b/lsp/nls/README.md index f86a6e530..34937176d 100644 --- a/lsp/nls/README.md +++ b/lsp/nls/README.md @@ -12,15 +12,6 @@ it in VSCode, (Neo)Vim and Emacs. ## Formatting Capabilities -**Warning**: because the cargo registry (crates.io) requires that all -dependencies of Nickel are published there as well, the format feature isn't -enabled when installing nls with `cargo install` as of NLS version 1.3.0. In -this case, to enable formatting in NLS, you have to make the `topiary` -executable available in your `PATH`. Please follow [Topiary's setup -instructions](https://github.com/tweag/topiary#installing) and ensure in -particular that the environment variable `TOPIARY_LANGUAGE_DIR` is correctly set -(this is covered in the setup instructions). - Formatting in `nls` is currently based on [Topiary](https://github.com/tweag/topiary), used as a library. No configuration or external dependencies are necessary. diff --git a/scripts/release.sh b/scripts/release.sh index 15b16415d..826c927d1 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -178,74 +178,6 @@ update_dependencies() { done } -# Currently, topiary isn't published on crates.io, so we can't publish crates -# that depend on it. -# -# The version released on the stable branch, the release branch and in the -# GitHub release should support the format feature, but the version published on -# crates.io can't, for the time being. -# -# For cargo to accept to publish our crates, we have to remove the "format" -# feature from the list of features and from the list of default features, as -# well as removing all the dependencies enabled by this feature (even if they -# aren't used anymore, their mere presence in `Cargo.toml` without them being -# available on crates.io is forbidden by cargo). -remove_format_feature() { - local path_cargo_toml - local tmpfile - - path_cargo_toml="$1" - tmpfile="$path_cargo_toml.tmp" - local -a deps_to_remove - - cleanup_actions+=('git restore '"$path_cargo_toml") - - # We first extract the list of dependencies that are required by the format - # feature, because we'll need to remove them all (it'll include topiary, but - # might not be limited to it) - # - # We filter out dependencies (as `format = [..]` can also contain features, - # such as `nickel-lang-core/format`), and then remove the `dep:` prefix. - readarray -t deps_to_remove < <(tomlq -r '(.features.format | .[] | select(startswith("dep:")) | sub("dep:";""))' "$path_cargo_toml") - - # see [^tomlq-sed] - # Removing the format feature is a bit more complicated than handling - # version numbers, because the format feature is a list of strings, so we - # resort to a stronger weapon: awk - # - # The following script looks for the `[features]` section, then for the - # `default` key and remove "format" from the list of default features. It - # also removes the feature format key (and its value) itself from the - # [features] section. - awk -F'[\n= ]+' ' - { - if($0 ~ /^\[features\]$/) { - a=1 - } - else if(a==1 && $1=="format") { - next - } - else if(a==1 && $0 ~ /^default ?= ?\[/) { - gsub(/, *"format"|"format" *,?/,"") - } - else if(a==1 && $0 ~ /^$/) { - a=0 - } - } - 1' "$path_cargo_toml" > "$tmpfile" && mv "$tmpfile" "$path_cargo_toml" - - # We remove all dependencies required by the format feature that we just - # removed - for dep in "${deps_to_remove[@]}"; do - # see [^tomlq-sed] - report_progress "Removing dependency $dep from $path_cargo_toml" - sed -i '/^'"$dep"'\s*=\s*{.*}$/d' "$path_cargo_toml" - done - - git add "$path_cargo_toml" - cleanup_actions+=('git reset -- '"$path_cargo_toml") -} - print_usage_and_exit() { echo "Usage: $0 " >&2 exit 1 @@ -481,19 +413,6 @@ for crate in "${crates_to_publish[@]}"; do cleanup_actions+=('git restore '"$crate/Cargo.toml") done -report_progress "Remove the format feature and topiary dependencies..." - -for crate in "${crates_to_publish[@]}"; do - remove_format_feature "$crate/Cargo.toml" - - git add "$crate/Cargo.toml" - cleanup_actions+=('git reset -- '"$crate/Cargo.toml") -done - -# Cargo requires to commit changes, but we'll reset them later -git commit -m "[release.sh][tmp] remove nickel-lang-utils and topiary from deps" -cleanup_actions+=("git reset --hard HEAD~") - # We have had reproducibility issues before due to the fact that when installing # the version of say `nickel-lang-cli` from crates.io, Cargo doesn't pick the # current workspace file `Cargo.lock`, but regenerates a fresh one. This can