Implement "update .app"
This commit is contained in:
parent
05a457bbc2
commit
56b9627041
@ -119,6 +119,8 @@ do(["set", "version", VersionString]) ->
|
|||||||
do(["verup", Level]) ->
|
do(["verup", Level]) ->
|
||||||
ok = compatibility_check([unix]),
|
ok = compatibility_check([unix]),
|
||||||
done(zx_local:verup(Level));
|
done(zx_local:verup(Level));
|
||||||
|
do(["update", ".app"]) ->
|
||||||
|
done(zx_local:update_app_file());
|
||||||
do(["list", "realms"]) ->
|
do(["list", "realms"]) ->
|
||||||
done(zx_local:list_realms());
|
done(zx_local:list_realms());
|
||||||
do(["list", "packages", Realm]) ->
|
do(["list", "packages", Realm]) ->
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
-export([initialize/2, set_version/1,
|
-export([initialize/2, set_version/1,
|
||||||
list_realms/0, list_packages/1, list_versions/1,
|
list_realms/0, list_packages/1, list_versions/1,
|
||||||
set_dep/1, list_deps/0, list_deps/1, drop_dep/1, verup/1, package/1,
|
set_dep/1, list_deps/0, list_deps/1, drop_dep/1, verup/1, package/1,
|
||||||
|
update_app_file/0,
|
||||||
import_realm/1, drop_realm/1,
|
import_realm/1, drop_realm/1,
|
||||||
takeover/1, abdicate/1, set_timeout/1, add_mirror/0, drop_mirror/0,
|
takeover/1, abdicate/1, set_timeout/1, add_mirror/0, drop_mirror/0,
|
||||||
create_plt/0, dialyze/0,
|
create_plt/0, dialyze/0,
|
||||||
@ -269,6 +270,42 @@ initialize_app_file({_, Name, Version}, AppStart) ->
|
|||||||
zx_lib:write_terms(AppFile, [AppProfile]).
|
zx_lib:write_terms(AppFile, [AppProfile]).
|
||||||
|
|
||||||
|
|
||||||
|
-spec update_app_file() -> zx:outcome().
|
||||||
|
|
||||||
|
update_app_file() ->
|
||||||
|
case zx_lib:read_project_meta() of
|
||||||
|
{ok, Meta} -> update_app_file(Meta);
|
||||||
|
Error -> Error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
update_app_file(Meta) ->
|
||||||
|
{_, Name, Version} = maps:get(package_id, Meta),
|
||||||
|
{ok, VersionString} = zx_lib:version_to_string(Version),
|
||||||
|
AppName = list_to_atom(Name),
|
||||||
|
AppFile = filename:join("ebin", Name ++ ".app"),
|
||||||
|
{application, AppName, RawAppData} =
|
||||||
|
case filelib:is_regular(AppFile) of
|
||||||
|
true ->
|
||||||
|
{ok, [D]} = file:consult(AppFile),
|
||||||
|
D;
|
||||||
|
false ->
|
||||||
|
{application,
|
||||||
|
AppName,
|
||||||
|
[{registered, []},
|
||||||
|
{included_applications, []},
|
||||||
|
{applications, [stdlib, kernel]}]}
|
||||||
|
end,
|
||||||
|
Grep = "grep -oP '^-module\\(\\K[^)]+' src/* | cut -d: -f2",
|
||||||
|
Modules = [list_to_atom(M) || M <- string:lexemes(os:cmd(Grep), "\n")],
|
||||||
|
Properties = [{vsn, VersionString}, {modules, Modules}],
|
||||||
|
Store = fun(T, L) -> lists:keystore(element(1, T), 1, L, T) end,
|
||||||
|
AppData = lists:foldl(Store, RawAppData, Properties),
|
||||||
|
AppProfile = {application, AppName, AppData},
|
||||||
|
ok = zx_lib:write_terms(AppFile, [AppProfile]),
|
||||||
|
log(info, "Writing app file: ~ts", [AppFile]).
|
||||||
|
|
||||||
|
|
||||||
-spec set_version(VersionString) -> zx:outcome()
|
-spec set_version(VersionString) -> zx:outcome()
|
||||||
when VersionString :: string().
|
when VersionString :: string().
|
||||||
%% @private
|
%% @private
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user