about summary refs log tree commit diff
path: root/pkgs/by-name/vs/vscode-js-debug/package.nix
blob: bde7ae221517743d1f6aa863de18a3b33e062664 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{ lib
, stdenv
, buildNpmPackage
, fetchFromGitHub
, buildPackages
, libsecret
, xcbuild
, Security
, AppKit
, pkg-config
, node-gyp
, runCommand
, vscode-js-debug
, nix-update-script
}:

buildNpmPackage rec {
  pname = "vscode-js-debug";
  version = "1.93.0";

  src = fetchFromGitHub {
    owner = "microsoft";
    repo = "vscode-js-debug";
    rev = "v${version}";
    hash = "sha256-8+ZoTddzgwLwPUduT+G5zVgt/ZxLWKojz1PKvOxLX6o=";
  };

  npmDepsHash = "sha256-4GTZevbQg1LhxVw6WQYGvWHVuaWTwpCf50gMZWAHE7c=";

  nativeBuildInputs = [
    pkg-config
    node-gyp
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];

  buildInputs =
    lib.optionals (!stdenv.hostPlatform.isDarwin) [ libsecret ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      Security
      AppKit
    ];

  postPatch = ''
    ${lib.getExe buildPackages.jq} '
      .scripts.postinstall |= empty |             # tries to install playwright, not necessary for build
      .scripts.build |= "gulp dapDebugServer" |   # there is no build script defined
      .bin |= "./dist/src/dapDebugServer.js"      # there is no bin output defined
    ' ${src}/package.json > package.json
  '';

  makeCacheWritable = true;

  npmInstallFlags = [ "--include=dev" ];

  preBuild = ''
    export PATH="node_modules/.bin:$PATH"
  '';

  passthru.updateScript = nix-update-script {
    extraArgs = [ "--version-regex" "v((?!\d{4}\.\d\.\d{3}).*)" ];
  };

  passthru.tests.test = runCommand "${pname}-test"
    {
      nativeBuildInputs = [ vscode-js-debug ];
      meta.timeout = 60;
    } ''
    output=$(js-debug --help 2>&1)
    if grep -Fw -- "Usage: dapDebugServer.js [port|socket path=8123] [host=localhost]" - <<< "$output"; then
      touch $out
    else
      echo "Expected help output was not found!" >&2
      echo "The output was:" >&2
      echo "$output" >&2
      exit 1
    fi
  '';

  meta = with lib; {
    description = "A DAP-compatible JavaScript debugger";
    longDescription = ''
      This is a [DAP](https://microsoft.github.io/debug-adapter-protocol/)-based
      JavaScript debugger. It debugs Node.js, Chrome, Edge, WebView2, VS Code
      extensions, and more. It has been the default JavaScript debugger in
      Visual Studio Code since 1.46, and is gradually rolling out in Visual
      Studio proper.
    '';
    homepage = "https://github.com/microsoft/vscode-js-debug";
    changelog =
      "https://github.com/microsoft/vscode-js-debug/blob/v${version}/CHANGELOG.md";
    mainProgram = "js-debug";
    license = licenses.mit;
    maintainers = with maintainers; [ zeorin ];
  };
}