Skip to content

Commit

Permalink
Merge pull request #679 from Workiva/dart-2.9-boilerplate-wip
Browse files Browse the repository at this point in the history
Merge Dart 2.9 boilerplate wip
  • Loading branch information
rmconsole7-wk authored Feb 3, 2021
2 parents ada4af6 + 0b1f3ab commit 2a6a609
Show file tree
Hide file tree
Showing 542 changed files with 5,728 additions and 26,465 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/dart_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ jobs:
if: always() && ${{ matrix.sdk }} == '2.7.2' && steps.install.outcome == 'success'

# Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building
- name: Analyze project source (pre-build)
run: pub run dart_dev analyze
- name: Analyze example source (pre-build)
run: |
# Analyze lib to ensure public APIs don't depend on build-to-cache files,
# which could cause analysis issues for consumers who haven't run a build yet.
dartanalyzer lib
cd example/boilerplate_versions
if [ ${{ matrix.sdk }} = '2.7.2' ]; then pub global activate tuneup && tuneup check; fi
if [ ${{ matrix.sdk }} = 'stable' ]; then echo 'Skip pre-build analysis for Dart versions >=2.9 and <2.12 because there will be analysis errors.'; fi
if [ ${{ matrix.sdk }} = 'dev' ]; then cd mixin_based/dart_2_9_compatible && dart analyze; fi
if: always() && steps.install.outcome == 'success'

- id: build
Expand All @@ -51,7 +58,7 @@ jobs:

# Analyze again after generated files are created to verify that those generated classes don't cause analysis errors
- name: Analyze project source (post-build)
run: pub run dart_dev analyze
run: if [ ${{ matrix.sdk }} = '2.7.2' ]; then pub global activate tuneup && tuneup check; else dart analyze; fi
if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success'

