mix corex.new
(Corex v0.1.0-alpha.33)
View Source
Creates a new Phoenix application with Corex preconfigured.
Use this task when you want to start a new project with Corex, Phoenix, optional Ecto, and default Corex styling and layout. To add Corex to an existing Phoenix app instead, see Manual installation.
It expects the path of the project as an argument:
$ mix corex.new PATH [--module MODULE] [--app APP]
A project at the given PATH will be created. The application name and module name will be retrieved from the path, unless --module or --app is given.
Options
--umbrella- generate an umbrella project, with one application for your domain, and a second application for the web interface.--app- the name of the OTP application--module- the name of the base module in the generated skeleton--database- specify the database adapter for Ecto. One of:postgres- via https://github.com/elixir-ecto/postgrexmysql- via https://github.com/elixir-ecto/myxqlmssql- via https://github.com/livehelpnow/tdssqlite3- via https://github.com/elixir-sqlite/ecto_sqlite3
Please check the driver docs for more information and requirements. Defaults to "postgres".
--adapter- specify the http adapter. One of:cowboy- via https://github.com/elixir-plug/plug_cowboybandit- via https://github.com/mtrudel/bandit
Please check the adapter docs for more information and requirements. Defaults to "bandit".
--no-dashboard- do not include Phoenix.LiveDashboard--no-ecto- do not generate Ecto files--designex- keep design tokens and designex-related files underassets/corex/designso you can run designex for token builds; when not set, only built CSS/tokens are copied (same asmix corex.designvsmix corex.design --designex)--no-design- do not include Corex design (tokens, component CSS) or Tailwind; use a prebuilt default.css instead (same as original Phoenix installer with no Tailwind)--mode- enable light/dark mode switching (adds Mode plug, root script, and mode_toggle in layout); when omitted, app stays static light only; no default config, user can change behavior themselves--theme- colon-separated theme names (e.g.uno:leo); when multiple themes are given, enables theme switching; each must be one of neo, uno, duo, leo--lang- colon-separated locales (e.g.en:ar:fr); first is default; when multiple locales are given, enables locale switching (adds Locale plug, SharedEvents, and locale_switcher in layout)--rtl- colon-separated RTL locales (e.g.ar); requires--lang; all must be in language--binary-id- usebinary_idas primary key type in Ecto schemas--verbose- use verbose output-v,--version- prints the Corex installer version--no-version-check- skip the version check for the latest corex_new version--no-agents-md- do not generate anAGENTS.mdfile--no-a11y- do not include accessibility testing (Wallaby, a11y_audit) or the home-page a11y test--no-tidewave- do not include Tidewave dev dependency or the Tidewave Plug in the endpoint
When passing the --no-ecto flag, Phoenix generators such as
phx.gen.html, phx.gen.json, phx.gen.live, and phx.gen.context
may no longer work as expected as they generate context files that rely
on Ecto for the database access. In those cases, you can pass the
--no-context flag to generate most of the HTML and JSON files
but skip the context, allowing you to fill in the blanks as desired.
Installation of the generator
To use this task, install the Corex project generator archive:
$ mix archive.install hex corex_new
To update the generator to the latest version:
$ mix local.corex
When generating a project, mix corex.new by default prompts you to fetch and install the new project's dependencies. You can enable this behaviour by passing the --install flag or disable it with the --no-install flag.
Examples
$ mix corex.new hello_world
Is equivalent to:
$ mix corex.new hello_world --module HelloWorld
With locale switching (English, French, Arabic), RTL for Arabic, light/dark mode, and multiple themes:
$ mix corex.new my_app --lang en:fr:ar --rtl ar --mode --theme neo:uno:duo:leo
As an umbrella:
$ mix corex.new hello --umbrella
Would generate the following directory structure and modules:
hello_umbrella/ Hello.Umbrella
apps/
hello/ Hello
hello_web/ HelloWebYou can read more about umbrella projects in the mix documentation
COREX_NEW_CACHE_DIR
In rare cases, it may be useful to copy the build from a previously
cached build. To do this, set the COREX_NEW_CACHE_DIR environment
variable before running mix corex.new. For example, you could generate a
cache by running:
mix corex.new mycache --no-install && cd mycache && mix deps.get && mix deps.compile && mix assets.setup && rm -rf assets config lib priv test mix.exs README.md
Your cached build directory should contain:
_build
deps
mix.lockThen you could run:
COREX_NEW_CACHE_DIR=/path/to/mycache mix corex.new myapp
The entire cache directory will be copied to the new project, replacing any existing files where conflicts exist.