From 695c5e258e30a9138b163419bd93427a9a8d3ad4 Mon Sep 17 00:00:00 2001 From: Serge Shkurko Date: Sat, 23 Oct 2021 19:52:03 +0300 Subject: [PATCH] Bump 3.0.0, resolve #11, resolve #16 --- .gitignore | 83 ++++++++++++-- CHANGELOG.md | 9 ++ README.md | 6 +- bin/icon_font_generator.dart | 23 ++-- example/lib/icon_font/ui_icons.ttf | Bin 1776 -> 1780 bytes example/lib/widgets/icons.dart | 11 +- example/pubspec.lock | 174 +++++++++++++++++++++++++++++ lib/generate_flutter_class.dart | 2 +- lib/templates/flutter_icons.dart | 3 +- pubspec.lock | 40 +++++++ pubspec.yaml | 6 +- 11 files changed, 325 insertions(+), 32 deletions(-) create mode 100644 example/pubspec.lock create mode 100644 pubspec.lock diff --git a/.gitignore b/.gitignore index e1a2aa3..16b9e81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,82 @@ -node_modules/* -dist/* -map/* -package-lock.json -package.json -yarn.lock +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ -/build/ -pubspec.lock \ No newline at end of file +build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 + +# Project +node_modules/* +dist/* +map/* +package-lock.json +package.json +yarn.lock \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5322024..ec0fede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 3.0.0 + +* Replaced [icon-font-generator] with [fantasticon] [pull#14](https://github.com/rbcprolabs/icon_font_generator/pull/14) +* Attribute ascent replaced by descent +* Attribute mono removed +* Attribute yarn added +* Added const in dart class template [issue#16](https://github.com/rbcprolabs/icon_font_generator/issues/16) +* Upgrade dependencies + ## 2.0.0 * Null-safety diff --git a/README.md b/README.md index b22a301..d1dea92 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ $ pub global activate icon_font_generator - `--out-flutter` * - Output flutter icon class (to file, for example: lib/icons.dart) - `--class-name` * - The class name is also the font name used in pubspec.yaml (as font name) - `--height` - Fixed font height value, defaults: 512 -- `--ascent` - Offset applied to the baseline, defaults: 240 +- `--descent` - Offset applied to the baseline, defaults: 240 - `--package` - Name of package for generated icon data ([See more](https://api.flutter.dev/flutter/widgets/IconData/fontPackage.html)) - `--indent` - Indent for generating dart file, for example: ' ', default: ' ' -- `--mono` - Make font monospace, default: true - `--normalize` - Normalize icons sizes, default: false +- `--yarn` - Usage yarn instead npm, default: false ## Example File structure: @@ -80,7 +80,7 @@ class _UiIconsData extends IconData { @immutable class UiIcons { - UiIcons._(); + const UiIcons._(); static const IconData account = _UiIconsData(0xe000); static const IconData arrowLeft = _UiIconsData(0xe001); diff --git a/bin/icon_font_generator.dart b/bin/icon_font_generator.dart index bcfa40d..c493821 100644 --- a/bin/icon_font_generator.dart +++ b/bin/icon_font_generator.dart @@ -60,6 +60,11 @@ class GenerateCommand extends Command { 'normalize', help: 'Normalize icons sizes', defaultsTo: false, + ) + ..addFlag( + 'yarn', + help: 'Use yarn instead npm', + defaultsTo: false, ); } @@ -97,10 +102,8 @@ class GenerateCommand extends Command { Directory.fromUri(genRootDir.uri.resolve('temp_icons')); final tempOutDirectory = Directory.fromUri(genRootDir.uri.resolve('temp_font')); - final iconsMap = File.fromUri(genRootDir.uri.resolve(path.join( - tempOutDirectory.path, - 'ui_icons.json' - ))); + final iconsMap = File.fromUri(genRootDir.uri + .resolve(path.join(tempOutDirectory.path, 'ui_icons.json'))); if (tempSourceDirectory.existsSync()) { await tempSourceDirectory.delete(recursive: true); } @@ -111,9 +114,11 @@ class GenerateCommand extends Command { await iconsMap.delete(); } + stdout.writeln('Installing npm dependencies...'); + final nodeInstallDependencies = await Process.start( - 'npm', - ['install'], + (argResults!['yarn'] as bool) ? 'yarn' : 'npm', + ['install', '--no-fund'], workingDirectory: genRootDir.path, runInShell: true, ); @@ -121,7 +126,7 @@ class GenerateCommand extends Command { // icon-font-generator requires package: `ttf2woff2` // we do not need him and requires a python - final String gypErr = 'gyp ERR!'; + final gypErr = 'gyp ERR!'; await stderr.addStream(nodeInstallDependencies.stderr .where((bytes) => !utf8.decode(bytes).contains(gypErr))); @@ -148,8 +153,6 @@ class GenerateCommand extends Command { ), [ path.absolute(tempSourceDirectory.path), - '--asset-types', - 'json', '--font-height', argResults!['height'], '--descent', @@ -160,6 +163,8 @@ class GenerateCommand extends Command { path.basenameWithoutExtension(argResults!['out-font']), '--output', path.absolute(tempOutDirectory.path), + '--asset-types', + 'json', '--font-types', 'ttf', ], diff --git a/example/lib/icon_font/ui_icons.ttf b/example/lib/icon_font/ui_icons.ttf index c7789d1743e16dc860bc018d5ed7fbbd66a4dca6..6182fe17e9d2deffef19a84b36d0198dce720e96 100644 GIT binary patch delta 526 zcmYjN&nrYx6#mYehbQC>W{^yNJO(4>=aeQalp@xM#>-&T3=@-(7zMo*CxD_M?| z4QiA>!9qz%mKI*I^_)8tx4wJMx!-rbdphqqA35=|wXVy)8-R8IjE#r&$kOs>5|Fs0 z!>Q2H!$WXF4-7t?lyLscXbbX#v_VeJuNhh}99>j6;odjC3PQ8vI_7Z7 z{YPA9hxNq>*-^=S5!YoidU*F(DUI=e&dBV1bme7l7)U>0ZV1FG)lzrwG;QQ9y5rCF zeIiTD1*}vhVt>&ZrFq;M*|eT7(;>x?#+}_X$%-E8HcrS>o;1mng&P{E1MkeR`@bU@ zuQZ^TvSk4#U9?Me)NisxKuAsgS3vB=wEX}g%0B?d)Tu!`dJz&jD?kBUK>@GFYnQx6W ImgNQM8&2bPbpQYW delta 518 zcmYjNze_?<6h7y@mp)5L^H&Z@q9urI3~G^wW(N5qlrWH_B^?@+=hRYT z(DI@w3R;5xfwmeR(b&*X(3G94MqT*s`OZ1tIehninBGmb!Sdwg%rO8GU@e}ObK36f z9pztyldYZoWc27J0l=S8|2efOCtTU;9C3{hN>PC?a600*1Syp+6h$I5`%0H>CmWZc z0OvH{pxl_2i#fD_hx+}L4`$?a{Zt$%0dS67HeV>cG&TTqOuG(9RU-9!N$NJ{7h}DV zPv~J4GLrQ?{EwJNRWahB74ZaX&_z8PCh1-Rn{tLe*MbHb-)c9tT zz36I@8^fqZWds(!Is)O)v?Vx<%SuczT2Zx|zaI^v5Q%V{V8C&+{pvv2<9+}+^=Hfg diff --git a/example/lib/widgets/icons.dart b/example/lib/widgets/icons.dart index f293488..076edd3 100644 --- a/example/lib/widgets/icons.dart +++ b/example/lib/widgets/icons.dart @@ -13,11 +13,10 @@ class _UiIconsData extends IconData { @immutable class UiIcons { - UiIcons._(); + const UiIcons._(); - - static const IconData account = _UiIconsData(0xe000); - static const IconData arrowLeft = _UiIconsData(0xe001); - static const IconData arrowRight = _UiIconsData(0xe002); - static const IconData collection = _UiIconsData(0xe003); + static const IconData account = _UiIconsData(0xf101); + static const IconData arrowLeft = _UiIconsData(0xf102); + static const IconData arrowRight = _UiIconsData(0xf103); + static const IconData collection = _UiIconsData(0xf104); } diff --git a/example/pubspec.lock b/example/pubspec.lock new file mode 100644 index 0000000..9f579e1 --- /dev/null +++ b/example/pubspec.lock @@ -0,0 +1,174 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + console: + dependency: transitive + description: + name: console + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + icon_font_generator: + dependency: "direct dev" + description: + path: ".." + relative: true + source: path + version: "3.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.10" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + recase: + dependency: transitive + description: + name: recase + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.2" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" +sdks: + dart: ">=2.12.0 <3.0.0" diff --git a/lib/generate_flutter_class.dart b/lib/generate_flutter_class.dart index b34338c..14d093e 100644 --- a/lib/generate_flutter_class.dart +++ b/lib/generate_flutter_class.dart @@ -1,6 +1,6 @@ import 'dart:convert'; import 'dart:io'; -import 'package:meta/meta.dart'; + import 'package:icon_font_generator/templates/flutter_icons.dart' as template; import 'package:recase/recase.dart'; diff --git a/lib/templates/flutter_icons.dart b/lib/templates/flutter_icons.dart index 2c2fb65..d2beaa6 100644 --- a/lib/templates/flutter_icons.dart +++ b/lib/templates/flutter_icons.dart @@ -14,9 +14,8 @@ class _%CLASS_NAME%Data extends IconData { @immutable class %CLASS_NAME% { -%INDENT%%CLASS_NAME%._(); +%INDENT%const %CLASS_NAME%._(); -%INDENT% %CONTENT% } '''; diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..e083266 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,40 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + args: + dependency: "direct main" + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + meta: + dependency: "direct main" + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + path: + dependency: "direct main" + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + pedantic: + dependency: "direct dev" + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" + recase: + dependency: "direct main" + description: + name: recase + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" +sdks: + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index a59257a..040e37f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: icon_font_generator -version: 2.0.0 +version: 3.0.0 homepage: https://github.com/rbcprolabs/icon_font_generator description: Convert all *.svg icons from dir to icon-font (.ttf) and generates flutter compatible dart class. @@ -7,8 +7,8 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - recase: ^4.0.0-nullsafety.0 - args: ^2.0.0 + recase: ^4.0.0 + args: ^2.3.0 meta: ^1.3.0 path: ^1.8.0