chore: modify the build to copy examples into the release

This commit is contained in:
firest 2023-06-20 12:09:01 +08:00
parent c4222557ba
commit bb2bf059ac
5 changed files with 6 additions and 25 deletions

View File

@ -5,7 +5,6 @@ This application provides configuration management capabilities for EMQX.
At compile time it reads all configuration schemas and generates the following files:
* `config-en.md`: documentation for all configuration options.
* `schema-en.json`: JSON description of all configuration schema options.
* `emqx.conf.example`: an example of a complete configuration file.
At runtime, it provides:
- Cluster configuration synchronization capability.

View File

@ -7,7 +7,7 @@
## To avoid confusion, please do not store the same configs in both files.
##
## See {{ emqx_configuration_doc }} for more details.
## Configuration full example can be found in emqx.conf.example
## Configuration full example can be found in etc/examples
node {
name = "emqx@127.0.0.1"

View File

@ -30,7 +30,6 @@
-export([reset/2, reset/3]).
-export([dump_schema/2]).
-export([schema_module/0]).
-export([gen_example_conf/2]).
-export([check_config/2]).
%% TODO: move to emqx_dashboard when we stop building api schema at build time
@ -161,8 +160,7 @@ dump_schema(Dir, SchemaModule) ->
ok = gen_schema_json(Dir, SchemaModule, Lang)
end,
["en", "zh"]
),
ok = gen_example_conf(Dir, SchemaModule).
).
%% for scripts/spellcheck.
gen_schema_json(Dir, SchemaModule, Lang) ->
@ -202,11 +200,6 @@ gen_config_md(Dir, SchemaModule, Lang) ->
io:format(user, "===< Generating: ~s~n", [SchemaMdFile]),
ok = gen_doc(SchemaMdFile, SchemaModule, Lang).
gen_example_conf(Dir, SchemaModule) ->
SchemaMdFile = filename:join([Dir, "emqx.conf.example"]),
io:format(user, "===< Generating: ~s~n", [SchemaMdFile]),
ok = gen_example(SchemaMdFile, SchemaModule).
%% @doc return the root schema module.
-spec schema_module() -> module().
schema_module() ->
@ -250,17 +243,6 @@ gen_doc(File, SchemaModule, Lang) ->
Doc = hocon_schema_md:gen(SchemaModule, Opts),
file:write_file(File, Doc).
gen_example(File, SchemaModule) ->
%% we do not generate description in example files
%% so there is no need for a desc_resolver
Opts = #{
title => <<"EMQX Configuration Example">>,
body => <<"">>,
include_importance_up_from => ?IMPORTANCE_MEDIUM
},
Example = hocon_schema_example:gen(SchemaModule, Opts),
file:write_file(File, Example).
gen_api_schema_json_iodata(SchemaMod, SchemaInfo) ->
emqx_dashboard_swagger:gen_api_schema_json_iodata(
SchemaMod,

View File

@ -541,9 +541,9 @@ defmodule EMQXUmbrella.MixProject do
profile = System.get_env("MIX_ENV")
Mix.Generator.copy_file(
"_build/docgen/#{profile}/emqx.conf.example",
Path.join(etc, "emqx.conf.example"),
File.cp_r!(
"examples",
Path.join(etc, "examples"),
force: overwrite?
)

View File

@ -524,7 +524,7 @@ etc_overlay(ReleaseType, _Edition) ->
[
{mkdir, "etc/"},
{copy, "{{base_dir}}/lib/emqx/etc/certs", "etc/"},
{copy, "_build/docgen/" ++ profile() ++ "/emqx.conf.example", "etc/emqx.conf.example"}
{copy, "examples", "etc/"}
] ++
lists:map(
fun