Unverified Commit 7f805255 authored by Anthony's avatar Anthony Committed by GitHub
Browse files

markdownlint-cli2: 0.18.0 -> 0.20.0 (#480446)

parents 4f25d5d4 51dbb7b7
Loading
Loading
Loading
Loading
+7704 −0

File added.

Preview size limit exceeded, changes collapsed.

+31 −36
Original line number Diff line number Diff line
{
  lib,
  stdenvNoCC,
  fetchurl,
  makeWrapper,
  buildNpmPackage,
  fetchFromGitHub,
  markdownlint-cli2,
  nodejs,
  nix-update-script,
  runCommand,
  zstd,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
buildNpmPackage rec {
  pname = "markdownlint-cli2";
  version = "0.18.1";
  version = "0.20.0";

  # upstream is not interested in including package-lock.json in the source
  # https://github.com/DavidAnson/markdownlint-cli2/issues/198#issuecomment-1690529976
  # see also https://github.com/DavidAnson/markdownlint-cli2/issues/186
  # so use the tarball from the archlinux mirror
  src = fetchurl {
    url = "https://us.mirrors.cicku.me/archlinux/extra/os/x86_64/markdownlint-cli2-${finalAttrs.version}-1-any.pkg.tar.zst";
    hash = "sha256-M7qmhRDJGm2MhgS2oMfRrkLAst1Ye/rPCwP78UBbyyY=";
  src = fetchFromGitHub {
    owner = "DavidAnson";
    repo = "markdownlint-cli2";
    tag = "v${version}";
    hash = "sha256-wZfLTk7F9HZaRFvYEo5rT+k/ivNk0fU+p844LMO06ek=";
  };

  nativeBuildInputs = [
    makeWrapper
    zstd
  ];

  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp -r lib share $out
    makeWrapper "${lib.getExe nodejs}" "$out/bin/markdownlint-cli2" \
      --add-flags "$out/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs"
  npmDepsHash = "sha256-tWvweCpzopItgfhpiBHUcpBvrJYCiq588WXzF9hvFfs=";

    runHook postInstall
  postPatch = ''
    rm -f .npmrc
    ln -s ${./package-lock.json} package-lock.json
  '';

  passthru.tests = {
    smoke = runCommand "${finalAttrs.pname}-test" { nativeBuildInputs = [ markdownlint-cli2 ]; } ''
      markdownlint-cli2 ${markdownlint-cli2}/share/doc/markdownlint-cli2/README.md > $out
  dontNpmBuild = true;

  passthru = {
    tests = {
      smoke = runCommand "${pname}-test" { nativeBuildInputs = [ markdownlint-cli2 ]; } ''
        markdownlint-cli2 ${markdownlint-cli2}/lib/node_modules/markdownlint-cli2/CHANGELOG.md > $out
      '';
    };
    updateScript = nix-update-script {
      extraArgs = [ "--generate-lockfile" ];
    };
  };

  meta = {
    changelog = "https://github.com/DavidAnson/markdownlint-cli2/blob/v${finalAttrs.version}/CHANGELOG.md";
    changelog = "https://github.com/DavidAnson/markdownlint-cli2/blob/v${version}/CHANGELOG.md";
    description = "Fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library";
    homepage = "https://github.com/DavidAnson/markdownlint-cli2";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ natsukium ];
    maintainers = with lib.maintainers; [
      anthonyroussel
      natsukium
    ];
    mainProgram = "markdownlint-cli2";
  };
})
}