Commit Graph

97 Commits

Author SHA1 Message Date
Michael Thomsen 897706edbd Remove unrecommended flag from output:
The current output indirectly advertizes premature out-of-order migration,
which would be bad if it happened widely.

We can keep the flag, but should not advertize it.

Change-Id: I8bde10489cef8e1104e2e5216e03aed61bc95ba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153612
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2020-07-09 01:19:53 +00:00
Paul Berry b514f45ac7 Migration: allow tests to override preview server's use of ipv4.
This is necessary for some Google internal testing environments that
are ipv6-only.

Change-Id: I1385786bd0f9614fabcf5730d96a0d6018c6401e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153063
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-01 21:26:04 +00:00
Sam Rawlins 448016e811 Migrator: add --preview-hostname option
Fixes https://github.com/dart-lang/sdk/issues/41084

Change-Id: I35068ecf2cf0cec5cac418146149d0e0705dc05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151666
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-23 18:50:53 +00:00
Paul Berry a9bb706ce2 Migration: allow the client to specify which files to analyze/migrate.
Change-Id: Ie49f003640342a8c0d26b4f509a9268200955dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151302
Reviewed-by: Janice Collins <jcollins@google.com>
2020-06-16 21:10:11 +00:00
Sam Rawlins 61184814e2 Migrator: use dart pub to check outdated
Fixes #42343

This also prevents a crash if the binary-to-execute could not be found.

Change-Id: I19dd9f6dcbb41a5c8b4ef2a04a87c1fc83429120
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151327
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-16 14:08:04 +00:00
Paul Berry 2fbe5c1f54 Migration: Make the three migration phases explicit in NonNullableFix API.
Previously the API was general, exposing a `numPhases` integer, and
providing a generic processing function with a `phase` argument.  This
was necessary back when migration was built into DartFix (because
different kinds of fixes had different numbers of phases), but now
that migration is a separate tool, it gets in the way because it makes
it difficult for the caller to have different behaviors in different
phases.

This is a prerequisite for making it possible to have some files
analyzed but not finalized (which is in turn necessary for handling
generated files).

Change-Id: I5993808eb3dace21d8b6cb9c5308f94a3b1f898e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry 9f8776f4a9 Migration: split out a MigrationCliRunner API from MigrationCli.
This API can be used by tools that wish to perform migration but want
to provide their own command-line argument parsing.

Change-Id: Ic54e993139c803ded5ac39229ae84980db12184e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151080
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry a7c93201e4 Migration: rework how MigrationCli.run() reports an exit code.
Previously, MigrationCli.run() would always return, but it would set
MigrationCli.exitCode to indicate whether an error occurred.  This
made it necessary to thread a lot of tricky logic around to ensure
that we would exit quickly if an error occurred.  This CL switches to
using an exception, so we get the same effect automatically.

Change-Id: I2b885092dec551700900b118ec3d9acd2f3649d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150760
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Devon Carew c607eb9637 [nnbd_migration] address an issue with the progress text written to stdout
Change-Id: I8bd4b4a291d1d64b48752c06f2ec7784e5bac819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151040
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-12 00:18:46 +00:00
Mike Fairhurst 6b40b26044 [nnbd_migration] Print warning when SDK_PATH is set and things go wrong.
Also clean up sanity checking code a little bit.

Change-Id: I4274dad42687a4dc419090d656ec56168c982c29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150661
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-11 17:19:51 +00:00
Samuel Rawlins 5a32ff0d7f Revert "Bump cli_util to 0.2.0; implement new methods"
This reverts commit ebcc6dc2a2.

Reason for revert: Broke golem. I think there are more implementations of Logger than I realized.

Original change's description:
> Bump cli_util to 0.2.0; implement new methods
> 
> This fixes the issue of progress indicators being shown during tests.
> 
> Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,jcollins@google.com,mfairhurst@google.com,srawlins@google.com

Change-Id: I52ac0f5d96a161534c28cc160c2a2b3b364ad511
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150693
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-10 23:59:05 +00:00
Sam Rawlins ebcc6dc2a2 Bump cli_util to 0.2.0; implement new methods
This fixes the issue of progress indicators being shown during tests.

Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-10 22:10:06 +00:00
Paul Berry ae3b975373 Migration: exit early if an exception occurs
Change-Id: I108b64d75f9eb4ab376dfacaaeafcac1ef333755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-10 13:50:27 +00:00
Paul Berry aa2566410f Migration: Add a flag to allow the user to ignore exceptions.
This should allow users to work around bugs while waiting for fixes
from the migration team.

