*/ private static function manifest(): array { $path = storage_path('app/deployment.json'); if (! File::exists($path)) { return []; } return (array) (json_decode((string) File::get($path), true) ?: []); } /** * A timestamp that cannot take the console down. * * The manifest is written by a shell script during a deployment, and every * other field here is already treated as possibly corrupt. An unparseable * date throwing out of a layout partial would 500 every admin page — over a * line of small print in the sidebar. */ private static function timestamp(mixed $value): ?Carbon { if (! is_string($value) || $value === '') { return null; } try { return Carbon::parse($value); } catch (Throwable) { return null; } } /** The short commit, for a footer that has no room for forty characters. */ public function shortCommit(): ?string { return $this->commit !== null ? substr($this->commit, 0, 7) : null; } /** * One line, honest about what it is. * * "1.0.0 (abc1234)" only for a deployment pinned to that tag. Anything else * is somewhere after the release and says so — reporting a main deployment * as a clean 1.0.0 is how a bug report ends up filed against the wrong code. */ public function label(): string { $commit = $this->shortCommit(); if ($this->isTaggedRelease) { return $commit !== null ? "{$this->version} ({$commit})" : $this->version; } $line = $this->source !== null && $this->source !== '' ? ' · '.$this->source : ''; return $commit !== null ? "{$this->version}-dev ({$commit}){$line}" : "{$this->version}-dev{$line}"; } }