Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b35270d

Browse files
authoredDec 16, 2024··
Update versions (#103)
1 parent f75fff1 commit b35270d

File tree

24 files changed

+3273
-7255
lines changed

24 files changed

+3273
-7255
lines changed
 

‎.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212

1313
- uses: erlef/setup-beam@v1
1414
with:
15-
otp-version: 24.3.3
16-
elixir-version: 1.13.4
15+
otp-version: 27.2
16+
elixir-version: 1.17.3
1717

1818
- run: mix deps.get
1919
- run: mix format --check-formatted

‎Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3 as build
1+
ARG ELIXIR_VERSION=1.17.3
2+
ARG ERLANG_VERSION=27.2
3+
ARG ALPINE_VERSION=3.20.3
4+
5+
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} AS build
26

37
# install build dependencies
48
RUN apk add --no-cache --update git build-base nodejs yarn
@@ -35,7 +39,7 @@ COPY rel rel
3539
RUN mix do sentry.package_source_code, release
3640

3741
# prepare release image
38-
FROM alpine:3.15.3 AS app
42+
FROM alpine:${ALPINE_VERSION} AS app
3943
RUN apk add --no-cache --update bash openssl git libstdc++
4044

4145
RUN mkdir /app

‎assets/package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
"phoenix_live_view": "file:../deps/phoenix_live_view"
1212
},
1313
"devDependencies": {
14-
"@babel/core": "^7.0.0",
15-
"@babel/preset-env": "^7.0.0",
16-
"babel-loader": "^8.0.0",
17-
"copy-webpack-plugin": "^4.5.0",
18-
"css-loader": "^2.1.1",
19-
"mini-css-extract-plugin": "^0.4.0",
20-
"optimize-css-assets-webpack-plugin": "^4.0.0",
21-
"uglifyjs-webpack-plugin": "^1.2.4",
22-
"webpack": "4.4.0",
23-
"webpack-cli": "^2.0.10"
14+
"@babel/core": "^7.24.4",
15+
"@babel/preset-env": "^7.24.4",
16+
"babel-loader": "^9.1.3",
17+
"copy-webpack-plugin": "^12.0.2",
18+
"css-loader": "^7.1.1",
19+
"css-minimizer-webpack-plugin": "^6.0.0",
20+
"mini-css-extract-plugin": "^2.8.1",
21+
"webpack-cli": "^5.1.4",
22+
"webpack": "5.91.0"
2423
}
2524
}

‎assets/webpack.config.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
const path = require('path');
2-
const glob = require('glob');
32
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
5-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
3+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
4+
const TerserPlugin = require("terser-webpack-plugin");
65
const CopyWebpackPlugin = require('copy-webpack-plugin');
76

87
module.exports = (env, options) => ({
98
optimization: {
109
minimizer: [
11-
new UglifyJsPlugin({ cache: true, parallel: true, sourceMap: false }),
12-
new OptimizeCSSAssetsPlugin({})
10+
new TerserPlugin(),
11+
new CssMinimizerPlugin(),
1312
]
1413
},
15-
entry: {
16-
'./js/app.js': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
17-
},
14+
entry: [
15+
'./js/app.js'
16+
],
1817
output: {
19-
filename: 'app.js',
20-
path: path.resolve(__dirname, '../priv/static/js')
18+
filename: 'js/app.js',
19+
path: path.resolve(__dirname, '../priv/static')
2120
},
2221
module: {
2322
rules: [
@@ -36,6 +35,6 @@ module.exports = (env, options) => ({
3635
},
3736
plugins: [
3837
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
39-
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
38+
new CopyWebpackPlugin({ patterns: [{ from: 'static/', to: '.' }] }),
4039
]
4140
});

‎assets/yarn.lock

Lines changed: 2143 additions & 7133 deletions
Large diffs are not rendered by default.

‎config/config.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# is restricted to this project.
66

77
# General application configuration
8-
use Mix.Config
8+
import Config
99

1010
config :diff,
1111
cache_version: 2,
@@ -24,7 +24,7 @@ config :diff, DiffWeb.Endpoint,
2424
live_view: [signing_salt: "Bmk5Cupu"]
2525

2626
# Configures Elixir's Logger
27-
config :logger, :console,
27+
config :logger, :default_formatter,
2828
format: "$metadata[$level] $message\n",
2929
metadata: [:request_id]
3030

‎config/dev.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# For development, we disable any cache and enable
44
# debugging and code reloading.
@@ -16,7 +16,8 @@ config :diff, DiffWeb.Endpoint,
1616
"node_modules/webpack/bin/webpack.js",
1717
"--mode",
1818
"development",
19-
"--watch-stdin",
19+
"--watch",
20+
"--watch-options-stdin",
2021
cd: Path.expand("../assets", __DIR__)
2122
]
2223
]
@@ -57,7 +58,7 @@ config :diff, DiffWeb.Endpoint,
5758
]
5859