Change-Id: I04fe08b4753ee1377a60ec60728a16560847536f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150542
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-10 13:50:27 +00:00
Paul Berry e4aaa1146b Sort declarations in migration_cli.dart
Change-Id: I05025f629080725f39a762c1d9f54d3aac7bf950
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150463
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-08 23:44:50 +00:00
Devon Carew 88f20ece1e [nnbd_migration] re-land a fix for migrating packages with multiple contexts
Change-Id: I60365e4a159f8696b17a8dd7f6d3fa0641a5afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149889
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-04 17:05:57 +00:00
Paul Berry ac45f23134 Migration: Fix reporting of exceptions.
Permissive mode in the analyzer currently is broken, leading to a
useless stacktrace if an exception occurs.  As a quick fix, turn
permissive mode off, so the exception just bubbles up normally and
shows on the console.  In follow-up CLs I'll actually fix permissive
mode and add a user option to enable it.

Fixes #42138.

Change-Id: I59322ca9dd90b856c56a6ec335762b94ec6935b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149863
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-04 13:01:51 +00:00
Devon Carew ceb08283df Revert "[nnbd_migration] handle multiple contexts"
This reverts commit 54adfeb93f.

Reason for revert: this breaks the windows bot

Original change's description:
> [nnbd_migration] handle multiple contexts
> 
> Bug: https://github.com/dart-lang/sdk/issues/42141
> Change-Id: I64179cd3fa0389397a8a9b3a763fbb1a3719294e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149664
> Commit-Queue: Devon Carew <devoncarew@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,devoncarew@google.com

Change-Id: I793d8f4a2832e7da0cb30565aee4a4806c0b0e02
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/42141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149803
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-03 16:04:53 +00:00
Devon Carew 54adfeb93f [nnbd_migration] handle multiple contexts
Bug: https://github.com/dart-lang/sdk/issues/42141
Change-Id: I64179cd3fa0389397a8a9b3a763fbb1a3719294e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149664
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-02 18:40:43 +00:00
Sam Rawlins 93d39a5ef5 Migrator: Edit the package_config.json file
Bug: https://github.com/dart-lang/sdk/issues/41765
Change-Id: I019a97427b6faa4d4f5335b64424fab4bc3c5cde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149611
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-02 15:51:11 +00:00
Devon Carew 2c5739bd2b [nnbd_migration] update the CLI instructions of the migration tool
Change-Id: If42abe73b9a6640e3e1a7d2ecc23bd604c57238e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149603
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-06-01 16:25:04 +00:00
Sam Rawlins d79c5b5d31 Migrator: run pub outdated from the correct directory
Fixes https://github.com/dart-lang/sdk/issues/42084

Change-Id: I74eb3cbf61f4346b82f81f77977989fbbd7f8274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149366
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-29 00:23:09 +00:00
Sam Rawlins 2dea325d87 Migrator: use pub.bat on Windows
Fixes https://github.com/dart-lang/sdk/issues/42102

Change-Id: Ic2dd785a84835402c7af3ef7b8d15285585a0afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149386
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-28 23:17:12 +00:00
Paul Berry 2e261f9386 Migration: add locations to trace entries that refer to elements.
Bug: https://github.com/dart-lang/sdk/issues/41402
Change-Id: I0dc59ae9d64c6e8ab470b2ddcb5fd42557ba5704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148742
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-27 21:52:14 +00:00
Sam Rawlins 16b90d2085 Migrator: Check dependencies with pub outdated
Fixes https://github.com/dart-lang/sdk/issues/41769

Change-Id: I892322076c1d03026c42c13b98bb1dcb466e9263
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148789
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-21 22:06:53 +00:00
Paul Berry e248acc156 Migration: remove dependency on analysis server's fix_code_task.dart.
Change-Id: I07b30dbfdf82d940f51d8f009d0e44e2baea15ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148509
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 18:09:54 +00:00
Paul Berry 48202fa5c2 Migration: extract some implementation details from migration_cli.dart
This will enable these classes to be re-used in unit tests.

Change-Id: Icb5e7ede94603577de44a7d53c30bb4e76a92b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148465
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-19 17:08:00 +00:00
Paul Berry c38742cdbc Migration: remove references from analysis_server to nnbd_migration.
Change-Id: I90b562b8b3e82b770f197d7ef2c4e10ac9f99100
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148160
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-15 16:49:32 +00:00
Paul Berry d00d800f3a Migration: connect dartdev to new command-line API.
We no longer use the analysis server or dartfix for migration.

This should unblock removing migration integration from dartfix, which
will unblock publishing dartfix.

It should also pave the way for future changes that will allow us to
publish the NNBD migration tool on pub, which in turn will allow us to
provide updates and bug fixes to the migration tool without having to
publish a new Dart or Flutter SDK.

Change-Id: I9f128b61a2983befc5ef686867dab3db87fd6855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148020
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-14 18:03:21 +00:00
Paul Berry 898f28d51a Migration: do not parse args in new CLI handler.
This is a step toward integrating the new migration CLI with dartdev.
It's necessary because dartdev handles arg parsing.

