Skip to content
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

chore: setup Yarn constraints #13363

Merged
merged 11 commits into from May 31, 2021
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -23,11 +23,14 @@ jobs:
key: yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-
- name: Check Yarn dedupe
- name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")'
run: |
yarn constraints
- name: 'Check for duplicate dependencies (fix w/ "yarn dedupe")'
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
yarn dedupe --check
- name: Check or update Yarn cache
- name: 'Check or update Yarn cache (fix w/ "yarn install")'
env:
YARN_ENABLE_SCRIPTS: false # disable post-install scripts
YARN_NODE_LINKER: pnp # use pnp linker for better linking performance: it's meant to update yarn cache only
Expand Down
8 changes: 8 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-constraints.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .yarn/releases/yarn-2.4.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Expand Up @@ -13,6 +13,8 @@ plugins:
spec: "https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-babel-release-tool/main/bundles/%40yarnpkg/plugin-babel-release-tool.js"
- path: .yarn/plugins/@yarnpkg/plugin-conditions.cjs
spec: "https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-conditions/main/bundles/%40yarnpkg/plugin-conditions.js"
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
spec: "@yarnpkg/plugin-constraints"

releaseTool:
ignoreChanges:
Expand Down
Expand Up @@ -11,7 +11,7 @@
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"keywords": [
"@babel/codemod",
"@babel/plugin"
Expand All @@ -25,5 +25,9 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*"
}
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}
Expand Up @@ -5,13 +5,13 @@
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "codemods/babel-plugin-codemod-remove-unused-catch-binding"
"directory": "codemods/babel-plugin-codemod-optional-catch-binding"
},
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"keywords": [
"@babel/codemod",
"@babel/plugin"
Expand All @@ -25,5 +25,9 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*"
}
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}
69 changes: 69 additions & 0 deletions constraints.pro
@@ -0,0 +1,69 @@
% Enforces that all workspaces depend on other workspaces using `workspace:*` in devDependencies
gen_enforced_dependency(WorkspaceCwd, DependencyIdent, 'workspace:*', 'devDependencies') :-
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, 'devDependencies'),
% Only consider dependency ranges that start with 'workspace:'
atom_concat('workspace:', _, DependencyRange).

% 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/babel/babel.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 all workspaces except '@babel/eslint*'
gen_enforced_field(WorkspaceCwd, 'engines.node', '>=6.9.0') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
% Get the workspace name
workspace_ident(WorkspaceCwd, WorkspaceIdent),
% Exempt from the rule as it supports '>=4'. TODO: remove with the next major
WorkspaceIdent \= '@babel/plugin-proposal-unicode-property-regex',
% Exempt from the rule as it supports '>=6.0.0'. TODO: remove with the next major
WorkspaceIdent \= '@babel/parser',
Comment on lines +34 to +37
Copy link
Contributor Author

@merceyz merceyz May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two actually built for >=6.9.0 but the engines.node value wasn't updated back in the day or are they correct and special cased?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch, they are both built for 6.9.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I let them get updated or wait for the next major to be on the safe side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep them for now, just to be safe.

% Skip '@babel/eslint*' workspaces. TODO: remove with the next major
\+ atom_concat('@babel/eslint', _, WorkspaceIdent).

% Enforces the engines.node field for '@babel/eslint*' workspaces
% TODO: remove with the next major
gen_enforced_field(WorkspaceCwd, 'engines.node', '^10.13.0 || ^12.13.0 || >=14.0.0') :-
\+ workspace_field(WorkspaceCwd, 'private', true),
% Get the workspace name
workspace_ident(WorkspaceCwd, WorkspaceIdent),
% Only target '@babel/eslint*' workspaces
atom_concat('@babel/eslint', _, WorkspaceIdent).

% Removes the 'engines.node' field from private workspaces
gen_enforced_field(WorkspaceCwd, 'engines.node', null) :-
workspace_field(WorkspaceCwd, 'private', true).

