diff options
author | Sandro <sandro.jaeckel@gmail.com> | 2024-07-03 15:49:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-03 15:49:10 +0200 |
commit | 794e497348ea2019c258aeefc2c9526a0873f9be (patch) | |
tree | 9f6f4e8e46368717fd7557313c258083d359dd80 | |
parent | 3893c0652674e99ee9aacd1a746ee561e045c025 (diff) | |
parent | 8659aebbf4f09155bcfaea61356ad7cac1f5a108 (diff) |
Merge pull request #323702 from lelgenio/repackage-uglify-js
-rw-r--r-- | pkgs/by-name/ug/uglify-js/package-lock.json | 44 | ||||
-rw-r--r-- | pkgs/by-name/ug/uglify-js/package.nix | 62 | ||||
-rwxr-xr-x | pkgs/by-name/ug/uglify-js/update.sh | 37 | ||||
-rw-r--r-- | pkgs/development/node-packages/aliases.nix | 1 | ||||
-rw-r--r-- | pkgs/development/node-packages/main-programs.nix | 1 | ||||
-rw-r--r-- | pkgs/development/node-packages/node-packages.json | 1 |
6 files changed, 144 insertions, 2 deletions
diff --git a/pkgs/by-name/ug/uglify-js/package-lock.json b/pkgs/by-name/ug/uglify-js/package-lock.json new file mode 100644 index 0000000000000..961c9ef4314f5 --- /dev/null +++ b/pkgs/by-name/ug/uglify-js/package-lock.json @@ -0,0 +1,44 @@ +{ + "name": "uglify-js", + "version": "3.18.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "uglify-js", + "version": "3.18.0", + "license": "BSD-2-Clause", + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "devDependencies": { + "acorn": "~8.7.1", + "semver": "~6.3.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/acorn": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", + "integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + } + } +} diff --git a/pkgs/by-name/ug/uglify-js/package.nix b/pkgs/by-name/ug/uglify-js/package.nix new file mode 100644 index 0000000000000..4056c78af31f0 --- /dev/null +++ b/pkgs/by-name/ug/uglify-js/package.nix @@ -0,0 +1,62 @@ +{ + lib, + buildNpmPackage, + fetchFromGitHub, + testers, + runCommand, + writeText, + uglify-js, +}: + +buildNpmPackage rec { + pname = "uglify-js"; + version = "3.18.0"; + + src = fetchFromGitHub { + owner = "mishoo"; + repo = "UglifyJS"; + rev = "v${version}"; + hash = "sha256-m+OEcvWEk4RX0C4re9TFZpkcBvSwl7qfIM+56t100ws="; + }; + + npmDepsHash = "sha256-iLWmNifHpVvFSFXkfItVpGlh6za9T9wSr1Af4CQQSGM="; + + postPatch = '' + cp ${./package-lock.json} package-lock.json + ''; + + dontNpmBuild = true; + + passthru = { + updateScript = ./update.sh; + tests = { + version = testers.testVersion { package = uglify-js; }; + + simple = testers.testEqualContents { + assertion = "uglify-js minifies a basic js file"; + expected = writeText "expected" '' + console.log(1); + ''; + actual = + runCommand "actual" + { + nativeBuildInputs = [ uglify-js ]; + base = writeText "base" '' + console . log ( ( 1 ) ) ; + ''; + } + '' + uglifyjs $base > $out + ''; + }; + }; + }; + + meta = { + homepage = "https://github.com/mishoo/UglifyJS"; + description = "JavaScript parser / mangler / compressor / beautifier toolkit"; + mainProgram = "uglifyjs"; + license = lib.licenses.bsd2; + maintainers = with lib.maintainers; [ lelgenio ]; + }; +} diff --git a/pkgs/by-name/ug/uglify-js/update.sh b/pkgs/by-name/ug/uglify-js/update.sh new file mode 100755 index 0000000000000..a9ebcf39e93b6 --- /dev/null +++ b/pkgs/by-name/ug/uglify-js/update.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p ripgrep common-updater-scripts nodejs prefetch-npm-deps jq + +set -xeu -o pipefail + +PACKAGE_DIR="$(realpath "$(dirname "$0")")" +cd "$PACKAGE_DIR/.." +while ! test -f flake.nix; do cd .. ; done +NIXPKGS_DIR="$PWD" + +version="$( + list-git-tags --url=https://github.com/mishoo/UglifyJS \ + | rg '^v([\d.]+)$' -r '$1' \ + | sort --version-sort \ + | tail -n1 +)" +update-source-version uglify-js "$version" + +TMPDIR="$(mktemp -d)" +trap "rm -rf '$TMPDIR'" EXIT +cd "$TMPDIR" + +src="$(nix-build --no-link "$NIXPKGS_DIR" -A uglify-js.src)" +cp $src/package*.json . + +# Maybe one day upstream may ship a package-lock.json, +# until then we must generate a fresh one +test -f package-lock.json || npm install --package-lock-only +cp -v package-lock.json "$PACKAGE_DIR/package-lock.json" + +prev_npm_hash=$( + nix-instantiate "$NIXPKGS_DIR" \ + --eval --json -A uglify-js.npmDepsHash \ + | jq -r . +) +new_npm_hash=$(prefetch-npm-deps ./package-lock.json) +sd --fixed-strings "$prev_npm_hash" "$new_npm_hash" "$PACKAGE_DIR/package.nix" diff --git a/pkgs/development/node-packages/aliases.nix b/pkgs/development/node-packages/aliases.nix index 1a31059d43c0a..e037716b3d67a 100644 --- a/pkgs/development/node-packages/aliases.nix +++ b/pkgs/development/node-packages/aliases.nix @@ -170,6 +170,7 @@ mapAliases { inherit (pkgs) titanium; # added 2023-08-17 triton = pkgs.triton; # Added 2023-05-06 typescript = pkgs.typescript; # Added 2023-06-21 + inherit (pkgs) uglify-js; # added 2024-06-15 inherit (pkgs) ungit; # added 2023-08-20 inherit (pkgs) vim-language-server; # added 2024-06-25 inherit (pkgs) vsc-leetcode-cli; # Added 2023-08-30 diff --git a/pkgs/development/node-packages/main-programs.nix b/pkgs/development/node-packages/main-programs.nix index 871f615605642..aa638a37d3984 100644 --- a/pkgs/development/node-packages/main-programs.nix +++ b/pkgs/development/node-packages/main-programs.nix @@ -52,7 +52,6 @@ remod-cli = "remod"; teck-programmer = "teck-firmware-upgrade"; typescript-language-server = "typescript-language-server"; - uglify-js = "uglifyjs"; undollar = "$"; vscode-json-languageserver = "vscode-json-languageserver"; webtorrent-cli = "webtorrent"; diff --git a/pkgs/development/node-packages/node-packages.json b/pkgs/development/node-packages/node-packages.json index 9e004b5f8144d..d03ecc442155f 100644 --- a/pkgs/development/node-packages/node-packages.json +++ b/pkgs/development/node-packages/node-packages.json @@ -250,7 +250,6 @@ , "ts-node" , "ttf2eot" , "typescript-language-server" -, "uglify-js" , "undollar" , "unified-language-server" , "vega-cli" |