forked from bangle-io/bangle-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraints.pro
49 lines (41 loc) · 2.58 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Yarn Constraints https://yarnpkg.com/features/constraints
% check with "yarn constraints" (fix w/ "yarn constraints --fix")
% This rule will enforce that all packages must have a "AGPL-3.0-or-later" license field
gen_enforced_field(WorkspaceCwd, 'license', 'AGPL-3.0-or-later').
% Enforces the repository field for all public workspaces while removing it from private workspaces
gen_enforced_field(WorkspaceCwd, 'repository.type', 'git') :-
\+ workspace_field(WorkspaceCwd, 'private', true).
gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/bangle-io/bangle-io.git') :-
\+ workspace_field(WorkspaceCwd, 'private', true).
gen_enforced_field(WorkspaceCwd, 'repository.directory', WorkspaceCwd) :-
\+ workspace_field(WorkspaceCwd, 'private', true).
gen_enforced_field(WorkspaceCwd, 'repository', null) :-
workspace_field(WorkspaceCwd, 'private', true).
% Enforces that a dependency doesn't appear in both `dependencies` and `devDependencies`
gen_enforced_dependency(WorkspaceCwd, DependencyIdent, null, 'devDependencies') :-
workspace_has_dependency(WorkspaceCwd, DependencyIdent, _, 'devDependencies'),
workspace_has_dependency(WorkspaceCwd, DependencyIdent, _, 'dependencies').
% 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),
% Iterates over similarly-named dependencies from all workspaces (again)
workspace_has_dependency(OtherWorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType2),
% Ignore peer dependencies
DependencyType \= 'peerDependencies',
DependencyType2 \= 'peerDependencies',
% Ignore devDependencies on other workspaces
(
(DependencyType = 'devDependencies'; DependencyType2 = 'devDependencies') ->
\+ workspace_ident(DependencyCwd, DependencyIdent)
;
true
).
% This rule enforces that all packages that depend on TypeScript must also depend on tslib
gen_enforced_dependency(WorkspaceCwd, 'tslib', 'range', 'dependencies') :-
% Iterates over all TypeScript dependencies from all workspaces
workspace_has_dependency(WorkspaceCwd, 'typescript', _, DependencyType),
% Ignores the case when TypeScript is a peer dependency
DependencyType \= 'peerDependencies',
% Only proceed if the workspace doesn't already depend on tslib
\+ workspace_has_dependency(WorkspaceCwd, 'tslib', _, _).