Skip to content

Commit 48001c4

Browse files
committed
Require Gleam v0.30+; support gleam run -m
1 parent 030a155 commit 48001c4

File tree

18 files changed

+1610
-502
lines changed

18 files changed

+1610
-502
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
otp-version: "25"
1919
rebar3-version: "3"
20-
gleam-version: "0.29"
20+
gleam-version: "0.30"
2121

2222
- uses: denoland/setup-deno@v1
2323
with:
@@ -60,7 +60,7 @@ jobs:
6060
- if: ${{ !steps.cache-gleam.outputs.cache-hit }}
6161
run: gleam deps download
6262

63-
- run: echo "$PWD/priv" >> $GITHUB_PATH
63+
- run: echo "$PWD/priv" >>$GITHUB_PATH
6464

6565
- run: rad format --check
6666

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Rad now requires Gleam v0.30 or later.
6+
- Rad can now be invoked via `gleam run --target=javascript -m rad`
7+
(`--target=erlang` is currently unsupported).
8+
- Rad no longer depends on `gleam_erlang` or `gleam_httpc`.
9+
310
## v0.3.0 - 2023-05-29
411

512
- Rad now requires Gleam v0.29 or later.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ resides).
7777

7878
```shell
7979
$ ./build/packages/rad/priv/rad <subcommand> [flags]
80+
$ # or
81+
$ gleam run --target=javascript --module=rad -- <subcommand> [flags]
8082
```
8183

84+
_Note: `gleam run --target=erlang --module=rad ...` is currently unsupported!_
85+
8286
For convenience when invoking `rad`, first perform one of the following
8387
operations in a manner consistent with your shell of choice. The goal is to get
8488
`priv/rad` or `priv/rad.ps1` somewhere in your `$PATH`; there are many ways to

gleam.toml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name = "rad"
2-
version = "0.3.0"
2+
version = "0.4.0-dev"
33
description = "A task runner for Gleam projects"
44
licences = ["Apache-2.0"]
55
target = "javascript"
6+
gleam = "~> 0.30"
67

78
[repository]
89
repo = "rad"
@@ -14,22 +15,17 @@ href = "https://gleam.run/"
1415
title = "Website"
1516

1617
[dependencies]
17-
gleam_erlang = "~> 0.19"
18-
gleam_http = "~> 3.1"
19-
gleam_httpc = "~> 2.0"
20-
gleam_json = "~> 0.5"
21-
gleam_stdlib = "~> 0.29"
22-
glint = "~> 0.11.1"
23-
shellout = "~> 1.3"
18+
gleam_http = "~> 3.3"
19+
gleam_json = "~> 0.6"
20+
gleam_stdlib = "~> 0.30"
21+
glint = "~> 0.11.4"
22+
shellout = "~> 1.4"
2423
snag = "~> 0.2"
25-
thoas = "~> 0.3"
24+
thoas = "~> 0.4"
2625
tomerl = "~> 0.5"
2726

2827
[dev-dependencies]
29-
gleeunit = "~> 0.7"
30-
31-
[javascript]
32-
runtime = "deno"
28+
gleeunit = "~> 0.11"
3329

3430
[javascript.deno]
3531
allow_all = true
@@ -42,7 +38,7 @@ with = "javascript"
4238
[[rad.formatters]]
4339
name = "erlang"
4440
check = ["erlfmt", "--check"]
45-
run = ["erlfmt", "--write", "src/rad_ffi.erl"]
41+
run = ["erlfmt", "--write", "src/rad_ffi.erl", "src/file_ffi.erl"]
4642

4743
[[rad.formatters]]
4844
name = "javascript"

