Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
spydon committed Jan 9, 2025
1 parent e9f85bc commit d0eaa18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 36 deletions.
4 changes: 2 additions & 2 deletions packages/melos/lib/src/commands/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ mixin _BootstrapMixin on _CleanMixin {
return didUpdate;
}

bool _areDependenciesEqual(DependencyReference? a, DependencyReference? b) {
if (a is GitReference && b is GitReference) {
bool _areDependenciesEqual(Dependency? a, Dependency? b) {
if (a is GitDependency && b is GitDependency) {
return a == b && a.path == b.path;
} else {
return a == b;
Expand Down
59 changes: 25 additions & 34 deletions packages/melos/test/commands/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ Generating IntelliJ IDE files...

await createProject(
io.Directory('${temporaryGitRepository.absolute.path}/dependency1'),
const PubSpec(name: 'dependency'),
Pubspec('dependency'),
);

await createProject(
io.Directory('${temporaryGitRepository.absolute.path}/dependency2'),
const PubSpec(name: 'dependency'),
Pubspec('dependency'),
);

await io.Process.run(
Expand All @@ -178,7 +178,12 @@ Generating IntelliJ IDE files...
workingDirectory: temporaryGitRepository.absolute.path,
);

final workspaceDirectory = await createTemporaryWorkspace();
final workspaceDirectory = await createTemporaryWorkspace(
workspacePackages: [
'dependency1',
'dependency2',
],
);

final initialReference = {
'git': {
Expand All @@ -189,10 +194,13 @@ Generating IntelliJ IDE files...

final package = await createProject(
workspaceDirectory,
PubSpec(
name: 'git_references',
Pubspec(
'git_references',
dependencies: {
'dependency': GitReference.fromJson(initialReference),
'dependency': GitDependency(
Uri.parse(initialReference['git']!['url']!),
path: initialReference['git']!['path']!,
),
},
),
);
Expand Down Expand Up @@ -270,28 +278,32 @@ Generating IntelliJ IDE files...
test(
'resolves workspace packages with path dependency',
() async {
final workspaceDir = await createTemporaryWorkspace();
final workspaceDir = await createTemporaryWorkspace(
workspacePackages: ['a', 'b', 'c', 'd'],
);

final aDir = await createProject(
workspaceDir,
PubSpec(
name: 'a',
dependencies: {'b': HostedReference(VersionConstraint.any)},
Pubspec(
'a',
dependencies: {
'b': HostedDependency(version: VersionConstraint.any),
},
),
);
await createProject(
workspaceDir,
const PubSpec(name: 'b'),
Pubspec('b'),
);

await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'add_to_app_json.json'),
pubspecFromJsonFile(fileName: 'add_to_app_json.json'),
);

await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'plugin_json.json'),
pubspecFromJsonFile(fileName: 'plugin_json.json'),
);

final logger = TestLogger();
Expand Down Expand Up @@ -354,27 +366,6 @@ Generating IntelliJ IDE files...
io.Platform.isLinux ? const Timeout(Duration(seconds: 45)) : null,
);

test(
'bootstrap transitive dependencies',
() async => dependencyResolutionTest(
{
'a': [],
'b': ['a'],
'c': ['b'],
},
),
);

test(
'bootstrap cyclic dependencies',
() async => dependencyResolutionTest(
{
'a': ['b'],
'b': ['a'],
},
),
);

test('respects user dependency_overrides', () async {
final workspaceDir = await createTemporaryWorkspace(
workspacePackages: ['a'],
Expand Down

0 comments on commit d0eaa18

Please sign in to comment.