Change-Id: Ie50a69c434fd4d8873616e72b8274545cf0277d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148007
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-14 18:03:21 +00:00
Paul Berry fabceab5ee Migration: remove changedPaths tracking.
See comments in
https://dart-review.googlesource.com/c/sdk/+/147043/1/pkg/nnbd_migration/lib/migration_cli.dart#484
for why this is unnecessary.

Change-Id: I046835d73eb581aecd8d65b1e3248d07daf34f17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147702
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-05-13 20:42:56 +00:00
Paul Berry 9e087df222 Migration: fix rerunning migration tool after adding/removing files
Change-Id: I33e7ab428902efa44c7569fefc9f9c7436cae740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147044
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-12 16:33:59 +00:00
Paul Berry 383e75e5de Migration: add rerun support to new CLI
Change-Id: If4e2854f0326ef0ef2d03a83a647a3d3bb092d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147043
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-12 16:33:59 +00:00
Sam Rawlins af99babc6c Migrator: Only print text about --apply-changes conditionally
Fixes https://github.com/dart-lang/sdk/issues/40881

Change-Id: I4671e29f05ca9495419681a1f3fcb9d1718acbf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147334
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-12 13:57:09 +00:00
Sam Rawlins c6db98667a Migrator: Add a progress bar; fixes #41187
The progress bar fills the width of the user's terminal, and computes
progress strictly based on files and phases, not weighing any file or
phase as greater than another.

Change-Id: Ic9840b3b66789512e0973160b3e0f069b714a4f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147421
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-05-12 01:22:11 +00:00
Paul Berry 965dd4d6d8 Migration CLI: validate that package to migrate exists and is not a file
Change-Id: I4b7c189e29c141a5bbd7738542d7dbf398e567d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146523
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry e5efe2be29 Migration CLI: normalize input path and make it absolute
Change-Id: Ie88dae881f62b3513df9f799ca1abd4c7e831641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146500
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry c644e4c001 Migration: remove unnecessary TODO comment about supporting --debug in new CLI.
In the dartfix-based implementation, the only significant effect of
supplying `--debug` was to enable the analysis server's
instrumentation log.  Since we don't have an analysis server layer in
the new CLI, there's no need for this command line option right now.

If we decide we need a `--debug` flag later we can always add it.

Change-Id: Ib729c5793044456ef460cfa7f823c48f5af9e898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146445
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:25:33 +00:00
Paul Berry 1ac898a2c5 Migration: add the ability to output a text diff to the CLI.
The previous implementation of the tool (based on dartfix) used
diffing code that was pretty deeply tied into dartfix, and didn't
produce good quality output for migration, so I've replaced it with a
new implementation.

Change-Id: Id3679435bf59c73145eacb6eaee1b6ce16dd61f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146442
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-05-05 20:19:23 +00:00
Paul Berry 8061d2d6cc Migration: add support for a machine-readable summary of migration results.
Change-Id: Id41bc9869448dd4ed63286cab814bf7687baaaad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-05-05 17:35:22 +00:00
Paul Berry ff53bd8d4a Migration: make sure new CLI detects when run with an old SDK
Change-Id: I7b279788e34d3d2e86df58ff4ef7c86b58e154e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145644
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 21:50:12 +00:00
Paul Berry c33f4ad9fc Migration: support changing pubspec in new CLI
Change-Id: I2e091a4ef8999f1fe649c7b9e69798e9959b635a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145643
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-30 21:50:12 +00:00
Paul Berry a144fedbba Migration: add support for --ignore-errors to new CLI
Change-Id: I467c3ecfc7e8a7f52a1ba2be887ac2a677d5545c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145543
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-30 16:23:37 +00:00
Paul Berry c80ff5f5f7 Migration: nicer text for command-line option errors
Previously we just printed the result of calling Exception.toString(),
so the exception class name appeared in the output.

Change-Id: I789d4e5524cd8614d688252644b80898fd2cda17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144882
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry cbdfc7f7ba Migration: add --apply-changes support to new CLI
Change-Id: I803747d09501be4cfa982ae6b3449e84d5752e3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144881
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry b2773e38da Migration: add --no-web-preview support to new CLI
Change-Id: I2fe106ab2a48cdba610990b747ae3b9e1ef1d086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144861
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00
Paul Berry 8d188a1a9f Migration: begin implementing CLI for the migration tool outside analysis server.
This will allow us to publish the migration tool on pub, so that we
can ship improvements to it that aren't coupled to SDK releases.

As of this CL, basic read-only functionality of the preview site is
working.  However, the ability to apply migrations and add hints to
existing code has not yet been tested.

Change-Id: Ib1588e741efa7be7861fa75b962fd1565765e794
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144808
Reviewed-by: Janice Collins <jcollins@google.com>
2020-04-27 16:33:23 +00:00