Skip to content

Commit bb0ef18

Browse files
committed
move installer scripts from vscode extension repo
deprecate ez archive release task
1 parent 7e11523 commit bb0ef18

15 files changed

+364
-66
lines changed

.formatter.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
subdirectories: [
77
"apps/elixir_ls_utils",
88
"apps/elixir_ls_debugger",
9-
"apps/language_server"
9+
"apps/language_server",
10+
"scripts"
1011
]
1112
]

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
While you can develop ElixirLS on its own, it's easiest to test out changes if you clone the [vscode-elixir-ls](https://github.com/elixir-lsp/vscode-elixir-ls) repository instead. It includes ElixirLS as a Git submodule, so you can make your changes in the submodule directory and launch the extension from the parent directory via the included "Launch Extension" configuration in `launch.json`. See the README on that repo for more details.
1+
While you can develop ElixirLS on its own, it's easiest to test out changes if you clone the [vscode-elixir-ls](https://github.com/elixir-lsp/vscode-elixir-ls) repository instead. It includes ElixirLS as a Git submodule, so you can make your changes in the submodule directory and launch the extension from the parent directory via the included "Launch Extension local" configuration in `launch.json`. See the README.md on that repo for more details.

.github/SUPPORT.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Thank you for using ElixirLS! :tada:
55
This document offers some guidelines when asking for support related to an
66
issues that you might encounter when using ElixirLS.
77

8-
# Guidelines
8+
## Guidelines
99

1010
These are some general guidelines to follow when reaching out through any of the
1111
available support channels.
@@ -15,6 +15,7 @@ available support channels.
1515
one**
1616

