Skip to content

Commit

Permalink
Support gleam_stdlib v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tynanbe committed Feb 16, 2024
1 parent bdf598f commit 422f676
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 256 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:

- uses: erlef/setup-beam@v1
with:
otp-version: "25"
otp-version: "26"
rebar3-version: "3"
gleam-version: "0.33"
gleam-version: "1.0.0-rc2"

- uses: denoland/setup-deno@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

- Rad now supports `gleam_stdlib` v1.0.
- Rad now requires Gleam v0.34 or later.
- Rad now requires `glint` v0.15 or later.

## v1.0.0 - 2023-12-21

- Rad now requires Gleam v0.33 or later.
Expand Down
18 changes: 9 additions & 9 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name = "rad"
version = "1.0.0"
version = "1.1.0-dev"
description = "A task runner for Gleam projects"
licences = ["Apache-2.0"]
target = "javascript"
gleam = ">= 0.33.0"
gleam = ">= 0.34.0"

[repository]
repo = "rad"
Expand All @@ -16,13 +16,13 @@ title = "Website"

[dependencies]
gleam_http = "~> 3.5"
gleam_json = "~> 0.7"
gleam_stdlib = "~> 0.34"
glint = "~> 0.13"
shellout = "~> 1.5"
snag = "~> 0.3"
thoas = "~> 0.4"
tomerl = "~> 0.5"
gleam_json = "~> 0.7 or ~> 1.0"
gleam_stdlib = "~> 0.34 or ~> 1.0"
glint = "~> 0.15 or ~> 1.0"
shellout = "~> 1.6"
snag = "~> 0.3 or ~> 1.0"
thoas = "~> 0.4 or ~> 1.0"
tomerl = "~> 0.5 or ~> 1.0"

