<commit_before>%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
%%%---------------------------------------------------------------------------
%%% @author <NAME>
%%% @doc
%%%   Builds the *.script and *.boot from the project rel file.
%%% @end
%%% @copyright (C) 2006-2011 Erlware
%%%---------------------------------------------------------------------------
-module(sin_task_release).

-behaviour(sin_task).

-include_lib("sinan/include/sinan.hrl").

%% API
-export([description/0, do_task/2, format_exception/1]).

-define(TASK, release).
-define(DEPS, [build]).

%%====================================================================
%% API
%%====================================================================

%% @doc describes this task to the system
-spec description() -> sin_task:task_description().
description() ->

    Desc = "This command creates all the artifacts needed to start the current
        project as an otp release. This creates the *.rel, *.boot and *.script
        files into the output area of the project. Those files maybe found at:
        <break> <break> <build-area>/realeases/<project-name>-<vsn> |
        <release-name>-<vsn> <break> <break> Check the erlang documentation for
        releases to understand what this means. <break> <break>"

        "The release task tasks a single configuration that looks like
         {types, [{AppName1, RelType},<break>
                  {AppName2, RelType}]}. <break>

        This configuration allows you to specify the type of application this is
        for the release. (Again review the release information for details).
        <break><break>
        You may substitute your own release file (completely replacing the
        generated file) by placing a file in releases/<release-name>.rel" ,

    #task{name = ?TASK,
          task_impl = ?MODULE,
          bare = false,
          deps = ?DEPS,
          example = "release",
          short_desc = "Creates an otp release for the system",
          desc = Desc,
          opts = []}.

%% @doc create an otp release
-spec do_task(sin_config:matcher(), sin_state:state()) -> sin_state:state().
do_task(Config, State0) ->
    ReleaseDir = sin_state:get_value(release_dir, State0),
    ReleaseName = sin_state:get_value(release, State0),
    Version = sin_state:get_value(release_vsn, State0),
    ReleaseInfo = generate_rel_file(Config, State0, ReleaseDir,
                                    ReleaseName, Version),
    State1 = sin_state:store(rel, ReleaseInfo, State0),
    copy_or_generate_sys_config_file(Config, ReleaseDir, Version),
    optionally_include_erts(State1, Config, filename:join([ReleaseDir,".."])),
    make_boot_script(State1, ReleaseInfo),
    State1.

%% @doc Format an exception thrown by this module
-spec format_exception(sin_exceptions:exception()) -><commit_msg>add include_erts documentation to the release task<commit_after>%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
%%%---------------------------------------------------------------------------
%%% @author <NAME>
%%% @doc
%%%   Builds the *.script and *.boot from the project rel file.
%%% @end
%%% @copyright (C) 2006-2011 Erlware
%%%---------------------------------------------------------------------------
-module(sin_task_release).

-behaviour(sin_task).

-include_lib("sinan/include/sinan.hrl").

%% API
-export([description/0, do_task/2, format_exception/1]).

-define(TASK, release).
-define(DEPS, [build]).

%%====================================================================
%% API
%%====================================================================

%% @doc describes this task to the system
-spec description() -> sin_task:task_description().
description() ->

    Desc = "This command creates all the artifacts needed to start the current
        project as an otp release. This creates the *.rel, *.boot and *.script
        files into the output area of the project. Those files maybe found at:
        <break> <break> <build-area>/realeases/<project-name>-<vsn> |
        <release-name>-<vsn> <break> <break> Check the erlang documentation for
        releases to understand what this means. <break> <break>"

        "The release task tasks a single configuration that looks like
         {types, [{AppName1, RelType},<break>
                  {AppName2, RelType}]}. <break>

        This configuration allows you to specify the type of application this is
        for the release. (Again review the release information for details).
        <break><break> You may substitute your own release file (completely
        replacing the generated file) by placing a file in
        releases/<release-name>.rel<break><break>

        At times you may wish to use the release directory under _build as a
        full release directory. This may require the inclusion of the erts
        executable. If you so desire you can have sinan include erts when it the
        release task is run so the _build/<release name> directory can be used
        as a full self contained release. <break><break>

        The option is:
        <break><break>
        {include_erts, true}.
        <break><break>
        Put this in your sinan.config to for erts inclusion in the build area." ,

    #task{name = ?TASK,
          task_impl = ?MODULE,
          bare = false,
          deps = ?DEPS,
          example = "release",
          short_desc = "Creates an otp release for the system",
          desc = Desc,
          opts = []}.

%% @doc create an otp release
-spec do_task(sin_config:matcher(), sin_state:state()) -> sin_state:state().
do_task(Config, State0) ->
    ReleaseDir = sin_state:get_value(release_dir, State0),
    ReleaseName = sin_state:get_value(release, State0),
    Version = sin_state:get_value(release_vsn, State0),
    ReleaseInfo = generate_rel_file(Config, State0, ReleaseDir,
                                    ReleaseName, Version),
    State1 = sin_state:store(rel, ReleaseInfo, State0),
    copy_or_generate_sys_config_file(Config, ReleaseDir, Version),
    optionally_include_erts(State1, Config, filename:join([ReleaseDir,".."])),
    make_boot_script(State1, ReleaseInfo),
    State1.

%% @doc Format an exception thrown by this module
-spec format_exception(sin_exceptions:exception()) ->
{'fraction_non_alphanumeric': 0.19697452229299364, 'fraction_numerical': 0.008598726114649681, 'mean_word_length': 2.716568047337278, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6056549', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1658, 'n_words': 546}