describeSetup function

({Map<String, Object?> json, String line, List<String> warnings}) describeSetup(
  1. DeviceSetup setup
)

One line for the attach reply, plus warnings for anything short of verified.

Implementation

({String line, List<String> warnings, Map<String, Object?> json}) describeSetup(DeviceSetup setup) {
  final v = judgeSetup(setup);
  final here = setup.platform == 'ios'
      ? '${setup.runtime ?? "iOS ?"}, Xcode ${setup.xcodeMajor ?? "?"}, macOS ${setup.hostMajor ?? "?"}, ${setup.backend}'
      : '${setup.runtime ?? "Android ?"}, ${setup.backend}';
  final warnings = switch (v.status) {
    SetupStatus.verified => [
        for (final i in v.match!.issues) 'known issue on this setup: $i',
      ],
    SetupStatus.partial => [
        'this setup works with known issues: ${v.match!.issues.join('; ')}',
      ],
    SetupStatus.untested => [
        'this setup is untested ($here)'
            '${v.closest != null ? "; closest proven: ${v.closest!.label} (${v.closest!.status.name})" : ""}'
            '; treat input failures as possibly glint\'s, and report them',
      ],
  };
  return (
    line: 'setup: $here ยท ${v.status.name}',
    warnings: warnings,
    json: {
      'backend': setup.backend,
      'setup': here,
      'status': v.status.name,
      if (v.match != null) 'evidence': v.match!.evidence,
      if (v.match != null) 'checkedOn': v.match!.checkedOn,
      if (v.closest != null) 'closestProven': v.closest!.toJson(),
    },
  );
}