-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Enforce same version of a dependency #12668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
594bfcb
enforce same version of a dependency
F3n67u 43d50fd
add workflow
F3n67u 82dbc04
fix pass 2
F3n67u 5273ba8
react
F3n67u 2fbef57
jest-environment-node
F3n67u 8b92faa
update lock
F3n67u 324418d
downgrade react of example-enzyme
F3n67u e4fe317
update yarn lock
F3n67u 7bbbcb4
@types/node
F3n67u 3d6e667
ignore prolog file
F3n67u 4b21550
update lock
F3n67u f0e4aa8
prettier
F3n67u f389910
update root package.json
F3n67u dddf349
update example
F3n67u 9ab23c5
update lock
F3n67u 2d37018
check dev deps
F3n67u 46a140e
ignore example enzyme
F3n67u 09b7105
duplicated deps
F3n67u 60851d7
fix contriants error
F3n67u dfcf657
update constriants
F3n67u f77e418
eslint to lint
F3n67u 4ffbdec
update
F3n67u 4dd6a3b
refactor: use member
F3n67u 33f09e5
make typescript version consistent
F3n67u 0120a79
update workflow and contributing.md
F3n67u 280f346
update snapshot
F3n67u 029c4e4
Update CONTRIBUTING.md
F3n67u 1588faa
reorder
F3n67u 5983579
example dir use *
F3n67u 121fe50
update lock
F3n67u c628e7b
use node 12 in root
F3n67u 801c01b
update lock
F3n67u bf3ae23
alphabetical
SimenB 9eedd17
update verion on examples to workspace:*
F3n67u 1fdef1e
workspace:*
F3n67u c4b11aa
workspace:*
F3n67u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
constraints_min_version(1). | ||
|
||
% This file is written in Prolog | ||
% It contains rules that the project must respect. | ||
% Check with "yarn constraints" (fix w/ "yarn constraints --fix") | ||
% Yarn Constraints https://yarnpkg.com/features/constraints | ||
% Reference for other constraints: | ||
% https://github.com/babel/babel/blob/main/constraints.pro | ||
% https://github.com/yarnpkg/berry/blob/master/constraints.pro | ||
|
||
% 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 * | ||
DependencyRange \= '*', | ||
DependencyRange2 \= '*', | ||
% Get the workspace name | ||
workspace_ident(WorkspaceCwd, WorkspaceIdent), | ||
workspace_ident(OtherWorkspaceCwd, OtherWorkspaceIdent), | ||
% 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 | ||
). | ||
|
||
% 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'). | ||
|
||
% Enforces the license in all public workspaces while removing it from private workspaces | ||
gen_enforced_field(WorkspaceCwd, 'license', 'MIT') :- | ||
\+ workspace_field(WorkspaceCwd, 'private', true). | ||
gen_enforced_field(WorkspaceCwd, 'license', null) :- | ||
workspace_field(WorkspaceCwd, 'private', true). | ||
|
||
% 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/facebook/jest.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 'publishConfig.access' is set to public for public workspaces while removing it from private workspaces | ||
gen_enforced_field(WorkspaceCwd, 'publishConfig.access', 'public') :- | ||
\+ workspace_field(WorkspaceCwd, 'private', true). | ||
gen_enforced_field(WorkspaceCwd, 'publishConfig.access', null) :- | ||
workspace_field(WorkspaceCwd, 'private', true). | ||
|
||
% Enforces the engines.node field for public workspace | ||
gen_enforced_field(WorkspaceCwd, 'engines.node', '^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0') :- | ||
\+ workspace_field(WorkspaceCwd, 'private', true). | ||
|
||
% Enforces the main and types field to start with ./ | ||
gen_enforced_field(WorkspaceCwd, FieldName, ExpectedValue) :- | ||
% Fields the rule applies to | ||
member(FieldName, ['main', 'types']), | ||
% Get current value | ||
workspace_field(WorkspaceCwd, FieldName, CurrentValue), | ||
% Must not start with ./ already | ||
\+ atom_concat('./', _, CurrentValue), | ||
% Store './' + CurrentValue in ExpectedValue | ||
atom_concat('./', CurrentValue, ExpectedValue). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
"testEnvironment": "node" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.7.4" | ||
"typescript": "^4.6.2" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"testRegex": "fails" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.7.4" | ||
"typescript": "^4.6.2" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"testRegex": "fails" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.7.4" | ||
"typescript": "^4.6.2" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
"testEnvironment": "node" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.3.1" | ||
"typescript": "^4.6.2" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.