From be7724b4e7762f628714a263ea15623fff648422 Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Tue, 14 Jun 2022 16:03:19 +0800 Subject: [PATCH] chore: add emqx-example-en.conf in release --- .gitignore | 1 + apps/emqx_conf/etc/emqx_conf.conf | 16 ++++++++-------- apps/emqx_conf/src/emqx_conf.erl | 11 ++++++++--- mix.exs | 17 ++++------------- rebar.config.erl | 3 +-- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 4c689ce9f..fd7731a8f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ deps *.o *.beam *.plt +*.example erl_crash.dump ebin !ebin/.placeholder diff --git a/apps/emqx_conf/etc/emqx_conf.conf b/apps/emqx_conf/etc/emqx_conf.conf index 7d608031d..42479ac94 100644 --- a/apps/emqx_conf/etc/emqx_conf.conf +++ b/apps/emqx_conf/etc/emqx_conf.conf @@ -9,20 +9,20 @@ ## All configuration details can be found in emqx.conf.example node { - name: "emqx@127.0.0.1" - cookie: emqxsecretcookie - data_dir: "{{ platform_data_dir }}" - etc_dir: "{{ platform_etc_dir }}" + name = "emqx@127.0.0.1" + cookie = emqxsecretcookie + data_dir = "{{ platform_data_dir }}" + etc_dir = "{{ platform_etc_dir }}" } log { file_handlers.default { - level: warning - file: "{{ platform_log_dir }}/emqx.log" + level = warning + file = "{{ platform_log_dir }}/emqx.log" } } cluster { - name: emqxcl - discovery_strategy: manual + name = emqxcl + discovery_strategy = manual } diff --git a/apps/emqx_conf/src/emqx_conf.erl b/apps/emqx_conf/src/emqx_conf.erl index 0e6b3ef0c..2f11d8e09 100644 --- a/apps/emqx_conf/src/emqx_conf.erl +++ b/apps/emqx_conf/src/emqx_conf.erl @@ -146,7 +146,7 @@ dump_schema(Dir, SchemaModule, I18nFile) -> fun(Lang) -> gen_config_md(Dir, I18nFile, SchemaModule, Lang), gen_hot_conf_schema_json(Dir, I18nFile, Lang), - gen_example_conf(Dir, I18nFile, SchemaModule, Lang) + gen_example_conf(filename:dirname(I18nFile), I18nFile, SchemaModule, Lang) end, [en, zh] ), @@ -177,7 +177,7 @@ gen_config_md(Dir, I18nFile, SchemaModule, Lang0) -> gen_example_conf(Dir, I18nFile, SchemaModule, Lang0) -> Lang = atom_to_list(Lang0), - SchemaMdFile = filename:join([Dir, "emqx-" ++ Lang ++ ".conf.example"]), + SchemaMdFile = filename:join([Dir, "emqx.conf." ++ Lang ++ ".example"]), io:format(user, "===< Generating: ~s~n", [SchemaMdFile]), ok = gen_example(SchemaMdFile, SchemaModule, I18nFile, Lang). @@ -204,7 +204,12 @@ gen_doc(File, SchemaModule, I18nFile, Lang) -> file:write_file(File, Doc). gen_example(File, SchemaModule, I18nFile, Lang) -> - Opts = #{title => <<"Title">>, body => <<"Body">>, desc_file => I18nFile, lang => Lang}, + Opts = #{ + title => <<"EMQX Configuration Example">>, + body => <<"">>, + desc_file => I18nFile, + lang => Lang + }, Example = hocon_schema_example:gen(SchemaModule, Opts), file:write_file(File, Example). diff --git a/mix.exs b/mix.exs index d5aa7f741..a2d6f6322 100644 --- a/mix.exs +++ b/mix.exs @@ -329,19 +329,10 @@ defmodule EMQXUmbrella.MixProject do force: overwrite? ) - # copy generated docs - Enum.each( - [ - "apps/emqx_dashboard/priv/www/static/emqx-en.conf.example", - "apps/emqx_dashboard/priv/www/static/emqx-zh.conf.example" - ], - fn file -> - Mix.Generator.copy_file( - file, - Path.join(etc, Path.basename(file)), - force: overwrite? - ) - end + Mix.Generator.copy_file( + "apps/emqx_dashboard/etc/emqx.conf.en.example", + Path.join(etc, "emqx-example-en.conf"), + force: overwrite? ) # this is required by the produced escript / nodetool diff --git a/rebar.config.erl b/rebar.config.erl index 0700a0bad..0349924d7 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -395,8 +395,7 @@ etc_overlay(ReleaseType, Edition) -> [ {mkdir, "etc/"}, {copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"}, - {copy, "apps/emqx_dashboard/priv/www/static/emqx-en.conf.example", "etc/"}, - {copy, "apps/emqx_dashboard/priv/www/static/emqx-zh.conf.example", "etc/"} + {copy, "apps/emqx_dashboard/etc/emqx.conf.en.example", "etc/emqx-example-en.conf"} ] ++ lists:map( fun