Skip to content

Commit

Permalink
Use gleam
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoDaniels committed Oct 24, 2023
1 parent c091e57 commit cf47997
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 373 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: "26.0.2"
gleam-version: "0.31.0"
rebar3-version: "3"
# elixir-version: "1.15.4"
- run: gleam format --check src test
- run: gleam deps download
- run: gleam test
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
.idea

dist
elm-stuff
elm-stuff

*.beam
*.ez
build
erl_crash.dump
14 changes: 0 additions & 14 deletions LICENSE.md

This file was deleted.

29 changes: 0 additions & 29 deletions elm.json

This file was deleted.

20 changes: 20 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = "cockpit_cms_proxy"
version = "0.1.0"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# description = ""
# licences = ["Apache-2.0"]
# repository = { type = "github", user = "username", repo = "project" }
# links = [{ title = "Website", href = "https://gleam.run" }]

[dependencies]
gleam_stdlib = "~> 0.31"
mist = "~> 0.13"
gleam_http = "~> 3.5"
gleam_erlang = "~> 0.22"
gleam_httpc = "~> 2.1"

[dev-dependencies]
gleeunit = "~> 0.10"
21 changes: 21 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.22.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "367D8B41A7A86809928ED1E7E55BFD0D46D7C4CF473440190F324AFA347109B4" },
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
{ name = "gleam_httpc", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "55E634778A29E4D7459B7081DA1D16125A86655BA3AC90AC33878B1B993200C8" },
{ name = "gleam_otp", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang"], otp_app = "gleam_otp", source = "hex", outer_checksum = "ED7381E90636E18F5697FD7956EECCA635A3B65538DC2BE2D91A38E61DCE8903" },
{ name = "gleam_stdlib", version = "0.31.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6D1BC5B4D4179B9FEE866B1E69FE180AC2CE485AD90047C0B32B2CA984052736" },
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
{ name = "glisten", version = "0.8.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "364E9B3D4F78308D2EEE5D73E0FB16C686E08516943EFDA501B17177B382907C" },
{ name = "mist", version = "0.13.2", build_tools = ["gleam"], requirements = ["gleam_otp", "gleam_erlang", "gleam_stdlib", "glisten", "gleam_http"], otp_app = "mist", source = "hex", outer_checksum = "51C385C58A78A2013A30F92705814560AD9A2B8EC3ECBA94C620F22D3ACB50BC" },
]

[requirements]
gleam_erlang = { version = "~> 0.22" }
gleam_http = { version = "~> 3.5" }
gleam_httpc = { version = "~> 2.1" }
gleam_stdlib = { version = "~> 0.31" }
gleeunit = { version = "~> 0.10" }
mist = { version = "~> 0.13" }
39 changes: 25 additions & 14 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
let
pkgs = import (fetchTarball {
name = "nixpkgs-22.11-darwin-2023-01-09";
url = "https://github.com/NixOS/nixpkgs/archive/6713011f9e92.tar.gz";
sha256 = "0fvz2phhvnh6pwz6bycmlm6wkn5aydpr2bsinw8hmv5hvvcx4hr1";
name = "nixpkgs-23.05-darwin-2023-10-05";
url = "https://github.com/NixOS/nixpkgs/archive/1e9c7c0203be.tar.gz";
sha256 = "10qbybc9k3dj1xap9n0i3z7pc3svzwhclgsyfzzsf8cfh8l518pn";
}) { };

startDev = pkgs.writeShellScriptBin "startDev" ''
rm -rf dist
${pkgs.elmPackages.elm}/bin/elm make src/Main.elm --output=dist/elm.js
cp src/index.js dist/index.js
${pkgs.nodejs-18_x}/bin/node ./dist/index.js $1
'';
inherit (pkgs.lib) optional optionals;

in pkgs.mkShell {
buildInputs = [
pkgs.nodejs-18_x
pkgs.elmPackages.elm
erlang = pkgs.beam.interpreters.erlangR26;

startDev
gleam = pkgs.stdenv.mkDerivation rec {
name = "gleam-${version}";
version = "v0.31.0";
src = pkgs.fetchurl {
url = "https://github.com/gleam-lang/gleam/releases/download/${version}/gleam-${version}-x86_64-apple-darwin.tar.gz";
sha256 = "sha256-Ty7RKPJ9BZ/vE1ILM0J2N6Qv0sqFDJzlyAlYWJTXRbA=";
};
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
tar -xf $src -C $out/bin
'';
};

in pkgs.mkShell rec {
buildInputs = with pkgs;
[
gleam
erlang
rebar3
];
}
Loading

0 comments on commit cf47997

Please sign in to comment.