Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow customizing the name of the generated providers (#1898)
- Loading branch information
Showing
14 changed files
with
260 additions
and
6 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
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
6 changes: 6 additions & 0 deletions
6
packages/riverpod_generator/integration/build_yaml/.gitignore
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,6 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
build/ |
23 changes: 23 additions & 0 deletions
23
packages/riverpod_generator/integration/build_yaml/README.md
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,23 @@ | ||
# Pub | ||
|
||
Install needed global packages | ||
|
||
```bash | ||
cd riverpod | ||
dart pub global activate melos | ||
``` | ||
|
||
Build the riverpod packages | ||
|
||
```bash | ||
fluttter pub get | ||
``` | ||
|
||
## Start the tests | ||
|
||
```bash | ||
cd examples/build_yaml | ||
flutter pub run build_runner build | ||
|
||
flutter test | ||
``` |
6 changes: 6 additions & 0 deletions
6
packages/riverpod_generator/integration/build_yaml/build.yaml
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,6 @@ | ||
targets: | ||
$default: | ||
builders: | ||
riverpod_generator: | ||
options: | ||
provider_name_suffix: 'Pod' |
29 changes: 29 additions & 0 deletions
29
packages/riverpod_generator/integration/build_yaml/lib/main.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,29 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'main.g.dart'; | ||
|
||
@riverpod | ||
int count(CountRef ref) { | ||
return 1; | ||
} | ||
|
||
@riverpod | ||
FutureOr<int> countFuture(CountFutureRef ref) { | ||
return 1; | ||
} | ||
|
||
@riverpod | ||
class CountNotifier extends _$CountNotifier { | ||
@override | ||
int build() { | ||
return 1; | ||
} | ||
} | ||
|
||
@riverpod | ||
class CountAsyncNotifier extends _$CountAsyncNotifier { | ||
@override | ||
FutureOr<int> build() { | ||
return 1; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
packages/riverpod_generator/integration/build_yaml/lib/main.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
packages/riverpod_generator/integration/build_yaml/pubspec.yaml
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,16 @@ | ||
name: build_yaml | ||
description: A sample command-line application. | ||
version: 1.0.0 | ||
|
||
environment: | ||
sdk: ">=2.18.4 <3.0.0" | ||
|
||
dependencies: | ||
riverpod: | ||
riverpod_annotation: | ||
|
||
dev_dependencies: | ||
build_runner: ^2.3.2 | ||
build_verify: ^3.0.0 | ||
riverpod_generator: | ||
test: ^1.16.0 |
8 changes: 8 additions & 0 deletions
8
packages/riverpod_generator/integration/build_yaml/pubspec_overrides.yaml
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 @@ | ||
# melos_managed_dependency_overrides: riverpod,riverpod_annotation,riverpod_generator | ||
dependency_overrides: | ||
riverpod: | ||
path: ../../../riverpod | ||
riverpod_annotation: | ||
path: ../../../riverpod_annotation | ||
riverpod_generator: | ||
path: ../.. |
21 changes: 21 additions & 0 deletions
21
packages/riverpod_generator/integration/build_yaml/test/build_yaml_test.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,21 @@ | ||
import 'package:build_verify/build_verify.dart'; | ||
import 'package:build_yaml/main.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test( | ||
'ensure_build', | ||
() => expectBuildClean( | ||
packageRelativeDirectory: | ||
'packages/riverpod_generator/integration/build_yaml', | ||
), | ||
timeout: const Timeout(Duration(minutes: 1)), | ||
); | ||
|
||
test('provider names', () { | ||
expect(countPod.name, 'countPod'); | ||
expect(countFuturePod.name, 'countFuturePod'); | ||
expect(countNotifierPod.name, 'countNotifierPod'); | ||
expect(countAsyncNotifierPod.name, 'countAsyncNotifierPod'); | ||
}); | ||
} |
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
10 changes: 10 additions & 0 deletions
10
packages/riverpod_generator/test/build_yaml_config_test.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,10 @@ | ||
import 'package:riverpod_generator/src/models.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('custom suffix', () async { | ||
const map = {'provider_name_suffix': 'Pod'}; | ||
final options = BuildYamlOptions.fromMap(map); | ||
expect(options.providerNameSuffix, 'Pod'); | ||
}); | ||
} |