Add task to check that Tailwind is up to date
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
defmodule Mix.Tasks.Tailwind.CheckVersion do
|
||||||
|
use Mix.Task
|
||||||
|
|
||||||
|
@shortdoc "Checks the the current Tailwind version is the latest"
|
||||||
|
@moduledoc """
|
||||||
|
Checks the the current Tailwind version is the latest.
|
||||||
|
|
||||||
|
Exits with 0 if versions match, 1 if the Tailwind needs to be updated.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@impl Mix.Task
|
||||||
|
def run(_args) do
|
||||||
|
Application.ensure_all_started(:req)
|
||||||
|
|
||||||
|
current_version =
|
||||||
|
Application.get_env(:tailwind, :version)
|
||||||
|
|
||||||
|
latest_version_url =
|
||||||
|
"https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest"
|
||||||
|
|
||||||
|
latest_version =
|
||||||
|
Req.get!(latest_version_url).body["tag_name"]
|
||||||
|
|> String.replace_prefix("v", "")
|
||||||
|
|
||||||
|
if current_version !== latest_version do
|
||||||
|
Mix.Shell.IO.info(
|
||||||
|
"A new tailwind version is available: #{current_version} ==> #{latest_version}"
|
||||||
|
)
|
||||||
|
|
||||||
|
System.halt(1)
|
||||||
|
else
|
||||||
|
Mix.Shell.IO.info("The tailwind version is up to date (#{current_version})")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -29,6 +29,11 @@ description = 'Update the Tailwind version configured in the project'
|
|||||||
run = 'mix tailwind.update_version'
|
run = 'mix tailwind.update_version'
|
||||||
hide = true
|
hide = true
|
||||||
|
|
||||||
|
[tasks.tailwind-outdated]
|
||||||
|
description = 'Checks that the Tailwind version is up to date'
|
||||||
|
run = 'mix tailwind.check_version'
|
||||||
|
hide = true
|
||||||
|
|
||||||
[tasks.setup]
|
[tasks.setup]
|
||||||
depends = ['npm-install']
|
depends = ['npm-install']
|
||||||
description = 'Install dependencies and setup the database'
|
description = 'Install dependencies and setup the database'
|
||||||
@@ -40,7 +45,7 @@ description = 'Update dependencies'
|
|||||||
run = ['mix deps.update --all']
|
run = ['mix deps.update --all']
|
||||||
|
|
||||||
[tasks.deps-outdated]
|
[tasks.deps-outdated]
|
||||||
depends = ['npm-outdated']
|
depends = ['npm-outdated', 'tailwind-outdated']
|
||||||
description = 'Show outdated dependencies'
|
description = 'Show outdated dependencies'
|
||||||
run = ['mix hex.outdated --all']
|
run = ['mix hex.outdated --all']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user