diff --git a/tool/grind.dart b/tool/grind.dart index f5e62f9335..14b6277bcc 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -12,8 +12,10 @@ void main(List args) => grind(args); @Task('Check plugin URLs for live-ness') void checkUrls() async { log('checking URLs in FlutterBundle.properties...'); - var lines = await File('flutter-idea/src/io/flutter/FlutterBundle.properties') - .readAsLines(); + var lines = + await File( + 'flutter-idea/src/io/flutter/FlutterBundle.properties', + ).readAsLines(); for (var line in lines) { var split = line.split('='); if (split.length == 2) { @@ -24,8 +26,8 @@ void checkUrls() async { log('checking: $url...'); if (response.statusCode != 200) { fail( - '$url GET failed: [${response.statusCode}] ${response - .reasonPhrase}'); + '$url GET failed: [${response.statusCode}] ${response.reasonPhrase}', + ); } } } @@ -55,18 +57,21 @@ void outlineIcons() async { } } -void _createPng(File sourceSvg, - String targetName, { - required int? size, - bool forLight = false, - }) { +void _createPng( + File sourceSvg, + String targetName, { + required int? size, + bool forLight = false, +}) { File targetFile = joinFile(sourceSvg.parent, [targetName]); String color = forLight ? '#7a7a7a' : '#9e9e9e'; String originalContent = sourceSvg.readAsStringSync(); - String newContent = - originalContent.replaceAll(' json, this.release) - : name = json['name'] as String, - channel = json['channel'] as String, - version = json['version'] as String, - ijVersion = json['ijVersion'] as String?, - ideaProduct = json['ideaProduct'] as String, - ideaVersion = json['ideaVersion'] as String, - baseVersion = (json['baseVersion'] ?? json['ideaVersion']) as String, - androidPluginVersion = json['androidPluginVersion'] as String, - dartPluginVersion = json['dartPluginVersion'] as String, - sinceBuild = json['sinceBuild'] as String, - untilBuild = json['untilBuild'] as String, - filesToSkip = json['filesToSkip'] as List? ?? [], - isUnitTestTarget = json['isUnitTestTarget'] == 'true', - isTestTarget = json['isTestTarget'] == 'true'; + : name = json['name'] as String, + channel = json['channel'] as String, + version = json['version'] as String, + ijVersion = json['ijVersion'] as String?, + ideaProduct = json['ideaProduct'] as String, + ideaVersion = json['ideaVersion'] as String, + baseVersion = (json['baseVersion'] ?? json['ideaVersion']) as String, + androidPluginVersion = json['androidPluginVersion'] as String, + dartPluginVersion = json['dartPluginVersion'] as String, + sinceBuild = json['sinceBuild'] as String, + untilBuild = json['untilBuild'] as String, + filesToSkip = json['filesToSkip'] as List? ?? [], + isUnitTestTarget = json['isUnitTestTarget'] == 'true', + isTestTarget = json['isTestTarget'] == 'true'; bool get copyIjVersion => isAndroidStudio && ijVersion != null; diff --git a/tool/plugin/lib/edit.dart b/tool/plugin/lib/edit.dart index 59f44e0cff..af30fdd8c0 100644 --- a/tool/plugin/lib/edit.dart +++ b/tool/plugin/lib/edit.dart @@ -46,7 +46,7 @@ Future applyEdits(BuildSpec spec, Future Function() compileFn) async { // Handle skipped files. for (String file in spec.filesToSkip) { final entity = - FileSystemEntity.isFileSync(file) ? File(file) : Directory(file); + FileSystemEntity.isFileSync(file) ? File(file) : Directory(file); if (entity.existsSync()) { await entity.rename('$file~'); log('renamed $file'); @@ -82,7 +82,7 @@ Future applyEdits(BuildSpec spec, Future Function() compileFn) async { for (final file in spec.filesToSkip) { final name = '$file~'; final entity = - FileSystemEntity.isFileSync(name) ? File(name) : Directory(name); + FileSystemEntity.isFileSync(name) ? File(name) : Directory(name); if (entity.existsSync()) { await entity.rename(file); } @@ -97,12 +97,11 @@ class EditCommand { required List initials, required List replacements, this.versions = const [], - }) - : assert(initials.length == replacements.length), - assert(initials.isNotEmpty), - assert(versions.isNotEmpty), - initials = initials.map(_platformAdaptiveString).toList(), - replacements = replacements.map(_platformAdaptiveString).toList(); + }) : assert(initials.length == replacements.length), + assert(initials.isNotEmpty), + assert(versions.isNotEmpty), + initials = initials.map(_platformAdaptiveString).toList(), + replacements = replacements.map(_platformAdaptiveString).toList(); /// The target file path. final String path; diff --git a/tool/plugin/lib/lint.dart b/tool/plugin/lib/lint.dart index ba2ba46e4a..2f0edf7fe4 100644 --- a/tool/plugin/lib/lint.dart +++ b/tool/plugin/lib/lint.dart @@ -41,7 +41,11 @@ class LintCommand extends Command { final result = Process.runSync( 'git', // Note: extra quotes added so grep doesn't match this file. - ['grep', 'import com.jetbrains.' 'lang.dart.'], + [ + 'grep', + 'import com.jetbrains.' + 'lang.dart.', + ], ); final String imports = (result.stdout as String).trim(); @@ -112,10 +116,7 @@ class LintCommand extends Command { for (var import in proscribedImports) { print('Checking for import of "$import"...'); - final result = Process.runSync( - 'git', - ['grep', 'import $import'], - ); + final result = Process.runSync('git', ['grep', 'import $import']); final String results = (result.stdout as String).trim(); if (results.isNotEmpty) { @@ -127,17 +128,12 @@ class LintCommand extends Command { } } - final partialImports = [ - 'com.sun.', - ]; + final partialImports = ['com.sun.']; for (var import in partialImports) { print('Checking for import of "$import"...'); - final result = Process.runSync( - 'git', - ['grep', 'import $import'], - ); + final result = Process.runSync('git', ['grep', 'import $import']); final String results = (result.stdout as String).trim(); if (results.isNotEmpty) { diff --git a/tool/plugin/lib/plugin.dart b/tool/plugin/lib/plugin.dart index 49dc37e56f..de8dbdd4f9 100644 --- a/tool/plugin/lib/plugin.dart +++ b/tool/plugin/lib/plugin.dart @@ -39,8 +39,11 @@ Future main(List args) async { void addProductFlags(ArgParser argParser, String verb) { argParser.addFlag('ij', help: '$verb the IntelliJ plugin', defaultsTo: true); - argParser.addFlag('as', - help: '$verb the Android Studio plugin', defaultsTo: true); + argParser.addFlag( + 'as', + help: '$verb the Android Studio plugin', + defaultsTo: true, + ); } void copyResources({required String from, required String to}) { @@ -84,13 +87,14 @@ Future genPluginFiles(BuildSpec spec, String destDir) async { Future genPluginXml(BuildSpec spec, String destDir, String path) async { var templatePath = '${path.substring(0, path.length - '.xml'.length)}_template.xml'; - var file = - await File(p.join(rootPath, destDir, path)).create(recursive: true); + var file = await File( + p.join(rootPath, destDir, path), + ).create(recursive: true); log('writing ${p.relative(file.path)}'); var dest = file.openWrite(); dest.writeln( - ""); + "", + ); dest.writeln(); await utf8.decoder .bind(File(p.join(rootPath, 'resources', templatePath)).openRead()) @@ -110,12 +114,15 @@ bool genPresubmitYaml(List specs) { } } - var templateFile = - File(p.join(rootPath, '.github', 'workflows', 'presubmit.yaml.template')); + var templateFile = File( + p.join(rootPath, '.github', 'workflows', 'presubmit.yaml.template'), + ); var templateContents = templateFile.readAsStringSync(); // If we need to make many changes consider something like genPluginXml(). - templateContents = - templateContents.replaceFirst('@VERSIONS@', versions.join(', ')); + templateContents = templateContents.replaceFirst( + '@VERSIONS@', + versions.join(', '), + ); var header = "# Do not edit; instead, modify ${p.basename(templateFile.path)}," " and run './bin/plugin generate'.\n\n"; @@ -150,9 +157,11 @@ bool isTravisFileValid() { Future jar(String directory, String outFile) async { var args = ['cf', p.absolute(outFile)]; - args.addAll(Directory(directory) - .listSync(followLinks: false) - .map((f) => p.basename(f.path))); + args.addAll( + Directory( + directory, + ).listSync(followLinks: false).map((f) => p.basename(f.path)), + ); args.remove('.DS_Store'); return await exec('jar', args, cwd: directory); } @@ -170,8 +179,9 @@ Future performReleaseChecks(ProductCommand cmd) async { return false; } if (!cmd.isReleaseValid) { - log('the release identifier ("${cmd - .release}") must be of the form xx.x (major.minor)'); + log( + 'the release identifier ("${cmd.release}") must be of the form xx.x (major.minor)', + ); return false; } var gitDir = await GitDir.fromExisting(rootPath); @@ -180,10 +190,11 @@ Future performReleaseChecks(ProductCommand cmd) async { var branch = await gitDir.currentBranch(); var name = branch.branchName; var expectedName = - cmd.isDevChannel ? 'master' : "release_${cmd.releaseMajor}"; + cmd.isDevChannel ? 'master' : "release_${cmd.releaseMajor}"; var result = name == expectedName; if (!result) { - result = name.startsWith("release_${cmd.releaseMajor}") && + result = + name.startsWith("release_${cmd.releaseMajor}") && name.lastIndexOf(RegExp(r"\.[0-9]")) == name.length - 2; } if (result) { @@ -202,8 +213,9 @@ Future performReleaseChecks(ProductCommand cmd) async { log('the current working directory is not managed by git: $rootPath'); } // Finally, check that a jxbrowser.properties exists - var jxBrowserFile = - File(p.join(rootPath, 'resources', 'jxbrowser', 'jxbrowser.properties')); + var jxBrowserFile = File( + p.join(rootPath, 'resources', 'jxbrowser', 'jxbrowser.properties'), + ); var jxBrowserFileContents = jxBrowserFile.readAsStringSync(); if (jxBrowserFile.existsSync() && jxBrowserFileContents.isNotEmpty && @@ -212,14 +224,15 @@ Future performReleaseChecks(ProductCommand cmd) async { return true; } else { log( - 'Release mode requires the jxbrowser.properties file to exist and include a key.'); + 'Release mode requires the jxbrowser.properties file to exist and include a key.', + ); } return false; } List> readProductMatrix() { var contents = - File(p.join(rootPath, 'product-matrix.json')).readAsStringSync(); + File(p.join(rootPath, 'product-matrix.json')).readAsStringSync(); var map = json.decode(contents); return (map['list'] as List).cast>(); } @@ -239,8 +252,8 @@ String substituteTemplateVariables(String line, BuildSpec spec) { case 'CHANGELOG': return spec.changeLog; case 'DEPEND': - // If found, this is the module that triggers loading the Android Studio - // support. The public sources and the installable plugin use different ones. + // If found, this is the module that triggers loading the Android Studio + // support. The public sources and the installable plugin use different ones. return spec.isSynthetic ? 'com.intellij.modules.androidstudio' : 'com.android.tools.apk'; @@ -303,23 +316,33 @@ class GradleBuildCommand extends ProductCommand { final BuildCommandRunner runner; GradleBuildCommand(this.runner) : super('make') { - argParser.addOption('only-version', - abbr: 'o', - help: 'Only build the specified IntelliJ version; useful for sharding ' - 'builds on CI systems.'); - argParser.addFlag('unpack', - abbr: 'u', - help: 'Unpack the artifact files during provisioning, ' - 'even if the cache appears fresh.\n' - 'This flag is ignored if --release is given.', - defaultsTo: false); - argParser.addOption('minor', - abbr: 'm', help: 'Set the minor version number.'); + argParser.addOption( + 'only-version', + abbr: 'o', + help: + 'Only build the specified IntelliJ version; useful for sharding ' + 'builds on CI systems.', + ); + argParser.addFlag( + 'unpack', + abbr: 'u', + help: + 'Unpack the artifact files during provisioning, ' + 'even if the cache appears fresh.\n' + 'This flag is ignored if --release is given.', + defaultsTo: false, + ); + argParser.addOption( + 'minor', + abbr: 'm', + help: 'Set the minor version number.', + ); argParser.addFlag('setup', abbr: 's', defaultsTo: true); } @override - String get description => 'Build a deployable version of the Flutter plugin, ' + String get description => + 'Build a deployable version of the Flutter plugin, ' 'compiled against the specified artifacts.'; @override @@ -402,8 +425,10 @@ class GradleBuildCommand extends ProductCommand { } // Print a summary of the collection of plugin versions built: var builtVersions = buildSpecs.map((spec) => spec.name).toList().join(', '); - log('\nMake of the ${buildSpecs.length} builds was ' - 'successful: $builtVersions.'); + log( + '\nMake of the ${buildSpecs.length} builds was ' + 'successful: $builtVersions.', + ); return result; } @@ -426,21 +451,18 @@ class GradleBuildCommand extends ProductCommand { // Log the contents of ./build/distributions, this is useful in debugging // in general and especially useful for the Kokoro bot which is run remotely - final result = Process.runSync( - 'ls', - ['-laf', '-laf', 'build/distributions'], - ); + final result = Process.runSync('ls', [ + '-laf', + '-laf', + 'build/distributions', + ]); log('Content generated in ./build/distributions:\n${result.stdout}'); var source = File('build/distributions/flutter-intellij.zip'); if (!source.existsSync()) { source = File('build/distributions/flutter-intellij-kokoro.zip'); } - _copyFile( - source, - file.parent, - filename: p.basename(file.path), - ); + _copyFile(source, file.parent, filename: p.basename(file.path)); await _stopDaemon(); return 0; } @@ -487,7 +509,11 @@ class DeployCommand extends ProductCommand { changeDirectory(file.parent); var pluginNumber = pluginRegistryIds[spec.pluginId]; value = await upload( - p.basename(file.path), pluginNumber!, token, spec.channel); + p.basename(file.path), + pluginNumber!, + token, + spec.channel, + ); if (value != 0) { return value; } @@ -500,8 +526,12 @@ class DeployCommand extends ProductCommand { Directory.current = dir.path; } - Future upload(String filePath, String pluginNumber, String token, - String channel) async { + Future upload( + String filePath, + String pluginNumber, + String token, + String channel, + ) async { if (!File(filePath).existsSync()) { throw 'File not found: $filePath'; } @@ -523,11 +553,7 @@ https://plugins.jetbrains.com/plugin/uploadPlugin log('Upload failed: ${processResult.stderr} for file: $filePath'); } final out = processResult.stdout as String; - var message = out - .trim() - .split('\n') - .last - .trim(); + var message = out.trim().split('\n').last.trim(); log(message); return processResult.exitCode; } @@ -548,9 +574,9 @@ class GenerateCommand extends ProductCommand { @override String get description => 'Generate plugin.xml, .github/workflows/presubmit.yaml, ' - 'and resources/liveTemplates/flutter_miscellaneous.xml files for the ' - 'Flutter plugin.\nThe plugin.xml.template and product-matrix.json are ' - 'used as input.'; + 'and resources/liveTemplates/flutter_miscellaneous.xml files for the ' + 'Flutter plugin.\nThe plugin.xml.template and product-matrix.json are ' + 'used as input.'; @override Future doit() async { @@ -571,14 +597,16 @@ class GenerateCommand extends ProductCommand { void generateLiveTemplates() { // Find all the live templates. - final templateFragments = Directory(p.join('resources', 'liveTemplates')) - .listSync() - .whereType() - .where((file) => p.extension(file.path) == '.txt') - .cast() - .toList(); - final templateFile = - File(p.join('resources', 'liveTemplates', 'flutter_miscellaneous.xml')); + final templateFragments = + Directory(p.join('resources', 'liveTemplates')) + .listSync() + .whereType() + .where((file) => p.extension(file.path) == '.txt') + .cast() + .toList(); + final templateFile = File( + p.join('resources', 'liveTemplates', 'flutter_miscellaneous.xml'), + ); var contents = templateFile.readAsStringSync(); log('writing ${p.relative(templateFile.path)}'); @@ -596,15 +624,15 @@ class GenerateCommand extends ProductCommand { final regexp = RegExp('