@@ -106,11 +106,7 @@ For example (follow the same format including spaces):
106
106
// To avoid breaking changes we keep supporting them, but hide them from
107
107
// --help to discourage further use. Combining these with new syntax will
108
108
// fail.
109
- argParser.addOption (
110
- 'git-url' ,
111
- help: 'Git URL of the package' ,
112
- hide: true ,
113
- );
109
+ argParser.addOption ('git-url' , help: 'Git URL of the package' , hide: true );
114
110
argParser.addOption (
115
111
'git-ref' ,
116
112
help: 'Git branch or commit to be retrieved' ,
@@ -218,8 +214,10 @@ Specify multiple sdk packages with descriptors.''');
218
214
);
219
215
} on GitException {
220
216
final name = updates.first.ref.name;
221
- dataError ('Unable to resolve package "$name " with the given '
222
- 'git parameters.' );
217
+ dataError (
218
+ 'Unable to resolve package "$name " with the given '
219
+ 'git parameters.' ,
220
+ );
223
221
} on SolveFailure catch (e) {
224
222
dataError (e.message);
225
223
} on WrappedException catch (e) {
@@ -231,18 +229,21 @@ Specify multiple sdk packages with descriptors.''');
231
229
for (final update in updates) {
232
230
final ref = update.ref;
233
231
final name = ref.name;
234
- final resultPackage = solveResult.packages
235
- .firstWhere ((packageId) => packageId.name == name);
232
+ final resultPackage = solveResult.packages.firstWhere (
233
+ (packageId) => packageId.name == name,
234
+ );
236
235
237
236
/// Assert that [resultPackage] is within the original user's
238
237
/// expectations.
239
238
final constraint = update.constraint;
240
239
if (constraint != null && ! constraint.allows (resultPackage.version)) {
241
240
final dependencyOverrides = resolutionPubspec.dependencyOverrides;
242
241
if (dependencyOverrides.isNotEmpty) {
243
- dataError ('"$name " resolved to "${resultPackage .version }" which '
244
- 'does not satisfy constraint "$constraint ". This could be '
245
- 'caused by "dependency_overrides".' );
242
+ dataError (
243
+ '"$name " resolved to "${resultPackage .version }" which '
244
+ 'does not satisfy constraint "$constraint ". This could be '
245
+ 'caused by "dependency_overrides".' ,
246
+ );
246
247
}
247
248
}
248
249
}
@@ -294,8 +295,10 @@ Specify multiple sdk packages with descriptors.''');
294
295
}
295
296
296
297
if (isOffline) {
297
- log.warning ('Warning: Packages added when offline may not resolve to '
298
- 'the latest compatible version available.' );
298
+ log.warning (
299
+ 'Warning: Packages added when offline may not resolve to '
300
+ 'the latest compatible version available.' ,
301
+ );
299
302
}
300
303
}
301
304
@@ -311,17 +314,21 @@ Specify multiple sdk packages with descriptors.''');
311
314
final dependencyOverrides = [...original.dependencyOverrides.values];
312
315
313
316
final dependencyNames = dependencies.map ((dependency) => dependency.name);
314
- final devDependencyNames =
315
- devDependencies.map ((devDependency) => devDependency.name);
316
- final range =
317
- package.ref.withConstraint (package.constraint ?? VersionConstraint .any);
317
+ final devDependencyNames = devDependencies.map (
318
+ (devDependency) => devDependency.name,
319
+ );
320
+ final range = package.ref.withConstraint (
321
+ package.constraint ?? VersionConstraint .any,
322
+ );
318
323
319
324
if (package.isOverride) {
320
325
dependencyOverrides.add (range);
321
326
} else if (package.isDev) {
322
327
if (devDependencyNames.contains (name)) {
323
- log.message ('"$name " is already in "dev_dependencies". '
324
- 'Will try to update the constraint.' );
328
+ log.message (
329
+ '"$name " is already in "dev_dependencies". '
330
+ 'Will try to update the constraint.' ,
331
+ );
325
332
devDependencies.removeWhere ((element) => element.name == name);
326
333
}
327
334
@@ -330,9 +337,11 @@ Specify multiple sdk packages with descriptors.''');
330
337
/// remove the package from dependencies, since it might cause the user's
331
338
/// code to break.
332
339
if (dependencyNames.contains (name)) {
333
- dataError ('"$name " is already in "dependencies". '
334
- 'Use "pub remove $name " to remove it before adding it '
335
- 'to "dev_dependencies"' );
340
+ dataError (
341
+ '"$name " is already in "dependencies". '
342
+ 'Use "pub remove $name " to remove it before adding it '
343
+ 'to "dev_dependencies"' ,
344
+ );
336
345
}
337
346
338
347
devDependencies.add (range);
@@ -349,8 +358,10 @@ Specify multiple sdk packages with descriptors.''');
349
358
/// dependencies, we remove the package from dev_dependencies, since it is
350
359
/// now redundant.
351
360
if (devDependencyNames.contains (name)) {
352
- log.message ('"$name " was found in dev_dependencies. '
353
- 'Removing "$name " and adding it to dependencies instead.' );
361
+ log.message (
362
+ '"$name " was found in dev_dependencies. '
363
+ 'Removing "$name " and adding it to dependencies instead.' ,
364
+ );
354
365
devDependencies.removeWhere ((element) => element.name == name);
355
366
}
356
367
@@ -394,9 +405,10 @@ Specify multiple sdk packages with descriptors.''');
394
405
'The only allowed prefixes are "dev:" and "override:"' ,
395
406
);
396
407
} else {
397
- final packageName = match2.namedGroup ('descriptor' ) == null
398
- ? match2.namedGroup ('prefix' )
399
- : match2.namedGroup ('name' );
408
+ final packageName =
409
+ match2.namedGroup ('descriptor' ) == null
410
+ ? match2.namedGroup ('prefix' )
411
+ : match2.namedGroup ('name' );
400
412
usageException ('Not a valid package name: "$packageName "' );
401
413
}
402
414
}
@@ -481,16 +493,18 @@ Specify multiple sdk packages with descriptors.''');
481
493
['sdk' ],
482
494
];
483
495
484
- for (final flag
485
- in conflictingFlagSets.expand ((s) => s).where (argResults.wasParsed)) {
496
+ for (final flag in conflictingFlagSets
497
+ .expand ((s) => s)
498
+ .where (argResults.wasParsed)) {
486
499
final conflictingFlag = conflictingFlagSets
487
500
.where ((s) => ! s.contains (flag))
488
501
.expand ((s) => s)
489
502
.firstWhereOrNull (argResults.wasParsed);
490
503
if (conflictingFlag != null ) {
491
504
usageException (
492
- 'Packages can only have one source, "pub add" flags "--$flag " and '
493
- '"--$conflictingFlag " are conflicting.' );
505
+ 'Packages can only have one source, "pub add" flags "--$flag " and '
506
+ '"--$conflictingFlag " are conflicting.' ,
507
+ );
494
508
}
495
509
}
496
510
@@ -632,12 +646,8 @@ Specify multiple sdk packages with descriptors.''');
632
646
try {
633
647
dummyPubspec = Pubspec .fromMap (
634
648
{
635
- 'dependencies' : {
636
- packageName: parsedDescriptor,
637
- },
638
- 'environment' : {
639
- 'sdk' : sdk.version.toString (),
640
- },
649
+ 'dependencies' : {packageName: parsedDescriptor},
650
+ 'environment' : {'sdk' : sdk.version.toString ()},
641
651
},
642
652
cache.sources,
643
653
// Resolve relative paths relative to current, not where the
@@ -654,7 +664,8 @@ Specify multiple sdk packages with descriptors.''');
654
664
} else {
655
665
ref = range.toRef ();
656
666
}
657
- final hasExplicitConstraint = parsedDescriptor is String ||
667
+ final hasExplicitConstraint =
668
+ parsedDescriptor is String ||
658
669
(parsedDescriptor is Map &&
659
670
parsedDescriptor.containsKey ('version' ));
660
671
// If the descriptor has an explicit constraint, use that. Otherwise we
@@ -682,15 +693,17 @@ Specify multiple sdk packages with descriptors.''');
682
693
List <PackageId > resultPackages,
683
694
List <_ParseResult > updates,
684
695
) {
685
- final yamlEditor =
686
- YamlEditor (readTextFile (entrypoint.workPackage.pubspecPath));
696
+ final yamlEditor = YamlEditor (
697
+ readTextFile (entrypoint.workPackage.pubspecPath),
698
+ );
687
699
log.io ('Reading ${entrypoint .workPackage .pubspecPath }.' );
688
700
log.fine ('Contents:\n $yamlEditor ' );
689
701
690
702
for (final update in updates) {
691
- final dependencyKey = update.isDev
692
- ? 'dev_dependencies'
693
- : (update.isOverride ? 'dependency_overrides' : 'dependencies' );
703
+ final dependencyKey =
704
+ update.isDev
705
+ ? 'dev_dependencies'
706
+ : (update.isOverride ? 'dependency_overrides' : 'dependencies' );
694
707
final constraint = update.constraint;
695
708
final ref = update.ref;
696
709
final name = ref.name;
@@ -707,19 +720,17 @@ Specify multiple sdk packages with descriptors.''');
707
720
entrypoint.workPackage,
708
721
);
709
722
710
- if (yamlEditor.parseAt (
711
- [dependencyKey],
712
- orElse: () => YamlScalar .wrap (null ),
713
- ).value ==
723
+ if (yamlEditor.parseAt ([
724
+ dependencyKey,
725
+ ], orElse: () => YamlScalar .wrap (null )).value ==
714
726
null ) {
715
727
// Handle the case where [dependencyKey] does not already exist.
716
728
// We ensure it is in Block-style by default.
717
729
yamlEditor.update (
718
730
[dependencyKey],
719
- wrapAsYamlNode (
720
- {name: description},
721
- collectionStyle: CollectionStyle .BLOCK ,
722
- ),
731
+ wrapAsYamlNode ({
732
+ name: description,
733
+ }, collectionStyle: CollectionStyle .BLOCK ),
723
734
);
724
735
} else {
725
736
final packagePath = [dependencyKey, name];
@@ -731,8 +742,9 @@ Specify multiple sdk packages with descriptors.''');
731
742
/// dependencies. Refer to [_addPackageToPubspec] for additional
732
743
/// discussion.
733
744
if (! update.isDev && ! update.isOverride) {
734
- final devDependenciesNode = yamlEditor
735
- .parseAt (['dev_dependencies' ], orElse: () => YamlScalar .wrap (null ));
745
+ final devDependenciesNode = yamlEditor.parseAt ([
746
+ 'dev_dependencies' ,
747
+ ], orElse: () => YamlScalar .wrap (null ));
736
748
737
749
if (devDependenciesNode is YamlMap &&
738
750
devDependenciesNode.containsKey (name)) {
0 commit comments