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 43ecfed6d2f58..3effaf34b5c1f 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 3f73129037ebc..f5c9355b5fa06 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-css-languageserver-bin = "css-languageserver"; vscode-html-languageserver-bin = "html-languageserver"; diff --git a/pkgs/development/node-packages/node-packages.json b/pkgs/development/node-packages/node-packages.json index 295fdef57f1cb..e5624e6e967a6 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"