Skip to content

Commit 6746820

Browse files
committed
graphql-language-service-cli: init at 3.5.0
Previously packaged by `node2nix`, removed in 776868c
1 parent 0e65727 commit 6746820

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// derived from graphql-vscode/esbuild.js
2+
const { build } = require('esbuild');
3+
4+
build({
5+
entryPoints: ['bin/graphql.js'],
6+
bundle: true,
7+
minify: true,
8+
sourcemap: false,
9+
platform: 'node',
10+
outdir: 'out/',
11+
external: [
12+
'pnpapi',
13+
// Avoid bundling @vue/compiler-sfc's dynamic dependencies
14+
'squirrelly',
15+
'teacup',
16+
'coffee-script',
17+
'marko',
18+
'slm',
19+
'vash',
20+
'plates',
21+
'babel-core',
22+
'htmling',
23+
'ractive',
24+
'mote',
25+
'eco',
26+
'jqtpl',
27+
'hamljs',
28+
'jazz',
29+
'hamlet',
30+
'whiskers',
31+
'haml-coffee',
32+
'hogan.js',
33+
'templayed',
34+
'walrus',
35+
'mustache',
36+
'just',
37+
'ect',
38+
'toffee',
39+
'twing',
40+
'dot',
41+
'bracket-template',
42+
'vscode',
43+
'velocityjs',
44+
'dustjs-linkedin',
45+
'atpl',
46+
'liquor',
47+
'twig',
48+
],
49+
});
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
lib,
3+
fetchFromGitHub,
4+
fetchYarnDeps,
5+
makeWrapper,
6+
nodejs,
7+
stdenv,
8+
yarnBuildHook,
9+
yarnConfigHook,
10+
versionCheckHook,
11+
}:
12+
13+
stdenv.mkDerivation (finalAttrs: {
14+
pname = "graphql-language-service-cli";
15+
version = "3.5.0";
16+
17+
src = fetchFromGitHub {
18+
owner = "graphql";
19+
repo = "graphiql";
20+
tag = "graphql-language-service-cli@${finalAttrs.version}";
21+
hash = "sha256-NJTggaMNMjOP5oN+gHxFTwEdNipPNzTFfA6f975HDgM=";
22+
};
23+
24+
yarnOfflineCache = fetchYarnDeps {
25+
yarnLock = "${finalAttrs.src}/yarn.lock";
26+
hash = "sha256-ae6KP2sFgw8/8YaTJSPscBlVQ5/bzbvHRZygcMgFAlU=";
27+
};
28+
29+
nativeBuildInputs = [
30+
yarnConfigHook
31+
yarnBuildHook
32+
nodejs
33+
makeWrapper
34+
];
35+
36+
installPhase = ''
37+
runHook preInstall
38+
39+
mkdir -p $out/{bin,lib}
40+
41+
pushd packages/graphql-language-service-cli
42+
43+
# even with dev dependencies stripped, node_modules is over 1GB
44+
# just bundle what we need
45+
cp ${./esbuild.js} esbuild.js
46+
node esbuild.js
47+
48+
# copy package.json for --version command
49+
mv {out/graphql.js,package.json} $out/lib
50+
51+
makeWrapper ${nodejs}/bin/node $out/bin/graphql-lsp \
52+
--add-flags $out/lib/graphql.js \
53+
54+
popd
55+
56+
runHook postInstall
57+
'';
58+
59+
nativeInstallCheckInputs = [ versionCheckHook ];
60+
doInstallCheck = true;
61+
versionCheckProgram = "${placeholder "out"}/bin/${finalAttrs.meta.mainProgram}";
62+
63+
passthru = {
64+
updateScript = ./updater.sh;
65+
};
66+
67+
meta = {
68+
description = "Official, runtime independent Language Service for GraphQL";
69+
homepage = "https://github.com/graphql/graphiql";
70+
changelog = "https://github.com/graphql/graphiql/blob/${finalAttrs.src.tag}/packages/graphql-language-service-cli/CHANGELOG.md";
71+
license = lib.licenses.mit;
72+
maintainers = with lib.maintainers; [ nathanregner ];
73+
mainProgram = "graphql-lsp";
74+
};
75+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p coreutils curl jq nix-update
3+
4+
set -euo pipefail
5+
6+
# this package is part of a monorepo with many tags; nix-update only seems to
7+
# fetch the 10 most recent
8+
# https://github.com/Mic92/nix-update/issues/231
9+
owner="graphql"
10+
repo="graphiql"
11+
version=$(
12+
curl -s "https://api.github.com/repos/graphql/graphiql/git/refs/tags/graphql-language-service-cli" |
13+
jq 'map(.ref | capture("refs/tags/graphql-language-service-cli@(?<version>[0-9.]+)").version) | .[]' -r |
14+
sort --reverse --version-sort | head -n1
15+
)
16+
17+
if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
18+
echo "Already up to date!"
19+
exit 0
20+
fi
21+
22+
nix-update graphql-language-service-cli --version $version

0 commit comments

Comments
 (0)