-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update/buttons-deprecated-isdefault
- Loading branch information
Showing
104 changed files
with
906 additions
and
476 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
# Ignored by default, but we should check it | ||
!.github/ | ||
!.prettierrc.js | ||
!.pnpmfile.cjs |
This file contains 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 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,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, | ||
}, | ||
}; |
This file contains 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 |
---|---|---|
|
@@ -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" | ||
} | ||
} | ||
} |
Oops, something went wrong.