Class: Lilac::CLI::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/lilac/cli/doctor.rb

Overview

Inspect a Lilac project for the common ways a fresh lilac new fails before the user sees the page boot. Catches missing wasm runtime, dangling <lilac-component> references, unparseable .lil, and similar setup problems.

run returns 0 when every check passes (or only warns); 1 when any check produced an :error result. Output is plain-text and mirrors the layout of rails about / bundle doctor / npx ... doctor — one line per check, prefix marks the level.

Defined Under Namespace

Classes: Result

Constant Summary collapse

RUNTIME_WASM =

Where the wasm runtime is expected to live, relative to public_dir. Both live under vendor/lilac-full/ so the target-aware public mirror can prune them when building --target compiled. Sourced from the single VendorWriter::REQUIRED_ASSETS definition.

VendorWriter::REQUIRED_ASSETS[:full][:wasm]
RUNTIME_JS_ADAPTER =
VendorWriter::REQUIRED_ASSETS[:full][:bridge]

Instance Method Summary collapse

Constructor Details

#initialize(config, out: $stdout) ⇒ Doctor

Returns a new instance of Doctor.



32
33
34
35
# File 'lib/lilac/cli/doctor.rb', line 32

def initialize(config, out: $stdout)
  @config = config
  @out = out
end

Instance Method Details

#runObject

Returns exit status (0 if no errors).



38
39
40
41
42
# File 'lib/lilac/cli/doctor.rb', line 38

def run
  results = run_checks
  emit(results)
  results.any? { |r| r.level == :error } ? 1 : 0
end