Skip to content

Commit

Permalink
Support glint v0.16, gleam_stdlib v0.36
Browse files Browse the repository at this point in the history
  • Loading branch information
tynanbe committed Mar 4, 2024
1 parent a9549d4 commit d0184db
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Rad now requires `glint` v0.16 or later.

## v1.1.0 - 2024-02-17

- Rad now uses npm package `smol-toml` for more feature-complete TOML parsing.
Expand Down
4 changes: 2 additions & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "rad"
version = "1.1.0"
version = "1.2.0-dev"
description = "A task runner for Gleam projects"
licences = ["Apache-2.0"]
target = "javascript"
Expand All @@ -19,7 +19,7 @@ gleam_http = "~> 3.5"
gleam_httpc = "~> 2.1"
gleam_json = "~> 0.7 or ~> 1.0"
gleam_stdlib = "~> 0.34 or ~> 1.0"
glint = "~> 0.15 or ~> 1.0"
glint = "~> 0.16 or ~> 1.0"
shellout = "~> 1.6"
snag = "~> 0.3 or ~> 1.0"
thoas = "~> 0.4 or ~> 1.0"
Expand Down
6 changes: 3 additions & 3 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ packages = [
{ name = "gleam_http", version = "3.5.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "C2FC3322203B16F897C1818D9810F5DEFCE347F0751F3B44421E1261277A7373" },
{ name = "gleam_httpc", version = "2.1.2", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "ACD05CA3BAC7780DF5FFAE334621FD199D1B490FAF6ECDFF74316CAA61CE88E6" },
{ name = "gleam_json", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "8B197DD5D578EA6AC2C0D4BDC634C71A5BCA8E7DB5F47091C263ECB411A60DF3" },
{ name = "gleam_stdlib", version = "0.35.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5443EEB74708454B65650FEBBB1EF5175057D1DEC62AEA9D7C6D96F41DA79152" },
{ name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
{ name = "glint", version = "0.15.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "D5324DBE11F57BF0B303D99EA086D66B8DC319EE59C1355C76EBB1544187C237" },
{ name = "glint", version = "0.16.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "61B7E85CBB0CCD2FD8A9C7AE06CA97A80BF6537716F34362A39DF9C74967BBBC" },
{ name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
{ name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
Expand All @@ -22,7 +22,7 @@ gleam_httpc = { version = "~> 2.1" }
gleam_json = { version = "~> 0.7 or ~> 1.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
glint = { version = "~> 0.15 or ~> 1.0" }
glint = { version = "~> 0.16 or ~> 1.0" }
shellout = { version = "~> 1.6" }
snag = { version = "~> 0.3 or ~> 1.0" }
thoas = { version = "~> 0.4 or ~> 1.0" }
Expand Down
7 changes: 2 additions & 5 deletions src/rad.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import gleam/bool
import gleam/dict
import gleam/dynamic
import gleam/function
import gleam/io
import gleam/list
import gleam/result
Expand Down Expand Up @@ -108,6 +106,7 @@ pub fn do_main(workbook: Workbook) -> Nil {
Help(string) -> Ok(string)
}
})
|> result.map_error(with: snag.new)
|> result.flatten
|> end_task
}
Expand All @@ -123,9 +122,7 @@ fn arguments(scope: Scope) -> List(String) {
start_arguments()
|> list.filter(keeping: case scope {
Global -> filter
Normal ->
filter
|> function.compose(bool.negate)
Normal -> fn(arg) { !filter(arg) }
})
case scope {
Global -> arguments
Expand Down
15 changes: 5 additions & 10 deletions src/rad/toml.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import gleam/string
import snag.{type Snag}
@target(erlang)
import gleam/dict
@target(erlang)
import gleam/function

/// A TOML [table](https://toml.io/en/v1.0.0#table) of dynamic data.
///
Expand Down Expand Up @@ -70,14 +68,11 @@ fn do_decode_every(
) -> Result(List(#(String, a)), Snag) {
use dict <- result.try(
key_path
|> decode(
from: toml,
expect: dynamic.from
|> function.compose(dynamic.dict(
of: dynamic.string,
to: dynamic.dynamic,
)),
),
|> decode(from: toml, expect: fn(toml) {
toml
|> dynamic.from
|> dynamic.dict(of: dynamic.string, to: dynamic.dynamic)
}),
)

dict
Expand Down
11 changes: 7 additions & 4 deletions src/rad/util.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,11 @@ pub fn relay_flags(flags: flag.Map) -> List(String) {
get_fun: fn(Flag) -> snag.Result(List(a)),
string_fun,
) {
list.map(_, with: string_fun)
|> function.compose(string.join(_, with: ","))
fn(flags) {
flags
|> list.map(with: string_fun)
|> string.join(with: ",")
}
|> relay_flag(get_fun, _)
}

Expand Down Expand Up @@ -474,7 +477,7 @@ const test_flag = "rad-test"
///
pub fn quiet_or_print(input: CommandInput) -> fn(String) -> Nil {
case is_test(input) {
True -> function.constant(Nil)
True -> fn(_) { Nil }
False -> io.print
}
}
Expand All @@ -487,7 +490,7 @@ pub fn quiet_or_print(input: CommandInput) -> fn(String) -> Nil {
///
pub fn quiet_or_println(input: CommandInput) -> fn(String) -> Nil {
case is_test(input) {
True -> function.constant(Nil)
True -> fn(_) { Nil }
False -> io.println
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/rad/workbook.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,14 @@ pub fn info(config: Toml) -> Result {
let version =
["version"]
|> toml.decode(from: config, expect: dynamic.string)
|> result.map(
with: string.append(to: "v", suffix: _)
|> function.compose(shellout.style(
_,
|> result.map(with: fn(version) {
version
|> string.append(to: "v")
|> shellout.style(
with: shellout.display(["italic"]),
custom: util.lookups,
)),
)
)
})
|> option.from_result

let description =
Expand Down
32 changes: 15 additions & 17 deletions src/rad/workbook/standard.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import gleam
import gleam/dict
import gleam/dynamic
import gleam/function
import gleam/http.{type Header}
import gleam/int
import gleam/io
Expand Down Expand Up @@ -750,10 +749,11 @@ pub fn ping(input: CommandInput, _task: Task(Result)) -> Result {
|> uri.to_string
|> do_ping([#("cache-control", "no-cache, no-store")])
|> result.map(with: int.to_string)
|> result.map_error(
with: int.to_string
|> function.compose(snag.new),
)
|> result.map_error(with: fn(status) {
status
|> int.to_string
|> snag.new
})
}

@target(erlang)
Expand Down Expand Up @@ -1028,12 +1028,11 @@ pub fn tree(_input: CommandInput, _task: Task(Result)) -> Result {
|> shellout.command(run: "tree", in: ".", opt: [])
|> result.replace_error(snag.layer(error, "command `tree` not found"))
}
|> result.map_error(
with: function.compose(
snag.layer(_, "failed to find a known tree command"),
snag.layer(_, "failed to run task"),
),
)
|> result.map_error(with: fn(snag) {
snag
|> snag.layer("failed to find a known tree command")
|> snag.layer("failed to run task")
})
}

/// Prints stylized versions for packages found in your project's `gleam.toml`
Expand Down Expand Up @@ -1214,12 +1213,11 @@ fn do_watch(input: CommandInput) -> Result {
"command `inotifywait` not found",
))
}
|> result.map_error(
with: function.compose(
snag.layer(_, "failed to find a known watcher command"),
snag.layer(_, "failed to run task"),
),
)
|> result.map_error(with: fn(snag) {
snag
|> snag.layer("failed to find a known watcher command")
|> snag.layer("failed to run task")
})
}

@target(javascript)
Expand Down
5 changes: 2 additions & 3 deletions test/rad/task_test.gleam
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import gleam/dict
import gleam/dynamic
import gleam/function
import gleam/int
import gleam/list
import gleam/result
Expand Down Expand Up @@ -433,11 +432,11 @@ pub fn trainer_test() {
|> task.new(run: fn(input, _task) {
input.args
|> list.map(with: fn(arg) {
let not_oddish =
let not_oddish = fn(_) {
["not", arg]
|> string.join(with: " ")
|> snag.new
|> function.constant
}
use maybe_oddish <- result.try(
arg
|> int.parse
Expand Down

0 comments on commit d0184db

Please sign in to comment.