adds schema view and schema generating command

This commit is contained in:
2026-11-03 09:35:41 +01:00
parent cc41decccb
commit 600d4874d2
62 changed files with 4416 additions and 105 deletions
@@ -0,0 +1,41 @@
import Foundation
/// How a line in the Schema view's artisan console is painted.
public enum ArtisanLineKind: String, Sendable, Equatable {
case command
case output
case error
case success
}
public struct ArtisanConsoleLine: Sendable, Equatable {
public var text: String
public var kind: ArtisanLineKind
public init(text: String, kind: ArtisanLineKind) {
self.text = text
self.kind = kind
}
}
public enum ArtisanOutputClassifier {
/// `$ php artisan helder:schema`, the echo before a run.
public static let commandEcho = "$ " + SchemaPaths.commandLine
/// Stderr and `ERROR`/`Exception` lines are errors; Laravel's `INFO`/`DONE` blocks and `Wrote …` are successes.
///
/// PHP writes warnings to stderr too, but there they still mean the run went wrong for the user.
public static func classify(_ line: String, isError: Bool) -> ArtisanLineKind {
if isError { return .error }
let trimmed = line.trimmingCharacters(in: .whitespaces)
if trimmed.hasPrefix("ERROR") || trimmed.hasPrefix("FAIL") || line.contains("Exception") { return .error }
if trimmed.hasPrefix("INFO") || trimmed.hasPrefix("DONE") || trimmed.hasPrefix("Wrote ") || trimmed.hasPrefix("Schema dumped") {
return .success
}
return .output
}
public static func line(_ text: String, isError: Bool) -> ArtisanConsoleLine {
ArtisanConsoleLine(text: text, kind: classify(text, isError: isError))
}
}