Skip to content

Commit

Permalink
Merge pull request #4 from janusvm/replace-gloml
Browse files Browse the repository at this point in the history
Replace dependency `gloml` with `tom`
  • Loading branch information
VioletBuse authored Aug 14, 2024
2 parents 8eaee6a + 7905662 commit 9ef8a90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ sqlight = ">= 0.9.0 and < 1.0.0"
simplifile = ">= 2.0.0 and < 3.0.0"
filepath = ">= 1.0.0 and < 2.0.0"
justin = ">= 1.0.1 and < 2.0.0"
gloml = ">= 0.1.3 and < 1.0.0"
argv = ">= 1.0.2 and < 2.0.0"
gleam_erlang = ">= 0.25.0 and < 1.0.0"
puddle = ">= 0.5.0 and < 1.0.0"
gleam_otp = ">= 0.10.0 and < 1.0.0"
tom = ">= 1.0.1 and < 2.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
7 changes: 3 additions & 4 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ packages = [
{ name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "gloml", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_stdlib", "toml"], otp_app = "gloml", source = "hex", outer_checksum = "D70229ACD487010B2D1CB57FFCCB0D2BB38CEC885DC9688D51D1020A579AC057" },
{ name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" },
{ name = "puddle", version = "0.5.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "puddle", source = "hex", outer_checksum = "1D199F61CAB692DA84CE8153C9351DC21C68C62BCE75782AFAAD5EE780144806" },
{ name = "simplifile", version = "2.0.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "95219227A43FCFE62C6E494F413A1D56FF953B68FE420698612E3D89A1EFE029" },
{ name = "sqlight", version = "0.9.0", build_tools = ["gleam"], requirements = ["esqlite", "gleam_stdlib"], otp_app = "sqlight", source = "hex", outer_checksum = "2D9C9BA420A5E7DCE7DB2DAAE4CAB0BE6218BEB48FD1531C583550B3D1316E94" },
{ name = "toml", version = "0.7.0", build_tools = ["mix"], requirements = [], otp_app = "toml", source = "hex", outer_checksum = "0690246A2478C1DEFD100B0C9B89B4EA280A22BE9A7B313A8A058A2408A2FA70" },
{ name = "tom", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "9EECB60150E834A07238BD5C7DF1FF07F7D4C5862BB8A773923D1981C7875FB0" },
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
filepath = { version = ">= 1.0.0 and < 2.0.0" }
gleam_erlang = { version = ">= 0.25.0 and < 1.0.0" }
gleam_otp = { version = ">= 0.10.0 and < 1.0.0"}
gleam_otp = { version = ">= 0.10.0 and < 1.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
gloml = { version = ">= 0.1.3 and < 1.0.0" }
justin = { version = ">= 1.0.1 and < 2.0.0" }
puddle = { version = ">= 0.5.0 and < 1.0.0" }
simplifile = { version = ">= 2.0.0 and < 3.0.0" }
sqlight = { version = ">= 0.9.0 and < 1.0.0" }
tom = { version = ">= 1.0.1 and < 2.0.0" }
26 changes: 15 additions & 11 deletions src/feather/migrate.gleam
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argv
import filepath
import gleam/bool
import gleam/dict.{type Dict}
import gleam/dynamic
import gleam/erlang
import gleam/int
Expand All @@ -10,10 +11,10 @@ import gleam/option.{None, Some}
import gleam/regex
import gleam/result
import gleam/string
import gloml
import justin
import simplifile
import sqlight.{type Connection}
import tom.{type Toml}

const helptext = "
gleam run -m feather/migrate -- <command> [options]
Expand All @@ -30,21 +31,24 @@ const helptext = "
migrations directory.
"

fn get_migrations_dir() -> String {
fn get_gleam_toml() -> Result(Dict(String, Toml), Nil) {
simplifile.read("gleam.toml")
|> result.nil_error
|> result.map(gloml.decode(_, dynamic.field("migrations_dir", dynamic.string)))
|> result.map(result.map_error(_, fn(_) { Nil }))
|> result.flatten
|> result.nil_error()
|> result.map(tom.parse)
|> result.then(result.nil_error)
}

fn get_migrations_dir() -> String {
get_gleam_toml()
|> result.map(tom.get_string(_, ["migrations_dir"]))
|> result.then(result.nil_error)
|> result.unwrap("./migrations")
}

fn get_schema_file() -> String {
simplifile.read("gleam.toml")
|> result.nil_error
|> result.map(gloml.decode(_, dynamic.field("schemafile", dynamic.string)))
|> result.map(result.map_error(_, fn(_) { Nil }))
|> result.flatten
get_gleam_toml()
|> result.map(tom.get_string(_, ["schemafile"]))
|> result.then(result.nil_error)
|> result.unwrap("./schema.sql")
}

Expand Down

0 comments on commit 9ef8a90

Please sign in to comment.