diff --git a/CHANGELOG.md b/CHANGELOG.md index e00a601..0f8317c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 3.3.1 +- fix export dart core libraries + ## 3.3.0 - feat can disable printing generated code `disclaimer` - feat added the `comments` field to the `indexes` to be able to add the comments or copyright to the library diff --git a/lib/src/dart_code/dart_export.dart b/lib/src/dart_code/dart_export.dart index a3aaa24..d9974c8 100644 --- a/lib/src/dart_code/dart_export.dart +++ b/lib/src/dart_code/dart_export.dart @@ -13,12 +13,16 @@ class DartExport { sb ??= StringBuffer(); sb.write('export \''); - if (package.endsWith('.dart')) { - sb.write(package); - } else { + + final segments = package.split(':'); + if (segments.length > 2) { + throw 'Invalid package name: \'$package\''; + } else if (segments.length == 1) { // TODO: Remove support on 4.0.0 version print('[WARNING]: Please change from \'$package\' to \'package:$package.dart\''); sb.write('package:$package.dart'); + } else { + sb.write(package); } sb.write('\''); diff --git a/pubspec.yaml b/pubspec.yaml index a621ad0..0c31094 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: index_generator description: Automatically generate index / barrel / library files with all the export needed for your library. -version: 3.3.0 +version: 3.3.1 homepage: https://github.com/BreX900/index_generator # dart pub publish --dry-run @@ -17,7 +17,7 @@ dependencies: yaml: ^3.1.1 checked_yaml: ^2.0.1 mek_data_class: ^0.1.0 - json_annotation: ^4.5.0 + json_annotation: ^4.6.0 glob: ^2.1.0 pubspec: ^2.2.0 @@ -31,9 +31,9 @@ dev_dependencies: # To generate .g files: # dart run build_runner build --delete-conflicting-outputs # dart run build_runner watch --delete-conflicting-outputs - build_runner: ^2.1.11 - mek_data_class_generator: ^0.1.3 - json_serializable: ^6.2.0 + build_runner: ^2.2.0 + mek_data_class_generator: ^0.1.4 + json_serializable: ^6.3.1 index_generator: exclude: diff --git a/test/dart_export_test.dart b/test/dart_export_test.dart index 06a445b..994ff4c 100644 --- a/test/dart_export_test.dart +++ b/test/dart_export_test.dart @@ -4,6 +4,16 @@ import 'package:test/scaffolding.dart'; void main() { group('test DartExport class', () { + test('Export dart package file', () { + final export = DartExport( + package: 'dart:async', + show: ['Future'], + hide: ['Stream'], + ); + + expect(export.toCode(), 'export \'dart:async\' show Future hide Stream;'); + }); + test('Export only library', () { final export = DartExport( package: 'package:example/example.dart',