Skip to content

Commit

Permalink
Merge branch 'master' into update/buttons-deprecated-isdefault
Browse files Browse the repository at this point in the history
  • Loading branch information
oskosk committed Mar 7, 2022
2 parents 863ed5c + 8f061c9 commit bb8fe46
Show file tree
Hide file tree
Showing 104 changed files with 906 additions and 476 deletions.
1 change: 1 addition & 0 deletions .eslintignore.root
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
# Ignored by default, but we should check it
!.github/
!.prettierrc.js
!.pnpmfile.cjs
4 changes: 4 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
"extends": [ "packages:jsUnitTest" ],
"groupName": "JS unit testing packages"
},
{
"groupName": "Size-limit",
"matchPackageNames": [ "size-limit", "@size-limit/preset-app" ]
},
{
"matchPaths": [ "packages/codesniffer/composer.json" ],
"rangeStrategy": "replace"
Expand Down
115 changes: 115 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Note if you change something here, you'll have to make a package.json mismatch pnpm-lock.yaml to
// get it re-run. An easy way to do that is to just edit pnpm-lock.yaml to change the version number
// of husky near the top.

/**
* Fix package dependencies.
*
* We could generally do the same with pnpm.overrides in packages.json, but this allows for comments.
*
* @param {object} pkg - Dependency package.json contents.
* @returns {object} Modified pkg.
*/
function fixDeps( pkg ) {
// Why do they not publish new versions from their monorepo?
if ( pkg.name === '@automattic/format-currency' ) {
// 1.0.0-alpha.0 published 3 years ago
pkg.dependencies[ 'i18n-calypso' ] = '^5';
}
if ( pkg.name === 'i18n-calypso' && pkg.dependencies[ 'interpolate-components' ] ) {
// 5.0.0 published 2 years ago
pkg.dependencies[ 'interpolate-components' ] = 'npm:@automattic/interpolate-components@^1.2.0';
}

// Even though Storybook works with webpack 5, they still have a bunch of deps on webpack4.
if ( pkg.name.startsWith( '@storybook/' ) ) {
if ( pkg.dependencies[ '@storybook/builder-webpack4' ] ) {
pkg.dependencies[ '@storybook/builder-webpack4' ] = 'npm:@storybook/builder-webpack5@^6';
}
if ( pkg.dependencies[ '@storybook/manager-webpack4' ] ) {
pkg.dependencies[ '@storybook/manager-webpack4' ] = 'npm:@storybook/manager-webpack5@^6';
}
if ( pkg.dependencies.webpack ) {
pkg.dependencies.webpack = '^5';
}
if ( pkg.dependencies[ '@types/webpack' ] ) {
pkg.dependencies[ '@types/webpack' ] = '^5';
}
}

// Project is supposedly not dead, but still isn't being updated.
// For our purposes at least it seems to work fine with jest-environment-jsdom 27.
// https://github.com/enzymejs/enzyme-matchers/issues/353
if ( pkg.name === 'jest-environment-enzyme' ) {
pkg.dependencies[ 'jest-environment-jsdom' ] = '^27';
}

// Unpin browserslist here.
if (
pkg.name === 'react-dev-utils' &&
pkg.dependencies.browserslist.match( /^\d+\.\d+\.\d+$/ )
) {
pkg.dependencies.browserslist = '^' + pkg.dependencies.browserslist;
}

// Regular expression DOS.
if ( pkg.dependencies.trim === '0.0.1' ) {
pkg.dependencies.trim = '^0.0.3';
}

return pkg;
}

/**
* Fix package peer dependencies.
*
* This can't be done with pnpm.overrides.
*
* @param {object} pkg - Dependency package.json contents.
* @returns {object} Modified pkg.
*/
function fixPeerDeps( pkg ) {
// React 17 is entirely compatible with React 16, but a lot of junk hasn't updated deps yet.
for ( const p of [ 'react', 'react-dom' ] ) {
if (
pkg.peerDependencies?.[ p ] &&
pkg.peerDependencies[ p ].match( /(?:^|\|\|\s*)(?:\^16|16\.x)/ ) &&
! pkg.peerDependencies[ p ].match( /(?:^|\|\|\s*)(?:\^17|17\.x)/ )
) {
pkg.peerDependencies[ p ] += ' || ^17';
}
}

// Outdated. Looks like they're going to drop the eslint-config-wpcalypso package entirely with
// eslint-plugin-wpcalypso 5.1.0, but they haven't released that yet.
if ( pkg.name === 'eslint-config-wpcalypso' ) {
pkg.peerDependencies.eslint = '^8';
pkg.peerDependencies[ 'eslint-plugin-inclusive-language' ] = '*';
pkg.peerDependencies[ 'eslint-plugin-jsdoc' ] = '*';
pkg.peerDependencies[ 'eslint-plugin-wpcalypso' ] = '*';
}

return pkg;
}

/**
* Pnpm package hook.
*
* @see https://pnpm.io/pnpmfile#hooksreadpackagepkg-context-pkg--promisepkg
* @param {object} pkg - Dependency package.json contents.
* @param {object} context - Pnpm object of some sort.
* @returns {object} Modified pkg.
*/
function readPackage( pkg, context ) {
if ( pkg.name ) {
pkg = fixDeps( pkg, context );
pkg = fixPeerDeps( pkg, context );
}
return pkg;
}

module.exports = {
hooks: {
readPackage,
},
};
16 changes: 0 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,5 @@
"node": "^14.18.3 || ^16.13.2",
"pnpm": "^6.23.6",
"yarn": "use pnpm instead - see docs/yarn-upgrade.md"
},
"pnpm": {
"overrides": {
"@automattic/format-currency>i18n-calypso": "^5",
"@storybook/addon-docs>@storybook/builder-webpack4": "npm:@storybook/builder-webpack5@^6",
"@storybook/core-common>webpack@4": ">= 4",
"@storybook/core-server>webpack@4": ">= 4",
"@storybook/core-server>@storybook/builder-webpack4": "npm:@storybook/builder-webpack5@^6",
"@storybook/core-server>@storybook/manager-webpack4": "npm:@storybook/manager-webpack5@^6",
"@storybook/react>webpack@4": ">= 4",
"i18n-calypso>interpolate-components": "npm:@automattic/interpolate-components@^1.2.0",
"jest-environment-enzyme>jest-environment-jsdom@^24.0.0": "^27",
"react-dev-utils>browserslist@^4": "^4",
"[email protected]": "^0.0.3",
"yargs>yargs-parser@^5.0.1": "^20.0.0"
}
}
}
Loading

0 comments on commit bb8fe46

Please sign in to comment.