manifest.toml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,27 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "gleam_bitwise", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "6064699EFBABB1CA392DCB193D0E8B402FB042B4B46857B01E6875E643B57F54" },
6-
{ name = "gleam_community_ansi", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_bitwise", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "6E4E0CF2B207C1A7FCD3C21AA43514D67BC7004F21F82045CDCCE6C727A14862" },
5+
{ name = "gleam_bitwise", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "E2A46EE42E5E9110DAD67E0F71E7358CBE54D5EC22C526DD48CBBA3223025792" },
6+
{ name = "gleam_community_ansi", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_colour", "gleam_bitwise"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "6E4E0CF2B207C1A7FCD3C21AA43514D67BC7004F21F82045CDCCE6C727A14862" },
77
{ name = "gleam_community_colour", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_bitwise"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "D27CE357ECB343929A8CEC3FBA0B499943A47F0EE1F589EE16AFC2DC21C61E5B" },
8-
{ name = "gleam_erlang", version = "0.19.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "720D1E0A0CEBBD51C4AA88501D1D4FBFEF4AA7B3332C994691ED944767A52582" },
9-
{ name = "gleam_http", version = "3.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "D034F5CE0639CD142CBA210B7D5D14236C284B0C5772A043D2E22128594573AE" },
10-
{ name = "gleam_httpc", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "4B7DB74F13814DAC8A9F470DF41D3B8335FC9CD9C48BED0B8EFB012F22C1315E" },
11-
{ name = "gleam_json", version = "0.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9A805C1E60FB9CD73AF3034EB464268A6B522D937FCD2DF92BD246F2F4B37930" },
12-
{ name = "gleam_stdlib", version = "0.29.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "DB981FB670AAC6392C0694AF639C49ADF1C2E42664D5F90BBF573102667B8E53" },
13-
{ name = "gleeunit", version = "0.10.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "ECEA2DE4BE6528D36AFE74F42A21CDF99966EC36D7F25DEB34D47DD0F7977BAF" },
14-
{ name = "glint", version = "0.11.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_colour", "gleam_community_ansi", "snag"], otp_app = "glint", source = "hex", outer_checksum = "B3B95A640C86B5833033B4B74276C7B1D2AA04634D845B526C56A8BC52F5D15F" },
15-
{ name = "shellout", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang"], otp_app = "shellout", source = "hex", outer_checksum = "2F0BFBA7E8D18427525EE8611E832D59D72D261FFA533A3C0DD86987383A53A5" },
16-
{ name = "snag", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "35C63E478782C58236F1050297C2FDF9806A4DD55C6FAF0B6EC5E54BC119342D" },
8+
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
9+
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
10+
{ name = "gleam_stdlib", version = "0.30.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "8D8BF3790AA31176B1E1C0B517DD74C86DA8235CF3389EA02043EE4FD82AE3DC" },
11+
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
12+
{ name = "glint", version = "0.11.4", build_tools = ["gleam"], requirements = ["snag", "gleam_stdlib", "gleam_community_ansi", "gleam_community_colour"], otp_app = "glint", source = "hex", outer_checksum = "9508BF037E35F549C51F9F1D2CC4736CEA7F7A49E21CCA9B4540452C7D6CC4C5" },
13+
{ name = "shellout", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "995564B69D40146B7A424CA21D32A68D668A882F88BDAD0EFA2C18C7EC412564" },
14+
{ name = "snag", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "8FD70D8FB3728E08AC425283BB509BB0F012BE1AE218424A597CDE001B0EE589" },
1715
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
1816
{ name = "tomerl", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "tomerl", source = "hex", outer_checksum = "2A7FB62F9EBF0E75561B39255638BC2B805B437C86FEC538657E7C3B576979FA" },
1917
]
2018

2119
[requirements]
22-
gleam_erlang = "~> 0.19"
23-
gleam_http = "~> 3.1"
24-
gleam_httpc = "~> 2.0"
25-
gleam_json = "~> 0.5"
26-
gleam_stdlib = "~> 0.29"
27-
gleeunit = "~> 0.7"
28-
glint = "~> 0.11.1"
29-
shellout = "~> 1.3"
30-
snag = "~> 0.2"
31-
thoas = "~> 0.3"
32-
tomerl = "~> 0.5"
20+
gleam_http = { version = "~> 3.3" }
21+
gleam_json = { version = "~> 0.6" }
22+
gleam_stdlib = { version = "~> 0.30" }
23+
gleeunit = { version = "~> 0.11" }
24+
glint = { version = "~> 0.11.4" }
25+
shellout = { version = "~> 1.4" }
26+
snag = { version = "~> 0.2" }
27+
thoas = { version = "~> 0.4" }
28+
tomerl = { version = "~> 0.5" }

priv/gleam.main.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { main } from "./rad.mjs";
2+
main();

priv/rad

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
set -e
44

55
self="rad"
6-
module="./build/dev/javascript/${self}/${self}.mjs"
6+
build_dir="./build/dev/javascript/${self}"
7+
main_module="${build_dir}/${self}.mjs"
8+
run="gleam.main"
9+
run_module="${build_dir}/${run}.mjs"
710

811
fail() {
912
message="${1}"
10-
echo "\033[91m${message}\033[0m" 1>&2
13+
printf %b "\033[91m${message}\033[0m\n" >&2
1114
exit 1
1215
}
1316

@@ -24,7 +27,7 @@ fi
2427

2528
snag=""
2629
for dependency in "gleam" "${runtime}"; do
27-
if ! type "${dependency}" > /dev/null 2>&1; then
30+
if ! type "${dependency}" >/dev/null 2>&1; then
2831
if test -n "${snag}"; then
2932
snag="${snag}\n"
3033
fi
@@ -39,25 +42,28 @@ fi
3942
#
4043
# Redirect stdout to stderr, keeping stdout clear for the given task.
4144
#
42-
if ! test -f "${module}"; then
43-
gleam build --target=javascript 1>&2
45+
if ! test -f "${main_module}"; then
46+
gleam build --target=javascript >&2
4447
fi
45-
if ! test -f "${module}"; then
46-
fail "error: \`${module}\` not found; try \`gleam add --dev ${self}\`"
48+
if ! test -f "${main_module}"; then
49+
fail "error: \`${main_module}\` not found; try \`gleam add --dev ${self}\`"
50+
fi
51+
if ! test -f "${run_module}"; then
52+
cp "./priv/${run}.mjs" "${run_module}"
4753
fi
4854

49-
script="import('${module}').then(module => module.main())"
5055
if test "${runtime}" = "deno"; then
51-
exec deno \
52-
eval "${script}" \
56+
exec deno run \
57+
--allow-all \
5358
--unstable \
54-
-- "${@}"
59+
"${run_module}" \
60+
"${@}"
5561
else
5662
exec node \
5763
--experimental-fetch \
5864
--experimental-repl-await \
5965
--no-warnings \
6066
--title="${self}" \
61-
--eval="${script}" \
62-
-- "${@}"
67+
"${run_module}" \
68+
"${@}"
6369
fi

priv/rad.ps1

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
$self = "rad"
2-
$module = "./build/dev/javascript/${self}/${self}.mjs"
2+
$build_dir = "./build/dev/javascript/${self}"
3+
$main_module = "${build_dir}/${self}.mjs"
4+
$run = "gleam.main"
5+
$run_module = "${build_dir}/${run}.mjs"
36

47
function Fail {
58
param($message)
@@ -36,28 +39,34 @@ if ("${snag}" -ne "") {
3639
#
3740
# Redirect stdout to stderr, keeping stdout clear for the given task.
3841
#
39-
if (-not (Test-Path -Type Leaf "${module}")) {
42+
if (-not (Test-Path -Type Leaf "${main_module}")) {
4043
gleam build --target=javascript | Out-Host
4144
if ($LastExitCode -ne 0) {
4245
Exit 1
4346
}
4447
}
45-
if (-not (Test-Path -Type Leaf "${module}")) {
46-
Fail "error: ``${module}`` not found; try ``gleam add --dev ${self}``"
48+
if (-not (Test-Path -Type Leaf "${main_module}")) {
49+
Fail "error: ``${main_module}`` not found; try ``gleam add --dev ${self}``"
50+
}
51+
if (-not (Test-Path -Type Leaf "${run_module}")) {
52+
Copy-Item -Path "./priv/${run}.mjs" -Destination "${run_module}"
53+
if ($LastExitCode -ne 0) {
54+
Exit 1
55+
}
4756
}
4857

49-
$script = "import('${module}').then(module => module.main())"
5058
if ("${runtime}" -eq "deno") {
51-
& deno `
52-
eval "${script}" `
59+
& deno run `
60+
--allow-all `
5361
--unstable `
54-
-- @Args
62+
"${run_module}" `
63+
@Args
5564
} else {
5665
& node `
5766
--experimental-fetch `
5867
--experimental-repl-await `
5968
--no-warnings `
6069
--title="${self}" `
61-
--eval="${script}" `
62-
-- @Args
70+
"${run_module}" `
71+
@Args
6372
}

0 commit comments

Comments
 (0)