diff --git a/CHANGELOG.md b/CHANGELOG.md index d7db0cc5667..e478d0b21eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,15 +85,31 @@ Updated the Linter to `0.1.123`, which includes: #### Pub +* **Breaking**: The Dart SDK constraint is now **required** in `pubspec.yaml`. + + You now have to include a section like: + + ```yaml + environment: + sdk: '>=2.10.0 <3.0.0' + ``` + + See [#44072][]. * The top level `pub` executable has been deprecated. Use `dart pub` instead. -* New commands `dart pub add` and `dart pub remove` that adds and removes new - dependencies to your `pubspec.yaml`. -* New option `dart pub outdated mode=null-safety` that will analyze your + See [dart tool][]. +* New command `dart pub add` that adds new dependencies to your `pubspec.yaml`. + + And a corresponding `dart pub remove` that removes dependencies. +* New option `dart pub outdated --mode=null-safety` that will analyze your dependencies for null-safety. * `dart pub publish` will now check your pubspec keys for likely typos. -* `dart pub get` will print a warning if the resolution is in mixed-mode requiring - the code to run with `dart --no-sound-null-safety`. * New command `dart pub login` that logs in to pub.dev. +* The `--server` option to `dart pub publish` and `dart pub uploader` have been + deprecated. Use `publish_to` in your `pubspec.yaml` or set the + `$PUB_HOSTED_URL` environment variable. + +[#44072]: https://github.com/dart-lang/sdk/issues/44072 +[dart tool]: https://dart.dev/tools/dart-tool ## 2.10.3 - 2020-10-29 diff --git a/DEPS b/DEPS index 57a2c1630c7..1e6598a51dd 100644 --- a/DEPS +++ b/DEPS @@ -132,7 +132,7 @@ vars = { "ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93", "pool_rev": "eedbd5fde84f9a1a8da643b475305a81841da599", "protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760", - "pub_rev": "900e796a37fd9f68de9dd183cf4798fe5f055eaa", + "pub_rev": "4ca4767a6c00b2dadecdaee9a4866dae40ef25f2", "pub_semver_tag": "v1.4.4", "resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7", "root_certificates_rev": "7e5ec82c99677a2e5b95ce296c4d68b0d3378ed8", diff --git a/pkg/dartdev/lib/src/commands/pub.dart b/pkg/dartdev/lib/src/commands/pub.dart new file mode 100644 index 00000000000..d77dce64e9b --- /dev/null +++ b/pkg/dartdev/lib/src/commands/pub.dart @@ -0,0 +1,89 @@ +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:async'; + +import 'package:args/args.dart'; + +import '../core.dart'; +import '../experiments.dart'; +import '../sdk.dart'; +import '../vm_interop_handler.dart'; + +class PubCommand extends DartdevCommand { + static const String cmdName = 'pub'; + + PubCommand() : super(cmdName, 'Work with packages.'); + + // TODO(jwren) as soon as pub commands are are implemented directly in + // dartdev, remove this static list. + /// A list of all subcommands, used only for the implementation of + /// [usagePath], see below. + static List pubSubcommands = [ + 'cache', + 'deps', + 'downgrade', + 'get', + 'global', + 'logout', + 'outdated', + 'publish', + 'run', + 'upgrade', + 'uploader', + 'version', + ]; + + @override + ArgParser createArgParser() => ArgParser.allowAnything(); + + @override + void printUsage() { + // Override [printUsage] for invocations of 'dart help pub' which won't + // execute [run] below. Without this, the 'dart help pub' reports the + // command pub with no commands or flags. + if (!Sdk.checkArtifactExists(sdk.pubSnapshot)) { + return; + } + final command = sdk.pubSnapshot; + final args = ['help']; + + log.trace('$command ${args.first}'); + + // Call 'pub help' + VmInteropHandler.run(command, args); + } + + @override + FutureOr run() async { + if (!Sdk.checkArtifactExists(sdk.pubSnapshot)) { + return 255; + } + final command = sdk.pubSnapshot; + var args = argResults.arguments; + + // Pass any --enable-experiment options along. + if (args.isNotEmpty && wereExperimentsSpecified) { + List experimentIds = specifiedExperiments; + + if (args.first == 'run') { + args = [ + ...args.sublist(0, 1), + '--$experimentFlagName=${experimentIds.join(',')}', + ...args.sublist(1), + ]; + } else if (args.length > 1 && args[0] == 'global' && args[0] == 'run') { + args = [ + ...args.sublist(0, 2), + '--$experimentFlagName=${experimentIds.join(',')}', + ...args.sublist(2), + ]; + } + } + + log.trace('$command ${args.join(' ')}'); + VmInteropHandler.run(command, args); + return 0; + } +} diff --git a/pkg/dartdev/test/commands/pub_test.dart b/pkg/dartdev/test/commands/pub_test.dart index d8a4a040ce1..82f00d03e62 100644 --- a/pkg/dartdev/test/commands/pub_test.dart +++ b/pkg/dartdev/test/commands/pub_test.dart @@ -86,8 +86,9 @@ void pub() { expect(result.stdout, isEmpty); expect( result.stderr, - contains('bin/main.dart:1:18: Error: This requires the \'non-nullable\'' - ' language feature to be enabled.\n')); + contains('bin/main.dart:1:18: Error: This requires the null safety ' + 'language feature, which requires language version of 2.12 or ' + 'higher.\n')); }); test('failure', () { diff --git a/pkg/dartdev/test/commands/test_test.dart b/pkg/dartdev/test/commands/test_test.dart index 93aa6b1c19c..cf7aea942d2 100644 --- a/pkg/dartdev/test/commands/test_test.dart +++ b/pkg/dartdev/test/commands/test_test.dart @@ -69,7 +69,11 @@ void defineTest() { test('no package:test dependency', () { p = project(mainSrc: 'int get foo => 1;\n'); - p.file('pubspec.yaml', 'name: ${p.name}\n'); + p.file('pubspec.yaml', ''' +name: ${p.name} +environment: + sdk: '>=2.10.0 <3.0.0' +'''); var result = p.runSync('pub', ['get']); expect(result.exitCode, 0); diff --git a/pkg/dartdev/test/utils.dart b/pkg/dartdev/test/utils.dart index 4d6709923e9..bbc46df475f 100644 --- a/pkg/dartdev/test/utils.dart +++ b/pkg/dartdev/test/utils.dart @@ -42,7 +42,14 @@ class TestProject { this.logAnalytics = false, }) { dir = Directory.systemTemp.createTempSync('dartdev'); - file('pubspec.yaml', 'name: $name\ndev_dependencies:\n test: any\n'); + file('pubspec.yaml', ''' +name: $name +environment: + sdk: '>=2.10.0 <3.0.0' + +dev_dependencies: + test: any +'''); if (analysisOptions != null) { file('analysis_options.yaml', analysisOptions); } diff --git a/tools/bots/pub_integration_test.py b/tools/bots/pub_integration_test.py index 6d71e1e1aea..6d6ef43c378 100755 --- a/tools/bots/pub_integration_test.py +++ b/tools/bots/pub_integration_test.py @@ -11,6 +11,8 @@ import shutil import tempfile PUBSPEC = """name: pub_integration_test +environment: + sdk: '>=2.10.0 <=3.0.0' dependencies: shelf: test: