refrakt_cli/diff
refrakt diff — show how the app differs from what the current
templates generate.
Generated code belongs to the app, so upgrading refrakt_cli never
changes it. refrakt diff renders the app again with the installed
refrakt_cli into a temporary directory: refrakt new with the app’s
name and database, then every generator recorded in
.refrakt/generated.toml, in order. It then prints a unified diff of
each file against the app’s copy. It never writes into the app.
Apps created before the manifest existed have none; their generators
are inferred from the app’s files (see infer).
Types
The outcome of comparing the app with the rendered templates.
pub type Report {
Report(
changed: List(String),
missing: List(String),
only_in_app: List(String),
compared: Int,
problems: List(String),
)
}
Constructors
-
Report( changed: List(String), missing: List(String), only_in_app: List(String), compared: Int, problems: List(String), )Arguments
- changed
-
Generated files whose content differs from the app’s copy
- missing
-
Generated files the app does not have
- only_in_app
-
App files under src/, test/ and priv/ that no generator writes
- compared
-
How many generated files were compared
- problems
-
Generators that could not be replayed
Values
pub fn check(paths: List(String)) -> Result(Report, String)
Compare the app in the current directory with what the templates
generate, limited to paths (all files when empty), without printing.
pub fn infer(app: String) -> List(List(String))
Infer the generators run in an app that has no manifest, from its files:
gen resource: adata/migrations/NNN_create_<plural>.sqlwith a matchingweb/<singular>_handler.gleamanddomain/<singular>.gleam. Field names,optional(...),--belongs-to(REFERENCES) and most types come from the CREATE TABLE; the domain type tells Bool from Int, the form view tells text (a textarea) from string, the tests tell date and datetime from string on SQLite. No views means--api.gen auth:create_userswithweb/auth_handler.gleamgen live:web/<name>_live_handler.gleamgen island:web/islands/<name>_embed.gleamgen page: any otherweb/<name>_handler.gleam
They are ordered by where their routes appear in the router, which is the order generators insert them in.
pub fn main(args: List(String)) -> Nil
Entry point for refrakt diff: runs and exits with its status.