Skip to content

Commit

Permalink
Merge pull request #75 from nimblehq/release/2.2.0
Browse files Browse the repository at this point in the history
Release/2.2.0
  • Loading branch information
andyduong1920 authored Jan 6, 2021
2 parents b73e730 + 686061f commit 0f5b388
Show file tree
Hide file tree
Showing 29 changed files with 342 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish_to_hex_pm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
workflow_dispatch:

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3

jobs:
publish:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_api_variant_on_custom_api_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: "Test API variant on custom API project"
on: push

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: "Test API variant on standard API project"
on: push

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7

jobs:
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/test_live_variant_on_custom_liveview_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Test Live variant on custom LiveView project"

on: push

env:
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7
NODE_VERSION: 14

jobs:
unit_test:
runs-on: ubuntu-latest

services:
db:
image: postgres:12.3
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
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 }}

- uses: actions/setup-node@v2-beta
with:
node-version: ${{ env.NODE_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: 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
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*') }}
restore-keys: |
${{ runner.os }}-npm-packages-
- uses: nimblehq/elixir-templates@composite_1.1
with:
new_project_options: '--live --module=CustomModule --app=custom_app'
variant: 'live'
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Test Live variant on standard LiveView project"

on: push

env:
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7
NODE_VERSION: 14

jobs:
unit_test:
runs-on: ubuntu-latest

services:
db:
image: postgres:12.3
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
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 }}

- uses: actions/setup-node@v2-beta
with:
node-version: ${{ env.NODE_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: 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
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*') }}
restore-keys: |
${{ runner.os }}-npm-packages-
- uses: nimblehq/elixir-templates@composite_1.1
with:
new_project_options: '--live'
variant: 'live'
46 changes: 46 additions & 0 deletions .github/workflows/test_release_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Test Release version"

on:
push:
branches:
- 'release/**'

env:
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7

jobs:
release_version_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: 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
4 changes: 2 additions & 2 deletions .github/workflows/test_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: "Test template"
on: push

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_variant_on_custom_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: "Test variant on custom Web project"
on: push

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7
NODE_VERSION: 12
NODE_VERSION: 14

jobs:
unit_test:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_variant_on_standard_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: "Test variant on standard Web project"
on: push

env:
OTP_VERSION: 23.1.4
ELIXIR_VERSION: 1.11.2
OTP_VERSION: 23.1.5
ELIXIR_VERSION: 1.11.3
PHOENIX_VERSION: 1.5.7
NODE_VERSION: 12
NODE_VERSION: 14

jobs:
unit_test:
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 23.1.4
elixir 1.11.2-otp-23
erlang 23.1.5
elixir 1.11.3-otp-23
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ web_addon_prompts =

api_addon_prompts =

live_addon_prompts =

# Y - in response to Fetch and install dependencies?
post_setup_addon_prompts = Y\n

Expand All @@ -31,6 +33,8 @@ apply_template:
printf "${common_addon_prompts}${web_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --web; \
elif [ $(VARIANT) = api ]; then \
printf "${common_addon_prompts}${api_addon_prompts}${post_setup_addon_prompts}" | mix nimble.phx.gen.template --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; \
fi;

remove_nimble_phx_gen_template:
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,34 @@ Project repository template to set up all public Phoenix projects at [Nimble](ht

## Installation

NimblePhxGenTemplate is published on Hex. Add it to your list of dependencies in `mix.exs`:
### Generate a new Phoenix project by using [mix phx.new](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html)

```bash
mix phx.new ...
```

### Adding `nimble_phx_gen_template` into `mix.exs`:

```elixir
def deps do
[
{:nimble_phx_gen_template, "~> 2.1.0", only: :dev, runtime: false}
{:nimble_phx_gen_template, "~> 2.2.0", only: :dev, runtime: false},
...
]
end
```

Then run `mix do deps.get, deps.compile` to install NimblePhxGenTemplate
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 template
```
## Requirements

Expand Down Expand Up @@ -61,10 +71,11 @@ All files are located under `test/` folder.

##### 2.1/ Variant

NimblePhxGenTemplate is supporting 2 variants:
NimblePhxGenTemplate is supporting 3 variants:

- API
- Web
- Live

##### 2.2/ Phoenix project

Expand All @@ -80,21 +91,25 @@ Aside from that, it could also be a Custom project, which contains the custom OT
- `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 4 project types:
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 6 variant test cases.
Putting it all together, it is 8 variant test cases.

- Applying the `API variant` to a `Standard Web project`
- Applying the `API variant` to a `Custom Web project`
- Applying the `API variant` to a `Standard API project`
- Applying the `API variant` to a `Custom API project`
- Applying the `Web variant` to a `Standard Web project`
- Applying the `Web variant` to a `Custom Web project`
- Applying the `Live variant` to a `Standard LiveView project`
- Applying the `Live variant` to a `Custom LiveView project`

### Release

Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/nimble.phx.gen.template.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Mix.Tasks.Nimble.Phx.Gen.Template do
alias Nimble.Phx.Gen.Template.{Project, Template}

@version Mix.Project.config()[:version]
@variants [api: :boolean, web: :boolean]
@variants [api: :boolean, web: :boolean, live: :boolean]

def run([args]) when args in ~w(-v --version) do
Mix.shell().info("Nimble.Phx.Gen.Template v#{@version}")
Expand Down
4 changes: 2 additions & 2 deletions lib/nimble.phx.gen.template/addons/docker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.Docker do
@impl true
def do_apply(
%Project{
api_project?: api_project?,
web_project?: web_project?,
otp_app: otp_app,
base_module: base_module,
docker_build_base_image: docker_build_base_image,
Expand All @@ -24,7 +24,7 @@ defmodule Nimble.Phx.Gen.Template.Addons.Docker do
base_module: base_module,
docker_build_base_image: docker_build_base_image,
docker_app_base_image: docker_app_base_image,
web_project?: !api_project?
web_project?: web_project?
)

Mix.shell().cmd("chmod +x bin/start.sh")
Expand Down
Loading

0 comments on commit 0f5b388

Please sign in to comment.