Open
Description
- I'd be willing to implement a fix
Describe the bug
Creating a constraint using the query predicate to enforce the fact for workspace manifests where a field does not exist.
Running yarn constraints
does not enforce the constraint.
To Reproduce
Seem minimal reproduction here https://github.com/theseyi/constraints
- init a yarn workspace with one workspace package
packages/package-a
and the workspace root - import the constraint plugin
yarn plugin import constraints
- touch a constraints.pro file and add in the following constraint
- attempt to enforce the constraint with
yarn constraints
% enforce workspace packages without a workspace field to have a scripts.test field
gen_enforced_field(WorkspaceCwd, 'scripts.test', 'someValue') :-
workspace_field(WorkspaceCwd, 'workspaces', null).
Reproduction
// in workspace root
{
"name": "constraints",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"workspaces": [
"packages/*"
]
}
// in packages/package-a
{
"name": "package-a",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
% enforce workspace packages without a workspace field to have a scripts.test field
gen_enforced_field(WorkspaceCwd, 'scripts.test', 'someValue') :-
workspace_field(WorkspaceCwd, 'workspaces', null).
Expected:
➤ YN0037: package-a must have a field scripts.test set to someValue, but doesn't
➤ YN0000: Failed with errors in 0s 18ms
IMPORTANT: We strongly prefer reproductions that use Sherlock. Please check our documentation
for more information: https://yarnpkg.com/advanced/sherlock
Unable to use Sherlock here since I'm not familiar with running it over prolog
Environment if relevant (please complete the following information):
- OS:
macos
- Node version
v12.20.1
- Yarn version
2.4.0