@@ -2,6 +2,7 @@ import 'dart:convert';
22import 'dart:io' ;
33
44import 'package:recase/recase.dart' ;
5+ import 'package:version/version.dart' ;
56
67void main (List <String > arguments) {
78 var file = new File (arguments.first);
@@ -17,6 +18,9 @@ void main(List<String> arguments) {
1718
1819 bool hasDuotone = false ;
1920
21+ // figure out current version
22+ Version highestVersion = Version .parse ("0.0.0" );
23+
2024 for (String iconName in icons.keys) {
2125 var icon = icons[iconName];
2226
@@ -25,6 +29,33 @@ void main(List<String> arguments) {
2529 if ((icon as Map <String , dynamic >).containsKey ('private' ) &&
2630 icon['private' ]) continue ;
2731
32+ // compute highest version
33+ var changes = (icon["changes" ] as List ) ?? List ();
34+
35+ List <Version > versions = changes.map ((v) {
36+ // since font awesome does not adhere to semver standards
37+ var partsCount = v.split ("." ).length;
38+ if (partsCount == 1 ) {
39+ return v + ".0.0" ;
40+ } else if (partsCount == 2 ) {
41+ return v + ".0" ;
42+ } else if (partsCount == 3 ) {
43+ return v;
44+ } else {
45+ return "0.0.0" ;
46+ }
47+ }).map ((v) {
48+ try {
49+ return Version .parse (v);
50+ } on FormatException {
51+ return Version .parse ("0.0.0" );
52+ }
53+ }).toList (growable: true )
54+ ..add (highestVersion)
55+ ..sort ();
56+
57+ highestVersion = versions.last;
58+
2859 var unicode = icon['unicode' ];
2960 List <String > styles = (icon['styles' ] as List ).cast <String >();
3061
@@ -77,6 +108,7 @@ void main(List<String> arguments) {
77108 '' ,
78109 '// THIS FILE IS AUTOMATICALLY GENERATED!' ,
79110 '' ,
111+ '/// Icons based on font awesome $highestVersion ' ,
80112 'class FontAwesomeIcons {' ,
81113 ]);
82114
0 commit comments