From d1a3f6d1d720d28c0a1d5c51f07f15d692881115 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Wed, 17 Mar 2021 09:49:39 +0700 Subject: [PATCH 01/52] Change the first app name in mix phx.new to lower key --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3231eb6e..176cec78 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Project repository template to set up all public Phoenix projects at [Nimble](ht ### Generate a new Phoenix project by using [mix phx.new](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html) ```bash -mix phx.new ... +mix phx.new helloElixirApp ``` ### Adding `nimble_phx_gen_template` into `mix.exs`: @@ -89,24 +89,24 @@ NimblePhxGenTemplate is supporting 3 variants: The Phoenix project could be either a Web project or API project. -- Web project is including HTML and Webpack configuration, which was generated by `mix phx.new AppName`. +- Web project is including HTML and Webpack configuration, which was generated by `mix phx.new appName`. -- API project is NOT including HTML and Webpack configuration, which was generated by `mix phx.new AppName --no-html --no-webpack`. +- API project is NOT including HTML and Webpack configuration, which was generated by `mix phx.new appName --no-html --no-webpack`. Aside from that, it could also be a Custom project, which contains the custom OTP app name or custom module name. -- `mix phx.new AppName --module=CustomModuleName` -- `mix phx.new AppName --app=custom_otp_app_name` -- `mix phx.new AppName --module=CustomModuleName --app=custom_otp_app_name` +- `mix phx.new appName --module=CustomModuleName` +- `mix phx.new appName --app=custom_otp_app_name` +- `mix phx.new appName --module=CustomModuleName --app=custom_otp_app_name` So it ends up with 6 project types: -- Standard Web project (`mix phx.new AppName`) -- Custom Web project (`mix phx.new AppName --module=CustomModuleName --app=custom_otp_app_name`) -- Standard API project (`mix phx.new AppName --no-html --no-webpack`) -- Custom API project (`mix phx.new AppName --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) -- Standard LiveView project (`mix phx.new AppName --live`) -- Custom LiveView project (`mix phx.new AppName --live --module=CustomModuleName --app=custom_otp_app_name`) +- Standard Web project (`mix phx.new appName`) +- Custom Web project (`mix phx.new appName --module=CustomModuleName --app=custom_otp_app_name`) +- Standard API project (`mix phx.new appName --no-html --no-webpack`) +- Custom API project (`mix phx.new appName --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) +- Standard LiveView project (`mix phx.new appName --live`) +- Custom LiveView project (`mix phx.new appName --live --module=CustomModuleName --app=custom_otp_app_name`) Putting it all together, it is 8 variant test cases. From 37b09f1572399b419c510ea1c3676f95109c9e14 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Wed, 24 Mar 2021 14:10:16 +0700 Subject: [PATCH 02/52] Update the naming convention of app name for the mix new task --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 176cec78..6d0c2340 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Project repository template to set up all public Phoenix projects at [Nimble](ht ### Generate a new Phoenix project by using [mix phx.new](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html) ```bash -mix phx.new helloElixirApp +mix phx.new hello_elixir ``` ### Adding `nimble_phx_gen_template` into `mix.exs`: @@ -89,24 +89,24 @@ NimblePhxGenTemplate is supporting 3 variants: The Phoenix project could be either a Web project or API project. -- Web project is including HTML and Webpack configuration, which was generated by `mix phx.new appName`. +- Web project is including HTML and Webpack configuration, which was generated by `mix phx.new your_app_name`. -- API project is NOT including HTML and Webpack configuration, which was generated by `mix phx.new appName --no-html --no-webpack`. +- API project is NOT including HTML and Webpack configuration, which was generated by `mix phx.new your_app_name --no-html --no-webpack`. Aside from that, it could also be a Custom project, which contains the custom OTP app name or custom module name. -- `mix phx.new appName --module=CustomModuleName` -- `mix phx.new appName --app=custom_otp_app_name` -- `mix phx.new appName --module=CustomModuleName --app=custom_otp_app_name` +- `mix phx.new your_app_name --module=CustomModuleName` +- `mix phx.new your_app_name --app=custom_otp_app_name` +- `mix phx.new your_app_name --module=CustomModuleName --app=custom_otp_app_name` So it ends up with 6 project types: -- Standard Web project (`mix phx.new appName`) -- Custom Web project (`mix phx.new appName --module=CustomModuleName --app=custom_otp_app_name`) -- Standard API project (`mix phx.new appName --no-html --no-webpack`) -- Custom API project (`mix phx.new appName --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) -- Standard LiveView project (`mix phx.new appName --live`) -- Custom LiveView project (`mix phx.new appName --live --module=CustomModuleName --app=custom_otp_app_name`) +- Standard Web project (`mix phx.new your_app_name`) +- Custom Web project (`mix phx.new your_app_name --module=CustomModuleName --app=custom_otp_app_name`) +- Standard API project (`mix phx.new your_app_name --no-html --no-webpack`) +- Custom API project (`mix phx.new your_app_name --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) +- Standard LiveView project (`mix phx.new your_app_name --live`) +- Custom LiveView project (`mix phx.new your_app_name --live --module=CustomModuleName --app=custom_otp_app_name`) Putting it all together, it is 8 variant test cases. From acb8d87a7a0e9ac8d043edde16bc7018f1463d11 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Thu, 25 Mar 2021 13:26:00 +0700 Subject: [PATCH 03/52] Resolve conflict --- README.md | 107 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 6d0c2340..d37a01fd 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,63 @@ -# NimblePhxGenTemplate +## Introduction -Project repository template to set up all public Phoenix projects at [Nimble](https://nimblehq.co/) +Phoenix template for projects at [Nimble](https://nimblehq.co/). + +## Prerequisites + +NimblePhxGenTemplate has been developed and actively tested with the below environment: + +- Elixir 1.11.3 +- Erlang/OTP 23.2.1 +- Phoenix 1.5.7 ## Installation -### Generate a new Phoenix project by using [mix phx.new](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html) +*Note:* NimblePhxGenTemplate only works on a _new_ Phoenix project, applying it to an existing Phoenix project might not work as expected. + +Step 1: Generate a new Phoenix project ```bash mix phx.new hello_elixir ``` -### Adding `nimble_phx_gen_template` into `mix.exs`: +Step 2: Add `nimble_phx_gen_template` dependency to `mix.exs`: ```elixir def deps do [ {:nimble_phx_gen_template, "~> 2.2.0", only: :dev, runtime: false}, - ... + # other dependencies ... ] end ``` -Then run `mix do deps.get, deps.compile` to install NimblePhxGenTemplate. +Step 3: Fetch and install dependencies -*Note:* NimblePhxGenTemplate is only working on a new Phoenix project, applying NimblePhxGenTemplate to an existing Phoenix project might not work as expected. +Run this command in the root of project directory to install NimblePhxGenTemplate. + +```bash +mix do deps.get, deps.compile +``` ## Usage ``` -mix nimble.phx.gen.template -v # Print the version -mix nimble.phx.gen.template --web # Apply the Web template -mix nimble.phx.gen.template --api # Apply the API template -mix nimble.phx.gen.template --live # Apply the LiveView template +mix nimble.phx.gen.template -v # Print the version +mix nimble.phx.gen.template --web # Apply the Web template +mix nimble.phx.gen.template --api # Apply the API template +mix nimble.phx.gen.template --live # Apply the LiveView template ``` -## Requirements -NimblePhxGenTemplate has been developed and actively tested with: -- Elixir 1.11.3 -- Erlang/OTP 23.2.1 -- Phoenix 1.5.7 +## Running tests -Running NimblePhxGenTemplate currently requires: -- Elixir 1.11.3 -- Erlang/OTP 23.2.1 -- Phoenix 1.5.7 +NimblePhxGenTemplate uses Github Action as the CI, the workflow files locate under [.github/workflows/](https://github.com/nimblehq/elixir-templates/tree/develop/.github/workflows) directory. -## Contributing +There are 2 types of test **Template test** and **Variant test** -We appreciate any contribution to NimblePhxGenTemplate. -### Test +### 1/ Template test -NimblePhxGenTemplate is using Github Action, the workflow files are located under `.github/workflows/` folder, it's including the Template test and Variant test workflow. - -#### 1/ Template test - -All files are located under `test/` folder. +All files are located under `test/` directory. ``` . @@ -75,9 +77,9 @@ All files are located under `test/` folder. │ │ │ │ │ └── web_addon_test.exs ``` -#### 2/ Variant test +### 2/ Variant test -##### 2.1/ Variant +#### 2.1/ Variant NimblePhxGenTemplate is supporting 3 variants: @@ -85,19 +87,33 @@ NimblePhxGenTemplate is supporting 3 variants: - Web - Live -##### 2.2/ Phoenix project +#### 2.2/ Phoenix project The Phoenix project could be either a Web project or API project. -- Web project is including HTML and Webpack configuration, which was generated by `mix phx.new your_app_name`. +- Web variant supports HTML and Webpack configuration. + +```bash +mix phx.new your_app_name +``` + +- API variant does NOT support HTML and Webpack configuration. + +```bash +mix phx.new your_app_name --no-html --no-webpack +``` -- API project is NOT including HTML and Webpack configuration, which was generated by `mix phx.new your_app_name --no-html --no-webpack`. +- Custom project variant allow us to modify the app name or module name. -Aside from that, it could also be a Custom project, which contains the custom OTP app name or custom module name. +```bash +# Use CustomModuleName +mix phx.new your_app_name --module=CustomModuleName -- `mix phx.new your_app_name --module=CustomModuleName` -- `mix phx.new your_app_name --app=custom_otp_app_name` -- `mix phx.new your_app_name --module=CustomModuleName --app=custom_otp_app_name` +# Use custom otp app name +mix phx.new AppName --app=custom_otp_app_name +# Use custom module and app name +mix phx.new AppName --module=CustomModuleName --app=custom_otp_app_name +``` So it ends up with 6 project types: @@ -108,7 +124,7 @@ So it ends up with 6 project types: - Standard LiveView project (`mix phx.new your_app_name --live`) - Custom LiveView project (`mix phx.new your_app_name --live --module=CustomModuleName --app=custom_otp_app_name`) -Putting it all together, it is 8 variant test cases. +Putting it all together, there are 8 variants test cases. - Applying the `API variant` to a `Standard Web project` - Applying the `API variant` to a `Custom Web project` @@ -123,16 +139,20 @@ Putting it all together, it is 8 variant test cases. Set the `HEX_API_KEY` as a Github secret (skip this step if it has been done). -The release process follows the [Git flow](https://nimblehq.co/compass/development/version-control/#releases-). +The release process follows the [Git flow](https://nimblehq.co/compass/development/version-control/release-management). Once a `release/` is created, to publish the new version to Hex.pm, the version number in the `mix.ex` file needs to be updated on the release branch before merging. -Once the release branch is merged into the `master` branch, Github Action will automatically publish the template to https://hex.pm/packages/nimble_phx_gen_template. +Once the release branch is merged into the `master` branch, Github Action automatically publishes the template to [https://hex.pm/packages/nimble_phx_gen_template](https://hex.pm/packages/nimble_phx_gen_template). + + +## Contributing + +Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/nimblehq/elixir-templates/issues). ## License -This project is Copyright (c) 2014-2021 Nimble. It is free software, -and may be redistributed under the terms specified in the [LICENSE] file. +This project is Copyright (c) 2014 and onwards. It is free software, and may be redistributed under the terms specified in the [LICENSE] file. [LICENSE]: /LICENSE @@ -146,4 +166,5 @@ We love open source and do our part in sharing our work with the community! See [our other projects][community] or [hire our team][hire] to help build your product. [community]: https://github.com/nimblehq -[hire]: https://nimblehq.co/ +[hire]: https://nimblehq.co + From 33cf2b05b5903ebeb4a48a47aa46f0d9a3ed4040 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Tue, 23 Mar 2021 15:30:46 +0700 Subject: [PATCH 04/52] Add run migrate step to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d37a01fd..0ec7d179 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ Run this command in the root of project directory to install NimblePhxGenTemplat mix do deps.get, deps.compile ``` +Step 4: Run migrate + +```bash +mix ecto.migrate +``` + ## Usage ``` From af144ce41f1c8acb82dac4e61e2a658c09c907a9 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Thu, 25 Mar 2021 13:50:23 +0700 Subject: [PATCH 05/52] Remove ecto migrate command --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 0ec7d179..d37a01fd 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,6 @@ Run this command in the root of project directory to install NimblePhxGenTemplat mix do deps.get, deps.compile ``` -Step 4: Run migrate - -```bash -mix ecto.migrate -``` - ## Usage ``` From 7ce2f1cbfe32aba366ecdb6038f4289b7083af44 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Thu, 25 Mar 2021 16:02:44 +0700 Subject: [PATCH 06/52] Rename the example project name --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d37a01fd..0e18c838 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ NimblePhxGenTemplate has been developed and actively tested with the below envir Step 1: Generate a new Phoenix project ```bash -mix phx.new hello_elixir +mix phx.new awesome_project ``` Step 2: Add `nimble_phx_gen_template` dependency to `mix.exs`: @@ -94,20 +94,20 @@ The Phoenix project could be either a Web project or API project. - Web variant supports HTML and Webpack configuration. ```bash -mix phx.new your_app_name +mix phx.new awesome_project ``` - API variant does NOT support HTML and Webpack configuration. ```bash -mix phx.new your_app_name --no-html --no-webpack +mix phx.new awesome_project --no-html --no-webpack ``` - Custom project variant allow us to modify the app name or module name. ```bash # Use CustomModuleName -mix phx.new your_app_name --module=CustomModuleName +mix phx.new awesome_project --module=CustomModuleName # Use custom otp app name mix phx.new AppName --app=custom_otp_app_name @@ -117,12 +117,12 @@ mix phx.new AppName --module=CustomModuleName --app=custom_otp_app_name So it ends up with 6 project types: -- Standard Web project (`mix phx.new your_app_name`) -- Custom Web project (`mix phx.new your_app_name --module=CustomModuleName --app=custom_otp_app_name`) -- Standard API project (`mix phx.new your_app_name --no-html --no-webpack`) -- Custom API project (`mix phx.new your_app_name --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) -- Standard LiveView project (`mix phx.new your_app_name --live`) -- Custom LiveView project (`mix phx.new your_app_name --live --module=CustomModuleName --app=custom_otp_app_name`) +- Standard Web project (`mix phx.new awesome_project`) +- Custom Web project (`mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name`) +- Standard API project (`mix phx.new awesome_project --no-html --no-webpack`) +- Custom API project (`mix phx.new awesome_project --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) +- Standard LiveView project (`mix phx.new awesome_project --live`) +- Custom LiveView project (`mix phx.new awesome_project --live --module=CustomModuleName --app=custom_otp_app_name`) Putting it all together, there are 8 variants test cases. From 23b51f09135d3fffb06a00755c4e666673bc0002 Mon Sep 17 00:00:00 2001 From: Thanh Huynh Date: Thu, 25 Mar 2021 16:15:43 +0700 Subject: [PATCH 07/52] Rename the example project name --- README.md | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 0e18c838..a50e65af 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ end Step 3: Fetch and install dependencies -Run this command in the root of project directory to install NimblePhxGenTemplate. +Run this command in the root of the project directory to install NimblePhxGenTemplate. ```bash mix do deps.get, deps.compile @@ -57,7 +57,7 @@ There are 2 types of test **Template test** and **Variant test** ### 1/ Template test -All files are located under `test/` directory. +All test files are located under `test/` directory. ``` . @@ -81,7 +81,7 @@ All files are located under `test/` directory. #### 2.1/ Variant -NimblePhxGenTemplate is supporting 3 variants: +NimblePhxGenTemplate supports 3 variants: - API - Web @@ -89,7 +89,7 @@ NimblePhxGenTemplate is supporting 3 variants: #### 2.2/ Phoenix project -The Phoenix project could be either a Web project or API project. +The Phoenix project could be either a Web or API project. - Web variant supports HTML and Webpack configuration. @@ -109,22 +109,28 @@ mix phx.new awesome_project --no-html --no-webpack # Use CustomModuleName mix phx.new awesome_project --module=CustomModuleName -# Use custom otp app name -mix phx.new AppName --app=custom_otp_app_name +# Use custom OTP app name +mix phx.new awesome_project --app=custom_otp_app_name + # Use custom module and app name -mix phx.new AppName --module=CustomModuleName --app=custom_otp_app_name +mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name ``` So it ends up with 6 project types: -- Standard Web project (`mix phx.new awesome_project`) -- Custom Web project (`mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name`) -- Standard API project (`mix phx.new awesome_project --no-html --no-webpack`) -- Custom API project (`mix phx.new awesome_project --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) -- Standard LiveView project (`mix phx.new awesome_project --live`) -- Custom LiveView project (`mix phx.new awesome_project --live --module=CustomModuleName --app=custom_otp_app_name`) +Web project +- Standard (`mix phx.new awesome_project`) +- Custom (`mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name`) + +API project +- Standard (`mix phx.new awesome_project --no-html --no-webpack`) +- Custom (`mix phx.new awesome_project --no-html --no-webpack --module=CustomModuleName --app=custom_otp_app_name`) + +LiveView project +- Standard (`mix phx.new awesome_project --live`) +- Custom (`mix phx.new awesome_project --live --module=CustomModuleName --app=custom_otp_app_name`) -Putting it all together, there are 8 variants test cases. +Putting it all together, there are 8 variants of test cases. - Applying the `API variant` to a `Standard Web project` - Applying the `API variant` to a `Custom Web project` @@ -148,7 +154,7 @@ Once the release branch is merged into the `master` branch, Github Action automa ## Contributing -Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/nimblehq/elixir-templates/issues). +Contributions, issues, and feature requests are welcome!
Feel free to check [issues page](https://github.com/nimblehq/elixir-templates/issues). ## License From ee2761cf74237cbcd713ca20a46509e138e62866 Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 8 Jan 2021 15:17:26 +0700 Subject: [PATCH 08/52] Refactor the default version component --- lib/nimble.phx.gen.template/project.ex | 29 ++++++++++---------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index 4616ded4..4256e06e 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -1,17 +1,8 @@ defmodule Nimble.Phx.Gen.Template.Project do - # Erlang versions: asdf list all erlang - # Elixir versions: asdf list all elixir - @default_versions %{ - erlang_asdf_version: "23.2.1", - elixir_asdf_version: "1.11.3-otp-23", - elixir_mix_version: "1.11.3" - } - - # Elixir image tags: https://hub.docker.com/r/hexpm/elixir/tags - @docker_base_images %{ - build: "hexpm/elixir:1.11.3-erlang-23.2.1-alpine-3.12.1", - app: "alpine:3.12.1" - } + @elixir_version "1.11.3" + @erlang_version "23.2.1" + + @alpine_version "3.12.1" defstruct otp_app: nil, base_module: nil, @@ -23,11 +14,13 @@ defmodule Nimble.Phx.Gen.Template.Project do api_project?: false, web_project?: false, live_project?: false, - erlang_asdf_version: @default_versions[:erlang_asdf_version], - elixir_asdf_version: @default_versions[:elixir_asdf_version], - elixir_mix_version: @default_versions[:elixir_mix_version], - docker_build_base_image: @docker_base_images[:build], - docker_app_base_image: @docker_base_images[:app] + elixir_mix_version: @elixir_version, + erlang_asdf_version: @erlang_version, + elixir_asdf_version: + "#{@elixir_version}-otp-#{@erlang_version |> String.split(".") |> List.first()}", + docker_build_base_image: + "hexpm/elixir:#{@elixir_version}-erlang-#{@erlang_version}-alpine-#{@alpine_version}", + docker_app_base_image: "alpine:#{@alpine_version}" def new(opts \\ %{}) do %__MODULE__{ From de40f0be6860ae1c0a1cb1d7a3c46031ddf2faf8 Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 8 Jan 2021 22:48:14 +0700 Subject: [PATCH 09/52] Refactor the github action version --- .../addons/elixir_version.ex | 22 +++---------------- lib/nimble.phx.gen.template/addons/github.ex | 18 ++++++++------- lib/nimble.phx.gen.template/addons/readme.ex | 8 +++---- lib/nimble.phx.gen.template/project.ex | 4 ++-- .../.github/workflows/test.yml.eex | 3 ++- .../.tool-versions.eex | 2 +- .../nimble.phx.gen.template/README.md.eex | 14 ++++++++++-- .../addons/elixir_version_test.exs | 13 ----------- 8 files changed, 34 insertions(+), 50 deletions(-) diff --git a/lib/nimble.phx.gen.template/addons/elixir_version.ex b/lib/nimble.phx.gen.template/addons/elixir_version.ex index 66d463df..f7966a82 100644 --- a/lib/nimble.phx.gen.template/addons/elixir_version.ex +++ b/lib/nimble.phx.gen.template/addons/elixir_version.ex @@ -3,36 +3,20 @@ defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersion do @impl true def do_apply(%Project{} = project, _opts) do - project - |> copy_files() - |> edit_files() + copy_files(project) end defp copy_files( %Project{ - erlang_asdf_version: erlang_asdf_version, + erlang_version: erlang_version, elixir_asdf_version: elixir_asdf_version } = project ) do Generator.copy_file([{:eex, ".tool-versions.eex", ".tool-versions"}], - erlang_asdf_version: erlang_asdf_version, + erlang_version: erlang_version, elixir_asdf_version: elixir_asdf_version ) project end - - defp edit_files(%Project{elixir_mix_version: elixir_mix_version} = project) do - Generator.replace_content( - "mix.exs", - """ - elixir: "~> 1.7", - """, - """ - elixir: "~> #{elixir_mix_version}", - """ - ) - - project - end end diff --git a/lib/nimble.phx.gen.template/addons/github.ex b/lib/nimble.phx.gen.template/addons/github.ex index ac2d0fad..9fb03e4d 100644 --- a/lib/nimble.phx.gen.template/addons/github.ex +++ b/lib/nimble.phx.gen.template/addons/github.ex @@ -1,11 +1,6 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do use Nimble.Phx.Gen.Template.Addon - @versions %{ - otp_version: "23.0.2", - elixir_version: "1.10.4" - } - @impl true def do_apply(%Project{} = project, opts) when is_map_key(opts, :github_template) do files = [ @@ -21,11 +16,18 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do end @impl true - def do_apply(%Project{web_project?: web_project?} = project, opts) + def do_apply( + %Project{ + web_project?: web_project?, + erlang_version: erlang_version, + elixir_version: elixir_version + } = project, + opts + ) when is_map_key(opts, :github_action) do binding = [ - otp_version: @versions.otp_version, - elixir_version: @versions.elixir_version, + erlang_version: erlang_version, + elixir_version: elixir_version, web_project?: web_project? ] diff --git a/lib/nimble.phx.gen.template/addons/readme.ex b/lib/nimble.phx.gen.template/addons/readme.ex index 834ff6b4..d445a808 100644 --- a/lib/nimble.phx.gen.template/addons/readme.ex +++ b/lib/nimble.phx.gen.template/addons/readme.ex @@ -17,13 +17,13 @@ defmodule Nimble.Phx.Gen.Template.Addons.Readme do defp copy_files( %Project{ api_project?: api_project?, - erlang_asdf_version: erlang_asdf_version, - elixir_mix_version: elixir_mix_version + erlang_version: erlang_version, + elixir_version: elixir_version } = project ) do Generator.copy_file([{:eex, "README.md.eex", "README.md"}], - erlang_version: erlang_asdf_version, - elixir_version: elixir_mix_version, + erlang_version: erlang_version, + elixir_version: elixir_version, web_project?: !api_project? ) diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index 4256e06e..0131ac41 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -14,8 +14,8 @@ defmodule Nimble.Phx.Gen.Template.Project do api_project?: false, web_project?: false, live_project?: false, - elixir_mix_version: @elixir_version, - erlang_asdf_version: @erlang_version, + elixir_version: @elixir_version, + erlang_version: @erlang_version, elixir_asdf_version: "#{@elixir_version}-otp-#{@erlang_version |> String.split(".") |> List.first()}", docker_build_base_image: diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex index 5ac67879..379e9744 100644 --- a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex +++ b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex @@ -1,8 +1,9 @@ name: "Tests" + on: pull_request env: - OTP_VERSION: <%= inspect otp_version %> + OTP_VERSION: <%= inspect erlang_version %> ELIXIR_VERSION: <%= inspect elixir_version %> jobs: diff --git a/priv/templates/nimble.phx.gen.template/.tool-versions.eex b/priv/templates/nimble.phx.gen.template/.tool-versions.eex index bbe8bcb4..8d20812c 100644 --- a/priv/templates/nimble.phx.gen.template/.tool-versions.eex +++ b/priv/templates/nimble.phx.gen.template/.tool-versions.eex @@ -1,3 +1,3 @@ # Configuration file for https://github.com/asdf-vm/asdf -erlang <%= erlang_asdf_version %> +erlang <%= erlang_version %> elixir <%= elixir_asdf_version %> diff --git a/priv/templates/nimble.phx.gen.template/README.md.eex b/priv/templates/nimble.phx.gen.template/README.md.eex index 65499ab8..c56769e6 100644 --- a/priv/templates/nimble.phx.gen.template/README.md.eex +++ b/priv/templates/nimble.phx.gen.template/README.md.eex @@ -8,11 +8,15 @@ ### Erlang & Elixir -* Erlang <%= erlang_version %> and Elixir <%= elixir_version %> +* Erlang <%= erlang_version %> + +* Elixir <%= elixir_version %> * Recommended version manager. - - [asdf](https://github.com/asdf-vm/asdf) Erlang & Elixir + - [asdf](https://github.com/asdf-vm/asdf) + - [asdf-erlang](https://github.com/asdf-vm/asdf-erlang) + - [asdf-elixir](https://github.com/asdf-vm/asdf-elixir) ### Development @@ -59,6 +63,12 @@ ```sh mix codebase ``` + +* Test coverage: + + ```sh + mix coverage + ``` ### Production diff --git a/test/nimble.phx.gen.template/addons/elixir_version_test.exs b/test/nimble.phx.gen.template/addons/elixir_version_test.exs index fb80b5ee..243eec5c 100644 --- a/test/nimble.phx.gen.template/addons/elixir_version_test.exs +++ b/test/nimble.phx.gen.template/addons/elixir_version_test.exs @@ -17,18 +17,5 @@ defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersionTest do end) end) end - - test "changes the minimum Elixir version", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project(test_project_path, fn -> - Addons.ElixirVersion.apply(project) - - assert_file("mix.exs", fn file -> - assert file =~ "elixir: \"~> 1.11.3\"," - end) - end) - end end end From e5ae4d77a0c9e22dfbd908013db9ff35f6d01854 Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 8 Jan 2021 23:03:27 +0700 Subject: [PATCH 10/52] Fix test, adding node_version --- .../addons/elixir_version.ex | 17 +++++++---------- lib/nimble.phx.gen.template/addons/github.ex | 4 +++- lib/nimble.phx.gen.template/project.ex | 2 ++ .../.github/workflows/test.yml.eex | 7 ++++++- .../test/support/factory.ex.eex | 2 +- .../addons/readme_test.exs | 10 ++++------ 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/nimble.phx.gen.template/addons/elixir_version.ex b/lib/nimble.phx.gen.template/addons/elixir_version.ex index f7966a82..373e0012 100644 --- a/lib/nimble.phx.gen.template/addons/elixir_version.ex +++ b/lib/nimble.phx.gen.template/addons/elixir_version.ex @@ -2,16 +2,13 @@ defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersion do use Nimble.Phx.Gen.Template.Addon @impl true - def do_apply(%Project{} = project, _opts) do - copy_files(project) - end - - defp copy_files( - %Project{ - erlang_version: erlang_version, - elixir_asdf_version: elixir_asdf_version - } = project - ) do + def do_apply( + %Project{ + erlang_version: erlang_version, + elixir_asdf_version: elixir_asdf_version + } = project, + _opts + ) do Generator.copy_file([{:eex, ".tool-versions.eex", ".tool-versions"}], erlang_version: erlang_version, elixir_asdf_version: elixir_asdf_version diff --git a/lib/nimble.phx.gen.template/addons/github.ex b/lib/nimble.phx.gen.template/addons/github.ex index 9fb03e4d..596d563c 100644 --- a/lib/nimble.phx.gen.template/addons/github.ex +++ b/lib/nimble.phx.gen.template/addons/github.ex @@ -20,7 +20,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do %Project{ web_project?: web_project?, erlang_version: erlang_version, - elixir_version: elixir_version + elixir_version: elixir_version, + node_version: node_version } = project, opts ) @@ -28,6 +29,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do binding = [ erlang_version: erlang_version, elixir_version: elixir_version, + node_version: node_version, web_project?: web_project? ] diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index 0131ac41..17aa489a 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -1,6 +1,7 @@ defmodule Nimble.Phx.Gen.Template.Project do @elixir_version "1.11.3" @erlang_version "23.2.1" + @node_version "14" @alpine_version "3.12.1" @@ -16,6 +17,7 @@ defmodule Nimble.Phx.Gen.Template.Project do live_project?: false, elixir_version: @elixir_version, erlang_version: @erlang_version, + node_version: @node_version, elixir_asdf_version: "#{@elixir_version}-otp-#{@erlang_version |> String.split(".") |> List.first()}", docker_build_base_image: diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex index 379e9744..0d593bae 100644 --- a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex +++ b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex @@ -5,6 +5,7 @@ on: pull_request env: OTP_VERSION: <%= inspect erlang_version %> ELIXIR_VERSION: <%= inspect elixir_version %> + NODE_VERSION: <%= inspect node_version %> jobs: test: @@ -31,7 +32,11 @@ jobs: with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} - + <%= if web_project? do %> + - uses: actions/setup-node@v2-beta + with: + node-version: ${{ env.NODE_VERSION }} + <% end %> - name: Cache Elixir build uses: actions/cache@v2 with: diff --git a/priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex b/priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex index 20ce910f..b516332e 100644 --- a/priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex +++ b/priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex @@ -2,5 +2,5 @@ defmodule <%= base_module %>.Factory do use ExMachina.Ecto, repo: <%= base_module %>.Repo # Define your factories in /test/factories and declare it here, - # eg: `use <%base_module %>.Accounts.UserFactory` + # eg: `use <%= base_module %>.Accounts.UserFactory` end diff --git a/test/nimble.phx.gen.template/addons/readme_test.exs b/test/nimble.phx.gen.template/addons/readme_test.exs index 8d778435..3d03ec50 100644 --- a/test/nimble.phx.gen.template/addons/readme_test.exs +++ b/test/nimble.phx.gen.template/addons/readme_test.exs @@ -10,9 +10,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do Addons.Readme.apply(project) assert_file("README.md", fn file -> - assert file =~ """ - Erlang 23.2.1 and Elixir 1.11.3 - """ + assert file =~ "Erlang 23.2.1" + assert file =~ "Elixir 1.11.3" assert file =~ """ * Install Node dependencies: @@ -37,9 +36,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do Addons.Readme.apply(project) assert_file("README.md", fn file -> - assert file =~ """ - Erlang 23.2.1 and Elixir 1.11.3 - """ + assert file =~ "Erlang 23.2.1" + assert file =~ "Elixir 1.11.3" refute file =~ """ * Install Node dependencies: From b721d4ba5d3f503b45a8e0e12775ca071d4ff4fa Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 25 Mar 2021 10:28:07 +0700 Subject: [PATCH 11/52] Increase setup-node to actions/setup-node@v2.1.5 --- .../workflows/test_live_variant_on_custom_liveview_project.yml | 2 +- .../test_live_variant_on_standard_liveview_project.yml | 2 +- .github/workflows/test_variant_on_custom_project.yml | 2 +- .github/workflows/test_variant_on_standard_project.yml | 2 +- .../nimble.phx.gen.template/.github/workflows/test.yml.eex | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_live_variant_on_custom_liveview_project.yml b/.github/workflows/test_live_variant_on_custom_liveview_project.yml index 21d24aad..d38f0f9a 100644 --- a/.github/workflows/test_live_variant_on_custom_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_custom_liveview_project.yml @@ -34,7 +34,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2.1.5 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/test_live_variant_on_standard_liveview_project.yml b/.github/workflows/test_live_variant_on_standard_liveview_project.yml index 9768b3f5..99e01055 100644 --- a/.github/workflows/test_live_variant_on_standard_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_standard_liveview_project.yml @@ -34,7 +34,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2.1.5 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/test_variant_on_custom_project.yml b/.github/workflows/test_variant_on_custom_project.yml index 338d4e61..fb5e9dfa 100644 --- a/.github/workflows/test_variant_on_custom_project.yml +++ b/.github/workflows/test_variant_on_custom_project.yml @@ -38,7 +38,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2.1.5 with: node-version: ${{ env.NODE_VERSION }} diff --git a/.github/workflows/test_variant_on_standard_project.yml b/.github/workflows/test_variant_on_standard_project.yml index b1c19807..0fcaf08b 100644 --- a/.github/workflows/test_variant_on_standard_project.yml +++ b/.github/workflows/test_variant_on_standard_project.yml @@ -38,7 +38,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2.1.5 with: node-version: ${{ env.NODE_VERSION }} diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex index 0d593bae..6c70f6af 100644 --- a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex +++ b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex @@ -33,7 +33,7 @@ jobs: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} <%= if web_project? do %> - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v2.1.5 with: node-version: ${{ env.NODE_VERSION }} <% end %> From 9bc7cf41b2c0a50307a2caeec91c36ad023e4057 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 25 Mar 2021 10:36:11 +0700 Subject: [PATCH 12/52] Group and order the configuration --- lib/nimble.phx.gen.template/project.ex | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index 17aa489a..f593e840 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -5,37 +5,39 @@ defmodule Nimble.Phx.Gen.Template.Project do @alpine_version "3.12.1" - defstruct otp_app: nil, - base_module: nil, + defstruct base_module: nil, base_path: nil, base_test_path: nil, + otp_app: nil, web_module: nil, web_path: nil, web_test_path: nil, - api_project?: false, - web_project?: false, - live_project?: false, + # Dependency Versions + docker_app_base_image: "alpine:#{@alpine_version}", + docker_build_base_image: + "hexpm/elixir:#{@elixir_version}-erlang-#{@erlang_version}-alpine-#{@alpine_version}", elixir_version: @elixir_version, - erlang_version: @erlang_version, - node_version: @node_version, elixir_asdf_version: "#{@elixir_version}-otp-#{@erlang_version |> String.split(".") |> List.first()}", - docker_build_base_image: - "hexpm/elixir:#{@elixir_version}-erlang-#{@erlang_version}-alpine-#{@alpine_version}", - docker_app_base_image: "alpine:#{@alpine_version}" + erlang_version: @erlang_version, + node_version: @node_version, + # Variants + api_project?: false, + live_project?: false, + web_project?: false def new(opts \\ %{}) do %__MODULE__{ - api_project?: api_project?(opts), - web_project?: web_project?(opts), - live_project?: live_project?(opts), - otp_app: otp_app(), base_module: base_module(), base_path: "lib/" <> Atom.to_string(otp_app()), base_test_path: "test/" <> Atom.to_string(otp_app()), + otp_app: otp_app(), web_module: base_module() <> "Web", web_path: "lib/" <> Atom.to_string(otp_app()) <> "_web", - web_test_path: "test/" <> Atom.to_string(otp_app()) <> "_web" + web_test_path: "test/" <> Atom.to_string(otp_app()) <> "_web", + api_project?: api_project?(opts), + web_project?: web_project?(opts), + live_project?: live_project?(opts) } end From 9ebd960fc80e4eefbab37d9e4bc8af46360a1f39 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 25 Mar 2021 10:45:02 +0700 Subject: [PATCH 13/52] Upgrade Elixir to 1.11.4 and Erlang to 23.3 --- .github/workflows/publish_to_hex_pm.yml | 4 ++-- .../workflows/test_api_variant_on_custom_api_project.yml | 4 ++-- .../test_api_variant_on_standard_api_project.yml | 4 ++-- .../test_live_variant_on_custom_liveview_project.yml | 4 ++-- .../test_live_variant_on_standard_liveview_project.yml | 4 ++-- .github/workflows/test_release_version.yml | 4 ++-- .github/workflows/test_template.yml | 4 ++-- .github/workflows/test_variant_on_custom_project.yml | 4 ++-- .github/workflows/test_variant_on_standard_project.yml | 4 ++-- .tool-versions | 4 ++-- README.md | 5 ++--- lib/nimble.phx.gen.template/project.ex | 6 +++--- mix.exs | 2 +- test/nimble.phx.gen.template/addons/docker_test.exs | 4 ++-- .../addons/elixir_version_test.exs | 4 ++-- test/nimble.phx.gen.template/addons/readme_test.exs | 8 ++++---- 16 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.github/workflows/publish_to_hex_pm.yml b/.github/workflows/publish_to_hex_pm.yml index d5bc21a2..73055c01 100644 --- a/.github/workflows/publish_to_hex_pm.yml +++ b/.github/workflows/publish_to_hex_pm.yml @@ -11,8 +11,8 @@ on: workflow_dispatch: env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 jobs: publish: diff --git a/.github/workflows/test_api_variant_on_custom_api_project.yml b/.github/workflows/test_api_variant_on_custom_api_project.yml index b17bec09..a8927ff0 100644 --- a/.github/workflows/test_api_variant_on_custom_api_project.yml +++ b/.github/workflows/test_api_variant_on_custom_api_project.yml @@ -3,8 +3,8 @@ name: "Test API variant on custom API project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 jobs: diff --git a/.github/workflows/test_api_variant_on_standard_api_project.yml b/.github/workflows/test_api_variant_on_standard_api_project.yml index 1b539f88..a4e14ef0 100644 --- a/.github/workflows/test_api_variant_on_standard_api_project.yml +++ b/.github/workflows/test_api_variant_on_standard_api_project.yml @@ -3,8 +3,8 @@ name: "Test API variant on standard API project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 jobs: diff --git a/.github/workflows/test_live_variant_on_custom_liveview_project.yml b/.github/workflows/test_live_variant_on_custom_liveview_project.yml index d38f0f9a..0ccbcf78 100644 --- a/.github/workflows/test_live_variant_on_custom_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_custom_liveview_project.yml @@ -3,8 +3,8 @@ name: "Test Live variant on custom LiveView project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 NODE_VERSION: 14 diff --git a/.github/workflows/test_live_variant_on_standard_liveview_project.yml b/.github/workflows/test_live_variant_on_standard_liveview_project.yml index 99e01055..78f8d2b5 100644 --- a/.github/workflows/test_live_variant_on_standard_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_standard_liveview_project.yml @@ -3,8 +3,8 @@ name: "Test Live variant on standard LiveView project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 NODE_VERSION: 14 diff --git a/.github/workflows/test_release_version.yml b/.github/workflows/test_release_version.yml index 00ec56da..b024c039 100644 --- a/.github/workflows/test_release_version.yml +++ b/.github/workflows/test_release_version.yml @@ -6,8 +6,8 @@ on: - 'release/**' env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 jobs: diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index 1763d628..f4b0bce1 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -3,8 +3,8 @@ name: "Test template" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 jobs: diff --git a/.github/workflows/test_variant_on_custom_project.yml b/.github/workflows/test_variant_on_custom_project.yml index fb5e9dfa..1b2ac024 100644 --- a/.github/workflows/test_variant_on_custom_project.yml +++ b/.github/workflows/test_variant_on_custom_project.yml @@ -3,8 +3,8 @@ name: "Test variant on custom Web project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 NODE_VERSION: 14 diff --git a/.github/workflows/test_variant_on_standard_project.yml b/.github/workflows/test_variant_on_standard_project.yml index 0fcaf08b..de10d314 100644 --- a/.github/workflows/test_variant_on_standard_project.yml +++ b/.github/workflows/test_variant_on_standard_project.yml @@ -3,8 +3,8 @@ name: "Test variant on standard Web project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 NODE_VERSION: 14 diff --git a/.tool-versions b/.tool-versions index 5cf945fb..7bc7f2ef 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 23.2.1 -elixir 1.11.3-otp-23 +erlang 23.3 +elixir 1.11.4-otp-23 diff --git a/README.md b/README.md index a50e65af..08f11f7f 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Phoenix template for projects at [Nimble](https://nimblehq.co/). NimblePhxGenTemplate has been developed and actively tested with the below environment: -- Elixir 1.11.3 -- Erlang/OTP 23.2.1 +- Elixir 1.11.4 +- Erlang/OTP 23.3 - Phoenix 1.5.7 ## Installation @@ -173,4 +173,3 @@ See [our other projects][community] or [hire our team][hire] to help build your [community]: https://github.com/nimblehq [hire]: https://nimblehq.co - diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index f593e840..d99587d1 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -1,9 +1,9 @@ defmodule Nimble.Phx.Gen.Template.Project do - @elixir_version "1.11.3" - @erlang_version "23.2.1" + @elixir_version "1.11.4" + @erlang_version "23.3" @node_version "14" - @alpine_version "3.12.1" + @alpine_version "3.13.2" defstruct base_module: nil, base_path: nil, diff --git a/mix.exs b/mix.exs index fded33ed..179d4f89 100644 --- a/mix.exs +++ b/mix.exs @@ -6,7 +6,7 @@ defmodule NimblePhxGenTemplate.MixProject do app: :nimble_phx_gen_template, version: "2.2.1", description: "Project repository template to set up all public Phoenix projects at Nimble", - elixir: "~> 1.11.3", + elixir: "~> 1.11.4", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, deps: deps(), diff --git a/test/nimble.phx.gen.template/addons/docker_test.exs b/test/nimble.phx.gen.template/addons/docker_test.exs index 815f3a99..b7f1f20b 100644 --- a/test/nimble.phx.gen.template/addons/docker_test.exs +++ b/test/nimble.phx.gen.template/addons/docker_test.exs @@ -57,8 +57,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.DockerTest do Addons.Docker.apply(project) assert_file("Dockerfile", fn file -> - assert file =~ "FROM hexpm/elixir:1.11.3-erlang-23.2.1-alpine-3.12.1 AS build" - assert file =~ "FROM alpine:3.12.1 AS app" + assert file =~ "FROM hexpm/elixir:1.11.4-erlang-23.3-alpine-3.13.2 AS build" + assert file =~ "FROM alpine:3.13.2 AS app" assert file =~ "RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error" diff --git a/test/nimble.phx.gen.template/addons/elixir_version_test.exs b/test/nimble.phx.gen.template/addons/elixir_version_test.exs index 243eec5c..41c56d6a 100644 --- a/test/nimble.phx.gen.template/addons/elixir_version_test.exs +++ b/test/nimble.phx.gen.template/addons/elixir_version_test.exs @@ -11,8 +11,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersionTest do assert_file(".tool-versions", fn file -> assert file =~ """ - erlang 23.2.1 - elixir 1.11.3-otp-23 + erlang 23.3 + elixir 1.11.4-otp-23 """ end) end) diff --git a/test/nimble.phx.gen.template/addons/readme_test.exs b/test/nimble.phx.gen.template/addons/readme_test.exs index 3d03ec50..e6bc7335 100644 --- a/test/nimble.phx.gen.template/addons/readme_test.exs +++ b/test/nimble.phx.gen.template/addons/readme_test.exs @@ -10,8 +10,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do Addons.Readme.apply(project) assert_file("README.md", fn file -> - assert file =~ "Erlang 23.2.1" - assert file =~ "Elixir 1.11.3" + assert file =~ "Erlang 23.3" + assert file =~ "Elixir 1.11.4" assert file =~ """ * Install Node dependencies: @@ -36,8 +36,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do Addons.Readme.apply(project) assert_file("README.md", fn file -> - assert file =~ "Erlang 23.2.1" - assert file =~ "Elixir 1.11.3" + assert file =~ "Erlang 23.3" + assert file =~ "Elixir 1.11.4" refute file =~ """ * Install Node dependencies: From 6fb4f08a35635486672ffdaf1e42b9cdb5e2de71 Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Tue, 6 Apr 2021 11:22:52 +0700 Subject: [PATCH 14/52] Add Github issue template --- .github/ISSUE_TEMPLATE/bug_template.md | 20 ++++++++++++++++ .github/ISSUE_TEMPLATE/feature_template.md | 14 +++++++++++ .github/ISSUE_TEMPLATE/rfc_template.md | 28 ++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_template.md create mode 100644 .github/ISSUE_TEMPLATE/feature_template.md create mode 100644 .github/ISSUE_TEMPLATE/rfc_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_template.md b/.github/ISSUE_TEMPLATE/bug_template.md new file mode 100644 index 00000000..adb94cc1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_template.md @@ -0,0 +1,20 @@ +--- +name: "Bug Report" +about: "You found something that is not working. Report it so that it can be fixed. 👷‍" +title: "Fix: " +labels: "type : bug" +--- + +## Issue + +Describe the issue you are facing. Show us the implementation: screenshots, gif, etc. + +## Expected + +Describe what should be the correct behaviour. + +## Steps to reproduce + +1. +2. +3. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_template.md b/.github/ISSUE_TEMPLATE/feature_template.md new file mode 100644 index 00000000..1176d56e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_template.md @@ -0,0 +1,14 @@ +--- +name: "Feature" +about: "Open a feature issue to add new functionalities." +title: "Add " +labels: "type : feature" +--- + +## Why + +Describe the big picture of the feature and why it's needed. + +## Who Benefits? + +Describe who will be the beneficiaries e.g. everyone, clients... \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/rfc_template.md b/.github/ISSUE_TEMPLATE/rfc_template.md new file mode 100644 index 00000000..bb67e96a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rfc_template.md @@ -0,0 +1,28 @@ +--- +name: "Request For Comments (RFC)" +about: "You have an idea on how to improve the template. Propose your idea so that the team can provide feedback." +title: "RFC: " +labels: "type : rfa" +--- + +## Issue + +Describe the issue from the template or generated project currently facing. Provide as much content as possible. + +## Solution + +Describe the solution you are prescribing for the issue. + +## Who Benefits? + +Describe who will be the beneficiaries e.g. everyone, clients... + +## What's Next? + +Provide an actionable list of things that must happen in order to implement the solution: + +- [ ] +- [ ] +- [ ] + +Using a poll is encouraged to gather feedback on the RFA 👉 Use this tool: https://gh-polls.com/ \ No newline at end of file From 93ae4f9d888a2c19d8f2b2aee81cfb4adc2dedfc Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 10:43:23 +0700 Subject: [PATCH 15/52] Mix variant --- ...test_api_variant_on_custom_api_project.yml | 2 +- ...st_api_variant_on_standard_api_project.yml | 2 +- ...ive_variant_on_custom_liveview_project.yml | 2 +- ...e_variant_on_standard_liveview_project.yml | 2 +- ...test_mix_variant_on_custom_mix_project.yml | 53 ++++++++++++++ ...on_custom_mix_project_with_supervision.yml | 53 ++++++++++++++ ...st_mix_variant_on_standard_mix_project.yml | 53 ++++++++++++++ ..._standard_mix_project_with_supervision.yml | 53 ++++++++++++++ ...=> test_variant_on_custom_web_project.yml} | 2 +- ... test_variant_on_standard_web_project.yml} | 2 +- Makefile | 24 ++++++- README.md | 59 ++++++++++++++-- action.yml | 10 +-- lib/mix/tasks/nimble.phx.gen.template.ex | 24 ++++++- lib/nimble.phx.gen.template/addons/credo.ex | 14 ++++ .../addons/ex_coveralls.ex | 19 ++++- lib/nimble.phx.gen.template/addons/github.ex | 10 ++- lib/nimble.phx.gen.template/addons/readme.ex | 14 +++- .../addons/test_env.ex | 44 ++++++++++++ .../addons/variants/mix/.keep | 0 lib/nimble.phx.gen.template/project.ex | 8 ++- lib/nimble.phx.gen.template/template.ex | 35 ++++++---- .../variants/mix/template.ex | 33 +++++++++ mix.exs | 2 +- .../.github/workflows/test.yml.mix.eex | 42 +++++++++++ .../nimble.phx.gen.template/README.md.mix.eex | 45 ++++++++++++ .../coveralls.json.mix.eex | 9 +++ .../addons/credo_test.exs | 48 +++++++++++++ ...veralls_test.exs => ex_coveralls_test.exs} | 67 ++++++++++++++++++ .../addons/github_test.exs | 65 ++++++++++++++++- .../addons/readme_test.exs | 52 +++++++++++++- .../addons/test_env_test.exs | 69 +++++++++++++++++++ .../addons/variants/live/.keep | 0 .../addons/variants/mix/.keep | 0 test/support/addon_case.ex | 28 ++++++-- 35 files changed, 890 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/test_mix_variant_on_custom_mix_project.yml create mode 100644 .github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml create mode 100644 .github/workflows/test_mix_variant_on_standard_mix_project.yml create mode 100644 .github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml rename .github/workflows/{test_variant_on_custom_project.yml => test_variant_on_custom_web_project.yml} (97%) rename .github/workflows/{test_variant_on_standard_project.yml => test_variant_on_standard_web_project.yml} (97%) create mode 100644 lib/nimble.phx.gen.template/addons/variants/mix/.keep create mode 100644 lib/nimble.phx.gen.template/variants/mix/template.ex create mode 100644 priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex create mode 100644 priv/templates/nimble.phx.gen.template/README.md.mix.eex create mode 100644 priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex rename test/nimble.phx.gen.template/addons/{excoveralls_test.exs => ex_coveralls_test.exs} (50%) create mode 100644 test/nimble.phx.gen.template/addons/variants/live/.keep create mode 100644 test/nimble.phx.gen.template/addons/variants/mix/.keep diff --git a/.github/workflows/test_api_variant_on_custom_api_project.yml b/.github/workflows/test_api_variant_on_custom_api_project.yml index a8927ff0..50293928 100644 --- a/.github/workflows/test_api_variant_on_custom_api_project.yml +++ b/.github/workflows/test_api_variant_on_custom_api_project.yml @@ -43,7 +43,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '--no-html --no-webpack --module=CustomModule --app=custom_app' variant: 'api' diff --git a/.github/workflows/test_api_variant_on_standard_api_project.yml b/.github/workflows/test_api_variant_on_standard_api_project.yml index a4e14ef0..47a15589 100644 --- a/.github/workflows/test_api_variant_on_standard_api_project.yml +++ b/.github/workflows/test_api_variant_on_standard_api_project.yml @@ -43,7 +43,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '--no-html --no-webpack' variant: 'api' diff --git a/.github/workflows/test_live_variant_on_custom_liveview_project.yml b/.github/workflows/test_live_variant_on_custom_liveview_project.yml index 0ccbcf78..f9304564 100644 --- a/.github/workflows/test_live_variant_on_custom_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_custom_liveview_project.yml @@ -63,7 +63,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '--live --module=CustomModule --app=custom_app' variant: 'live' diff --git a/.github/workflows/test_live_variant_on_standard_liveview_project.yml b/.github/workflows/test_live_variant_on_standard_liveview_project.yml index 78f8d2b5..cd1a7607 100644 --- a/.github/workflows/test_live_variant_on_standard_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_standard_liveview_project.yml @@ -63,7 +63,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '--live' variant: 'live' diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project.yml b/.github/workflows/test_mix_variant_on_custom_mix_project.yml new file mode 100644 index 00000000..2fb6d04d --- /dev/null +++ b/.github/workflows/test_mix_variant_on_custom_mix_project.yml @@ -0,0 +1,53 @@ +name: "Test Mix variant on custom Mix project" + +on: push + +env: + OTP_VERSION: 23.2.1 + ELIXIR_VERSION: 1.11.3 + +jobs: + unit_test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-elixir@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache Elixir build + uses: actions/cache@v2 + with: + path: | + _build + deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Elixir Dependencies + run: mix deps.get + + - name: Create Mix project + run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--module=CustomModule --app=custom_app" + + - name: Apply Mix template + run: make apply_mix_template PROJECT_DIRECTORY=sample_project + + - name: Install Elixir Dependencies + run: cd sample_project && mix deps.get + + - name: Run mix codebase + run: cd sample_project && mix codebase + env: + MIX_ENV: test + + - name: Run mix test + run: cd sample_project && mix do compile --warnings-as-errors, test + env: + MIX_ENV: test diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml new file mode 100644 index 00000000..336502d2 --- /dev/null +++ b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml @@ -0,0 +1,53 @@ +name: "Test Mix variant on custom Mix project with --sup option" + +on: push + +env: + OTP_VERSION: 23.2.1 + ELIXIR_VERSION: 1.11.3 + +jobs: + unit_test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-elixir@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache Elixir build + uses: actions/cache@v2 + with: + path: | + _build + deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Elixir Dependencies + run: mix deps.get + + - name: Create Mix project + run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--module=CustomModule --app=custom_app --sup" + + - name: Apply Mix template + run: make apply_mix_template PROJECT_DIRECTORY=sample_project + + - name: Install Elixir Dependencies + run: cd sample_project && mix deps.get + + - name: Run mix codebase + run: cd sample_project && mix codebase + env: + MIX_ENV: test + + - name: Run mix test + run: cd sample_project && mix do compile --warnings-as-errors, test + env: + MIX_ENV: test diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project.yml b/.github/workflows/test_mix_variant_on_standard_mix_project.yml new file mode 100644 index 00000000..0cf1ee0c --- /dev/null +++ b/.github/workflows/test_mix_variant_on_standard_mix_project.yml @@ -0,0 +1,53 @@ +name: "Test Mix variant on standard Mix project" + +on: push + +env: + OTP_VERSION: 23.2.1 + ELIXIR_VERSION: 1.11.3 + +jobs: + unit_test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-elixir@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache Elixir build + uses: actions/cache@v2 + with: + path: | + _build + deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Elixir Dependencies + run: mix deps.get + + - name: Create Mix project + run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="" + + - name: Apply Mix template + run: make apply_mix_template PROJECT_DIRECTORY=sample_project + + - name: Install Elixir Dependencies + run: cd sample_project && mix deps.get + + - name: Run mix codebase + run: cd sample_project && mix codebase + env: + MIX_ENV: test + + - name: Run mix test + run: cd sample_project && mix do compile --warnings-as-errors, test + env: + MIX_ENV: test diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml new file mode 100644 index 00000000..831716dd --- /dev/null +++ b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml @@ -0,0 +1,53 @@ +name: "Test Mix variant on standard Mix project with --sup option" + +on: push + +env: + OTP_VERSION: 23.2.1 + ELIXIR_VERSION: 1.11.3 + +jobs: + unit_test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-elixir@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache Elixir build + uses: actions/cache@v2 + with: + path: | + _build + deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Elixir Dependencies + run: mix deps.get + + - name: Create Mix project + run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--sup" + + - name: Apply Mix template + run: make apply_mix_template PROJECT_DIRECTORY=sample_project + + - name: Install Elixir Dependencies + run: cd sample_project && mix deps.get + + - name: Run mix codebase + run: cd sample_project && mix codebase + env: + MIX_ENV: test + + - name: Run mix test + run: cd sample_project && mix do compile --warnings-as-errors, test + env: + MIX_ENV: test diff --git a/.github/workflows/test_variant_on_custom_project.yml b/.github/workflows/test_variant_on_custom_web_project.yml similarity index 97% rename from .github/workflows/test_variant_on_custom_project.yml rename to .github/workflows/test_variant_on_custom_web_project.yml index 1b2ac024..08f9c388 100644 --- a/.github/workflows/test_variant_on_custom_project.yml +++ b/.github/workflows/test_variant_on_custom_web_project.yml @@ -67,7 +67,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '--module=CustomModule --app=custom_app' variant: ${{ matrix.variant }} diff --git a/.github/workflows/test_variant_on_standard_project.yml b/.github/workflows/test_variant_on_standard_web_project.yml similarity index 97% rename from .github/workflows/test_variant_on_standard_project.yml rename to .github/workflows/test_variant_on_standard_web_project.yml index de10d314..b3e01f94 100644 --- a/.github/workflows/test_variant_on_standard_project.yml +++ b/.github/workflows/test_variant_on_standard_web_project.yml @@ -67,7 +67,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.1 + - uses: nimblehq/elixir-templates@composite_1.2 with: new_project_options: '' variant: ${{ matrix.variant }} diff --git a/Makefile b/Makefile index 3b5edd18..8cbc651f 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ -.PHONY: install_phoenix create_project apply_template remove_nimble_phx_gen_template +.PHONY: install_phoenix create_phoenix_project apply_phoenix_template create_mix_project apply_mix_template remove_nimble_phx_gen_template # Y - in response to Are you sure you want to install "phx_new-${PHOENIX_VERSION}.ez"? install_phoenix: printf "Y\n" | mix archive.install hex phx_new ${PHOENIX_VERSION} -create_project: +create_phoenix_project: mix phx.new ${PROJECT_DIRECTORY} ${OPTIONS} + +create_mix_project: + mix new ${PROJECT_DIRECTORY} ${OPTIONS} # Y - in response to Will you host this project on Github? # Y - in response to Do you want to generate the .github/ISSUE_TEMPLATE and .github/PULL_REQUEST_TEMPLATE? @@ -19,10 +22,16 @@ api_addon_prompts = live_addon_prompts = +# Y - in response to Will you host this project on Github? +# Y - in response to Do you want to generate the .github/ISSUE_TEMPLATE and .github/PULL_REQUEST_TEMPLATE? +# Y - in response to Do you want to generate the Github Action workflow? +# Y - in response to Would you like to add the Mimic addon? +mix_addon_prompts = Y\nY\nY\nY\n + # Y - in response to Fetch and install dependencies? post_setup_addon_prompts = Y\n -apply_template: +apply_phoenix_template: cd ${PROJECT_DIRECTORY} && \ echo '{:nimble_phx_gen_template, path: "../", only: :dev, runtime: false},' > nimble_phx_gen_template.txt && \ sed -i -e '/{:phoenix, "~> /r nimble_phx_gen_template.txt' mix.exs && \ @@ -36,6 +45,15 @@ apply_template: elif [ $(VARIANT) = live ]; then \ printf "${common_addon_prompts}${web_addon_prompts}${live_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --live; \ fi; + +apply_mix_template: + cd ${PROJECT_DIRECTORY} && \ + echo '{:nimble_phx_gen_template, path: "../", only: :dev, runtime: false}' > nimble_phx_gen_template.txt && \ + sed -i -e '/# {:dep_from_git, /r nimble_phx_gen_template.txt' mix.exs && \ + rm nimble_phx_gen_template.txt && \ + mix deps.get && \ + mix format && \ + printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --mix; \ remove_nimble_phx_gen_template: cd ${PROJECT_DIRECTORY} && \ diff --git a/README.md b/README.md index 08f11f7f..6ad4a008 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,16 @@ NimblePhxGenTemplate has been developed and actively tested with the below envir ## Installation -*Note:* NimblePhxGenTemplate only works on a _new_ Phoenix project, applying it to an existing Phoenix project might not work as expected. +*Note:* NimblePhxGenTemplate only works on a _new_ Phoenix/Mix project, applying it to an existing Phoenix/Mix project might not work as expected. -Step 1: Generate a new Phoenix project +Step 1: Generate a new project ```bash +# New Phoenix project mix phx.new awesome_project + +# New Mix project +mix new awesome_project ``` Step 2: Add `nimble_phx_gen_template` dependency to `mix.exs`: @@ -41,11 +45,18 @@ mix do deps.get, deps.compile ## Usage -``` -mix nimble.phx.gen.template -v # Print the version +```bash +mix help nimble.phx.gen.template # Print help + +mix nimble.phx.gen.template -v # Print the version + +# Phoenix application mix nimble.phx.gen.template --web # Apply the Web template mix nimble.phx.gen.template --api # Apply the API template mix nimble.phx.gen.template --live # Apply the LiveView template + +# Non-Phoenix application +mix nimble.phx.gen.template --mix # Apply the Mix template ``` ## Running tests @@ -72,6 +83,12 @@ All test files are located under `test/` directory. │ │ │ │ └── api │ │ │ │ │ ├── ... │ │ │ │ │ └── api_addon_test.exs +│ │ │ │ └── live +│ │ │ │ │ ├── ... +│ │ │ │ │ └── live_addon_test.exs +│ │ │ │ └── mix +│ │ │ │ │ ├── ... +│ │ │ │ │ └── mix_addon_test.exs │ │ │ │ └── web │ │ │ │ │ ├── ... │ │ │ │ │ └── web_addon_test.exs @@ -81,11 +98,12 @@ All test files are located under `test/` directory. #### 2.1/ Variant -NimblePhxGenTemplate supports 3 variants: +NimblePhxGenTemplate supports 4 variants: - API -- Web - Live +- Web +- Mix #### 2.2/ Phoenix project @@ -97,6 +115,12 @@ The Phoenix project could be either a Web or API project. mix phx.new awesome_project ``` +- LiveView project is including HTML and Webpack configuration. + +```bash +mix phx.new awesome_project --live +``` + - API variant does NOT support HTML and Webpack configuration. ```bash @@ -141,6 +165,29 @@ Putting it all together, there are 8 variants of test cases. - Applying the `Live variant` to a `Standard LiveView project` - Applying the `Live variant` to a `Custom LiveView project` +##### 2.2/ Mix project + +The Mix project could be either a Standard project or a Custom project. + +- `mix new awesome_project` +- `mix new awesome_project --module=CustomModuleName` +- `mix new awesome_project --app=custom_otp_app_name` +- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name` + +Each project could be include the `supervision tree` or not. + +- `mix new awesome_project` +- `mix new awesome_project --sup` +- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name` +- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name --sup` + +Putting it all together, it will has 4 variant test cases. + +- Applying the `Mix variant` to a `Standard Mix project` +- Applying the `Mix variant` to a `Custom Mix project` +- Applying the `Mix variant` to a `Standard Mix project with the --sup option` +- Applying the `Mix variant` to a `Custom Mix project with the --sup option` + ### Release Set the `HEX_API_KEY` as a Github secret (skip this step if it has been done). diff --git a/action.yml b/action.yml index d07218c4..127d138a 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ inputs: runs: using: "composite" steps: - - name: Install Dependencies + - name: Install Elixir Dependencies run: mix deps.get shell: bash @@ -16,12 +16,12 @@ runs: shell: bash # Y - in response to Fetch and install dependencies? - - name: Create project - run: printf "Y\n" | make create_project PROJECT_DIRECTORY=sample_project OPTIONS="${{ inputs.new_project_options }}" + - name: Create Phoenix project + run: printf "Y\n" | make create_phoenix_project PROJECT_DIRECTORY=sample_project OPTIONS="${{ inputs.new_project_options }}" shell: bash - - name: Apply template - run: make apply_template PROJECT_DIRECTORY=sample_project VARIANT=${{ inputs.variant }} + - name: Apply Phoenix template + run: make apply_phoenix_template PROJECT_DIRECTORY=sample_project VARIANT=${{ inputs.variant }} shell: bash - name: Install Elixir Dependencies diff --git a/lib/mix/tasks/nimble.phx.gen.template.ex b/lib/mix/tasks/nimble.phx.gen.template.ex index a539e8fa..2f75c595 100644 --- a/lib/mix/tasks/nimble.phx.gen.template.ex +++ b/lib/mix/tasks/nimble.phx.gen.template.ex @@ -1,12 +1,32 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do - @shortdoc "Generates Nimble's Phoenix template" + @shortdoc "Apply Nimble's Elixir/Phoenix template" + @moduledoc """ + #{@shortdoc} + + - Hex package: https://hex.pm/packages/nimble_phx_gen_template + - Github: https://github.com/nimblehq/elixir-templates + + # Usage + + - mix nimble.phx.gen.template -v # Print the version + + ## Phoenix application + + - mix nimble.phx.gen.template --api # Apply the Phoenix API template + - mix nimble.phx.gen.template --live # Apply the Phoenix LiveView template + - mix nimble.phx.gen.template --web # Apply the Phoenix Web template + + ## Non-Phoenix application + + - mix nimble.phx.gen.template --mix # Apply the Mix template + """ use Mix.Task alias Nimble.Phx.Gen.Template.{Project, Template} @version Mix.Project.config()[:version] - @variants [api: :boolean, web: :boolean, live: :boolean] + @variants [api: :boolean, web: :boolean, live: :boolean, mix: :boolean] def run([args]) when args in ~w(-v --version) do Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") diff --git a/lib/nimble.phx.gen.template/addons/credo.ex b/lib/nimble.phx.gen.template/addons/credo.ex index 74e2139c..e6d94655 100644 --- a/lib/nimble.phx.gen.template/addons/credo.ex +++ b/lib/nimble.phx.gen.template/addons/credo.ex @@ -28,6 +28,20 @@ defmodule Nimble.Phx.Gen.Template.Addons.Credo do project end + defp edit_mix(%Project{mix_project?: true} = project) do + Generator.replace_content( + "mix.exs", + """ + codebase: ["deps.unlock --check-unused", "format --check-formatted"] + """, + """ + codebase: ["deps.unlock --check-unused", "format --check-formatted", "credo --strict"] + """ + ) + + project + end + defp edit_mix(project) do Generator.replace_content( "mix.exs", diff --git a/lib/nimble.phx.gen.template/addons/ex_coveralls.ex b/lib/nimble.phx.gen.template/addons/ex_coveralls.ex index 426e02c1..218a6db6 100644 --- a/lib/nimble.phx.gen.template/addons/ex_coveralls.ex +++ b/lib/nimble.phx.gen.template/addons/ex_coveralls.ex @@ -8,13 +8,28 @@ defmodule Nimble.Phx.Gen.Template.Addons.ExCoveralls do |> edit_files() end - defp copy_files(%Project{otp_app: otp_app} = project) do + defp copy_files(%Project{otp_app: otp_app, mix_project?: mix_project?} = project) do binding = [ otp_app: otp_app, minimum_coverage: 100 ] - Generator.copy_file([{:eex, "coveralls.json.eex", "coveralls.json"}], binding) + template_file_path = + if mix_project? do + "coveralls.json.mix.eex" + else + "coveralls.json.eex" + end + + Generator.copy_file([{:eex, template_file_path, "coveralls.json"}], binding) + + project + end + + defp edit_files(%Project{mix_project?: true} = project) do + project + |> inject_mix_dependency() + |> edit_mix() project end diff --git a/lib/nimble.phx.gen.template/addons/github.ex b/lib/nimble.phx.gen.template/addons/github.ex index 596d563c..c39b2e29 100644 --- a/lib/nimble.phx.gen.template/addons/github.ex +++ b/lib/nimble.phx.gen.template/addons/github.ex @@ -19,6 +19,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do def do_apply( %Project{ web_project?: web_project?, + mix_project?: mix_project?, erlang_version: erlang_version, elixir_version: elixir_version, node_version: node_version @@ -33,8 +34,15 @@ defmodule Nimble.Phx.Gen.Template.Addons.Github do web_project?: web_project? ] + template_file_path = + if mix_project? do + ".github/workflows/test.yml.mix.eex" + else + ".github/workflows/test.yml.eex" + end + files = [ - {:eex, ".github/workflows/test.yml.eex", ".github/workflows/test.yml"} + {:eex, template_file_path, ".github/workflows/test.yml"} ] Generator.copy_file(files, binding) diff --git a/lib/nimble.phx.gen.template/addons/readme.ex b/lib/nimble.phx.gen.template/addons/readme.ex index d445a808..2ac5e491 100644 --- a/lib/nimble.phx.gen.template/addons/readme.ex +++ b/lib/nimble.phx.gen.template/addons/readme.ex @@ -16,15 +16,23 @@ defmodule Nimble.Phx.Gen.Template.Addons.Readme do defp copy_files( %Project{ - api_project?: api_project?, + web_project?: web_project?, + mix_project?: mix_project?, erlang_version: erlang_version, elixir_version: elixir_version } = project ) do - Generator.copy_file([{:eex, "README.md.eex", "README.md"}], + template_file_path = + if mix_project? do + "README.md.mix.eex" + else + "README.md.eex" + end + + Generator.copy_file([{:eex, template_file_path, "README.md"}], erlang_version: erlang_version, elixir_version: elixir_version, - web_project?: !api_project? + web_project?: web_project? ) project diff --git a/lib/nimble.phx.gen.template/addons/test_env.ex b/lib/nimble.phx.gen.template/addons/test_env.ex index f4e66a5b..3673f462 100644 --- a/lib/nimble.phx.gen.template/addons/test_env.ex +++ b/lib/nimble.phx.gen.template/addons/test_env.ex @@ -1,6 +1,14 @@ defmodule Nimble.Phx.Gen.Template.Addons.TestEnv do use Nimble.Phx.Gen.Template.Addon + @impl true + def do_apply(%Project{mix_project?: true} = project, _opts) do + project + |> edit_mix() + |> edit_formatter_exs() + |> edit_test_helper() + end + @impl true def do_apply(%Project{} = project, _opts) do project @@ -11,6 +19,42 @@ defmodule Nimble.Phx.Gen.Template.Addons.TestEnv do |> edit_test_support_cases() end + defp edit_mix(%Project{mix_project?: true} = project) do + Generator.replace_content( + "mix.exs", + """ + deps: deps() + """, + """ + elixirc_paths: elixirc_paths(Mix.env()), + aliases: aliases(), + deps: deps() + """ + ) + + Generator.replace_content( + "mix.exs", + """ + # Run "mix help deps" to learn about dependencies. + """, + """ + defp aliases do + [ + codebase: ["deps.unlock --check-unused", "format --check-formatted"] + ] + end + + # Specifies which paths to compile per environment. + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] + + # Run "mix help deps" to learn about dependencies. + """ + ) + + project + end + defp edit_mix(project) do Generator.inject_content( "mix.exs", diff --git a/lib/nimble.phx.gen.template/addons/variants/mix/.keep b/lib/nimble.phx.gen.template/addons/variants/mix/.keep new file mode 100644 index 00000000..e69de29b diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index d99587d1..6c7c5ea7 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -24,7 +24,8 @@ defmodule Nimble.Phx.Gen.Template.Project do # Variants api_project?: false, live_project?: false, - web_project?: false + web_project?: false, + mix_project?: false def new(opts \\ %{}) do %__MODULE__{ @@ -37,7 +38,8 @@ defmodule Nimble.Phx.Gen.Template.Project do web_test_path: "test/" <> Atom.to_string(otp_app()) <> "_web", api_project?: api_project?(opts), web_project?: web_project?(opts), - live_project?: live_project?(opts) + live_project?: live_project?(opts), + mix_project?: mix_project?(opts), } end @@ -47,6 +49,8 @@ defmodule Nimble.Phx.Gen.Template.Project do defp live_project?(opts), do: opts[:live] === true + defp mix_project?(opts), do: opts[:mix] === true + defp otp_app(), do: Mix.Phoenix.otp_app() defp base_module(), do: Mix.Phoenix.base() diff --git a/lib/nimble.phx.gen.template/template.ex b/lib/nimble.phx.gen.template/template.ex index a30e58e8..c7de8c45 100644 --- a/lib/nimble.phx.gen.template/template.ex +++ b/lib/nimble.phx.gen.template/template.ex @@ -1,9 +1,16 @@ defmodule Nimble.Phx.Gen.Template.Template do alias Nimble.Phx.Gen.Template.Api.Template, as: ApiTemplate alias Nimble.Phx.Gen.Template.Live.Template, as: LiveTemplate + alias Nimble.Phx.Gen.Template.Mix.Template, as: MixTemplate alias Nimble.Phx.Gen.Template.Web.Template, as: WebTemplate alias Nimble.Phx.Gen.Template.{Addons, Project} + def apply(%Project{mix_project?: true} = project) do + MixTemplate.apply(project) + + if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") + end + def apply(%Project{} = project) do project |> common_setup() @@ -12,6 +19,20 @@ defmodule Nimble.Phx.Gen.Template.Template do if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") end + def host_on_github?(), do: Mix.shell().yes?("\nWill you host this project on Github?") + + def generate_github_template?(), + do: + Mix.shell().yes?( + "\nDo you want to generate the .github/ISSUE_TEMPLATE and .github/PULL_REQUEST_TEMPLATE?" + ) + + def generate_github_action?(), + do: Mix.shell().yes?("\nDo you want to generate the Github Action workflow?") + + def install_addon_prompt?(addon), + do: Mix.shell().yes?("\nWould you like to add the #{addon} addon?") + # Common setup for both API and Web projects defp common_setup(%Project{} = project) do project @@ -47,18 +68,4 @@ defmodule Nimble.Phx.Gen.Template.Template do defp variant_setup(%Project{web_project?: true, live_project?: true} = project), do: LiveTemplate.apply(project) - - defp host_on_github?(), do: Mix.shell().yes?("\nWill you host this project on Github?") - - defp generate_github_template?(), - do: - Mix.shell().yes?( - "\nDo you want to generate the .github/ISSUE_TEMPLATE and .github/PULL_REQUEST_TEMPLATE?" - ) - - defp generate_github_action?(), - do: Mix.shell().yes?("\nDo you want to generate the Github Action workflow?") - - defp install_addon_prompt?(addon), - do: Mix.shell().yes?("\nWould you like to add the #{addon} addon?") end diff --git a/lib/nimble.phx.gen.template/variants/mix/template.ex b/lib/nimble.phx.gen.template/variants/mix/template.ex new file mode 100644 index 00000000..4da34e54 --- /dev/null +++ b/lib/nimble.phx.gen.template/variants/mix/template.ex @@ -0,0 +1,33 @@ +defmodule Nimble.Phx.Gen.Template.Mix.Template do + import Nimble.Phx.Gen.Template.Template, + only: [ + host_on_github?: 0, + generate_github_template?: 0, + generate_github_action?: 0, + install_addon_prompt?: 1 + ] + + alias Nimble.Phx.Gen.Template.{Addons, Project} + + def apply(%Project{} = project) do + project + |> Addons.ElixirVersion.apply() + |> Addons.Readme.apply() + |> Addons.TestEnv.apply() + |> Addons.Credo.apply() + |> Addons.Dialyxir.apply() + |> Addons.ExCoveralls.apply() + + if host_on_github?() do + if generate_github_template?(), + do: Addons.Github.apply(project, %{github_template: true}) + + if generate_github_action?(), + do: Addons.Github.apply(project, %{github_action: true}) + end + + if install_addon_prompt?("Mimic"), do: Addons.Mimic.apply(project) + + project + end +end diff --git a/mix.exs b/mix.exs index 179d4f89..0c08ab77 100644 --- a/mix.exs +++ b/mix.exs @@ -1,4 +1,4 @@ -defmodule NimblePhxGenTemplate.MixProject do +defmodule Nimble.Phx.Gen.Template.MixProject do use Mix.Project def project do diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex new file mode 100644 index 00000000..2046b442 --- /dev/null +++ b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex @@ -0,0 +1,42 @@ +name: "Tests" + +on: pull_request + +env: + OTP_VERSION: <%= inspect erlang_version %> + ELIXIR_VERSION: <%= inspect elixir_version %> + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - uses: actions/setup-elixir@v1 + with: + otp-version: ${{ env.OTP_VERSION }} + elixir-version: ${{ env.ELIXIR_VERSION }} + + - name: Cache Elixir build + uses: actions/cache@v2 + with: + path: | + _build + deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Dependencies + run: mix deps.get + + - name: Run codebase check + run: mix codebase + + - name: Run Tests + run: mix do compile --warnings-as-errors, coverage + env: + MIX_ENV: test diff --git a/priv/templates/nimble.phx.gen.template/README.md.mix.eex b/priv/templates/nimble.phx.gen.template/README.md.mix.eex new file mode 100644 index 00000000..1cb7f107 --- /dev/null +++ b/priv/templates/nimble.phx.gen.template/README.md.mix.eex @@ -0,0 +1,45 @@ +[![Build Status](CI_BADGE_URL goes here)](REPO_URL goes here) + +## Introduction + +> *App introduction goes here ...* + +## Project Setup + +### Erlang & Elixir + +* Erlang <%= erlang_version %> + +* Elixir <%= elixir_version %> + +* Recommended version manager. + + - [asdf](https://github.com/asdf-vm/asdf) + - [asdf-erlang](https://github.com/asdf-vm/asdf-erlang) + - [asdf-elixir](https://github.com/asdf-vm/asdf-elixir) + +### Development + +* Install Elixir dependencies: + + ```sh + mix deps.get + ``` + +* Run all tests: + + ```sh + mix test + ``` + +* Run all lint: + + ```sh + mix codebase + ``` + +* Test coverage: + + ```sh + mix coverage + ``` diff --git a/priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex b/priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex new file mode 100644 index 00000000..ec9de978 --- /dev/null +++ b/priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex @@ -0,0 +1,9 @@ +{ + "skip_files": [ + "lib/<%= otp_app %>/application.ex", + "test/support" + ], + "coverage_options": { + "minimum_coverage": <%= minimum_coverage %> + } +} diff --git a/test/nimble.phx.gen.template/addons/credo_test.exs b/test/nimble.phx.gen.template/addons/credo_test.exs index 0bb1235f..1bf32085 100644 --- a/test/nimble.phx.gen.template/addons/credo_test.exs +++ b/test/nimble.phx.gen.template/addons/credo_test.exs @@ -47,4 +47,52 @@ defmodule Nimble.Phx.Gen.Template.Addons.CredoTest do end) end end + + describe "#apply/2 with mix_project" do + @describetag mix_project?: true + @describetag mock_latest_package_versions: [{:credo, "1.4"}] + @describetag required_addons: [:TestEnv] + + test "copies the .credo.exs", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Credo.apply(project) + + assert_file(".credo.exs") + end) + end + + test "injects credo to mix dependency", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Credo.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ """ + defp deps do + [ + {:credo, \"~> 1.4\", [only: [:dev, :test], runtime: false]}, + """ + end) + end) + end + + test "adds credo codebase alias", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.Credo.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ """ + defp aliases do + [ + codebase: [\"deps.unlock --check-unused\", \"format --check-formatted\", \"credo --strict\"] + """ + end) + end) + end + end end diff --git a/test/nimble.phx.gen.template/addons/excoveralls_test.exs b/test/nimble.phx.gen.template/addons/ex_coveralls_test.exs similarity index 50% rename from test/nimble.phx.gen.template/addons/excoveralls_test.exs rename to test/nimble.phx.gen.template/addons/ex_coveralls_test.exs index 8db52aa7..857ba3b6 100644 --- a/test/nimble.phx.gen.template/addons/excoveralls_test.exs +++ b/test/nimble.phx.gen.template/addons/ex_coveralls_test.exs @@ -65,4 +65,71 @@ defmodule Nimble.Phx.Gen.Template.Addons.ExCoverallsTest do end) end end + + describe "#apply/2 with mix_project" do + @describetag mix_project?: true + @describetag required_addons: [:TestEnv] + @describetag mock_latest_package_versions: [{:excoveralls, "0.12.2"}] + + test "copies the coveralls.json", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.ExCoveralls.apply(project) + + assert_file("coveralls.json") + end) + end + + test "injects excoveralls to mix dependency", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.ExCoveralls.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ """ + defp deps do + [ + {:excoveralls, \"~> 0.12.2\", [only: :test]}, + """ + end) + end) + end + + test "sets ExCoveralls tool", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.ExCoveralls.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ """ + deps: deps(), + test_coverage: [tool: ExCoveralls], + preferred_cli_env: [ + lint: :test, + coverage: :test, + coveralls: :test, + "coveralls.html": :test + ] + """ + end) + end) + end + + test "adds coverage alias", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.ExCoveralls.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ """ + defp aliases do + [ + coverage: [\"coveralls.html --raise\"], + """ + end) + end) + end + end end diff --git a/test/nimble.phx.gen.template/addons/github_test.exs b/test/nimble.phx.gen.template/addons/github_test.exs index b871101e..9e2cb39d 100644 --- a/test/nimble.phx.gen.template/addons/github_test.exs +++ b/test/nimble.phx.gen.template/addons/github_test.exs @@ -25,8 +25,34 @@ defmodule Nimble.Phx.Gen.Template.Addons.GithubTest do end end + describe "#apply/2 with mix_project and github_template option" do + @describetag mix_project?: true + + test "copies the .github/ISSUE_TEMPLATE.md", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Github.apply(project, %{github_template: true}) + + assert_file(".github/ISSUE_TEMPLATE.md") + end) + end + + test "copies the .github/PULL_REQUEST_TEMPLATE.md", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Github.apply(project, %{github_template: true}) + + assert_file(".github/PULL_REQUEST_TEMPLATE.md") + end) + end + end + describe "#apply/2 with api_project and github_action option" do - test "copies the .credo.exs", %{ + test "does NOT include the npm setting", %{ project: project, test_project_path: test_project_path } do @@ -46,7 +72,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.GithubTest do end describe "#apply/2 with web_project and github_action option" do - test "copies the .credo.exs", %{ + test "includes the npm setting", %{ project: project, test_project_path: test_project_path } do @@ -62,4 +88,39 @@ defmodule Nimble.Phx.Gen.Template.Addons.GithubTest do end) end end + + describe "#apply/2 with mix_project and github_action option" do + @describetag mix_project?: true + + test "does NOT include database setting", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Github.apply(project, %{github_action: true}) + + assert_file(".github/workflows/test.yml", fn file -> + refute file =~ "postgres" + refute file =~ "ecto.create" + refute file =~ "ecto.migrate" + end) + end) + end + + test "does NOT include the npm setting", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.Github.apply(project, %{github_action: true}) + + assert_file(".github/workflows/test.yml", fn file -> + refute file =~ "assets/node_modules" + refute file =~ "npm --prefix assets install" + refute file =~ "npm run --prefix assets build:dev" + refute file =~ "wallaby_screenshots" + end) + end) + end + end end diff --git a/test/nimble.phx.gen.template/addons/readme_test.exs b/test/nimble.phx.gen.template/addons/readme_test.exs index e6bc7335..44290983 100644 --- a/test/nimble.phx.gen.template/addons/readme_test.exs +++ b/test/nimble.phx.gen.template/addons/readme_test.exs @@ -20,6 +20,14 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do npm install --prefix assets ``` """ + + assert file =~ """ + * Start the Phoenix app + + ```sh + iex -S mix phx.server + ``` + """ end) end) end @@ -30,8 +38,42 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do project: project, test_project_path: test_project_path } do - project = %{project | api_project?: true} + project = %{project | api_project?: true, web_project?: false} + + in_test_project(test_project_path, fn -> + Addons.Readme.apply(project) + + assert_file("README.md", fn file -> + assert file =~ "Erlang 23.2.1" + assert file =~ "Elixir 1.11.3" + + refute file =~ """ + * Install Node dependencies: + + ```sh + npm install --prefix assets + ``` + """ + + assert file =~ """ + * Start the Phoenix app + + ```sh + iex -S mix phx.server + ``` + """ + end) + end) + end + end + + describe "#apply/2 with mix_project" do + @describetag mix_project?: true + test "copies the README.md", %{ + project: project, + test_project_path: test_project_path + } do in_test_project(test_project_path, fn -> Addons.Readme.apply(project) @@ -46,6 +88,14 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do npm install --prefix assets ``` """ + + refute file =~ """ + * Start the Phoenix app + + ```sh + iex -S mix phx.server + ``` + """ end) end) end diff --git a/test/nimble.phx.gen.template/addons/test_env_test.exs b/test/nimble.phx.gen.template/addons/test_env_test.exs index 9d3a5d6c..b58fb409 100644 --- a/test/nimble.phx.gen.template/addons/test_env_test.exs +++ b/test/nimble.phx.gen.template/addons/test_env_test.exs @@ -74,4 +74,73 @@ defmodule Nimble.Phx.Gen.Template.Addons.TestEnvTest do end) end end + + describe "#apply/2 with mix_project" do + @describetag mix_project?: true + + test "adds codebase alias", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.TestEnv.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ "aliases: aliases()" + + assert file =~ """ + defp aliases do + [ + codebase: [\"deps.unlock --check-unused\", \"format --check-formatted\"] + ] + end + """ + end) + end) + end + + test "adds elixirc_paths", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.TestEnv.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ "elixirc_paths: elixirc_paths(Mix.env())," + + assert file =~ """ + # Specifies which paths to compile per environment. + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] + """ + end) + end) + end + + test "adds `Code.put_compiler_option(:warnings_as_errors, true)` into `test/test_helper.exs`", + %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.TestEnv.apply(project) + + assert_file("test/test_helper.exs", fn file -> + assert file =~ """ + Code.put_compiler_option(:warnings_as_errors, true) + + ExUnit.start() + """ + end) + end) + end + + test "sets line_length to 100 in .formatter.exs", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.TestEnv.apply(project) + + assert_file(".formatter.exs", fn file -> + assert file =~ """ + [ + line_length: 100, + """ + end) + end) + end + end end diff --git a/test/nimble.phx.gen.template/addons/variants/live/.keep b/test/nimble.phx.gen.template/addons/variants/live/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/nimble.phx.gen.template/addons/variants/mix/.keep b/test/nimble.phx.gen.template/addons/variants/mix/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/support/addon_case.ex b/test/support/addon_case.ex index c8d015ad..a936d281 100644 --- a/test/support/addon_case.ex +++ b/test/support/addon_case.ex @@ -30,14 +30,21 @@ defmodule Nimble.Phx.Gen.Template.AddonCase do end setup context do - # Set Web Project as default, switch to either API or Live Project in each test case - # eg: project = %{project | api_project?: true, web_project?: false} - project = Project.new(web: true) - parent_test_project_path = Path.join(tmp_path(), parent_test_project_path()) test_project_path = Path.join(parent_test_project_path, "/nimble_phx_gen_template") - create_test_project(test_project_path) + project = + if context[:mix_project?] == true do + create_mix_test_project(test_project_path) + + Project.new(mix: true) + else + create_phoenix_test_project(test_project_path) + + # Set Web Project as default, switch to either API or Live Project in each test case + # eg: project = %{project | api_project?: true, web_project?: false} + Project.new(web: true) + end on_exit(fn -> File.rm_rf!(parent_test_project_path) @@ -59,10 +66,17 @@ defmodule Nimble.Phx.Gen.Template.AddonCase do defp mock_latest_package_version({_package, version}), do: expect(Package, :get_latest_version, fn _package -> version end) - defp create_test_project(test_project_path) do + defp create_phoenix_test_project(test_project_path) do + # N - in response to Fetch and install dependencies? + Mix.shell().cmd( + "printf \"N\n\" | make create_phoenix_project PROJECT_DIRECTORY=#{test_project_path} > /dev/null" + ) + end + + defp create_mix_test_project(test_project_path) do # N - in response to Fetch and install dependencies? Mix.shell().cmd( - "printf \"N\n\" | make create_project PROJECT_DIRECTORY=#{test_project_path} > /dev/null" + "printf \"N\n\" | make create_mix_project PROJECT_DIRECTORY=#{test_project_path} > /dev/null" ) end From 7350cf2d160dfc84f8cf07b651accf2ee15a307e Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:37:13 +0700 Subject: [PATCH 16/52] Separate the @shortdoc and @moduledoc --- lib/mix/tasks/nimble.phx.gen.template.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/mix/tasks/nimble.phx.gen.template.ex b/lib/mix/tasks/nimble.phx.gen.template.ex index 2f75c595..c7568ced 100644 --- a/lib/mix/tasks/nimble.phx.gen.template.ex +++ b/lib/mix/tasks/nimble.phx.gen.template.ex @@ -1,5 +1,6 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do @shortdoc "Apply Nimble's Elixir/Phoenix template" + @moduledoc """ #{@shortdoc} From e64501c62fc1cdd59357964301c643498d466b8e Mon Sep 17 00:00:00 2001 From: An Duong Date: Wed, 7 Apr 2021 17:11:47 +0700 Subject: [PATCH 17/52] Fix github action --- .../workflows/test_mix_variant_on_custom_mix_project.yml | 6 +++--- ...t_mix_variant_on_custom_mix_project_with_supervision.yml | 6 +++--- .../workflows/test_mix_variant_on_standard_mix_project.yml | 6 +++--- ...mix_variant_on_standard_mix_project_with_supervision.yml | 6 +++--- .../.github/workflows/test.yml.mix.eex | 2 +- test/nimble.phx.gen.template/addons/readme_test.exs | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project.yml b/.github/workflows/test_mix_variant_on_custom_mix_project.yml index 2fb6d04d..97fd5e87 100644 --- a/.github/workflows/test_mix_variant_on_custom_mix_project.yml +++ b/.github/workflows/test_mix_variant_on_custom_mix_project.yml @@ -3,8 +3,8 @@ name: "Test Mix variant on custom Mix project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 jobs: unit_test: @@ -15,7 +15,7 @@ jobs: with: ref: ${{ github.head_ref }} - - uses: actions/setup-elixir@v1 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml index 336502d2..51f44a96 100644 --- a/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml +++ b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml @@ -3,8 +3,8 @@ name: "Test Mix variant on custom Mix project with --sup option" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 jobs: unit_test: @@ -15,7 +15,7 @@ jobs: with: ref: ${{ github.head_ref }} - - uses: actions/setup-elixir@v1 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project.yml b/.github/workflows/test_mix_variant_on_standard_mix_project.yml index 0cf1ee0c..27530d10 100644 --- a/.github/workflows/test_mix_variant_on_standard_mix_project.yml +++ b/.github/workflows/test_mix_variant_on_standard_mix_project.yml @@ -3,8 +3,8 @@ name: "Test Mix variant on standard Mix project" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 jobs: unit_test: @@ -15,7 +15,7 @@ jobs: with: ref: ${{ github.head_ref }} - - uses: actions/setup-elixir@v1 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml index 831716dd..f56a7437 100644 --- a/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml +++ b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml @@ -3,8 +3,8 @@ name: "Test Mix variant on standard Mix project with --sup option" on: push env: - OTP_VERSION: 23.2.1 - ELIXIR_VERSION: 1.11.3 + OTP_VERSION: 23.3 + ELIXIR_VERSION: 1.11.4 jobs: unit_test: @@ -15,7 +15,7 @@ jobs: with: ref: ${{ github.head_ref }} - - uses: actions/setup-elixir@v1 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex index 2046b442..2aee8406 100644 --- a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex +++ b/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex @@ -15,7 +15,7 @@ jobs: with: ref: ${{ github.head_ref }} - - uses: actions/setup-elixir@v1 + - uses: erlef/setup-elixir@v1 with: otp-version: ${{ env.OTP_VERSION }} elixir-version: ${{ env.ELIXIR_VERSION }} diff --git a/test/nimble.phx.gen.template/addons/readme_test.exs b/test/nimble.phx.gen.template/addons/readme_test.exs index 44290983..24059914 100644 --- a/test/nimble.phx.gen.template/addons/readme_test.exs +++ b/test/nimble.phx.gen.template/addons/readme_test.exs @@ -44,8 +44,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do Addons.Readme.apply(project) assert_file("README.md", fn file -> - assert file =~ "Erlang 23.2.1" - assert file =~ "Elixir 1.11.3" + assert file =~ "Erlang 23.3" + assert file =~ "Elixir 1.11.4" refute file =~ """ * Install Node dependencies: From e8db56a304430b8eb9cf542176c5e2e06e55b963 Mon Sep 17 00:00:00 2001 From: An Duong Date: Wed, 7 Apr 2021 17:16:11 +0700 Subject: [PATCH 18/52] Fix format --- lib/nimble.phx.gen.template/project.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble.phx.gen.template/project.ex index 6c7c5ea7..5ab0369f 100644 --- a/lib/nimble.phx.gen.template/project.ex +++ b/lib/nimble.phx.gen.template/project.ex @@ -39,7 +39,7 @@ defmodule Nimble.Phx.Gen.Template.Project do api_project?: api_project?(opts), web_project?: web_project?(opts), live_project?: live_project?(opts), - mix_project?: mix_project?(opts), + mix_project?: mix_project?(opts) } end From bf9f7f0905f6bfcb4ffe5b8c7fd06eb45849ea85 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 10:30:55 +0700 Subject: [PATCH 19/52] Minor refactor the doc --- lib/mix/tasks/nimble.phx.gen.template.ex | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/mix/tasks/nimble.phx.gen.template.ex b/lib/mix/tasks/nimble.phx.gen.template.ex index c7568ced..2013fc58 100644 --- a/lib/mix/tasks/nimble.phx.gen.template.ex +++ b/lib/mix/tasks/nimble.phx.gen.template.ex @@ -11,13 +11,13 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do - mix nimble.phx.gen.template -v # Print the version - ## Phoenix application + ### Phoenix application - mix nimble.phx.gen.template --api # Apply the Phoenix API template - mix nimble.phx.gen.template --live # Apply the Phoenix LiveView template - mix nimble.phx.gen.template --web # Apply the Phoenix Web template - ## Non-Phoenix application + ### Non-Phoenix application - mix nimble.phx.gen.template --mix # Apply the Mix template """ @@ -29,9 +29,7 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do @version Mix.Project.config()[:version] @variants [api: :boolean, web: :boolean, live: :boolean, mix: :boolean] - def run([args]) when args in ~w(-v --version) do - Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") - end + def run([args]) when args in ~w(-v --version), do: Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") def run(args) do if Mix.Project.umbrella?() do From bf2870a6d19b6c1d6cfe17da4072febfc9e06f1f Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 10:34:35 +0700 Subject: [PATCH 20/52] Mix format --- lib/mix/tasks/nimble.phx.gen.template.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mix/tasks/nimble.phx.gen.template.ex b/lib/mix/tasks/nimble.phx.gen.template.ex index 2013fc58..be8f8be7 100644 --- a/lib/mix/tasks/nimble.phx.gen.template.ex +++ b/lib/mix/tasks/nimble.phx.gen.template.ex @@ -29,7 +29,8 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do @version Mix.Project.config()[:version] @variants [api: :boolean, web: :boolean, live: :boolean, mix: :boolean] - def run([args]) when args in ~w(-v --version), do: Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") + def run([args]) when args in ~w(-v --version), + do: Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") def run(args) do if Mix.Project.umbrella?() do From f0d84370e95222b08c8ddc46e4188e06db2d5e4f Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:01:12 +0700 Subject: [PATCH 21/52] Rename mix task --- ...hx.gen.template.ex => nimble.template.gen.ex} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename lib/mix/tasks/{nimble.phx.gen.template.ex => nimble.template.gen.ex} (67%) diff --git a/lib/mix/tasks/nimble.phx.gen.template.ex b/lib/mix/tasks/nimble.template.gen.ex similarity index 67% rename from lib/mix/tasks/nimble.phx.gen.template.ex rename to lib/mix/tasks/nimble.template.gen.ex index be8f8be7..f9a2c701 100644 --- a/lib/mix/tasks/nimble.phx.gen.template.ex +++ b/lib/mix/tasks/nimble.template.gen.ex @@ -1,25 +1,25 @@ -defmodule Mix.Tasks.Nimble.Phx.Gen.Template do +defmodule Mix.Tasks.Nimble.Template.Gen do @shortdoc "Apply Nimble's Elixir/Phoenix template" @moduledoc """ #{@shortdoc} - - Hex package: https://hex.pm/packages/nimble_phx_gen_template + - Hex package: https://hex.pm/packages/nimble_template - Github: https://github.com/nimblehq/elixir-templates # Usage - - mix nimble.phx.gen.template -v # Print the version + - mix nimble.template.gen -v # Print the version ### Phoenix application - - mix nimble.phx.gen.template --api # Apply the Phoenix API template - - mix nimble.phx.gen.template --live # Apply the Phoenix LiveView template - - mix nimble.phx.gen.template --web # Apply the Phoenix Web template + - mix nimble.template.gen --api # Apply the Phoenix API template + - mix nimble.template.gen --live # Apply the Phoenix LiveView template + - mix nimble.template.gen --web # Apply the Phoenix Web template ### Non-Phoenix application - - mix nimble.phx.gen.template --mix # Apply the Mix template + - mix nimble.template.gen --mix # Apply the Mix template """ use Mix.Task @@ -34,7 +34,7 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do def run(args) do if Mix.Project.umbrella?() do - Mix.raise("mix nimble.phx.gen.template can only be run inside an application directory") + Mix.raise("mix nimble.template.gen can only be run inside an application directory") end {opts, _params} = parse_opts(args) From f1895ecec7dc0624d93f544ef363fa039d92c649 Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:14:53 +0700 Subject: [PATCH 22/52] Rename the template to nimble_template --- .gitignore | 2 +- Makefile | 26 ++++++++-------- README.md | 20 ++++++------- action.yml | 4 +-- lib/mix/tasks/nimble.template.gen.ex | 5 ++-- .../http_client/http_adapter.ex | 3 -- .../variants/api/template.ex | 7 ----- .../variants/live/template.ex | 10 ------- .../addon.ex | 8 ++--- .../addons/credo.ex | 4 +-- .../addons/dialyxir.ex | 4 +-- .../addons/docker.ex | 4 +-- .../addons/elixir_version.ex | 4 +-- .../addons/ex_coveralls.ex | 4 +-- .../addons/ex_machina.ex | 4 +-- .../addons/github.ex | 4 +-- .../addons/makefile.ex | 4 +-- .../addons/mimic.ex | 4 +-- .../addons/mix_release.ex | 4 +-- .../addons/oban.ex | 4 +-- .../addons/readme.ex | 4 +-- .../addons/test_env.ex | 4 +-- .../addons/variants/api/.keep | 0 .../addons/variants/live/.keep | 0 .../addons/variants/mix/.keep | 0 .../addons/variants/web/assets.ex | 4 +-- .../addons/variants/web/core_js.ex | 4 +-- .../addons/variants/web/sobelow.ex | 4 +-- .../addons/variants/web/wallaby.ex | 4 +-- .../generator.ex | 6 ++-- .../hex/hex_client.ex | 4 +-- .../hex/package.ex | 4 +-- .../http_client/http_adapter.ex | 3 ++ .../project.ex | 0 .../template.ex | 12 ++++---- lib/nimble_template/variants/api/template.ex | 7 +++++ lib/nimble_template/variants/live/template.ex | 10 +++++++ .../variants/mix/template.ex | 6 ++-- .../variants/web/template.ex | 6 ++-- mix.exs | 4 +-- .../.credo.exs | 0 .../.dockerignore | 0 .../.github/ISSUE_TEMPLATE.md | 0 .../.github/PULL_REQUEST_TEMPLATE.md | 0 .../.github/workflows/test.yml.eex | 0 .../.github/workflows/test.yml.mix.eex | 0 .../.sobelow-conf | 0 .../.tool-versions.eex | 0 .../Dockerfile.eex | 0 .../Makefile | 0 .../README.md.eex | 0 .../README.md.mix.eex | 0 .../bin/start.sh.eex | 0 .../config/runtime.exs.eex | 0 .../coveralls.json.eex | 0 .../coveralls.json.mix.eex | 0 .../docker-compose.dev.yml.eex | 0 .../docker-compose.yml.eex | 0 .../lib/otp_app/release_tasks.ex.eex | 0 .../migrations/add_oban_jobs_table.exs.eex | 0 .../home_page/view_home_page_test.exs.eex | 0 .../test/support/factory.ex.eex | 0 .../test/support/feature_case.ex.eex | 0 .../addons/credo_test.exs | 4 +-- .../addons/dialyxir_test.exs | 4 +-- .../addons/docker_test.exs | 14 ++++----- .../addons/elixir_version_test.exs | 4 +-- .../addons/ex_coveralls_test.exs | 4 +-- .../addons/ex_machina_test.exs | 10 +++---- .../addons/github_test.exs | 4 +-- .../addons/makefile_test.exs | 4 +-- .../addons/mimic_test.exs | 4 +-- .../addons/mix_release_test.exs | 12 ++++---- .../addons/oban_test.exs | 18 +++++------ .../addons/readme_test.exs | 4 +-- .../addons/test_env_test.exs | 4 +-- .../addons/variants/api/.keep | 0 .../addons/variants/live/.keep | 0 .../addons/variants/mix/.keep | 0 .../addons/variants/web/assets_test.exs | 4 +-- .../addons/variants/web/core_js_test.exs | 4 +-- .../addons/variants/web/sobelow_test.exs | 4 +-- .../addons/variants/web/wallaby_test.exs | 30 +++++++++---------- .../release_version_test.exs | 6 ++-- test/support/addon_case.ex | 14 ++++----- test/test_helper.exs | 2 +- 86 files changed, 184 insertions(+), 185 deletions(-) delete mode 100644 lib/nimble.phx.gen.template/http_client/http_adapter.ex delete mode 100644 lib/nimble.phx.gen.template/variants/api/template.ex delete mode 100644 lib/nimble.phx.gen.template/variants/live/template.ex rename lib/{nimble.phx.gen.template => nimble_template}/addon.ex (76%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/credo.ex (93%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/dialyxir.ex (70%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/docker.ex (91%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/elixir_version.ex (79%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/ex_coveralls.ex (97%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/ex_machina.ex (95%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/github.ex (93%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/makefile.ex (61%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/mimic.ex (88%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/mix_release.ex (96%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/oban.ex (96%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/readme.ex (89%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/test_env.ex (97%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/api/.keep (100%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/live/.keep (100%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/mix/.keep (100%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/web/assets.ex (92%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/web/core_js.ex (92%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/web/sobelow.ex (91%) rename lib/{nimble.phx.gen.template => nimble_template}/addons/variants/web/wallaby.ex (96%) rename lib/{nimble.phx.gen.template => nimble_template}/generator.ex (93%) rename lib/{nimble.phx.gen.template => nimble_template}/hex/hex_client.ex (75%) rename lib/{nimble.phx.gen.template => nimble_template}/hex/package.ex (65%) create mode 100644 lib/nimble_template/http_client/http_adapter.ex rename lib/{nimble.phx.gen.template => nimble_template}/project.ex (100%) rename lib/{nimble.phx.gen.template => nimble_template}/template.ex (85%) create mode 100644 lib/nimble_template/variants/api/template.ex create mode 100644 lib/nimble_template/variants/live/template.ex rename lib/{nimble.phx.gen.template => nimble_template}/variants/mix/template.ex (83%) rename lib/{nimble.phx.gen.template => nimble_template}/variants/web/template.ex (57%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.credo.exs (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.dockerignore (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.github/ISSUE_TEMPLATE.md (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.github/PULL_REQUEST_TEMPLATE.md (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.github/workflows/test.yml.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.github/workflows/test.yml.mix.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.sobelow-conf (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/.tool-versions.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/Dockerfile.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/Makefile (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/README.md.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/README.md.mix.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/bin/start.sh.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/config/runtime.exs.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/coveralls.json.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/coveralls.json.mix.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/docker-compose.dev.yml.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/docker-compose.yml.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/lib/otp_app/release_tasks.ex.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/priv/repo/migrations/add_oban_jobs_table.exs.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/test/features/home_page/view_home_page_test.exs.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/test/support/factory.ex.eex (100%) rename priv/templates/{nimble.phx.gen.template => nimble_template}/test/support/feature_case.ex.eex (100%) rename test/{nimble.phx.gen.template => nimble_template}/addons/credo_test.exs (96%) rename test/{nimble.phx.gen.template => nimble_template}/addons/dialyxir_test.exs (85%) rename test/{nimble.phx.gen.template => nimble_template}/addons/docker_test.exs (86%) rename test/{nimble.phx.gen.template => nimble_template}/addons/elixir_version_test.exs (81%) rename test/{nimble.phx.gen.template => nimble_template}/addons/ex_coveralls_test.exs (97%) rename test/{nimble.phx.gen.template => nimble_template}/addons/ex_machina_test.exs (88%) rename test/{nimble.phx.gen.template => nimble_template}/addons/github_test.exs (97%) rename test/{nimble.phx.gen.template => nimble_template}/addons/makefile_test.exs (73%) rename test/{nimble.phx.gen.template => nimble_template}/addons/mimic_test.exs (91%) rename test/{nimble.phx.gen.template => nimble_template}/addons/mix_release_test.exs (81%) rename test/{nimble.phx.gen.template => nimble_template}/addons/oban_test.exs (83%) rename test/{nimble.phx.gen.template => nimble_template}/addons/readme_test.exs (96%) rename test/{nimble.phx.gen.template => nimble_template}/addons/test_env_test.exs (97%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/api/.keep (100%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/live/.keep (100%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/mix/.keep (100%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/web/assets_test.exs (93%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/web/core_js_test.exs (89%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/web/sobelow_test.exs (94%) rename test/{nimble.phx.gen.template => nimble_template}/addons/variants/web/wallaby_test.exs (75%) rename test/{nimble.phx.gen.template => nimble_template}/release_version_test.exs (55%) diff --git a/.gitignore b/.gitignore index 967b8ce3..2e3f8871 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ erl_crash.dump *.ez # Ignore package tarball (built via "mix hex.build"). -nimble_phx_gen_template-*.tar +nimble_template-*.tar # Ignore folder information and IDE-specific files .DS_Store diff --git a/Makefile b/Makefile index 8cbc651f..9f3eccad 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install_phoenix create_phoenix_project apply_phoenix_template create_mix_project apply_mix_template remove_nimble_phx_gen_template +.PHONY: install_phoenix create_phoenix_project apply_phoenix_template create_mix_project apply_mix_template remove_nimble_template # Y - in response to Are you sure you want to install "phx_new-${PHOENIX_VERSION}.ez"? install_phoenix: @@ -33,28 +33,28 @@ post_setup_addon_prompts = Y\n apply_phoenix_template: cd ${PROJECT_DIRECTORY} && \ - echo '{:nimble_phx_gen_template, path: "../", only: :dev, runtime: false},' > nimble_phx_gen_template.txt && \ - sed -i -e '/{:phoenix, "~> /r nimble_phx_gen_template.txt' mix.exs && \ - rm nimble_phx_gen_template.txt && \ + echo '{:nimble_template, path: "../", only: :dev, runtime: false},' > nimble_template.txt && \ + sed -i -e '/{:phoenix, "~> /r nimble_template.txt' mix.exs && \ + rm nimble_template.txt && \ mix deps.get && \ mix format && \ if [ $(VARIANT) = web ]; then \ - printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --web; \ + printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --web; \ elif [ $(VARIANT) = api ]; then \ - printf "${common_addon_prompts}${api_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --api; \ + printf "${common_addon_prompts}${api_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --api; \ elif [ $(VARIANT) = live ]; then \ - printf "${common_addon_prompts}${web_addon_prompts}${live_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --live; \ + printf "${common_addon_prompts}${web_addon_prompts}${live_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --live; \ fi; apply_mix_template: cd ${PROJECT_DIRECTORY} && \ - echo '{:nimble_phx_gen_template, path: "../", only: :dev, runtime: false}' > nimble_phx_gen_template.txt && \ - sed -i -e '/# {:dep_from_git, /r nimble_phx_gen_template.txt' mix.exs && \ - rm nimble_phx_gen_template.txt && \ + echo '{:nimble_template, path: "../", only: :dev, runtime: false}' > nimble_template.txt && \ + sed -i -e '/# {:dep_from_git, /r nimble_template.txt' mix.exs && \ + rm nimble_template.txt && \ mix deps.get && \ mix format && \ - printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --mix; \ + printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --mix; \ -remove_nimble_phx_gen_template: +remove_nimble_template: cd ${PROJECT_DIRECTORY} && \ - sed -i -e 's/{:nimble_phx_gen_template, path: "..\/"},//' mix.exs + sed -i -e 's/{:nimble_template, path: "..\/"},//' mix.exs diff --git a/README.md b/README.md index 6ad4a008..9d1af7c9 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ mix phx.new awesome_project mix new awesome_project ``` -Step 2: Add `nimble_phx_gen_template` dependency to `mix.exs`: +Step 2: Add `nimble_template` dependency to `mix.exs`: ```elixir def deps do [ - {:nimble_phx_gen_template, "~> 2.2.0", only: :dev, runtime: false}, + {:nimble_template, "~> 2.2.0", only: :dev, runtime: false}, # other dependencies ... ] end @@ -46,17 +46,17 @@ mix do deps.get, deps.compile ## Usage ```bash -mix help nimble.phx.gen.template # Print help +mix help nimble_template # Print help -mix nimble.phx.gen.template -v # Print the version +mix nimble_template -v # Print the version # Phoenix application -mix nimble.phx.gen.template --web # Apply the Web template -mix nimble.phx.gen.template --api # Apply the API template -mix nimble.phx.gen.template --live # Apply the LiveView template +mix nimble_template --web # Apply the Web template +mix nimble_template --api # Apply the API template +mix nimble_template --live # Apply the LiveView template # Non-Phoenix application -mix nimble.phx.gen.template --mix # Apply the Mix template +mix nimble.template.gen --mix # Apply the Mix template ``` ## Running tests @@ -75,7 +75,7 @@ All test files are located under `test/` directory. ├── ... ├── test │ ├── ... -│ ├── nimble.phx.gen.template +│ ├── nimble_template │ │ └── addons │ │ │ ├── ... │ │ │ ├── common_addon_test.exs @@ -196,7 +196,7 @@ The release process follows the [Git flow](https://nimblehq.co/compass/developme Once a `release/` is created, to publish the new version to Hex.pm, the version number in the `mix.ex` file needs to be updated on the release branch before merging. -Once the release branch is merged into the `master` branch, Github Action automatically publishes the template to [https://hex.pm/packages/nimble_phx_gen_template](https://hex.pm/packages/nimble_phx_gen_template). +Once the release branch is merged into the `master` branch, Github Action automatically publishes the template to [https://hex.pm/packages/nimble_template](https://hex.pm/packages/nimble_template). ## Contributing diff --git a/action.yml b/action.yml index 127d138a..769d21ea 100644 --- a/action.yml +++ b/action.yml @@ -60,8 +60,8 @@ runs: MIX_ENV: test DB_HOST: localhost - - name: Remove nimble_phx_gen_template - run: make remove_nimble_phx_gen_template PROJECT_DIRECTORY=sample_project + - name: Remove nimble_template + run: make remove_nimble_template PROJECT_DIRECTORY=sample_project shell: bash - name: Build release app diff --git a/lib/mix/tasks/nimble.template.gen.ex b/lib/mix/tasks/nimble.template.gen.ex index f9a2c701..25c25c9b 100644 --- a/lib/mix/tasks/nimble.template.gen.ex +++ b/lib/mix/tasks/nimble.template.gen.ex @@ -24,13 +24,12 @@ defmodule Mix.Tasks.Nimble.Template.Gen do use Mix.Task - alias Nimble.Phx.Gen.Template.{Project, Template} + alias Nimble.Template.{Project, Template} @version Mix.Project.config()[:version] @variants [api: :boolean, web: :boolean, live: :boolean, mix: :boolean] - def run([args]) when args in ~w(-v --version), - do: Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}") + def run([args]) when args in ~w(-v --version), do: Mix.shell().info("Nimble.Template v#{@version}") def run(args) do if Mix.Project.umbrella?() do diff --git a/lib/nimble.phx.gen.template/http_client/http_adapter.ex b/lib/nimble.phx.gen.template/http_client/http_adapter.ex deleted file mode 100644 index 1f177d9b..00000000 --- a/lib/nimble.phx.gen.template/http_client/http_adapter.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Nimble.Phx.Gen.Template.HttpClient.HttpAdapter do - use HTTPoison.Base -end diff --git a/lib/nimble.phx.gen.template/variants/api/template.ex b/lib/nimble.phx.gen.template/variants/api/template.ex deleted file mode 100644 index 60f3e0cf..00000000 --- a/lib/nimble.phx.gen.template/variants/api/template.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule Nimble.Phx.Gen.Template.Api.Template do - alias Nimble.Phx.Gen.Template.Project - - def apply(%Project{} = project) do - project - end -end diff --git a/lib/nimble.phx.gen.template/variants/live/template.ex b/lib/nimble.phx.gen.template/variants/live/template.ex deleted file mode 100644 index 5d85d74b..00000000 --- a/lib/nimble.phx.gen.template/variants/live/template.ex +++ /dev/null @@ -1,10 +0,0 @@ -defmodule Nimble.Phx.Gen.Template.Live.Template do - alias Nimble.Phx.Gen.Template.Project - alias Nimble.Phx.Gen.Template.Web.Template, as: WebTemplate - - def apply(%Project{} = project) do - WebTemplate.apply(project) - - project - end -end diff --git a/lib/nimble.phx.gen.template/addon.ex b/lib/nimble_template/addon.ex similarity index 76% rename from lib/nimble.phx.gen.template/addon.ex rename to lib/nimble_template/addon.ex index dda68391..c0880e8e 100644 --- a/lib/nimble.phx.gen.template/addon.ex +++ b/lib/nimble_template/addon.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addon do - alias Nimble.Phx.Gen.Template.{Addon, Project} +defmodule Nimble.Template.Addon do + alias Nimble.Template.{Addon, Project} @callback apply(%Project{}, %{}) :: %Project{} @callback do_apply(%Project{}, %{}) :: %Project{} @@ -8,8 +8,8 @@ defmodule Nimble.Phx.Gen.Template.Addon do quote location: :keep, bind_quoted: [opts: opts] do @behaviour Addon - alias Nimble.Phx.Gen.Template.{Generator, Project} - alias Nimble.Phx.Gen.Template.Hex.Package + alias Nimble.Template.{Generator, Project} + alias Nimble.Template.Hex.Package def apply(%Project{} = project, opts \\ %{}) when is_map(opts) do Generator.print_log("* applying ", inspect(__MODULE__)) diff --git a/lib/nimble.phx.gen.template/addons/credo.ex b/lib/nimble_template/addons/credo.ex similarity index 93% rename from lib/nimble.phx.gen.template/addons/credo.ex rename to lib/nimble_template/addons/credo.ex index e6d94655..d13b3d87 100644 --- a/lib/nimble.phx.gen.template/addons/credo.ex +++ b/lib/nimble_template/addons/credo.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Credo do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Credo do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/dialyxir.ex b/lib/nimble_template/addons/dialyxir.ex similarity index 70% rename from lib/nimble.phx.gen.template/addons/dialyxir.ex rename to lib/nimble_template/addons/dialyxir.ex index bc48310e..dfc82066 100644 --- a/lib/nimble.phx.gen.template/addons/dialyxir.ex +++ b/lib/nimble_template/addons/dialyxir.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Dialyxir do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Dialyxir do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/docker.ex b/lib/nimble_template/addons/docker.ex similarity index 91% rename from lib/nimble.phx.gen.template/addons/docker.ex rename to lib/nimble_template/addons/docker.ex index b0040e19..38991397 100644 --- a/lib/nimble.phx.gen.template/addons/docker.ex +++ b/lib/nimble_template/addons/docker.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Docker do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Docker do + use Nimble.Template.Addon @impl true def do_apply( diff --git a/lib/nimble.phx.gen.template/addons/elixir_version.ex b/lib/nimble_template/addons/elixir_version.ex similarity index 79% rename from lib/nimble.phx.gen.template/addons/elixir_version.ex rename to lib/nimble_template/addons/elixir_version.ex index 373e0012..7b10f0dc 100644 --- a/lib/nimble.phx.gen.template/addons/elixir_version.ex +++ b/lib/nimble_template/addons/elixir_version.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersion do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.ElixirVersion do + use Nimble.Template.Addon @impl true def do_apply( diff --git a/lib/nimble.phx.gen.template/addons/ex_coveralls.ex b/lib/nimble_template/addons/ex_coveralls.ex similarity index 97% rename from lib/nimble.phx.gen.template/addons/ex_coveralls.ex rename to lib/nimble_template/addons/ex_coveralls.ex index 218a6db6..083a4709 100644 --- a/lib/nimble.phx.gen.template/addons/ex_coveralls.ex +++ b/lib/nimble_template/addons/ex_coveralls.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExCoveralls do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.ExCoveralls do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/ex_machina.ex b/lib/nimble_template/addons/ex_machina.ex similarity index 95% rename from lib/nimble.phx.gen.template/addons/ex_machina.ex rename to lib/nimble_template/addons/ex_machina.ex index 0cc195d8..ac552cb9 100644 --- a/lib/nimble.phx.gen.template/addons/ex_machina.ex +++ b/lib/nimble_template/addons/ex_machina.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExMachina do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.ExMachina do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/github.ex b/lib/nimble_template/addons/github.ex similarity index 93% rename from lib/nimble.phx.gen.template/addons/github.ex rename to lib/nimble_template/addons/github.ex index c39b2e29..6d05d24d 100644 --- a/lib/nimble.phx.gen.template/addons/github.ex +++ b/lib/nimble_template/addons/github.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Github do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Github do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, opts) when is_map_key(opts, :github_template) do diff --git a/lib/nimble.phx.gen.template/addons/makefile.ex b/lib/nimble_template/addons/makefile.ex similarity index 61% rename from lib/nimble.phx.gen.template/addons/makefile.ex rename to lib/nimble_template/addons/makefile.ex index 1154f4a5..c8ad3230 100644 --- a/lib/nimble.phx.gen.template/addons/makefile.ex +++ b/lib/nimble_template/addons/makefile.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Makefile do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Makefile do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/mimic.ex b/lib/nimble_template/addons/mimic.ex similarity index 88% rename from lib/nimble.phx.gen.template/addons/mimic.ex rename to lib/nimble_template/addons/mimic.ex index 2ff2ec5d..a1332b23 100644 --- a/lib/nimble.phx.gen.template/addons/mimic.ex +++ b/lib/nimble_template/addons/mimic.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Mimic do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Mimic do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/mix_release.ex b/lib/nimble_template/addons/mix_release.ex similarity index 96% rename from lib/nimble.phx.gen.template/addons/mix_release.ex rename to lib/nimble_template/addons/mix_release.ex index 258f5c49..8b5c3f8f 100644 --- a/lib/nimble.phx.gen.template/addons/mix_release.ex +++ b/lib/nimble_template/addons/mix_release.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.MixRelease do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.MixRelease do + use Nimble.Template.Addon @prod_secret_path "config/prod.secret.exs" diff --git a/lib/nimble.phx.gen.template/addons/oban.ex b/lib/nimble_template/addons/oban.ex similarity index 96% rename from lib/nimble.phx.gen.template/addons/oban.ex rename to lib/nimble_template/addons/oban.ex index 90228403..fec5efcc 100644 --- a/lib/nimble.phx.gen.template/addons/oban.ex +++ b/lib/nimble_template/addons/oban.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Oban do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Oban do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/readme.ex b/lib/nimble_template/addons/readme.ex similarity index 89% rename from lib/nimble.phx.gen.template/addons/readme.ex rename to lib/nimble_template/addons/readme.ex index 2ac5e491..7ef4e5ef 100644 --- a/lib/nimble.phx.gen.template/addons/readme.ex +++ b/lib/nimble_template/addons/readme.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Readme do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Readme do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/test_env.ex b/lib/nimble_template/addons/test_env.ex similarity index 97% rename from lib/nimble.phx.gen.template/addons/test_env.ex rename to lib/nimble_template/addons/test_env.ex index 3673f462..61ef8d90 100644 --- a/lib/nimble.phx.gen.template/addons/test_env.ex +++ b/lib/nimble_template/addons/test_env.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.TestEnv do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.TestEnv do + use Nimble.Template.Addon @impl true def do_apply(%Project{mix_project?: true} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/variants/api/.keep b/lib/nimble_template/addons/variants/api/.keep similarity index 100% rename from lib/nimble.phx.gen.template/addons/variants/api/.keep rename to lib/nimble_template/addons/variants/api/.keep diff --git a/lib/nimble.phx.gen.template/addons/variants/live/.keep b/lib/nimble_template/addons/variants/live/.keep similarity index 100% rename from lib/nimble.phx.gen.template/addons/variants/live/.keep rename to lib/nimble_template/addons/variants/live/.keep diff --git a/lib/nimble.phx.gen.template/addons/variants/mix/.keep b/lib/nimble_template/addons/variants/mix/.keep similarity index 100% rename from lib/nimble.phx.gen.template/addons/variants/mix/.keep rename to lib/nimble_template/addons/variants/mix/.keep diff --git a/lib/nimble.phx.gen.template/addons/variants/web/assets.ex b/lib/nimble_template/addons/variants/web/assets.ex similarity index 92% rename from lib/nimble.phx.gen.template/addons/variants/web/assets.ex rename to lib/nimble_template/addons/variants/web/assets.ex index 5cabe94e..8c740cd4 100644 --- a/lib/nimble.phx.gen.template/addons/variants/web/assets.ex +++ b/lib/nimble_template/addons/variants/web/assets.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Web.Assets do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Web.Assets do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/variants/web/core_js.ex b/lib/nimble_template/addons/variants/web/core_js.ex similarity index 92% rename from lib/nimble.phx.gen.template/addons/variants/web/core_js.ex rename to lib/nimble_template/addons/variants/web/core_js.ex index 93e24d4b..278e3d2a 100644 --- a/lib/nimble.phx.gen.template/addons/variants/web/core_js.ex +++ b/lib/nimble_template/addons/variants/web/core_js.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Web.CoreJS do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Web.CoreJS do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/variants/web/sobelow.ex b/lib/nimble_template/addons/variants/web/sobelow.ex similarity index 91% rename from lib/nimble.phx.gen.template/addons/variants/web/sobelow.ex rename to lib/nimble_template/addons/variants/web/sobelow.ex index 14854bd1..1d938661 100644 --- a/lib/nimble.phx.gen.template/addons/variants/web/sobelow.ex +++ b/lib/nimble_template/addons/variants/web/sobelow.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Web.Sobelow do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Web.Sobelow do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/addons/variants/web/wallaby.ex b/lib/nimble_template/addons/variants/web/wallaby.ex similarity index 96% rename from lib/nimble.phx.gen.template/addons/variants/web/wallaby.ex rename to lib/nimble_template/addons/variants/web/wallaby.ex index 451d8481..dc1eeff5 100644 --- a/lib/nimble.phx.gen.template/addons/variants/web/wallaby.ex +++ b/lib/nimble_template/addons/variants/web/wallaby.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.Web.Wallaby do - use Nimble.Phx.Gen.Template.Addon +defmodule Nimble.Template.Addons.Web.Wallaby do + use Nimble.Template.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble.phx.gen.template/generator.ex b/lib/nimble_template/generator.ex similarity index 93% rename from lib/nimble.phx.gen.template/generator.ex rename to lib/nimble_template/generator.ex index ca035a3c..61f7d6cc 100644 --- a/lib/nimble.phx.gen.template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -1,9 +1,9 @@ -defmodule Nimble.Phx.Gen.Template.Generator do - @template_resource "priv/templates/nimble.phx.gen.template" +defmodule Nimble.Template.Generator do + @template_resource "priv/templates/nimble_template" def copy_file(files, binding \\ []) do Mix.Phoenix.copy_from( - [:nimble_phx_gen_template], + [:nimble_template], @template_resource, binding, files diff --git a/lib/nimble.phx.gen.template/hex/hex_client.ex b/lib/nimble_template/hex/hex_client.ex similarity index 75% rename from lib/nimble.phx.gen.template/hex/hex_client.ex rename to lib/nimble_template/hex/hex_client.ex index d8b71703..eb854576 100644 --- a/lib/nimble.phx.gen.template/hex/hex_client.ex +++ b/lib/nimble_template/hex/hex_client.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Hex.HexClient do - alias Nimble.Phx.Gen.Template.HttpClient.HttpAdapter +defmodule Nimble.Template.Hex.HexClient do + alias Nimble.Template.HttpClient.HttpAdapter @base_url "https://hex.pm/api/" diff --git a/lib/nimble.phx.gen.template/hex/package.ex b/lib/nimble_template/hex/package.ex similarity index 65% rename from lib/nimble.phx.gen.template/hex/package.ex rename to lib/nimble_template/hex/package.ex index e5a06296..2e6fffd0 100644 --- a/lib/nimble.phx.gen.template/hex/package.ex +++ b/lib/nimble_template/hex/package.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Hex.Package do - alias Nimble.Phx.Gen.Template.Hex.HexClient +defmodule Nimble.Template.Hex.Package do + alias Nimble.Template.Hex.HexClient def get_latest_version(package) do {:ok, package_info} = HexClient.get("packages/#{package}") diff --git a/lib/nimble_template/http_client/http_adapter.ex b/lib/nimble_template/http_client/http_adapter.ex new file mode 100644 index 00000000..b36c780d --- /dev/null +++ b/lib/nimble_template/http_client/http_adapter.ex @@ -0,0 +1,3 @@ +defmodule Nimble.Template.HttpClient.HttpAdapter do + use HTTPoison.Base +end diff --git a/lib/nimble.phx.gen.template/project.ex b/lib/nimble_template/project.ex similarity index 100% rename from lib/nimble.phx.gen.template/project.ex rename to lib/nimble_template/project.ex diff --git a/lib/nimble.phx.gen.template/template.ex b/lib/nimble_template/template.ex similarity index 85% rename from lib/nimble.phx.gen.template/template.ex rename to lib/nimble_template/template.ex index c7de8c45..0e90a1b0 100644 --- a/lib/nimble.phx.gen.template/template.ex +++ b/lib/nimble_template/template.ex @@ -1,9 +1,9 @@ -defmodule Nimble.Phx.Gen.Template.Template do - alias Nimble.Phx.Gen.Template.Api.Template, as: ApiTemplate - alias Nimble.Phx.Gen.Template.Live.Template, as: LiveTemplate - alias Nimble.Phx.Gen.Template.Mix.Template, as: MixTemplate - alias Nimble.Phx.Gen.Template.Web.Template, as: WebTemplate - alias Nimble.Phx.Gen.Template.{Addons, Project} +defmodule Nimble.Template.Template do + alias Nimble.Template.Api.Template, as: ApiTemplate + alias Nimble.Template.Live.Template, as: LiveTemplate + alias Nimble.Template.Mix.Template, as: MixTemplate + alias Nimble.Template.Web.Template, as: WebTemplate + alias Nimble.Template.{Addons, Project} def apply(%Project{mix_project?: true} = project) do MixTemplate.apply(project) diff --git a/lib/nimble_template/variants/api/template.ex b/lib/nimble_template/variants/api/template.ex new file mode 100644 index 00000000..527dbb03 --- /dev/null +++ b/lib/nimble_template/variants/api/template.ex @@ -0,0 +1,7 @@ +defmodule Nimble.Template.Api.Template do + alias Nimble.Template.Project + + def apply(%Project{} = project) do + project + end +end diff --git a/lib/nimble_template/variants/live/template.ex b/lib/nimble_template/variants/live/template.ex new file mode 100644 index 00000000..3827a02f --- /dev/null +++ b/lib/nimble_template/variants/live/template.ex @@ -0,0 +1,10 @@ +defmodule Nimble.Template.Live.Template do + alias Nimble.Template.Project + alias Nimble.Template.Web.Template, as: WebTemplate + + def apply(%Project{} = project) do + WebTemplate.apply(project) + + project + end +end diff --git a/lib/nimble.phx.gen.template/variants/mix/template.ex b/lib/nimble_template/variants/mix/template.ex similarity index 83% rename from lib/nimble.phx.gen.template/variants/mix/template.ex rename to lib/nimble_template/variants/mix/template.ex index 4da34e54..fd3a2cb1 100644 --- a/lib/nimble.phx.gen.template/variants/mix/template.ex +++ b/lib/nimble_template/variants/mix/template.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Mix.Template do - import Nimble.Phx.Gen.Template.Template, +defmodule Nimble.Template.Mix.Template do + import Nimble.Template.Template, only: [ host_on_github?: 0, generate_github_template?: 0, @@ -7,7 +7,7 @@ defmodule Nimble.Phx.Gen.Template.Mix.Template do install_addon_prompt?: 1 ] - alias Nimble.Phx.Gen.Template.{Addons, Project} + alias Nimble.Template.{Addons, Project} def apply(%Project{} = project) do project diff --git a/lib/nimble.phx.gen.template/variants/web/template.ex b/lib/nimble_template/variants/web/template.ex similarity index 57% rename from lib/nimble.phx.gen.template/variants/web/template.ex rename to lib/nimble_template/variants/web/template.ex index 5403ed17..690252b7 100644 --- a/lib/nimble.phx.gen.template/variants/web/template.ex +++ b/lib/nimble_template/variants/web/template.ex @@ -1,6 +1,6 @@ -defmodule Nimble.Phx.Gen.Template.Web.Template do - alias Nimble.Phx.Gen.Template.Addons.Web - alias Nimble.Phx.Gen.Template.Project +defmodule Nimble.Template.Web.Template do + alias Nimble.Template.Addons.Web + alias Nimble.Template.Project def apply(%Project{} = project) do project diff --git a/mix.exs b/mix.exs index 0c08ab77..ae70af9f 100644 --- a/mix.exs +++ b/mix.exs @@ -1,9 +1,9 @@ -defmodule Nimble.Phx.Gen.Template.MixProject do +defmodule Nimble.Template.MixProject do use Mix.Project def project do [ - app: :nimble_phx_gen_template, + app: :nimble_template, version: "2.2.1", description: "Project repository template to set up all public Phoenix projects at Nimble", elixir: "~> 1.11.4", diff --git a/priv/templates/nimble.phx.gen.template/.credo.exs b/priv/templates/nimble_template/.credo.exs similarity index 100% rename from priv/templates/nimble.phx.gen.template/.credo.exs rename to priv/templates/nimble_template/.credo.exs diff --git a/priv/templates/nimble.phx.gen.template/.dockerignore b/priv/templates/nimble_template/.dockerignore similarity index 100% rename from priv/templates/nimble.phx.gen.template/.dockerignore rename to priv/templates/nimble_template/.dockerignore diff --git a/priv/templates/nimble.phx.gen.template/.github/ISSUE_TEMPLATE.md b/priv/templates/nimble_template/.github/ISSUE_TEMPLATE.md similarity index 100% rename from priv/templates/nimble.phx.gen.template/.github/ISSUE_TEMPLATE.md rename to priv/templates/nimble_template/.github/ISSUE_TEMPLATE.md diff --git a/priv/templates/nimble.phx.gen.template/.github/PULL_REQUEST_TEMPLATE.md b/priv/templates/nimble_template/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from priv/templates/nimble.phx.gen.template/.github/PULL_REQUEST_TEMPLATE.md rename to priv/templates/nimble_template/.github/PULL_REQUEST_TEMPLATE.md diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex b/priv/templates/nimble_template/.github/workflows/test.yml.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.eex rename to priv/templates/nimble_template/.github/workflows/test.yml.eex diff --git a/priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex b/priv/templates/nimble_template/.github/workflows/test.yml.mix.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/.github/workflows/test.yml.mix.eex rename to priv/templates/nimble_template/.github/workflows/test.yml.mix.eex diff --git a/priv/templates/nimble.phx.gen.template/.sobelow-conf b/priv/templates/nimble_template/.sobelow-conf similarity index 100% rename from priv/templates/nimble.phx.gen.template/.sobelow-conf rename to priv/templates/nimble_template/.sobelow-conf diff --git a/priv/templates/nimble.phx.gen.template/.tool-versions.eex b/priv/templates/nimble_template/.tool-versions.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/.tool-versions.eex rename to priv/templates/nimble_template/.tool-versions.eex diff --git a/priv/templates/nimble.phx.gen.template/Dockerfile.eex b/priv/templates/nimble_template/Dockerfile.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/Dockerfile.eex rename to priv/templates/nimble_template/Dockerfile.eex diff --git a/priv/templates/nimble.phx.gen.template/Makefile b/priv/templates/nimble_template/Makefile similarity index 100% rename from priv/templates/nimble.phx.gen.template/Makefile rename to priv/templates/nimble_template/Makefile diff --git a/priv/templates/nimble.phx.gen.template/README.md.eex b/priv/templates/nimble_template/README.md.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/README.md.eex rename to priv/templates/nimble_template/README.md.eex diff --git a/priv/templates/nimble.phx.gen.template/README.md.mix.eex b/priv/templates/nimble_template/README.md.mix.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/README.md.mix.eex rename to priv/templates/nimble_template/README.md.mix.eex diff --git a/priv/templates/nimble.phx.gen.template/bin/start.sh.eex b/priv/templates/nimble_template/bin/start.sh.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/bin/start.sh.eex rename to priv/templates/nimble_template/bin/start.sh.eex diff --git a/priv/templates/nimble.phx.gen.template/config/runtime.exs.eex b/priv/templates/nimble_template/config/runtime.exs.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/config/runtime.exs.eex rename to priv/templates/nimble_template/config/runtime.exs.eex diff --git a/priv/templates/nimble.phx.gen.template/coveralls.json.eex b/priv/templates/nimble_template/coveralls.json.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/coveralls.json.eex rename to priv/templates/nimble_template/coveralls.json.eex diff --git a/priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex b/priv/templates/nimble_template/coveralls.json.mix.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/coveralls.json.mix.eex rename to priv/templates/nimble_template/coveralls.json.mix.eex diff --git a/priv/templates/nimble.phx.gen.template/docker-compose.dev.yml.eex b/priv/templates/nimble_template/docker-compose.dev.yml.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/docker-compose.dev.yml.eex rename to priv/templates/nimble_template/docker-compose.dev.yml.eex diff --git a/priv/templates/nimble.phx.gen.template/docker-compose.yml.eex b/priv/templates/nimble_template/docker-compose.yml.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/docker-compose.yml.eex rename to priv/templates/nimble_template/docker-compose.yml.eex diff --git a/priv/templates/nimble.phx.gen.template/lib/otp_app/release_tasks.ex.eex b/priv/templates/nimble_template/lib/otp_app/release_tasks.ex.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/lib/otp_app/release_tasks.ex.eex rename to priv/templates/nimble_template/lib/otp_app/release_tasks.ex.eex diff --git a/priv/templates/nimble.phx.gen.template/priv/repo/migrations/add_oban_jobs_table.exs.eex b/priv/templates/nimble_template/priv/repo/migrations/add_oban_jobs_table.exs.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/priv/repo/migrations/add_oban_jobs_table.exs.eex rename to priv/templates/nimble_template/priv/repo/migrations/add_oban_jobs_table.exs.eex diff --git a/priv/templates/nimble.phx.gen.template/test/features/home_page/view_home_page_test.exs.eex b/priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/test/features/home_page/view_home_page_test.exs.eex rename to priv/templates/nimble_template/test/features/home_page/view_home_page_test.exs.eex diff --git a/priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex b/priv/templates/nimble_template/test/support/factory.ex.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/test/support/factory.ex.eex rename to priv/templates/nimble_template/test/support/factory.ex.eex diff --git a/priv/templates/nimble.phx.gen.template/test/support/feature_case.ex.eex b/priv/templates/nimble_template/test/support/feature_case.ex.eex similarity index 100% rename from priv/templates/nimble.phx.gen.template/test/support/feature_case.ex.eex rename to priv/templates/nimble_template/test/support/feature_case.ex.eex diff --git a/test/nimble.phx.gen.template/addons/credo_test.exs b/test/nimble_template/addons/credo_test.exs similarity index 96% rename from test/nimble.phx.gen.template/addons/credo_test.exs rename to test/nimble_template/addons/credo_test.exs index 1bf32085..f9ef9934 100644 --- a/test/nimble.phx.gen.template/addons/credo_test.exs +++ b/test/nimble_template/addons/credo_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.CredoTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.CredoTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "1.4"}] diff --git a/test/nimble.phx.gen.template/addons/dialyxir_test.exs b/test/nimble_template/addons/dialyxir_test.exs similarity index 85% rename from test/nimble.phx.gen.template/addons/dialyxir_test.exs rename to test/nimble_template/addons/dialyxir_test.exs index ae0ef75b..19e23175 100644 --- a/test/nimble.phx.gen.template/addons/dialyxir_test.exs +++ b/test/nimble_template/addons/dialyxir_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.DialyxirTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.DialyxirTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:dialyxir, "1.0"}] diff --git a/test/nimble.phx.gen.template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs similarity index 86% rename from test/nimble.phx.gen.template/addons/docker_test.exs rename to test/nimble_template/addons/docker_test.exs index b7f1f20b..33ae3b9e 100644 --- a/test/nimble.phx.gen.template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.DockerTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.DockerTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "copies the docker-compose.dev.yml", %{ @@ -16,10 +16,10 @@ defmodule Nimble.Phx.Gen.Template.Addons.DockerTest do services: db: image: postgres:12.3 - container_name: nimble_phx_gen_template_db + container_name: nimble_template_db environment: - POSTGRES_HOST_AUTH_METHOD=trust - - POSTGRES_DB=nimble_phx_gen_template_dev + - POSTGRES_DB=nimble_template_dev ports: - "5432:5432" """ @@ -67,7 +67,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.DockerTest do assert file =~ "USER app_user" assert file =~ - "COPY --from=build --chown=app_user:app_group /app/_build/prod/rel/nimble_phx_gen_template ./" + "COPY --from=build --chown=app_user:app_group /app/_build/prod/rel/nimble_template ./" end) end) end @@ -81,9 +81,9 @@ defmodule Nimble.Phx.Gen.Template.Addons.DockerTest do assert_file("bin/start.sh", fn file -> assert file =~ """ - bin/nimble_phx_gen_template eval "NimblePhxGenTemplate.ReleaseTasks.migrate()" + bin/nimble_template eval "NimbleTemplate.ReleaseTasks.migrate()" - bin/nimble_phx_gen_template start + bin/nimble_template start """ end) end) diff --git a/test/nimble.phx.gen.template/addons/elixir_version_test.exs b/test/nimble_template/addons/elixir_version_test.exs similarity index 81% rename from test/nimble.phx.gen.template/addons/elixir_version_test.exs rename to test/nimble_template/addons/elixir_version_test.exs index 41c56d6a..813ab809 100644 --- a/test/nimble.phx.gen.template/addons/elixir_version_test.exs +++ b/test/nimble_template/addons/elixir_version_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ElixirVersionTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.ElixirVersionTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "copies the .tool-versions", %{ diff --git a/test/nimble.phx.gen.template/addons/ex_coveralls_test.exs b/test/nimble_template/addons/ex_coveralls_test.exs similarity index 97% rename from test/nimble.phx.gen.template/addons/ex_coveralls_test.exs rename to test/nimble_template/addons/ex_coveralls_test.exs index 857ba3b6..6a319911 100644 --- a/test/nimble.phx.gen.template/addons/ex_coveralls_test.exs +++ b/test/nimble_template/addons/ex_coveralls_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExCoverallsTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.ExCoverallsTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:excoveralls, "0.12.2"}] diff --git a/test/nimble.phx.gen.template/addons/ex_machina_test.exs b/test/nimble_template/addons/ex_machina_test.exs similarity index 88% rename from test/nimble.phx.gen.template/addons/ex_machina_test.exs rename to test/nimble_template/addons/ex_machina_test.exs index d7fa6065..41445bf5 100644 --- a/test/nimble.phx.gen.template/addons/ex_machina_test.exs +++ b/test/nimble_template/addons/ex_machina_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExMachinaTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.ExMachinaTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:ex_machina, "2.4"}] @@ -66,15 +66,15 @@ defmodule Nimble.Phx.Gen.Template.Addons.ExMachinaTest do Addons.ExMachina.apply(project) assert_file("test/support/data_case.ex", fn file -> - assert file =~ "import NimblePhxGenTemplate.Factory" + assert file =~ "import NimbleTemplate.Factory" end) assert_file("test/support/channel_case.ex", fn file -> - assert file =~ "import NimblePhxGenTemplate.Factory" + assert file =~ "import NimbleTemplate.Factory" end) assert_file("test/support/conn_case.ex", fn file -> - assert file =~ "import NimblePhxGenTemplate.Factory" + assert file =~ "import NimbleTemplate.Factory" end) end) end diff --git a/test/nimble.phx.gen.template/addons/github_test.exs b/test/nimble_template/addons/github_test.exs similarity index 97% rename from test/nimble.phx.gen.template/addons/github_test.exs rename to test/nimble_template/addons/github_test.exs index 9e2cb39d..7f34e934 100644 --- a/test/nimble.phx.gen.template/addons/github_test.exs +++ b/test/nimble_template/addons/github_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.GithubTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.GithubTest do + use Nimble.Template.AddonCase describe "#apply/2 with github_template option" do test "copies the .github/ISSUE_TEMPLATE.md", %{ diff --git a/test/nimble.phx.gen.template/addons/makefile_test.exs b/test/nimble_template/addons/makefile_test.exs similarity index 73% rename from test/nimble.phx.gen.template/addons/makefile_test.exs rename to test/nimble_template/addons/makefile_test.exs index 19ecc7a2..b2f48a61 100644 --- a/test/nimble.phx.gen.template/addons/makefile_test.exs +++ b/test/nimble_template/addons/makefile_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.MakefileTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.MakefileTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "copies the Makefile", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble.phx.gen.template/addons/mimic_test.exs b/test/nimble_template/addons/mimic_test.exs similarity index 91% rename from test/nimble.phx.gen.template/addons/mimic_test.exs rename to test/nimble_template/addons/mimic_test.exs index 7e250ced..d71c9796 100644 --- a/test/nimble.phx.gen.template/addons/mimic_test.exs +++ b/test/nimble_template/addons/mimic_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.MimicTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.MimicTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:mimic, "1.3.1"}] diff --git a/test/nimble.phx.gen.template/addons/mix_release_test.exs b/test/nimble_template/addons/mix_release_test.exs similarity index 81% rename from test/nimble.phx.gen.template/addons/mix_release_test.exs rename to test/nimble_template/addons/mix_release_test.exs index a1e3a58b..da3c4a3c 100644 --- a/test/nimble.phx.gen.template/addons/mix_release_test.exs +++ b/test/nimble_template/addons/mix_release_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.MixReleaseTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.MixReleaseTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "deletes the import_config \"prod.secret.exs\" in config/prod.exs", %{ @@ -47,17 +47,17 @@ defmodule Nimble.Phx.Gen.Template.Addons.MixReleaseTest do end) end - test "creates the lib/nimble_phx_gen_template/release_tasks.ex", %{ + test "creates the lib/nimble_template/release_tasks.ex", %{ project: project, test_project_path: test_project_path } do in_test_project(test_project_path, fn -> Addons.MixRelease.apply(project) - assert_file("lib/nimble_phx_gen_template/release_tasks.ex", fn file -> + assert_file("lib/nimble_template/release_tasks.ex", fn file -> assert file =~ """ - defmodule NimblePhxGenTemplate.ReleaseTasks do - @app :nimble_phx_gen_template + defmodule NimbleTemplate.ReleaseTasks do + @app :nimble_template def migrate do """ diff --git a/test/nimble.phx.gen.template/addons/oban_test.exs b/test/nimble_template/addons/oban_test.exs similarity index 83% rename from test/nimble.phx.gen.template/addons/oban_test.exs rename to test/nimble_template/addons/oban_test.exs index 7ab6dc4a..1ebe5a74 100644 --- a/test/nimble.phx.gen.template/addons/oban_test.exs +++ b/test/nimble_template/addons/oban_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.ObanTest do + use Nimble.Template.AddonCase use Mimic describe "#apply/2" do @@ -33,7 +33,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do assert_file("priv/repo/migrations/20201120074154_add_oban_jobs_table.exs", fn file -> assert file =~ """ - defmodule NimblePhxGenTemplate.Repo.Migrations.AddObanJobsTable do + defmodule NimbleTemplate.Repo.Migrations.AddObanJobsTable do use Ecto.Migration def up do @@ -58,7 +58,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do in_test_project(test_project_path, fn -> Addons.Oban.apply(project) - assert_file("lib/nimble_phx_gen_template/application.ex", fn file -> + assert_file("lib/nimble_template/application.ex", fn file -> assert file =~ """ {Oban, oban_config()} """ @@ -66,7 +66,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do assert file =~ """ # Conditionally disable crontab, queues, or plugins here. defp oban_config do - Application.get_env(:nimble_phx_gen_template, Oban) + Application.get_env(:nimble_template, Oban) end """ end) @@ -82,8 +82,8 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do assert_file("config/config.exs", fn file -> assert file =~ """ - config :nimble_phx_gen_template, Oban, - repo: NimblePhxGenTemplate.Repo, + config :nimble_template, Oban, + repo: NimbleTemplate.Repo, plugins: [Oban.Plugins.Pruner], queues: [default: 10] """ @@ -100,7 +100,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do assert_file("config/test.exs", fn file -> assert file =~ """ - config :nimble_phx_gen_template, Oban, crontab: false, queues: false, plugins: false + config :nimble_template, Oban, crontab: false, queues: false, plugins: false """ end) end) @@ -113,7 +113,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ObanTest do in_test_project(test_project_path, fn -> Addons.Oban.apply(project) - assert(File.dir?("lib/nimble_phx_gen_template_worker")) == true + assert(File.dir?("lib/nimble_template_worker")) == true end) end end diff --git a/test/nimble.phx.gen.template/addons/readme_test.exs b/test/nimble_template/addons/readme_test.exs similarity index 96% rename from test/nimble.phx.gen.template/addons/readme_test.exs rename to test/nimble_template/addons/readme_test.exs index 24059914..e1572a30 100644 --- a/test/nimble.phx.gen.template/addons/readme_test.exs +++ b/test/nimble_template/addons/readme_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ReadmeTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.ReadmeTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "copies the README.md", %{ diff --git a/test/nimble.phx.gen.template/addons/test_env_test.exs b/test/nimble_template/addons/test_env_test.exs similarity index 97% rename from test/nimble.phx.gen.template/addons/test_env_test.exs rename to test/nimble_template/addons/test_env_test.exs index b58fb409..84c17ae3 100644 --- a/test/nimble.phx.gen.template/addons/test_env_test.exs +++ b/test/nimble_template/addons/test_env_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.TestEnvTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.Addons.TestEnvTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "injects the DB_HOST ENV", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble.phx.gen.template/addons/variants/api/.keep b/test/nimble_template/addons/variants/api/.keep similarity index 100% rename from test/nimble.phx.gen.template/addons/variants/api/.keep rename to test/nimble_template/addons/variants/api/.keep diff --git a/test/nimble.phx.gen.template/addons/variants/live/.keep b/test/nimble_template/addons/variants/live/.keep similarity index 100% rename from test/nimble.phx.gen.template/addons/variants/live/.keep rename to test/nimble_template/addons/variants/live/.keep diff --git a/test/nimble.phx.gen.template/addons/variants/mix/.keep b/test/nimble_template/addons/variants/mix/.keep similarity index 100% rename from test/nimble.phx.gen.template/addons/variants/mix/.keep rename to test/nimble_template/addons/variants/mix/.keep diff --git a/test/nimble.phx.gen.template/addons/variants/web/assets_test.exs b/test/nimble_template/addons/variants/web/assets_test.exs similarity index 93% rename from test/nimble.phx.gen.template/addons/variants/web/assets_test.exs rename to test/nimble_template/addons/variants/web/assets_test.exs index 43125917..4f990502 100644 --- a/test/nimble.phx.gen.template/addons/variants/web/assets_test.exs +++ b/test/nimble_template/addons/variants/web/assets_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.AddonsWeb.AssetsTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.AddonsWeb.AssetsTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "adds assets.compile alias", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble.phx.gen.template/addons/variants/web/core_js_test.exs b/test/nimble_template/addons/variants/web/core_js_test.exs similarity index 89% rename from test/nimble.phx.gen.template/addons/variants/web/core_js_test.exs rename to test/nimble_template/addons/variants/web/core_js_test.exs index 00c716b1..e82bb9d0 100644 --- a/test/nimble.phx.gen.template/addons/variants/web/core_js_test.exs +++ b/test/nimble_template/addons/variants/web/core_js_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.AddonsWeb.CoreJSTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.AddonsWeb.CoreJSTest do + use Nimble.Template.AddonCase describe "#apply/2" do test "adds core-js into package.json", %{ diff --git a/test/nimble.phx.gen.template/addons/variants/web/sobelow_test.exs b/test/nimble_template/addons/variants/web/sobelow_test.exs similarity index 94% rename from test/nimble.phx.gen.template/addons/variants/web/sobelow_test.exs rename to test/nimble_template/addons/variants/web/sobelow_test.exs index 9c7e4d72..4f704db0 100644 --- a/test/nimble.phx.gen.template/addons/variants/web/sobelow_test.exs +++ b/test/nimble_template/addons/variants/web/sobelow_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.AddonsWeb.SobelowTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.AddonsWeb.SobelowTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "0.26.2"}, {:sobelow, "0.8"}] diff --git a/test/nimble.phx.gen.template/addons/variants/web/wallaby_test.exs b/test/nimble_template/addons/variants/web/wallaby_test.exs similarity index 75% rename from test/nimble.phx.gen.template/addons/variants/web/wallaby_test.exs rename to test/nimble_template/addons/variants/web/wallaby_test.exs index 4d3abbd3..e8fb48fc 100644 --- a/test/nimble.phx.gen.template/addons/variants/web/wallaby_test.exs +++ b/test/nimble_template/addons/variants/web/wallaby_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.AddonsWeb.WallabyTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule Nimble.Template.AddonsWeb.WallabyTest do + use Nimble.Template.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:wallaby, "0.26.2"}] @@ -13,16 +13,16 @@ defmodule Nimble.Phx.Gen.Template.AddonsWeb.WallabyTest do assert_file("test/support/feature_case.ex", fn file -> assert file =~ """ - defmodule NimblePhxGenTemplateWeb.FeatureCase do + defmodule NimbleTemplateWeb.FeatureCase do use ExUnit.CaseTemplate using do quote do use Wallaby.Feature - import NimblePhxGenTemplate.Factory + import NimbleTemplate.Factory - alias NimblePhxGenTemplateWeb.Router.Helpers, as: Routes + alias NimbleTemplateWeb.Router.Helpers, as: Routes end end end @@ -38,7 +38,7 @@ defmodule Nimble.Phx.Gen.Template.AddonsWeb.WallabyTest do in_test_project(test_project_path, fn -> AddonsWeb.Wallaby.apply(project) - assert_file("test/nimble_phx_gen_template_web/features/home_page/view_home_page_test.exs") + assert_file("test/nimble_template_web/features/home_page/view_home_page_test.exs") end) end @@ -71,26 +71,26 @@ defmodule Nimble.Phx.Gen.Template.AddonsWeb.WallabyTest do {:ok, _} = Application.ensure_all_started(:wallaby) ExUnit.start() - Ecto.Adapters.SQL.Sandbox.mode(NimblePhxGenTemplate.Repo, :manual) + Ecto.Adapters.SQL.Sandbox.mode(NimbleTemplate.Repo, :manual) - Application.put_env(:wallaby, :base_url, NimblePhxGenTemplateWeb.Endpoint.url()) + Application.put_env(:wallaby, :base_url, NimbleTemplateWeb.Endpoint.url()) """ end) end) end - test "updates lib/nimble_phx_gen_template_web/endpoint.ex", %{ + test "updates lib/nimble_template_web/endpoint.ex", %{ project: project, test_project_path: test_project_path } do in_test_project(test_project_path, fn -> AddonsWeb.Wallaby.apply(project) - assert_file("lib/nimble_phx_gen_template_web/endpoint.ex", fn file -> + assert_file("lib/nimble_template_web/endpoint.ex", fn file -> assert file =~ """ - use Phoenix.Endpoint, otp_app: :nimble_phx_gen_template + use Phoenix.Endpoint, otp_app: :nimble_template - if Application.get_env(:nimble_phx_gen_template, :sql_sandbox) do + if Application.get_env(:nimble_template, :sql_sandbox) do plug Phoenix.Ecto.SQL.Sandbox end """ @@ -107,14 +107,14 @@ defmodule Nimble.Phx.Gen.Template.AddonsWeb.WallabyTest do assert_file("config/test.exs", fn file -> assert file =~ """ - config :nimble_phx_gen_template, NimblePhxGenTemplateWeb.Endpoint, + config :nimble_template, NimbleTemplateWeb.Endpoint, http: [port: 4002], server: true - config :nimble_phx_gen_template, :sql_sandbox, true + config :nimble_template, :sql_sandbox, true config :wallaby, - otp_app: :nimble_phx_gen_template, + otp_app: :nimble_template, chromedriver: [headless: System.get_env("CHROME_HEADLESS", "true") === "true"], screenshot_dir: "tmp/wallaby_screenshots", screenshot_on_failure: true diff --git a/test/nimble.phx.gen.template/release_version_test.exs b/test/nimble_template/release_version_test.exs similarity index 55% rename from test/nimble.phx.gen.template/release_version_test.exs rename to test/nimble_template/release_version_test.exs index 37031d54..888a62f0 100644 --- a/test/nimble.phx.gen.template/release_version_test.exs +++ b/test/nimble_template/release_version_test.exs @@ -1,12 +1,12 @@ -defmodule Nimble.Phx.Gen.Template.ReleaseVersionTest do +defmodule Nimble.Template.ReleaseVersionTest do use ExUnit.Case, async: true - alias Nimble.Phx.Gen.Template.Hex.Package + alias Nimble.Template.Hex.Package @tag :release_version test "the new version is greater than the hex version" do new_version = Mix.Project.config()[:version] - hex_version = Package.get_latest_version("nimble_phx_gen_template") + hex_version = Package.get_latest_version("nimble_template") assert new_version > hex_version end diff --git a/test/support/addon_case.ex b/test/support/addon_case.ex index a936d281..50433a10 100644 --- a/test/support/addon_case.ex +++ b/test/support/addon_case.ex @@ -1,16 +1,16 @@ -defmodule Nimble.Phx.Gen.Template.AddonCase do +defmodule Nimble.Template.AddonCase do use ExUnit.CaseTemplate use Mimic - alias Nimble.Phx.Gen.Template.Addons.Web, as: AddonsWeb - alias Nimble.Phx.Gen.Template.{Addons, Project} - alias Nimble.Phx.Gen.Template.Hex.Package + alias Nimble.Template.Addons.Web, as: AddonsWeb + alias Nimble.Template.{Addons, Project} + alias Nimble.Template.Hex.Package using do quote do - alias Nimble.Phx.Gen.Template.Addons - alias Nimble.Phx.Gen.Template.Addons.Web, as: AddonsWeb + alias Nimble.Template.Addons + alias Nimble.Template.Addons.Web, as: AddonsWeb # ATTENTION: File.cd! doesn't support `async: true`, the test will fail randomly in async mode # https://elixirforum.com/t/randomly-getting-compilationerror-on-tests/17298/3 @@ -31,7 +31,7 @@ defmodule Nimble.Phx.Gen.Template.AddonCase do setup context do parent_test_project_path = Path.join(tmp_path(), parent_test_project_path()) - test_project_path = Path.join(parent_test_project_path, "/nimble_phx_gen_template") + test_project_path = Path.join(parent_test_project_path, "/nimble_template") project = if context[:mix_project?] == true do diff --git a/test/test_helper.exs b/test/test_helper.exs index e6701419..a3115b9f 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -3,7 +3,7 @@ Code.put_compiler_option(:warnings_as_errors, true) {:ok, _} = Application.ensure_all_started(:mimic) Mimic.copy(Calendar) -Mimic.copy(Nimble.Phx.Gen.Template.Hex.Package) +Mimic.copy(Nimble.Template.Hex.Package) ExUnit.start() ExUnit.configure(exclude: :release_version) From 09f1906e892f4c5751f250b74a58b857f1c82b5f Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:16:03 +0700 Subject: [PATCH 23/52] Increase the composite version --- .github/workflows/test_api_variant_on_custom_api_project.yml | 2 +- .github/workflows/test_api_variant_on_standard_api_project.yml | 2 +- .../workflows/test_live_variant_on_custom_liveview_project.yml | 2 +- .../test_live_variant_on_standard_liveview_project.yml | 2 +- .github/workflows/test_variant_on_custom_web_project.yml | 2 +- .github/workflows/test_variant_on_standard_web_project.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_api_variant_on_custom_api_project.yml b/.github/workflows/test_api_variant_on_custom_api_project.yml index 50293928..6d3f00d4 100644 --- a/.github/workflows/test_api_variant_on_custom_api_project.yml +++ b/.github/workflows/test_api_variant_on_custom_api_project.yml @@ -43,7 +43,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '--no-html --no-webpack --module=CustomModule --app=custom_app' variant: 'api' diff --git a/.github/workflows/test_api_variant_on_standard_api_project.yml b/.github/workflows/test_api_variant_on_standard_api_project.yml index 47a15589..bcbc0ecf 100644 --- a/.github/workflows/test_api_variant_on_standard_api_project.yml +++ b/.github/workflows/test_api_variant_on_standard_api_project.yml @@ -43,7 +43,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '--no-html --no-webpack' variant: 'api' diff --git a/.github/workflows/test_live_variant_on_custom_liveview_project.yml b/.github/workflows/test_live_variant_on_custom_liveview_project.yml index f9304564..eb267c0e 100644 --- a/.github/workflows/test_live_variant_on_custom_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_custom_liveview_project.yml @@ -63,7 +63,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '--live --module=CustomModule --app=custom_app' variant: 'live' diff --git a/.github/workflows/test_live_variant_on_standard_liveview_project.yml b/.github/workflows/test_live_variant_on_standard_liveview_project.yml index cd1a7607..3f241051 100644 --- a/.github/workflows/test_live_variant_on_standard_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_standard_liveview_project.yml @@ -63,7 +63,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '--live' variant: 'live' diff --git a/.github/workflows/test_variant_on_custom_web_project.yml b/.github/workflows/test_variant_on_custom_web_project.yml index 08f9c388..b3bd99ec 100644 --- a/.github/workflows/test_variant_on_custom_web_project.yml +++ b/.github/workflows/test_variant_on_custom_web_project.yml @@ -67,7 +67,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '--module=CustomModule --app=custom_app' variant: ${{ matrix.variant }} diff --git a/.github/workflows/test_variant_on_standard_web_project.yml b/.github/workflows/test_variant_on_standard_web_project.yml index b3e01f94..2ddfedba 100644 --- a/.github/workflows/test_variant_on_standard_web_project.yml +++ b/.github/workflows/test_variant_on_standard_web_project.yml @@ -67,7 +67,7 @@ jobs: restore-keys: | ${{ runner.os }}-npm-packages- - - uses: nimblehq/elixir-templates@composite_1.2 + - uses: nimblehq/elixir-templates@composite_1.3 with: new_project_options: '' variant: ${{ matrix.variant }} From 6989d668cb5b454dbeff7ac5ef209cb3d3facc39 Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:36:42 +0700 Subject: [PATCH 24/52] Increase the composite version --- Makefile | 8 ++++---- README.md | 12 ++++++------ ....template.gen.ex => nimble_template.gen.ex} | 18 +++++++++--------- lib/nimble_template/addon.ex | 8 ++++---- lib/nimble_template/addons/credo.ex | 4 ++-- lib/nimble_template/addons/dialyxir.ex | 4 ++-- lib/nimble_template/addons/docker.ex | 4 ++-- lib/nimble_template/addons/elixir_version.ex | 4 ++-- lib/nimble_template/addons/ex_coveralls.ex | 4 ++-- lib/nimble_template/addons/ex_machina.ex | 4 ++-- lib/nimble_template/addons/github.ex | 4 ++-- lib/nimble_template/addons/makefile.ex | 4 ++-- lib/nimble_template/addons/mimic.ex | 4 ++-- lib/nimble_template/addons/mix_release.ex | 4 ++-- lib/nimble_template/addons/oban.ex | 4 ++-- lib/nimble_template/addons/readme.ex | 4 ++-- lib/nimble_template/addons/test_env.ex | 4 ++-- .../addons/variants/web/assets.ex | 4 ++-- .../addons/variants/web/core_js.ex | 4 ++-- .../addons/variants/web/sobelow.ex | 4 ++-- .../addons/variants/web/wallaby.ex | 4 ++-- lib/nimble_template/generator.ex | 2 +- lib/nimble_template/hex/hex_client.ex | 4 ++-- lib/nimble_template/hex/package.ex | 4 ++-- .../http_client/http_adapter.ex | 2 +- lib/nimble_template/project.ex | 2 +- lib/nimble_template/template.ex | 12 ++++++------ lib/nimble_template/variants/api/template.ex | 4 ++-- lib/nimble_template/variants/live/template.ex | 6 +++--- lib/nimble_template/variants/mix/template.ex | 6 +++--- lib/nimble_template/variants/web/template.ex | 6 +++--- mix.exs | 2 +- test/nimble_template/addons/credo_test.exs | 4 ++-- test/nimble_template/addons/dialyxir_test.exs | 4 ++-- test/nimble_template/addons/docker_test.exs | 4 ++-- .../addons/elixir_version_test.exs | 4 ++-- .../addons/ex_coveralls_test.exs | 4 ++-- .../nimble_template/addons/ex_machina_test.exs | 4 ++-- test/nimble_template/addons/github_test.exs | 4 ++-- test/nimble_template/addons/makefile_test.exs | 4 ++-- test/nimble_template/addons/mimic_test.exs | 4 ++-- .../addons/mix_release_test.exs | 4 ++-- test/nimble_template/addons/oban_test.exs | 4 ++-- test/nimble_template/addons/readme_test.exs | 4 ++-- test/nimble_template/addons/test_env_test.exs | 4 ++-- .../addons/variants/web/assets_test.exs | 4 ++-- .../addons/variants/web/core_js_test.exs | 4 ++-- .../addons/variants/web/sobelow_test.exs | 4 ++-- .../addons/variants/web/wallaby_test.exs | 4 ++-- test/nimble_template/release_version_test.exs | 4 ++-- test/support/addon_case.ex | 12 ++++++------ test/test_helper.exs | 2 +- 52 files changed, 125 insertions(+), 125 deletions(-) rename lib/mix/tasks/{nimble.template.gen.ex => nimble_template.gen.ex} (69%) diff --git a/Makefile b/Makefile index 9f3eccad..a4cdb0fe 100644 --- a/Makefile +++ b/Makefile @@ -39,11 +39,11 @@ apply_phoenix_template: mix deps.get && \ mix format && \ if [ $(VARIANT) = web ]; then \ - printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --web; \ + printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --web; \ elif [ $(VARIANT) = api ]; then \ - printf "${common_addon_prompts}${api_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --api; \ + printf "${common_addon_prompts}${api_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --api; \ elif [ $(VARIANT) = live ]; then \ - printf "${common_addon_prompts}${web_addon_prompts}${live_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --live; \ + printf "${common_addon_prompts}${web_addon_prompts}${live_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --live; \ fi; apply_mix_template: @@ -53,7 +53,7 @@ apply_mix_template: rm nimble_template.txt && \ mix deps.get && \ mix format && \ - printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble.template.gen --mix; \ + printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --mix; \ remove_nimble_template: cd ${PROJECT_DIRECTORY} && \ diff --git a/README.md b/README.md index 9d1af7c9..728ec4e1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Phoenix template for projects at [Nimble](https://nimblehq.co/). ## Prerequisites -NimblePhxGenTemplate has been developed and actively tested with the below environment: +NimbleTemplate has been developed and actively tested with the below environment: - Elixir 1.11.4 - Erlang/OTP 23.3 @@ -12,7 +12,7 @@ NimblePhxGenTemplate has been developed and actively tested with the below envir ## Installation -*Note:* NimblePhxGenTemplate only works on a _new_ Phoenix/Mix project, applying it to an existing Phoenix/Mix project might not work as expected. +*Note:* NimbleTemplate only works on a _new_ Phoenix/Mix project, applying it to an existing Phoenix/Mix project might not work as expected. Step 1: Generate a new project @@ -37,7 +37,7 @@ end Step 3: Fetch and install dependencies -Run this command in the root of the project directory to install NimblePhxGenTemplate. +Run this command in the root of the project directory to install NimbleTemplate. ```bash mix do deps.get, deps.compile @@ -56,12 +56,12 @@ mix nimble_template --api # Apply the API template mix nimble_template --live # Apply the LiveView template # Non-Phoenix application -mix nimble.template.gen --mix # Apply the Mix template +mix nimble_template.gen --mix # Apply the Mix template ``` ## Running tests -NimblePhxGenTemplate uses Github Action as the CI, the workflow files locate under [.github/workflows/](https://github.com/nimblehq/elixir-templates/tree/develop/.github/workflows) directory. +NimbleTemplate uses Github Action as the CI, the workflow files locate under [.github/workflows/](https://github.com/nimblehq/elixir-templates/tree/develop/.github/workflows) directory. There are 2 types of test **Template test** and **Variant test** @@ -98,7 +98,7 @@ All test files are located under `test/` directory. #### 2.1/ Variant -NimblePhxGenTemplate supports 4 variants: +NimbleTemplate supports 4 variants: - API - Live diff --git a/lib/mix/tasks/nimble.template.gen.ex b/lib/mix/tasks/nimble_template.gen.ex similarity index 69% rename from lib/mix/tasks/nimble.template.gen.ex rename to lib/mix/tasks/nimble_template.gen.ex index 25c25c9b..91e1ba8a 100644 --- a/lib/mix/tasks/nimble.template.gen.ex +++ b/lib/mix/tasks/nimble_template.gen.ex @@ -1,4 +1,4 @@ -defmodule Mix.Tasks.Nimble.Template.Gen do +defmodule Mix.Tasks.NimbleTemplate.Gen do @shortdoc "Apply Nimble's Elixir/Phoenix template" @moduledoc """ @@ -9,31 +9,31 @@ defmodule Mix.Tasks.Nimble.Template.Gen do # Usage - - mix nimble.template.gen -v # Print the version + - mix nimble_template.gen -v # Print the version ### Phoenix application - - mix nimble.template.gen --api # Apply the Phoenix API template - - mix nimble.template.gen --live # Apply the Phoenix LiveView template - - mix nimble.template.gen --web # Apply the Phoenix Web template + - mix nimble_template.gen --api # Apply the Phoenix API template + - mix nimble_template.gen --live # Apply the Phoenix LiveView template + - mix nimble_template.gen --web # Apply the Phoenix Web template ### Non-Phoenix application - - mix nimble.template.gen --mix # Apply the Mix template + - mix nimble_template.gen --mix # Apply the Mix template """ use Mix.Task - alias Nimble.Template.{Project, Template} + alias NimbleTemplate.{Project, Template} @version Mix.Project.config()[:version] @variants [api: :boolean, web: :boolean, live: :boolean, mix: :boolean] - def run([args]) when args in ~w(-v --version), do: Mix.shell().info("Nimble.Template v#{@version}") + def run([args]) when args in ~w(-v --version), do: Mix.shell().info("NimbleTemplate v#{@version}") def run(args) do if Mix.Project.umbrella?() do - Mix.raise("mix nimble.template.gen can only be run inside an application directory") + Mix.raise("mix nimble_template.gen can only be run inside an application directory") end {opts, _params} = parse_opts(args) diff --git a/lib/nimble_template/addon.ex b/lib/nimble_template/addon.ex index c0880e8e..60067ed7 100644 --- a/lib/nimble_template/addon.ex +++ b/lib/nimble_template/addon.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addon do - alias Nimble.Template.{Addon, Project} +defmodule NimbleTemplate.Addon do + alias NimbleTemplate.{Addon, Project} @callback apply(%Project{}, %{}) :: %Project{} @callback do_apply(%Project{}, %{}) :: %Project{} @@ -8,8 +8,8 @@ defmodule Nimble.Template.Addon do quote location: :keep, bind_quoted: [opts: opts] do @behaviour Addon - alias Nimble.Template.{Generator, Project} - alias Nimble.Template.Hex.Package + alias NimbleTemplate.{Generator, Project} + alias NimbleTemplate.Hex.Package def apply(%Project{} = project, opts \\ %{}) when is_map(opts) do Generator.print_log("* applying ", inspect(__MODULE__)) diff --git a/lib/nimble_template/addons/credo.ex b/lib/nimble_template/addons/credo.ex index d13b3d87..ad559dd4 100644 --- a/lib/nimble_template/addons/credo.ex +++ b/lib/nimble_template/addons/credo.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Credo do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Credo do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/dialyxir.ex b/lib/nimble_template/addons/dialyxir.ex index dfc82066..118ecbdc 100644 --- a/lib/nimble_template/addons/dialyxir.ex +++ b/lib/nimble_template/addons/dialyxir.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Dialyxir do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Dialyxir do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/docker.ex b/lib/nimble_template/addons/docker.ex index 38991397..79710882 100644 --- a/lib/nimble_template/addons/docker.ex +++ b/lib/nimble_template/addons/docker.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Docker do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Docker do + use NimbleTemplate.Addon @impl true def do_apply( diff --git a/lib/nimble_template/addons/elixir_version.ex b/lib/nimble_template/addons/elixir_version.ex index 7b10f0dc..01b50623 100644 --- a/lib/nimble_template/addons/elixir_version.ex +++ b/lib/nimble_template/addons/elixir_version.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ElixirVersion do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.ElixirVersion do + use NimbleTemplate.Addon @impl true def do_apply( diff --git a/lib/nimble_template/addons/ex_coveralls.ex b/lib/nimble_template/addons/ex_coveralls.ex index 083a4709..5172ad76 100644 --- a/lib/nimble_template/addons/ex_coveralls.ex +++ b/lib/nimble_template/addons/ex_coveralls.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ExCoveralls do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.ExCoveralls do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/ex_machina.ex b/lib/nimble_template/addons/ex_machina.ex index ac552cb9..c38dc9de 100644 --- a/lib/nimble_template/addons/ex_machina.ex +++ b/lib/nimble_template/addons/ex_machina.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ExMachina do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.ExMachina do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/github.ex b/lib/nimble_template/addons/github.ex index 6d05d24d..3fa964e7 100644 --- a/lib/nimble_template/addons/github.ex +++ b/lib/nimble_template/addons/github.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Github do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Github do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, opts) when is_map_key(opts, :github_template) do diff --git a/lib/nimble_template/addons/makefile.ex b/lib/nimble_template/addons/makefile.ex index c8ad3230..11a0726b 100644 --- a/lib/nimble_template/addons/makefile.ex +++ b/lib/nimble_template/addons/makefile.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Makefile do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Makefile do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/mimic.ex b/lib/nimble_template/addons/mimic.ex index a1332b23..b122ebcc 100644 --- a/lib/nimble_template/addons/mimic.ex +++ b/lib/nimble_template/addons/mimic.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Mimic do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Mimic do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/mix_release.ex b/lib/nimble_template/addons/mix_release.ex index 8b5c3f8f..69e45bfb 100644 --- a/lib/nimble_template/addons/mix_release.ex +++ b/lib/nimble_template/addons/mix_release.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.MixRelease do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.MixRelease do + use NimbleTemplate.Addon @prod_secret_path "config/prod.secret.exs" diff --git a/lib/nimble_template/addons/oban.ex b/lib/nimble_template/addons/oban.ex index fec5efcc..561888a6 100644 --- a/lib/nimble_template/addons/oban.ex +++ b/lib/nimble_template/addons/oban.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Oban do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Oban do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/readme.ex b/lib/nimble_template/addons/readme.ex index 7ef4e5ef..d5d0e236 100644 --- a/lib/nimble_template/addons/readme.ex +++ b/lib/nimble_template/addons/readme.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Readme do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Readme do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/test_env.ex b/lib/nimble_template/addons/test_env.ex index 61ef8d90..19a93d4e 100644 --- a/lib/nimble_template/addons/test_env.ex +++ b/lib/nimble_template/addons/test_env.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.TestEnv do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.TestEnv do + use NimbleTemplate.Addon @impl true def do_apply(%Project{mix_project?: true} = project, _opts) do diff --git a/lib/nimble_template/addons/variants/web/assets.ex b/lib/nimble_template/addons/variants/web/assets.ex index 8c740cd4..91faa738 100644 --- a/lib/nimble_template/addons/variants/web/assets.ex +++ b/lib/nimble_template/addons/variants/web/assets.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Web.Assets do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Web.Assets do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/variants/web/core_js.ex b/lib/nimble_template/addons/variants/web/core_js.ex index 278e3d2a..e67ced9d 100644 --- a/lib/nimble_template/addons/variants/web/core_js.ex +++ b/lib/nimble_template/addons/variants/web/core_js.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Web.CoreJS do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Web.CoreJS do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/variants/web/sobelow.ex b/lib/nimble_template/addons/variants/web/sobelow.ex index 1d938661..83f0a3fe 100644 --- a/lib/nimble_template/addons/variants/web/sobelow.ex +++ b/lib/nimble_template/addons/variants/web/sobelow.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Web.Sobelow do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Web.Sobelow do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/addons/variants/web/wallaby.ex b/lib/nimble_template/addons/variants/web/wallaby.ex index dc1eeff5..483dfeff 100644 --- a/lib/nimble_template/addons/variants/web/wallaby.ex +++ b/lib/nimble_template/addons/variants/web/wallaby.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.Web.Wallaby do - use Nimble.Template.Addon +defmodule NimbleTemplate.Addons.Web.Wallaby do + use NimbleTemplate.Addon @impl true def do_apply(%Project{} = project, _opts) do diff --git a/lib/nimble_template/generator.ex b/lib/nimble_template/generator.ex index 61f7d6cc..8c1d2037 100644 --- a/lib/nimble_template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -1,4 +1,4 @@ -defmodule Nimble.Template.Generator do +defmodule NimbleTemplate.Generator do @template_resource "priv/templates/nimble_template" def copy_file(files, binding \\ []) do diff --git a/lib/nimble_template/hex/hex_client.ex b/lib/nimble_template/hex/hex_client.ex index eb854576..33d72e06 100644 --- a/lib/nimble_template/hex/hex_client.ex +++ b/lib/nimble_template/hex/hex_client.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Hex.HexClient do - alias Nimble.Template.HttpClient.HttpAdapter +defmodule NimbleTemplate.Hex.HexClient do + alias NimbleTemplate.HttpClient.HttpAdapter @base_url "https://hex.pm/api/" diff --git a/lib/nimble_template/hex/package.ex b/lib/nimble_template/hex/package.ex index 2e6fffd0..d8131e30 100644 --- a/lib/nimble_template/hex/package.ex +++ b/lib/nimble_template/hex/package.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Hex.Package do - alias Nimble.Template.Hex.HexClient +defmodule NimbleTemplate.Hex.Package do + alias NimbleTemplate.Hex.HexClient def get_latest_version(package) do {:ok, package_info} = HexClient.get("packages/#{package}") diff --git a/lib/nimble_template/http_client/http_adapter.ex b/lib/nimble_template/http_client/http_adapter.ex index b36c780d..a0ea2c2f 100644 --- a/lib/nimble_template/http_client/http_adapter.ex +++ b/lib/nimble_template/http_client/http_adapter.ex @@ -1,3 +1,3 @@ -defmodule Nimble.Template.HttpClient.HttpAdapter do +defmodule NimbleTemplate.HttpClient.HttpAdapter do use HTTPoison.Base end diff --git a/lib/nimble_template/project.ex b/lib/nimble_template/project.ex index 5ab0369f..9db3ab4f 100644 --- a/lib/nimble_template/project.ex +++ b/lib/nimble_template/project.ex @@ -1,4 +1,4 @@ -defmodule Nimble.Phx.Gen.Template.Project do +defmodule NimbleTemplate.Project do @elixir_version "1.11.4" @erlang_version "23.3" @node_version "14" diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index 0e90a1b0..aa5f4c7c 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -1,9 +1,9 @@ -defmodule Nimble.Template.Template do - alias Nimble.Template.Api.Template, as: ApiTemplate - alias Nimble.Template.Live.Template, as: LiveTemplate - alias Nimble.Template.Mix.Template, as: MixTemplate - alias Nimble.Template.Web.Template, as: WebTemplate - alias Nimble.Template.{Addons, Project} +defmodule NimbleTemplate.Template do + alias NimbleTemplate.Api.Template, as: ApiTemplate + alias NimbleTemplate.Live.Template, as: LiveTemplate + alias NimbleTemplate.Mix.Template, as: MixTemplate + alias NimbleTemplate.Web.Template, as: WebTemplate + alias NimbleTemplate.{Addons, Project} def apply(%Project{mix_project?: true} = project) do MixTemplate.apply(project) diff --git a/lib/nimble_template/variants/api/template.ex b/lib/nimble_template/variants/api/template.ex index 527dbb03..bf428a2a 100644 --- a/lib/nimble_template/variants/api/template.ex +++ b/lib/nimble_template/variants/api/template.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Api.Template do - alias Nimble.Template.Project +defmodule NimbleTemplate.Api.Template do + alias NimbleTemplate.Project def apply(%Project{} = project) do project diff --git a/lib/nimble_template/variants/live/template.ex b/lib/nimble_template/variants/live/template.ex index 3827a02f..28b90aec 100644 --- a/lib/nimble_template/variants/live/template.ex +++ b/lib/nimble_template/variants/live/template.ex @@ -1,6 +1,6 @@ -defmodule Nimble.Template.Live.Template do - alias Nimble.Template.Project - alias Nimble.Template.Web.Template, as: WebTemplate +defmodule NimbleTemplate.Live.Template do + alias NimbleTemplate.Project + alias NimbleTemplate.Web.Template, as: WebTemplate def apply(%Project{} = project) do WebTemplate.apply(project) diff --git a/lib/nimble_template/variants/mix/template.ex b/lib/nimble_template/variants/mix/template.ex index fd3a2cb1..1e1c91ca 100644 --- a/lib/nimble_template/variants/mix/template.ex +++ b/lib/nimble_template/variants/mix/template.ex @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Mix.Template do - import Nimble.Template.Template, +defmodule NimbleTemplate.Mix.Template do + import NimbleTemplate.Template, only: [ host_on_github?: 0, generate_github_template?: 0, @@ -7,7 +7,7 @@ defmodule Nimble.Template.Mix.Template do install_addon_prompt?: 1 ] - alias Nimble.Template.{Addons, Project} + alias NimbleTemplate.{Addons, Project} def apply(%Project{} = project) do project diff --git a/lib/nimble_template/variants/web/template.ex b/lib/nimble_template/variants/web/template.ex index 690252b7..1c99d4a0 100644 --- a/lib/nimble_template/variants/web/template.ex +++ b/lib/nimble_template/variants/web/template.ex @@ -1,6 +1,6 @@ -defmodule Nimble.Template.Web.Template do - alias Nimble.Template.Addons.Web - alias Nimble.Template.Project +defmodule NimbleTemplate.Web.Template do + alias NimbleTemplate.Addons.Web + alias NimbleTemplate.Project def apply(%Project{} = project) do project diff --git a/mix.exs b/mix.exs index ae70af9f..f211e5fa 100644 --- a/mix.exs +++ b/mix.exs @@ -1,4 +1,4 @@ -defmodule Nimble.Template.MixProject do +defmodule NimbleTemplate.MixProject do use Mix.Project def project do diff --git a/test/nimble_template/addons/credo_test.exs b/test/nimble_template/addons/credo_test.exs index f9ef9934..47d4d7ff 100644 --- a/test/nimble_template/addons/credo_test.exs +++ b/test/nimble_template/addons/credo_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.CredoTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.CredoTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "1.4"}] diff --git a/test/nimble_template/addons/dialyxir_test.exs b/test/nimble_template/addons/dialyxir_test.exs index 19e23175..e13d0a9e 100644 --- a/test/nimble_template/addons/dialyxir_test.exs +++ b/test/nimble_template/addons/dialyxir_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.DialyxirTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.DialyxirTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:dialyxir, "1.0"}] diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index 33ae3b9e..dc8a6b87 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.DockerTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.DockerTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "copies the docker-compose.dev.yml", %{ diff --git a/test/nimble_template/addons/elixir_version_test.exs b/test/nimble_template/addons/elixir_version_test.exs index 813ab809..17ce9cd9 100644 --- a/test/nimble_template/addons/elixir_version_test.exs +++ b/test/nimble_template/addons/elixir_version_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ElixirVersionTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.ElixirVersionTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "copies the .tool-versions", %{ diff --git a/test/nimble_template/addons/ex_coveralls_test.exs b/test/nimble_template/addons/ex_coveralls_test.exs index 6a319911..0c52e53c 100644 --- a/test/nimble_template/addons/ex_coveralls_test.exs +++ b/test/nimble_template/addons/ex_coveralls_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ExCoverallsTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.ExCoverallsTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:excoveralls, "0.12.2"}] diff --git a/test/nimble_template/addons/ex_machina_test.exs b/test/nimble_template/addons/ex_machina_test.exs index 41445bf5..4716e142 100644 --- a/test/nimble_template/addons/ex_machina_test.exs +++ b/test/nimble_template/addons/ex_machina_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ExMachinaTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.ExMachinaTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:ex_machina, "2.4"}] diff --git a/test/nimble_template/addons/github_test.exs b/test/nimble_template/addons/github_test.exs index 7f34e934..aea57b7b 100644 --- a/test/nimble_template/addons/github_test.exs +++ b/test/nimble_template/addons/github_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.GithubTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.GithubTest do + use NimbleTemplate.AddonCase describe "#apply/2 with github_template option" do test "copies the .github/ISSUE_TEMPLATE.md", %{ diff --git a/test/nimble_template/addons/makefile_test.exs b/test/nimble_template/addons/makefile_test.exs index b2f48a61..cc131386 100644 --- a/test/nimble_template/addons/makefile_test.exs +++ b/test/nimble_template/addons/makefile_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.MakefileTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.MakefileTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "copies the Makefile", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/mimic_test.exs b/test/nimble_template/addons/mimic_test.exs index d71c9796..4eb3e2db 100644 --- a/test/nimble_template/addons/mimic_test.exs +++ b/test/nimble_template/addons/mimic_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.MimicTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.MimicTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:mimic, "1.3.1"}] diff --git a/test/nimble_template/addons/mix_release_test.exs b/test/nimble_template/addons/mix_release_test.exs index da3c4a3c..cfb3a9d3 100644 --- a/test/nimble_template/addons/mix_release_test.exs +++ b/test/nimble_template/addons/mix_release_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.MixReleaseTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.MixReleaseTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "deletes the import_config \"prod.secret.exs\" in config/prod.exs", %{ diff --git a/test/nimble_template/addons/oban_test.exs b/test/nimble_template/addons/oban_test.exs index 1ebe5a74..5c5968ce 100644 --- a/test/nimble_template/addons/oban_test.exs +++ b/test/nimble_template/addons/oban_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ObanTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.ObanTest do + use NimbleTemplate.AddonCase use Mimic describe "#apply/2" do diff --git a/test/nimble_template/addons/readme_test.exs b/test/nimble_template/addons/readme_test.exs index e1572a30..8fa06fc5 100644 --- a/test/nimble_template/addons/readme_test.exs +++ b/test/nimble_template/addons/readme_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.ReadmeTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.ReadmeTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "copies the README.md", %{ diff --git a/test/nimble_template/addons/test_env_test.exs b/test/nimble_template/addons/test_env_test.exs index 84c17ae3..067e3bfa 100644 --- a/test/nimble_template/addons/test_env_test.exs +++ b/test/nimble_template/addons/test_env_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.Addons.TestEnvTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.Addons.TestEnvTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "injects the DB_HOST ENV", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/variants/web/assets_test.exs b/test/nimble_template/addons/variants/web/assets_test.exs index 4f990502..b566bd8e 100644 --- a/test/nimble_template/addons/variants/web/assets_test.exs +++ b/test/nimble_template/addons/variants/web/assets_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.AddonsWeb.AssetsTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.AddonsWeb.AssetsTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "adds assets.compile alias", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/variants/web/core_js_test.exs b/test/nimble_template/addons/variants/web/core_js_test.exs index e82bb9d0..45f4a978 100644 --- a/test/nimble_template/addons/variants/web/core_js_test.exs +++ b/test/nimble_template/addons/variants/web/core_js_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.AddonsWeb.CoreJSTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.AddonsWeb.CoreJSTest do + use NimbleTemplate.AddonCase describe "#apply/2" do test "adds core-js into package.json", %{ diff --git a/test/nimble_template/addons/variants/web/sobelow_test.exs b/test/nimble_template/addons/variants/web/sobelow_test.exs index 4f704db0..5578b66f 100644 --- a/test/nimble_template/addons/variants/web/sobelow_test.exs +++ b/test/nimble_template/addons/variants/web/sobelow_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.AddonsWeb.SobelowTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.AddonsWeb.SobelowTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "0.26.2"}, {:sobelow, "0.8"}] diff --git a/test/nimble_template/addons/variants/web/wallaby_test.exs b/test/nimble_template/addons/variants/web/wallaby_test.exs index e8fb48fc..9f0e7ae0 100644 --- a/test/nimble_template/addons/variants/web/wallaby_test.exs +++ b/test/nimble_template/addons/variants/web/wallaby_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Template.AddonsWeb.WallabyTest do - use Nimble.Template.AddonCase +defmodule NimbleTemplate.AddonsWeb.WallabyTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:wallaby, "0.26.2"}] diff --git a/test/nimble_template/release_version_test.exs b/test/nimble_template/release_version_test.exs index 888a62f0..00fed614 100644 --- a/test/nimble_template/release_version_test.exs +++ b/test/nimble_template/release_version_test.exs @@ -1,7 +1,7 @@ -defmodule Nimble.Template.ReleaseVersionTest do +defmodule NimbleTemplate.ReleaseVersionTest do use ExUnit.Case, async: true - alias Nimble.Template.Hex.Package + alias NimbleTemplate.Hex.Package @tag :release_version test "the new version is greater than the hex version" do diff --git a/test/support/addon_case.ex b/test/support/addon_case.ex index 50433a10..6902324c 100644 --- a/test/support/addon_case.ex +++ b/test/support/addon_case.ex @@ -1,16 +1,16 @@ -defmodule Nimble.Template.AddonCase do +defmodule NimbleTemplate.AddonCase do use ExUnit.CaseTemplate use Mimic - alias Nimble.Template.Addons.Web, as: AddonsWeb - alias Nimble.Template.{Addons, Project} - alias Nimble.Template.Hex.Package + alias NimbleTemplate.Addons.Web, as: AddonsWeb + alias NimbleTemplate.{Addons, Project} + alias NimbleTemplate.Hex.Package using do quote do - alias Nimble.Template.Addons - alias Nimble.Template.Addons.Web, as: AddonsWeb + alias NimbleTemplate.Addons + alias NimbleTemplate.Addons.Web, as: AddonsWeb # ATTENTION: File.cd! doesn't support `async: true`, the test will fail randomly in async mode # https://elixirforum.com/t/randomly-getting-compilationerror-on-tests/17298/3 diff --git a/test/test_helper.exs b/test/test_helper.exs index a3115b9f..70afb8bd 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -3,7 +3,7 @@ Code.put_compiler_option(:warnings_as_errors, true) {:ok, _} = Application.ensure_all_started(:mimic) Mimic.copy(Calendar) -Mimic.copy(Nimble.Template.Hex.Package) +Mimic.copy(NimbleTemplate.Hex.Package) ExUnit.start() ExUnit.configure(exclude: :release_version) From ad1896533cafae840c63ac159401afed4781a6c1 Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:43:21 +0700 Subject: [PATCH 25/52] Adding @moduledoc false --- lib/nimble_template/addon.ex | 2 ++ lib/nimble_template/addons/credo.ex | 2 ++ lib/nimble_template/addons/dialyxir.ex | 2 ++ lib/nimble_template/addons/docker.ex | 2 ++ lib/nimble_template/addons/elixir_version.ex | 2 ++ lib/nimble_template/addons/ex_coveralls.ex | 2 ++ lib/nimble_template/addons/ex_machina.ex | 2 ++ lib/nimble_template/addons/github.ex | 2 ++ lib/nimble_template/addons/makefile.ex | 2 ++ lib/nimble_template/addons/mimic.ex | 2 ++ lib/nimble_template/addons/mix_release.ex | 2 ++ lib/nimble_template/addons/oban.ex | 2 ++ lib/nimble_template/addons/readme.ex | 2 ++ lib/nimble_template/addons/test_env.ex | 2 ++ lib/nimble_template/addons/variants/web/assets.ex | 2 ++ lib/nimble_template/addons/variants/web/core_js.ex | 2 ++ lib/nimble_template/addons/variants/web/sobelow.ex | 2 ++ lib/nimble_template/addons/variants/web/wallaby.ex | 2 ++ lib/nimble_template/generator.ex | 2 ++ lib/nimble_template/hex/hex_client.ex | 2 ++ lib/nimble_template/hex/package.ex | 2 ++ lib/nimble_template/http_client/http_adapter.ex | 2 ++ lib/nimble_template/project.ex | 2 ++ lib/nimble_template/template.ex | 2 ++ lib/nimble_template/variants/api/template.ex | 2 ++ lib/nimble_template/variants/live/template.ex | 2 ++ lib/nimble_template/variants/mix/template.ex | 2 ++ lib/nimble_template/variants/web/template.ex | 2 ++ 28 files changed, 56 insertions(+) diff --git a/lib/nimble_template/addon.ex b/lib/nimble_template/addon.ex index 60067ed7..19d86f23 100644 --- a/lib/nimble_template/addon.ex +++ b/lib/nimble_template/addon.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addon do + @moduledoc false + alias NimbleTemplate.{Addon, Project} @callback apply(%Project{}, %{}) :: %Project{} diff --git a/lib/nimble_template/addons/credo.ex b/lib/nimble_template/addons/credo.ex index ad559dd4..43be4a91 100644 --- a/lib/nimble_template/addons/credo.ex +++ b/lib/nimble_template/addons/credo.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Credo do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/dialyxir.ex b/lib/nimble_template/addons/dialyxir.ex index 118ecbdc..5e4098a5 100644 --- a/lib/nimble_template/addons/dialyxir.ex +++ b/lib/nimble_template/addons/dialyxir.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Dialyxir do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/docker.ex b/lib/nimble_template/addons/docker.ex index 79710882..a82b396a 100644 --- a/lib/nimble_template/addons/docker.ex +++ b/lib/nimble_template/addons/docker.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Docker do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/elixir_version.ex b/lib/nimble_template/addons/elixir_version.ex index 01b50623..ae6b2af0 100644 --- a/lib/nimble_template/addons/elixir_version.ex +++ b/lib/nimble_template/addons/elixir_version.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.ElixirVersion do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/ex_coveralls.ex b/lib/nimble_template/addons/ex_coveralls.ex index 5172ad76..50c00f54 100644 --- a/lib/nimble_template/addons/ex_coveralls.ex +++ b/lib/nimble_template/addons/ex_coveralls.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.ExCoveralls do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/ex_machina.ex b/lib/nimble_template/addons/ex_machina.ex index c38dc9de..a4aeca95 100644 --- a/lib/nimble_template/addons/ex_machina.ex +++ b/lib/nimble_template/addons/ex_machina.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.ExMachina do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/github.ex b/lib/nimble_template/addons/github.ex index 3fa964e7..4878171e 100644 --- a/lib/nimble_template/addons/github.ex +++ b/lib/nimble_template/addons/github.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Github do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/makefile.ex b/lib/nimble_template/addons/makefile.ex index 11a0726b..b9c277f8 100644 --- a/lib/nimble_template/addons/makefile.ex +++ b/lib/nimble_template/addons/makefile.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Makefile do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/mimic.ex b/lib/nimble_template/addons/mimic.ex index b122ebcc..ccf17ca1 100644 --- a/lib/nimble_template/addons/mimic.ex +++ b/lib/nimble_template/addons/mimic.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Mimic do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/mix_release.ex b/lib/nimble_template/addons/mix_release.ex index 69e45bfb..ec815f1e 100644 --- a/lib/nimble_template/addons/mix_release.ex +++ b/lib/nimble_template/addons/mix_release.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.MixRelease do + @moduledoc false + use NimbleTemplate.Addon @prod_secret_path "config/prod.secret.exs" diff --git a/lib/nimble_template/addons/oban.ex b/lib/nimble_template/addons/oban.ex index 561888a6..3c8f06fc 100644 --- a/lib/nimble_template/addons/oban.ex +++ b/lib/nimble_template/addons/oban.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Oban do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/readme.ex b/lib/nimble_template/addons/readme.ex index d5d0e236..43297998 100644 --- a/lib/nimble_template/addons/readme.ex +++ b/lib/nimble_template/addons/readme.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Readme do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/test_env.ex b/lib/nimble_template/addons/test_env.ex index 19a93d4e..1078d662 100644 --- a/lib/nimble_template/addons/test_env.ex +++ b/lib/nimble_template/addons/test_env.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.TestEnv do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/variants/web/assets.ex b/lib/nimble_template/addons/variants/web/assets.ex index 91faa738..ce35645e 100644 --- a/lib/nimble_template/addons/variants/web/assets.ex +++ b/lib/nimble_template/addons/variants/web/assets.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Web.Assets do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/variants/web/core_js.ex b/lib/nimble_template/addons/variants/web/core_js.ex index e67ced9d..cf218309 100644 --- a/lib/nimble_template/addons/variants/web/core_js.ex +++ b/lib/nimble_template/addons/variants/web/core_js.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Web.CoreJS do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/variants/web/sobelow.ex b/lib/nimble_template/addons/variants/web/sobelow.ex index 83f0a3fe..3982455a 100644 --- a/lib/nimble_template/addons/variants/web/sobelow.ex +++ b/lib/nimble_template/addons/variants/web/sobelow.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Web.Sobelow do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/addons/variants/web/wallaby.ex b/lib/nimble_template/addons/variants/web/wallaby.ex index 483dfeff..c86076aa 100644 --- a/lib/nimble_template/addons/variants/web/wallaby.ex +++ b/lib/nimble_template/addons/variants/web/wallaby.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Addons.Web.Wallaby do + @moduledoc false + use NimbleTemplate.Addon @impl true diff --git a/lib/nimble_template/generator.ex b/lib/nimble_template/generator.ex index 8c1d2037..e2cc612c 100644 --- a/lib/nimble_template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Generator do + @moduledoc false + @template_resource "priv/templates/nimble_template" def copy_file(files, binding \\ []) do diff --git a/lib/nimble_template/hex/hex_client.ex b/lib/nimble_template/hex/hex_client.ex index 33d72e06..3fd497ca 100644 --- a/lib/nimble_template/hex/hex_client.ex +++ b/lib/nimble_template/hex/hex_client.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Hex.HexClient do + @moduledoc false + alias NimbleTemplate.HttpClient.HttpAdapter @base_url "https://hex.pm/api/" diff --git a/lib/nimble_template/hex/package.ex b/lib/nimble_template/hex/package.ex index d8131e30..402e9ed7 100644 --- a/lib/nimble_template/hex/package.ex +++ b/lib/nimble_template/hex/package.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Hex.Package do + @moduledoc false + alias NimbleTemplate.Hex.HexClient def get_latest_version(package) do diff --git a/lib/nimble_template/http_client/http_adapter.ex b/lib/nimble_template/http_client/http_adapter.ex index a0ea2c2f..e59660ba 100644 --- a/lib/nimble_template/http_client/http_adapter.ex +++ b/lib/nimble_template/http_client/http_adapter.ex @@ -1,3 +1,5 @@ defmodule NimbleTemplate.HttpClient.HttpAdapter do + @moduledoc false + use HTTPoison.Base end diff --git a/lib/nimble_template/project.ex b/lib/nimble_template/project.ex index 9db3ab4f..2038ed41 100644 --- a/lib/nimble_template/project.ex +++ b/lib/nimble_template/project.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Project do + @moduledoc false + @elixir_version "1.11.4" @erlang_version "23.3" @node_version "14" diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index aa5f4c7c..bf9b6c1b 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Template do + @moduledoc false + alias NimbleTemplate.Api.Template, as: ApiTemplate alias NimbleTemplate.Live.Template, as: LiveTemplate alias NimbleTemplate.Mix.Template, as: MixTemplate diff --git a/lib/nimble_template/variants/api/template.ex b/lib/nimble_template/variants/api/template.ex index bf428a2a..a010e544 100644 --- a/lib/nimble_template/variants/api/template.ex +++ b/lib/nimble_template/variants/api/template.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Api.Template do + @moduledoc false + alias NimbleTemplate.Project def apply(%Project{} = project) do diff --git a/lib/nimble_template/variants/live/template.ex b/lib/nimble_template/variants/live/template.ex index 28b90aec..a1cab24b 100644 --- a/lib/nimble_template/variants/live/template.ex +++ b/lib/nimble_template/variants/live/template.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Live.Template do + @moduledoc false + alias NimbleTemplate.Project alias NimbleTemplate.Web.Template, as: WebTemplate diff --git a/lib/nimble_template/variants/mix/template.ex b/lib/nimble_template/variants/mix/template.ex index 1e1c91ca..531ef43d 100644 --- a/lib/nimble_template/variants/mix/template.ex +++ b/lib/nimble_template/variants/mix/template.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Mix.Template do + @moduledoc false + import NimbleTemplate.Template, only: [ host_on_github?: 0, diff --git a/lib/nimble_template/variants/web/template.ex b/lib/nimble_template/variants/web/template.ex index 1c99d4a0..79a98fc5 100644 --- a/lib/nimble_template/variants/web/template.ex +++ b/lib/nimble_template/variants/web/template.ex @@ -1,4 +1,6 @@ defmodule NimbleTemplate.Web.Template do + @moduledoc false + alias NimbleTemplate.Addons.Web alias NimbleTemplate.Project From bae9eb24d5373cae9eb23ccf0278f9dca8184f4c Mon Sep 17 00:00:00 2001 From: An Duong Date: Mon, 11 Jan 2021 11:44:54 +0700 Subject: [PATCH 26/52] Disable the Test Release version --- .github/workflows/test_release_version.yml | 74 +++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test_release_version.yml b/.github/workflows/test_release_version.yml index b024c039..fe67fb10 100644 --- a/.github/workflows/test_release_version.yml +++ b/.github/workflows/test_release_version.yml @@ -1,46 +1,46 @@ -name: "Test Release version" +# name: "Test Release version" -on: - push: - branches: - - 'release/**' +# on: +# push: +# branches: +# - 'release/**' -env: - OTP_VERSION: 23.3 - ELIXIR_VERSION: 1.11.4 - PHOENIX_VERSION: 1.5.7 +# env: +# OTP_VERSION: 23.3 +# ELIXIR_VERSION: 1.11.4 +# PHOENIX_VERSION: 1.5.7 -jobs: - release_version_test: - runs-on: ubuntu-latest +# jobs: +# release_version_test: +# runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} +# steps: +# - uses: actions/checkout@v2 +# with: +# ref: ${{ github.head_ref }} - - uses: erlef/setup-elixir@v1 - with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} +# - uses: erlef/setup-elixir@v1 +# with: +# otp-version: ${{ env.OTP_VERSION }} +# elixir-version: ${{ env.ELIXIR_VERSION }} - - name: Cache Elixir build - uses: actions/cache@v2 - with: - path: | - _build - deps - key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} - restore-keys: | - ${{ runner.os }}-mix- +# - name: Cache Elixir build +# uses: actions/cache@v2 +# with: +# path: | +# _build +# deps +# key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} +# restore-keys: | +# ${{ runner.os }}-mix- - - name: Install Dependencies - run: mix deps.get +# - name: Install Dependencies +# run: mix deps.get - - name: Install Phoenix ${{ env.PHOENIX_VERSION }} - run: make install_phoenix PHOENIX_VERSION=${{ env.PHOENIX_VERSION }} +# - name: Install Phoenix ${{ env.PHOENIX_VERSION }} +# run: make install_phoenix PHOENIX_VERSION=${{ env.PHOENIX_VERSION }} - - name: Run Tests - run: mix test --only release_version - env: - MIX_ENV: test +# - name: Run Tests +# run: mix test --only release_version +# env: +# MIX_ENV: test From 1f73ce660c956c07d676289c8cfe4b582ae7cef1 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:17:31 +0700 Subject: [PATCH 27/52] Minor updating --- README.md | 10 +++++----- lib/mix/tasks/nimble_template.gen.ex | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 728ec4e1..965f5d29 100644 --- a/README.md +++ b/README.md @@ -46,14 +46,14 @@ mix do deps.get, deps.compile ## Usage ```bash -mix help nimble_template # Print help +mix help nimble_template.gen # Print help -mix nimble_template -v # Print the version +mix nimble_template.gen -v # Print the version # Phoenix application -mix nimble_template --web # Apply the Web template -mix nimble_template --api # Apply the API template -mix nimble_template --live # Apply the LiveView template +mix nimble_template.gen --web # Apply the Web template +mix nimble_template.gen --api # Apply the API template +mix nimble_template.gen --live # Apply the LiveView template # Non-Phoenix application mix nimble_template.gen --mix # Apply the Mix template diff --git a/lib/mix/tasks/nimble_template.gen.ex b/lib/mix/tasks/nimble_template.gen.ex index 91e1ba8a..85533749 100644 --- a/lib/mix/tasks/nimble_template.gen.ex +++ b/lib/mix/tasks/nimble_template.gen.ex @@ -9,6 +9,7 @@ defmodule Mix.Tasks.NimbleTemplate.Gen do # Usage + - mix help nimble_template.gen # Print help - mix nimble_template.gen -v # Print the version ### Phoenix application From 5abd0bd4435fcca922b57216920755da8ab36027 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:19:44 +0700 Subject: [PATCH 28/52] Bump to 3.0.0 --- README.md | 2 +- mix.exs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 965f5d29..8ce4826a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Step 2: Add `nimble_template` dependency to `mix.exs`: ```elixir def deps do [ - {:nimble_template, "~> 2.2.0", only: :dev, runtime: false}, + {:nimble_template, "~> 3.0", only: :dev, runtime: false}, # other dependencies ... ] end diff --git a/mix.exs b/mix.exs index f211e5fa..a07828d8 100644 --- a/mix.exs +++ b/mix.exs @@ -4,8 +4,8 @@ defmodule NimbleTemplate.MixProject do def project do [ app: :nimble_template, - version: "2.2.1", - description: "Project repository template to set up all public Phoenix projects at Nimble", + version: "3.0.0", + description: "Project repository template to set up all public Phoenix/Mix projects at Nimble - https://nimblehq.co/", elixir: "~> 1.11.4", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, From 40c47c7af343598a0b4a54d1f12f7d91b08fdfc8 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:21:46 +0700 Subject: [PATCH 29/52] Mix format --- mix.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index a07828d8..9b3f4839 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,8 @@ defmodule NimbleTemplate.MixProject do [ app: :nimble_template, version: "3.0.0", - description: "Project repository template to set up all public Phoenix/Mix projects at Nimble - https://nimblehq.co/", + description: + "Project repository template to set up all public Phoenix/Mix projects at Nimble - https://nimblehq.co/", elixir: "~> 1.11.4", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, From 6042fb9c9df30c600ef1562f4503d8c13e6ce6d7 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:25:56 +0700 Subject: [PATCH 30/52] Update Readme --- README.md | 3 ++- mix.exs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8ce4826a..00492fcc 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ ## Introduction -Phoenix template for projects at [Nimble](https://nimblehq.co/). +Phoenix/Mix template for projects at [Nimble](https://nimblehq.co/). ## Prerequisites NimbleTemplate has been developed and actively tested with the below environment: +- Mix 1.11.4 - Elixir 1.11.4 - Erlang/OTP 23.3 - Phoenix 1.5.7 diff --git a/mix.exs b/mix.exs index 9b3f4839..f1f7ba99 100644 --- a/mix.exs +++ b/mix.exs @@ -5,8 +5,7 @@ defmodule NimbleTemplate.MixProject do [ app: :nimble_template, version: "3.0.0", - description: - "Project repository template to set up all public Phoenix/Mix projects at Nimble - https://nimblehq.co/", + description: "Phoenix/Mix template for projects at [Nimble](https://nimblehq.co/).", elixir: "~> 1.11.4", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, From c958df89e6994fdfe263957c3caec1cc99939d1e Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Mon, 5 Apr 2021 16:16:11 +0700 Subject: [PATCH 31/52] Add addon for ExVCR --- lib/nimble.phx.gen.template/addons/ex_vcr.ex | 73 ++++++++++++++++++++ lib/nimble_template/generator.ex | 37 ++++++++++ lib/nimble_template/template.ex | 1 + 3 files changed, 111 insertions(+) create mode 100644 lib/nimble.phx.gen.template/addons/ex_vcr.ex diff --git a/lib/nimble.phx.gen.template/addons/ex_vcr.ex b/lib/nimble.phx.gen.template/addons/ex_vcr.ex new file mode 100644 index 00000000..56074a63 --- /dev/null +++ b/lib/nimble.phx.gen.template/addons/ex_vcr.ex @@ -0,0 +1,73 @@ +defmodule Nimble.Phx.Gen.Template.Addons.ExVCR do + use Nimble.Phx.Gen.Template.Addon + + @cassette_directory "test/support/fixtures/vcr_cassettes" + + @impl true + def do_apply(%Project{} = project, _opts) do + project + |> edit_files() + |> create_cassette_directory() + end + + defp edit_files(%Project{} = project) do + project + |> inject_mix_dependency() + |> edit_test_config() + |> edit_case() + + project + end + + defp inject_mix_dependency(%Project{} = project) do + Generator.inject_mix_dependency({:exvcr, latest_package_version(:exvcr), only: :test}) + + project + end + + defp edit_test_config(project) do + Generator.append_content( + "config/test.exs", + """ + + # Configurations for ExVCR + config :exvcr, + vcr_cassette_library_dir: "#{@cassette_directory}" + """ + ) + + project + end + + defp edit_case(project) do + Generator.inject_content( + "test/support/conn_case.ex", + """ + quote do + """, + """ + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + """ + ) + + Generator.inject_content( + "test/support/data_case.ex", + """ + quote do + """, + """ + use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney + + """ + ) + + project + end + + defp create_cassette_directory(project) do + Generator.make_directory(@cassette_directory) + + project + end +end diff --git a/lib/nimble_template/generator.ex b/lib/nimble_template/generator.ex index e2cc612c..2e69762e 100644 --- a/lib/nimble_template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -56,6 +56,19 @@ defmodule NimbleTemplate.Generator do end end + def append_content(file_path, content) do + file = Path.join([file_path]) + + file_content = + case File.read(file) do + {:ok, bin} -> bin + {:error, _} -> Mix.raise(~s[Can't read #{file}]) + end + + print_log("* appending ", Path.relative_to_cwd(file_path)) + File.write!(file, [file_content, content]) + end + def inject_mix_dependency(dependencies) when is_list(dependencies) do inject_content( "mix.exs", @@ -80,6 +93,18 @@ defmodule NimbleTemplate.Generator do ) end + def make_directory(path, touch_directory \\ true) do + case File.mkdir_p(path) do + :ok -> + :ok + + {:error, reason} -> + Mix.raise(~s[Failed to make directory #{path} reason: #{Atom.to_string(reason)}]) + end + + create_keep_file(path, touch_directory) + end + def print_log(prefix, content \\ ""), do: Mix.shell().info([:green, prefix, :reset, content]) defp split_with_self(contents, text) do @@ -88,4 +113,16 @@ defmodule NimbleTemplate.Generator do [_] -> :error end end + + defp create_keep_file(path, true) do + case File.touch("#{path}/.keep") do + :ok -> + :ok + + {:error, reason} -> + Mix.raise(~s[Failed to create keep file at #{path} reason: #{Atom.to_string(reason)}]) + end + end + + defp create_keep_file(_, _), do: :ok end diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index bf9b6c1b..7fcf7b7f 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -48,6 +48,7 @@ defmodule NimbleTemplate.Template do |> Addons.Dialyxir.apply() |> Addons.ExCoveralls.apply() |> Addons.ExMachina.apply() + |> Addons.ExVCR.apply() |> Addons.Mimic.apply() if host_on_github?() do From 1bba7739451261dff7c9c59db34cdf99bd764cc7 Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Mon, 5 Apr 2021 16:41:30 +0700 Subject: [PATCH 32/52] Add test --- .../addons/ex_vcr_test.exs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test/nimble.phx.gen.template/addons/ex_vcr_test.exs diff --git a/test/nimble.phx.gen.template/addons/ex_vcr_test.exs b/test/nimble.phx.gen.template/addons/ex_vcr_test.exs new file mode 100644 index 00000000..7455e87c --- /dev/null +++ b/test/nimble.phx.gen.template/addons/ex_vcr_test.exs @@ -0,0 +1,62 @@ +defmodule Nimble.Phx.Gen.Template.Addons.ExVCRTest do + use Nimble.Phx.Gen.Template.AddonCase + + describe "#apply/2" do + @describetag mock_latest_package_versions: [{:exvcr, "0.12.2"}] + + test "injects exvcr to mix dependency", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.ExVCR.apply(project) + + assert_file("mix.exs", fn file -> + assert file =~ "{:exvcr, \"~> 0.12.2\", [only: :test]}" + end) + end) + end + + test "updates configurations for test env", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.ExVCR.apply(project) + + assert_file("config/test.exs", fn file -> + assert file =~ """ + # Configurations for ExVCR + config :exvcr, + vcr_cassette_library_dir: "test/support/fixtures/vcr_cassettes" + """ + end) + end) + end + + test "updates test cases", %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.ExVCR.apply(project) + + assert_file("test/support/data_case.ex", fn file -> + assert file =~ "use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney" + end) + + assert_file("test/support/conn_case.ex", fn file -> + assert file =~ "use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney" + end) + end) + end + + test "creates cassettes directory with .keep file", %{ + project: project, + test_project_path: test_project_path + } do + in_test_project(test_project_path, fn -> + Addons.ExVCR.apply(project) + + assert(File.exists?("test/support/fixtures/vcr_cassettes/.keep")) == true + end) + end + end +end From bbaebc93d21188a0d56217f58e91b0482827503a Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Mon, 5 Apr 2021 16:44:35 +0700 Subject: [PATCH 33/52] Fix credo warnings --- lib/nimble_template/generator.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nimble_template/generator.ex b/lib/nimble_template/generator.ex index 2e69762e..82ccf1ad 100644 --- a/lib/nimble_template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -124,5 +124,5 @@ defmodule NimbleTemplate.Generator do end end - defp create_keep_file(_, _), do: :ok + defp create_keep_file(_path, _touch_directory), do: :ok end From d9eb0e14fe113102da2674a93affcff96f206850 Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Tue, 6 Apr 2021 10:56:05 +0700 Subject: [PATCH 34/52] Update styling and make addon optional --- lib/nimble_template/generator.ex | 2 +- lib/nimble_template/template.ex | 2 +- test/nimble.phx.gen.template/addons/ex_vcr_test.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nimble_template/generator.ex b/lib/nimble_template/generator.ex index 82ccf1ad..376ba90e 100644 --- a/lib/nimble_template/generator.ex +++ b/lib/nimble_template/generator.ex @@ -120,7 +120,7 @@ defmodule NimbleTemplate.Generator do :ok {:error, reason} -> - Mix.raise(~s[Failed to create keep file at #{path} reason: #{Atom.to_string(reason)}]) + Mix.raise(~s[Failed to create .keep file at #{path}, reason: #{Atom.to_string(reason)}]) end end diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index 7fcf7b7f..a6d0e318 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -48,7 +48,6 @@ defmodule NimbleTemplate.Template do |> Addons.Dialyxir.apply() |> Addons.ExCoveralls.apply() |> Addons.ExMachina.apply() - |> Addons.ExVCR.apply() |> Addons.Mimic.apply() if host_on_github?() do @@ -60,6 +59,7 @@ defmodule NimbleTemplate.Template do end if install_addon_prompt?("Oban"), do: Addons.Oban.apply(project) + if install_addon_prompt?("ExVCR"), do: Addons.ExVCR.apply(project) project end diff --git a/test/nimble.phx.gen.template/addons/ex_vcr_test.exs b/test/nimble.phx.gen.template/addons/ex_vcr_test.exs index 7455e87c..c383bc47 100644 --- a/test/nimble.phx.gen.template/addons/ex_vcr_test.exs +++ b/test/nimble.phx.gen.template/addons/ex_vcr_test.exs @@ -4,7 +4,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.ExVCRTest do describe "#apply/2" do @describetag mock_latest_package_versions: [{:exvcr, "0.12.2"}] - test "injects exvcr to mix dependency", %{ + test "injects ExVCR to mix dependency", %{ project: project, test_project_path: test_project_path } do From e05e1c02e5876a46ad0520f9b7f6a92675dc23e3 Mon Sep 17 00:00:00 2001 From: Miicky Jittjana Date: Thu, 8 Apr 2021 13:44:46 +0700 Subject: [PATCH 35/52] Update Makefile and refactoring --- Makefile | 3 ++- .../addons/ex_vcr.ex | 6 ++++-- .../addons/ex_vcr_test.exs | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) rename lib/{nimble.phx.gen.template => nimble_template}/addons/ex_vcr.ex (93%) rename test/{nimble.phx.gen.template => nimble_template}/addons/ex_vcr_test.exs (94%) diff --git a/Makefile b/Makefile index a4cdb0fe..13d5245a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ create_mix_project: # Y - in response to Do you want to generate the .github/ISSUE_TEMPLATE and .github/PULL_REQUEST_TEMPLATE? # Y - in response to Do you want to generate the Github Action workflow? # Y - in response to Would you like to add the Oban addon? -common_addon_prompts = Y\nY\nY\nY\n +# Y - in response to Would you like to add the ExVCR addon? +common_addon_prompts = Y\nY\nY\nY\nY\n web_addon_prompts = diff --git a/lib/nimble.phx.gen.template/addons/ex_vcr.ex b/lib/nimble_template/addons/ex_vcr.ex similarity index 93% rename from lib/nimble.phx.gen.template/addons/ex_vcr.ex rename to lib/nimble_template/addons/ex_vcr.ex index 56074a63..ed799752 100644 --- a/lib/nimble.phx.gen.template/addons/ex_vcr.ex +++ b/lib/nimble_template/addons/ex_vcr.ex @@ -1,5 +1,7 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExVCR do - use Nimble.Phx.Gen.Template.Addon +defmodule NimbleTemplate.Addons.ExVCR do + @moduledoc false + + use NimbleTemplate.Addon @cassette_directory "test/support/fixtures/vcr_cassettes" diff --git a/test/nimble.phx.gen.template/addons/ex_vcr_test.exs b/test/nimble_template/addons/ex_vcr_test.exs similarity index 94% rename from test/nimble.phx.gen.template/addons/ex_vcr_test.exs rename to test/nimble_template/addons/ex_vcr_test.exs index c383bc47..cfe7f8fe 100644 --- a/test/nimble.phx.gen.template/addons/ex_vcr_test.exs +++ b/test/nimble_template/addons/ex_vcr_test.exs @@ -1,5 +1,5 @@ -defmodule Nimble.Phx.Gen.Template.Addons.ExVCRTest do - use Nimble.Phx.Gen.Template.AddonCase +defmodule NimbleTemplate.Addons.ExVCRTest do + use NimbleTemplate.AddonCase describe "#apply/2" do @describetag mock_latest_package_versions: [{:exvcr, "0.12.2"}] From 81457b04cae611c53bfdb1a38b8c8e530b5564d8 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:32:53 +0700 Subject: [PATCH 36/52] Adding async: false to each addon test --- test/nimble_template/addons/credo_test.exs | 2 +- test/nimble_template/addons/dialyxir_test.exs | 2 +- test/nimble_template/addons/docker_test.exs | 2 +- test/nimble_template/addons/elixir_version_test.exs | 2 +- test/nimble_template/addons/ex_coveralls_test.exs | 2 +- test/nimble_template/addons/ex_machina_test.exs | 2 +- test/nimble_template/addons/github_test.exs | 2 +- test/nimble_template/addons/makefile_test.exs | 2 +- test/nimble_template/addons/mimic_test.exs | 2 +- test/nimble_template/addons/mix_release_test.exs | 2 +- test/nimble_template/addons/oban_test.exs | 2 +- test/nimble_template/addons/readme_test.exs | 2 +- test/nimble_template/addons/test_env_test.exs | 2 +- test/nimble_template/addons/variants/web/assets_test.exs | 2 +- test/nimble_template/addons/variants/web/core_js_test.exs | 2 +- test/nimble_template/addons/variants/web/sobelow_test.exs | 2 +- test/nimble_template/addons/variants/web/wallaby_test.exs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/nimble_template/addons/credo_test.exs b/test/nimble_template/addons/credo_test.exs index 47d4d7ff..ea468150 100644 --- a/test/nimble_template/addons/credo_test.exs +++ b/test/nimble_template/addons/credo_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.CredoTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "1.4"}] diff --git a/test/nimble_template/addons/dialyxir_test.exs b/test/nimble_template/addons/dialyxir_test.exs index e13d0a9e..02ea4848 100644 --- a/test/nimble_template/addons/dialyxir_test.exs +++ b/test/nimble_template/addons/dialyxir_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.DialyxirTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:dialyxir, "1.0"}] diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index dc8a6b87..7754e74c 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.DockerTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "copies the docker-compose.dev.yml", %{ diff --git a/test/nimble_template/addons/elixir_version_test.exs b/test/nimble_template/addons/elixir_version_test.exs index 17ce9cd9..5b833b1d 100644 --- a/test/nimble_template/addons/elixir_version_test.exs +++ b/test/nimble_template/addons/elixir_version_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.ElixirVersionTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "copies the .tool-versions", %{ diff --git a/test/nimble_template/addons/ex_coveralls_test.exs b/test/nimble_template/addons/ex_coveralls_test.exs index 0c52e53c..0da13400 100644 --- a/test/nimble_template/addons/ex_coveralls_test.exs +++ b/test/nimble_template/addons/ex_coveralls_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.ExCoverallsTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:excoveralls, "0.12.2"}] diff --git a/test/nimble_template/addons/ex_machina_test.exs b/test/nimble_template/addons/ex_machina_test.exs index 4716e142..2da75a0f 100644 --- a/test/nimble_template/addons/ex_machina_test.exs +++ b/test/nimble_template/addons/ex_machina_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.ExMachinaTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:ex_machina, "2.4"}] diff --git a/test/nimble_template/addons/github_test.exs b/test/nimble_template/addons/github_test.exs index aea57b7b..43157cfb 100644 --- a/test/nimble_template/addons/github_test.exs +++ b/test/nimble_template/addons/github_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.GithubTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2 with github_template option" do test "copies the .github/ISSUE_TEMPLATE.md", %{ diff --git a/test/nimble_template/addons/makefile_test.exs b/test/nimble_template/addons/makefile_test.exs index cc131386..7ce8b7a0 100644 --- a/test/nimble_template/addons/makefile_test.exs +++ b/test/nimble_template/addons/makefile_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.MakefileTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "copies the Makefile", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/mimic_test.exs b/test/nimble_template/addons/mimic_test.exs index 4eb3e2db..61455435 100644 --- a/test/nimble_template/addons/mimic_test.exs +++ b/test/nimble_template/addons/mimic_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.MimicTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:mimic, "1.3.1"}] diff --git a/test/nimble_template/addons/mix_release_test.exs b/test/nimble_template/addons/mix_release_test.exs index cfb3a9d3..4ca1ec59 100644 --- a/test/nimble_template/addons/mix_release_test.exs +++ b/test/nimble_template/addons/mix_release_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.MixReleaseTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "deletes the import_config \"prod.secret.exs\" in config/prod.exs", %{ diff --git a/test/nimble_template/addons/oban_test.exs b/test/nimble_template/addons/oban_test.exs index 5c5968ce..10b091b0 100644 --- a/test/nimble_template/addons/oban_test.exs +++ b/test/nimble_template/addons/oban_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.ObanTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false use Mimic describe "#apply/2" do diff --git a/test/nimble_template/addons/readme_test.exs b/test/nimble_template/addons/readme_test.exs index 8fa06fc5..36d415c6 100644 --- a/test/nimble_template/addons/readme_test.exs +++ b/test/nimble_template/addons/readme_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.ReadmeTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "copies the README.md", %{ diff --git a/test/nimble_template/addons/test_env_test.exs b/test/nimble_template/addons/test_env_test.exs index 067e3bfa..000b8550 100644 --- a/test/nimble_template/addons/test_env_test.exs +++ b/test/nimble_template/addons/test_env_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.Addons.TestEnvTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "injects the DB_HOST ENV", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/variants/web/assets_test.exs b/test/nimble_template/addons/variants/web/assets_test.exs index b566bd8e..32397b57 100644 --- a/test/nimble_template/addons/variants/web/assets_test.exs +++ b/test/nimble_template/addons/variants/web/assets_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.AddonsWeb.AssetsTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "adds assets.compile alias", %{project: project, test_project_path: test_project_path} do diff --git a/test/nimble_template/addons/variants/web/core_js_test.exs b/test/nimble_template/addons/variants/web/core_js_test.exs index 45f4a978..a37ab469 100644 --- a/test/nimble_template/addons/variants/web/core_js_test.exs +++ b/test/nimble_template/addons/variants/web/core_js_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.AddonsWeb.CoreJSTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do test "adds core-js into package.json", %{ diff --git a/test/nimble_template/addons/variants/web/sobelow_test.exs b/test/nimble_template/addons/variants/web/sobelow_test.exs index 5578b66f..7e55cdeb 100644 --- a/test/nimble_template/addons/variants/web/sobelow_test.exs +++ b/test/nimble_template/addons/variants/web/sobelow_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.AddonsWeb.SobelowTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:credo, "0.26.2"}, {:sobelow, "0.8"}] diff --git a/test/nimble_template/addons/variants/web/wallaby_test.exs b/test/nimble_template/addons/variants/web/wallaby_test.exs index 9f0e7ae0..e51bd2ee 100644 --- a/test/nimble_template/addons/variants/web/wallaby_test.exs +++ b/test/nimble_template/addons/variants/web/wallaby_test.exs @@ -1,5 +1,5 @@ defmodule NimbleTemplate.AddonsWeb.WallabyTest do - use NimbleTemplate.AddonCase + use NimbleTemplate.AddonCase, async: false describe "#apply/2" do @describetag mock_latest_package_versions: [{:wallaby, "0.26.2"}] From dcc979b7582ee90f2d362e72d4b44283e23705d5 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:39:35 +0700 Subject: [PATCH 37/52] Adding Phoenix template --- lib/nimble_template/template.ex | 49 ++-------------- .../variants/phoenix/template.ex | 58 +++++++++++++++++++ 2 files changed, 64 insertions(+), 43 deletions(-) create mode 100644 lib/nimble_template/variants/phoenix/template.ex diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index a6d0e318..511b4b71 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -1,24 +1,20 @@ defmodule NimbleTemplate.Template do @moduledoc false - alias NimbleTemplate.Api.Template, as: ApiTemplate - alias NimbleTemplate.Live.Template, as: LiveTemplate alias NimbleTemplate.Mix.Template, as: MixTemplate - alias NimbleTemplate.Web.Template, as: WebTemplate + alias NimbleTemplate.Phoenix.Template, as: PhoenixTemplate alias NimbleTemplate.{Addons, Project} def apply(%Project{mix_project?: true} = project) do MixTemplate.apply(project) - if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") + fetch_and_install_dependencies() end def apply(%Project{} = project) do - project - |> common_setup() - |> variant_setup() + PhoenixTemplate.apply(project) - if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") + fetch_and_install_dependencies() end def host_on_github?(), do: Mix.shell().yes?("\nWill you host this project on Github?") @@ -35,40 +31,7 @@ defmodule NimbleTemplate.Template do def install_addon_prompt?(addon), do: Mix.shell().yes?("\nWould you like to add the #{addon} addon?") - # Common setup for both API and Web projects - defp common_setup(%Project{} = project) do - project - |> Addons.ElixirVersion.apply() - |> Addons.Readme.apply() - |> Addons.Makefile.apply() - |> Addons.Docker.apply() - |> Addons.MixRelease.apply() - |> Addons.TestEnv.apply() - |> Addons.Credo.apply() - |> Addons.Dialyxir.apply() - |> Addons.ExCoveralls.apply() - |> Addons.ExMachina.apply() - |> Addons.Mimic.apply() - - if host_on_github?() do - if generate_github_template?(), - do: Addons.Github.apply(project, %{github_template: true}) - - if generate_github_action?(), - do: Addons.Github.apply(project, %{github_action: true}) - end - - if install_addon_prompt?("Oban"), do: Addons.Oban.apply(project) - if install_addon_prompt?("ExVCR"), do: Addons.ExVCR.apply(project) - - project + defp fetch_and_install_dependencies() do + if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") end - - defp variant_setup(%Project{api_project?: true} = project), do: ApiTemplate.apply(project) - - defp variant_setup(%Project{web_project?: true, live_project?: false} = project), - do: WebTemplate.apply(project) - - defp variant_setup(%Project{web_project?: true, live_project?: true} = project), - do: LiveTemplate.apply(project) end diff --git a/lib/nimble_template/variants/phoenix/template.ex b/lib/nimble_template/variants/phoenix/template.ex new file mode 100644 index 00000000..189ca964 --- /dev/null +++ b/lib/nimble_template/variants/phoenix/template.ex @@ -0,0 +1,58 @@ +defmodule NimbleTemplate.Phoenix.Template do + @moduledoc false + + import NimbleTemplate.Template, + only: [ + host_on_github?: 0, + generate_github_template?: 0, + generate_github_action?: 0, + install_addon_prompt?: 1 + ] + + alias NimbleTemplate.Api.Template, as: ApiTemplate + alias NimbleTemplate.Live.Template, as: LiveTemplate + alias NimbleTemplate.Web.Template, as: WebTemplate + alias NimbleTemplate.{Addons, Project} + + def apply(%Project{} = project) do + project + |> common_setup() + |> variant_setup() + end + + defp common_setup(%Project{} = project) do + project + |> Addons.ElixirVersion.apply() + |> Addons.Readme.apply() + |> Addons.Makefile.apply() + |> Addons.Docker.apply() + |> Addons.MixRelease.apply() + |> Addons.TestEnv.apply() + |> Addons.Credo.apply() + |> Addons.Dialyxir.apply() + |> Addons.ExCoveralls.apply() + |> Addons.ExMachina.apply() + |> Addons.Mimic.apply() + + if host_on_github?() do + if generate_github_template?(), + do: Addons.Github.apply(project, %{github_template: true}) + + if generate_github_action?(), + do: Addons.Github.apply(project, %{github_action: true}) + end + + if install_addon_prompt?("Oban"), do: Addons.Oban.apply(project) + if install_addon_prompt?("ExVCR"), do: Addons.ExVCR.apply(project) + + project + end + + defp variant_setup(%Project{api_project?: true} = project), do: ApiTemplate.apply(project) + + defp variant_setup(%Project{web_project?: true, live_project?: false} = project), + do: WebTemplate.apply(project) + + defp variant_setup(%Project{web_project?: true, live_project?: true} = project), + do: LiveTemplate.apply(project) +end From 65c3ea9f278c497dceb09089a4847f9afbe88acb Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:39:56 +0700 Subject: [PATCH 38/52] Adding Phoenix template - refactor --- lib/nimble_template/template.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index 511b4b71..2fa76337 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -31,7 +31,7 @@ defmodule NimbleTemplate.Template do def install_addon_prompt?(addon), do: Mix.shell().yes?("\nWould you like to add the #{addon} addon?") - defp fetch_and_install_dependencies() do - if Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get") - end + defp fetch_and_install_dependencies(), + do: + if(Mix.shell().yes?("\nFetch and install dependencies?"), do: Mix.shell().cmd("mix deps.get")) end From 21653658c2c2ce95c9f751f9983dff9fbff67844 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:46:23 +0700 Subject: [PATCH 39/52] Moving to phoenix addons --- lib/nimble_template/addons/variants/{ => phoenix}/api/.keep | 0 .../addons/variants/{ => phoenix}/live/.keep | 0 .../addons/variants/{ => phoenix}/web/assets.ex | 2 +- .../addons/variants/{ => phoenix}/web/core_js.ex | 2 +- .../addons/variants/{ => phoenix}/web/sobelow.ex | 2 +- .../addons/variants/{ => phoenix}/web/wallaby.ex | 2 +- lib/nimble_template/template.ex | 2 +- lib/nimble_template/variants/{ => phoenix}/api/template.ex | 2 +- lib/nimble_template/variants/{ => phoenix}/live/template.ex | 4 ++-- lib/nimble_template/variants/phoenix/template.ex | 6 +++--- lib/nimble_template/variants/{ => phoenix}/web/template.ex | 4 ++-- test/support/addon_case.ex | 4 ++-- 12 files changed, 15 insertions(+), 15 deletions(-) rename lib/nimble_template/addons/variants/{ => phoenix}/api/.keep (100%) rename lib/nimble_template/addons/variants/{ => phoenix}/live/.keep (100%) rename lib/nimble_template/addons/variants/{ => phoenix}/web/assets.ex (95%) rename lib/nimble_template/addons/variants/{ => phoenix}/web/core_js.ex (95%) rename lib/nimble_template/addons/variants/{ => phoenix}/web/sobelow.ex (95%) rename lib/nimble_template/addons/variants/{ => phoenix}/web/wallaby.ex (98%) rename lib/nimble_template/variants/{ => phoenix}/api/template.ex (69%) rename lib/nimble_template/variants/{ => phoenix}/live/template.ex (56%) rename lib/nimble_template/variants/{ => phoenix}/web/template.ex (71%) diff --git a/lib/nimble_template/addons/variants/api/.keep b/lib/nimble_template/addons/variants/phoenix/api/.keep similarity index 100% rename from lib/nimble_template/addons/variants/api/.keep rename to lib/nimble_template/addons/variants/phoenix/api/.keep diff --git a/lib/nimble_template/addons/variants/live/.keep b/lib/nimble_template/addons/variants/phoenix/live/.keep similarity index 100% rename from lib/nimble_template/addons/variants/live/.keep rename to lib/nimble_template/addons/variants/phoenix/live/.keep diff --git a/lib/nimble_template/addons/variants/web/assets.ex b/lib/nimble_template/addons/variants/phoenix/web/assets.ex similarity index 95% rename from lib/nimble_template/addons/variants/web/assets.ex rename to lib/nimble_template/addons/variants/phoenix/web/assets.ex index ce35645e..7f921c92 100644 --- a/lib/nimble_template/addons/variants/web/assets.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/assets.ex @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.Addons.Web.Assets do +defmodule NimbleTemplate.Addons.Phoenix.Web.Assets do @moduledoc false use NimbleTemplate.Addon diff --git a/lib/nimble_template/addons/variants/web/core_js.ex b/lib/nimble_template/addons/variants/phoenix/web/core_js.ex similarity index 95% rename from lib/nimble_template/addons/variants/web/core_js.ex rename to lib/nimble_template/addons/variants/phoenix/web/core_js.ex index cf218309..54d044e5 100644 --- a/lib/nimble_template/addons/variants/web/core_js.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/core_js.ex @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.Addons.Web.CoreJS do +defmodule NimbleTemplate.Addons.Phoenix.Web.CoreJS do @moduledoc false use NimbleTemplate.Addon diff --git a/lib/nimble_template/addons/variants/web/sobelow.ex b/lib/nimble_template/addons/variants/phoenix/web/sobelow.ex similarity index 95% rename from lib/nimble_template/addons/variants/web/sobelow.ex rename to lib/nimble_template/addons/variants/phoenix/web/sobelow.ex index 3982455a..a597b610 100644 --- a/lib/nimble_template/addons/variants/web/sobelow.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/sobelow.ex @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.Addons.Web.Sobelow do +defmodule NimbleTemplate.Addons.Phoenix.Web.Sobelow do @moduledoc false use NimbleTemplate.Addon diff --git a/lib/nimble_template/addons/variants/web/wallaby.ex b/lib/nimble_template/addons/variants/phoenix/web/wallaby.ex similarity index 98% rename from lib/nimble_template/addons/variants/web/wallaby.ex rename to lib/nimble_template/addons/variants/phoenix/web/wallaby.ex index c86076aa..2d489759 100644 --- a/lib/nimble_template/addons/variants/web/wallaby.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/wallaby.ex @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.Addons.Web.Wallaby do +defmodule NimbleTemplate.Addons.Phoenix.Web.Wallaby do @moduledoc false use NimbleTemplate.Addon diff --git a/lib/nimble_template/template.ex b/lib/nimble_template/template.ex index 2fa76337..0db74daa 100644 --- a/lib/nimble_template/template.ex +++ b/lib/nimble_template/template.ex @@ -3,7 +3,7 @@ defmodule NimbleTemplate.Template do alias NimbleTemplate.Mix.Template, as: MixTemplate alias NimbleTemplate.Phoenix.Template, as: PhoenixTemplate - alias NimbleTemplate.{Addons, Project} + alias NimbleTemplate.Project def apply(%Project{mix_project?: true} = project) do MixTemplate.apply(project) diff --git a/lib/nimble_template/variants/api/template.ex b/lib/nimble_template/variants/phoenix/api/template.ex similarity index 69% rename from lib/nimble_template/variants/api/template.ex rename to lib/nimble_template/variants/phoenix/api/template.ex index a010e544..443bd77b 100644 --- a/lib/nimble_template/variants/api/template.ex +++ b/lib/nimble_template/variants/phoenix/api/template.ex @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.Api.Template do +defmodule NimbleTemplate.Phoenix.Api.Template do @moduledoc false alias NimbleTemplate.Project diff --git a/lib/nimble_template/variants/live/template.ex b/lib/nimble_template/variants/phoenix/live/template.ex similarity index 56% rename from lib/nimble_template/variants/live/template.ex rename to lib/nimble_template/variants/phoenix/live/template.ex index a1cab24b..df614ed7 100644 --- a/lib/nimble_template/variants/live/template.ex +++ b/lib/nimble_template/variants/phoenix/live/template.ex @@ -1,8 +1,8 @@ -defmodule NimbleTemplate.Live.Template do +defmodule NimbleTemplate.Phoenix.Live.Template do @moduledoc false alias NimbleTemplate.Project - alias NimbleTemplate.Web.Template, as: WebTemplate + alias NimbleTemplate.Phoenix.Web.Template, as: WebTemplate def apply(%Project{} = project) do WebTemplate.apply(project) diff --git a/lib/nimble_template/variants/phoenix/template.ex b/lib/nimble_template/variants/phoenix/template.ex index 189ca964..e75eba0e 100644 --- a/lib/nimble_template/variants/phoenix/template.ex +++ b/lib/nimble_template/variants/phoenix/template.ex @@ -9,9 +9,9 @@ defmodule NimbleTemplate.Phoenix.Template do install_addon_prompt?: 1 ] - alias NimbleTemplate.Api.Template, as: ApiTemplate - alias NimbleTemplate.Live.Template, as: LiveTemplate - alias NimbleTemplate.Web.Template, as: WebTemplate + alias NimbleTemplate.Phoenix.Api.Template, as: ApiTemplate + alias NimbleTemplate.Phoenix.Live.Template, as: LiveTemplate + alias NimbleTemplate.Phoenix.Web.Template, as: WebTemplate alias NimbleTemplate.{Addons, Project} def apply(%Project{} = project) do diff --git a/lib/nimble_template/variants/web/template.ex b/lib/nimble_template/variants/phoenix/web/template.ex similarity index 71% rename from lib/nimble_template/variants/web/template.ex rename to lib/nimble_template/variants/phoenix/web/template.ex index 79a98fc5..434d2319 100644 --- a/lib/nimble_template/variants/web/template.ex +++ b/lib/nimble_template/variants/phoenix/web/template.ex @@ -1,7 +1,7 @@ -defmodule NimbleTemplate.Web.Template do +defmodule NimbleTemplate.Phoenix.Web.Template do @moduledoc false - alias NimbleTemplate.Addons.Web + alias NimbleTemplate.Addons.Phoenix.Web alias NimbleTemplate.Project def apply(%Project{} = project) do diff --git a/test/support/addon_case.ex b/test/support/addon_case.ex index 6902324c..e5995e87 100644 --- a/test/support/addon_case.ex +++ b/test/support/addon_case.ex @@ -3,14 +3,14 @@ defmodule NimbleTemplate.AddonCase do use Mimic - alias NimbleTemplate.Addons.Web, as: AddonsWeb + alias NimbleTemplate.Addons.Phoenix.Web, as: AddonsWeb alias NimbleTemplate.{Addons, Project} alias NimbleTemplate.Hex.Package using do quote do alias NimbleTemplate.Addons - alias NimbleTemplate.Addons.Web, as: AddonsWeb + alias NimbleTemplate.Addons.Phoenix.Web, as: AddonsWeb # ATTENTION: File.cd! doesn't support `async: true`, the test will fail randomly in async mode # https://elixirforum.com/t/randomly-getting-compilationerror-on-tests/17298/3 From 8d17d31b181c460294621ddf81f587ee6f77abdf Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:48:19 +0700 Subject: [PATCH 40/52] Moving to phoenix addons test --- test/nimble_template/addons/variants/{ => phoenix}/api/.keep | 0 test/nimble_template/addons/variants/{ => phoenix}/live/.keep | 0 .../addons/variants/{ => phoenix}/web/assets_test.exs | 2 +- .../addons/variants/{ => phoenix}/web/core_js_test.exs | 2 +- .../addons/variants/{ => phoenix}/web/sobelow_test.exs | 2 +- .../addons/variants/{ => phoenix}/web/wallaby_test.exs | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename test/nimble_template/addons/variants/{ => phoenix}/api/.keep (100%) rename test/nimble_template/addons/variants/{ => phoenix}/live/.keep (100%) rename test/nimble_template/addons/variants/{ => phoenix}/web/assets_test.exs (96%) rename test/nimble_template/addons/variants/{ => phoenix}/web/core_js_test.exs (94%) rename test/nimble_template/addons/variants/{ => phoenix}/web/sobelow_test.exs (96%) rename test/nimble_template/addons/variants/{ => phoenix}/web/wallaby_test.exs (98%) diff --git a/test/nimble_template/addons/variants/api/.keep b/test/nimble_template/addons/variants/phoenix/api/.keep similarity index 100% rename from test/nimble_template/addons/variants/api/.keep rename to test/nimble_template/addons/variants/phoenix/api/.keep diff --git a/test/nimble_template/addons/variants/live/.keep b/test/nimble_template/addons/variants/phoenix/live/.keep similarity index 100% rename from test/nimble_template/addons/variants/live/.keep rename to test/nimble_template/addons/variants/phoenix/live/.keep diff --git a/test/nimble_template/addons/variants/web/assets_test.exs b/test/nimble_template/addons/variants/phoenix/web/assets_test.exs similarity index 96% rename from test/nimble_template/addons/variants/web/assets_test.exs rename to test/nimble_template/addons/variants/phoenix/web/assets_test.exs index 32397b57..96432b75 100644 --- a/test/nimble_template/addons/variants/web/assets_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/assets_test.exs @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.AddonsWeb.AssetsTest do +defmodule NimbleTemplate.Addons.Phoenix.Web.AssetsTest do use NimbleTemplate.AddonCase, async: false describe "#apply/2" do diff --git a/test/nimble_template/addons/variants/web/core_js_test.exs b/test/nimble_template/addons/variants/phoenix/web/core_js_test.exs similarity index 94% rename from test/nimble_template/addons/variants/web/core_js_test.exs rename to test/nimble_template/addons/variants/phoenix/web/core_js_test.exs index a37ab469..c6e4b466 100644 --- a/test/nimble_template/addons/variants/web/core_js_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/core_js_test.exs @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.AddonsWeb.CoreJSTest do +defmodule NimbleTemplate.Addons.Phoenix.Web.CoreJSTest do use NimbleTemplate.AddonCase, async: false describe "#apply/2" do diff --git a/test/nimble_template/addons/variants/web/sobelow_test.exs b/test/nimble_template/addons/variants/phoenix/web/sobelow_test.exs similarity index 96% rename from test/nimble_template/addons/variants/web/sobelow_test.exs rename to test/nimble_template/addons/variants/phoenix/web/sobelow_test.exs index 7e55cdeb..91abc080 100644 --- a/test/nimble_template/addons/variants/web/sobelow_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/sobelow_test.exs @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.AddonsWeb.SobelowTest do +defmodule NimbleTemplate.Addons.Phoenix.Web.SobelowTest do use NimbleTemplate.AddonCase, async: false describe "#apply/2" do diff --git a/test/nimble_template/addons/variants/web/wallaby_test.exs b/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs similarity index 98% rename from test/nimble_template/addons/variants/web/wallaby_test.exs rename to test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs index e51bd2ee..c7f5bd70 100644 --- a/test/nimble_template/addons/variants/web/wallaby_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/wallaby_test.exs @@ -1,4 +1,4 @@ -defmodule NimbleTemplate.AddonsWeb.WallabyTest do +defmodule NimbleTemplate.Addons.Phoenix.Web.WallabyTest do use NimbleTemplate.AddonCase, async: false describe "#apply/2" do From ec54813be2052a41e6c203733bcdb9c858572fc0 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 11:54:20 +0700 Subject: [PATCH 41/52] Fix credo --- lib/nimble_template/variants/phoenix/live/template.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nimble_template/variants/phoenix/live/template.ex b/lib/nimble_template/variants/phoenix/live/template.ex index df614ed7..4175bbbe 100644 --- a/lib/nimble_template/variants/phoenix/live/template.ex +++ b/lib/nimble_template/variants/phoenix/live/template.ex @@ -1,8 +1,8 @@ defmodule NimbleTemplate.Phoenix.Live.Template do @moduledoc false - alias NimbleTemplate.Project alias NimbleTemplate.Phoenix.Web.Template, as: WebTemplate + alias NimbleTemplate.Project def apply(%Project{} = project) do WebTemplate.apply(project) From d24015ca0fef1b69c3c6acd51d1f22370876a705 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 12:02:46 +0700 Subject: [PATCH 42/52] Update Readme --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 00492fcc..67ff890e 100644 --- a/README.md +++ b/README.md @@ -81,18 +81,19 @@ All test files are located under `test/` directory. │ │ │ ├── ... │ │ │ ├── common_addon_test.exs │ │ │ └── variants -│ │ │ │ └── api -│ │ │ │ │ ├── ... -│ │ │ │ │ └── api_addon_test.exs -│ │ │ │ └── live -│ │ │ │ │ ├── ... -│ │ │ │ │ └── live_addon_test.exs │ │ │ │ └── mix │ │ │ │ │ ├── ... │ │ │ │ │ └── mix_addon_test.exs -│ │ │ │ └── web -│ │ │ │ │ ├── ... -│ │ │ │ │ └── web_addon_test.exs +│ │ │ │ └── phoenix +│ │ │ │ │ └── api +│ │ │ │ │ │ ├── ... +│ │ │ │ │ │ └── api_addon_test.exs +│ │ │ │ │ └── live +│ │ │ │ │ │ ├── ... +│ │ │ │ │ │ └── live_addon_test.exs +│ │ │ │ │ └── web +│ │ │ │ │ │ ├── ... +│ │ │ │ │ │ └── web_addon_test.exs ``` ### 2/ Variant test From 49d5a6924ba539fb289e1cf5f75c2c0c5dc4bffb Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 21:45:08 +0700 Subject: [PATCH 43/52] Adding capture_log: true --- lib/nimble_template/addons/ex_unit.ex | 22 +++++++++++++++++++ lib/nimble_template/variants/mix/template.ex | 2 ++ .../variants/phoenix/template.ex | 2 ++ test/nimble_template/addons/ex_unit_test.exs | 16 ++++++++++++++ test/test_helper.exs | 2 +- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 lib/nimble_template/addons/ex_unit.ex create mode 100644 test/nimble_template/addons/ex_unit_test.exs diff --git a/lib/nimble_template/addons/ex_unit.ex b/lib/nimble_template/addons/ex_unit.ex new file mode 100644 index 00000000..50d02535 --- /dev/null +++ b/lib/nimble_template/addons/ex_unit.ex @@ -0,0 +1,22 @@ +defmodule NimbleTemplate.Addons.ExUnit do + @moduledoc false + + use NimbleTemplate.Addon + + @impl true + def do_apply(%Project{} = project, _opts), do: edit_test_helper(project) + + defp edit_test_helper(%Project{} = project) do + Generator.replace_content( + "test/test_helper.exs", + """ + ExUnit.start() + """, + """ + ExUnit.start(capture_log: true) + """ + ) + + project + end +end diff --git a/lib/nimble_template/variants/mix/template.ex b/lib/nimble_template/variants/mix/template.ex index 531ef43d..5547a134 100644 --- a/lib/nimble_template/variants/mix/template.ex +++ b/lib/nimble_template/variants/mix/template.ex @@ -28,6 +28,8 @@ defmodule NimbleTemplate.Mix.Template do do: Addons.Github.apply(project, %{github_action: true}) end + Addons.ExUnit.apply(project) + if install_addon_prompt?("Mimic"), do: Addons.Mimic.apply(project) project diff --git a/lib/nimble_template/variants/phoenix/template.ex b/lib/nimble_template/variants/phoenix/template.ex index e75eba0e..d9025f81 100644 --- a/lib/nimble_template/variants/phoenix/template.ex +++ b/lib/nimble_template/variants/phoenix/template.ex @@ -42,6 +42,8 @@ defmodule NimbleTemplate.Phoenix.Template do do: Addons.Github.apply(project, %{github_action: true}) end + Addons.ExUnit.apply(project) + if install_addon_prompt?("Oban"), do: Addons.Oban.apply(project) if install_addon_prompt?("ExVCR"), do: Addons.ExVCR.apply(project) diff --git a/test/nimble_template/addons/ex_unit_test.exs b/test/nimble_template/addons/ex_unit_test.exs new file mode 100644 index 00000000..3730c54c --- /dev/null +++ b/test/nimble_template/addons/ex_unit_test.exs @@ -0,0 +1,16 @@ +defmodule NimbleTemplate.Addons.ExUnitTest do + use NimbleTemplate.AddonCase, async: false + + describe "#apply/2" do + test "sets `ExUnit.start(capture_log: true)` in `test/test_helper.exs`", + %{project: project, test_project_path: test_project_path} do + in_test_project(test_project_path, fn -> + Addons.ExUnit.apply(project) + + assert_file("test/test_helper.exs", fn file -> + assert file =~ "ExUnit.start(capture_log: true)" + end) + end) + end + end +end diff --git a/test/test_helper.exs b/test/test_helper.exs index 70afb8bd..6fc0293f 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -5,5 +5,5 @@ Code.put_compiler_option(:warnings_as_errors, true) Mimic.copy(Calendar) Mimic.copy(NimbleTemplate.Hex.Package) -ExUnit.start() +ExUnit.start(capture_log: true) ExUnit.configure(exclude: :release_version) From 2eba62f9ee5fa15fb625c729d85842098ff01957 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 21:54:30 +0700 Subject: [PATCH 44/52] Moving Addons.ExUnit.apply(project) to the end --- lib/nimble_template/variants/mix/template.ex | 4 ++-- lib/nimble_template/variants/phoenix/template.ex | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/nimble_template/variants/mix/template.ex b/lib/nimble_template/variants/mix/template.ex index 5547a134..50067dd9 100644 --- a/lib/nimble_template/variants/mix/template.ex +++ b/lib/nimble_template/variants/mix/template.ex @@ -28,10 +28,10 @@ defmodule NimbleTemplate.Mix.Template do do: Addons.Github.apply(project, %{github_action: true}) end - Addons.ExUnit.apply(project) - if install_addon_prompt?("Mimic"), do: Addons.Mimic.apply(project) + Addons.ExUnit.apply(project) + project end end diff --git a/lib/nimble_template/variants/phoenix/template.ex b/lib/nimble_template/variants/phoenix/template.ex index d9025f81..36b2fecf 100644 --- a/lib/nimble_template/variants/phoenix/template.ex +++ b/lib/nimble_template/variants/phoenix/template.ex @@ -18,6 +18,10 @@ defmodule NimbleTemplate.Phoenix.Template do project |> common_setup() |> variant_setup() + + Addons.ExUnit.apply(project) + + project end defp common_setup(%Project{} = project) do @@ -42,8 +46,6 @@ defmodule NimbleTemplate.Phoenix.Template do do: Addons.Github.apply(project, %{github_action: true}) end - Addons.ExUnit.apply(project) - if install_addon_prompt?("Oban"), do: Addons.Oban.apply(project) if install_addon_prompt?("ExVCR"), do: Addons.ExVCR.apply(project) From f1386b25e17e587a2a44e0f8a06e68dcf9af5fca Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 9 Apr 2021 12:04:52 +0700 Subject: [PATCH 45/52] Improve Github action --- .github/workflows/publish_to_hex_pm.yml | 5 ++++ ...test_api_variant_on_custom_api_project.yml | 7 +++++- ...st_api_variant_on_standard_api_project.yml | 7 +++++- ...ive_variant_on_custom_liveview_project.yml | 19 ++++++++------- ...e_variant_on_standard_liveview_project.yml | 19 ++++++++------- ...test_mix_variant_on_custom_mix_project.yml | 18 ++++++++------- ...on_custom_mix_project_with_supervision.yml | 18 ++++++++------- ...st_mix_variant_on_standard_mix_project.yml | 18 ++++++++------- ..._standard_mix_project_with_supervision.yml | 18 ++++++++------- .github/workflows/test_release_version.yml | 11 +++++++-- .github/workflows/test_template.yml | 15 ++++++++---- .../test_variant_on_custom_web_project.yml | 19 ++++++++------- .../test_variant_on_standard_web_project.yml | 19 ++++++++------- Makefile | 6 +++-- action.yml | 10 ++++++-- .../.github/workflows/test.yml.eex | 23 ++++++++++--------- .../.github/workflows/test.yml.mix.eex | 15 ++++++++---- 17 files changed, 148 insertions(+), 99 deletions(-) diff --git a/.github/workflows/publish_to_hex_pm.yml b/.github/workflows/publish_to_hex_pm.yml index 73055c01..5614d9fb 100644 --- a/.github/workflows/publish_to_hex_pm.yml +++ b/.github/workflows/publish_to_hex_pm.yml @@ -19,6 +19,11 @@ jobs: runs-on: ubuntu-latest if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.event.workflow_run.head_branch || github.ref }} diff --git a/.github/workflows/test_api_variant_on_custom_api_project.yml b/.github/workflows/test_api_variant_on_custom_api_project.yml index 6d3f00d4..146f401e 100644 --- a/.github/workflows/test_api_variant_on_custom_api_project.yml +++ b/.github/workflows/test_api_variant_on_custom_api_project.yml @@ -24,6 +24,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -43,7 +48,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '--no-html --no-webpack --module=CustomModule --app=custom_app' variant: 'api' diff --git a/.github/workflows/test_api_variant_on_standard_api_project.yml b/.github/workflows/test_api_variant_on_standard_api_project.yml index bcbc0ecf..9841036c 100644 --- a/.github/workflows/test_api_variant_on_standard_api_project.yml +++ b/.github/workflows/test_api_variant_on_standard_api_project.yml @@ -24,6 +24,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -43,7 +48,7 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '--no-html --no-webpack' variant: 'api' diff --git a/.github/workflows/test_live_variant_on_custom_liveview_project.yml b/.github/workflows/test_live_variant_on_custom_liveview_project.yml index eb267c0e..5cc4dd99 100644 --- a/.github/workflows/test_live_variant_on_custom_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_custom_liveview_project.yml @@ -25,6 +25,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -47,23 +52,17 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" - - name: npm packages cache + - name: Cache Node npm uses: actions/cache@v2 with: path: | - ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} - **/yarn.lock **/node_modules - key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-npm-packages- + ${{ runner.os }}-node- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '--live --module=CustomModule --app=custom_app' variant: 'live' diff --git a/.github/workflows/test_live_variant_on_standard_liveview_project.yml b/.github/workflows/test_live_variant_on_standard_liveview_project.yml index 3f241051..6ba329d5 100644 --- a/.github/workflows/test_live_variant_on_standard_liveview_project.yml +++ b/.github/workflows/test_live_variant_on_standard_liveview_project.yml @@ -25,6 +25,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -47,23 +52,17 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" - - name: npm packages cache + - name: Cache Node npm uses: actions/cache@v2 with: path: | - ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} - **/yarn.lock **/node_modules - key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-npm-packages- + ${{ runner.os }}-node- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '--live' variant: 'live' diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project.yml b/.github/workflows/test_mix_variant_on_custom_mix_project.yml index 97fd5e87..17c8767a 100644 --- a/.github/workflows/test_mix_variant_on_custom_mix_project.yml +++ b/.github/workflows/test_mix_variant_on_custom_mix_project.yml @@ -5,12 +5,18 @@ on: push env: OTP_VERSION: 23.3 ELIXIR_VERSION: 1.11.4 + MIX_ENV: test jobs: unit_test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -29,9 +35,6 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Install Elixir Dependencies - run: mix deps.get - name: Create Mix project run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--module=CustomModule --app=custom_app" @@ -42,12 +45,11 @@ jobs: - name: Install Elixir Dependencies run: cd sample_project && mix deps.get + - name: Compile dependencies + run: cd sample_project && mix compile --warnings-as-errors --all-warnings + - name: Run mix codebase run: cd sample_project && mix codebase - env: - MIX_ENV: test - name: Run mix test - run: cd sample_project && mix do compile --warnings-as-errors, test - env: - MIX_ENV: test + run: cd sample_project && mix test diff --git a/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml index 51f44a96..e240d59a 100644 --- a/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml +++ b/.github/workflows/test_mix_variant_on_custom_mix_project_with_supervision.yml @@ -5,12 +5,18 @@ on: push env: OTP_VERSION: 23.3 ELIXIR_VERSION: 1.11.4 + MIX_ENV: test jobs: unit_test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -29,9 +35,6 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Install Elixir Dependencies - run: mix deps.get - name: Create Mix project run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--module=CustomModule --app=custom_app --sup" @@ -42,12 +45,11 @@ jobs: - name: Install Elixir Dependencies run: cd sample_project && mix deps.get + - name: Compile dependencies + run: cd sample_project && mix compile --warnings-as-errors --all-warnings + - name: Run mix codebase run: cd sample_project && mix codebase - env: - MIX_ENV: test - name: Run mix test - run: cd sample_project && mix do compile --warnings-as-errors, test - env: - MIX_ENV: test + run: cd sample_project && mix test diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project.yml b/.github/workflows/test_mix_variant_on_standard_mix_project.yml index 27530d10..bd62d7ce 100644 --- a/.github/workflows/test_mix_variant_on_standard_mix_project.yml +++ b/.github/workflows/test_mix_variant_on_standard_mix_project.yml @@ -5,12 +5,18 @@ on: push env: OTP_VERSION: 23.3 ELIXIR_VERSION: 1.11.4 + MIX_ENV: test jobs: unit_test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -29,9 +35,6 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Install Elixir Dependencies - run: mix deps.get - name: Create Mix project run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="" @@ -42,12 +45,11 @@ jobs: - name: Install Elixir Dependencies run: cd sample_project && mix deps.get + - name: Compile dependencies + run: cd sample_project && mix compile --warnings-as-errors --all-warnings + - name: Run mix codebase run: cd sample_project && mix codebase - env: - MIX_ENV: test - name: Run mix test - run: cd sample_project && mix do compile --warnings-as-errors, test - env: - MIX_ENV: test + run: cd sample_project && mix test diff --git a/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml index f56a7437..6d515a2f 100644 --- a/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml +++ b/.github/workflows/test_mix_variant_on_standard_mix_project_with_supervision.yml @@ -5,12 +5,18 @@ on: push env: OTP_VERSION: 23.3 ELIXIR_VERSION: 1.11.4 + MIX_ENV: test jobs: unit_test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -29,9 +35,6 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: | ${{ runner.os }}-mix- - - - name: Install Elixir Dependencies - run: mix deps.get - name: Create Mix project run: make create_mix_project PROJECT_DIRECTORY=sample_project OPTIONS="--sup" @@ -42,12 +45,11 @@ jobs: - name: Install Elixir Dependencies run: cd sample_project && mix deps.get + - name: Compile dependencies + run: cd sample_project && mix compile --warnings-as-errors --all-warnings + - name: Run mix codebase run: cd sample_project && mix codebase - env: - MIX_ENV: test - name: Run mix test - run: cd sample_project && mix do compile --warnings-as-errors, test - env: - MIX_ENV: test + run: cd sample_project && mix test diff --git a/.github/workflows/test_release_version.yml b/.github/workflows/test_release_version.yml index fe67fb10..5a48b40e 100644 --- a/.github/workflows/test_release_version.yml +++ b/.github/workflows/test_release_version.yml @@ -9,12 +9,18 @@ # OTP_VERSION: 23.3 # ELIXIR_VERSION: 1.11.4 # PHOENIX_VERSION: 1.5.7 +# MIX_ENV: test # jobs: # release_version_test: # runs-on: ubuntu-latest # steps: +# - name: Cancel Previous Runs +# uses: styfle/cancel-workflow-action@0.8.0 +# with: +# access_token: ${{ github.token }} + # - uses: actions/checkout@v2 # with: # ref: ${{ github.head_ref }} @@ -37,10 +43,11 @@ # - name: Install Dependencies # run: mix deps.get +# - name: Compile dependencies +# run: mix compile --warnings-as-errors --all-warnings + # - name: Install Phoenix ${{ env.PHOENIX_VERSION }} # run: make install_phoenix PHOENIX_VERSION=${{ env.PHOENIX_VERSION }} # - name: Run Tests # run: mix test --only release_version -# env: -# MIX_ENV: test diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index f4b0bce1..6aff76c7 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -6,12 +6,18 @@ env: OTP_VERSION: 23.3 ELIXIR_VERSION: 1.11.4 PHOENIX_VERSION: 1.5.7 + MIX_ENV: test jobs: unit_test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -33,7 +39,10 @@ jobs: - name: Install Dependencies run: mix deps.get - + + - name: Compile dependencies + run: mix compile --warnings-as-errors --all-warnings + - name: Install Phoenix ${{ env.PHOENIX_VERSION }} run: make install_phoenix PHOENIX_VERSION=${{ env.PHOENIX_VERSION }} @@ -41,6 +50,4 @@ jobs: run: mix codebase - name: Run Tests - run: mix do compile --warnings-as-errors, test - env: - MIX_ENV: test + run: mix test diff --git a/.github/workflows/test_variant_on_custom_web_project.yml b/.github/workflows/test_variant_on_custom_web_project.yml index b3bd99ec..c2796562 100644 --- a/.github/workflows/test_variant_on_custom_web_project.yml +++ b/.github/workflows/test_variant_on_custom_web_project.yml @@ -29,6 +29,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -52,22 +57,16 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" - - - name: npm packages cache + - name: Cache Node npm uses: actions/cache@v2 with: path: | - ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} - **/yarn.lock **/node_modules - key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-npm-packages- + ${{ runner.os }}-node- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '--module=CustomModule --app=custom_app' variant: ${{ matrix.variant }} diff --git a/.github/workflows/test_variant_on_standard_web_project.yml b/.github/workflows/test_variant_on_standard_web_project.yml index 2ddfedba..0e365e40 100644 --- a/.github/workflows/test_variant_on_standard_web_project.yml +++ b/.github/workflows/test_variant_on_standard_web_project.yml @@ -29,6 +29,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -52,22 +57,16 @@ jobs: restore-keys: | ${{ runner.os }}-mix- - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" - - - name: npm packages cache + - name: Cache Node npm uses: actions/cache@v2 with: path: | - ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} - **/yarn.lock **/node_modules - key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-npm-packages- + ${{ runner.os }}-node- - - uses: nimblehq/elixir-templates@composite_1.3 + - uses: nimblehq/elixir-templates@composite_1.4 with: new_project_options: '' variant: ${{ matrix.variant }} diff --git a/Makefile b/Makefile index 13d5245a..97ab82f1 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ apply_phoenix_template: echo '{:nimble_template, path: "../", only: :dev, runtime: false},' > nimble_template.txt && \ sed -i -e '/{:phoenix, "~> /r nimble_template.txt' mix.exs && \ rm nimble_template.txt && \ - mix deps.get && \ + export MIX_ENV=dev && \ + mix do deps.get, deps.compile && \ mix format && \ if [ $(VARIANT) = web ]; then \ printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --web; \ @@ -52,7 +53,8 @@ apply_mix_template: echo '{:nimble_template, path: "../", only: :dev, runtime: false}' > nimble_template.txt && \ sed -i -e '/# {:dep_from_git, /r nimble_template.txt' mix.exs && \ rm nimble_template.txt && \ - mix deps.get && \ + export MIX_ENV=dev && \ + mix do deps.get, deps.compile && \ mix format && \ printf "${mix_addon_prompts}${post_setup_addon_prompts}" | mix nimble_template.gen --mix; \ diff --git a/action.yml b/action.yml index 769d21ea..e8ee3237 100644 --- a/action.yml +++ b/action.yml @@ -27,6 +27,12 @@ runs: - name: Install Elixir Dependencies run: cd sample_project && mix deps.get shell: bash + + - name: Compile dependencies + run: cd sample_project && mix compile --warnings-as-errors --all-warnings + shell: bash + env: + MIX_ENV: test - name: Install Node Dependencies run: cd sample_project && npm install --prefix assets @@ -52,9 +58,9 @@ runs: env: MIX_ENV: test DB_HOST: localhost - + - name: Run mix test - run: cd sample_project && mix do compile --warnings-as-errors, coverage + run: cd sample_project && mix coverage shell: bash env: MIX_ENV: test diff --git a/priv/templates/nimble_template/.github/workflows/test.yml.eex b/priv/templates/nimble_template/.github/workflows/test.yml.eex index 6c70f6af..a67a05e0 100644 --- a/priv/templates/nimble_template/.github/workflows/test.yml.eex +++ b/priv/templates/nimble_template/.github/workflows/test.yml.eex @@ -6,6 +6,8 @@ env: OTP_VERSION: <%= inspect erlang_version %> ELIXIR_VERSION: <%= inspect elixir_version %> NODE_VERSION: <%= inspect node_version %> + MIX_ENV: test + DB_HOST: localhost jobs: test: @@ -24,6 +26,11 @@ jobs: --health-retries 5 steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -57,7 +64,10 @@ jobs: <% end %> - name: Install Dependencies run: mix deps.get - + + - name: Compile dependencies + run: mix compile --warnings-as-errors --all-warnings + <%= if web_project? do %> - name: Install node module run: npm --prefix assets install @@ -67,24 +77,15 @@ jobs: <% end %> - name: Create database run: mix ecto.create - env: - MIX_ENV: test - DB_HOST: localhost - name: Migrate database run: mix ecto.migrate - env: - MIX_ENV: test - DB_HOST: localhost - name: Run codebase check run: mix codebase - name: Run Tests - run: mix do compile --warnings-as-errors, coverage - env: - MIX_ENV: test - DB_HOST: localhost + run: mix coverage <%= if web_project? do %> - uses: actions/upload-artifact@v2 if: ${{ failure() }} diff --git a/priv/templates/nimble_template/.github/workflows/test.yml.mix.eex b/priv/templates/nimble_template/.github/workflows/test.yml.mix.eex index 2aee8406..7b466bf1 100644 --- a/priv/templates/nimble_template/.github/workflows/test.yml.mix.eex +++ b/priv/templates/nimble_template/.github/workflows/test.yml.mix.eex @@ -5,12 +5,18 @@ on: pull_request env: OTP_VERSION: <%= inspect erlang_version %> ELIXIR_VERSION: <%= inspect elixir_version %> + MIX_ENV: test jobs: test: runs-on: ubuntu-latest steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} @@ -32,11 +38,12 @@ jobs: - name: Install Dependencies run: mix deps.get - + + - name: Compile dependencies + run: mix compile --warnings-as-errors --all-warnings + - name: Run codebase check run: mix codebase - name: Run Tests - run: mix do compile --warnings-as-errors, coverage - env: - MIX_ENV: test + run: mix coverage From bda3cf5d27d12727121eb61a3b23254bf69eaa71 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 8 Apr 2021 22:44:37 +0700 Subject: [PATCH 46/52] Refactor the Dockerfile --- lib/nimble_template/addons/docker.ex | 10 ++- lib/nimble_template/project.ex | 7 +- priv/templates/nimble_template/Dockerfile.eex | 75 ++++++++++--------- test/nimble_template/addons/docker_test.exs | 27 +++++-- 4 files changed, 66 insertions(+), 53 deletions(-) diff --git a/lib/nimble_template/addons/docker.ex b/lib/nimble_template/addons/docker.ex index a82b396a..8347650b 100644 --- a/lib/nimble_template/addons/docker.ex +++ b/lib/nimble_template/addons/docker.ex @@ -9,8 +9,9 @@ defmodule NimbleTemplate.Addons.Docker do web_project?: web_project?, otp_app: otp_app, base_module: base_module, - docker_build_base_image: docker_build_base_image, - docker_app_base_image: docker_app_base_image + alpine_version: alpine_version, + elixir_version: elixir_version, + erlang_version: erlang_version } = project, _opts ) do @@ -24,8 +25,9 @@ defmodule NimbleTemplate.Addons.Docker do ], otp_app: otp_app, base_module: base_module, - docker_build_base_image: docker_build_base_image, - docker_app_base_image: docker_app_base_image, + alpine_version: alpine_version, + elixir_version: elixir_version, + erlang_version: erlang_version, web_project?: web_project? ) diff --git a/lib/nimble_template/project.ex b/lib/nimble_template/project.ex index 2038ed41..87844838 100644 --- a/lib/nimble_template/project.ex +++ b/lib/nimble_template/project.ex @@ -1,12 +1,11 @@ defmodule NimbleTemplate.Project do @moduledoc false + @alpine_version "3.13.2" @elixir_version "1.11.4" @erlang_version "23.3" @node_version "14" - @alpine_version "3.13.2" - defstruct base_module: nil, base_path: nil, base_test_path: nil, @@ -15,9 +14,7 @@ defmodule NimbleTemplate.Project do web_path: nil, web_test_path: nil, # Dependency Versions - docker_app_base_image: "alpine:#{@alpine_version}", - docker_build_base_image: - "hexpm/elixir:#{@elixir_version}-erlang-#{@erlang_version}-alpine-#{@alpine_version}", + alpine_version: @alpine_version, elixir_version: @elixir_version, elixir_asdf_version: "#{@elixir_version}-otp-#{@erlang_version |> String.split(".") |> List.first()}", diff --git a/priv/templates/nimble_template/Dockerfile.eex b/priv/templates/nimble_template/Dockerfile.eex index d8135612..3caebf9a 100644 --- a/priv/templates/nimble_template/Dockerfile.eex +++ b/priv/templates/nimble_template/Dockerfile.eex @@ -1,52 +1,55 @@ -FROM <%= docker_build_base_image %> AS build +ARG ELIXIR_IMAGE_VERSION=<%= elixir_version %> +ARG ERLANG_IMAGE_VERSION=<%= erlang_version %> +ARG RELEASE_IMAGE_VERSION=<%= alpine_version %> + +FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS builder + +RUN apk update && \ + apk upgrade --no-cache && \ + apk add --no-cache \ + nodejs \ + npm \ + git \ + build-base && \ + mix local.rebar --force && \ + mix local.hex --force -# install build dependencies -RUN apk add --no-cache build-base npm git && \ - mix local.hex --force && \ - mix local.rebar --force - -# prepare build dir WORKDIR /app -# set build ENV +COPY . . + ENV MIX_ENV=prod -# install mix dependencies -COPY mix.exs mix.lock ./ -COPY config config -RUN mix do deps.get, deps.compile +RUN mix do deps.get, deps.compile, compile <%= if web_project? do %> -# build assets -COPY assets/package.json assets/package-lock.json ./assets/ -RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error - -COPY priv priv -COPY assets assets -RUN npm run --prefix ./assets deploy -RUN mix phx.digest +RUN cd assets && \ + npm ci --progress=false --no-audit --loglevel=error && \ + npm run deploy && \ + cd - && \ + mix phx.digest <% end %> -# compile and build release -COPY lib lib -# uncomment COPY if rel/ exists -# COPY rel rel -RUN mix do compile, release -# prepare release image -FROM <%= docker_app_base_image %> AS app +RUN mix release -RUN apk add --no-cache openssl ncurses-libs +# +# Release +# +FROM alpine:${RELEASE_IMAGE_VERSION} AS app -WORKDIR /app +RUN apk update && \ + apk add --no-cache \ + bash \ + openssl-dev -# Setup non-root user -RUN addgroup -S app_group && \ - adduser -s /bin/sh -G app_group -D app_user && \ - chown app_user:app_group /app +WORKDIR /opt/app +EXPOSE 4000 -COPY --from=build --chown=app_user:app_group /app/_build/prod/rel/<%= otp_app %> ./ -COPY bin/start.sh ./bin/start.sh +RUN addgroup -g 1000 appuser && \ + adduser -u 1000 -G appuser -g appuser -s /bin/sh -D appuser && \ + chown 1000:1000 /opt/app -ENV HOME=/app +COPY --from=builder --chown=app_user:app_group /app/_build/prod/rel/<%= otp_app %> ./ +COPY bin/start.sh ./bin/start.sh USER app_user diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index 7754e74c..02e603e9 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -57,17 +57,26 @@ defmodule NimbleTemplate.Addons.DockerTest do Addons.Docker.apply(project) assert_file("Dockerfile", fn file -> - assert file =~ "FROM hexpm/elixir:1.11.4-erlang-23.3-alpine-3.13.2 AS build" - assert file =~ "FROM alpine:3.13.2 AS app" + assert file =~ """ + ARG ELIXIR_IMAGE_VERSION=1.11.4 + ARG ERLANG_IMAGE_VERSION=23.3 + ARG RELEASE_IMAGE_VERSION=3.13.2 - assert file =~ - "RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error" + FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS builder + """ + + assert file =~ "FROM alpine:${RELEASE_IMAGE_VERSION} AS app" + + assert file =~ "RUN cd assets" + assert file =~ "npm ci --progress=false --no-audit --loglevel=error" + assert file =~ "npm run deploy" + assert file =~ "mix phx.digest" - assert file =~ "adduser -s /bin/sh -G app_group -D app_user &&" + assert file =~ "adduser -u 1000 -G appuser -g appuser -s /bin/sh -D appuser" assert file =~ "USER app_user" assert file =~ - "COPY --from=build --chown=app_user:app_group /app/_build/prod/rel/nimble_template ./" + "COPY --from=builder --chown=app_user:app_group /app/_build/prod/rel/nimble_template ./" end) end) end @@ -101,8 +110,10 @@ defmodule NimbleTemplate.Addons.DockerTest do Addons.Docker.apply(project) assert_file("Dockerfile", fn file -> - refute file =~ - "RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error" + refute file =~ "RUN cd assets" + refute file =~ "npm ci --progress=false --no-audit --loglevel=error" + refute file =~ "npm run deploy" + refute file =~ "mix phx.digest" end) end) end From 5ca92338b11a10998191ec26e46180cb53c86456 Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 9 Apr 2021 09:21:02 +0700 Subject: [PATCH 47/52] Update the target to builder --- priv/templates/nimble_template/docker-compose.yml.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/templates/nimble_template/docker-compose.yml.eex b/priv/templates/nimble_template/docker-compose.yml.eex index 4687c4f5..2e0a4fa2 100644 --- a/priv/templates/nimble_template/docker-compose.yml.eex +++ b/priv/templates/nimble_template/docker-compose.yml.eex @@ -6,7 +6,7 @@ services: context: . cache_from: - <%= otp_app %>-build - target: build + target: builder image: <%= otp_app %>-build app: From 4bab0f51cb6885e99ba18dada3c776a06f463af1 Mon Sep 17 00:00:00 2001 From: An Duong Date: Fri, 9 Apr 2021 09:37:21 +0700 Subject: [PATCH 48/52] Update chown --- priv/templates/nimble_template/Dockerfile.eex | 2 +- test/nimble_template/addons/docker_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/nimble_template/Dockerfile.eex b/priv/templates/nimble_template/Dockerfile.eex index 3caebf9a..b26bf8d7 100644 --- a/priv/templates/nimble_template/Dockerfile.eex +++ b/priv/templates/nimble_template/Dockerfile.eex @@ -48,7 +48,7 @@ RUN addgroup -g 1000 appuser && \ adduser -u 1000 -G appuser -g appuser -s /bin/sh -D appuser && \ chown 1000:1000 /opt/app -COPY --from=builder --chown=app_user:app_group /app/_build/prod/rel/<%= otp_app %> ./ +COPY --from=builder --chown=1000:1000 /app/_build/prod/rel/<%= otp_app %> ./ COPY bin/start.sh ./bin/start.sh USER app_user diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index 02e603e9..28a003ac 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -76,7 +76,7 @@ defmodule NimbleTemplate.Addons.DockerTest do assert file =~ "USER app_user" assert file =~ - "COPY --from=builder --chown=app_user:app_group /app/_build/prod/rel/nimble_template ./" + "COPY --from=builder --chown=1000:1000 /app/_build/prod/rel/nimble_template ./" end) end) end From 3b61cffc713404135c95c5e2637f17c8a2c91660 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 15 Apr 2021 10:17:40 +0700 Subject: [PATCH 49/52] Update test assert --- test/nimble_template/addons/docker_test.exs | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index 28a003ac..ffd2cead 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -67,10 +67,13 @@ defmodule NimbleTemplate.Addons.DockerTest do assert file =~ "FROM alpine:${RELEASE_IMAGE_VERSION} AS app" - assert file =~ "RUN cd assets" - assert file =~ "npm ci --progress=false --no-audit --loglevel=error" - assert file =~ "npm run deploy" - assert file =~ "mix phx.digest" + assert file =~ """ + RUN cd assets && \\ + \t\tnpm ci --progress=false --no-audit --loglevel=error && \\ + \t\tnpm run deploy && \\ + \t\tcd - && \\ + \t\tmix phx.digest + """ assert file =~ "adduser -u 1000 -G appuser -g appuser -s /bin/sh -D appuser" assert file =~ "USER app_user" @@ -110,10 +113,13 @@ defmodule NimbleTemplate.Addons.DockerTest do Addons.Docker.apply(project) assert_file("Dockerfile", fn file -> - refute file =~ "RUN cd assets" - refute file =~ "npm ci --progress=false --no-audit --loglevel=error" - refute file =~ "npm run deploy" - refute file =~ "mix phx.digest" + refute file =~ """ + RUN cd assets && \\ + \t\tnpm ci --progress=false --no-audit --loglevel=error && \\ + \t\tnpm run deploy && \\ + \t\tcd - && \\ + \t\tmix phx.digest + """ end) end) end From c777ebb913300b4a395a2d73ddc2484538912e1a Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 15 Apr 2021 10:24:55 +0700 Subject: [PATCH 50/52] Revert to build --- priv/templates/nimble_template/Dockerfile.eex | 4 ++-- priv/templates/nimble_template/docker-compose.yml.eex | 2 +- test/nimble_template/addons/docker_test.exs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/priv/templates/nimble_template/Dockerfile.eex b/priv/templates/nimble_template/Dockerfile.eex index b26bf8d7..1afbd53e 100644 --- a/priv/templates/nimble_template/Dockerfile.eex +++ b/priv/templates/nimble_template/Dockerfile.eex @@ -2,7 +2,7 @@ ARG ELIXIR_IMAGE_VERSION=<%= elixir_version %> ARG ERLANG_IMAGE_VERSION=<%= erlang_version %> ARG RELEASE_IMAGE_VERSION=<%= alpine_version %> -FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS builder +FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS build RUN apk update && \ apk upgrade --no-cache && \ @@ -48,7 +48,7 @@ RUN addgroup -g 1000 appuser && \ adduser -u 1000 -G appuser -g appuser -s /bin/sh -D appuser && \ chown 1000:1000 /opt/app -COPY --from=builder --chown=1000:1000 /app/_build/prod/rel/<%= otp_app %> ./ +COPY --from=build --chown=1000:1000 /app/_build/prod/rel/<%= otp_app %> ./ COPY bin/start.sh ./bin/start.sh USER app_user diff --git a/priv/templates/nimble_template/docker-compose.yml.eex b/priv/templates/nimble_template/docker-compose.yml.eex index 2e0a4fa2..4687c4f5 100644 --- a/priv/templates/nimble_template/docker-compose.yml.eex +++ b/priv/templates/nimble_template/docker-compose.yml.eex @@ -6,7 +6,7 @@ services: context: . cache_from: - <%= otp_app %>-build - target: builder + target: build image: <%= otp_app %>-build app: diff --git a/test/nimble_template/addons/docker_test.exs b/test/nimble_template/addons/docker_test.exs index ffd2cead..041b8d5a 100644 --- a/test/nimble_template/addons/docker_test.exs +++ b/test/nimble_template/addons/docker_test.exs @@ -62,7 +62,7 @@ defmodule NimbleTemplate.Addons.DockerTest do ARG ERLANG_IMAGE_VERSION=23.3 ARG RELEASE_IMAGE_VERSION=3.13.2 - FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS builder + FROM hexpm/elixir:${ELIXIR_IMAGE_VERSION}-erlang-${ERLANG_IMAGE_VERSION}-alpine-${RELEASE_IMAGE_VERSION} AS build """ assert file =~ "FROM alpine:${RELEASE_IMAGE_VERSION} AS app" @@ -79,7 +79,7 @@ defmodule NimbleTemplate.Addons.DockerTest do assert file =~ "USER app_user" assert file =~ - "COPY --from=builder --chown=1000:1000 /app/_build/prod/rel/nimble_template ./" + "COPY --from=build --chown=1000:1000 /app/_build/prod/rel/nimble_template ./" end) end) end From 63244ffcf08b70287b1f2a8b0de3204e81816394 Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 15 Apr 2021 10:54:38 +0700 Subject: [PATCH 51/52] Upgrade dependecy --- mix.exs | 10 +++++----- mix.lock | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/mix.exs b/mix.exs index f1f7ba99..b51f9126 100644 --- a/mix.exs +++ b/mix.exs @@ -31,11 +31,11 @@ defmodule NimbleTemplate.MixProject do defp deps do [ {:phoenix, "~> 1.5.7"}, - {:jason, "~> 1.2.2"}, - {:httpoison, "~> 1.7.0"}, - {:mimic, "~> 1.3.1", only: :test}, - {:credo, "~> 1.4.0", only: [:dev, :test], runtime: false}, - {:ex_doc, "~> 0.23.0", only: :dev, runtime: false} + {:jason, "~> 1.2"}, + {:httpoison, "~> 1.7"}, + {:mimic, "~> 1.3", only: :test}, + {:credo, "~> 1.4", only: [:dev, :test], runtime: false}, + {:ex_doc, "~> 0.23", only: :dev, runtime: false} ] end diff --git a/mix.lock b/mix.lock index 740450d5..c3d1ab37 100644 --- a/mix.lock +++ b/mix.lock @@ -1,26 +1,28 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"}, - "credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"}, - "ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"}, - "hackney": {:hex, :hackney, "1.16.0", "5096ac8e823e3a441477b2d187e30dd3fff1a82991a806b2003845ce72ce2d84", [:rebar3], [{:certifi, "2.5.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "3bf0bebbd5d3092a3543b783bf065165fa5d3ad4b899b836810e513064134e18"}, - "httpoison": {:hex, :httpoison, "1.7.0", "abba7d086233c2d8574726227b6c2c4f6e53c4deae7fe5f6de531162ce9929a0", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "975cc87c845a103d3d1ea1ccfd68a2700c211a434d8428b10c323dc95dc5b980"}, - "idna": {:hex, :idna, "6.0.1", "1d038fb2e7668ce41fbf681d2c45902e52b3cb9e9c77b55334353b222c2ee50c", [:rebar3], [{:unicode_util_compat, "0.5.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a02c8a1c4fd601215bb0b0324c8a6986749f807ce35f25449ec9e69758708122"}, + "certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"}, + "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, + "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, + "hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"}, + "httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"}, + "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "1.5.0", "203ef35ef3389aae6d361918bf3f952fa17a09e8e43b5aa592b93eba05d0fb8d", [:mix], [], "hexpm", "55a94c0f552249fc1a3dd9cd2d3ab9de9d3c89b559c2bd01121f824834f24746"}, + "mime": {:hex, :mime, "1.6.0", "dabde576a497cef4bbdd60aceee8160e02a6c89250d6c0b29e56c0dfb00db3d2", [:mix], [], "hexpm", "31a1a8613f8321143dde1dafc36006a17d28d02bdfecb9e95a880fa7aabd19a7"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "mimic": {:hex, :mimic, "1.3.1", "ba1c90b851de9065db81b1e3a16f659e53dffb89d2f4d404db06f67d0b990deb", [:mix], [], "hexpm", "51b74ab8009e0673bf68beba6abfce0e5500c8bec3ad27033c4a8dacbc44d55e"}, + "mimic": {:hex, :mimic, "1.5.0", "ad33740f414412639006afa4092f7bf09f5ddeb51999f94181ff8ad9e5d5d675", [:mix], [], "hexpm", "0f4620b88623c3869a11bd7e5691cccc712290c4bcbf73bf07bfb37c3c6932a4"}, "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "phoenix": {:hex, :phoenix, "1.5.7", "2923bb3af924f184459fe4fa4b100bd25fa6468e69b2803dfae82698269aa5e0", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "774cd64417c5a3788414fdbb2be2eb9bcd0c048d9e6ad11a0c1fd67b7c0d0978"}, + "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, + "phoenix": {:hex, :phoenix, "1.5.8", "71cfa7a9bb9a37af4df98939790642f210e35f696b935ca6d9d9c55a884621a4", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "35ded0a32f4836168c7ab6c33b88822eccd201bcd9492125a9bea4c54332d955"}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"}, - "plug": {:hex, :plug, "1.11.0", "f17217525597628298998bc3baed9f8ea1fa3f1160aa9871aee6df47a6e4d38e", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2d9c633f0499f9dc5c2fd069161af4e2e7756890b81adcbb2ceaa074e8308876"}, - "plug_crypto": {:hex, :plug_crypto, "1.2.0", "1cb20793aa63a6c619dd18bb33d7a3aa94818e5fd39ad357051a67f26dfa2df6", [:mix], [], "hexpm", "a48b538ae8bf381ffac344520755f3007cc10bd8e90b240af98ea29b69683fc2"}, + "plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"}, + "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, - "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.5.0", "8516502659002cec19e244ebd90d312183064be95025a319a6c7e89f4bccd65b", [:rebar3], [], "hexpm", "d48d002e15f5cc105a696cf2f1bbb3fc72b4b770a184d8420c8db20da2674b38"}, + "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, } From f99c162050128c1356275faa603ffa0906746c4a Mon Sep 17 00:00:00 2001 From: An Duong Date: Thu, 15 Apr 2021 11:43:21 +0700 Subject: [PATCH 52/52] Order dependencies by alphabet --- mix.exs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index b51f9126..a89d3519 100644 --- a/mix.exs +++ b/mix.exs @@ -30,12 +30,12 @@ defmodule NimbleTemplate.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:phoenix, "~> 1.5.7"}, - {:jason, "~> 1.2"}, + {:credo, "~> 1.4", only: [:dev, :test], runtime: false}, + {:ex_doc, "~> 0.23", only: :dev, runtime: false}, {:httpoison, "~> 1.7"}, + {:jason, "~> 1.2"}, {:mimic, "~> 1.3", only: :test}, - {:credo, "~> 1.4", only: [:dev, :test], runtime: false}, - {:ex_doc, "~> 0.23", only: :dev, runtime: false} + {:phoenix, "~> 1.5.7"} ] end