mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
Merge pull request #317403 from kiike/pkgs/basedpyright
basedpyright: 1.12.4 -> 1.12.5
This commit is contained in:
commit
bef4a000c2
@ -1,6 +1,5 @@
|
||||
{
|
||||
lib,
|
||||
nix-update-script,
|
||||
buildNpmPackage,
|
||||
fetchFromGitHub,
|
||||
runCommand,
|
||||
@ -8,13 +7,13 @@
|
||||
}:
|
||||
|
||||
let
|
||||
version = "1.12.4";
|
||||
version = "1.12.5";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "detachhead";
|
||||
repo = "basedpyright";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-ZcFCK6KKX10w5KgsUQIDMMBIzU+8pw0t9/pn1tzCnMg=";
|
||||
hash = "sha256-fiaIkZoW0eOzVLOv9vhEk32kgKorNSG1vtNw0bIOtNU=";
|
||||
};
|
||||
|
||||
patchedPackageJSON = runCommand "package.json" { } ''
|
||||
@ -44,7 +43,7 @@ let
|
||||
pname = "pyright-internal";
|
||||
inherit version src;
|
||||
sourceRoot = "${src.name}/packages/pyright-internal";
|
||||
npmDepsHash = "sha256-90IGWvXvUpvIQdpukm8njwcNj7La6rWwoENh4kiBayI=";
|
||||
npmDepsHash = "sha256-bdlcGrYLnX318+MByYIzjnchl9n4+EcZKCZJgSMKyHo=";
|
||||
dontNpmBuild = true;
|
||||
# FIXME: Remove this flag when TypeScript 5.5 is released
|
||||
npmFlags = [ "--legacy-peer-deps" ];
|
||||
@ -60,7 +59,7 @@ buildNpmPackage rec {
|
||||
inherit version src;
|
||||
|
||||
sourceRoot = "${src.name}/packages/pyright";
|
||||
npmDepsHash = "sha256-HI3ehtJ29kFSv0XyrXcp5JGs9HGYb9ub2oOSQ6uEn8Q=";
|
||||
npmDepsHash = "sha256-JDGNpyOBK3EwbHIHp4Zoo376MqU5u97Zj46vtuWY488=";
|
||||
|
||||
postPatch = ''
|
||||
chmod +w ../../
|
||||
@ -76,7 +75,7 @@ buildNpmPackage rec {
|
||||
|
||||
dontNpmBuild = true;
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/detachhead/basedpyright/releases/tag/${version}";
|
||||
|
44
pkgs/by-name/ba/basedpyright/update.sh
Executable file
44
pkgs/by-name/ba/basedpyright/update.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl gnused common-updater-scripts jq prefetch-npm-deps
|
||||
set -euo pipefail
|
||||
|
||||
version=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} -v -s https://api.github.com/repos/detachhead/basedpyright/releases/latest | jq -r '.tag_name | sub("^v"; "")')
|
||||
|
||||
update-source-version basedpyright "$version"
|
||||
|
||||
root="$(dirname "$(readlink -f "$0")")"
|
||||
FILE_PATH="$root/package.nix"
|
||||
REPO_URL_PREFIX="https://github.com/detachhead/basedpyright/raw"
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
# Function to download `package-lock.json` for a given source path and update hash
|
||||
update_hash() {
|
||||
local source_root_path="$1"
|
||||
local existing_hash="$2"
|
||||
|
||||
# Formulate download URL
|
||||
local download_url="${REPO_URL_PREFIX}/v${version}${source_root_path}/package-lock.json"
|
||||
|
||||
# Download package-lock.json to temporary directory
|
||||
curl -fsSL -v -o "${TEMP_DIR}/package-lock.json" "$download_url"
|
||||
|
||||
# Calculate the new hash
|
||||
local new_hash
|
||||
new_hash=$(prefetch-npm-deps "${TEMP_DIR}/package-lock.json")
|
||||
|
||||
# Update npmDepsHash in the original file
|
||||
sed -i "s|$existing_hash|${new_hash}|" "$FILE_PATH"
|
||||
}
|
||||
|
||||
while IFS= read -r source_root_line; do
|
||||
[[ "$source_root_line" =~ sourceRoot ]] || continue
|
||||
source_root_path=$(echo "$source_root_line" | sed -e 's/^.*"${src.name}\(.*\)";.*$/\1/')
|
||||
|
||||
# Extract the current npmDepsHash for this sourceRoot
|
||||
existing_hash=$(grep -A1 "$source_root_line" "$FILE_PATH" | grep 'npmDepsHash' | sed -e 's/^.*npmDepsHash = "\(.*\)";$/\1/')
|
||||
|
||||
# Call the function to download and update the hash
|
||||
update_hash "$source_root_path" "$existing_hash"
|
||||
done < "$FILE_PATH"
|
Loading…
Reference in New Issue
Block a user