Packages

A tool to audit Erlang & Elixir dependencies, to make sure your Gleam ✨ projects really sparkle!

Retired package: Security issue - Vulnerability warnings were never emitted due to an inverted advisory filter. Upgrade to 3.3.1 or 4.0.0-rc2+.

Current section

Files

Jump to
go_over src go_over@packages.erl
Raw

src/go_over@packages.erl

-module(go_over@packages).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/go_over/packages.gleam").
-export([read_manifest/1]).
-export_type([package_source/0, package/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-type package_source() :: package_source_hex |
package_source_git |
package_source_local.
-type package() :: {package,
binary(),
gleamsver:sem_ver(),
binary(),
boolean(),
package_source()}.
-file("src/go_over/packages.gleam", 29).
?DOC(false).
-spec read_manifest(binary()) -> list(package()).
read_manifest(Path) ->
Manifest = begin
_pipe = simplifile:read(Path),
_pipe@1 = gxyz@cli:hard_fail_with_msg(
_pipe,
<<"could not parse "/utf8, Path/binary>>
),
_pipe@2 = gleam@string:replace(_pipe@1, <<"\r\n"/utf8>>, <<"\n"/utf8>>),
_pipe@3 = tom:parse(_pipe@2),
gxyz@cli:hard_fail_with_msg(
_pipe@3,
<<"could not parse "/utf8, Path/binary>>
)
end,
Packages = begin
_pipe@4 = tom:get_array(Manifest, [<<"packages"/utf8>>]),
gxyz@cli:hard_fail_with_msg(
_pipe@4,
<<<<"could not parse "/utf8, Path/binary>>/binary,
" value: packages"/utf8>>
)
end,
Required_packages = begin
_pipe@5 = tom:get_table(Manifest, [<<"requirements"/utf8>>]),
_pipe@6 = gxyz@cli:hard_fail_with_msg(
_pipe@5,
<<<<"could not parse "/utf8, Path/binary>>/binary,
" value: requirements"/utf8>>
),
maps:keys(_pipe@6)
end,
_pipe@11 = gleam@list:map(Packages, fun(P) -> case P of
{inline_table, T} ->
Name = begin
_pipe@7 = tom:get_string(T, [<<"name"/utf8>>]),
gxyz@cli:hard_fail_with_msg(
_pipe@7,
<<"could not parse package: "/utf8,
(gleam@string:inspect(T))/binary>>
)
end,
Ver = begin
_pipe@8 = tom:get_string(T, [<<"version"/utf8>>]),
gxyz@cli:hard_fail_with_msg(
_pipe@8,
<<"could not parse package: "/utf8,
(gleam@string:inspect(T))/binary>>
)
end,
Semver = begin
_pipe@9 = gleamsver:parse(Ver),
gxyz@cli:hard_fail_with_msg(
_pipe@9,
<<"could not parse package version: "/utf8,
Ver/binary>>
)
end,
Source_raw = begin
_pipe@10 = tom:get_string(T, [<<"source"/utf8>>]),
gxyz@cli:hard_fail_with_msg(
_pipe@10,
<<"could not parse package: "/utf8,
(gleam@string:inspect(T))/binary>>
)
end,
Source = case Source_raw of
<<"git"/utf8>> ->
package_source_git;
<<"hex"/utf8>> ->
package_source_hex;
<<"local"/utf8>> ->
package_source_local;
_ ->
go_over@util@util:do_panic()
end,
{some,
{package,
Name,
Semver,
Ver,
gleam@list:contains(Required_packages, Name),
Source}};
_ ->
go_over@util@print:warning(
<<"could not parse packages: incorrect type"/utf8>>
),
shellout_ffi:os_exit(1),
go_over@util@util:do_panic()
end end),
gleam@option:values(_pipe@11).