Просмотр исходного кода

Merge pull request #8360 from zhongwencool/example-name

chore: mv i18n.conf to emqx_dashboard/priv/
zhongwencool 3 лет назад
Родитель
Сommit
e0ab8e58cf

+ 1 - 1
.github/workflows/build_packages.yaml

@@ -189,7 +189,7 @@ jobs:
         # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
         ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
         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
             ready='yes'
             break

+ 1 - 0
.gitignore

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

+ 3 - 2
apps/emqx_conf/src/emqx_conf.erl

@@ -138,7 +138,7 @@ reset(Node, KeyPath, Opts) ->
 %% @doc Called from build script.
 -spec dump_schema(file:name_all()) -> ok.
 dump_schema(Dir) ->
-    I18nFile = emqx:etc_file("i18n.conf"),
+    I18nFile = emqx_dashboard:i18n_file(),
     dump_schema(Dir, emqx_conf_schema, I18nFile).
 
 dump_schema(Dir, SchemaModule, I18nFile) ->
@@ -146,7 +146,8 @@ dump_schema(Dir, SchemaModule, I18nFile) ->
         fun(Lang) ->
             gen_config_md(Dir, I18nFile, SchemaModule, 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,
         [en, zh]
     ),

+ 2 - 2
apps/emqx_conf/test/emqx_conf_schema_tests.erl

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

+ 2 - 1
apps/emqx_dashboard/src/emqx_dashboard.erl

@@ -30,6 +30,7 @@
     init_i18n/2,
     init_i18n/0,
     get_i18n/0,
+    i18n_file/0,
     clear_i18n/0
 ]).
 
@@ -271,7 +272,7 @@ return_unauthorized(Code, Message) ->
 
 i18n_file() ->
     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
     end.
 

+ 2 - 3
apps/emqx_dashboard/test/emqx_dashboard_api_test_helpers.erl

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

+ 5 - 2
apps/emqx_management/src/emqx_mgmt_api_nodes.erl

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

+ 1 - 1
build

@@ -92,7 +92,7 @@ make_docs() {
     # shellcheck disable=SC2086
     erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \
         "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), \
          halt(0)."
 }

+ 1 - 1
deploy/docker/Dockerfile

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

+ 2 - 2
lib-ee/emqx_enterprise_conf/test/emqx_enterprise_conf_schema_tests.erl

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

+ 1 - 8
mix.exs

@@ -322,16 +322,9 @@ defmodule EMQXUmbrella.MixProject do
       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(
       "apps/emqx_dashboard/etc/emqx.conf.en.example",
-      Path.join(etc, "emqx-example-en.conf"),
+      Path.join(etc, "emqx-example.conf"),
       force: overwrite?
     )
 

+ 2 - 2
rebar.config

@@ -1,9 +1,9 @@
 %% -*- mode: erlang -*-
 %% This config file is the very basic config to compile emqx
 %% 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
 %% rebar.config.rendered if environment DEBUG is set.
 

+ 3 - 5
rebar.config.erl

@@ -401,7 +401,7 @@ etc_overlay(ReleaseType, Edition) ->
     [
         {mkdir, "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(
             fun
@@ -424,14 +424,12 @@ emqx_etc_overlay_common() ->
 
 emqx_etc_overlay_per_edition(ce) ->
     [
-        {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"},
-        {"{{base_dir}}/lib/emqx_dashboard/etc/i18n.conf.all", "etc/i18n.conf"}
+        {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}
     ];
 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.conf.all", "etc/emqx.conf"},
-        {"{{base_dir}}/lib/emqx_dashboard/etc/i18n.conf.all", "etc/i18n.conf"}
+        {"{{base_dir}}/lib/emqx_conf/etc/emqx.conf.all", "etc/emqx.conf"}
     ].
 
 get_vsn(Profile) ->

+ 1 - 1
scripts/merge-i18n.escript

@@ -8,7 +8,7 @@ main(_) ->
     Conf = [merge(BaseConf, Cfgs),
             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) ->
     lists:foldl(