@@ -81,7 +81,7 @@ Future<bool> genPluginFiles(BuildSpec spec, String destDir) async {
81
81
return true ;
82
82
}
83
83
84
- Future <File > genPluginXml (BuildSpec spec, String destDir, String path) async {
84
+ Future <void > genPluginXml (BuildSpec spec, String destDir, String path) async {
85
85
var templatePath =
86
86
'${path .substring (0 , path .length - '.xml' .length )}_template.xml' ;
87
87
var file =
@@ -96,7 +96,7 @@ Future<File> genPluginXml(BuildSpec spec, String destDir, String path) async {
96
96
.transform (LineSplitter ())
97
97
.forEach ((l) => dest.writeln (substituteTemplateVariables (l, spec)));
98
98
await dest.close ();
99
- return await dest.done;
99
+ await dest.done;
100
100
}
101
101
102
102
bool genPresubmitYaml (List <BuildSpec > specs) {
@@ -200,21 +200,24 @@ Future<bool> performReleaseChecks(ProductCommand cmd) async {
200
200
log ('the current working directory is not managed by git: $rootPath ' );
201
201
}
202
202
// Finally, check that a jxbrowser.properties exists
203
- var jxBrowserFile = File (p.join (rootPath, 'resources' , 'jxbrowser' , 'jxbrowser.properties' ));
203
+ var jxBrowserFile =
204
+ File (p.join (rootPath, 'resources' , 'jxbrowser' , 'jxbrowser.properties' ));
204
205
var jxBrowserFileContents = jxBrowserFile.readAsStringSync ();
205
- if (jxBrowserFile.existsSync () && jxBrowserFileContents.isNotEmpty && ! jxBrowserFileContents.contains ("<KEY>" )) {
206
+ if (jxBrowserFile.existsSync () &&
207
+ jxBrowserFileContents.isNotEmpty &&
208
+ ! jxBrowserFileContents.contains ("<KEY>" )) {
206
209
return true ;
207
210
} else {
208
211
log ('Release mode requires the jxbrowser.properties file to exist and include a key.' );
209
212
}
210
213
return false ;
211
214
}
212
215
213
- List readProductMatrix () {
216
+ List < Map < String , Object ?>> readProductMatrix () {
214
217
var contents =
215
218
File (p.join (rootPath, 'product-matrix.json' )).readAsStringSync ();
216
219
var map = json.decode (contents);
217
- return map['list' ];
220
+ return ( map['list' ] as List < Object ?>). cast < Map < String , Object ?>>() ;
218
221
}
219
222
220
223
String substituteTemplateVariables (String line, BuildSpec spec) {
@@ -389,8 +392,9 @@ abstract class BuildCommand extends ProductCommand {
389
392
390
393
@override
391
394
Future <int > doit () async {
395
+ final argResults = this .argResults! ;
392
396
if (isReleaseMode) {
393
- if (argResults! [ 'unpack' ] ) {
397
+ if (argResults. flag ( 'unpack' ) ) {
394
398
separator ('Release mode (--release) implies --unpack' );
395
399
}
396
400
if (! await performReleaseChecks (this )) {
@@ -399,7 +403,7 @@ abstract class BuildCommand extends ProductCommand {
399
403
}
400
404
401
405
// Check to see if we should only be building a specific version.
402
- String ? onlyVersion = argResults! [ 'only-version' ] ;
406
+ final onlyVersion = argResults. option ( 'only-version' ) ;
403
407
404
408
var buildSpecs = specs;
405
409
if (onlyVersion != null && onlyVersion.isNotEmpty) {
@@ -410,7 +414,7 @@ abstract class BuildCommand extends ProductCommand {
410
414
}
411
415
}
412
416
413
- String ? minorNumber = argResults! [ 'minor' ] ;
417
+ final minorNumber = argResults. option ( 'minor' ) ;
414
418
if (minorNumber != null ) {
415
419
pluginCount = int .parse (minorNumber) - 1 ;
416
420
}
@@ -458,7 +462,7 @@ abstract class BuildCommand extends ProductCommand {
458
462
separator ('Built artifact' );
459
463
log (releasesFilePath (spec));
460
464
}
461
- if (argResults! [ 'only-version' ] == null ) {
465
+ if (argResults. option ( 'only-version' ) == null ) {
462
466
checkAndClearAppliedEditCommands ();
463
467
}
464
468
@@ -534,7 +538,7 @@ https://plugins.jetbrains.com/plugin/uploadPlugin
534
538
if (processResult.exitCode != 0 ) {
535
539
log ('Upload failed: ${processResult .stderr } for file: $filePath ' );
536
540
}
537
- String out = processResult.stdout;
541
+ final out = processResult.stdout as String ;
538
542
var message = out.trim ().split ('\n ' ).last.trim ();
539
543
log (message);
540
544
return processResult.exitCode;
@@ -577,9 +581,6 @@ class GenerateCommand extends ProductCommand {
577
581
return 0 ;
578
582
}
579
583
580
- SyntheticBuildSpec makeSyntheticSpec (List specs) =>
581
- SyntheticBuildSpec .fromJson (specs[0 ], release, specs[2 ]);
582
-
583
584
void generateLiveTemplates () {
584
585
// Find all the live templates.
585
586
final templateFragments = Directory (p.join ('resources' , 'liveTemplates' ))
@@ -623,7 +624,7 @@ class GenerateCommand extends ProductCommand {
623
624
}
624
625
}
625
626
626
- abstract class ProductCommand extends Command {
627
+ abstract class ProductCommand extends Command < int > {
627
628
@override
628
629
final String name;
629
630
late List <BuildSpec > specs;
@@ -636,16 +637,16 @@ abstract class ProductCommand extends Command {
636
637
defaultsTo: 'stable' );
637
638
}
638
639
639
- String get channel => argResults! [ 'channel' ] ;
640
+ String get channel => argResults! . option ( 'channel' ) ! ;
640
641
641
642
bool get isDevChannel => channel == 'dev' ;
642
643
643
644
/// Returns true when running in the context of a unit test.
644
645
bool get isTesting => false ;
645
646
646
- bool get isForAndroidStudio => argResults! [ 'as' ] ;
647
+ bool get isForAndroidStudio => argResults! . flag ( 'as' ) ;
647
648
648
- bool get isForIntelliJ => argResults! [ 'ij' ] ;
649
+ bool get isForIntelliJ => argResults! . flag ( 'ij' ) ;
649
650
650
651
DateTime get releaseDate => lastReleaseDate;
651
652
@@ -660,10 +661,10 @@ abstract class ProductCommand extends Command {
660
661
return rel == RegExp (r'^\d+\.\d(?:-dev.\d)?$' ).stringMatch (rel);
661
662
}
662
663
663
- bool get isTestMode => globalResults! [ 'cwd' ] != null ;
664
+ bool get isTestMode => globalResults! . option ( 'cwd' ) != null ;
664
665
665
666
String ? get release {
666
- String ? rel = globalResults! [ 'release' ] ;
667
+ var rel = globalResults! . option ( 'release' ) ;
667
668
668
669
if (rel != null ) {
669
670
if (rel.startsWith ('=' )) {
@@ -729,7 +730,7 @@ abstract class ProductCommand extends Command {
729
730
// Initialization constraint: rootPath depends on arg parsing, and
730
731
// lastReleaseName and lastReleaseDate depend on rootPath.
731
732
rootPath = Directory .current.path;
732
- var rel = globalResults! [ 'cwd' ] ;
733
+ var rel = globalResults! . option ( 'cwd' ) ;
733
734
if (rel != null ) {
734
735
rootPath = p.normalize (p.join (rootPath, rel));
735
736
}
@@ -799,11 +800,14 @@ class RenamePackageCommand extends ProductCommand {
799
800
800
801
@override
801
802
Future <int > doit () async {
802
- if (argResults! ['studio' ]) baseDir = p.join (baseDir, 'flutter-studio/src' );
803
- oldName = argResults! ['package' ];
804
- newName = argResults! .wasParsed ('new-name' )
805
- ? argResults! ['new-name' ]
806
- : oldName + argResults! ['append' ];
803
+ final argResults = this .argResults! ;
804
+ if (argResults.flag ('studio' )) {
805
+ baseDir = p.join (baseDir, 'flutter-studio/src' );
806
+ }
807
+ oldName = argResults.option ('package' )! ;
808
+ newName = argResults.wasParsed ('new-name' )
809
+ ? argResults.option ('new-name' )!
810
+ : oldName + argResults.option ('append' )! ;
807
811
if (oldName == newName) {
808
812
log ('Nothing to do; new name is same as old name' );
809
813
return 1 ;
@@ -901,8 +905,8 @@ class TestCommand extends ProductCommand {
901
905
log ('JAVA_HOME=$javaHome ' );
902
906
903
907
final spec = specs.firstWhere ((s) => s.isUnitTestTarget);
904
- if (! argResults! [ 'skip' ] ) {
905
- if (argResults! [ 'integration' ] ) {
908
+ if (! argResults! . flag ( 'skip' ) ) {
909
+ if (argResults! . flag ( 'integration' ) ) {
906
910
return await _runIntegrationTests ();
907
911
} else {
908
912
return await _runUnitTests (spec);
0 commit comments