5960
# Do not include metadata nor timestamps in development logs
60-
config :logger, :console, format: "[$level] $message\n"
61+
config :logger, :default_formatter, format: "[$level] $message\n"
6162

6263
# Set a higher stacktrace during development. Avoid configuring such
6364
# in production as building large stacktraces may be expensive.

‎config/prod.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# For production, don't forget to configure the url host
44
# to something meaningful, Phoenix uses this information
@@ -12,7 +12,6 @@ use Mix.Config
1212
config :diff, DiffWeb.Endpoint,
1313
http: [compress: true],
1414
url: [scheme: "https", port: 443],
15-
load_from_system_env: true,
1615
cache_static_manifest: "priv/static/cache_manifest.json"
1716

1817
config :diff,

‎config/releases.exs

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎config/runtime.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Config
2+
3+
if config_env() == :prod do
4+
config :diff,
5+
host: System.fetch_env!("DIFF_HOST"),
6+
hexpm_host: System.fetch_env!("DIFF_HEXPM_HOST"),
7+
cache_version: String.to_integer(System.fetch_env!("DIFF_CACHE_VERSION")),
8+
bucket: System.fetch_env!("DIFF_BUCKET")
9+
10+
config :diff, DiffWeb.Endpoint,
11+
http: [port: String.to_integer(System.fetch_env!("DIFF_PORT"))],
12+
url: [host: System.fetch_env!("DIFF_HOST")],
13+
secret_key_base: System.fetch_env!("DIFF_SECRET_KEY_BASE")
14+
15+
config :goth, json: System.fetch_env!("DIFF_GCP_CREDENTIALS")
16+
17+
config :sentry,
18+
dsn: System.fetch_env!("DIFF_SENTRY_DSN"),
19+
environment_name: System.fetch_env!("DIFF_ENV")
20+
21+
config :kernel,
22+
inet_dist_listen_min: String.to_integer(System.fetch_env!("BEAM_PORT")),
23+
inet_dist_listen_max: String.to_integer(System.fetch_env!("BEAM_PORT"))
24+
end

‎config/test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# We don't run a server during test. If one is required,
44
# you can enable the server option below.
@@ -9,7 +9,7 @@ config :diff, DiffWeb.Endpoint,
99
config :goth, config: %{"project_id" => "diff"}
1010

1111
# Print only warnings and errors during test
12-
config :logger, level: :warn
12+
config :logger, level: :warning
1313

1414
config :diff,
1515
package_store_impl: Diff.Package.StoreMock,

‎lib/diff/hex/hex.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Diff.Hex do
5151
def get_checksums(package, versions) do
5252
with {:ok, {200, _, releases}} <- :hex_repo.get_package(@config, package) do
5353
checksums =
54-
for release <- releases, release.version in versions do
54+
for release <- releases.releases, release.version in versions do
5555
release.outer_checksum
5656
end
5757

‎lib/diff/http.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ defmodule Diff.HTTP do
8282
end
8383

8484
defp do_retry(fun, service, times, reason) do
85-
Logger.warn("#{service} API ERROR: #{inspect(reason)}")
85+
Logger.warning("#{service} API ERROR: #{inspect(reason)}")
8686

8787
if times + 1 < @max_retry_times do
8888
sleep = trunc(:math.pow(3, times) * @base_sleep_time)

‎lib/diff/package/updater.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule Diff.Package.Updater do
4040
Process.send_after(self(), :update, 60_000)
4141
end
4242

43-
def format_packages(packages) do
43+
def format_packages(%{packages: packages}) do
4444
Enum.map(packages, fn %{name: name, versions: versions} -> {name, versions} end)
4545
end
4646
end

‎lib/diff/storage/gcs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule Diff.Storage.GCS do
4444
end
4545

4646
defp headers() do
47-
{:ok, token} = Goth.Token.for_scope(@oauth_scope)
47+
token = Goth.fetch!(@oauth_scope)
4848
[{"authorization", "#{token.type} #{token.token}"}]
4949
end
5050

‎lib/diff_web.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule DiffWeb do
4444
def live_view do
4545
quote do
4646
use Phoenix.LiveView,
47-
layout: {DiffWeb.LayoutView, "live.html"}
47+
layout: {DiffWeb.LayoutView, :live}
4848

4949
unquote(view_helpers())
5050
end
@@ -79,7 +79,9 @@ defmodule DiffWeb do
7979
defp view_helpers do
8080
quote do
8181
# Use all HTML functionality (forms, tags, etc)
82-
use Phoenix.HTML
82+
import Phoenix.HTML
83+
import Phoenix.HTML.Form
84+
use PhoenixHTMLHelpers
8385

8486
# Import LiveView helpers (live_render, live_component, live_patch, etc)
8587
import Phoenix.LiveView.Helpers

