Future version()

in tool/grind.dart [36:60]


Future<void> version() async {
  final Map<String, String> versionInfo = calculateFlutterVersion();

  final String actualChannel = versionInfo['channel'];
  if (actualChannel != flutterBranch) {
    throw 'You are currently using the Flutter $actualChannel channel, please '
        'generate these files using the $flutterBranch channel.';
  }

  // Avoid generating needless diffs by mapping SSH clones onto the HTTPS URL.
  // - git@github.com:flutter/flutter.git (SSH)
  // - https://github.com/flutter/flutter (HTTPS)
  versionInfo['repositoryUrl'] = versionInfo['repositoryUrl']
      .replaceAll('git@github.com:', 'https://github.com/')
      .replaceAll(RegExp(r'.git$'), '');

  // Remove the local installed flutter path.
  versionInfo.remove('flutterRoot');

  final File versionFile = File('resources/version.json');
  const JsonEncoder encoder = JsonEncoder.withIndent('  ');
  versionFile.writeAsStringSync('${encoder.convert(versionInfo)}\n');
  log('${versionInfo['frameworkVersion']} / ${versionInfo['channel']}');
  log('Wrote ${versionFile.path}');
}