forked from yarnpkg/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstraints.pro
33 lines (27 loc) · 1.75 KB
/
constraints.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
constraints_min_version(1).
% This file is written in Prolog
% It contains rules that the project must respect.
% In order to see them in action, run `berry constraints detail`
% This rule will prevent two of our workspaces from depending on different versions of a same dependency
gen_invalid_dependency(WorkspaceCwd, DependencyIdent, 'This dependency conflicts with another one from another workspace') :-
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange),
workspace_has_dependency(_, DependencyIdent, DependencyRange2),
DependencyRange \= DependencyRange2,
\+(gen_enforced_dependency_range(WorkspaceCwd, DependencyIdent, _)).
% This rule will prevent workspaces from depending on non-workspace versions of available workspaces
gen_enforced_dependency_range(WorkspaceCwd, DependencyIdent, 'workspace:*') :-
workspace_ident(_, DependencyIdent),
workspace_has_dependency(WorkspaceCwd, DependencyIdent, _).
% The following rules describes which workspaces are allowed to depend on respectively "webpack" and "typescript"
workspace_allowed_dependency(WorkspaceCwd, 'webpack') :-
workspace_ident(WorkspaceCwd, '@berry/builder').
workspace_allowed_dependency(WorkspaceCwd, 'typescript'):-
workspace_ident(WorkspaceCwd, '@berry/builder').
% This rule will prevent workspaces from depending any blacklisted package
gen_enforced_dependency_range(WorkspaceCwd, DependencyIdent, null) :-
workspace_has_dependency(WorkspaceCwd, DependencyIdent, _),
workspace_allowed_dependency(_, DependencyIdent),
\+(workspace_allowed_dependency(WorkspaceIdent, DependencyIdent)).
% This rule will prevent all workspaces from depending on tslib
gen_enforced_dependency_range(WorkspaceCwd, 'tslib', null) :-
workspace_has_dependency(WorkspaceCwd, 'tslib', _).