Skip to content

Commit

Permalink
Merge pull request #14 from Workiva/dart2_upgrade_codemod
Browse files Browse the repository at this point in the history
AF-3911 Finish the Dart 2 Upgrade codemod
  • Loading branch information
rmconsole7-wk authored Jan 23, 2019
2 parents 799b786 + 2b04d4a commit 7a01454
Show file tree
Hide file tree
Showing 46 changed files with 1,769 additions and 583 deletions.
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,29 @@ pub global activate over_react_codemod
Once you've activated this package, you should be able to run whichever codemods
you need via `pub global run`.

## Dart 1 to Dart 2 Codemods
## Dart 1 to Dart 2 Codemod

This package provides a `dart2_upgrade` codemod that will modify existing
over_react component code to be compatible with Dart 2 and the over_react
builder.

Depending on your needs, you may be able to upgrade directly from Dart 1 to
Dart 2, or you may need to take an intermediary step and provide a version of
your codebase that is both forwards- and backwards-compatible.

This package provides three codemod executables:

- `pub global run over_react_codemod:dart1_to_dart2`
your codebase that is both forwards- and backwards-compatible. Both of these
options are supported by this codemod.

Use this codemod if you want to migrate directly from Dart 1 compatibile
code to Dart 2 compatible code and do not need to provide a version that is
compatible with both.

_Still in progress; coming soon._

- `pub global run over_react_codemod:dart1_to_dart1_and_dart2`
- `pub global run over_react_codemod:dart2_upgrade --backwards-compat`

Use this codemod to migrate your over_react code to a format that is both
forwards-compatible with Dart 2 and backwards-compatible with Dart 1.

- `pub global run over_react_codemod:dart1_and_dart2_to_dart2`

Use this codemod to migrate over_react code that has previously been
migrated via the `dart1_to_dart1_and_dart2` codemod to the form that is only
compatible with Dart 2. In other words, use this when you're ready to drop
Dart 1 support.
- `pub global run over_react_codemod:dart2_upgrade`

_Still in progress; coming soon._
Use this codemod if you want to migrate to Dart 2 compatible code and do not
need to maintain backwards-compatability with Dart 1. You can run this to
immediately upgrade from Dart 1 to Dart 2, or you can run this on code that
has already been run through this codemod with the `--backwards-compat`
flag once you're ready to drop Dart 1 support.

For more information on the transition from Dart 1 to Dart 2 and how it affects
over_react, check out the [over_react Dart 2 migration guide](over_react_dart2).
Expand All @@ -69,7 +63,7 @@ checklist will prevent merging code that is not in the form that is compatible
with both Dart 1 and Dart 2:

```bash
pub global run over_react_codemod:dart1_to_dart1_and_dart2 --fail-on-changes
pub global run over_react_codemod:dart2_upgrade --fail-on-changes
```

## Ignoring Codemod Suggestions
Expand All @@ -87,8 +81,8 @@ of ending with `StateMixin`, but isn't actually an over_react state mixin:
class Foo extends Object with BarStateMixin {}
```

As is, the `dart1_to_dart1_and_dart2` codemod would find this code and attempt
to change it to:
As is, the `dart2_upgrade --backwards-compat` codemod would find this code and
attempt to change it to:

```dart
class Foo extends Object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.

export 'package:over_react_codemod/src/d1_to_d1_and_d2/executable.dart';
export 'package:over_react_codemod/src/executables/dart2_upgrade.dart';
13 changes: 13 additions & 0 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ const List<String> overReactAnnotationNames = const [
'StateMixin',
];

const List<String> overReactPropsStateAnnotationNames = const [
'Props',
'State',
'AbstractProps',
'AbstractState',
'PropsMixin',
'StateMixin',
];

/// Annotation names for over_react's props and state classes, excluding the
/// mixin annotations.
const List<String> overReactPropsStateNonMixinAnnotationNames = const [
Expand All @@ -56,3 +65,7 @@ const String propsMetaType = 'PropsMeta';

/// Dart type for the static meta field on state classes.
const String stateMetaType = 'StateMeta';

/// Comment text that is attached to the props/state companion classes.
const String temporaryCompanionClassComment =
'This will be removed once the transition to Dart 2 is complete.';
108 changes: 0 additions & 108 deletions lib/src/d1_to_d1_and_d2/executable.dart

This file was deleted.

181 changes: 0 additions & 181 deletions lib/src/d1_to_d1_and_d2/util.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:analyzer/analyzer.dart';
import 'package:codemod/codemod.dart';
import 'package:path/path.dart' as p;

import '../../util.dart';
import '../util.dart';
import 'over_react_generated_part_directive_adder.dart';

/// Suggestor that collects the set of libraries that need an over_react
Expand Down
Loading

0 comments on commit 7a01454

Please sign in to comment.