% Enforces the author field to be consistent
gen_enforced_field(WorkspaceCwd, 'author', 'The Babel Team (https://babel.dev/team)') :-
\+ workspace_field(WorkspaceCwd, 'private', true).
Comment on lines +55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I would love to do it, I'm not 100% sure that we can legally remove Sebastian, Logan and the other people from the existing author fields. We can do that if git blame doesn't assign any piece of code to them, but probably it's too much work to check.

Maybe we should add an explicit list of packages that can have a different author (it doesn't need to be maintained anyway, it's "legacy"), and only enforce The Babel Team for new packages.

We can probably replace @hzoo in @babel/preset-env if he agrees, since he's still a team member.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'm not a lawyer the MIT license only requires that the license is included so based on that it's fine to change it as it's part of the "Software" and permission was granted to modify it.

Copy link
Contributor

@julienw julienw Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey!

Not a lawyer here either, but I worked a bit on licenses in the past. I just want to mention that license and author rights are two different things.

I think the change here is fine as long as Sebastian and others' attributions are still present otherwise (an AUTHORS file, or maybe the output git blame itself is already good enough in this case as long as their contributions are properly labeled in the git repository).

Other free software sometimes uses a CLA that enforces that every contribution's author rights are given to one single organization... but even this doesn't work in some countries (eg: France).

My (unwanted) 2 cents :-)

