mix flick.install (flick v0.1.0)

Copy Markdown

Installs flick into a Phoenix project.

What it does

  1. Vendors flick.min.js.gz (pre-minified, pre-compressed) to assets/vendor/flick.min.js.gz and priv/static/assets/js/flick.min.js.gz.
  2. Patches the root layout to add a <script> tag before app.js.
  3. Generates a WebSock behaviour module skeleton.
  4. Generates an upgrade controller.
  5. Patches router.ex with a get route for the WebSocket path.
  6. Appends a starter hook to assets/js/app.js.

Plug.Static serves .gz files automatically when gzip: true is set (the Phoenix default). No esbuild or runtime minification step required.

Steps 3–6 are skipped when --no-boilerplate is passed. All steps are idempotent — re-running is safe.

Usage

mix flick.install
mix flick.install --module TickerSocket --path /ws/ticker
mix flick.install --channels
mix flick.install --channels --no-boilerplate
mix flick.install --layout lib/my_app_web/components/layouts/root.html.heex
mix flick.install --no-boilerplate
mix flick.install --yes

Options

  • --module - WebSock module name suffix appended to the <AppWeb> namespace. Defaults to MySocket. Produces <AppWeb>.MySocket and <AppWeb>.MySocketController.
  • --path - WebSocket URL path used in the router and JS hook. Defaults to /ws.
  • --layout - path to the root layout file. Defaults to lib/<app>_web/components/layouts/root.html.heex.
  • --skip-layout - skip the root layout patch.
  • --channels - also vendor flick-channel.min.js.gz for projects using Flick.Socket.Serializer with Phoenix Channels. Can be combined with --no-boilerplate to add Channels support to an existing installation without re-running the boilerplate generator.
  • --no-boilerplate - only vendor the JS files and patch the layout; skip steps 3–6.
  • --yes - apply all changes without prompting for confirmation.