From da6d13cea0023fc8501859ec38f16b036988f11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Thu, 25 Jan 2024 16:55:40 -0800 Subject: [PATCH] graphite-cli: use buildNpmPackage --- .../by-name/gr/graphite-cli/package-lock.json | 237 ++++++++++++++++++ pkgs/by-name/gr/graphite-cli/package.nix | 44 ++++ pkgs/by-name/gr/graphite-cli/update.sh | 30 +++ pkgs/development/node-packages/aliases.nix | 2 + .../node-packages/main-programs.nix | 1 - .../node-packages/node-packages.json | 1 - .../node-packages/node-packages.nix | 42 ---- pkgs/development/node-packages/overrides.nix | 17 -- pkgs/top-level/all-packages.nix | 2 - 9 files changed, 313 insertions(+), 63 deletions(-) create mode 100644 pkgs/by-name/gr/graphite-cli/package-lock.json create mode 100644 pkgs/by-name/gr/graphite-cli/package.nix create mode 100755 pkgs/by-name/gr/graphite-cli/update.sh diff --git a/pkgs/by-name/gr/graphite-cli/package-lock.json b/pkgs/by-name/gr/graphite-cli/package-lock.json new file mode 100644 index 000000000000..8f6a8fb32c5f --- /dev/null +++ b/pkgs/by-name/gr/graphite-cli/package-lock.json @@ -0,0 +1,237 @@ +{ + "name": "@withgraphite/graphite-cli", + "version": "1.1.2", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@withgraphite/graphite-cli", + "version": "1.1.2", + "license": "None", + "dependencies": { + "chalk": "^4.1.2", + "ws": "^8.6.0", + "yargs": "^17.5.1" + }, + "bin": { + "graphite": "graphite.js", + "gt": "graphite.js" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/ws": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", + "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/pkgs/by-name/gr/graphite-cli/package.nix b/pkgs/by-name/gr/graphite-cli/package.nix new file mode 100644 index 000000000000..473729054881 --- /dev/null +++ b/pkgs/by-name/gr/graphite-cli/package.nix @@ -0,0 +1,44 @@ +{ lib +, buildNpmPackage +, fetchurl +, installShellFiles +}: + +buildNpmPackage rec { + pname = "graphite-cli"; + version = "1.0.14"; + + src = fetchurl { + url = "https://registry.npmjs.org/@withgraphite/graphite-cli/-/graphite-cli-${version}.tgz"; + hash = "sha256-m54jBeUAWYMXYl2KVw0GMpb7Y3dFGEtzKIanN4WyZSk="; + }; + + npmDepsHash = "sha256-Nk0Aoyv4eEXZD4B9B/B6mJd/UDy8Kc/sHtQWXrLukSk="; + + postPatch = '' + ln -s ${./package-lock.json} package-lock.json + ''; + + nativeBuildInputs = [ + installShellFiles + ]; + + dontNpmBuild = true; + + postInstall = '' + installShellCompletion --cmd gt \ + --bash <($out/bin/gt completion) \ + --zsh <(ZSH_NAME=zsh $out/bin/gt completion) + ''; + + passthru.updateScript = ./update.sh; + + meta = { + description = "CLI that makes creating stacked git changes fast & intuitive"; + downloadPage = "https://www.npmjs.com/package/@withgraphite/graphite-cli"; + homepage = "https://graphite.dev/docs/graphite-cli"; + license = lib.licenses.unfree; # no license specified + mainProgram = "gt"; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/by-name/gr/graphite-cli/update.sh b/pkgs/by-name/gr/graphite-cli/update.sh new file mode 100755 index 000000000000..2940714e37bf --- /dev/null +++ b/pkgs/by-name/gr/graphite-cli/update.sh @@ -0,0 +1,30 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p gnused nix nodejs prefetch-npm-deps wget + +set -euo pipefail +pushd "$(dirname "${BASH_SOURCE[0]}")" + +version=$(npm view @withgraphite/graphite-cli version) +tarball="graphite-cli-$version.tgz" +url="https://registry.npmjs.org/@withgraphite/graphite-cli/-/$tarball" + +if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then + echo "Already up to date!" + exit 0 +fi + +sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix + +sha256=$(nix-prefetch-url "$url") +src_hash=$(nix-hash --to-sri --type sha256 "$sha256") +sed -i 's#hash = "[^"]*"#hash = "'"$src_hash"'"#' package.nix + +rm -f package-lock.json package.json *.tgz +wget "$url" +tar xf "$tarball" --strip-components=1 package/package.json +npm i --package-lock-only +npm_hash=$(prefetch-npm-deps package-lock.json) +sed -i 's#npmDepsHash = "[^"]*"#npmDepsHash = "'"$npm_hash"'"#' package.nix +rm -f package.json *.tgz + +popd diff --git a/pkgs/development/node-packages/aliases.nix b/pkgs/development/node-packages/aliases.nix index ffe26a735d97..44af254f4d19 100644 --- a/pkgs/development/node-packages/aliases.nix +++ b/pkgs/development/node-packages/aliases.nix @@ -50,6 +50,7 @@ mapAliases { "@nerdwallet/shepherd" = pkgs.shepherd; # added 2023-09-30 "@nestjs/cli" = pkgs.nest-cli; # Added 2023-05-06 "@tailwindcss/language-server" = pkgs.tailwindcss-language-server; # added 2024-01-22 + "@withgraphite/graphite-cli" = pkgs.graphite-cli; # added 2024-01-25 "@zwave-js/server" = pkgs.zwave-js-server; # Added 2023-09-09 alloy = pkgs.titanium-alloy; # added 2023-08-17 antennas = pkgs.antennas; # added 2023-07-30 @@ -82,6 +83,7 @@ mapAliases { inherit (pkgs) gitmoji-cli; # added 2023-09-23 glob = pkgs.node-glob; # added 2023-08-18 inherit (pkgs) gqlint; # added 2023-08-19 + inherit (pkgs) graphite-cli; # added 2024-01-25 inherit (pkgs) graphqurl; # added 2023-08-19 gtop = pkgs.gtop; # added 2023-07-31 hs-client = pkgs.hsd; # added 2023-08-20 diff --git a/pkgs/development/node-packages/main-programs.nix b/pkgs/development/node-packages/main-programs.nix index 2513bb481e52..5f2c214a4965 100644 --- a/pkgs/development/node-packages/main-programs.nix +++ b/pkgs/development/node-packages/main-programs.nix @@ -5,7 +5,6 @@ "@electron-forge/cli" = "electron-forge"; "@microsoft/rush" = "rush"; "@webassemblyjs/cli-1.11.1" = "wasm2wast"; - "@withgraphite/graphite-cli" = "gt"; # Packages that provide a single executable. "@angular/cli" = "ng"; diff --git a/pkgs/development/node-packages/node-packages.json b/pkgs/development/node-packages/node-packages.json index d4a420320c64..8e9a7a73af5e 100644 --- a/pkgs/development/node-packages/node-packages.json +++ b/pkgs/development/node-packages/node-packages.json @@ -300,7 +300,6 @@ , "webpack-dev-server" , "copy-webpack-plugin" , "webtorrent-cli" -, "@withgraphite/graphite-cli" , "wrangler" , "wring" , "@yaegassy/coc-nginx" diff --git a/pkgs/development/node-packages/node-packages.nix b/pkgs/development/node-packages/node-packages.nix index c03c1506797d..ea26d4c5014e 100644 --- a/pkgs/development/node-packages/node-packages.nix +++ b/pkgs/development/node-packages/node-packages.nix @@ -101730,48 +101730,6 @@ in bypassCache = true; reconstructLock = true; }; - "@withgraphite/graphite-cli" = nodeEnv.buildNodePackage { - name = "_at_withgraphite_slash_graphite-cli"; - packageName = "@withgraphite/graphite-cli"; - version = "1.0.14"; - src = fetchurl { - url = "https://registry.npmjs.org/@withgraphite/graphite-cli/-/graphite-cli-1.0.14.tgz"; - sha512 = "VXgUM5RSYXMVc9i3E1A6j0CYNS5ScQjUXaKO9l3epOws5rxiyDa7QOl7tiSXTQw1eQKtzXxiwve+iWDZsPSDQw=="; - }; - dependencies = [ - sources."ansi-regex-5.0.1" - sources."ansi-styles-4.3.0" - sources."bufferutil-4.0.8" - sources."chalk-4.1.2" - sources."cliui-8.0.1" - sources."color-convert-2.0.1" - sources."color-name-1.1.4" - sources."emoji-regex-8.0.0" - sources."escalade-3.1.1" - sources."get-caller-file-2.0.5" - sources."has-flag-4.0.0" - sources."is-fullwidth-code-point-3.0.0" - sources."node-gyp-build-4.8.0" - sources."require-directory-2.1.1" - sources."string-width-4.2.3" - sources."strip-ansi-6.0.1" - sources."supports-color-7.2.0" - sources."utf-8-validate-6.0.3" - sources."wrap-ansi-7.0.0" - sources."ws-8.16.0" - sources."y18n-5.0.8" - sources."yargs-17.7.2" - sources."yargs-parser-21.1.1" - ]; - buildInputs = globalBuildInputs; - meta = { - homepage = "https://github.com/withgraphite/graphite-cli"; - license = "None"; - }; - production = true; - bypassCache = true; - reconstructLock = true; - }; wrangler = nodeEnv.buildNodePackage { name = "wrangler"; packageName = "wrangler"; diff --git a/pkgs/development/node-packages/overrides.nix b/pkgs/development/node-packages/overrides.nix index 88d9d76e46e3..f49f09126e42 100644 --- a/pkgs/development/node-packages/overrides.nix +++ b/pkgs/development/node-packages/overrides.nix @@ -72,23 +72,6 @@ final: prev: { ''; }; - - graphite-cli = prev."@withgraphite/graphite-cli".override (old: { - name = "graphite-cli"; - nativeBuildInputs = with pkgs; [ installShellFiles pkg-config ]; - buildInputs = with pkgs; [ cairo pango pixman ]; - # 'gt completion' auto-detects zshell from environment variables: - # https://github.com/yargs/yargs/blob/2b6ba3139396b2e623aed404293f467f16590039/lib/completion.ts#L45 - postInstall = '' - installShellCompletion --cmd gt \ - --bash <($out/bin/gt completion) \ - --zsh <(ZSH_NAME=zsh $out/bin/gt completion) - ''; - meta = old.meta // { - license = lib.licenses.unfree; # no license specified - }; - }); - graphql-language-service-cli = prev.graphql-language-service-cli.override { nativeBuildInputs = [ pkgs.buildPackages.makeWrapper ]; postInstall = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8f3a15a5213a..9959bc4c0ed0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3925,8 +3925,6 @@ with pkgs; goperf = callPackage ../development/tools/goperf { }; - graphite-cli = nodePackages.graphite-cli; - gucci = callPackage ../tools/text/gucci { }; guglielmo = libsForQt5.callPackage ../applications/radio/guglielmo { };