Merge pull request #8360 from zhongwencool/example-name

chore: mv i18n.conf to emqx_dashboard/priv/
This commit is contained in:
zhongwencool 2022-07-01 10:23:10 +08:00 committed by GitHub
commit e0ab8e58cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 27 additions and 31 deletions

View File

@ -189,7 +189,7 @@ jobs:
# gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
./emqx/bin/emqx start || cat emqx/log/erlang.log.1 ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
ready='no' ready='no'
for i in {1..10}; do for i in {1..18}; do
if curl -fs 127.0.0.1:18083/api/v5/status > /dev/null; then if curl -fs 127.0.0.1:18083/api/v5/status > /dev/null; then
ready='yes' ready='yes'
break break

1
.gitignore vendored
View File

@ -44,6 +44,7 @@ _packages
elvis elvis
emqx_dialyzer_*_plt emqx_dialyzer_*_plt
*/emqx_dashboard/priv/www */emqx_dashboard/priv/www
*/emqx_dashboard/priv/i18n.conf
dist.zip dist.zip
scripts/git-token scripts/git-token
apps/*/etc/*.all apps/*/etc/*.all

View File

@ -138,7 +138,7 @@ reset(Node, KeyPath, Opts) ->
%% @doc Called from build script. %% @doc Called from build script.
-spec dump_schema(file:name_all()) -> ok. -spec dump_schema(file:name_all()) -> ok.
dump_schema(Dir) -> dump_schema(Dir) ->
I18nFile = emqx:etc_file("i18n.conf"), I18nFile = emqx_dashboard:i18n_file(),
dump_schema(Dir, emqx_conf_schema, I18nFile). dump_schema(Dir, emqx_conf_schema, I18nFile).
dump_schema(Dir, SchemaModule, I18nFile) -> dump_schema(Dir, SchemaModule, I18nFile) ->
@ -146,7 +146,8 @@ dump_schema(Dir, SchemaModule, I18nFile) ->
fun(Lang) -> fun(Lang) ->
gen_config_md(Dir, I18nFile, SchemaModule, Lang), gen_config_md(Dir, I18nFile, SchemaModule, Lang),
gen_api_schema_json(Dir, I18nFile, Lang), gen_api_schema_json(Dir, I18nFile, Lang),
gen_example_conf(filename:dirname(I18nFile), I18nFile, SchemaModule, Lang) ExampleDir = filename:join(filename:dirname(filename:dirname(I18nFile)), "etc"),
gen_example_conf(ExampleDir, I18nFile, SchemaModule, Lang)
end, end,
[en, zh] [en, zh]
), ),

View File

@ -19,8 +19,8 @@ doc_gen_test() ->
"test", "test",
"lib", "lib",
"emqx_dashboard", "emqx_dashboard",
"etc", "priv",
"i18n.conf.all" "i18n.conf"
]), ]),
_ = emqx_conf:dump_schema(Dir, emqx_conf_schema, I18nFile), _ = emqx_conf:dump_schema(Dir, emqx_conf_schema, I18nFile),
ok ok

View File

@ -30,6 +30,7 @@
init_i18n/2, init_i18n/2,
init_i18n/0, init_i18n/0,
get_i18n/0, get_i18n/0,
i18n_file/0,
clear_i18n/0 clear_i18n/0
]). ]).
@ -271,7 +272,7 @@ return_unauthorized(Code, Message) ->
i18n_file() -> i18n_file() ->
case application:get_env(emqx_dashboard, i18n_file) of case application:get_env(emqx_dashboard, i18n_file) of
undefined -> emqx:etc_file("i18n.conf"); undefined -> filename:join([code:priv_dir(emqx_dashboard), "i18n.conf"]);
{ok, File} -> File {ok, File} -> File
end. end.

View File

@ -55,9 +55,8 @@ set_default_config(DefaultUsername) ->
}, },
emqx_config:put([dashboard], Config), emqx_config:put([dashboard], Config),
I18nFile = filename:join([ I18nFile = filename:join([
filename:dirname(code:priv_dir(emqx_dashboard)), code:priv_dir(emqx_dashboard),
"etc", "i18n.conf"
"i18n.conf.all"
]), ]),
application:set_env(emqx_dashboard, i18n_file, I18nFile), application:set_env(emqx_dashboard, i18n_file, I18nFile),
ok. ok.

View File

@ -221,7 +221,10 @@ fields(node_info) ->
{log_path, {log_path,
mk( mk(
string(), string(),
#{desc => <<"Path to log files">>, example => "path/to/log | not found"} #{
desc => <<"Path to log files">>,
example => "path/to/log | The log path is not yet set"
}
)}, )},
{role, {role,
mk( mk(
@ -286,7 +289,7 @@ format(_Node, Info = #{memory_total := Total, memory_used := Used}) ->
LogPath = LogPath =
case log_path() of case log_path() of
undefined -> undefined ->
<<"not found">>; <<"log.file_handler.default.enable is false,only log to console">>;
Path -> Path ->
filename:join(SysPath, Path) filename:join(SysPath, Path)
end, end,

2
build
View File

@ -92,7 +92,7 @@ make_docs() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \ erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \
"Dir = filename:join([apps, emqx_dashboard, priv, www, static]), \ "Dir = filename:join([apps, emqx_dashboard, priv, www, static]), \
I18nFile = filename:join([apps, emqx_dashboard, etc, 'i18n.conf.all']), \ I18nFile = filename:join([apps, emqx_dashboard, priv, 'i18n.conf']), \
ok = emqx_conf:dump_schema(Dir, $SCHEMA_MODULE, I18nFile), \ ok = emqx_conf:dump_schema(Dir, $SCHEMA_MODULE, I18nFile), \
halt(0)." halt(0)."
} }

View File

@ -49,7 +49,7 @@ VOLUME ["/opt/emqx/log", "/opt/emqx/data"]
# - 8883 port for MQTT(SSL) # - 8883 port for MQTT(SSL)
# - 11883 port for internal MQTT/TCP # - 11883 port for internal MQTT/TCP
# - 18083 for dashboard # - 18083 for dashboard
# - 4370 default Erlang distrbution port # - 4370 default Erlang distribution port
# - 5369 for backplain gen_rpc # - 5369 for backplain gen_rpc
EXPOSE 1883 8081 8083 8084 8883 11883 18083 4370 5369 EXPOSE 1883 8081 8083 8084 8883 11883 18083 4370 5369

View File

@ -19,8 +19,8 @@ doc_gen_test() ->
"test", "test",
"lib", "lib",
"emqx_dashboard", "emqx_dashboard",
"etc", "priv",
"i18n.conf.all" "i18n.conf"
]), ]),
_ = emqx_conf:dump_schema(Dir, emqx_enterprise_conf_schema, I18nFile), _ = emqx_conf:dump_schema(Dir, emqx_enterprise_conf_schema, I18nFile),
ok ok

View File

@ -322,16 +322,9 @@ defmodule EMQXUmbrella.MixProject do
Path.join(etc, "certs") Path.join(etc, "certs")
) )
# required by emqx_dashboard
Mix.Generator.copy_file(
"apps/emqx_dashboard/etc/i18n.conf.all",
Path.join(etc, "i18n.conf"),
force: overwrite?
)
Mix.Generator.copy_file( Mix.Generator.copy_file(
"apps/emqx_dashboard/etc/emqx.conf.en.example", "apps/emqx_dashboard/etc/emqx.conf.en.example",
Path.join(etc, "emqx-example-en.conf"), Path.join(etc, "emqx-example.conf"),
force: overwrite? force: overwrite?
) )

View File

@ -1,9 +1,9 @@
%% -*- mode: erlang -*- %% -*- mode: erlang -*-
%% This config file is the very basic config to compile emqx %% This config file is the very basic config to compile emqx
%% This allows emqx to be used as a dependency for other applications %% This allows emqx to be used as a dependency for other applications
%% such as emqx module/plugin develpments and tests. %% such as emqx module/plugin developments and tests.
%% With the help of EMQ's rebar3 fork, the config is extended %% With the help of EMQX's rebar3 fork, the config is extended
%% with rebar.config.erl module. Final result is written to %% with rebar.config.erl module. Final result is written to
%% rebar.config.rendered if environment DEBUG is set. %% rebar.config.rendered if environment DEBUG is set.

View File

@ -401,7 +401,7 @@ etc_overlay(ReleaseType, Edition) ->
[ [
{mkdir, "etc/"}, {mkdir, "etc/"},
{copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"}, {copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"},
{copy, "apps/emqx_dashboard/etc/emqx.conf.en.example", "etc/emqx-example-en.conf"} {copy, "apps/emqx_dashboard/etc/emqx.conf.en.example", "etc/emqx-example.conf"}
] ++ ] ++
lists:map( lists:map(
fun fun
@ -424,14 +424,12 @@ emqx_etc_overlay_common() ->
emqx_etc_overlay_per_edition(ce) -> emqx_etc_overlay_per_edition(ce) ->
[ [
{"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}, {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}
{"{{base_dir}}/lib/emqx_dashboard/etc/i18n.conf.all", "etc/i18n.conf"}
]; ];
emqx_etc_overlay_per_edition(ee) -> emqx_etc_overlay_per_edition(ee) ->
[ [
{"{{base_dir}}/lib/emqx_conf/etc/emqx_enterprise.conf.all", "etc/emqx_enterprise.conf"}, {"{{base_dir}}/lib/emqx_conf/etc/emqx_enterprise.conf.all", "etc/emqx_enterprise.conf"},
{"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}, {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}
{"{{base_dir}}/lib/emqx_dashboard/etc/i18n.conf.all", "etc/i18n.conf"}
]. ].
get_vsn(Profile) -> get_vsn(Profile) ->

View File

@ -8,7 +8,7 @@ main(_) ->
Conf = [merge(BaseConf, Cfgs), Conf = [merge(BaseConf, Cfgs),
io_lib:nl() io_lib:nl()
], ],
ok = file:write_file("apps/emqx_dashboard/etc/i18n.conf.all", Conf). ok = file:write_file("apps/emqx_dashboard/priv/i18n.conf", Conf).
merge(BaseConf, Cfgs) -> merge(BaseConf, Cfgs) ->
lists:foldl( lists:foldl(