-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
352 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Annotation Publisher | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- annotation/pubspec.yaml | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate | ||
uses: peiffer-innovations/actions-flutter-validate@v1 | ||
with: | ||
path: annotation | ||
|
||
- name: Publish | ||
uses: peiffer-innovations/actions-pub-publish@v1.0.2 | ||
with: | ||
credentials: ${{ secrets.CREDENTIAL_JSON }} | ||
path: annotation |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Codegen Publisher | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
paths: | ||
- codegen/pubspec.yaml | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate | ||
uses: peiffer-innovations/actions-flutter-validate@v1 | ||
with: | ||
path: codegen | ||
|
||
- name: Publish | ||
uses: peiffer-innovations/actions-pub-publish@v1.0.2 | ||
with: | ||
credentials: ${{ secrets.CREDENTIAL_JSON }} | ||
path: codegen |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ coverage/ | |
coverage_badge.svg | ||
test/.test_coverage.dart | ||
output/ | ||
*.g.dart | ||
|
||
# IntelliJ related | ||
*.iml | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [1.0.0+1] - July 4th, 2023 | ||
|
||
* Initial Release |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Peiffer Innovations, LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# json_theme_annotation | ||
|
||
Simple package containing the annotation classes needed for the code generation | ||
tools within the [json_theme](https://pub.dev/packages/json_theme) package. |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const jsonThemeDecoder = JsonThemeDecoder(); | ||
|
||
class JsonThemeDecoder { | ||
const JsonThemeDecoder(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'json_theme_annotation' | ||
description: 'Simple package holding the annotations needed by the JsonTheme code generator.' | ||
homepage: 'https://github.com/peiffer-innovations/json_theme' | ||
version: '1.0.0+1' | ||
|
||
environment: | ||
sdk: '>=3.0.0 <4.0.0' | ||
|
||
analyzer: | ||
exclude: | ||
- 'lib/generated/**' | ||
- 'lib/**/*.g.dart' | ||
|
||
dev_dependencies: | ||
test: '^1.24.3' | ||
|
||
ignore_updates: | ||
- 'archive' | ||
- 'async' | ||
- 'boolean_selector' | ||
- 'characters' | ||
- 'charcode' | ||
- 'collection' | ||
- 'clock' | ||
- 'crypto' | ||
- 'fake_async' | ||
- 'file' | ||
- 'matcher' | ||
- 'material_color_utilities' | ||
- 'meta' | ||
- 'path' | ||
- 'source_span' | ||
- 'stack_trace' | ||
- 'stream_channel' | ||
- 'string_scanner' | ||
- 'sync_http' | ||
- 'term_glyph' | ||
- 'test_api' | ||
- 'typed_data' | ||
- 'vector_math' | ||
- 'webdriver' |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('no-op', () {}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## [1.0.0] - July 4th, 2023 | ||
|
||
* Initial Release |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Peiffer Innovations, LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# json_theme_codegen | ||
|
||
Code generator for the [json_theme] package. This is intended to be used as an | ||
internal tool on the [json_theme] package itself rather than for external | ||
consumption. | ||
|
||
<!-- Links --> | ||
[json_theme]: https://pub.dev/packages/json_theme |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
builders: | ||
decoder_builder: | ||
import: 'package:json_theme_codegen/builder.dart' | ||
builder_factories: ['decoderLibrary'] | ||
build_extensions: { '.dart': ['decoder.g.part'] } | ||
auto_apply: dependents | ||
build_to: cache | ||
applies_builders: ['source_gen|combining_builder'] |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:build/build.dart'; | ||
import 'package:json_theme_codegen/json_theme_codegen.dart'; | ||
import 'package:source_gen/source_gen.dart'; | ||
|
||
Builder decoderLibrary(BuilderOptions options) => SharedPartBuilder( | ||
[ | ||
DecoderLibraryBuilder(), | ||
], | ||
'decoder', | ||
); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'src/decoder_library_builder.dart'; |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'package:analyzer/dart/element/element.dart'; | ||
import 'package:build/build.dart'; | ||
import 'package:json_theme_annotation/json_theme_annotation.dart'; | ||
import 'package:source_gen/source_gen.dart'; | ||
|
||
class DecoderLibraryBuilder extends GeneratorForAnnotation<JsonThemeDecoder> { | ||
@override | ||
String generateForAnnotatedElement( | ||
Element element, | ||
ConstantReader annotation, | ||
BuildStep buildStep, | ||
) { | ||
const kDecode = 'decode'; | ||
final name = element.name; | ||
if (name == null) { | ||
throw Exception( | ||
'Annotation found on unnamed location, cannot continue.', | ||
); | ||
} | ||
|
||
if (element is! ClassElement) { | ||
throw Exception('Annotation found but is '); | ||
} | ||
final methods = <String, String>{}; | ||
for (var m in element.methods) { | ||
if (m.isStatic && m.name.startsWith(kDecode)) { | ||
final mName = m.name; | ||
methods[mName.substring(kDecode.length)] = '$name.$mName'; | ||
print(mName); | ||
} | ||
} | ||
|
||
final buf = StringBuffer(); | ||
|
||
buf.write(''' | ||
typedef Decoder = dynamic Function(dynamic map, {bool validate}); | ||
const k${name}s = <String, Decoder>{ | ||
'''); | ||
|
||
for (var entry in methods.entries) { | ||
buf.write("'${entry.key}': ${entry.value},"); | ||
} | ||
|
||
buf.write('};'); | ||
return buf.toString(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: 'json_theme_codegen' | ||
description: 'A library to generate the mapping of decoders to the class names they decode' | ||
homepage: 'https://github.com/peiffer-innovations/json_theme' | ||
version: '1.0.0' | ||
|
||
environment: | ||
sdk: '>=3.0.0 <4.0.0' | ||
|
||
analyzer: | ||
exclude: | ||
- 'lib/generated/**' | ||
- 'lib/**/*.g.dart' | ||
|
||
dependencies: | ||
analyzer: '^5.13.0' | ||
build: '^2.4.0' | ||
build_runner: '^2.4.5' | ||
code_builder: '^4.4.0' | ||
json_class: '^2.2.1+3' | ||
json_theme_annotation: '^1.0.0+1' | ||
recase: '^4.1.0' | ||
source_gen: '^1.2.7' | ||
|
||
dev_dependencies: | ||
test: '^1.24.3' | ||
|
||
# dependency_overrides: | ||
# json_theme_annotation: | ||
# path: ../annotation | ||
|
||
ignore_updates: | ||
- 'archive' | ||
- 'async' | ||
- 'boolean_selector' | ||
- 'characters' | ||
- 'charcode' | ||
- 'collection' | ||
- 'clock' | ||
- 'crypto' | ||
- 'fake_async' | ||
- 'file' | ||
- 'matcher' | ||
- 'material_color_utilities' | ||
- 'meta' | ||
- 'path' | ||
- 'source_span' | ||
- 'stack_trace' | ||
- 'stream_channel' | ||
- 'string_scanner' | ||
- 'sync_http' | ||
- 'term_glyph' | ||
- 'test_api' | ||
- 'typed_data' | ||
- 'vector_math' | ||
- 'webdriver' |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('no-op', () {}); | ||
} |
Oops, something went wrong.