From 88b961107d6176f8413e874a56cf96faa0298163 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 2 Dec 2022 20:02:42 -0330 Subject: [PATCH] Add peer dependencies between packages Packages now list `peerDependencies` to represent the expectation that a specific package version is setup with the controller messenger. This ensures that projects using these packages get a warning upon install if they are using incompatible package versions. This lets us safely make breaking changes to controller messenger events and actions. The constraints needed adjustment to allow the same dependency to be declared both in `dependencies` and `peerDependencies`. The constraint now ensures packages aren't listed both in `dependencies` and `devDependencies` instead. --- constraints.pro | 9 ++++----- packages/assets-controllers/package.json | 3 +++ packages/gas-fee-controller/package.json | 3 +++ packages/permission-controller/package.json | 3 +++ yarn.lock | 6 ++++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/constraints.pro b/constraints.pro index a07ab0dc84..ef2a0370a8 100644 --- a/constraints.pro +++ b/constraints.pro @@ -224,14 +224,13 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, OtherDependencyRange, Dep npm_version_range_out_of_sync(DependencyRange, OtherDependencyRange). % If a dependency is listed under "dependencies", it should not be listed under -% any other "*dependencies" lists. We match on the same dependency range so that -% if a dependency is listed twice in the same manifest, their versions are -% synchronized and then this constraint will apply and remove the "right" -% duplicate. +% "devDependencies". We match on the same dependency range so that if a +% dependency is listed under both lists, their versions are synchronized and +% then this constraint will apply and remove the "right" duplicate. gen_enforced_dependency(WorkspaceCwd, DependencyIdent, null, DependencyType) :- workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, 'dependencies'), workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType), - DependencyType \= 'dependencies'. + DependencyType == 'devDependencies'. % eth-query has an unlisted dependency on babel-runtime, so that package needs % to be present if eth-query is present. diff --git a/packages/assets-controllers/package.json b/packages/assets-controllers/package.json index 55cfbc671a..b23465236f 100644 --- a/packages/assets-controllers/package.json +++ b/packages/assets-controllers/package.json @@ -65,6 +65,9 @@ "typedoc-plugin-missing-exports": "^0.22.6", "typescript": "~4.6.3" }, + "peerDependencies": { + "@metamask/network-controller": "workspace:^" + }, "engines": { "node": ">=14.0.0" }, diff --git a/packages/gas-fee-controller/package.json b/packages/gas-fee-controller/package.json index ed2a998d7b..5adfc15ce1 100644 --- a/packages/gas-fee-controller/package.json +++ b/packages/gas-fee-controller/package.json @@ -54,6 +54,9 @@ "typedoc-plugin-missing-exports": "^0.22.6", "typescript": "~4.6.3" }, + "peerDependencies": { + "@metamask/network-controller": "workspace:^" + }, "engines": { "node": ">=14.0.0" }, diff --git a/packages/permission-controller/package.json b/packages/permission-controller/package.json index f7197c718d..72368972d7 100644 --- a/packages/permission-controller/package.json +++ b/packages/permission-controller/package.json @@ -50,6 +50,9 @@ "typedoc-plugin-missing-exports": "^0.22.6", "typescript": "~4.6.3" }, + "peerDependencies": { + "@metamask/approval-controller": "workspace:^" + }, "engines": { "node": ">=14.0.0" }, diff --git a/yarn.lock b/yarn.lock index 500519c790..ac121c4ecc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1434,6 +1434,8 @@ __metadata: typedoc-plugin-missing-exports: ^0.22.6 typescript: ~4.6.3 uuid: ^8.3.2 + peerDependencies: + "@metamask/network-controller": "workspace:^" languageName: unknown linkType: soft @@ -1707,6 +1709,8 @@ __metadata: typedoc-plugin-missing-exports: ^0.22.6 typescript: ~4.6.3 uuid: ^8.3.2 + peerDependencies: + "@metamask/network-controller": "workspace:^" languageName: unknown linkType: soft @@ -1844,6 +1848,8 @@ __metadata: typedoc: ^0.22.15 typedoc-plugin-missing-exports: ^0.22.6 typescript: ~4.6.3 + peerDependencies: + "@metamask/approval-controller": "workspace:^" languageName: unknown linkType: soft