‎lib/diff_web/endpoint.ex

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule DiffWeb.Endpoint do
2626

2727
plug DiffWeb.Plugs.Status
2828
plug Plug.RequestId
29-
plug Logster.Plugs.Logger, excludes: [:params]
29+
plug Logster.Plugs.Logger, excludes: [:params], log: :info
3030

3131
plug Plug.Parsers,
3232
parsers: [:urlencoded, :multipart, :json],
@@ -50,25 +50,4 @@ defmodule DiffWeb.Endpoint do
5050
end
5151

5252
plug DiffWeb.Router
53-
54-
def init(_key, config) do
55-
if config[:load_from_system_env] do
56-
port = System.fetch_env!("DIFF_PORT")
57-
58-
case Integer.parse(port) do
59-
{_int, ""} ->
60-
host = Application.fetch_env!(:diff, :host)
61-
secret_key_base = System.fetch_env!("DIFF_SECRET_KEY_BASE")
62-
config = put_in(config[:http][:port], port)
63-
config = put_in(config[:url][:host], host)
64-
config = put_in(config[:secret_key_base], secret_key_base)
65-
{:ok, config}
66-
67-
:error ->
68-
{:ok, config}
69-
end
70-
else
71-
{:ok, config}
72-
end
73-
end
7453
end

‎lib/diff_web/gettext.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ defmodule DiffWeb.Gettext do
2020
2121
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
2222
"""
23-
use Gettext, otp_app: :diff
23+
use Gettext.Backend, otp_app: :diff
2424
end

‎lib/diff_web/plugs/forwarded.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule DiffWeb.Plugs.Forwarded do
2121
parsed_ip
2222

2323
{:error, _} ->
24-
Logger.warn("Invalid IP: #{inspect(ip)}")
24+
Logger.warning("Invalid IP: #{inspect(ip)}")
2525
nil
2626
end
2727
end

‎lib/diff_web/views/error_helpers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule DiffWeb.ErrorHelpers do
33
Conveniences for translating and building error messages.
44
"""
55

6-
use Phoenix.HTML
6+
use PhoenixHTMLHelpers
77

88
@doc """
99
Generates tag for inlined form input errors.

‎mix.exs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ defmodule Diff.MixProject do
77
version: "0.1.0",
88
elixir: "~> 1.10",
99
elixirc_paths: elixirc_paths(Mix.env()),
10-
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
1110
start_permanent: Mix.env() == :prod,
1211
aliases: aliases(),
1312
releases: releases(),
@@ -34,19 +33,21 @@ defmodule Diff.MixProject do
3433
# Type `mix help deps` for examples and options.
3534
defp deps do
3635
[
37-
{:floki, "~> 0.32.0"},
36+
{:floki, "~> 0.37.0"},
3837
{:gettext, "~> 0.11"},
3938
{:git_diff, github: "ericmj/git_diff", branch: "ericmj/fix-modes"},
4039
{:goth, "~> 1.0"},
4140
{:hackney, "~> 1.15"},
42-
{:hex_core, "~> 0.8.0"},
41+
{:hex_core, "~> 0.11.0"},
4342
{:jason, "~> 1.0"},
44-
{:logster, "~> 1.0"},
45-
{:mox, "~> 1.0.0", only: :test},
46-
{:phoenix_html, "~> 3.2"},
43+
{:logster, "~> 1.0.0"},
44+
{:mox, "~> 1.0", only: :test},
45+
{:phoenix_html, "~> 4.0"},
46+
{:phoenix_html_helpers, "~> 1.0"},
4747
{:phoenix_live_reload, "~> 1.2", only: :dev},
48-
{:phoenix_live_view, "~> 0.6"},
48+
{:phoenix_live_view, "~> 1.0"},
4949
{:phoenix_pubsub, "~> 2.0"},
50+
{:phoenix_view, "~> 2.0"},
5051
{:phoenix, "~> 1.6"},
5152
{:plug_cowboy, "~> 2.1"},
5253
{:sentry, "~> 10.2"}

‎mix.lock

Lines changed: 39 additions & 32 deletions
Large diffs are not rendered by default.

‎priv/css/app.css

Lines changed: 1010 additions & 0 deletions
Large diffs are not rendered by default.

‎test/diff_web/live/search_view_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ defmodule DiffWeb.SearchLiveViewTest do
6464
send(view.pid, {:search, "phoenix"})
6565

6666
assert render_click(view, "go", %{result: "phoenix", to: "1.4.11", from: "1.4.10"}) ==
67-
{:error, {:redirect, %{to: "/diff/phoenix/1.4.10..1.4.11"}}}
67+
{:error, {:redirect, %{to: "/diff/phoenix/1.4.10..1.4.11", status: 302}}}
6868
end
6969

7070
test "no duplicates for suggestions", %{conn: conn} do

0 commit comments

Comments
 (0)
Please sign in to comment.