NimblePhxGenTemplate
Project repository template to set up all public Phoenix projects at Nimble
Installation
Generate a new Phoenix project by using mix phx.new
mix phx.new ...
Adding nimble_phx_gen_template into mix.exs:
def deps do
[
{:nimble_phx_gen_template, "~> 2.2.0", only: :dev, runtime: false},
...
]
end
Then run mix do deps.get, deps.compile to install NimblePhxGenTemplate.
Note: NimblePhxGenTemplate is only working on a new Phoenix project, applying NimblePhxGenTemplate to an existing Phoenix project might not work as expected.
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 templateRequirements
NimblePhxGenTemplate has been developed and actively tested with:
- Elixir 1.11.3
- Erlang/OTP 23.2.1
- Phoenix 1.5.7
Running NimblePhxGenTemplate currently requires:
- Elixir 1.11.3
- Erlang/OTP 23.2.1
- Phoenix 1.5.7
Contributing
We appreciate any contribution to NimblePhxGenTemplate.
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.
.
├── ...
├── test
│ ├── ...
│ ├── nimble.phx.gen.template
│ │ └── addons
│ │ │ ├── ...
│ │ │ ├── common_addon_test.exs
│ │ │ └── variants
│ │ │ │ └── api
│ │ │ │ │ ├── ...
│ │ │ │ │ └── api_addon_test.exs
│ │ │ │ └── web
│ │ │ │ │ ├── ...
│ │ │ │ │ └── web_addon_test.exs2/ Variant test
2.1/ Variant
NimblePhxGenTemplate is supporting 3 variants:
- API
- Web
- Live
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 AppName.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=CustomModuleNamemix phx.new AppName --app=custom_otp_app_namemix 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)
Putting it all together, it is 8 variant test cases.
-
Applying the
API variantto aStandard Web project -
Applying the
API variantto aCustom Web project -
Applying the
API variantto aStandard API project -
Applying the
API variantto aCustom API project -
Applying the
Web variantto aStandard Web project -
Applying the
Web variantto aCustom Web project -
Applying the
Live variantto aStandard LiveView project -
Applying the
Live variantto aCustom LiveView project
Release
Set the HEX_API_KEY as a Github secret (skip this step if it has been done).
The release process follows the Git flow.
Once a release/<version number> 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.
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.
About
This project is maintained and funded by Nimble.
We love open source and do our part in sharing our work with the community! See our other projects or hire our team to help build your product.