|
1 |
| -constraints_min_version(1). |
2 |
| - |
3 |
| -% This file is written in Prolog |
4 |
| -% It contains rules that the project must respect. |
5 |
| -% In order to see them in action, run `yarn constraints source` |
6 |
| - |
7 |
| -% This rule will enforce that a workspace MUST depend on the same version of a dependency as the one used by the other workspaces |
8 |
| -% We allow Docusaurus to have different dependencies for now; will be addressed later (when we remove Gatsby) |
9 |
| -gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType) :- |
10 |
| - % Iterates over all dependencies from all workspaces |
11 |
| - workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType), |
12 |
| - WorkspaceCwd \= 'packages/docusaurus', |
13 |
| - % Iterates over similarly-named dependencies from all workspaces (again) |
14 |
| - workspace_has_dependency(OtherWorkspaceCwd, DependencyIdent, DependencyRange2, DependencyType2), |
15 |
| - OtherWorkspaceCwd \= 'packages/docusaurus', |
16 |
| - % Ignore peer dependencies |
17 |
| - DependencyType \= 'peerDependencies', |
18 |
| - DependencyType2 \= 'peerDependencies', |
19 |
| - % Ignore devDependencies on other workspaces |
20 |
| - ( |
21 |
| - (DependencyType = 'devDependencies'; DependencyType2 = 'devDependencies') -> |
22 |
| - \+ workspace_ident(DependencyCwd, DependencyIdent) |
23 |
| - ; |
24 |
| - true |
25 |
| - ). |
26 |
| - |
27 |
| -% This rule will prevent workspaces from depending on non-workspace versions of available workspaces |
28 |
| -gen_enforced_dependency(WorkspaceCwd, DependencyIdent, 'workspace:^', DependencyType) :- |
29 |
| - % Iterates over all dependencies from all workspaces |
30 |
| - workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType), |
31 |
| - % Only consider those that target something that could be a workspace |
32 |
| - workspace_ident(DependencyCwd, DependencyIdent). |
33 |
| - |
34 |
| -% This rule enforces that all packages must not depend on inquirer - we use enquirer instead |
35 |
| -gen_enforced_dependency(WorkspaceCwd, 'inquirer', null, DependencyType) :- |
36 |
| - workspace_has_dependency(WorkspaceCwd, 'inquirer', _, DependencyType). |
37 |
| - |
38 |
| -% This rule enforces that all packages that depend on TypeScript must also depend on tslib |
39 |
| -gen_enforced_dependency(WorkspaceCwd, 'tslib', 'range', 'dependencies') :- |
40 |
| - % Iterates over all TypeScript dependencies from all workspaces |
41 |
| - workspace_has_dependency(WorkspaceCwd, 'typescript', _, DependencyType), |
42 |
| - % Ignores the case when TypeScript is a peer dependency |
43 |
| - DependencyType \= 'peerDependencies', |
44 |
| - % Only proceed if the workspace doesn't already depend on tslib |
45 |
| - \+ workspace_has_dependency(WorkspaceCwd, 'tslib', _, _). |
46 |
| - |
47 |
| -% This rule will enforce that all packages must have a "BSD-2-Clause" license field |
48 |
| -gen_enforced_field(WorkspaceCwd, 'license', 'BSD-2-Clause'). |
49 |
| - |
50 |
| -% This rule will enforce that all packages must have an correct engines.node field |
51 |
| -% Keep in sync with the range inside packages/yarnpkg-cli/sources/main.ts |
52 |
| -gen_enforced_field(WorkspaceCwd, 'engines.node', '>=18.12.0'). |
53 |
| - |
54 |
| -% Required to make the package work with the GitHub Package Registry |
55 |
| -gen_enforced_field(WorkspaceCwd, 'repository.type', 'git'). |
56 |
| -gen_enforced_field( WorkspaceCwd, 'repository.url', 'ssh://[email protected]/yarnpkg/berry.git') . |
57 |
| -gen_enforced_field(WorkspaceCwd, 'repository.directory', WorkspaceCwd). |
58 |
| - |
59 |
| -% This rule will require that the plugins that aren't embed in the CLI list a specific script that'll |
60 |
| -% be called as part of our release process (to rebuild them in the context of our repository) |
61 |
| -gen_enforced_field(WorkspaceCwd, 'scripts.update-local', '<any value>') :- |
62 |
| - % Obtain the path for the CLI |
63 |
| - workspace_ident(CliCwd, '@yarnpkg/cli'), |
64 |
| - % Iterates over all workspaces whose name is prefixed with "@yarnpkg/plugin-" |
65 |
| - workspace_ident(WorkspaceCwd, WorkspaceIdent), |
66 |
| - atom_concat('@yarnpkg/plugin-', _, WorkspaceIdent), |
67 |
| - % Select those that are not included in the CLI bundle array |
68 |
| - \+ workspace_field_test(CliCwd, '@yarnpkg/builder.bundles.standard', '$$.includes($0)', [WorkspaceIdent]), |
69 |
| - % Only if they don't have a script set |
70 |
| - \+ workspace_field(WorkspaceCwd, 'scripts.update-local', _). |
71 |
| - |
72 |
| -inline_compile('@yarnpkg/eslint-config'). |
73 |
| -inline_compile('@yarnpkg/libui'). |
74 |
| - |
75 |
| -gen_enforced_field(WorkspaceCwd, 'scripts.prepack', 'run build:compile "$(pwd)"') :- |
76 |
| - workspace(WorkspaceCwd), |
77 |
| - % This package is built using Rollup, so we allow it to configure its build scripts itself |
78 |
| - \+ workspace_ident(WorkspaceCwd, '@yarnpkg/pnp'), |
79 |
| - % Those packages use a different build |
80 |
| - \+ (workspace_ident(WorkspaceCwd, WorkspaceIdent), inline_compile(WorkspaceIdent)), |
81 |
| - % Private packages aren't covered |
82 |
| - \+ workspace_field_test(WorkspaceCwd, 'private', 'true'). |
83 |
| - |
84 |
| -gen_enforced_field(WorkspaceCwd, 'scripts.postpack', 'rm -rf lib') :- |
85 |
| - workspace(WorkspaceCwd), |
86 |
| - % This package is built using Rollup, so we allow it to configure its build scripts itself |
87 |
| - \+ workspace_ident(WorkspaceCwd, '@yarnpkg/pnp'), |
88 |
| - % Those packages use a different build |
89 |
| - \+ (workspace_ident(WorkspaceCwd, WorkspaceIdent), inline_compile(WorkspaceIdent)), |
90 |
| - % Private packages aren't covered |
91 |
| - \+ workspace_field_test(WorkspaceCwd, 'private', 'true'). |
| 1 | +% ## Prolog constraints are deprecated ! ## |
| 2 | +% |
| 3 | +% Check this other file in this same repository to see the new way to write constraints, using JS/TS: |
| 4 | +% |
| 5 | +% yarn.config.js |
0 commit comments