Completely switch from pub.dartlang.org to pub.dev (#3611)

diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index 115f6a9..4b182b2 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -156,9 +156,9 @@
   Future<void> _publish(List<int> packageBytes) async {
     try {
       final officialPubServers = {
-        'https://pub.dartlang.org',
-        // [validateAndNormalizeHostedUrl] normalizes https://pub.dev
-        // to https://pub.dartlang.org, so we don't need to do allow that here.
+        'https://pub.dev',
+        // [validateAndNormalizeHostedUrl] normalizes https://pub.dartlang.org
+        // to https://pub.dev, so we don't need to do allow that here.
 
         // Pub uses oauth2 credentials only for authenticating official pub
         // servers for security purposes (to not expose pub.dev access token to
diff --git a/lib/src/command/uploader.dart b/lib/src/command/uploader.dart
index 07ffacc..4b6406d 100644
--- a/lib/src/command/uploader.dart
+++ b/lib/src/command/uploader.dart
@@ -27,8 +27,7 @@
 
   UploaderCommand() {
     argParser.addOption('server',
-        defaultsTo: Platform.environment['PUB_HOSTED_URL'] ??
-            'https://pub.dartlang.org',
+        defaultsTo: Platform.environment['PUB_HOSTED_URL'] ?? 'https://pub.dev',
         help: 'The package server on which the package is hosted.\n',
         hide: true);
     argParser.addOption('package',
diff --git a/lib/src/oauth2.dart b/lib/src/oauth2.dart
index 802a8c2..2159847 100644
--- a/lib/src/oauth2.dart
+++ b/lib/src/oauth2.dart
@@ -212,7 +212,7 @@
   return path.join(cache.rootDir, 'credentials.json');
 }
 
-/// Gets the user to authorize pub as a client of pub.dartlang.org via oauth2.
+/// Gets the user to authorize pub as a client of pub.dev via oauth2.
 ///
 /// Returns a Future that completes to a fully-authorized [Client].
 Future<Client> _authorize() async {
@@ -241,7 +241,7 @@
     completer
         .complete(grant.handleAuthorizationResponse(queryToMap(queryString)));
 
-    return shelf.Response.found('https://pub.dartlang.org/authorized');
+    return shelf.Response.found('https://pub.dev/authorized');
   });
 
   var authUrl = grant.getAuthorizationUrl(
diff --git a/lib/src/source/hosted.dart b/lib/src/source/hosted.dart
index 4c366d5..4e8a939 100644
--- a/lib/src/source/hosted.dart
+++ b/lib/src/source/hosted.dart
@@ -47,8 +47,8 @@
 /// unless the path is merely `/`, in which case we normalize to the bare
 /// domain.
 ///
-/// We change `https://pub.dev` to `https://pub.dartlang.org`, this  maintains
-/// avoids churn for `pubspec.lock`-files which contain
+/// We change `https://pub.dartlang.org` to `https://pub.dev`, this  maintains
+/// backwards compatibility with `pubspec.lock`-files which contain
 /// `https://pub.dartlang.org`.
 ///
 /// Throws [FormatException] if there is anything wrong [hostedUrl].
@@ -105,9 +105,9 @@
   //
   // Clearly, a bit of investigation is necessary before we update this to
   // pub.dev, it might be attractive to do next time we change the server API.
-  if (u == Uri.parse('https://pub.dev')) {
-    log.fine('Using https://pub.dartlang.org instead of https://pub.dev.');
-    u = Uri.parse('https://pub.dartlang.org');
+  if (u == Uri.parse('https://pub.dartlang.org')) {
+    log.fine('Using https://pub.dev instead of https://pub.dartlang.org.');
+    u = Uri.parse('https://pub.dev');
   }
   return u;
 }
@@ -151,7 +151,7 @@
     // Clearly, a bit of investigation is necessary before we update this to
     // pub.dev, it might be attractive to do next time we change the server API.
     try {
-      var defaultHostedUrl = 'https://pub.dartlang.org';
+      var defaultHostedUrl = 'https://pub.dev';
       // Allow the defaultHostedUrl to be overriden when running from tests
       if (runningFromTest) {
         defaultHostedUrl =
diff --git a/test/cache/list_test.dart b/test/cache/list_test.dart
index a2c26a4..c554c22 100644
--- a/test/cache/list_test.dart
+++ b/test/cache/list_test.dart
@@ -10,8 +10,7 @@
 
 void main() {
   String hostedDir(package) {
-    return path.join(
-        d.sandbox, cachePath, 'hosted', 'pub.dartlang.org', package);
+    return path.join(d.sandbox, cachePath, 'hosted', 'pub.dev', package);
   }
 
   test('running pub cache list when there is no cache', () async {
@@ -21,7 +20,7 @@
   test('running pub cache list on empty cache', () async {
     // Set up a cache.
     await d.dir(cachePath, [
-      d.dir('hosted', [d.dir('pub.dartlang.org', [])])
+      d.dir('hosted', [d.dir('pub.dev', [])])
     ]).create();
 
     await runPub(args: ['cache', 'list'], outputJson: {'packages': {}});
@@ -31,7 +30,7 @@
     // Set up a cache.
     await d.dir(cachePath, [
       d.dir('hosted', [
-        d.dir('pub.dartlang.org', [
+        d.dir('pub.dev', [
           d.dir('foo-1.2.3', [d.libPubspec('foo', '1.2.3'), d.libDir('foo')]),
           d.dir('bar-2.0.0', [d.libPubspec('bar', '2.0.0'), d.libDir('bar')])
         ])
@@ -57,7 +56,7 @@
     // Set up a cache.
     await d.dir(cachePath, [
       d.dir('hosted', [
-        d.dir('pub.dartlang.org', [
+        d.dir('pub.dev', [
           d.dir('foo-1.2.3', [
             d.libPubspec('foo', '1.2.3', deps: {
               'bar': {'bad': 'bar'}
diff --git a/test/oauth2/utils.dart b/test/oauth2/utils.dart
index dab8c92..b486f56 100644
--- a/test/oauth2/utils.dart
+++ b/test/oauth2/utils.dart
@@ -35,8 +35,7 @@
   // sign-in with Google account.
   var response =
       await (http.Request('GET', redirectUrl)..followRedirects = false).send();
-  expect(response.headers['location'],
-      equals('https://pub.dartlang.org/authorized'));
+  expect(response.headers['location'], equals('https://pub.dev/authorized'));
 }
 
 void handleAccessTokenRequest(PackageServer server, String accessToken) {
diff --git a/test/pubspec_test.dart b/test/pubspec_test.dart
index a750229..c4e3112 100644
--- a/test/pubspec_test.dart
+++ b/test/pubspec_test.dart
@@ -379,7 +379,7 @@
               sha256: null,
             ).serializeForLockfile(containingDir: null),
             {
-              'url': 'https://pub.dartlang.org',
+              'url': 'https://pub.dev',
               'name': 'bar',
             });
       });
@@ -425,7 +425,7 @@
               sha256: null,
             ).serializeForLockfile(containingDir: null),
             {
-              'url': 'https://pub.dartlang.org',
+              'url': 'https://pub.dev',
               'name': 'foo',
             });
       });
diff --git a/test/token/add_token_test.dart b/test/token/add_token_test.dart
index e8d0dc4..3fa0d7f 100644
--- a/test/token/add_token_test.dart
+++ b/test/token/add_token_test.dart
@@ -151,18 +151,18 @@
     );
   });
 
-  test('with https://pub.dev rewrites to https://pub.dartlang.org', () async {
+  test('with https://pub.dartlang.org rewrites to https://pub.dev', () async {
     await runPub(
-      args: ['token', 'add', 'https://pub.dev'],
+      args: ['token', 'add', 'https://pub.dartlang.org'],
       input: ['auth-token'],
       silent: contains(
-          'Using https://pub.dartlang.org instead of https://pub.dev.'),
+          'Using https://pub.dev instead of https://pub.dartlang.org.'),
     );
 
     await d.tokensFile({
       'version': 1,
       'hosted': [
-        {'url': 'https://pub.dartlang.org', 'token': 'auth-token'}
+        {'url': 'https://pub.dev', 'token': 'auth-token'}
       ]
     }).validate();
   });