defmodule Lain.CLI do @certpath Path.join([ Mix.Project.build_path(), "lib", "castore", "priv", "cacerts.pem" ]) @external_resource @certpath @cacerts File.read!(@certpath) def main([command, path]) do Application.put_env( :tailwind, :cacerts_path, Path.join([File.cwd!(), "_build", "castore.pem"]) ) tailwind_args = [ "--config=#{Path.join(Path.expand(path), "tailwind.config.js")}", "--input=#{Path.join(Path.expand(path), "assets/app.css")}", "--output=#{Path.join(Path.expand(path), "build/assets/app.css")}", "--minify" ] Application.put_all_env( tailwind: [ version: "3.2.7", default: [ args: tailwind_args, cd: Path.expand(path) ] ] ) Application.ensure_all_started([:castore, :inets, :ssl, :tailwind, :autumn]) File.write!(Path.join("_build", "castore.pem"), @cacerts) Tailwind.install_and_run(:default, tailwind_args) case command do "build" -> Lain.run(path) "clean" -> Lain.clean(path) "serve" -> Lain.serve(path) end end end