Initial "verbs" adjustment

This commit is contained in:
Craig Everett 2019-12-20 19:12:25 +09:00
parent 4e83b63dcc
commit 959902d56f
6 changed files with 37 additions and 22 deletions

View File

@ -382,6 +382,12 @@ start() ->
module => logger_std_h},
ok = logger:add_handler(default, logger_std_h, LoggerConf),
ok = logger:set_primary_config(level, debug),
% Hacky:
% Load all necessary atoms for binary_to_term(B, [safe]) to work with zx_zsp:meta()
MetaKeys = maps:keys(zx_zsp:new_meta()),
Types = [lib, app, gui, cli],
ok = log(info, "ZSP meta keys: ~w", [MetaKeys]),
ok = log(info, "Available package types: ~w", [Types]),
application:ensure_started(zx).

View File

@ -118,7 +118,8 @@ submit2(ZspBin) ->
end.
submit3(ZspBin) ->
{ok, #{project_id := {Realm, Name, Version}, key_name := KeyName}} = zx_zsp:meta(ZspBin),
{ok, #{package_id := {Realm, Name, Version}, key_name := KeyName}}
= zx_zsp:meta(ZspBin),
UserName = select_auth(Realm),
case zx_daemon:get_key(private, {Realm, KeyName}) of
{ok, DKey} ->

View File

@ -280,17 +280,22 @@ wait_ok(Socket) ->
dispatch(Socket, ID, Action) ->
case Action of
{list, R} -> send_query(Socket, 3, R);
{list, R, N} -> send_query(Socket, 4, {R, N});
{list, R, N, V} -> send_query(Socket, 4, {R, N, V});
{latest, R, N} -> send_query(Socket, 5, {R, N});
{latest, R, N, V} -> send_query(Socket, 5, {R, N, V});
{provides, R, M} -> send_query(Socket, 6, {R, M});
{list_deps, R, N, V} -> send_query(Socket, 7, {R, N, V});
{list_sysops, R} -> send_query(Socket, 8, R);
{fetch, R, N, V} -> fetch(Socket, ID, {R, N, V});
{keychain, R, K} -> send_query(Socket, 10, {R, K});
Unexpected ->
{list, R} -> send_query(Socket, 3, R);
{list, R, N} -> send_query(Socket, 4, {R, N});
{list, R, N, V} -> send_query(Socket, 4, {R, N, V});
{latest, R, N} -> send_query(Socket, 5, {R, N});
{latest, R, N, V} -> send_query(Socket, 5, {R, N, V});
{describe, R, N} -> send_query(Socket, 6, {R, N});
{describe, R, N, V} -> send_query(Socket, 6, {R, N, V});
{tags, R, N} -> send_query(Socket, 7, {R, N});
{tags, R, N, V} -> send_query(Socket, 7, {R, N, V});
{provides, R, M} -> send_query(Socket, 8, {R, M});
{search, R, String} -> send_query(Socket, 9, {R, String});
{list_deps, R, N, V} -> send_query(Socket, 10, {R, N, V});
{list_sysops, R} -> send_query(Socket, 11, R);
{fetch, R, N, V} -> fetch(Socket, ID, {R, N, V});
{keychain, R, K} -> send_query(Socket, 13, {R, K});
Unexpected ->
Message = "Received unexpected request action. ID: ~tp, Action: ~200tp",
log(warning, Message, [ID, Unexpected])
end.

View File

@ -262,6 +262,7 @@
| {latest, zx:realm(), zx:name(), zx:version()}
| {describe, zx:realm(), zx:name()}
| {provides, zx:realm(), string()}
| {search, zx:realm(), string()}
| {list_deps, zx:realm(), zx:name(), zx:version()}
| {list_sysops, zx:realm()}
| {pending, zx:realm(), zx:name()}

View File

@ -248,15 +248,15 @@ initialize_check(P = #project{id = PackageID}) ->
initialize(P#project{id = none});
maybe ->
Message =
"~nHmmm...~n"
"zx_daemon wasn't able to find out (network problem?) whether this "
"package already exists.~n"
"What do?~",
"~n∑(。・Д・。)???~nHmmm...~n"
"zx_daemon wasn't able to check whether this package already exists.~n"
"(Network problem?)~n"
"What do?~n",
ok = io:format(Message),
Options = [{"Continue anyway.", 1},
{"Check again.", 2},
{"Abort and do it later.", 3}],
case zx_tty:selet(Options) of
case zx_tty:select(Options) of
1 -> zompify(P);
2 -> initialize_check(P);
3 -> ok
@ -2394,10 +2394,8 @@ ask_description() ->
"This description will appear:~n"
"- In the project's .app file~n"
"- Be displayed when a user uses the `zx describe [project]` command~n"
"- (If this is an end-user GUI application) As the program summary in the GUI~n"
" program launcher if no HTML summary data is provided on a project site~n"
"(NOTE: You can change or update this description in subsequent package "
"versions.)~n",
"- (GUIs) As the program summary if no project site summary can be found~n"
"NOTE: You can change or update this description in subsequent versions.~n",
String = zx_tty:get_input(Instructions, [], "[ENTER] to leave blank"),
unicode:characters_to_list(String, utf8).

View File

@ -32,6 +32,7 @@
a_email := string(),
copyright := string(),
c_email := string(),
license := string(),
ws_url := string(),
repo_url := string(),
prefix := string(),
@ -52,6 +53,7 @@ new_meta() ->
a_email => "",
copyright => "",
c_email => "",
license => "",
ws_url => "",
repo_url => "",
prefix => "",
@ -99,6 +101,7 @@ pack3(TargetDir, PackageID, Meta, {KeyName, Key}, ZspFile) ->
{ok, [{application, _, AppData}]} = file:consult(AppFile),
Modules = lists:map(fun atom_to_list/1, proplists:get_value(modules, AppData)),
TarGzPath = filename:join(zx_lib:path(tmp), ZspFile ++ ".tgz"),
ok = filelib:ensure_dir(TarGzPath),
ok = erl_tar:create(TarGzPath, Targets, [compressed]),
{ok, TgzBin} = file:read_file(TarGzPath),
ok = file:delete(TarGzPath),
@ -197,10 +200,11 @@ verify(_) ->
verify2(Sig, Signed = <<MetaSize:24, MetaBin:MetaSize/binary, _/binary>>) ->
case zx_lib:b_to_ts(MetaBin) of
{ok, {{Realm, _, _}, SigKeyName, _, _, _}} ->
{ok, #{package_id := {Realm, _, _}, key_name := SigKeyName}} ->
SigKeyID = {Realm, SigKeyName},
verify3(Sig, Signed, SigKeyID);
error ->
tell(info, "MetaBin: ~p", [MetaBin]),
{error, bad_zsp}
end;
verify2(_, _) ->