Skip to content

Commit 75cc017

Browse files
committed
improve naming
1 parent 4d77eb4 commit 75cc017

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

bricks/dart_frog_prod_server/hooks/lib/src/disable_workspace_resolution.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:io';
22
import 'package:dart_frog_prod_server_hooks/dart_frog_prod_server_hooks.dart';
33
import 'package:mason/mason.dart';
4-
import 'package:package_config/package_config.dart' as package_config;
4+
import 'package:package_config/package_config.dart';
55
import 'package:path/path.dart' as path;
66
import 'package:yaml/yaml.dart';
77
import 'package:yaml_edit/yaml_edit.dart';
@@ -10,7 +10,7 @@ import 'package:yaml_edit/yaml_edit.dart';
1010
/// https://github.com/dart-lang/pub/issues/4594
1111
VoidCallback disableWorkspaceResolution(
1212
HookContext context, {
13-
required package_config.PackageConfig packageConfig,
13+
required PackageConfig packageConfig,
1414
required PackageGraph packageGraph,
1515
required String projectDirectory,
1616
required String workspaceRoot,
@@ -73,7 +73,7 @@ VoidCallback overrideResolutionInPubspecOverrides(String projectDirectory) {
7373
/// Add overrides for all path dependencies to `pubspec_overrides.yaml`
7474
void overridePathDependenciesInPubspecOverrides({
7575
required String projectDirectory,
76-
required package_config.PackageConfig packageConfig,
76+
required PackageConfig packageConfig,
7777
required PackageGraph packageGraph,
7878
}) {
7979
final name = getPackageName(projectDirectory: projectDirectory);
@@ -98,7 +98,7 @@ void overridePathDependenciesInPubspecOverrides({
9898

9999
void writePathDependencyOverrides({
100100
required String projectDirectory,
101-
required Iterable<package_config.Package> pathDependencies,
101+
required Iterable<Package> pathDependencies,
102102
}) {
103103
final pubspecOverridesFile = File(
104104
path.join(projectDirectory, 'pubspec_overrides.yaml'),

bricks/dart_frog_prod_server/hooks/lib/src/package_graph/package_graph.dart

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ import 'package:path/path.dart' as path;
66

77
part 'package_graph.g.dart';
88

9+
/// {@template package_graph}
10+
/// A Dart object containing the deserialized contents of the package_graph.json
11+
/// {@endtemplate}
912
@JsonSerializable()
1013
class PackageGraph {
14+
/// {@macro package_graph}
1115
const PackageGraph({
1216
required this.roots,
1317
required this.packages,
1418
required this.configVersion,
1519
});
1620

21+
/// Load a [PackageGraph] from the provided [project] root.
1722
factory PackageGraph.load(String project) {
1823
final file = File(path.join(project, '.dart_tool', 'package_graph.json'));
1924
if (!file.existsSync()) throw Exception('${file.path} not found');
@@ -22,32 +27,48 @@ class PackageGraph {
2227
);
2328
}
2429

30+
/// Create a [PackageGraph] from a [Map].
2531
factory PackageGraph.fromJson(Map<String, dynamic> json) =>
2632
_$PackageGraphFromJson(json);
2733

34+
/// The root nodes of the package graph.
2835
final List<String> roots;
29-
final List<Package> packages;
36+
37+
/// A list of packages for the given package graph.
38+
final List<PackageGraphPackage> packages;
39+
40+
/// The config version of the package graph.
3041
final int configVersion;
3142
}
3243

44+
/// {@template package_graph_package}
45+
/// An individual package in a package graph.
46+
/// {@endtemplate}
3347
@JsonSerializable()
34-
class Package {
35-
const Package({
48+
class PackageGraphPackage {
49+
/// {@macro package_graph_package}
50+
const PackageGraphPackage({
3651
required this.name,
3752
required this.version,
3853
required this.dependencies,
3954
required this.devDependencies,
4055
});
4156

42-
factory Package.fromJson(Map<String, dynamic> json) =>
43-
_$PackageFromJson(json);
57+
/// Create a [PackageGraphPackage] from a [Map].
58+
factory PackageGraphPackage.fromJson(Map<String, dynamic> json) =>
59+
_$PackageGraphPackageFromJson(json);
4460

61+
/// The name of the package.
4562
final String name;
63+
64+
/// The version of the package.
4665
final String version;
4766

67+
/// The list of package names that this package depends on in production.
4868
@JsonKey(defaultValue: <String>[])
4969
final List<String> dependencies;
5070

71+
/// The list of package names that this package depends on in development.
5172
@JsonKey(defaultValue: <String>[])
5273
final List<String> devDependencies;
5374
}

bricks/dart_frog_prod_server/hooks/lib/src/package_graph/package_graph.g.dart

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bricks/dart_frog_prod_server/hooks/test/src/disable_workspace_resolution_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void main() {
4444
when(() => packageGraph.roots).thenReturn([packageName]);
4545
when(() => packageGraph.packages).thenReturn(
4646
[
47-
const Package(
47+
const PackageGraphPackage(
4848
name: packageName,
4949
dependencies: [],
5050
devDependencies: [],

0 commit comments

Comments
 (0)