Packages
phoenix_kit
1.7.186
1.7.207
1.7.206
1.7.205
1.7.204
1.7.203
1.7.202
1.7.201
1.7.200
1.7.199
1.7.198
1.7.197
1.7.196
1.7.194
1.7.193
1.7.192
1.7.191
1.7.190
1.7.189
1.7.187
1.7.186
1.7.185
1.7.184
1.7.183
1.7.182
1.7.181
1.7.180
1.7.179
1.7.178
1.7.177
1.7.176
1.7.175
1.7.174
1.7.173
1.7.172
1.7.171
1.7.170
1.7.169
1.7.168
1.7.167
1.7.166
1.7.165
1.7.164
1.7.162
1.7.161
1.7.160
1.7.159
1.7.157
1.7.156
1.7.155
1.7.154
1.7.153
1.7.152
1.7.151
1.7.150
1.7.149
1.7.146
1.7.145
1.7.144
1.7.143
1.7.138
1.7.133
1.7.132
1.7.131
1.7.130
1.7.128
1.7.126
1.7.125
1.7.121
1.7.120
1.7.119
1.7.118
1.7.117
1.7.116
1.7.115
1.7.114
1.7.113
1.7.112
1.7.111
1.7.110
1.7.109
1.7.108
1.7.107
1.7.106
1.7.105
1.7.104
1.7.103
1.7.102
1.7.101
1.7.100
1.7.99
1.7.98
1.7.97
1.7.96
1.7.95
1.7.94
1.7.93
1.7.92
1.7.91
1.7.90
1.7.89
1.7.88
1.7.87
1.7.86
1.7.85
1.7.84
1.7.83
1.7.82
1.7.81
1.7.80
1.7.79
1.7.78
1.7.77
1.7.76
1.7.75
1.7.74
1.7.71
1.7.70
1.7.69
1.7.66
1.7.65
1.7.64
1.7.63
1.7.62
1.7.61
1.7.59
1.7.58
1.7.57
1.7.56
1.7.55
1.7.54
1.7.53
1.7.52
1.7.51
1.7.49
1.7.44
1.7.43
1.7.42
1.7.41
1.7.39
1.7.38
1.7.37
1.7.36
1.7.34
1.7.33
1.7.31
1.7.30
1.7.29
1.7.28
1.7.27
1.7.26
1.7.25
1.7.24
1.7.23
1.7.22
1.7.21
1.7.20
1.7.19
1.7.18
1.7.17
1.7.16
1.7.15
1.7.14
1.7.13
1.7.12
1.7.11
1.7.10
1.7.9
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.20
1.6.19
1.6.18
1.6.17
1.6.16
1.6.15
1.6.14
1.6.13
1.6.12
1.6.11
1.6.10
1.6.9
1.6.8
1.6.7
1.6.6
1.6.5
1.6.4
1.6.3
1.5.2
1.5.1
1.5.0
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
1.2.10
1.2.9
1.2.8
1.2.7
1.2.5
1.2.4
1.2.2
1.2.1
1.2.0
1.1.0
1.0.0
A foundation for building Elixir Phoenix apps — SaaS, social networks, ERP systems, marketplaces, and more
Current section
221 Versions
Jump to
Current section
221 Versions
Compare versions
8
files changed
+106
additions
-101
deletions
unknownCHANGELOG.md
File is too large to be displayed (100 KB limit).
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/BeamLabEU/phoenix_kit">>}]}. |
| 2 2 | {<<"name">>,<<"phoenix_kit">>}. |
| 3 | - {<<"version">>,<<"1.7.185">>}. |
| 3 | + {<<"version">>,<<"1.7.186">>}. |
| 4 4 | {<<"description">>, |
| 5 5 | <<65,32,102,111,117,110,100,97,116,105,111,110,32,102,111,114,32,98,117,105, |
| 6 6 | 108,100,105,110,103,32,69,108,105,120,105,114,32,80,104,111,101,110,105, |
| @@ -66,6 +66,7 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do | |
| 66 66 | BasicConfiguration, |
| 67 67 | BootHook, |
| 68 68 | BrowserPipelineIntegration, |
| 69 | + Common, |
| 69 70 | CssIntegration, |
| 70 71 | DbConnectionCheck, |
| 71 72 | DemoFiles, |
| @@ -120,6 +121,10 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do | |
| 120 121 | |> BootHook.add_boot_hook() |
| 121 122 | |> ObanConfig.add_oban_supervisor() |
| 122 123 | |> LayoutConfig.add_layout_integration_configuration() |
| 124 | + |> Common.ensure_compilers_registered([ |
| 125 | + :phoenix_kit_css_sources, |
| 126 | + :phoenix_kit_js_sources |
| 127 | + ]) |
| 123 128 | |> CssIntegration.add_automatic_css_integration() |
| 124 129 | |> JsIntegration.add_js_integration() |
| 125 130 | |> DemoFiles.copy_test_demo_files() |
| @@ -375,11 +375,18 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do | |
| 375 375 | # This must run AFTER add_oban_supervisor to fix installations with wrong order |
| 376 376 | igniter = fix_supervisor_ordering(igniter) |
| 377 377 | |
| 378 | - # Ensure :phoenix_kit_css_sources compiler is registered in mix.exs |
| 379 | - igniter = ensure_css_sources_compiler(igniter) |
| 378 | + # Register both compilers in a SINGLE mix.exs edit — touching :compilers |
| 379 | + # from two separate Igniter.Project.MixProject.update/4 calls corrupts |
| 380 | + # the second registration (see Common.ensure_compilers_registered/2). |
| 381 | + igniter = |
| 382 | + Common.ensure_compilers_registered(igniter, [ |
| 383 | + :phoenix_kit_css_sources, |
| 384 | + :phoenix_kit_js_sources |
| 385 | + ]) |
| 380 386 | |
| 381 | - # Ensure the external-module JS integration is wired (compiler + aggregate |
| 382 | - # script tag). Picks up the feature on hosts installed before it existed. |
| 387 | + # Ensure the rest of the external-module JS integration is wired |
| 388 | + # (aggregate file, script tag). Picks up the feature on hosts installed |
| 389 | + # before it existed. |
| 383 390 | igniter = JsIntegration.ensure_module_js_integration(igniter) |
| 384 391 | |
| 385 392 | # Check if this is the first pass (config missing) or second pass (config exists) |
| @@ -940,28 +947,6 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do | |
| 940 947 | Mix.Task.run("phoenix_kit.status", args) |
| 941 948 | end |
| 942 949 | |
| 943 | - # Add :phoenix_kit_css_sources compiler to the parent app's mix.exs if missing. |
| 944 | - defp ensure_css_sources_compiler(igniter) do |
| 945 | - Igniter.Project.MixProject.update(igniter, :project, [:compilers], fn |
| 946 | - nil -> |
| 947 | - # No :compilers key yet — keep the defaults by prepending. |
| 948 | - {:ok, {:code, quote(do: [:phoenix_kit_css_sources] ++ Mix.compilers())}} |
| 949 | - |
| 950 | - zipper -> |
| 951 | - case Igniter.Code.List.prepend_new_to_list(zipper, :phoenix_kit_css_sources) do |
| 952 | - {:ok, zipper} -> {:ok, zipper} |
| 953 | - :error -> {:warning, "Could not add :phoenix_kit_css_sources to compilers in mix.exs"} |
| 954 | - end |
| 955 | - end) |
| 956 | - rescue |
| 957 | - _ -> |
| 958 | - Igniter.add_warning( |
| 959 | - igniter, |
| 960 | - "⚠️ Could not add :phoenix_kit_css_sources compiler to mix.exs. " <> |
| 961 | - "Please add compilers: [:phoenix_kit_css_sources] ++ Mix.compilers() to your project/0." |
| 962 | - ) |
| 963 | - end |
| 964 | - |
| 965 950 | # Update CSS integration during PhoenixKit updates |
| 966 951 | defp update_css_integration do |
| 967 952 | css_paths = [ |
| @@ -7,11 +7,91 @@ defmodule PhoenixKit.Install.Common do | |
| 7 7 | - Version formatting |
| 8 8 | - Status checking |
| 9 9 | - Migration detection |
| 10 | + - Registering PhoenixKit's Mix compilers in a host's `mix.exs` |
| 10 11 | """ |
| 11 12 | |
| 12 13 | alias PhoenixKit.Config |
| 13 14 | alias PhoenixKit.Migrations.Postgres |
| 14 15 | |
| 16 | + @doc """ |
| 17 | + Ensures every atom in `compiler_names` is present in the host's `mix.exs` |
| 18 | + `project/0` `:compilers` list — in ONE `Igniter.Project.MixProject.update/4` |
| 19 | + call across every compiler PhoenixKit registers. |
| 20 | + |
| 21 | + This must be a single call spanning all of them, not one call per compiler. |
| 22 | + `Igniter.Code.List.prepend_new_to_list/2` only understands a literal list |
| 23 | + AST. Registering against an absent `:compilers` key has to produce `atoms |
| 24 | + ++ Mix.compilers()` (a `++` call, not a literal list — `Mix.compilers()` is |
| 25 | + a live call that can't be flattened at install time). A SECOND, separate |
| 26 | + `Igniter.Project.MixProject.update/4` call touching the same key then lands |
| 27 | + on that `++` node instead of a list, and `prepend_new_to_list/2` silently |
| 28 | + fails into a `{:warning, ...}` that's easy to miss in the wall of `mix |
| 29 | + phoenix_kit.update`/`mix phoenix_kit.install` output — so the second |
| 30 | + compiler never actually gets registered even though the run reports |
| 31 | + success. This is not hypothetical: it's exactly how a production host ended |
| 32 | + up with `:phoenix_kit_css_sources` registered (added first) but |
| 33 | + `:phoenix_kit_js_sources` silently missing (added second, in a separate |
| 34 | + call) across many `phoenix_kit.update` runs — so PhoenixKit's own JS hook |
| 35 | + fixes never reached the browser. |
| 36 | + |
| 37 | + Also repairs a `:compilers` value an affected host is already stuck with in |
| 38 | + that broken `[some_atom] ++ Mix.compilers()` shape: descends into the |
| 39 | + literal list on the left of `++` and prepends there instead of bailing. |
| 40 | + """ |
| 41 | + def ensure_compilers_registered(igniter, compiler_names) when is_list(compiler_names) do |
| 42 | + Igniter.Project.MixProject.update(igniter, :project, [:compilers], fn |
| 43 | + nil -> |
| 44 | + # No :compilers key yet — must keep the defaults, so prepend to |
| 45 | + # Mix.compilers() rather than replacing the whole list. |
| 46 | + {:ok, {:code, quote(do: unquote(compiler_names) ++ Mix.compilers())}} |
| 47 | + |
| 48 | + zipper -> |
| 49 | + zipper |
| 50 | + |> resolve_literal_compilers_list() |
| 51 | + |> case do |
| 52 | + {:ok, list_zipper} -> prepend_missing(list_zipper, compiler_names) |
| 53 | + :error -> :error |
| 54 | + end |
| 55 | + |> case do |
| 56 | + {:ok, zipper} -> |
| 57 | + {:ok, zipper} |
| 58 | + |
| 59 | + :error -> |
| 60 | + {:warning, |
| 61 | + "Could not add #{inspect(compiler_names)} to compilers in mix.exs — " <> |
| 62 | + "please add them manually: compilers: #{inspect(compiler_names)} ++ Mix.compilers()"} |
| 63 | + end |
| 64 | + end) |
| 65 | + end |
| 66 | + |
| 67 | + # The zipper is either already a literal list (`compilers: [:a, :b]`), or |
| 68 | + # `[:a] ++ Mix.compilers()` (the shape THIS module itself produces on first |
| 69 | + # registration, or that a foreign tool produced the same way) — descend |
| 70 | + # into the literal list on the left of `++` so callers can prepend into it. |
| 71 | + # Anything else (a bare variable, a function call returning a list, etc.) |
| 72 | + # is refused rather than guessed at. |
| 73 | + defp resolve_literal_compilers_list(zipper) do |
| 74 | + cond do |
| 75 | + Igniter.Code.List.list?(zipper) -> |
| 76 | + {:ok, zipper} |
| 77 | + |
| 78 | + Igniter.Code.Function.function_call?(zipper, :++, 2) -> |
| 79 | + Igniter.Code.Function.move_to_nth_argument(zipper, 0) |
| 80 | + |
| 81 | + true -> |
| 82 | + :error |
| 83 | + end |
| 84 | + end |
| 85 | + |
| 86 | + defp prepend_missing(zipper, names) do |
| 87 | + Enum.reduce_while(names, {:ok, zipper}, fn name, {:ok, zipper} -> |
| 88 | + case Igniter.Code.List.prepend_new_to_list(zipper, name) do |
| 89 | + {:ok, zipper} -> {:cont, {:ok, zipper}} |
| 90 | + :error -> {:halt, :error} |
| 91 | + end |
| 92 | + end) |
| 93 | + end |
| 94 | + |
| 15 95 | @doc """ |
| 16 96 | Generates timestamp in Ecto migration format. |
Loading more files…