Skip to content

Commit

Permalink
Add jetpack-composer-plugin to wpcomsh and mu-wpcom-plugin (#41185
Browse files Browse the repository at this point in the history
)

The `wp i18n` command ignores files under `vendor/`, on the assumption
that Composer packages probably aren't using WordPress's i18n functions.
This doesn't hold true for many of our packages, such as
`jetpack-mu-wpcom`.

Our workaround for that is a Composer plugin that installs
"jetpack-library" packages under `jetpack_vendor/` instead, which
`wp i18n` does not ignore.

See Problem 5 at
https://developer.wordpress.com/2022/01/06/wordpress-plugin-i18n-webpack-and-composer/
for details.

Presumably we don't need to worry about Problem 6 for these plugins, as
they're only used on WordPress.com and we'd presumably have heard about
it already if that problem wasn't worked around somehow at the platform
level there.
  • Loading branch information
anomiex authored and coder-karen committed Jan 24, 2025
1 parent 1378a5b commit e087187
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 10 deletions.
1 change: 1 addition & 0 deletions projects/plugins/mu-wpcom-plugin/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vendor/autoload.php production-include
vendor/composer/** production-include
vendor/automattic/** production-include
vendor/scssphp/scssphp/** production-include
/jetpack_vendor/** production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Use `Automattic/jetpack-composer-plugin` so jetpack-library packages will be installed in a place where `wp i18n` will see them.
6 changes: 5 additions & 1 deletion projects/plugins/mu-wpcom-plugin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-composer-plugin": "@dev",
"automattic/jetpack-mu-wpcom": "@dev"
},
"require-dev": {
Expand Down Expand Up @@ -45,6 +46,9 @@
"release-branch-prefix": "mu-wpcom"
},
"config": {
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_7_0"
"autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_7_0",
"allow-plugins": {
"automattic/jetpack-composer-plugin": true
}
}
}
63 changes: 62 additions & 1 deletion projects/plugins/mu-wpcom-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions projects/plugins/wpcomsh/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package.json export-ignore
/vendor/scssphp/scssphp/** production-include
/vendor/tubalmartin/** production-include
/vendor/wordpress/classic-editor-plugin/** production-include
/jetpack_vendor/** production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
Expand Down
8 changes: 4 additions & 4 deletions projects/plugins/wpcomsh/bin/i18n/generate-pot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ find -L . \
-or -path './vendor/*/wordpress' \
-or -path './vendor/*/node_modules' \
-or -path './vendor/*/jetpack_vendor' \
-or -path './jetpack_vendor/*/vendor' \
-or -path './jetpack_vendor/*/wordpress' \
-or -path './jetpack_vendor/*/node_modules' \
-or -path './jetpack_vendor/*/jetpack_vendor' \
\) \
-prune \
-or \
-name '*.php' -and ! -path './build/*' -and ! -path './custom-colors/*' \
-and \( \
! -path './vendor/*' \
-or -path './vendor/automattic/jetpack-mu-wpcom/*' \
-or -path './vendor/automattic/at-pressable-podcasting/*' \
-or -path './vendor/automattic/custom-fonts-typekit/*' \
-or -path './vendor/automattic/custom-fonts/*' \
-or -path './vendor/automattic/jetpack-assets/*' \
-or -path './vendor/automattic/jetpack-config/*' \
-or -path './vendor/automattic/jetpack-post-list/*' \
\) \
-print \
| sed -e 's,^\./,,' \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Use `Automattic/jetpack-composer-plugin` so jetpack-library packages will be installed in a place where `wp i18n` will see them.
4 changes: 3 additions & 1 deletion projects/plugins/wpcomsh/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"automattic/text-media-widget-styles": "^2.0",
"automattic/wc-calypso-bridge": "2.8.1",
"wordpress/classic-editor-plugin": "1.6.7",
"automattic/jetpack-composer-plugin": "@dev",
"automattic/jetpack-config": "@dev",
"automattic/jetpack-post-list": "@dev",
"automattic/jetpack-mu-wpcom": "@dev",
Expand Down Expand Up @@ -122,7 +123,8 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/installers": true
"composer/installers": true,
"automattic/jetpack-composer-plugin": true
},
"autoloader-suffix": "26841ac2064774301cbe06d174833bfc_wpcomshⓥ6_0_0"
},
Expand Down
63 changes: 62 additions & 1 deletion projects/plugins/wpcomsh/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/plugins/wpcomsh/lib/class.color.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
// phpcs:ignoreFile WordPress.Files.FileName.NotHyphenatedLowercase

// Dummy comment to make phpcs happy.
require_once WPCOMSH__PLUGIN_DIR_PATH . '/vendor/automattic/jetpack-classic-theme-helper/_inc/lib/class.color.php';
require_once WPCOMSH__PLUGIN_DIR_PATH . '/jetpack_vendor/automattic/jetpack-classic-theme-helper/_inc/lib/class.color.php';
2 changes: 1 addition & 1 deletion projects/plugins/wpcomsh/lib/tonesque.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*/

// Dummy comment to make phpcs happy.
require_once WPCOMSH__PLUGIN_DIR_PATH . '/vendor/automattic/jetpack-classic-theme-helper/_inc/lib/tonesque.php';
require_once WPCOMSH__PLUGIN_DIR_PATH . '/jetpack_vendor/automattic/jetpack-classic-theme-helper/_inc/lib/tonesque.php';

0 comments on commit e087187

Please sign in to comment.