-module(go_over@retired@outdated). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([check_outdated/2]). -file("/home/bwireman/src/go-over/src/go_over/retired/outdated.gleam", 16). -spec pull_outdated(go_over@packages:package()) -> nil. pull_outdated(Pkg) -> go_over@util@print:progress( <<<<"Checking latest version: "/utf8, (erlang:element(2, Pkg))/binary>>/binary, " From hex.pm"/utf8>> ), Pkg_path = go_over@retired@core:outdated_path(Pkg), Pkg_path_fail = go_over@retired@core:pkg_pull_error(Pkg, Pkg_path), _ = simplifile_erl:delete(Pkg_path), _pipe = simplifile:create_directory_all(Pkg_path), go_over@util@util:hard_fail(_pipe, Pkg_path_fail), Resp = go_over@retired@core:do_pull_hex( Pkg, go_over@retired@core:package_url(Pkg) ), _pipe@1 = Pkg, _pipe@2 = go_over@retired@core:outdated_filename(_pipe@1), _pipe@3 = simplifile:write(_pipe@2, Resp), go_over@util@util:hard_fail(_pipe@3, Pkg_path_fail). -file("/home/bwireman/src/go-over/src/go_over/retired/outdated.gleam", 33). -spec decode_latest_stable_version(gleam@dynamic:dynamic_()) -> {ok, gleam@option:option(binary())} | {error, list(gleam@dynamic:decode_error())}. decode_latest_stable_version(Data) -> (gleam@dynamic:decode1( fun gleam@function:identity/1, gleam@dynamic:field( <<"latest_stable_version"/utf8>>, gleam@dynamic:optional(fun gleam@dynamic:string/1) ) ))(Data). -file("/home/bwireman/src/go-over/src/go_over/retired/outdated.gleam", 42). -spec check_outdated(go_over@packages:package(), boolean()) -> gleam@option:option(binary()). check_outdated(Pkg, Force_pull) -> _pipe = Pkg, _pipe@1 = go_over@retired@core:outdated_path(_pipe), go_over@util@cache:pull_if_not_cached( _pipe@1, 3600, Force_pull, gxyz@gxyz_function:freeze1(fun pull_outdated/1, Pkg), <<(erlang:element(2, Pkg))/binary, ": latest stable version"/utf8>> ), Cached_file_name = go_over@retired@core:outdated_filename(Pkg), Resp = begin _pipe@2 = Cached_file_name, _pipe@3 = simplifile:read(_pipe@2), go_over@util@util:hard_fail( _pipe@3, <<"failed to read "/utf8, Cached_file_name/binary>> ) end, _pipe@5 = (gleam@option:map( go_over@util@util:hard_fail( gleam@json:decode(Resp, fun decode_latest_stable_version/1), <<"failed to parse "/utf8, Cached_file_name/binary>> ), fun(Latest_version) -> Latest_semver = begin _pipe@4 = gleamsver:parse(Latest_version), go_over@util@util:hard_fail( _pipe@4, <<"failed to parse: "/utf8, Cached_file_name/binary>> ) end, case gleamsver:compare(Latest_semver, erlang:element(3, Pkg)) of gt -> {some, Latest_version}; _ -> none end end )), gleam@option:flatten(_pipe@5).