1717
Also check [elixir\_sense issues](https://github.com/elixir-lsp/elixir_sense/issues)
18+
and [vscode-elixir-ls issues](https://github.com/elixir-lsp/vscode-elixir-ls/issues)
1819

1920
Check if one already exists related to the issue you are having. Remember
2021
to include `closed` issues as well.
@@ -29,8 +30,8 @@ available support channels.
2930
This can be applied to life in general, but it's especially important when
3031
communicating only through written text.
3132

32-
# Support Channels
33+
## Support Channels
3334

3435
- Github [Issues](https://github.com/elixir-lsp/elixir-ls/issues/).
3536
- #elixir-ls tag on the [elixir forum](https://elixirforum.com/).
36-
37+
- Slack [#language-server](https://elixir-lang.slack.com/archives/C7D272G6N)

.github/workflows/release-asset.yml

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Elixir CI
1+
name: Release
22

33
on:
44
push:
@@ -28,49 +28,31 @@ jobs:
2828
name: Build and publish release asset
2929
runs-on: ubuntu-20.04
3030
needs: release
31-
32-
strategy:
33-
matrix:
34-
include:
35-
- elixir-version: '1.14'
36-
otp-version: '25.1'
37-
- elixir-version: '1.14'
38-
otp-version: '24.3'
39-
- elixir-version: '1.14'
40-
otp-version: '23.3'
41-
- elixir-version: '1.13'
42-
otp-version: '25.1'
43-
- elixir-version: '1.13'
44-
otp-version: '24.3'
45-
- elixir-version: '1.13'
46-
otp-version: '23.3'
47-
- elixir-version: '1.13'
48-
otp-version: '22.3'
49-
default: true
50-
5131
steps:
5232
- uses: actions/checkout@v3
33+
34+
- name: Validate version
35+
run: |
36+
VERSION="v$(cat VERSION)"
37+
if [[ "$TAG" != "$VERSION" ]]; then
38+
echo "VERSION does not match commit tag"
39+
exit 1
40+
fi
41+
env:
42+
TAG: ${{ github.ref }}
43+
5344
- name: Set up BEAM
5445
uses: erlef/setup-beam@v1
5546
with:
56-
elixir-version: ${{ matrix.elixir-version }}
57-
otp-version: ${{ matrix.otp-version }}
58-
59-
- name: Restore dependencies cache
60-
uses: actions/cache@v3
61-
with:
62-
path: deps
63-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
64-
restore-keys: ${{ runner.os }}-mix-
47+
elixir-version: 1.14.x
48+
otp-version: 25.x
6549

6650
- name: Install dependencies
6751
run: mix deps.get
6852

6953
- name: Build release
7054
run: |
71-
mkdir ./release
72-
mix compile
73-
MIX_ENV=prod mix elixir_ls.release -o ./release
55+
mix elixir_ls.release2 -o ./release
7456
zip -jr elixir-ls.zip ./release
7557
7658
- name: Upload Release Asset
@@ -80,17 +62,5 @@ jobs:
8062
with:
8163
upload_url: ${{ needs.release.outputs.upload_url }}
8264
asset_path: ./elixir-ls.zip
83-
asset_name: elixir-ls-${{ matrix.elixir-version }}-${{ matrix.otp-version }}.zip
65+
asset_name: elixir-ls-${{ github.ref }}.zip
8466
asset_content_type: application/zip
85-
86-
- name: Upload Default Release Asset
87-
if: ${{ matrix.default == true }}
88-
uses: actions/upload-release-asset@v1
89-
env:
90-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
with:
92-
upload_url: ${{ needs.release.outputs.upload_url }}
93-
asset_path: ./elixir-ls.zip
94-
asset_name: elixir-ls.zip
95-
asset_content_type: application/zip
96-

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.15.0
1+
0.15.0-rc.0

apps/elixir_ls_utils/lib/mix.tasks.elixir_ls.release.ex

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Mix.Tasks.ElixirLs.Release do
66

77
@impl Mix.Task
88
def run(args) do
9-
version_warning()
9+
IO.warn("This task is deprecated. Consider switching to release2")
1010
{opts, _} = OptionParser.parse!(args, aliases: @aliases, switches: @switches)
1111
destination = Path.expand(opts[:destination] || "release")
1212

@@ -38,17 +38,4 @@ defmodule Mix.Tasks.ElixirLs.Release do
3838

3939
:ok
4040
end
41-
42-
defp version_warning do
43-
{otp_version, _} = Integer.parse(to_string(:erlang.system_info(:otp_release)))
44-
45-
if otp_version > 22 do
46-
IO.warn(
47-
"Building with Erlang/OTP #{otp_version}. Make sure to build with OTP 22 if " <>
48-
"publishing the compiled packages because modules built with higher versions are not " <>
49-
"backwards-compatible.",
50-
[]
51-
)
52-
end
53-
end
5441
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
defmodule Mix.Tasks.ElixirLs.Release2 do
2+
use Mix.Task
3+
4+
@switches [destination: :string, local: :boolean]
5+
@aliases [o: :destination, l: :local]
6+
7+
@impl Mix.Task
8+
def run(args) do
9+
{opts, _} = OptionParser.parse!(args, aliases: @aliases, switches: @switches)
10+
destination = Path.expand(opts[:destination] || "release")
11+
12+
File.rm_rf!(destination)
13+
14+
File.cp_r!("./scripts", destination)
15+
16+
IO.inspect(opts)
17+
18+
unless opts[:local] do
19+
File.cp!("./VERSION", Path.join(destination, "VERSION"))
20+
end
21+
22+
:ok
23+
end
24+
end

scripts/debugger.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off & setlocal enabledelayedexpansion
2+
3+
SET ELS_MODE=debugger
4+
5+
IF EXIST "%APPDATA%\elixir_ls\setup.bat" (
6+
ECHO "" | CALL "%APPDATA%\elixir_ls\setup.bat" > nul
7+
IF %ERRORLEVEL% NEQ 0 EXIT 1
8+
)
9+
10+
SET MIX_ENV=prod
11+
@REM pipe echo to avoid passing protocol messages to quiet install command
12+
@REM intercept stdout
13+
@REM elixir is a batch script and needs to be called
14+
ECHO "" | CALL elixir "%~dp0quiet_install.exs" > nul
15+
IF %ERRORLEVEL% NEQ 0 EXIT 1
16+
elixir --erl "+sbwt none +sbwtdcpu none +sbwtdio none" "%~dp0launch.exs"

scripts/debugger.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# Launches the debugger. This script must be in the same directory as mix install launch script.
3+
4+
readlink_f () {
5+
cd "$(dirname "$1")" > /dev/null || exit 1
6+
filename="$(basename "$1")"
7+
if [ -h "$filename" ]; then
8+
readlink_f "$(readlink "$filename")"
9+
else
10+
echo "$(pwd -P)/$filename"
11+
fi
12+
}
13+
14+
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
15+
dir="$(dirname "$(readlink_f "$0")")"
16+
else
17+
dir=${ELS_INSTALL_PREFIX}
18+
fi
19+
20+
export ELS_MODE=debugger
21+
exec "${dir}/launch.sh"

scripts/installer.exs

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
defmodule ElixirLS.Shell.Quiet do
2+
@moduledoc false
3+
4+
@behaviour Mix.Shell
5+
6+
@impl true
7+
def print_app() do
8+
if name = Mix.Shell.printable_app_name() do
9+
IO.puts(:stderr, "==> #{name}")
10+
end
11+
12+
:ok
13+
end
14+
15+
@impl true
16+
def info(message) do
17+
print_app()
18+
IO.puts(:stderr, IO.ANSI.format(message))
19+
end
20+
21+
@impl true
22+
def error(message) do
23+
print_app()
24+
IO.puts(:stderr, IO.ANSI.format(message))
25+
end
26+
27+
@impl true
28+
def prompt(message) do
29+
print_app()
30+
IO.puts(:stderr, IO.ANSI.format(message))
31+
raise "Mix.Shell.prompt is not supported at this time"
32+
end
33+
34+
@impl true
35+
def yes?(message, options \\ []) do
36+
default = Keyword.get(options, :default, :yes)
37+
38+
unless default in [:yes, :no] do
39+
raise ArgumentError,
40+
"expected :default to be either :yes or :no, got: #{inspect(default)}"
41+
end
42+
43+
IO.puts(:stderr, IO.ANSI.format(message))
44+
45+
default == :yes
46+
end
47+
48+
@impl true
49+
def cmd(command, opts \\ []) do
50+
print_app? = Keyword.get(opts, :print_app, true)
51+
52+
Mix.Shell.cmd(command, opts, fn data ->
53+
if print_app?, do: print_app()
54+
IO.write(:stderr, data)
55+
end)
56+
end
57+
end
58+
59+
defmodule ElixirLS.Installer do
60+
defp local_dir, do: Path.expand("#{__DIR__}/..")
61+
62+
defp run_mix_install({:local, dir}, force?) do
63+
Mix.install(
64+
[
65+
{:elixir_ls, path: dir},
66+
],
67+
force: force?,
68+
consolidate_protocols: false,
69+
config_path: Path.join(dir, "config/config.exs"),
70+
lockfile: Path.join(dir, "mix.lock")
71+
)
72+
end
73+
74+
defp run_mix_install({:tag, tag}, force?) do
75+
Mix.install([
76+
{:elixir_ls, github: "elixir-lsp/elixir-ls", tag: tag}
77+
],
78+
force: force?,
79+
consolidate_protocols: false
80+
)
81+
end
82+
83+
defp local? do
84+
System.get_env("ELS_LOCAL") == "1"
85+
end
86+
87+
defp get_release do
88+
version = Path.expand("#{__DIR__}/VERSION")
89+
|> File.read!()
90+
|> String.trim()
91+
{:tag, "v#{version}"}
92+
end
93+
94+
def install(force?) do
95+
if local?() do
96+
dir = local_dir()
97+
IO.puts(:stderr, "Installing local ElixirLS from #{dir}")
98+
IO.puts(:stderr, "Running in #{File.cwd!}")
99+
100+
run_mix_install({:local, dir}, force?)
101+
else
102+
{:tag, tag} = get_release()
103+
IO.puts(:stderr, "Installing ElixirLS release #{tag}")
104+
IO.puts(:stderr, "Running in #{File.cwd!}")
105+
106+
run_mix_install({:tag, tag}, force?)
107+
end
108+
IO.puts(:stderr, "Install complete")
109+
end
110+
111+
def install_for_launch do
112+
if local?() do
113+
dir = Path.expand("#{__DIR__}/..")
114+
run_mix_install({:local, dir}, false)
115+
else
116+
run_mix_install(get_release(), false)
117+
end
118+
end
119+
120+
def install_with_retry do
121+
try do
122+
install(false)
123+
catch
124+
kind, error ->
125+
IO.puts(:stderr, "Mix.install failed with #{Exception.format(kind, error, __STACKTRACE__)}")
126+
IO.puts(:stderr, "Retrying Mix.install with force: true")
127+
install(true)
128+
end
129+
end
130+
end

scripts/language_server.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off & setlocal enabledelayedexpansion
2+
3+
SET ELS_MODE=language_server
4+
5+
IF EXIST "%APPDATA%\elixir_ls\setup.bat" (
6+
ECHO "" | CALL "%APPDATA%\elixir_ls\setup.bat" > nul
7+
IF %ERRORLEVEL% NEQ 0 EXIT 1
8+
)
9+
10+
SET MIX_ENV=prod
11+
@REM pipe echo to avoid passing protocol messages to quiet install command
12+
@REM intercept stdout and stderr
13+
@REM elixir is a batch script and needs to be called
14+
ECHO "" | CALL elixir "%~dp0quiet_install.exs" >nul
15+
IF %ERRORLEVEL% NEQ 0 EXIT 1
16+
elixir --erl "+sbwt none +sbwtdcpu none +sbwtdio none" "%~dp0launch.exs"

scripts/language_server.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# Launches the language server. This script must be in the same directory as mix install launch script.
3+
4+
readlink_f () {
5+
cd "$(dirname "$1")" > /dev/null || exit 1
6+
filename="$(basename "$1")"
7+
if [ -h "$filename" ]; then
8+
readlink_f "$(readlink "$filename")"
9+
else
10+
echo "$(pwd -P)/$filename"
11+
fi
12+
}
13+
14+
if [ -z "${ELS_INSTALL_PREFIX}" ]; then
15+
dir="$(dirname "$(readlink_f "$0")")"
16+
else
17+
dir=${ELS_INSTALL_PREFIX}
18+
fi
19+
20+
export ELS_MODE=language_server
21+
exec "${dir}/launch.sh"

0 commit comments

Comments
 (0)