-module(go_over@retired@outdated). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([check_outdated/4]). -file("/home/bwireman/src/go-over/src/go_over/retired/outdated.gleam", 16). -spec pull_outdated(go_over@packages:package(), boolean(), boolean()) -> nil. pull_outdated(Pkg, Verbose, Global) -> go_over@util@print:progress( Verbose, <<<<"Checking latest version: "/utf8, (erlang:element(2, Pkg))/binary>>/binary, " From hex.pm"/utf8>> ), Pkg_path = go_over@retired@core:outdated_path(Pkg, Global), 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), gxyz@cli:hard_fail_with_msg(_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, Global), _pipe@3 = simplifile:write(_pipe@2, Resp), gxyz@cli:hard_fail_with_msg(_pipe@3, Pkg_path_fail). -file("/home/bwireman/src/go-over/src/go_over/retired/outdated.gleam", 36). -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", 45). -spec check_outdated( go_over@packages:package(), boolean(), boolean(), boolean() ) -> gleam@option:option(binary()). check_outdated(Pkg, Force_pull, Verbose, Global) -> _pipe = Pkg, _pipe@1 = go_over@retired@core:outdated_path(_pipe, Global), go_over@util@cache:pull_if_not_cached( _pipe@1, 3600, Force_pull, Verbose, gxyz@function:freeze3(fun pull_outdated/3, Pkg, Verbose, Global), <<(erlang:element(2, Pkg))/binary, ": latest stable version"/utf8>> ), Cached_file_name = go_over@retired@core:outdated_filename(Pkg, Global), Resp = begin _pipe@2 = Cached_file_name, _pipe@3 = simplifile:read(_pipe@2), gxyz@cli:hard_fail_with_msg( _pipe@3, <<"failed to read "/utf8, Cached_file_name/binary>> ) end, _pipe@5 = begin gleam@option:map( gxyz@cli:hard_fail_with_msg( 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), gxyz@cli:hard_fail_with_msg( _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 ) end, gleam@option:flatten(_pipe@5).