|
1 | 1 | # Justfile for building, testing, packaging, and installing the VSCode Justfile LSP provider |
2 | 2 |
|
| 3 | + |
3 | 4 | # 🤓 export display for GUI applications, ALWAYS Use this, it is set correctly on init. |
4 | | -DISPLAY:="localhost:10.0" |
| 5 | +# TODO: only set $DISPLAY if the env $env:DISPALY |
| 6 | +#DISPLAY:="localhost:10.0" |
| 7 | +DISPLAY := env("DISPLAY", "localhost:10.0") |
5 | 8 | VSCODE:="~/.dotfiles/vscode.sh" |
6 | 9 |
|
7 | 10 | EXT_VER := `jq -r .version package.json` |
8 | 11 |
|
| 12 | +bump-patch: |
| 13 | + git add -u . |
| 14 | + git commit -m "Bump patch version v{{EXT_VER}}" |
| 15 | + pnpm version patch |
| 16 | + |
9 | 17 | run-debug-extension: |
10 | 18 | pnpm run compile && DISPLAY={{DISPLAY}} pnpm run test |
11 | 19 |
|
12 | 20 | # Build the VSCode extension |
13 | 21 | build: |
14 | 22 | . $HOME/.nvm/nvm.sh |
15 | | - pnpm install |
16 | 23 | pnpm run compile |
17 | 24 |
|
| 25 | +package-clean: |
| 26 | + rm -rf out && pnpm run compile-tests |
| 27 | + |
18 | 28 | # Test the VSCode extension |
19 | 29 | test: |
20 | | - # this will appear on operators screen (useful for debugging) |
| 30 | + # Upgrade everything to TypeScript and precompile tests |
| 31 | + just build |
| 32 | + NODE_OPTIONS='--import=tsx' pnpm exec mocha ./src/test/language-configuration-accessibility.test.ts |
| 33 | + pnpm run compile-tests || (echo "Precompiled tests failed. Skipping extension host tests." && exit 1) |
| 34 | + # Run extension host tests only if precompiled tests pass |
21 | 35 | just package |
22 | | - just install |
23 | | - export DISPLAY={{DISPLAY}} && pnpm run test |
| 36 | + export DISPLAY={{DISPLAY}} && pnpm exec vscode-test |
| 37 | + |
| 38 | +test-lsp: |
| 39 | + #!/bin/bash |
| 40 | + # MUST BE RUN AS /bin/bash so that {} aren't interpolated by lsp |
| 41 | + # THIS WONT WORK: no content header |
| 42 | + # echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | just-lsp |
| 43 | + rm foo || true |
| 44 | + echo -e 'Content-Length: 76\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | just-lsp --log foo |
| 45 | + cat foo |
24 | 46 |
|
25 | 47 | # Package the VSCode extension into a .vsix file |
26 | 48 | package: |
27 | 49 | . $HOME/.nvm/nvm.sh |
28 | 50 | pnpm run compile |
29 | | - pnpm install -g @vscode/vsce |
30 | | - vsce package |
| 51 | + node scripts/package.js |
| 52 | + @just package-check |
| 53 | + |
| 54 | + |
| 55 | +package-check: |
| 56 | + #!/bin/bash |
| 57 | + # check if the extension file is less than 1 minute old using {{EXT_VER}} |
| 58 | + FILENAME="./justlang-lsp-{{EXT_VER}}.vsix" |
| 59 | + if [ -f "$FILENAME" ] && [ $(($(date +%s) - $(stat -c %Y "$FILENAME"))) -lt 60 ]; then \ |
| 60 | + echo "👍🏻 file $FILENAME" |
| 61 | + else \ |
| 62 | + echo "😭 file $FILENAME missing or too old"; \ |
| 63 | + fi |
| 64 | + |
| 65 | + |
| 66 | +package-inspect: |
| 67 | + unzip justlang-lsp-{{EXT_VER}}.vsix -d vsix-content |
| 68 | + tree vsix-content |
| 69 | + @echo "🤔 remember to cleanup ./vsix-content when finished" |
| 70 | + |
31 | 71 |
|
32 | 72 | # Install the VSCode extension |
33 | 73 | install: |
34 | | - {{VSCODE}} --install-extension ./vscode-just-lsp-*.vsix |
| 74 | + pnpm install |
| 75 | + |
| 76 | +package-install: |
| 77 | + {{VSCODE}} --install-extension ./justlang-lsp-{{EXT_VER}}.vsix |
| 78 | + |
0 commit comments