commitlint: fix executable, add version check (#462603)
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
fetchYarnDeps,
|
fetchYarnDeps,
|
||||||
yarnConfigHook,
|
yarnConfigHook,
|
||||||
nodejs,
|
nodejs,
|
||||||
|
makeBinaryWrapper,
|
||||||
|
versionCheckHook,
|
||||||
nix-update-script,
|
nix-update-script,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "conventional-changelog";
|
owner = "conventional-changelog";
|
||||||
repo = "commitlint";
|
repo = "commitlint";
|
||||||
rev = "v${finalAttrs.version}";
|
tag = "v${finalAttrs.version}";
|
||||||
hash = "sha256-o8AnIewSmg8vRjs8LU6QwRyl2hMQ2iK5W7WL137treU=";
|
hash = "sha256-o8AnIewSmg8vRjs8LU6QwRyl2hMQ2iK5W7WL137treU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,16 +29,41 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
yarnConfigHook
|
yarnConfigHook
|
||||||
nodejs
|
nodejs
|
||||||
|
makeBinaryWrapper
|
||||||
];
|
];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
pkgs=("config-validator" "rules" "parse" "is-ignored" "lint"
|
# Remove test files to avoid dependency on commitlint test packages
|
||||||
"resolve-extends" "execute-rule" "load" "read" "types" "cli")
|
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
|
for p in "''${pkgs[@]}" ; do
|
||||||
|
echo "Building package: @commitlint/$p"
|
||||||
cd @commitlint/$p/
|
cd @commitlint/$p/
|
||||||
yarn run tsc --build --force
|
yarn run --offline tsc --build --force
|
||||||
cd ../..
|
cd ../..
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -50,15 +77,23 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
mkdir -p $out/lib/node_modules/@commitlint/root
|
mkdir -p $out/lib/node_modules/@commitlint/root
|
||||||
mv * $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
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
nativeInstallCheckInputs = [
|
||||||
|
versionCheckHook
|
||||||
|
];
|
||||||
|
doInstallCheck = true;
|
||||||
|
|
||||||
passthru.updateScript = nix-update-script { };
|
passthru.updateScript = nix-update-script { };
|
||||||
|
|
||||||
meta = {
|
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";
|
description = "Lint your commit messages";
|
||||||
homepage = "https://commitlint.js.org/";
|
homepage = "https://commitlint.js.org/";
|
||||||
license = lib.licenses.mit;
|
license = lib.licenses.mit;
|
||||||
|
|||||||
Reference in New Issue
Block a user