Monorepo: rework deps patching in favour of built-in pnpm functionality (#49892)

* Monorepo: added pach.

* Monorepo: added patch.

* Monorepo: added patch.

* Monorepo: added patch.

* Monorepo: added patch.

* Monorepo: cleanup.

* Monorepo: cleanup.

* Monorepo: changelog entry.
This commit is contained in:
Vladimir Reznichenko 2024-07-24 17:38:32 +02:00 committed by GitHub
parent b796b90d68
commit 474b7624d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 36 deletions

View File

@ -0,0 +1,44 @@
diff --git a/build-module/lock-unlock.js b/build-module/lock-unlock.js
index 2265f933ceec19f65ca6776c24c3f88b368d713f..e9e10980bfd1b584ab0a037c3b72edae29a2a26e 100644
--- a/build-module/lock-unlock.js
+++ b/build-module/lock-unlock.js
@@ -1,9 +1,34 @@
/**
- * WordPress dependencies
+ * External dependencies
*/
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
-export const {
- lock,
- unlock
-} = __dangerousOptInToUnstableAPIsOnlyForCoreModules('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-site');
+
+// Workaround for Gutenberg private API consent string differences between WP 6.3 and 6.4+
+// The modified version checks for the WP version and replaces the consent string with the correct one.
+// This can be removed once we drop support for WP 6.3 in the "Customize Your Store" task.
+// See this PR for details: https://github.com/woocommerce/woocommerce/pull/40884
+
+const wordPressConsentString = {
+ 6.4: 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
+ 6.5: 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
+ 6.6: 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
+};
+
+function optInToUnstableAPIs() {
+ let error;
+ for ( const optInString of Object.values( wordPressConsentString ) ) {
+ try {
+ return __dangerousOptInToUnstableAPIsOnlyForCoreModules(
+ optInString,
+ '@wordpress/edit-site'
+ );
+ } catch ( anError ) {
+ error = anError;
+ }
+ }
+
+ throw error;
+}
+
+export const { lock, unlock } = optInToUnstableAPIs();
//# sourceMappingURL=lock-unlock.js.map

View File

@ -75,6 +75,9 @@
"@types/react": "^17.0.71",
"react-resize-aware": "3.1.1",
"@automattic/tour-kit>@wordpress/element": "4.4.1"
},
"patchedDependencies": {
"@wordpress/edit-site@5.15.0": "bin/patches/@wordpress__edit-site@5.15.0.patch"
}
}
}

View File

@ -1,34 +0,0 @@
/**
* External dependencies
*/
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
// Workaround for Gutenberg private API consent string differences between WP 6.3 and 6.4+
// The modified version checks for the WP version and replaces the consent string with the correct one.
// This can be removed once we drop support for WP 6.3 in the "Customize Your Store" task.
// See this PR for details: https://github.com/woocommerce/woocommerce/pull/40884
const wordPressConsentString = {
6.4: 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
6.5: 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
6.6: 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
};
function optInToUnstableAPIs() {
let error;
for ( const optInString of Object.values( wordPressConsentString ) ) {
try {
return __dangerousOptInToUnstableAPIsOnlyForCoreModules(
optInString,
'@wordpress/edit-site'
);
} catch ( anError ) {
error = anError;
}
}
throw error;
}
export const { lock, unlock } = optInToUnstableAPIs();
//# sourceMappingURL=lock-unlock.js.map

View File

@ -16,7 +16,6 @@
"build": "pnpm --if-present --workspace-concurrency=Infinity --stream --filter=\"$npm_package_name...\" '/^build:project:.*$/'",
"build:project": "pnpm --if-present '/^build:project:.*$/'",
"build:project:bundle": "wireit",
"build:project:patch-dependecies": "cp ./bin/modified-editsite-lock-unlock.js ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js",
"build:project:feature-config": "php ../woocommerce/bin/generate-feature-config.php",
"changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger",
"example": "webpack --config docs/examples/extensions/examples.config.js",
@ -30,7 +29,6 @@
"watch:build": "pnpm --if-present --workspace-concurrency=Infinity --filter=\"$npm_package_name...\" --parallel '/^watch:build:project:.*$/'",
"watch:build:project": "pnpm --if-present run '/^watch:build:project:.*$/'",
"watch:build:project:bundle": "wireit",
"watch:build:project:patch-dependecies": "cp ./bin/modified-editsite-lock-unlock.js ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js",
"watch:build:project:feature-config": "WC_ADMIN_PHASE=development php ../woocommerce/bin/generate-feature-config.php",
"postinstall": "node ./bin/xstate5-react-script.js"
},

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Monorepo: refine approach to patching dependecies in favour of built-in pnpm functionality.

View File

@ -11,6 +11,11 @@ overrides:
pnpmfileChecksum: y3ex4x7shfdnqpcpdnu67kmuvu
patchedDependencies:
'@wordpress/edit-site@5.15.0':
hash: 6y3l6gxu33zybfmvbjd23dtqda
path: bin/patches/@wordpress__edit-site@5.15.0.patch
importers:
.: