commitlint: fix executable, add version check (#462603)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
fetchYarnDeps,
|
||||
yarnConfigHook,
|
||||
nodejs,
|
||||
makeBinaryWrapper,
|
||||
versionCheckHook,
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
@@ -15,7 +17,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "conventional-changelog";
|
||||
repo = "commitlint";
|
||||
rev = "v${finalAttrs.version}";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-o8AnIewSmg8vRjs8LU6QwRyl2hMQ2iK5W7WL137treU=";
|
||||
};
|
||||
|
||||
@@ -27,16 +29,41 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
nativeBuildInputs = [
|
||||
yarnConfigHook
|
||||
nodejs
|
||||
makeBinaryWrapper
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
pkgs=("config-validator" "rules" "parse" "is-ignored" "lint"
|
||||
"resolve-extends" "execute-rule" "load" "read" "types" "cli")
|
||||
# Remove test files to avoid dependency on commitlint test packages
|
||||
rm -rf @commitlint/**/*.test.{js,ts}
|
||||
|
||||
# See https://github.com/conventional-changelog/commitlint/blob/20.1.0/Dockerfile.ci
|
||||
# Excludes `config-nx-scopes` which is a plain JavaScript package
|
||||
pkgs=(
|
||||
"config-validator"
|
||||
"rules"
|
||||
"parse"
|
||||
"is-ignored"
|
||||
"lint"
|
||||
"resolve-extends"
|
||||
"execute-rule"
|
||||
"load"
|
||||
"read"
|
||||
"types"
|
||||
"cli"
|
||||
"config-conventional"
|
||||
"config-pnpm-scopes"
|
||||
"ensure"
|
||||
"format"
|
||||
"message"
|
||||
"to-lines"
|
||||
"top-level"
|
||||
)
|
||||
for p in "''${pkgs[@]}" ; do
|
||||
echo "Building package: @commitlint/$p"
|
||||
cd @commitlint/$p/
|
||||
yarn run tsc --build --force
|
||||
yarn run --offline tsc --build --force
|
||||
cd ../..
|
||||
done
|
||||
|
||||
@@ -50,15 +77,23 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/lib/node_modules/@commitlint/root
|
||||
mv * $out/lib/node_modules/@commitlint/root/
|
||||
ln -s $out/lib/node_modules/@commitlint/root/@commitlint/cli/cli.js $out/bin/commitlint
|
||||
|
||||
makeBinaryWrapper ${lib.getExe nodejs} $out/bin/commitlint \
|
||||
--add-flags "$out/lib/node_modules/@commitlint/root/@commitlint/cli/cli.js" \
|
||||
--set NODE_PATH "$out/lib/node_modules/@commitlint/root/node_modules"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
versionCheckHook
|
||||
];
|
||||
doInstallCheck = true;
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/conventional-changelog/commitlint/releases/tag/v${finalAttrs.version}";
|
||||
changelog = "https://github.com/conventional-changelog/commitlint/releases/tag/${finalAttrs.src.tag}";
|
||||
description = "Lint your commit messages";
|
||||
homepage = "https://commitlint.js.org/";
|
||||
license = lib.licenses.mit;
|
||||
|
||||
Reference in New Issue
Block a user