-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dynamite): generate library for every spec
Signed-off-by: Nikolas Rimikis <[email protected]>
- Loading branch information
Showing
25 changed files
with
207 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import 'package:build/build.dart'; | ||
import 'package:code_builder/code_builder.dart'; | ||
import 'package:dynamite/src/builder/state.dart'; | ||
import 'package:dynamite/src/models/openapi.dart' as openapi; | ||
import 'package:path/path.dart' as p; | ||
|
||
Iterable<Spec> generateImports(final AssetId outputId, final State state) sync* { | ||
final analyzerIgnores = state.buildConfig.analyzerIgnores; | ||
if (analyzerIgnores != null) { | ||
for (final rule in analyzerIgnores) { | ||
yield Code('// ignore_for_file: $rule'); | ||
} | ||
} | ||
Spec generateLibrary(final AssetId outputId, final State state, final openapi.OpenAPI spec) => Library((final b) { | ||
b | ||
..name = spec.info.title | ||
..directives.addAll([ | ||
Directive.import('dart:convert'), | ||
Directive.import('dart:typed_data'), | ||
Directive.import('package:built_collection/built_collection.dart'), | ||
Directive.import('package:built_value/built_value.dart'), | ||
Directive.import('package:built_value/json_object.dart'), | ||
Directive.import('package:built_value/serializer.dart'), | ||
Directive.import('package:built_value/standard_json_plugin.dart'), | ||
Directive.import('package:collection/collection.dart'), | ||
Directive.import('package:dynamite_runtime/built_value.dart'), | ||
Directive.import('package:dynamite_runtime/http_client.dart'), | ||
Directive.import('package:dynamite_runtime/models.dart'), | ||
Directive.import('package:dynamite_runtime/utils.dart', as: 'dynamite_utils'), | ||
Directive.import('package:meta/meta.dart'), | ||
Directive.import('package:universal_io/io.dart'), | ||
Directive.import('package:uri/uri.dart'), | ||
]); | ||
|
||
yield* [ | ||
Directive.import('dart:convert'), | ||
Directive.import('dart:typed_data'), | ||
const Code(''), | ||
Directive.import('package:built_collection/built_collection.dart'), | ||
Directive.import('package:built_value/built_value.dart'), | ||
Directive.import('package:built_value/json_object.dart'), | ||
Directive.import('package:built_value/serializer.dart'), | ||
Directive.import('package:built_value/standard_json_plugin.dart'), | ||
Directive.import('package:collection/collection.dart'), | ||
Directive.import('package:dynamite_runtime/built_value.dart'), | ||
Directive.import('package:dynamite_runtime/http_client.dart'), | ||
Directive.import('package:dynamite_runtime/models.dart'), | ||
Directive.import('package:dynamite_runtime/utils.dart', as: 'dynamite_utils'), | ||
Directive.import('package:meta/meta.dart'), | ||
Directive.import('package:universal_io/io.dart'), | ||
Directive.import('package:uri/uri.dart'), | ||
const Code(''), | ||
]; | ||
if (state.hasResolvedBuiltTypes) { | ||
b.directives.add( | ||
Directive.part(p.basename(outputId.changeExtension('.g.dart').path)), | ||
); | ||
} | ||
|
||
if (state.hasResolvedBuiltTypes) { | ||
yield Directive.part(p.basename(outputId.changeExtension('.g.dart').path)); | ||
yield const Code(''); | ||
} | ||
} | ||
final analyzerIgnores = state.buildConfig.analyzerIgnores; | ||
if (analyzerIgnores != null) { | ||
b.ignoreForFile.addAll(analyzerIgnores); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.