ExtraChecksRunnerNode

Run checks in the command line.

program :
{ checks : Array Check
, extraPaths : Array String
}
-> Program

Fully assembled command line program to run checks, re-running on file changes. Use from a node gren project as the main. Be aware that if you change the gren.json/dependencies of the project to check the program needs to be restarted.

If you just want to list all errors once without fixes and without watching for changes, run the node program not in TTY mode, for example with gren run Main | cat on linux.

In projects where security is important, you can instead assemble the parts that define a ExtraChecksRunnerNode.program yourself, for you to inspect and mess with:

program =
    Node.defineProgram
        { init =
            \environment ->
                Init.await Terminal.initialize
                    (\maybeTerminalConfiguration ->
                        Init.await FileSystem.initialize
                            (\fileSystemPermission ->
                                Init.awaitTask
                                    (initWith config
                                        { environment = environment
                                        , terminalConfiguration = maybeTerminalConfiguration
                                        , fileSystemPermission = fileSystemPermission
                                        }
                                    )
                                    Node.startProgram
                            )
                    )
        , update = \event state -> update config event state
        , subscriptions = \state -> subscriptions config state
        }

Notice how initWith being a Task (not Init.Task) enforces that the program cannot itself attain new permissions, to for example reach out to the internet.

type alias Program = Program ProgramState ProgramEvent

A node program produced by ExtraChecksRunnerNode.program

initWith :
{ checks : Array Check
, extraPaths : Array String
}
-> { environment : Environment, terminalConfiguration : Maybe Configuration, fileSystemPermission : Permission }
-> Task Never { model : ProgramState, command : Cmd ProgramEvent
}

The "starting up" part of a program definition for assembling yourself.

Notice how initWith being a Task (not Init.Task) enforces that the program cannot itself attain new permissions, to for example reach out to the internet.

update :
{ checks : Array Check
, extraPaths : Array String
}
-> ProgramEvent
-> ProgramState
-> { model : ProgramState, command : Cmd ProgramEvent
}

The "react to an incoming event" part of a program definition for assembling yourself

subscriptions :
{ checks : Array Check
, extraPaths : Array String
}
-> ProgramState
-> Sub ProgramEvent

The "listen to incoming events" part of a program definition for assembling yourself

type ProgramEvent
= ModuleWatchEvent ({ sourceDirectory : Path, event : WatchEvent })
| ModuleAddedOrChanged ({ path : Path, source : Result String String })
| ModuleRemoved ({ path : Path })
| ExtraFileWatchEvent ({ path : String, event : WatchEvent })
| ExtraFileAddedOrChanged ({ path : Path, source : Result String String })
| ExtraFileRemoved ({ path : Path })
| Typed (Result Error Bytes)

Msg of a ExtraChecksRunnerNode.program