View Source mix surface.init (surface v0.11.4)

Configures Surface on an phoenix project.

This task is mostly meant to be used after bootstrapping a fresh Phoenix project using mix phx.new. Although it can also be used on existing non-fresh projects, some patches might not be applicable as they may depend on file content code/patterns that are no longer available.

If such cases are detected, the task will inform which patches were skipped as well as provide instructions for manual configuration.

$ mix surface.init

Important note

This task is still experimental. Make sure you have committed your work or have a proper backup before running it. As it may change a few files in the project, it's recommended to have a safe way to rollback the changes in case anything goes wrong.

Options

  • --catalogue - Configures the experimental Surface Catalogue for the project, which will be available at the /catalogue route. For more information see: https://github.com/surface-ui/surface_catalogue.

  • --demo - Generates a sample <Hero> component. When used together with the --catalogue option, it additionally generates two catalogue examples and a playground for the component.

  • --layouts - Replaces the generated .heex layouts with .sface files compatible with Surface. Warning: using this option always replaces the existing layouts, so any changes done in those layout files will be lost. It's recommended to use this option only on fresh projects.

  • --yes - automatic answer "yes" to all prompts. Warning: this will also say "yes" to overwrite existing files as well as fetching/installing dependencies, if required.

  • --dry-run - does not save, delete or patch any file.

  • --no-formatter - do not configure the Surface formatter.

  • --no-js-hooks - do not configure automatic loading of colocated JS hook files.

  • --no-scoped-css - do not configure scoped CSS for components.

  • --no-error-tag - do not configure the ErrorTag component to use the ErrorHelpers.translate_error/1 function generated by mix phx.new when Gettext support is detected.

  • --no-install - do not fetch and install added/updated dependencies.

  • --web-module - Configures the name of the Web module. Defaults to MyAppWeb.