diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3186a95..3c302f3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml
@@ -25,7 +25,7 @@ sdk: [dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: ${{ matrix.sdk }} - id: install @@ -53,7 +53,7 @@ shard: [0, 1, 2, 3, 4, 5, 6] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: ${{ matrix.sdk }} - name: Install dependencies
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart index 2d4eae3..e0db64f 100644 --- a/lib/src/global_packages.dart +++ b/lib/src/global_packages.dart
@@ -506,7 +506,12 @@ try { result = await log.spinner( 'Resolving dependencies', - () => resolveVersions(SolveType.get, cache, root), + () => resolveVersions( + SolveType.get, + cache, + root, + lockFile: entrypoint.lockFile, + ), ); } on SolveFailure catch (e) { log.error(e.message);
diff --git a/lib/src/ignore.dart b/lib/src/ignore.dart index 0a843be..e28205e 100644 --- a/lib/src/ignore.dart +++ b/lib/src/ignore.dart
@@ -363,7 +363,7 @@ }) sync* { ArgumentError.checkNotNull(patterns, 'patterns'); ArgumentError.checkNotNull(ignoreCase, 'ignoreCase'); - onInvalidPattern ??= (_, __) {}; + onInvalidPattern ??= (_, _) {}; final parsedPatterns = patterns .expand((s) => s.split(_lineBreakPattern))
diff --git a/lib/src/source/path.dart b/lib/src/source/path.dart index 0125d85..46b6981 100644 --- a/lib/src/source/path.dart +++ b/lib/src/source/path.dart
@@ -79,9 +79,11 @@ return PackageRef( name, PathDescription( - p.normalize( - p.join(p.absolute(containingDescription.path), description), - ), + isRelative + ? p.normalize( + p.join(p.absolute(containingDescription.path), description), + ) + : description, isRelative, ), );
diff --git a/pubspec.lock b/pubspec.lock index ac0dd37..6df6ff8 100644 --- a/pubspec.lock +++ b/pubspec.lock
@@ -26,10 +26,10 @@ dependency: "direct main" description: name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" async: dependency: "direct main" description: @@ -98,10 +98,10 @@ dependency: "direct dev" description: name: dart_flutter_team_lints - sha256: "241f050cb4d908caffdcc5d4407e1c4e0b1dd449294ef7b6ceb4a9d8bc77dd96" + sha256: "4c8f38142598339cd28c0b48a66b6b04434ee0499b6e40baf7c62c76daa1fcad" url: "https://pub.dev" source: hosted - version: "3.3.0" + version: "3.5.1" file: dependency: transitive description: @@ -258,10 +258,10 @@ dependency: "direct main" description: name: pub_semver - sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" shelf: dependency: "direct main" description:
diff --git a/pubspec.yaml b/pubspec.yaml index 91acead..1f40063 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -5,7 +5,7 @@ dependencies: analyzer: 7.1.0 - args: ^2.6.0 + args: ^2.7.0 async: ^2.11.0 cli_util: ^0.4.1 collection: ^1.18.0 @@ -19,7 +19,7 @@ meta: ^1.16.0 path: ^1.9.1 pool: ^1.5.1 - pub_semver: ^2.1.4 + pub_semver: ^2.2.0 shelf: ^1.4.1 source_span: ^1.10.1 stack_trace: ^1.11.1 @@ -30,7 +30,7 @@ dev_dependencies: checks: ^0.3.0 - dart_flutter_team_lints: ^3.2.1 + dart_flutter_team_lints: ^3.5.1 shelf_test_handler: ^2.0.2 test: ^1.25.14 test_descriptor: ^2.0.2
diff --git a/test/add/common/add_test.dart b/test/add/common/add_test.dart index 15e8be6..8457d86 100644 --- a/test/add/common/add_test.dart +++ b/test/add/common/add_test.dart
@@ -2,11 +2,13 @@ // 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:convert'; import 'dart:io' show File; import 'package:path/path.dart' as p; import 'package:pub/src/exit_codes.dart' as exit_codes; import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart'; import 'package:yaml/yaml.dart'; import '../../descriptor.dart' as d; @@ -1182,4 +1184,26 @@ server.serve('foo', '2.0.0'); await pubAdd(args: ['foo', '--offline']); }); + + test('Uses given path for absolute paths', () async { + await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create(); + + await d.appDir(dependencies: {}).create(); + + // Explicitly add using a forward slash in absolute path. + // This should be preserved in the pubspec.yaml, even on windows. + await pubAdd( + args: [ + 'foo:${json.encode({'path': '$sandbox/foo'})}', + ], + ); + + await d + .appDir( + dependencies: { + 'foo': {'path': '$sandbox/foo'}, + }, + ) + .validate(); + }); }
diff --git a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart index caa2b02..9f7e511 100644 --- a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart +++ b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
@@ -2,6 +2,8 @@ // 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:io'; + import 'package:path/path.dart' as p; import 'package:pub/src/exit_codes.dart'; import 'package:pub/src/io.dart'; @@ -89,6 +91,8 @@ await runPub(args: ['global', 'run', 'foo'], output: 'original'); + // Serve an updated version of bar, to validate that the recompilation + // validates content hashes. server.serve( 'bar', '1.0.0', @@ -97,6 +101,11 @@ ], ); + // Delete the existing download of bar to trigger a redownload. + Directory( + p.join(d.sandbox, d.hostedCachePath(port: server.port), 'bar-1.0.0'), + ).deleteSync(recursive: true); + await runPub( args: ['global', 'run', 'foo'], environment: { @@ -214,7 +223,7 @@ await d.dir('dart', [ d.dir('packages', [ d.dir('bar', [ - // Doesn't fulfill constraint, but doesn't satisfy pubspec.lock. + // Doesn't fulfill constraint. d.libPubspec('bar', '2.0.0', deps: {}), ]), ]), @@ -227,7 +236,8 @@ }, error: allOf( contains( - 'Because every version of foo depends on bar ^1.0.0 from sdk', + 'So, because pub global activate depends on foo 1.0.0 ' + 'which depends on bar ^1.0.0 from sdk', ), contains('The package `foo` as currently activated cannot resolve.'), contains('Try reactivating the package'),
diff --git a/test/global/run/runs_path_script_test.dart b/test/global/run/runs_path_script_test.dart index fdd6fe8..8058794 100644 --- a/test/global/run/runs_path_script_test.dart +++ b/test/global/run/runs_path_script_test.dart
@@ -2,6 +2,7 @@ // 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 'package:test/test.dart'; import '../../descriptor.dart' as d; @@ -20,4 +21,24 @@ expect(pub.stdout, emitsThrough('ok')); await pub.shouldExit(); }); + + // Regression test of https://github.com/dart-lang/pub/issues/4536 + test('respects existing lockfile', () async { + final server = await servePackages(); + server.serve('dep', '1.0.0'); + + await d.dir('foo', [ + d.libPubspec('foo', '1.0.0', deps: {'dep': '^1.0.0'}), + d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), + ]).create(); + + await pubGet(workingDirectory: p.join(d.sandbox, 'foo')); + await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); + + server.serve('dep', '1.0.1'); + + final pub = await pubRun(global: true, args: ['foo']); + expect(pub.stdout, emitsThrough('ok')); + await pub.shouldExit(); + }); }
diff --git a/test/ignore_test.dart b/test/ignore_test.dart index 406525f..1003612 100644 --- a/test/ignore_test.dart +++ b/test/ignore_test.dart
@@ -44,7 +44,7 @@ ? null : Ignore( c.patterns[dir]!, - onInvalidPattern: (_, __) => hasWarning = true, + onInvalidPattern: (_, _) => hasWarning = true, ignoreCase: ignoreCase, );