depot/third_party/nixpkgs/pkgs/by-name/re/redocly/package.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

58 lines
1.5 KiB
Nix

{ lib
, buildNpmPackage
, fetchFromGitHub
, makeWrapper
, redocly
, testers
}:
buildNpmPackage rec {
pname = "redocly";
version = "1.15.0";
src = fetchFromGitHub {
owner = "Redocly";
repo = "redocly-cli";
rev = "@redocly/cli@${version}";
hash = "sha256-qGjFueL05f7DgDa0/B+w1Ix2tRx7PicMneub2sWJ7Gw=";
};
npmDepsHash = "sha256-pO1ewVInuPCLDk2V4HRqOCFmT1VTVa/qRkJ5rxREWMU=";
npmBuildScript = "prepare";
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
npm --prefix packages/cli run copy-assets
'';
postInstall = ''
rm $out/lib/node_modules/@redocly/cli/node_modules/@redocly/{cli,openapi-core}
cp -R packages/cli $out/lib/node_modules/@redocly/cli/node_modules/@redocly/cli
cp -R packages/core $out/lib/node_modules/@redocly/cli/node_modules/@redocly/openapi-core
mkdir $out/bin
makeWrapper $out/lib/node_modules/@redocly/cli/node_modules/@redocly/cli/bin/cli.js \
$out/bin/redocly \
--set-default REDOCLY_TELEMETRY off \
--set-default CI true # Silence update messages
# Symlink for backwards compatibility. Remove after 24.05.
ln -s $out/bin/redocly $out/bin/redocly-cli
'';
passthru = {
tests.version = testers.testVersion {
package = redocly;
};
};
meta = {
description = "Makes OpenAPI easy. Lint/validate to any standard, generate beautiful docs, and more";
homepage = "https://github.com/Redocly/redocly-cli";
license = lib.licenses.mit;
mainProgram = "redocly";
maintainers = with lib.maintainers; [ szlend ];
};
}