feat: Artisan checklist for application commands, hints and coverage gate
- migrate, migrate:rollback and deferred:purge gain --pretend and --force; they and queue:clear confirm only in production on an interactive terminal, so deploys over SSH proceed as before - result lines: Applied N migrations, Rolled back <id> of <plugin>, Cleared N jobs from <queue> - --json for migrate:status, key:generate, route:list, admin:token:create, admin:token:list, admin:token:scopes and websockets:health; -q keeps the key and the token - hints for an empty DSN, an unreachable database, an invalid app.key, a missing uploads bucket and an application binary run below its root - flare and websockets:health return bonfire.Reported after printing - long help and examples for every application command, greeter:hello and blog:publish; cmd/summer TestCommandsDocumented fails on any gap
This commit is contained in:
@@ -20,17 +20,36 @@ func GenerateAppKey() (string, error) {
|
||||
}
|
||||
|
||||
// KeyGenerateCommand prints a fresh 32-byte base64 app.key and performs no
|
||||
// other side effect (D-11).
|
||||
// other side effect (D-11). --json prints {"key": "..."}; under -q the bare
|
||||
// key is printed, because the key is the data the command exists for (D-27).
|
||||
func KeyGenerateCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "key:generate",
|
||||
Description: "Print a fresh 32-byte base64 app.key",
|
||||
Long: `Prints a new random app.key (32 bytes, base64) and changes nothing: put it in
|
||||
SUMMER_APP__KEY or config/app.yaml yourself. app.key encrypts Encrypted
|
||||
columns and signs sessions, so changing it on a running application makes
|
||||
existing encrypted values unreadable; move the old key to app.previous_keys
|
||||
first. With -q only the key is printed; --json prints {"key": "..."}.`,
|
||||
Flags: []bonfire.Flag{jsonFlag},
|
||||
Examples: []bonfire.Example{
|
||||
{Command: "key:generate", Description: "Print a new key"},
|
||||
{Command: "key:generate -q", Description: "Print only the key, for scripts: KEY=$(bin/acme key:generate -q)"},
|
||||
{Command: "key:generate --json", Description: "Print the key as JSON"},
|
||||
},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
key, err := GenerateAppKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Success(key)
|
||||
switch {
|
||||
case flagOn(in, "json"):
|
||||
return printJSON(out, map[string]string{"key": key})
|
||||
case bonfire.IsQuiet(out):
|
||||
out.Println(key)
|
||||
default:
|
||||
out.Success(key)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user