diff --git a/constraints.pro b/constraints.pro index 04266320187a..9baf9b0da392 100644 --- a/constraints.pro +++ b/constraints.pro @@ -11,33 +11,23 @@ constraints_min_version(1). % This rule will enforce that a workspace MUST depend on the same version of a dependency as the one used by the other workspaces gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType) :- % Iterates over all dependencies from all workspaces - workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType), + workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType), % Iterates over similarly-named dependencies from all workspaces (again) - workspace_has_dependency(OtherWorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType2), + workspace_has_dependency(OtherWorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType2), % Ignore peer dependencies - DependencyType \= 'peerDependencies', - DependencyType2 \= 'peerDependencies', + DependencyType \= 'peerDependencies', + DependencyType2 \= 'peerDependencies', % Ignore workspace:*: we use both `workspace:*` and real version such as `^28.0.0-alpha.8` to reference package in monorepo % TODO: in the future we should make it consistent and remove this ignore - DependencyRange \= 'workspace:*', - DependencyRange2 \= 'workspace:*', - % Get the workspace name - workspace_ident(WorkspaceCwd, WorkspaceIdent), - workspace_ident(OtherWorkspaceCwd, OtherWorkspaceIdent), - % @types/node in the root need to stay on ~12.12.0 - ( - (WorkspaceIdent = '@jest/monorepo'; OtherWorkspaceIdent = '@jest/monorepo') -> - DependencyIdent \= '@types/node' - ; - true - ), - % Allow enzyme example workspace use a older version react and react-dom, because enzyme don't support react 17 - ( - (WorkspaceIdent = 'example-enzyme'; OtherWorkspaceIdent = 'example-enzyme') -> - \+ member(DependencyIdent, ['react', 'react-dom']) - ; - true - ). + DependencyRange \= 'workspace:*', + DependencyRange2 \= 'workspace:*', + % A list of exception to same version rule + \+ member(DependencyIdent, [ + % Allow enzyme example workspace use a older version react and react-dom, because enzyme don't support react 17 + 'react', 'react-dom', + % @types/node in the root need to stay on ~12.12.0 + '@types/node' + ]). % Enforces that a dependency doesn't appear in both `dependencies` and `devDependencies` gen_enforced_dependency(WorkspaceCwd, DependencyIdent, null, 'devDependencies') :-