Remove command list-package-dirs (#3832)
diff --git a/lib/src/command/list_package_dirs.dart b/lib/src/command/list_package_dirs.dart deleted file mode 100644 index 4fa6e8a..0000000 --- a/lib/src/command/list_package_dirs.dart +++ /dev/null
@@ -1,79 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as p; - -import '../command.dart'; -import '../command_runner.dart'; -import '../io.dart'; -import '../log.dart' as log; -import '../package_name.dart'; -import '../utils.dart'; - -/// Handles the `list-package-dirs` pub command. -class ListPackageDirsCommand extends PubCommand { - @override - String get name => 'list-package-dirs'; - @override - String get description => 'Print local paths to dependencies.'; - @override - String get argumentsDescription => ''; - @override - bool get takesArguments => false; - @override - bool get hidden => true; - - ListPackageDirsCommand() { - argParser.addOption( - 'format', - help: 'How output should be displayed.', - allowed: ['json'], - ); - argParser.addOption( - 'directory', - abbr: 'C', - help: 'Run this in the directory <dir>.', - valueHelp: 'dir', - ); - } - - @override - Future<void> runProtected() async { - log.json.enabled = true; - - if (!fileExists(entrypoint.lockFilePath)) { - dataError( - 'Package "myapp" has no lockfile. Please run "$topLevelProgram pub get" first.', - ); - } - - var output = {}; - - // Include the local paths to all locked packages. - var packages = mapMap( - entrypoint.lockFile.packages, - value: (String name, PackageId package) { - var packageDir = cache.getDirectory(package); - // Normalize paths and make them absolute for backwards compatibility - // with the protocol used by the analyzer. - return p.normalize(p.absolute(p.join(packageDir, 'lib'))); - }, - ); - - // Include the self link. - packages[entrypoint.root.name] = - p.normalize(p.absolute(entrypoint.root.path('lib'))); - - output['packages'] = packages; - - // Include the file(s) which when modified will affect the results. For pub, - // that's just the pubspec and lockfile. - output['input_files'] = [ - p.normalize(p.absolute(entrypoint.lockFilePath)), - p.normalize(p.absolute(entrypoint.pubspecPath)) - ]; - - log.json.message(output); - } -}
diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart index e45e057..ebaf63b 100644 --- a/lib/src/command_runner.dart +++ b/lib/src/command_runner.dart
@@ -18,7 +18,6 @@ import 'command/get.dart'; import 'command/global.dart'; import 'command/lish.dart'; -import 'command/list_package_dirs.dart'; import 'command/login.dart'; import 'command/logout.dart'; import 'command/outdated.dart'; @@ -146,7 +145,6 @@ addCommand(DowngradeCommand()); addCommand(GlobalCommand()); addCommand(GetCommand()); - addCommand(ListPackageDirsCommand()); addCommand(LishCommand()); addCommand(OutdatedCommand()); addCommand(RemoveCommand());
diff --git a/test/list_package_dirs/ignores_updated_pubspec_test.dart b/test/list_package_dirs/ignores_updated_pubspec_test.dart deleted file mode 100644 index 34ca2ac..0000000 --- a/test/list_package_dirs/ignores_updated_pubspec_test.dart +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/io.dart'; - -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test("uses what's in the lockfile regardless of the pubspec", () async { - await d - .dir('foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create(); - - await d.dir(appPath, [ - d.appPubspec( - dependencies: { - 'foo': {'path': path.join(d.sandbox, 'foo')} - }, - ) - ]).create(); - - await pubGet(); - // Add a dependency on "bar" and remove "foo", but don't run "pub get". - - await d.dir(appPath, [ - d.appPubspec(dependencies: {'bar': 'any'}) - ]).create(); - // Note: Using canonicalize here because pub gets the path to the - // entrypoint package from the working directory, which has had symlinks - // resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we - // need to accommodate that. - - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'packages': { - 'foo': path.join(d.sandbox, 'foo', 'lib'), - 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib')) - }, - 'input_files': [ - canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')), - canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml')) - ] - }, - ); - }); -}
diff --git a/test/list_package_dirs/includes_dev_dependencies_test.dart b/test/list_package_dirs/includes_dev_dependencies_test.dart deleted file mode 100644 index fbb99ff..0000000 --- a/test/list_package_dirs/includes_dev_dependencies_test.dart +++ /dev/null
@@ -1,47 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/io.dart'; - -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test('includes dev dependencies in the results', () async { - await d - .dir('foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create(); - - await d.dir(appPath, [ - d.pubspec({ - 'name': 'myapp', - 'dev_dependencies': { - 'foo': {'path': path.join(d.sandbox, 'foo')} - } - }) - ]).create(); - - await pubGet(); - - // Note: Using canonicalize here because pub gets the path to the - // entrypoint package from the working directory, which has had symlinks - // resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we - // need to accommodate that. - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'packages': { - 'foo': path.join(d.sandbox, 'foo', 'lib'), - 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib')) - }, - 'input_files': [ - canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')), - canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml')) - ] - }, - ); - }); -}
diff --git a/test/list_package_dirs/lists_dependency_directories_test.dart b/test/list_package_dirs/lists_dependency_directories_test.dart deleted file mode 100644 index a9731a5..0000000 --- a/test/list_package_dirs/lists_dependency_directories_test.dart +++ /dev/null
@@ -1,58 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/io.dart'; - -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test('prints the local paths to all packages in the lockfile', () async { - final server = await servePackages() - ..serve('bar', '1.0.0'); - - await d - .dir('foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create(); - - await d.dir(appPath, [ - d.appPubspec( - dependencies: { - 'foo': {'path': path.join(d.sandbox, 'foo')}, - 'bar': 'any' - }, - ) - ]).create(); - - await pubGet(); - - // Note: Using canonicalize here because pub gets the path to the - // entrypoint package from the working directory, which has had symlinks - // resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we - // need to accommodate that. - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'packages': { - 'foo': path.join(d.sandbox, 'foo', 'lib'), - 'bar': path.join( - d.sandbox, - cachePath, - 'hosted', - 'localhost%58${server.port}', - 'bar-1.0.0', - 'lib', - ), - 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib')) - }, - 'input_files': [ - canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')), - canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml')) - ] - }, - ); - }); -}
diff --git a/test/list_package_dirs/lockfile_error_test.dart b/test/list_package_dirs/lockfile_error_test.dart deleted file mode 100644 index 752f3f5..0000000 --- a/test/list_package_dirs/lockfile_error_test.dart +++ /dev/null
@@ -1,29 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/exit_codes.dart' as exit_codes; -import 'package:pub/src/io.dart'; -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test('reports the lockfile path when there is an error in it', () async { - await d.dir( - appPath, - [d.appPubspec(), d.file('pubspec.lock', 'some bad yaml')], - ).create(); - - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'error': contains('Expected a YAML mapping.'), - 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')) - }, - exitCode: exit_codes.DATA, - ); - }); -}
diff --git a/test/list_package_dirs/missing_pubspec_test.dart b/test/list_package_dirs/missing_pubspec_test.dart deleted file mode 100644 index 07cecaf..0000000 --- a/test/list_package_dirs/missing_pubspec_test.dart +++ /dev/null
@@ -1,28 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/exit_codes.dart' as exit_codes; -import 'package:pub/src/io.dart'; -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - // This is a regression test for #20065. - test('reports a missing pubspec error using JSON', () async { - await d.dir(appPath).create(); - - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'error': 'Could not find a file named "pubspec.yaml" in ' - '"${canonicalize(path.join(d.sandbox, appPath))}".', - 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml')) - }, - exitCode: exit_codes.NO_INPUT, - ); - }); -}
diff --git a/test/list_package_dirs/no_lockfile_test.dart b/test/list_package_dirs/no_lockfile_test.dart deleted file mode 100644 index 1593e2f..0000000 --- a/test/list_package_dirs/no_lockfile_test.dart +++ /dev/null
@@ -1,25 +0,0 @@ -// Copyright (c) 2013, 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 'package:pub/src/exit_codes.dart' as exit_codes; - -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test('with no lockfile, exits with error', () async { - await d.dir(appPath, [d.appPubspec()]).create(); - - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'error': - 'Package "myapp" has no lockfile. Please run "dart pub get" first.' - }, - exitCode: exit_codes.DATA, - ); - }); -}
diff --git a/test/list_package_dirs/pubspec_error_test.dart b/test/list_package_dirs/pubspec_error_test.dart deleted file mode 100644 index 458bafe..0000000 --- a/test/list_package_dirs/pubspec_error_test.dart +++ /dev/null
@@ -1,26 +0,0 @@ -// Copyright (c) 2013, 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 'package:path/path.dart' as path; -import 'package:pub/src/exit_codes.dart' as exit_codes; -import 'package:pub/src/io.dart'; -import 'package:test/test.dart'; - -import '../descriptor.dart' as d; -import '../test_pub.dart'; - -void main() { - test('reports the pubspec path when there is an error in it', () async { - await d.dir(appPath, [d.file('pubspec.yaml', 'some bad yaml')]).create(); - - await runPub( - args: ['list-package-dirs', '--format=json'], - outputJson: { - 'error': contains('Error on line 1'), - 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml')) - }, - exitCode: exit_codes.DATA, - ); - }); -}