Merge pull request #260000 from lelgenio/init-blade-formatter
blade-formatter: init at 1.41.1
This commit is contained in:
commit
0f817f8862
13221
pkgs/by-name/bl/blade-formatter/package-lock.json
generated
Normal file
13221
pkgs/by-name/bl/blade-formatter/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
67
pkgs/by-name/bl/blade-formatter/package.nix
Normal file
67
pkgs/by-name/bl/blade-formatter/package.nix
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
lib,
|
||||
buildNpmPackage,
|
||||
fetchFromGitHub,
|
||||
testers,
|
||||
writeText,
|
||||
runCommand,
|
||||
blade-formatter,
|
||||
nodejs,
|
||||
}:
|
||||
|
||||
buildNpmPackage rec {
|
||||
pname = "blade-formatter";
|
||||
version = "1.41.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "shufo";
|
||||
repo = "blade-formatter";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-iaWpIa+H+ocAXGc042PfmCu9UcJZeso9ripWB2/1oTs=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
cp ${./package-lock.json} ./package-lock.json
|
||||
'';
|
||||
|
||||
npmDepsHash = "sha256-wEz0DTbg+Fdmsf0Qyeu9QS+I8gkPJeaJC/3HuP913og=";
|
||||
|
||||
passthru = {
|
||||
updateScript = ./update.sh;
|
||||
tests = {
|
||||
version = testers.testVersion {
|
||||
package = blade-formatter;
|
||||
command = "blade-formatter --version";
|
||||
};
|
||||
|
||||
simple = testers.testEqualContents {
|
||||
assertion = "blade-formatter formats a basic blade file";
|
||||
expected = writeText "expected" ''
|
||||
@if (true)
|
||||
Hello world!
|
||||
@endif
|
||||
'';
|
||||
actual =
|
||||
runCommand "actual"
|
||||
{
|
||||
nativeBuildInputs = [ blade-formatter ];
|
||||
base = writeText "base" ''
|
||||
@if( true ) Hello world! @endif
|
||||
'';
|
||||
}
|
||||
''
|
||||
blade-formatter $base > $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Laravel Blade template formatter";
|
||||
homepage = "https://github.com/shufo/blade-formatter";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ lelgenio ];
|
||||
mainProgram = "blade-formatter";
|
||||
inherit (nodejs.meta) platforms;
|
||||
};
|
||||
}
|
38
pkgs/by-name/bl/blade-formatter/update.sh
Executable file
38
pkgs/by-name/bl/blade-formatter/update.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p ripgrep common-updater-scripts prefetch-npm-deps jq sd
|
||||
|
||||
set -xeu -o pipefail
|
||||
|
||||
PACKAGE_DIR="$(realpath "$(dirname "$0")")"
|
||||
cd "$PACKAGE_DIR/.."
|
||||
while ! test -f default.nix; do cd .. ; done
|
||||
NIXPKGS_DIR="$PWD"
|
||||
|
||||
new_version="$(
|
||||
list-git-tags --url=https://github.com/shufo/blade-formatter \
|
||||
| rg '^v([\d.]*)' -r '$1' \
|
||||
| sort --version-sort \
|
||||
| tail -n1
|
||||
)"
|
||||
|
||||
cd "$NIXPKGS_DIR"
|
||||
update-source-version blade-formatter "$new_version"
|
||||
|
||||
TMPDIR="$(mktemp -d)"
|
||||
cd "$TMPDIR"
|
||||
|
||||
src="$(nix-build --no-link "$NIXPKGS_DIR" -A blade-formatter.src)"
|
||||
cp $src/package.json .
|
||||
npm update
|
||||
cp ./package-lock.json "$PACKAGE_DIR"
|
||||
|
||||
prev_npm_hash="$(nix-instantiate "$NIXPKGS_DIR" \
|
||||
--eval --json \
|
||||
-A blade-formatter.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"
|
||||
|
||||
rm -rf "$TMPDIR"
|
Loading…
Reference in New Issue
Block a user