feat: dump schema json file to dashbarod static dir
This commit is contained in:
parent
fe24892b6d
commit
507952c473
|
@ -19,7 +19,7 @@
|
||||||
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}}
|
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}}
|
||||||
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.3"}}}
|
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.3"}}}
|
||||||
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.0"}}}
|
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.0"}}}
|
||||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.23.0"}}}
|
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.24.0"}}}
|
||||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
||||||
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
|
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
|
||||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}}
|
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
-export([update/3, update/4]).
|
-export([update/3, update/4]).
|
||||||
-export([remove/2, remove/3]).
|
-export([remove/2, remove/3]).
|
||||||
-export([reset/2, reset/3]).
|
-export([reset/2, reset/3]).
|
||||||
-export([gen_doc/1]).
|
-export([dump_schema/1]).
|
||||||
|
|
||||||
%% for rpc
|
%% for rpc
|
||||||
-export([get_node_and_config/1]).
|
-export([get_node_and_config/1]).
|
||||||
|
@ -121,20 +121,31 @@ reset(Node, KeyPath, Opts) when Node =:= node() ->
|
||||||
reset(Node, KeyPath, Opts) ->
|
reset(Node, KeyPath, Opts) ->
|
||||||
emqx_conf_proto_v1:reset(Node, KeyPath, Opts).
|
emqx_conf_proto_v1:reset(Node, KeyPath, Opts).
|
||||||
|
|
||||||
|
%% @doc Called from build script.
|
||||||
|
-spec dump_schema(file:name_all()) -> ok.
|
||||||
|
dump_schema(Dir) ->
|
||||||
|
SchemaJsonFile = filename:join([Dir, "schema.json"]),
|
||||||
|
JsonMap = hocon_schema_json:gen(emqx_conf_schema),
|
||||||
|
IoData = jsx:encode(JsonMap, [space, {indent, 4}]),
|
||||||
|
io:format(user, "===< Generating: ~s~n", [SchemaJsonFile]),
|
||||||
|
ok = file:write_file(SchemaJsonFile, IoData),
|
||||||
|
SchemaMarkdownFile = filename:join([Dir, "config.md"]),
|
||||||
|
io:format(user, "===< Generating: ~s~n", [SchemaMarkdownFile ]),
|
||||||
|
ok = gen_doc(SchemaMarkdownFile).
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Internal functions
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-spec gen_doc(file:name_all()) -> ok.
|
-spec gen_doc(file:name_all()) -> ok.
|
||||||
gen_doc(File) ->
|
gen_doc(File) ->
|
||||||
Version = emqx_release:version(),
|
Version = emqx_release:version(),
|
||||||
Title = "# EMQ X " ++ Version ++ " Configuration",
|
Title = "# EMQ X " ++ Version ++ " Configuration",
|
||||||
BodyFile = filename:join([code:lib_dir(emqx_conf), "etc", "emqx_conf.md"]),
|
BodyFile = filename:join([code:lib_dir(emqx_conf), "etc", "emqx_conf.md"]),
|
||||||
{ok, Body} = file:read_file(BodyFile),
|
{ok, Body} = file:read_file(BodyFile),
|
||||||
Doc = hocon_schema_doc:gen(emqx_conf_schema, #{title => Title,
|
Doc = hocon_schema_md:gen(emqx_conf_schema, #{title => Title, body => Body}),
|
||||||
body => Body}),
|
|
||||||
file:write_file(File, Doc).
|
file:write_file(File, Doc).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Internal functions
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
check_cluster_rpc_result(Result) ->
|
check_cluster_rpc_result(Result) ->
|
||||||
case Result of
|
case Result of
|
||||||
{ok, _TnxId, Res} -> Res;
|
{ok, _TnxId, Res} -> Res;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
[ {emqx, {path, "../emqx"}},
|
[ {emqx, {path, "../emqx"}},
|
||||||
%% FIXME: tag this as v3.1.3
|
%% FIXME: tag this as v3.1.3
|
||||||
{prometheus, {git, "https://github.com/emqx/prometheus.erl", {ref, "9994c76adca40d91a2545102230ccce2423fd8a7"}}},
|
{prometheus, {git, "https://github.com/emqx/prometheus.erl", {ref, "9994c76adca40d91a2545102230ccce2423fd8a7"}}},
|
||||||
{hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.23.0"}}},
|
{hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.24.0"}}},
|
||||||
{minirest, {git, "https://github.com/emqx/minirest", {tag, "1.2.11"}}}
|
{minirest, {git, "https://github.com/emqx/minirest", {tag, "1.2.11"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
5
build
5
build
|
@ -69,9 +69,8 @@ make_doc() {
|
||||||
libs_dir2="$("$FIND" "_build/$PROFILE/lib/" -maxdepth 2 -name ebin -type d)"
|
libs_dir2="$("$FIND" "_build/$PROFILE/lib/" -maxdepth 2 -name ebin -type d)"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
erl -noshell -pa $libs_dir1 $libs_dir2 -eval \
|
erl -noshell -pa $libs_dir1 $libs_dir2 -eval \
|
||||||
"F = filename:join(['_build', '${PROFILE}', lib, emqx_dashboard, priv, www, static, 'config.md']), \
|
"Dir = filename:join(['_build', '${PROFILE}', lib, emqx_dashboard, priv, www, static]), \
|
||||||
io:format(\"===< Generating: ~s~n\", [F]),
|
ok = emqx_conf:dump_schema(Dir), \
|
||||||
ok = emqx_conf:gen_doc(F), \
|
|
||||||
halt(0)."
|
halt(0)."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -68,7 +68,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
# in conflict by emqtt and hocon
|
# in conflict by emqtt and hocon
|
||||||
{:getopt, "1.0.2", override: true},
|
{:getopt, "1.0.2", override: true},
|
||||||
{:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.16.0", override: true},
|
{:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.16.0", override: true},
|
||||||
{:hocon, github: "emqx/hocon", tag: "0.23.0", override: true},
|
{:hocon, github: "emqx/hocon", tag: "0.24.0", override: true},
|
||||||
{:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.4.1", override: true},
|
{:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.4.1", override: true},
|
||||||
{:esasl, github: "emqx/esasl", tag: "0.2.0"},
|
{:esasl, github: "emqx/esasl", tag: "0.2.0"},
|
||||||
{:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"},
|
{:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"},
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
, {system_monitor, {git, "https://github.com/k32/system_monitor", {tag, "2.2.1"}}}
|
, {system_monitor, {git, "https://github.com/k32/system_monitor", {tag, "2.2.1"}}}
|
||||||
, {getopt, "1.0.2"}
|
, {getopt, "1.0.2"}
|
||||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}}
|
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.16.0"}}}
|
||||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.23.0"}}}
|
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.24.0"}}}
|
||||||
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.4.1"}}}
|
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.4.1"}}}
|
||||||
, {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}}
|
, {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}}
|
||||||
, {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}}
|
, {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}}
|
||||||
|
|
Loading…
Reference in New Issue