gen_enforced_field(WorkspaceCwd, 'author', null) :-
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).
7 changes: 0 additions & 7 deletions eslint/babel-eslint-config-internal/package.json
Expand Up @@ -2,13 +2,6 @@
"name": "@babel/eslint-config-internal",
"version": "7.12.13",
"description": "The Babel Team's ESLint configuration. Since it's internal, it might not respect semver.",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-config-internal"
},
"private": true,
"main": "./index.js",
"type": "commonjs",
Expand Down
9 changes: 1 addition & 8 deletions eslint/babel-eslint-plugin-development-internal/package.json
Expand Up @@ -2,21 +2,14 @@
"name": "@babel/eslint-plugin-development-internal",
"version": "7.14.0",
"description": "The Babel Team's ESLint custom rules plugin. Since it's internal, it might not respect semver.",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "eslint/babel-eslint-plugin-development-internal"
},
"main": "./lib/index.js",
"keywords": [
"babel",
"eslint",
"eslintplugin",
"eslint-plugin",
"babel-eslint"
],
"author": "Kai Cataldo <kai@kaicataldo.com>",
"license": "MIT",
"private": true,
"bugs": {
"url": "https://github.com/babel/babel/issues"
Expand Down
6 changes: 1 addition & 5 deletions eslint/babel-eslint-plugin-development/package.json
Expand Up @@ -7,11 +7,7 @@
"eslintplugin",
"eslint-plugin"
],
"author": {
"name": "Nicolò Ribaudo",
"email": "nicolo.ribaudo@gmail.com",
"url": "https://github.com/nicolo-ribaudo"
},
"author": "The Babel Team (https://babel.dev/team)",
"main": "./lib/index.js",
"type": "commonjs",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion eslint/babel-eslint-plugin/package.json
Expand Up @@ -23,7 +23,7 @@
"eslint-plugin",
"babel-eslint"
],
"author": "Jason Quense @monasticpanic",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"engines": {
"node": "^10.13.0 || ^12.13.0 || >=14.0.0"
Expand Down
1 change: 0 additions & 1 deletion eslint/babel-eslint-shared-fixtures/package.json
Expand Up @@ -2,7 +2,6 @@
"name": "@babel/eslint-shared-fixtures",
"version": "7.12.13",
"description": "Shared fixtures for testing @babel/eslint-* packages",
"license": "MIT",
"private": true,
"dependencies": {
"@babel/core": "workspace:^7.12.13",
Expand Down
1 change: 0 additions & 1 deletion eslint/babel-eslint-tests/package.json
Expand Up @@ -2,7 +2,6 @@
"name": "@babel/eslint-tests",
"version": "7.14.3",
"description": "Tests for babel/eslint-* packages",
"license": "MIT",
"private": true,
"dependencies": {
"@babel/core": "workspace:^7.14.3",
Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,6 @@
"name": "babel",
"version": "7.14.3",
"private": true,
"license": "MIT",
"type": "commonjs",
"scripts": {
"bootstrap": "make bootstrap",
Expand Down Expand Up @@ -90,7 +89,6 @@
"babel-plugin-polyfill-corejs2/@babel/compat-data": "workspace:*"
},
"engines": {
"node": ">= 6.9.0",
"yarn": ">=1.4.0"
},
"lint-staged": {
Expand Down
5 changes: 4 additions & 1 deletion packages/babel-cli/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@babel/cli",
"version": "7.14.3",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-cli",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20cli%22+is%3Aopen",
"license": "MIT",
Expand Down Expand Up @@ -47,5 +47,8 @@
"bin": {
"babel": "./bin/babel.js",
"babel-external-helpers": "./bin/babel-external-helpers.js"
},
"engines": {
"node": ">=6.9.0"
}
}
7 changes: 5 additions & 2 deletions packages/babel-code-frame/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@babel/code-frame",
"version": "7.12.13",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen",
"license": "MIT",
Expand All @@ -14,13 +14,16 @@
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-code-frame"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"dependencies": {
"@babel/highlight": "workspace:^7.12.13"
},
"devDependencies": {
"@types/chalk": "^2.0.0",
"chalk": "^2.0.0",
"strip-ansi": "^4.0.0"
},
"engines": {
"node": ">=6.9.0"
}
}
3 changes: 3 additions & 0 deletions packages/babel-compat-data/package.json
Expand Up @@ -32,5 +32,8 @@
"@mdn/browser-compat-data": "^3.3.4",
"core-js-compat": "^3.9.0",
"electron-to-chromium": "^1.3.738"
},
"engines": {
"node": ">=6.9.0"
}
}
4 changes: 2 additions & 2 deletions packages/babel-core/package.json
Expand Up @@ -2,8 +2,8 @@
"name": "@babel/core",
"version": "7.14.3",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"main": "./lib/index.js",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
7 changes: 5 additions & 2 deletions packages/babel-generator/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@babel/generator",
"version": "7.14.3",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand All @@ -14,7 +14,7 @@
},
"homepage": "https://babel.dev/docs/en/next/babel-generator",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen",
"main": "lib/index.js",
"main": "./lib/index.js",
"files": [
"lib"
],
Expand All @@ -28,5 +28,8 @@
"@babel/parser": "workspace:*",
"@types/jsesc": "^2.5.0",
"@types/source-map": "^0.5.0"
},
"engines": {
"node": ">=6.9.0"
}
}
8 changes: 6 additions & 2 deletions packages/babel-helper-annotate-as-pure/package.json
Expand Up @@ -12,8 +12,12 @@
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"dependencies": {
"@babel/types": "workspace:^7.12.13"
}
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}
Expand Up @@ -12,9 +12,13 @@
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-explode-assignable-expression": "workspace:^7.12.13",
"@babel/types": "workspace:^7.12.13"
}
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}
8 changes: 6 additions & 2 deletions packages/babel-helper-builder-react-jsx/package.json
Expand Up @@ -12,9 +12,13 @@
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-annotate-as-pure": "workspace:^7.12.13",
"@babel/types": "workspace:^7.12.13"
}
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)"
}
5 changes: 4 additions & 1 deletion packages/babel-helper-compilation-targets/package.json
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-helper-compilation-targets"
},
"main": "lib/index.js",
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js"
},
Expand All @@ -33,5 +33,8 @@
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"@types/semver": "^5.5.0"
},
"engines": {
"node": ">=6.9.0"
}
}