-module(go_over@packages). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([read_manifest/1]). -export_type([package/0]). -type package() :: {package, binary(), gleamsver:sem_ver(), binary(), boolean()}. -file("/home/bwireman/src/go-over/src/go_over/packages.gleam", 16). -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, Requirements = begin _pipe@5 = tom:get_table(Manifest, [<<"requirements"/utf8>>]), gxyz@cli:hard_fail_with_msg( _pipe@5, <<<<"could not parse "/utf8, Path/binary>>/binary, " value: requirements"/utf8>> ) end, Required_packages = maps:keys(Requirements), _pipe@9 = gleam@list:map(Packages, fun(P) -> case P of {inline_table, T} -> Name = begin _pipe@6 = tom:get_string(T, [<<"name"/utf8>>]), gxyz@cli:hard_fail_with_msg( _pipe@6, <<"could not parse package: "/utf8, (gleam@string:inspect(T))/binary>> ) end, Ver = begin _pipe@7 = tom:get_string(T, [<<"version"/utf8>>]), gxyz@cli:hard_fail_with_msg( _pipe@7, <<"could not parse package: "/utf8, (gleam@string:inspect(T))/binary>> ) end, Semver = begin _pipe@8 = gleamsver:parse(Ver), gxyz@cli:hard_fail_with_msg( _pipe@8, <<"could not parse package version: "/utf8, Ver/binary>> ) end, {some, {package, Name, Semver, Ver, gleam@list:contains(Required_packages, Name)}}; _ -> go_over@util@print:warning( <<"could not parse packages: incorrect type"/utf8>> ), shellout_ffi:os_exit(1), erlang:error(#{gleam_error => panic, message => <<"Unreachable, please create an issue in https://github.com/bwireman/go-over if you see this"/utf8>>, module => <<"go_over/packages"/utf8>>, function => <<"read_manifest"/utf8>>, line => 57}) end end), gleam@option:values(_pipe@9).