[dev-dependencies]
gleeunit = "~> 1.0"
Expand Down
28 changes: 14 additions & 14 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_community_ansi", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_colour"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8B5A9677BC5A2738712BBAF2BA289B1D8195FDF962BBC769569976AD5E9794E1" },
{ name = "gleam_community_colour", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "036C206886AFB9F153C552700A7A0B4D2864E3BC96A20C77E5F34A013C051BE3" },
{ name = "gleam_http", version = "3.5.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "AECDA43AFD523D07A8F09068598A6E271C505278A0CB6F9C7A2E4365EAE8D11E" },
{ name = "gleam_json", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB405BD93A8828BCD870463DE29375E7B2D252D9D124C109E5B618AAC00B86FC" },
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
{ name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
{ name = "gleam_community_colour", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "A49A5E3AE8B637A5ACBA80ECB9B1AFE89FD3D5351FF6410A42B84F666D40D7D5" },
{ name = "gleam_http", version = "3.5.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "C2FC3322203B16F897C1818D9810F5DEFCE347F0751F3B44421E1261277A7373" },
{ 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.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "81E91937710732ED1CA1F8E83D7AD19B4E87F63A1FC644A539264B6A118003D4" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
{ name = "glint", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_community_ansi", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "46E56049CD370D61F720D319D0AB970408C9336EEB918F08B5DCB1DCE9845FA3" },
{ name = "shellout", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "7B5DE499DBB3DDC25051FC1BB3770DD5466938B6A2AFA91A6FB4A4D49F4CB0D4" },
{ 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 = "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" },
{ name = "tomerl", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "tomerl", source = "hex", outer_checksum = "2A7FB62F9EBF0E75561B39255638BC2B805B437C86FEC538657E7C3B576979FA" },
]

[requirements]
gleam_http = { version = "~> 3.5" }
gleam_json = { version = "~> 0.7" }
gleam_stdlib = { version = "~> 0.34" }
gleam_json = { version = "~> 0.7 or ~> 1.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
glint = { version = "~> 0.13" }
shellout = { version = "~> 1.5" }
snag = { version = "~> 0.3" }
thoas = { version = "~> 0.4" }
tomerl = { version = "~> 0.5" }
glint = { version = "~> 0.15 or ~> 1.0" }
shellout = { version = "~> 1.6" }
snag = { version = "~> 0.3 or ~> 1.0" }
thoas = { version = "~> 0.4 or ~> 1.0" }
tomerl = { version = "~> 0.5 or ~> 1.0" }
26 changes: 13 additions & 13 deletions src/rad.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ pub fn main() -> Nil {
|> glint.add(
at: [],
do: fn(input: CommandInput) {
"with"
|> flag.get_string(from: input.flags)
|> result.unwrap(or: with)
}
|> glint.command
|> glint.flag(
at: "with",
of: flag.string()
|> flag.default(of: with),
),
"with"
|> flag.get_string(from: input.flags)
|> result.unwrap(or: with)
}
|> glint.command
|> glint.flag(
at: "with",
of: flag.string()
|> flag.default(of: with),
),
)
|> glint.execute(arguments(Global))

Expand Down Expand Up @@ -96,9 +96,9 @@ pub fn do_main(workbook: Workbook) -> Nil {
|> glint.add(
at: path,
do: task.run(_, task)
|> glint.command
|> glint.flags(with: task.flags)
|> glint.description(task.shortdoc),
|> glint.command
|> glint.flags(with: task.flags)
|> glint.description(task.shortdoc),
)
})
|> glint.execute(arguments(Normal))
Expand Down
29 changes: 18 additions & 11 deletions src/rad/task.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import gleam
import gleam/bool
import gleam/dict
import gleam/dynamic
import gleam/int
import gleam/json
Expand Down Expand Up @@ -169,9 +170,9 @@ pub fn flag(
let flag = #(
name,
flag_fun()
|> flag.default(of: value)
|> flag.description(of: description)
|> flag.build,
|> flag.default(of: value)
|> flag.description(of: description)
|> flag.build,
)
let flags =
task.flags
Expand Down Expand Up @@ -322,6 +323,8 @@ pub fn or(
}
}

let named_args = dict.new()

let mapper = fn(input: CommandInput, task, index, item) {
case cond(input) {
Each(map: mapper, ..) -> mapper(input, task, index, item)
Expand All @@ -330,7 +333,7 @@ pub fn or(
item
|> json.decode(using: dynamic.list(of: dynamic.string))
|> result.unwrap(or: [])
|> CommandInput(flags: input.flags)
|> CommandInput(flags: input.flags, named_args: named_args)
}
}
}
Expand Down Expand Up @@ -384,8 +387,10 @@ pub type Formatter {
pub fn formatters() -> Iterable(a) {
let formatters = [
"gleam"
|> Formatter(check: ["gleam", "format", "--check"], run: ["gleam", "format"])
|> Ok,
|> Formatter(check: ["gleam", "format", "--check"], run: [
"gleam", "format",
])
|> Ok,
..formatters_from_config()
]

Expand All @@ -394,6 +399,8 @@ pub fn formatters() -> Iterable(a) {
|> list.map(with: fn(_result) { "" })
}

let named_args = dict.new()

let mapper = fn(input: CommandInput, _task, index, _argument) {
let io_println = util.quiet_or_println(input)
let check =
Expand All @@ -414,7 +421,7 @@ pub fn formatters() -> Iterable(a) {
let _print =
[
action
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
" ",
formatter.name,
extra,
Expand All @@ -423,13 +430,13 @@ pub fn formatters() -> Iterable(a) {
|> string.concat
|> io_println
args
|> CommandInput(flags: input.flags)
|> CommandInput(flags: input.flags, named_args: named_args)
}
_else ->
"--fail"
|> flag.update_flags(in: input.flags)
|> result.unwrap(or: input.flags)
|> CommandInput(args: [])
|> CommandInput(args: [], named_args: named_args)
}
}

Expand Down Expand Up @@ -520,7 +527,7 @@ pub fn targets() -> Iterable(a) {
let _heading =
[
" Targeting"
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
" ",
target,
"...",
Expand Down Expand Up @@ -672,7 +679,7 @@ pub fn trainer(runner: Runner(Result)) -> Runner(Result) {
|> int.to_string
[
errors
|> int.to_string,
|> int.to_string,
"of",
results,
"task runs failed",
Expand Down
5 changes: 4 additions & 1 deletion src/rad/toml.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ fn do_decode_every(
|> decode(
from: toml,
expect: dynamic.from
|> function.compose(dynamic.dict(of: dynamic.string, to: dynamic.dynamic)),
|> function.compose(dynamic.dict(
of: dynamic.string,
to: dynamic.dynamic,
)),
),
)

Expand Down
20 changes: 10 additions & 10 deletions src/rad/util.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ pub fn snag_pretty_print(snag: Snag) -> String {
let builder =
[
"error"
|> bold(and: ["red"]),
|> bold(and: ["red"]),
": "
|> bold([]),
|> bold([]),
snag.issue
|> bold([]),
|> bold([]),
"\n",
]
|> string_builder.from_strings
Expand All @@ -338,9 +338,9 @@ pub fn snag_pretty_print(snag: Snag) -> String {
[
"\n",
"cause"
|> bold(and: ["red"]),
|> bold(and: ["red"]),
":\n"
|> bold([]),
|> bold([]),
]
|> string_builder.from_strings
|> string_builder.append_builder(to: builder)
Expand All @@ -355,12 +355,12 @@ fn pretty_print_cause(cause) {
[
" ",
index
|> int.to_string
|> bold(and: ["red"]),
|> int.to_string
|> bold(and: ["red"]),
": "
|> bold([]),
|> bold([]),
line
|> bold([]),
|> bold([]),
"\n",
]
|> string.concat
Expand All @@ -372,7 +372,7 @@ fn bold(string, and colors: List(String)) -> String {
string
|> shellout.style(
with: shellout.display(["bold"])
|> dict.merge(from: shellout.color(colors)),
|> dict.merge(from: shellout.color(colors)),
custom: lookups,
)
}
Expand Down
32 changes: 16 additions & 16 deletions src/rad/workbook.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
#(
"help",
flag.bool()
|> flag.default(of: False)
|> flag.description(of: "Print help information")
|> flag.build,
|> flag.default(of: False)
|> flag.description(of: "Print help information")
|> flag.build,
),
#(
"with",
flag.string()
|> flag.default(of: "")
|> flag.description(of: "Specify a rad runtime")
|> flag.build,
|> flag.default(of: "")
|> flag.description(of: "Specify a rad runtime")
|> flag.build,
),
..task.flags
|> list.filter(keeping: fn(flag) {
Expand Down Expand Up @@ -211,7 +211,7 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
|> string.join(with: " ")
|> shellout.style(
with: shellout.display(["bold"])
|> dict.merge(from: shellout.color([path_color])),
|> dict.merge(from: shellout.color([path_color])),
custom: util.lookups,
)
|> Some
Expand Down Expand Up @@ -256,7 +256,7 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
"rad"
|> shellout.style(
with: shellout.display(["bold"])
|> dict.merge(from: shellout.color(["pink"])),
|> dict.merge(from: shellout.color(["pink"])),
custom: util.lookups,
)
|> Some
Expand Down Expand Up @@ -336,7 +336,7 @@ pub fn info(config: Toml) -> Result {
"rad"
|> shellout.style(
with: shellout.display(["bold", "italic"])
|> dict.merge(from: shellout.color(["pink"])),
|> dict.merge(from: shellout.color(["pink"])),
custom: util.lookups,
)
|> Some
Expand All @@ -360,19 +360,19 @@ pub fn info(config: Toml) -> Result {
|> result.map(with: shellout.style(
_,
with: shellout.display(["italic"])
|> dict.merge(from: shellout.color(["purple"])),
|> dict.merge(from: shellout.color(["purple"])),
custom: util.lookups,
))
|> option.from_result

[
[name, version]
|> option.values
|> string.join(with: " ")
|> Some,
|> option.values
|> string.join(with: " ")
|> Some,
[Some(""), description]
|> option.all
|> option.map(with: string.join(_, with: tab)),
|> option.all
|> option.map(with: string.join(_, with: tab)),
]
|> option.values
|> string.join(with: "\n")
Expand All @@ -385,7 +385,7 @@ pub fn heading(name: String) -> String {
name
|> shellout.style(
with: shellout.display(["bold"])
|> dict.merge(from: shellout.color([heading_color])),
|> dict.merge(from: shellout.color([heading_color])),
custom: util.lookups,
)
}
Expand Down
Loading

0 comments on commit 422f676

Please sign in to comment.