Pub publish dialog with policy link (#2318)

* Add policy note to pub publish command

Includes a minor re-design of how errors and warnings are presented.
Notably prints summary of warnings in bold red text when asking if
the user wants to publish the package.

The confirmation dialog also includes the package name and version as
this may have scrolled out of view if the list of files or warnings is
huge.

* Fixed tests

Co-authored-by: Michael Thomsen <mit@google.com>
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index 626ae63..9a45636 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -180,14 +180,20 @@
       return warnings.isEmpty;
     }
 
-    var message = '\nLooks great! Are you ready to upload your package';
+    log.message('\nUploads to pub.dev are subject to https://pub.dev/policy');
+
+    final package = entrypoint.root;
+    var message = 'Do you want to publish ${package.name} ${package.version}';
 
     if (warnings.isNotEmpty) {
-      var s = warnings.length == 1 ? '' : 's';
-      message = '\nPackage has ${warnings.length} warning$s. Upload anyway';
+      final s = warnings.length == 1 ? '' : 's';
+      final warning = log.bold(log.red(
+        'Package has ${warnings.length} warning$s',
+      ));
+      message = '$warning. $message';
     }
 
-    var confirmed = await confirm(message);
+    var confirmed = await confirm('\n$message');
     if (!confirmed) {
       log.error('Package upload canceled.');
       return false;
diff --git a/lib/src/validator.dart b/lib/src/validator.dart
index 5a516cd..1317860 100644
--- a/lib/src/validator.dart
+++ b/lib/src/validator.dart
@@ -138,7 +138,8 @@
           validators.expand((validator) => validator.warnings).toList();
 
       if (errors.isNotEmpty) {
-        log.error('Missing requirements:');
+        final s = errors.length > 1 ? 's' : '';
+        log.error('Package validation found the following error$s:');
         for (var error in errors) {
           log.error("* ${error.split('\n').join('\n  ')}");
         }
@@ -146,7 +147,10 @@
       }
 
       if (warnings.isNotEmpty) {
-        log.warning('Suggestions:');
+        final s = warnings.length > 1 ? 's' : '';
+        log.warning(
+          'Package validation found the following potential issue$s:',
+        );
         for (var warning in warnings) {
           log.warning("* ${warning.split('\n').join('\n  ')}");
         }
diff --git a/test/lish/force_publishes_if_there_are_warnings_test.dart b/test/lish/force_publishes_if_there_are_warnings_test.dart
index e1f5bec..23b7996 100644
--- a/test/lish/force_publishes_if_there_are_warnings_test.dart
+++ b/test/lish/force_publishes_if_there_are_warnings_test.dart
@@ -37,7 +37,10 @@
     });
 
     await pub.shouldExit(exit_codes.SUCCESS);
-    expect(pub.stderr, emitsThrough('Suggestions:'));
+    expect(
+      pub.stderr,
+      emitsThrough('Package validation found the following potential issue:'),
+    );
     expect(
         pub.stderr,
         emitsLines(
diff --git a/test/lish/preview_package_validation_has_a_warning_test.dart b/test/lish/preview_package_validation_has_a_warning_test.dart
index b715fab..43e3272 100644
--- a/test/lish/preview_package_validation_has_a_warning_test.dart
+++ b/test/lish/preview_package_validation_has_a_warning_test.dart
@@ -23,7 +23,10 @@
     var pub = await startPublish(server, args: ['--dry-run']);
 
     await pub.shouldExit(exit_codes.DATA);
-    expect(pub.stderr, emitsThrough('Suggestions:'));
+    expect(
+      pub.stderr,
+      emitsThrough('Package validation found the following potential issue:'),
+    );
     expect(
         pub.stderr,
         emitsLines(
diff --git a/test/test_pub.dart b/test/test_pub.dart
index c79319c..dbcea40 100644
--- a/test/test_pub.dart
+++ b/test/test_pub.dart
@@ -289,8 +289,11 @@
   // test packages. Should validate this a little more loosely.
   await expectLater(
       pub.stdout, emits(startsWith('Publishing test_pkg 1.0.0 to ')));
-  await expectLater(pub.stdout,
-      emitsThrough('Looks great! Are you ready to upload your package (y/n)?'));
+  await expectLater(
+      pub.stdout,
+      emitsThrough(matches(
+        r'^Do you want to publish [^ ]+ [^ ]+ (y/n)?',
+      )));
   pub.stdin.writeln('y');
 }