# `mix castle.appup.gen`
[🔗](https://github.com/ausimian/forecastle/blob/1.0.0/lib/mix/tasks/castle.appup.gen.ex#L1)

Drafts appup entries for a transition and writes them to source.

    mix castle.appup.gen --from <spec> [--to <spec>] [--app <app>]...

The build and application options match `mix castle.appup`. Review the
generated source and comments before committing it.

## Drafts

`Forecastle.Appup.Draft` selects instructions from module changes and BEAM
behaviour attributes. The draft calls out decisions that require review,
including state migration data, missing `code_change` callbacks, supervisor
children, unsupervised processes, changed behaviour roles, and instruction
ordering.

Existing entries selected for the same from-version are not changed. Use
`mix castle.appup` after generation to verify coverage.

## Writing

For an owned application, the task writes the file named by the `:appup`
project key. If the key is absent, it writes `appup.exs` beside `mix.exs` and
tells you to configure the key and compiler.

For a dependency, it writes
`rel/appups/<app>-<from>-<to>.exs`. Forecastle places this file in the assembled
release and never writes to `deps/`.

A missing source is created. A pure-literal appup source is updated without
changing its comments or formatting. Computed source is refused and the entry
is printed for manual merging.

The task also refuses applications present in only one build, unchanged
application versions, applications with no BEAM files, malformed appups,
ambiguous dependency entries, and files that change before replacement.

If the application version changed but no modules moved, the task writes an
empty entry. If both directions already have entries, it reports a no-op. A
dependency entry already covered by another source is also a no-op when both
directions are covered.

The default `--to` compiles the current project. If the `:appup` key names a
file that does not yet exist, provide an explicit `--to` baseline or leave the
key unset until the first source has been generated.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
