Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,36 @@ jobs:
unzip -l /tmp/corex_new_archive_check.ez | grep -q 'priv/corex_design/corex/' || (echo 'missing priv/corex_design in archive'; exit 1)

integration-tests:
name: Integration tests (OTP ${{ matrix.otp }} | Elixir ${{ matrix.elixir }})
name: Integration tests (OTP ${{ matrix.otp }} | Elixir ${{ matrix.elixir }}${{ matrix.phx_new_suffix }})
runs-on: ubuntu-24.04

strategy:
matrix:
include:
- elixir: 1.17.3
otp: 26.2.5.2
phx_new_version: ""
phx_new_suffix: ""
- elixir: 1.18.4
otp: 27.3
phx_new_version: ""
phx_new_suffix: ""
- elixir: 1.18.4
otp: 28.0.1
phx_new_version: ""
phx_new_suffix: ""
- elixir: 1.17.3
otp: 26.2.5.2
phx_new_version: "1.8.4"
phx_new_suffix: " | phx_new 1.8.4"
- elixir: 1.18.4
otp: 27.3
phx_new_version: "1.8.4"
phx_new_suffix: " | phx_new 1.8.4"
- elixir: 1.18.4
otp: 28.0.1
phx_new_version: "1.8.4"
phx_new_suffix: " | phx_new 1.8.4"

services:
postgres:
Expand Down Expand Up @@ -441,7 +459,12 @@ jobs:
mix archive.install corex_new.ez --force

- name: Install Mix archives for corex.new (phx_new)
run: mix archive.install hex phx_new --force
run: |
if [ -n "${{ matrix.phx_new_version }}" ]; then
mix archive.install hex phx_new ${{ matrix.phx_new_version }} --force
else
mix archive.install hex phx_new --force
fi

- name: Run integration tests (fast)
working-directory: integration_test
Expand Down
2 changes: 1 addition & 1 deletion e2e/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule E2e.MixProject do
{:phoenix_html, "~> 4.1"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_dashboard, "~> 0.8.3"},
{:phoenix_live_view, "~> 1.1.0"},
{:phoenix_live_view, "~> 1.1"},
{:live_capture, "~> 0.2"},
{:lazy_html, ">= 0.1.0", only: :test},
{:esbuild, "~> 0.10", runtime: Mix.env() == :dev},
Expand Down
12 changes: 12 additions & 0 deletions installer/lib/corex_new/patches.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ defmodule Corex.New.Patches do
|> maybe_add_corex_generators_config(opts)
|> maybe_add_designex_config(opts)
|> patch_esbuild_for_esm()
|> patch_env_path_lists()

write_if_changed!(path, content, updated)
end
Expand Down Expand Up @@ -750,6 +751,17 @@ defmodule Corex.New.Patches do
end
end

defp patch_env_path_lists(content) do
Regex.replace(
~r/"NODE_PATH"\s*=>\s*\[([^\]]+)\]/u,
content,
fn _, inner ->
paths = inner |> String.split(",") |> Enum.map(&String.trim/1)
~s/"NODE_PATH" => Enum.join([#{Enum.join(paths, ", ")}], ":")/
end
)
end

defp patch_esbuild_for_esm(content) do
cond do
String.contains?(content, "--format=esm") ->
Expand Down
60 changes: 60 additions & 0 deletions installer/test/patches_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,66 @@ defmodule Corex.New.PatchesTest do
end)
end

test "joins NODE_PATH env lists for tailwind and esbuild on Elixir 1.18" do
in_tmp(:patch_config_node_path, fn ->
File.mkdir_p!("config")
File.write!("config/config.exs", @stock_config_exs)

Patches.patch_config_exs(File.cwd!(), otp_app: :my_app)
body = File.read!("config/config.exs")

assert body =~
~s|"NODE_PATH" => Enum.join([Path.expand("../deps", __DIR__), Mix.Project.build_path()], ":")|

refute body =~
~s|"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]|
end)
end

test "leaves NODE_PATH unchanged when already a string" do
in_tmp(:patch_config_node_path_string, fn ->
File.mkdir_p!("config")

config = """
import Config

config :esbuild,
version: "0.25.4",
my_app: [
args: ~w(js/app.js --bundle),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]

import_config "#{"#"}{config_env()}.exs"
"""

File.write!("config/config.exs", config)
Patches.patch_config_exs(File.cwd!(), otp_app: :my_app)
body = File.read!("config/config.exs")

assert body =~ ~s|"NODE_PATH" => Path.expand("../deps", __DIR__)|
refute body =~ "Enum.join"
end)
end

test "NODE_PATH list patch is idempotent" do
in_tmp(:patch_config_node_path_idempotent, fn ->
File.mkdir_p!("config")
File.write!("config/config.exs", @stock_config_exs)

Patches.patch_config_exs(File.cwd!(), otp_app: :my_app)
Patches.patch_config_exs(File.cwd!(), otp_app: :my_app)
body = File.read!("config/config.exs")

assert length(Regex.scan(~r/"NODE_PATH"\s*=>/u, body)) == 1
assert body =~ "Enum.join"

refute body =~
~s|"NODE_PATH" => [Path.expand("../deps", __DIR__), Mix.Project.build_path()]|
end)
end

test "skips themes config when themes key already exists" do
in_tmp(:patch_config_themes_present, fn ->
File.mkdir_p!("config")
Expand Down
4 changes: 4 additions & 0 deletions integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This project contains integration tests for Phoenix-generated projects and Corex
CI (`.github/workflows/elixir.yml`) installs **`phx_new`** and locally built **`corex_new`**, then runs,
in order:

The matrix runs **latest** `phx_new` on each OTP / Elixir row, then repeats all three rows with **pinned
`phx_new 1.8.4`** (aligned with `installer/mix.exs` `@phoenix_version`) so `corex.new` stays compatible
with older Phoenix installers as well as current Hex releases.

1. **`mix test`** - matches local default; `test_helper.exs` sets `exclude: [:database]`, so untagged work runs here.
2. **`mix test --include database:postgresql`** - uses the job’s **Postgres 15** service on **localhost:5432**
(`PGHOST`, `PGUSER`, `PGPASSWORD`, `PGPORT`, `DATABASE_URL` set in the workflow).
Expand Down
2 changes: 1 addition & 1 deletion integration_test/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule Corex.Integration.MixProject do
{:postgrex, ">= 0.0.0"},
{:ecto_sqlite3, ">= 0.0.0"},
{:phoenix_html, "~> 4.1"},
{:phoenix_live_view, "~> 1.1.0"},
{:phoenix_live_view, "~> 1.1"},
{:dns_cluster, "~> 0.2.0"},
{:lazy_html, ">= 0.1.0"},
{:phoenix_live_reload, "~> 1.2"},
Expand Down
2 changes: 0 additions & 2 deletions lib/components/file_upload_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ defmodule Corex.FileUploadLive do
entry={entry}
data-scope="file-upload"
data-part="item-preview-image"
width="40"
height="40"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Corex.MixProject do
[
{:jason, "~> 1.0"},
{:phoenix, "~> 1.8.1"},
{:phoenix_live_view, "~> 1.1.0"},
{:phoenix_live_view, "~> 1.1"},
{:gettext, "~> 1.0"},
{:esbuild, "~> 0.8", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.40", only: [:dev, :docs], runtime: false},
Expand Down
Loading