@@ -2,7 +2,7 @@ import 'dart:io';
2
2
3
3
import 'package:cli_util/cli_logging.dart' show Logger;
4
4
import 'package:melos/melos.dart'
5
- show MelosLogger, MelosWorkspace, MelosWorkspaceConfig;
5
+ show MelosLogger, MelosWorkspace, MelosWorkspaceConfig, Package ;
6
6
import 'package:path/path.dart' as p;
7
7
import 'package:pub_semver/pub_semver.dart' ;
8
8
import 'package:yaml/yaml.dart' ;
@@ -40,30 +40,42 @@ void main() async {
40
40
}
41
41
}
42
42
43
- final current = Version .parse (
43
+ final currentDart = Version .parse (
44
44
RegExp (r'\d*\.\d*\.\d*' ).firstMatch (Platform .version)! .group (0 )! ,
45
45
);
46
- final validPackages = packages.where ((e) {
46
+ final overridePackages = < Package > [];
47
+ final ignoredPackages = < Package > [];
48
+ for (final e in packages) {
47
49
final dynamic package = e as dynamic ;
48
50
bool allows;
49
51
try {
50
52
// Compatible with melos v6.3.
51
- allows = package.pubspec.environment['sdk' ]! .allows (current );
53
+ allows = package.pubspec.environment['sdk' ]! .allows (currentDart );
52
54
} on NoSuchMethodError {
53
55
// Fallback to previous melos.
54
- allows = package.pubSpec.environment! .sdkConstraint! .allows (current );
56
+ allows = package.pubSpec.environment! .sdkConstraint! .allows (currentDart );
55
57
}
56
- return allows;
57
- });
58
+ if (allows) {
59
+ overridePackages.add (e);
60
+ } else {
61
+ ignoredPackages.add (e);
62
+ }
63
+ }
58
64
59
- // Create melos marker files
60
- for (final package in validPackages ) {
65
+ // Create melos marker files.
66
+ for (final package in overridePackages ) {
61
67
File (p.join (package.path, '.melos_package' )).createSync ();
62
68
}
63
69
64
- final validPackagesString = validPackages.map ((p) => p.name).join (',' );
70
+ final overridePackagesString = overridePackages.map ((p) => p.name).join (',' );
71
+ final ignoredPackagesString = ignoredPackages.map ((p) => p.name).join (',' );
72
+ print (
73
+ 'Checked valid packages: \n '
74
+ ' [override]: $overridePackagesString \n '
75
+ ' [ignored]: $ignoredPackagesString ' ,
76
+ );
65
77
File ('$root /.melos_packages' )
66
- .writeAsStringSync ('MELOS_PACKAGES=$validPackagesString ' );
78
+ .writeAsStringSync ('MELOS_PACKAGES=$overridePackagesString ' );
67
79
}
68
80
69
81
extension YamlUtils on YamlNode {
0 commit comments