Composer.Helpers (composer v0.2.0)

Copy Markdown View Source

Conveniences for writing steps.

Summary

Functions

Returns the camelized app module name (e.g. "MyApp").

Returns the app's web module name (e.g. "MyAppWeb").

Creates a file unless it already exists, in the project or on disk.

Generates a migration with a unique timestamp.

Returns the app's Repo module (e.g. MyApp.Repo).

Updates a file's content, adding a loud warning instead of silently no-oping when the transformation changes nothing or the file is missing.

Updates a file's raw content with a transformation function.

Functions

app_module(igniter)

Returns the camelized app module name (e.g. "MyApp").

app_web_module(igniter)

Returns the app's web module name (e.g. "MyAppWeb").

create_unless_exists(igniter, path, contents)

Creates a file unless it already exists, in the project or on disk.

Use this rather than Igniter.create_new_file/4 with on_exists: :skip, which overwrites a file that exists on disk but has not been read into the igniter yet.

gen_migration(igniter, repo, name, opts \\ [])

Generates a migration with a unique timestamp.

Ecto refuses to run duplicate migration versions, and a composer can create several within the same second, so the timestamp is advanced past every migration already present.

repo(igniter)

Returns the app's Repo module (e.g. MyApp.Repo).

update_file_checked(igniter, path, transform, warning)

Updates a file's content, adding a loud warning instead of silently no-oping when the transformation changes nothing or the file is missing.

Steps that pattern-match against phx.new output should use this so that drift in Phoenix's generators surfaces as a warning instead of silence.

update_file_content(igniter, path, transform)

Updates a file's raw content with a transformation function.