- name: Run tests (VM)
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ __`UiFactory` is a function__ that returns a new instance of a
[`UiComponent2`](#uicomponent2)’s [`UiProps`](#uiprops) class.

```dart
UiFactory<FooProps> Foo = _$Foo;
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
```

* This factory is __the entry-point__ to consuming any OverReact component.
* The `UiProps` instance it returns can be used [as a component builder](#uiprops-as-a-builder),
or [as a typed view into an existing props map](#uiprops-as-a-map).
* `castUiFactory` is necessary to prevent implicit cast analysis warnings before code generation has been run.

&nbsp;

Expand All @@ -214,7 +215,7 @@ mixin FooProps on UiProps {
__To compose props mixin classes__, create a class alias that uses `UiProps` as the base and mix in multiple props mixins. The generated props implementation will then use it as the base class and implement the generated version of those props mixins.

```dart
UiFactory<FooProps> Foo = _$Foo;
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
mixin FooPropsMixin on UiProps {
String bar;
Expand All @@ -239,7 +240,7 @@ The use-case for composing multiple props mixins into a single component props c
#### UiProps as a Map

```dart
UiFactory<FooProps> Foo = _$Foo;
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
mixin FooProps on UiProps {
String color;
Expand Down Expand Up @@ -274,7 +275,7 @@ void baz() {
#### UiProps as a builder

```dart
UiFactory<FooProps> Foo = _$Foo;
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
mixin FooProps on UiProps {
String color;
Expand Down Expand Up @@ -353,7 +354,7 @@ They are instances of `UiProps` and `UiState`, __which means you don’t need St
* `typedPropsFactory()` and `typedStateFactory()` are also exposed to conveniently create typed `props` / `state` objects out of any provided backing map.

```dart
UiFactory<FooProps> Foo = _$Foo;
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
mixin FooProps on UiProps {
String color;
Expand Down Expand Up @@ -741,7 +742,7 @@ that you get for free from OverReact, you're ready to start building your own cu
import 'package:over_react/over_react.dart';
part 'foo_component.over_react.g.dart';
UiFactory<FooProps> Foo = _$Foo; // ignore: undefined_identifier
UiFactory<FooProps> Foo = castUiFactory(_$Foo); // ignore: undefined_identifier
mixin FooProps on UiProps {
// Props go here, declared as fields:
Expand Down Expand Up @@ -771,7 +772,7 @@ that you get for free from OverReact, you're ready to start building your own cu
import 'package:over_react/over_react.dart';
part 'foo_component.over_react.g.dart';
UiFactory<BarProps> Bar = _$Bar; // ignore: undefined_identifier
UiFactory<BarProps> Bar = castUiFactory(_$Bar); // ignore: undefined_identifier
mixin BarProps on UiProps {
// Props go here, declared as fields:
Expand Down Expand Up @@ -826,7 +827,7 @@ that you get for free from OverReact, you're ready to start building your own cu
);
},
// The generated props config will match the factory name.
$FooConfig, // ignore: undefined_identifier
_$FooConfig, // ignore: undefined_identifier
);

mixin FooProps on UiProps {
Expand Down Expand Up @@ -855,13 +856,13 @@ another component.
/// * Similar to [SplitButton].
///
/// See: <https://link-to-any-relevant-documentation>.
UiFactory<DropdownButtonProps> DropdownButton = _$DropdownButton; // ignore: undefined_identifier
UiFactory<DropdownButtonProps> DropdownButton = castUiFactory(_$DropdownButton); // ignore: undefined_identifier
```

_Bad:_
```dart
/// Component Factory for a dropdown button component.
UiFactory<DropdownButtonProps> DropdownButton = _$DropdownButton; // ignore: undefined_identifier
UiFactory<DropdownButtonProps> DropdownButton = castUiFactory(_$DropdownButton); // ignore: undefined_identifier
```

&nbsp;
Expand Down
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
include: package:pedantic/analysis_options.1.8.0.yaml

analyzer:
strong-mode:
implicit-casts: false
exclude:
- _site/**
- test_fixtures/**
- app/**
- tools/analyzer_plugin/**
- ddc_precompiled/**
errors:
unused_import: warning
duplicate_import: warning
missing_required_param: error
must_call_super: error
uri_has_not_been_generated: ignore
linter:
rules:
# -------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ UiFactory<TodoAppProps> TodoApp = connect<AppState, TodoAppProps>(
);
},
forwardRef: true,
)(_$TodoApp); // ignore: undefined_identifier
)(castUiFactory(_$TodoApp)); // ignore: undefined_identifier

mixin TodoAppPropsMixin on UiProps {
Function(String description) createTodo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'app_bar.over_react.g.dart';

UiFactory<TodoAppBarProps> TodoAppBar =
_$TodoAppBar; // ignore: undefined_identifier
castUiFactory(_$TodoAppBar); // ignore: undefined_identifier

mixin TodoAppBarProps on UiProps {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UiFactory<AppBarLocalStorageMenuProps> AppBarLocalStorageMenu = connect<AppState
..currentDataHasBeenModified = json.encode(localTodoAppStorage[state.name]) != json.encode(state.toJson())
);
},
)(_$AppBarLocalStorageMenu); // ignore: undefined_identifier
)(castUiFactory(_$AppBarLocalStorageMenu)); // ignore: undefined_identifier

mixin AppBarLocalStorageMenuPropsMixin on UiProps {
String currentDataSetName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'local_storage_menu_item_input.over_react.g.dart';

UiFactory<LocalStorageMenuItemInputProps> LocalStorageMenuItemInput =
_$LocalStorageMenuItemInput; // ignore: undefined_identifier
castUiFactory(_$LocalStorageMenuItemInput); // ignore: undefined_identifier

@Props(keyNamespace: '')
mixin LocalStorageMenuItemInputProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'save_as_menu_item.over_react.g.dart';

UiFactory<SaveAsMenuItemProps> SaveAsMenuItem =
_$SaveAsMenuItem; // ignore: undefined_identifier
castUiFactory(_$SaveAsMenuItem); // ignore: undefined_identifier

mixin SaveAsMenuItemProps on UiProps {
String initialValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:todo_client/src/components/shared/menu_overlay.dart';
part 'saved_data_menu_item.over_react.g.dart';

UiFactory<SavedDataMenuItemProps> SavedDataMenuItem =
_$SavedDataMenuItem; // ignore: undefined_identifier
castUiFactory(_$SavedDataMenuItem); // ignore: undefined_identifier

@Props(keyNamespace: '')
mixin SavedDataMenuItemProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'create_input.over_react.g.dart';

UiFactory<CreateInputProps> CreateInput =
_$CreateInput; // ignore: undefined_identifier
castUiFactory(_$CreateInput); // ignore: undefined_identifier

@Props(keyNamespace: '') // No namespace so prop forwarding works when passing to the JS TextField component.
mixin CreateInputProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'avatar_with_colors.over_react.g.dart';

UiFactory<AvatarWithColorsProps> AvatarWithColors =
_$AvatarWithColors; // ignore: undefined_identifier
castUiFactory(_$AvatarWithColors); // ignore: undefined_identifier

mixin AvatarWithColorsProps on UiProps {
String fullName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:todo_client/src/components/shared/empty_view.dart';
part 'display_list.over_react.g.dart';

UiFactory<DisplayListProps> DisplayList =
_$DisplayList; // ignore: undefined_identifier
castUiFactory(_$DisplayList); // ignore: undefined_identifier

@Props(keyNamespace: '') // No namespace so prop forwarding works when passing to the JS TextField component.
mixin DisplayListProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ part 'empty_view.over_react.g.dart';
/// or an empty view such as a 404 error page.
UiFactory<EmptyViewProps> EmptyView =
_$EmptyView; // ignore: undefined_identifier
castUiFactory(_$EmptyView); // ignore: undefined_identifier

mixin EmptyViewProps on UiProps {
/// The layout of the [EmptyView].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
part 'list_item_expansion_panel_summary.over_react.g.dart';

UiFactory<ListItemAccordionSummaryProps> ListItemAccordionSummary =
_$ListItemAccordionSummary; // ignore: undefined_identifier
castUiFactory(_$ListItemAccordionSummary); // ignore: undefined_identifier

mixin ListItemAccordionSummaryProps on UiProps {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ part 'menu_overlay.over_react.g.dart';
/// or an empty view such as a 404 error page.
UiFactory<MenuOverlayProps> MenuOverlay =
_$MenuOverlay; // ignore: undefined_identifier
castUiFactory(_$MenuOverlay); // ignore: undefined_identifier

@Props(keyNamespace: '')
mixin MenuOverlayProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ part 'todo_item_text_field.over_react.g.dart';
/// or an empty view such as a 404 error page.
UiFactory<TodoItemTextFieldProps> TodoItemTextField =
_$TodoItemTextField; // ignore: undefined_identifier
castUiFactory(_$TodoItemTextField); // ignore: undefined_identifier

@Props(keyNamespace: '') // No namespace so prop forwarding works when passing to the JS TextField / InputBase components.
mixin TodoItemTextFieldProps on UiProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ UiFactory<TaskCountBadgeProps> TaskCountBadge = connect<AppState, TaskCountBadge
areStatePropsEqual: (nextProps, prevProps) {
return ListEquality().equals(nextProps.assignedTodoIds, prevProps.assignedTodoIds);
},
)(_$TaskCountBadge); // ignore: undefined_identifier
)(castUiFactory(_$TaskCountBadge)); // ignore: undefined_identifier

mixin TaskCountBadgePropsMixin on UiProps {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ UiFactory<TodoListProps> TodoList = connect<AppState, TodoListProps>(
);
},
forwardRef: true,
)(_$TodoList); // ignore: undefined_identifier
)(castUiFactory(_$TodoList)); // ignore: undefined_identifier

mixin TodoListPropsMixin on UiProps {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ UiFactory<TodoListItemProps> TodoListItem = connect<AppState, TodoListItemProps>
..isHighlighted = isHighlighted
);
},
)(_$TodoListItem); // ignore: undefined_identifier
)(castUiFactory(_$TodoListItem)); // ignore: undefined_identifier

mixin TodoListItemPropsMixin on UiProps, ListItemPropsMixin {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ UiFactory<UserListProps> UserList = connect<AppState, UserListProps>(
);
},
forwardRef: true,
)(_$UserList); // ignore: undefined_identifier
)(castUiFactory(_$UserList)); // ignore: undefined_identifier

mixin UserListPropsMixin on UiProps {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ UiFactory<UserListItemProps> UserListItem = connect<AppState, UserListItemProps>
..isHighlighted = isHighlighted
);
},
)(_$UserListItem); // ignore: undefined_identifier
)(castUiFactory(_$UserListItem)); // ignore: undefined_identifier

mixin UserListItemPropsMixin on UiProps, ListItemPropsMixin {
@requiredProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ UiFactory<UserSelectorProps> UserSelector = connect<AppState, UserSelectorProps>
);
},
forwardRef: true
)(_$UserSelector); // ignore: undefined_identifier
)(castUiFactory(_$UserSelector)); // ignore: undefined_identifier

mixin UserSelectorProps on UiProps {
String selectedUserId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of todo_client.src.components.user_selector;

UiFactory<UserSelectorTriggerProps> UserSelectorTrigger =
_$UserSelectorTrigger; // ignore: undefined_identifier
castUiFactory(_$UserSelectorTrigger); // ignore: undefined_identifier

@Props(keyNamespace: '')
mixin UserSelectorTriggerProps on UiProps {
Expand Down
5 changes: 0 additions & 5 deletions app/over_react_redux/todo_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,3 @@ dev_dependencies:
dependency_overrides:
over_react:
path: '../../../'
react:
git:
url: https://github.com/cleandart/react-dart.git
ref: 6.0.0-wip

32 changes: 27 additions & 5 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,36 @@ targets:
over_react|_over_react_local_builder:
enabled: true
generate_for:
include:
- "lib/**"
- "test/**"
- "web/component1/**"
# The Dart 2 only boilerplate does not analyze cleanly without a build so the generated files need to be
# checked in.
- "example/boilerplate_versions/dart2_only/**"
exclude:
# These tests analyze cleanly without a build so the generated files do not need to be checked in.
- "test/over_react/component_declaration/builder_integration_tests/backwards_compatible/**"
- "test/over_react/component_declaration/builder_integration_tests/new_boilerplate/**"
# These test un-built base class behavior, and contain code that might look like declarations
# and should definitely not be built
- "test/over_react/component_declaration/builder_helpers_test.dart"
- "test/over_react/component_declaration/component_base_test.dart"

over_react|overReactBuilder:
enabled: false
enabled: true
generate_for:
include:
- "web/**"
- "example/**"
# These tests analyze cleanly without a build so the generated files do not need to be checked in.
- "test/over_react/component_declaration/builder_integration_tests/backwards_compatible/**"
- "test/over_react/component_declaration/builder_integration_tests/new_boilerplate/**"
exclude:
- "web/component1/**"
# The Dart 2 only boilerplate does not analyze cleanly without a build so the generated files need to be
# checked in.
- "example/boilerplate_versions/dart2_only/**"

built_value_generator|built_value:
generate_for:
Expand All @@ -39,10 +61,10 @@ targets:
include:
- test/over_react/component_declaration/redux_component_test/test_reducer.dart

build_vm_compilers|entrypoint:
generate_for:
include:
- "test/vm_tests/**"
# build_vm_compilers|entrypoint:
# generate_for:
# include:
# - "test/vm_tests/**"

# builder uses mirrors and will cause a build to fail when using build web compilers
# vm tests require the use of mirrors
Expand Down
Loading

0 comments on commit 2a6a609

Please sign in to comment.