verifyAppVersion function

Future<String> verifyAppVersion (
  1. String libPkgRoot
)

Implementation

Future<String> verifyAppVersion(String libPkgRoot) async {
  // Config.debugLogger.v('verifyAppVersion $libPkgRoot');
  var yaml = loadYamlFileSync(libPkgRoot + '/pubspec.yaml');
  if (yaml == null) {
    Config.prodLogger.w('verifyAppVersion: pubspec.yaml not found');
    return null;
  }
  // print('yaml: $yaml');
  var appVersionStr;
  try {
    appVersionStr = yaml['dartrix']['version'];
  } catch (e) {
    //FIXME: exit?
    Config.prodLogger.w(
        'Invalid plugin ${libPkgRoot} - missing required dartrix version in pubspec.yaml. Continuing anyway...');
    // exit(1);
    return null;
  }
  if (Config.version) {
    Config.prodLogger.v(
        'Plugin ${path.basename(libPkgRoot)} built for dartrix version: $appVersionStr');
  }

  var appVersion = Version.parse(appVersionStr);
  // print('parse version: $appVersion');
  // print('min: ${appVersion.min}');
  // print('min: ${appVersion.max}');

  // print('dartrix version: ${await Config.appVersion}');
  if (appVersion <= Version.parse(await Config.appVersion)) {
    return null;
  } else {
    return appVersionStr;
  }
}