Skip to content

Commit 0601e8a

Browse files
committed
Add feature: elm-lang
1 parent d55952e commit 0601e8a

File tree

8 files changed

+185
-0
lines changed

8 files changed

+185
-0
lines changed

src/elm-lang/NOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Elm-lang
2+
3+
Installs the [Elm](https://elm-lang.org) compiler following the [linux install](https://github.com/elm/compiler/blob/master/installers/linux/README.md) documentation.
4+
5+
```shell
6+
elm --help
7+
```
8+
9+
See the [language guide](https://guide.elm-lang.org), [examples](https://elm-lang.org/examples), and [documentation](https://elm-lang.org/docs) for more information on the language.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"id": "elm-lang",
3+
"name": "Elm Language Compiler (via Github Releases)",
4+
"version": "0.1.0",
5+
"documentationURL": "https://github.com/CodeMan99/features/tree/main/src/elm-lang",
6+
"description": "Install the elm language compiler and related tools",
7+
"options": {
8+
"version": {
9+
"default": "0.19.1",
10+
"description": "Specify the compiler version",
11+
"type": "string"
12+
},
13+
"elmPrefix": {
14+
"default": "/usr/local/bin",
15+
"description": "Where the \"elm\" binary will be installed",
16+
"type": "string"
17+
},
18+
"installFormat": {
19+
"default": true,
20+
"description": "Install the \"elm-format\" command (via npm if installed)",
21+
"type": "boolean"
22+
},
23+
"installReview": {
24+
"default": true,
25+
"description": "Install the \"elm-review\" command (via npm if installed)",
26+
"type": "boolean"
27+
},
28+
"installTest": {
29+
"default": true,
30+
"description": "Install the \"elm-test\" command (via npm if installed)",
31+
"type": "boolean"
32+
}
33+
},
34+
"customizations": {
35+
"vscode": {
36+
"extensions": [
37+
"Elmtooling.elm-ls-vscode"
38+
]
39+
}
40+
},
41+
"installsAfter": [
42+
"ghcr.io/devcontainers/features/node"
43+
]
44+
}

src/elm-lang/install.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
VERSION="${VERSION:-0.19.1}"
6+
ELM_PREFIX="${ELMPREFIX:-/usr/local/bin}"
7+
INSTALL_FORMAT="${INSTALLFORMAT:-true}"
8+
INSTALL_REVIEW="${INSTALLREVIEW:-true}"
9+
INSTALL_TEST="${INSTALLTEST:-true}"
10+
11+
apt_get_update()
12+
{
13+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
14+
echo "Running apt-get update..."
15+
apt-get update -y
16+
fi
17+
}
18+
19+
# Checks if packages are installed and installs them if not
20+
check_packages() {
21+
if ! dpkg -s "$@" > /dev/null 2>&1; then
22+
apt_get_update
23+
apt-get -y install --no-install-recommends "$@"
24+
fi
25+
}
26+
27+
export DEBIAN_FRONTEND=noninteractive
28+
check_packages curl ca-certificates
29+
30+
curl --location --output elm.gz "https://github.com/elm/compiler/releases/download/${VERSION}/binary-for-linux-64-bit.gz"
31+
gunzip elm.gz
32+
install elm "${ELM_PREFIX}"
33+
34+
declare -a PACKAGES
35+
36+
if [[ "${INSTALL_FORMAT}" == "true" ]]; then
37+
PACKAGES+=("elm-format")
38+
fi
39+
40+
if [[ "${INSTALL_REVIEW}" == "true" ]]; then
41+
PACKAGES+=("elm-review")
42+
fi
43+
44+
if [[ "${INSTALL_TEST}" == "true" ]]; then
45+
PACKAGES+=("elm-test")
46+
fi
47+
48+
if command -v npm &> /dev/null && [[ ${#PACKAGES[@]} -gt 0 ]]; then
49+
npm install -g "${PACKAGES[@]}"
50+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "Elm-lang compiler binary is executable" test -x /usr/local/bin/elm
8+
check "elm --version" elm --version
9+
check "npm tool: elm-format" test -x "$(npm prefix -g)/bin/elm-format"
10+
check "npm tool: elm-review" test -x "$(npm prefix -g)/bin/elm-review"
11+
check "npm tool: elm-test" test -x "$(npm prefix -g)/bin/elm-test"
12+
13+
reportResults
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "Elm-lang compiler binary is executable" test -x /usr/local/bin/elm
8+
check "elm --version" elm --version
9+
check "npm tool: elm-format" test -x "$(npm prefix -g)/bin/elm-format"
10+
check "npm tool: elm-review" test -x "$(npm prefix -g)/bin/elm-review"
11+
check "npm tool: elm-test" test -x "$(npm prefix -g)/bin/elm-test"
12+
13+
reportResults
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "Elm-lang compiler binary is executable" test -x /usr/local/bin/elm
8+
check "elm --version" elm --version
9+
check "npm tool not installed: elm-format" test ! -e "$(npm prefix -g)/bin/elm-format"
10+
check "npm tool not installed: elm-review" test ! -e "$(npm prefix -g)/bin/elm-review"
11+
check "npm tool: elm-test" test -x "$(npm prefix -g)/bin/elm-test"
12+
13+
reportResults

test/elm-lang/scenarios.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"elm__debian__with_npm_tools": {
3+
"image": "debian:trixie",
4+
"features": {
5+
"elm-lang": {},
6+
"ghcr.io/devcontainers/features/node:1": {
7+
"version": "lts",
8+
"nodeGypDependencies": false
9+
}
10+
}
11+
},
12+
"elm__ubuntu__with_npm_tools": {
13+
"image": "ubuntu:noble",
14+
"features": {
15+
"elm-lang": {
16+
"installFormat": false,
17+
"installReview": false,
18+
"installTest": true
19+
},
20+
"ghcr.io/devcontainers/features/node:1": {
21+
"version": "lts",
22+
"nodeGypDependencies": false
23+
}
24+
}
25+
},
26+
"elm__javascript-node__with_npm_tools": {
27+
"image": "mcr.microsoft.com/devcontainers/javascript-node:4-24-bookworm",
28+
"remoteUser": "node",
29+
"features": {
30+
"elm-lang": {}
31+
}
32+
}
33+
}

test/elm-lang/test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
7+
check "Elm-lang compiler binary is executable" test -x /usr/local/bin/elm
8+
check "elm --version" elm --version
9+
10+
reportResults

0 commit comments

Comments
 (0)