Skip to content

Commit fc052a9

Browse files
authored
feature: Migrate to Phoenix 1.6 (#134)
feature: Migrate to Phoenix 1.6
1 parent 6a07bb8 commit fc052a9

File tree

147 files changed

+3030
-14854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+3030
-14854
lines changed

.formatter.exs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[
2+
surface_line_length: 120,
23
import_deps: [:ecto, :phoenix, :surface],
3-
surface_inputs: ["{lib,test}/**/*.{ex,exs,sface}"],
4-
inputs: [
5-
"mix.exs",
6-
"{config,lib,test,priv,web}/**/*.{ex,exs}"
7-
],
4+
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
5+
surface_inputs: ["{lib,test}/**/*.{ex,sface}"],
6+
subdirectories: ["priv/*/migrations"],
87
locals_without_parens: [
98
# Formatter tests
109
assert_format: 2,

.github/workflows/tests.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on: push
33
jobs:
44
dependencies:
55
runs-on: ubuntu-latest
6+
env:
7+
MIX_ENV: test
68
strategy:
79
matrix:
810
elixir: ["1.12.2"]
@@ -42,6 +44,8 @@ jobs:
4244
static-code-analysis:
4345
needs: dependencies
4446
runs-on: ubuntu-latest
47+
env:
48+
MIX_ENV: test
4549
strategy:
4650
matrix:
4751
elixir: ["1.12.2"]
@@ -82,7 +86,7 @@ jobs:
8286
otp: ["24.0"]
8387
services:
8488
db:
85-
image: postgres:latest
89+
image: postgres:13-alpine
8690
ports: ["5432:5432"]
8791
env:
8892
POSTGRES_PASSWORD: postgres
@@ -120,6 +124,9 @@ jobs:
120124
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}-v2
121125
- name: Install NPM Packages (Global)
122126
run: yarn install
127+
- name: Seed
128+
run: |
129+
MIX_ENV=test mix ecto.setup
123130
- run: mix coveralls.json --trace --slowest 10
124131
- uses: codecov/codecov-action@v2
125132
with:

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ config/local.exs
1515
cover
1616
.elixir_ls
1717

18-
priv/static
19-
priv/static
18+
/priv/static/assets/

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
elixir 1.12.2-otp-24
22
erlang 24.0
3+
nodejs 14.16.1

assets/build.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const esbuild = require('esbuild')
2+
const { sassPlugin } = require('esbuild-sass-plugin')
3+
const path = require('path')
4+
5+
const bundle = true
6+
const logLevel = process.env.ESBUILD_LOG_LEVEL || 'silent'
7+
const watch = !!process.env.ESBUILD_WATCH
8+
9+
const plugins = [
10+
sassPlugin({
11+
includePaths: [path.resolve(__dirname, 'node_modules')]
12+
})
13+
]
14+
15+
const promise = esbuild.build({
16+
entryPoints: ['js/index.ts'],
17+
bundle,
18+
target: 'es2016',
19+
plugins,
20+
outdir: '../priv/static/assets',
21+
logLevel,
22+
watch,
23+
loader: {
24+
'.eot': 'file',
25+
'.woff': 'file',
26+
'.woff2': 'file',
27+
'.svg': 'file',
28+
'.ttf': 'file'
29+
}
30+
})
31+
32+
if (watch) {
33+
promise.then((_result) => {
34+
process.stdin.on('close', () => {
35+
process.exit(0)
36+
})
37+
38+
process.stdin.resume()
39+
})
40+
}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap");
2-
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts" !default;
3-
@import "~@fortawesome/fontawesome-free/scss/fontawesome";
4-
@import "~@fortawesome/fontawesome-free/scss/solid";
5-
@import "~@fortawesome/fontawesome-free/scss/brands";
6-
@import "~@fortawesome/fontawesome-free/scss/v4-shims";
72

83
.file-table {
94
line-height: 1.1em;

assets/js/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// We import the CSS which is extracted to its own file by esbuild.
2+
// Remove this line if you add a your own CSS build pipeline (e.g postcss).
3+
import '@fortawesome/fontawesome-free'
4+
import '@fortawesome/fontawesome-free/js/solid'
5+
import '@fortawesome/fontawesome-free/js/regular'
6+
import '@fortawesome/fontawesome-free/js/brands'
7+
8+
// If you want to use Phoenix channels, run `mix help phx.gen.channel`
9+
// to get started and then uncomment the line below.
10+
// import "./user_socket.js"
11+
12+
// You can include dependencies in two ways.
13+
//
14+
// The simplest option is to put them in assets/vendor and
15+
// import them using relative paths:
16+
//
17+
// import "./vendor/some-package.js"
18+
//
19+
// Alternatively, you can `npm install some-package` and import
20+
// them using a path starting with the package name:
21+
//
22+
// import "some-package"
23+
//
24+
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
25+
import 'phoenix_html'
26+
// Establish Phoenix Socket and LiveView configuration.
27+
import { Socket } from 'phoenix'
28+
import { LiveSocket } from 'phoenix_live_view'
29+
import topbar from '../vendor/topbar'
30+
31+
const csrfToken = document
32+
.querySelector("meta[name='csrf-token']")
33+
?.getAttribute('content')
34+
const liveSocket = new LiveSocket('/live', Socket, {
35+
params: { _csrf_token: csrfToken }
36+
})
37+
38+
// Show progress bar on live navigation and form submits
39+
topbar.config({ barColors: { 0: '#29d' }, shadowColor: 'rgba(0, 0, 0, .3)' })
40+
window.addEventListener('phx:page-loading-start', (info) => topbar.show())
41+
window.addEventListener('phx:page-loading-stop', (info) => topbar.hide())
42+
43+
// connect if there are any LiveViews on the page
44+
liveSocket.connect()
45+
46+
// expose liveSocket on window for web console debug logs and latency simulation:
47+
// >> liveSocket.enableDebug()
48+
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
49+
// >> liveSocket.disableLatencySim()
50+
// @ts-expect-error
51+
window.liveSocket = liveSocket

assets/vendor/topbar.js

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/**
2+
* @license MIT
3+
* topbar 1.0.0, 2021-01-06
4+
* http://buunguyen.github.io/topbar
5+
* Copyright (c) 2021 Buu Nguyen
6+
*/
7+
;(function (window, document) {
8+
'use strict'
9+
10+
// https://gist.github.com/paulirish/1579671
11+
;(function () {
12+
var lastTime = 0
13+
var vendors = ['ms', 'moz', 'webkit', 'o']
14+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
15+
window.requestAnimationFrame =
16+
window[vendors[x] + 'RequestAnimationFrame']
17+
window.cancelAnimationFrame =
18+
window[vendors[x] + 'CancelAnimationFrame'] ||
19+
window[vendors[x] + 'CancelRequestAnimationFrame']
20+
}
21+
if (!window.requestAnimationFrame)
22+
window.requestAnimationFrame = function (callback, element) {
23+
var currTime = new Date().getTime()
24+
var timeToCall = Math.max(0, 16 - (currTime - lastTime))
25+
var id = window.setTimeout(function () {
26+
callback(currTime + timeToCall)
27+
}, timeToCall)
28+
lastTime = currTime + timeToCall
29+
return id
30+
}
31+
if (!window.cancelAnimationFrame)
32+
window.cancelAnimationFrame = function (id) {
33+
clearTimeout(id)
34+
}
35+
})()
36+
37+
var canvas,
38+
progressTimerId,
39+
fadeTimerId,
40+
currentProgress,
41+
showing,
42+
addEvent = function (elem, type, handler) {
43+
if (elem.addEventListener) elem.addEventListener(type, handler, false)
44+
else if (elem.attachEvent) elem.attachEvent('on' + type, handler)
45+
else elem['on' + type] = handler
46+
},
47+
options = {
48+
autoRun: true,
49+
barThickness: 3,
50+
barColors: {
51+
0: 'rgba(26, 188, 156, .9)',
52+
'.25': 'rgba(52, 152, 219, .9)',
53+
'.50': 'rgba(241, 196, 15, .9)',
54+
'.75': 'rgba(230, 126, 34, .9)',
55+
'1.0': 'rgba(211, 84, 0, .9)'
56+
},
57+
shadowBlur: 10,
58+
shadowColor: 'rgba(0, 0, 0, .6)',
59+
className: null
60+
},
61+
repaint = function () {
62+
canvas.width = window.innerWidth
63+
canvas.height = options.barThickness * 5 // need space for shadow
64+
65+
var ctx = canvas.getContext('2d')
66+
ctx.shadowBlur = options.shadowBlur
67+
ctx.shadowColor = options.shadowColor
68+
69+
var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0)
70+
for (var stop in options.barColors)
71+
lineGradient.addColorStop(stop, options.barColors[stop])
72+
ctx.lineWidth = options.barThickness
73+
ctx.beginPath()
74+
ctx.moveTo(0, options.barThickness / 2)
75+
ctx.lineTo(
76+
Math.ceil(currentProgress * canvas.width),
77+
options.barThickness / 2
78+
)
79+
ctx.strokeStyle = lineGradient
80+
ctx.stroke()
81+
},
82+
createCanvas = function () {
83+
canvas = document.createElement('canvas')
84+
var style = canvas.style
85+
style.position = 'fixed'
86+
style.top = style.left = style.right = style.margin = style.padding = 0
87+
style.zIndex = 100001
88+
style.display = 'none'
89+
if (options.className) canvas.classList.add(options.className)
90+
document.body.appendChild(canvas)
91+
addEvent(window, 'resize', repaint)
92+
},
93+
topbar = {
94+
config: function (opts) {
95+
for (var key in opts)
96+
if (options.hasOwnProperty(key)) options[key] = opts[key]
97+
},
98+
show: function () {
99+
if (showing) return
100+
showing = true
101+
if (fadeTimerId !== null) window.cancelAnimationFrame(fadeTimerId)
102+
if (!canvas) createCanvas()
103+
canvas.style.opacity = 1
104+
canvas.style.display = 'block'
105+
topbar.progress(0)
106+
if (options.autoRun) {
107+
;(function loop() {
108+
progressTimerId = window.requestAnimationFrame(loop)
109+
topbar.progress(
110+
'+' + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
111+
)
112+
})()
113+
}
114+
},
115+
progress: function (to) {
116+
if (typeof to === 'undefined') return currentProgress
117+
if (typeof to === 'string') {
118+
to =
119+
(to.indexOf('+') >= 0 || to.indexOf('-') >= 0
120+
? currentProgress
121+
: 0) + parseFloat(to)
122+
}
123+
currentProgress = to > 1 ? 1 : to
124+
repaint()
125+
return currentProgress
126+
},
127+
hide: function () {
128+
if (!showing) return
129+
showing = false
130+
if (progressTimerId != null) {
131+
window.cancelAnimationFrame(progressTimerId)
132+
progressTimerId = null
133+
}
134+
;(function loop() {
135+
if (topbar.progress('+.1') >= 1) {
136+
canvas.style.opacity -= 0.05
137+
if (canvas.style.opacity <= 0.05) {
138+
canvas.style.display = 'none'
139+
fadeTimerId = null
140+
return
141+
}
142+
}
143+
fadeTimerId = window.requestAnimationFrame(loop)
144+
})()
145+
}
146+
}
147+
148+
if (typeof module === 'object' && typeof module.exports === 'object') {
149+
module.exports = topbar
150+
} else if (typeof define === 'function' && define.amd) {
151+
define(function () {
152+
return topbar
153+
})
154+
} else {
155+
this.topbar = topbar
156+
}
157+
}.call(this, window, document))

compile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
./node_modules/.bin/webpack build --mode production
2-
mix phx.digest
1+
mix assets.deploy

config/config.exs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ config :scrivener_html,
3030

3131
config :librecov, PlugBasicAuth, enable: false
3232

33-
config :seedex, repo: Librecov.Repo
34-
3533
config :librecov, :email,
3634
sender: "LibreCov <info@librecov.com>",
3735
smtp: [

0 commit comments

Comments
 (0)