helperVersionWarnings function

List<String> helperVersionWarnings({
  1. required RunningHelperVersion running,
  2. required String? resolved,
  3. String cliVersion = constants.version,
})

Returns the WARNING: ... lines for running compared to the version the project resolves (resolved, null when unknown) and the fdb CLI version (cliVersion). Empty when everything lines up or nothing is known.

Implementation

List<String> helperVersionWarnings({
  required RunningHelperVersion running,
  required String? resolved,
  String cliVersion = constants.version,
}) {
  const rebuild = 'Hot reload/restart does not reload it; stop and rebuild the app (fdb kill, then fdb launch).';
  const unreported = 'an fdb_helper that does not report its version (older than 1.13)';
  final warnings = <String>[];

  switch (running) {
    case HelperVersionUnavailable():
      break;
    case HelperVersionReported(:final version):
      if (resolved != null && resolved != version) {
        warnings.add('WARNING: The app runs fdb_helper $version but the project resolves $resolved. $rebuild');
      }
      if (_isOlderMajorMinor(version, cliVersion)) {
        warnings
            .add('WARNING: fdb $cliVersion with fdb_helper $version; update fdb_helper to ^$cliVersion and rebuild.');
      }
    case HelperVersionNotReported():
      // Only conclusive once the resolved helper (or fdb itself) is new enough
      // to report a version; before that a silent helper is expected.
      if (resolved != null && !_isOlderMajorMinor(resolved, helperVersionReportingSince)) {
        warnings.add('WARNING: The app runs $unreported but the project resolves $resolved. $rebuild');
      }
      if (!_isOlderMajorMinor(cliVersion, helperVersionReportingSince)) {
        warnings.add('WARNING: fdb $cliVersion with $unreported; update fdb_helper to ^$cliVersion and rebuild.');
      }
  }
  return warnings;
}