Skip to content

Commit

Permalink
Update to newest main
Browse files Browse the repository at this point in the history
  • Loading branch information
spydon committed Jan 9, 2025
1 parent d0eaa18 commit 2544d8d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 78 deletions.
22 changes: 13 additions & 9 deletions packages/melos/lib/src/common/extensions/dependency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,26 @@ extension HostedDependencyExtension on HostedDependency {
return inlineVersion
? version.toString()
: {
'version': version.toString(),
if (hosted != null)
'hosted': {
'name': hosted!.declaredName,
'url': hosted!.url?.toString(),
},
'hosted': {
'version': version.toString(),
if (hosted != null)
'hosted': {
'name': hosted!.declaredName,
'url': hosted!.url?.toString(),
},
},
};
}
}

extension GitDependencyExtension on GitDependency {
Map<String, dynamic> toJson() {
return {
'url': url.toString(),
if (ref != null) 'ref': ref,
if (path != null) 'path': path,
'git': {
'url': url.toString(),
if (ref != null) 'ref': ref,
if (path != null) 'path': path,
},
};
}
}
Expand Down
35 changes: 10 additions & 25 deletions packages/melos/test/commands/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ Generating IntelliJ IDE files...

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

Expand All @@ -199,7 +198,7 @@ Generating IntelliJ IDE files...
dependencies: {
'dependency': GitDependency(
Uri.parse(initialReference['git']!['url']!),
path: initialReference['git']!['path']!,
path: initialReference['git']!['path'],
),
},
),
Expand Down Expand Up @@ -228,7 +227,7 @@ Generating IntelliJ IDE files...

await runMelosBootstrap(melosBeforeChangingPath, logger);

final packageConfig = packageConfigForPackageAt(package);
final packageConfig = packageConfigForPackageAt(workspaceDirectory);
final dependencyPackage = packageConfig.packages.singleWhere(
(package) => package.name == 'dependency',
);
Expand Down Expand Up @@ -265,7 +264,8 @@ Generating IntelliJ IDE files...

await runMelosBootstrap(melosAfterChangingPath, logger);

final alteredPackageConfig = packageConfigForPackageAt(package);
final alteredPackageConfig =
packageConfigForPackageAt(workspaceDirectory);
final alteredDependencyPackage = alteredPackageConfig.packages
.singleWhere((package) => package.name == 'dependency');

Expand Down Expand Up @@ -325,23 +325,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "flutter pub get" in workspace packages...''',
'''
✓ a
└> packages/a
''',
'''
✓ b
└> packages/b
''',
'''
✓ c
└> packages/c
''',
'''
✓ d
└> packages/d
''',
Running "flutter pub get" in workspace...''',
'''
> SUCCESS
Expand All @@ -355,11 +339,11 @@ Generating IntelliJ IDE files...
),
);

final aConfig = packageConfigForPackageAt(aDir);
final aConfig = packageConfigForPackageAt(workspaceDir);

expect(
aConfig.packages.firstWhere((p) => p.name == 'b').rootUri,
'../../b',
'../packages/b',
);
},
timeout:
Expand Down Expand Up @@ -410,7 +394,8 @@ Generating IntelliJ IDE files...

test('bootstrap flutter example packages', () async {
final workspaceDir = await createTemporaryWorkspace(
workspacePackages: ['a', 'a/example'],
workspacePackages: ['a'],
withExamples: true,
);

await createProject(
Expand Down
42 changes: 1 addition & 41 deletions packages/melos/test/pubspec_extension.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:melos/src/common/extensions/dependency.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
Expand Down Expand Up @@ -100,44 +101,3 @@ extension on Screenshot {
};
}
}

extension DependencyExtension on Dependency {
Map<String, dynamic> toJson() {
if (this is SdkDependency) {
final sdkDep = this as SdkDependency;
return {
'sdk': sdkDep.sdk,
'version': sdkDep.version.toString(),
};
} else if (this is GitDependency) {
final gitDep = this as GitDependency;
return {
'url': gitDep.url.toString(),
'ref': gitDep.ref,
'path': gitDep.path,
};
} else if (this is PathDependency) {
final pathDep = this as PathDependency;
return {
'path': pathDep.path,
};
} else if (this is HostedDependency) {
final hostedDep = this as HostedDependency;
return {
'version': hostedDep.version.toString(),
if (hostedDep.hosted != null) 'hosted': hostedDep.hosted?.toJson(),
};
} else {
throw UnsupportedError('Unknown Dependency type');
}
}
}

extension HostedDetailsExtension on HostedDetails {
Map<String, dynamic> toJson() {
return {
'name': declaredName,
'url': url?.toString(),
};
}
}
4 changes: 2 additions & 2 deletions packages/melos/test/test_assets/add_to_app_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "An example add to app module.",
"version": "1.0.0+1",
"environment": {
"sdk": ">=3.0.0 <4.0.0",
"flutter": ">=2.0.0 <=3.0.0"
"sdk": ">=3.6.0 <4.0.0",
"flutter": ">=3.27.1 <=4.0.0"
},
"dependencies": {
"flutter": {
Expand Down
2 changes: 1 addition & 1 deletion packages/melos/test/test_assets/plugin_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "An example plugin",
"version": "0.0.1",
"environment": {
"sdk": ">=3.0.0 <4.0.0"
"sdk": ">=3.6.0 <4.0.0"
},
"flutter": {
"plugin": {
Expand Down

0 comments on commit 2544d8d

Please sign in to comment.