Current section

Files

Jump to
go_over src go_over.erl
Raw

src/go_over.erl

-module(go_over).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-spec main() -> nil.
main() ->
_assert_subject = go_over@yaml:start(),
{ok, _} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"go_over"/utf8>>,
function => <<"main"/utf8>>,
line => 16})
end,
Args = shellout_ffi:start_arguments(),
Skip = gleam@list:any(Args, fun(Arg) -> Arg =:= <<"--skip"/utf8>> end),
Force = gleam@list:any(Args, fun(Arg@1) -> Arg@1 =:= <<"--force"/utf8>> end),
Pkgs = go_over@packages:read_manifest(<<"./manifest.toml"/utf8>>),
case Force andalso Skip of
true ->
_pipe = shellout:style(
<<"Cannot specify both `--skip` & `--force`"/utf8>>,
shellout:color([<<"red"/utf8>>]),
[]
),
gleam@io:print(_pipe),
shellout_ffi:os_exit(1);
_ ->
nil
end,
_ = case Force of
true ->
simplifile:delete(go_over@constants:go_over_path());
_ ->
{ok, nil}
end,
Vulnerable_packages = begin
_pipe@1 = go_over@advisories:check_for_advisories(Pkgs, not Skip),
gleam@list:map(_pipe@1, fun(P) -> case P of
{Pkg, Adv} ->
go_over@warning:adv_to_warning(Pkg, Adv)
end end)
end,
Retired_packages = case Skip of
true ->
[];
_ ->
_pipe@2 = Pkgs,
_pipe@3 = gleam@list:map(
_pipe@2,
fun(Pkg@1) ->
case go_over@retired:check_retired(Pkg@1, not Skip) of
{some, Ret} ->
{some, {Pkg@1, Ret}};
none ->
none
end
end
),
_pipe@4 = gleam@option:values(_pipe@3),
gleam@list:map(
_pipe@4,
fun(P@1) ->
{Pkg@2, Ret@1} = P@1,
go_over@warning:retired_to_warning(Pkg@2, Ret@1)
end
)
end,
case lists:append(Retired_packages, Vulnerable_packages) of
[] ->
_pipe@5 = shellout:style(
<<"✅ All good! ✨\n\n"/utf8>>,
shellout:color([<<"brightgreen"/utf8>>]),
[]
),
gleam@io:print(_pipe@5);
Vulns ->
Len = erlang:length(Vulns),
_pipe@6 = (<<<<"⛔ "/utf8, (gleam@int:to_string(Len))/binary>>/binary,
" WARNING(s) FOUND!\n-----------------------------------------------\n"/utf8>>),
gleam@io:print(_pipe@6),
_pipe@7 = Vulns,
_pipe@9 = gleam@list:map(
_pipe@7,
fun(W) -> _pipe@8 = go_over@warning:print(W),
shellout:style(
_pipe@8,
shellout:color([<<"red"/utf8>>]),
[]
) end
),
_pipe@10 = gleam@string:join(
_pipe@9,
<<"\n-----------------------------------------------\n"/utf8>>
),
gleam@io:print(_pipe@10),
shellout_ffi:os_exit(1)
end.