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

Search: Migrate Classic Search, Instant Search, and Customberg to package #21637

Merged
merged 98 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
701d31f
Establish JS package, add build config
jsnmoon Nov 3, 2021
316be8b
Add active plugins function, fix webpack pathing
jsnmoon Nov 3, 2021
edfebe3
Migrate classic and instant search classes
jsnmoon Nov 3, 2021
07c2a01
Move Instant Search assets
jsnmoon Nov 3, 2021
6e539ef
Add initializers
jsnmoon Nov 3, 2021
563a28f
Use the new initializer in Jetpack plugin
jsnmoon Nov 8, 2021
2b7d6aa
Changelog
jsnmoon Nov 8, 2021
ce5d54a
Rename test files and fix lint errors
jsnmoon Nov 9, 2021
fdcc0bb
Migrate the template tags class
jsnmoon Nov 10, 2021
779779c
Fix instant search build
jsnmoon Nov 10, 2021
a1a529c
Continue migrating classic search
jsnmoon Nov 10, 2021
e2bc29b
Comment linting
jsnmoon Nov 10, 2021
20ef77d
Migrate the Settings class to package
jsnmoon Nov 10, 2021
f1ded70
Simplify babel config
jsnmoon Nov 10, 2021
c118255
Tweak module resolution config for instant search
jsnmoon Nov 10, 2021
f3a7e37
Tweak babel config
jsnmoon Nov 11, 2021
f65536e
Migrate Customberg to package
jsnmoon Nov 11, 2021
282d676
Move eslint config
jsnmoon Nov 11, 2021
ffcb945
Generalize instant search initialization
jsnmoon Nov 11, 2021
4aa74bb
Remove search builds from Jetpack plugin
jsnmoon Nov 11, 2021
233ecc0
Update pnpm lockfile
jsnmoon Nov 15, 2021
169c31f
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Nov 16, 2021
f8490c7
Fix merge mistakes
jsnmoon Nov 16, 2021
a9fd3cd
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Nov 16, 2021
02a54f6
Remove unnecessary style inclusion
jsnmoon Nov 17, 2021
5150dd2
Remove unnecessary namespace aliasing
jsnmoon Nov 17, 2021
ba0e0c4
Use correct package version value
jsnmoon Nov 17, 2021
d06ed3c
Reduce code duplication
jsnmoon Nov 17, 2021
30b2b53
Update composer lockfile
jsnmoon Nov 17, 2021
b74a350
Update excludelists
jsnmoon Nov 17, 2021
7acb060
Undo change, use Helper
jsnmoon Nov 17, 2021
edeaabe
Remove unnecessary namespace aliasing
jsnmoon Nov 17, 2021
13bbf65
Reverts instance() signature, add initialize fn
jsnmoon Nov 17, 2021
67456d1
Update composer config
jsnmoon Nov 17, 2021
5ba6fee
Update package.json
jsnmoon Nov 17, 2021
6d27093
Port instant search jest and size-limit tests
jsnmoon Nov 18, 2021
4e0efa1
Flesh out build scripts
jsnmoon Nov 18, 2021
8af1061
Update pnpm lockfile
jsnmoon Nov 18, 2021
c64be57
Move build folder to tools
jsnmoon Nov 19, 2021
1345267
Move dist folder to build
jsnmoon Nov 19, 2021
a0d1935
Jetpack_Search -> Classic_Search
jsnmoon Nov 19, 2021
229fe69
Fix code comment typo
jsnmoon Nov 19, 2021
56900ed
Duplicate postcss config instead of importing
jsnmoon Nov 19, 2021
23a41a4
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 2, 2021
f065a20
Undo accidental deletion via merge
jsnmoon Dec 3, 2021
82b4146
Fix linting error
jsnmoon Dec 3, 2021
7c71657
Remove unused script, fix Webpack build
jsnmoon Dec 3, 2021
0ffcc19
Remove obsolete search scripts in main plugin
jsnmoon Dec 3, 2021
16045c3
Fix version number in package.json
jsnmoon Dec 3, 2021
caa5a8a
Fix browserslist
jsnmoon Dec 3, 2021
7bcc885
pnpm lockfile
jsnmoon Dec 3, 2021
5e41003
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 3, 2021
201c8b0
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 3, 2021
eac2b14
Fix merge conflict & build
jsnmoon Dec 3, 2021
a0ae5c9
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 7, 2021
8b70bbf
Repin composer deps with php 7.4
jsnmoon Dec 7, 2021
6910825
Fix merge conflict typo
jsnmoon Dec 7, 2021
ec9163b
Fix tests
jsnmoon Dec 7, 2021
392150b
Bump composer version in Jetpack plugin
jsnmoon Dec 7, 2021
d715910
Undo rename and linting uplift
jsnmoon Dec 7, 2021
14975da
Remove test-search from Jetpack plugin's composer
jsnmoon Dec 7, 2021
19c700e
Use new Plan class
jsnmoon Dec 7, 2021
3a8ee83
Rename customberg assets for consistency
jsnmoon Dec 7, 2021
dc84c0c
Fix size-limit config
jsnmoon Dec 7, 2021
b5b7bf5
Bump react to 17 to fix tests
jsnmoon Dec 7, 2021
430edbc
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 7, 2021
ac9bf3a
Add test-js composer script
jsnmoon Dec 7, 2021
36c877d
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 8, 2021
29e533d
Fix script registration invocation
jsnmoon Dec 8, 2021
997f41f
Fix lockfile
jsnmoon Dec 8, 2021
5a829d2
Update jest config for plugin
jsnmoon Dec 8, 2021
305b576
Remove obsolete git attribute config
jsnmoon Dec 8, 2021
de48a69
Remove obsolete comment
jsnmoon Dec 8, 2021
e9d3cf2
Remove obsolete files
jsnmoon Dec 9, 2021
5072cb5
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 9, 2021
1f96166
Fix lint errors
jsnmoon Dec 9, 2021
c4e3646
Fix lint errors
jsnmoon Dec 9, 2021
45354d3
Improve code comments
jsnmoon Dec 9, 2021
bc6367b
Remove redundant changelog
jsnmoon Dec 9, 2021
15b6277
Use better name for package directory constant
jsnmoon Dec 9, 2021
8fd418b
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 9, 2021
3216810
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 10, 2021
79ffb10
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 10, 2021
c7205b7
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 15, 2021
469b41d
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 16, 2021
c2ed6fb
Remove obsolete comment
jsnmoon Dec 17, 2021
3ba84b1
Update class usage
jsnmoon Dec 17, 2021
b1624a0
Update auto-config behavior
jsnmoon Dec 17, 2021
427aa66
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 17, 2021
d397b49
Bump package version
jsnmoon Dec 17, 2021
1063b99
Temporarily rename Customberg class
jsnmoon Dec 18, 2021
262afef
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 20, 2021
ecc050c
Update class name to appease linter
jsnmoon Dec 21, 2021
9bdcd3f
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 21, 2021
2d0b797
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Dec 23, 2021
b8bb605
Fix i18n text domains
jsnmoon Dec 23, 2021
247d82c
Merge branch 'master' of github.com:Automattic/jetpack into update/mo…
jsnmoon Jan 10, 2022
ee11158
Update textdomain.
jeherve Jan 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
690 changes: 161 additions & 529 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions projects/packages/search/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
// JavaScript files inside this folder are meant to be transpiled by Webpack.
root: true,
extends: [ '../../../.eslintrc.react.js' ],
ignorePatterns: [ '**/external/*.js' ],
parserOptions: {
babelOptions: {
configFile: require.resolve( './babel.config.js' ),
Expand Down
12 changes: 12 additions & 0 deletions projects/packages/search/.size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = [
{
path: 'build/instant-search/jp-search.js',
running: false,
limit: '4 KiB',
},
{
path: 'build/instant-search/jp-search.chunk-main-payload.js',
running: false,
limit: '50 KiB',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Search: Migrated Classic and Instant Search code from Jetpack plugin.
4 changes: 4 additions & 0 deletions projects/packages/search/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"@composer install",
"phpdbg -d memory_limit=2048M -d max_execution_time=900 -qrr ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/clover.xml\""
],
"test-js": [
"Composer\\Config::disableProcessTimeout",
"pnpm run test"
],
"test-php": [
"@composer install",
"@composer phpunit"
Expand Down
10 changes: 5 additions & 5 deletions projects/packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"build": "pnpm run clean && pnpm run install-if-deps-outdated && pnpm run build-instant && pnpm run build-customberg && pnpm run build-dashboard",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate && pnpm run build-production-php",
"build-development": "NODE_ENV=development BABEL_ENV=development pnpm run build && pnpm run build-php",
"build-instant": "echo 'Not yet implemented.'",
"build-customberg": "echo 'Not yet implemented.'",
"build-instant": "webpack --config ./tools/webpack.instant.config.js",
"build-customberg": "webpack --config ./tools/webpack.customberg.config.js",
"build-dashboard": "echo 'Not yet implemented.'",
"build-php": "composer install --ignore-platform-reqs",
"build-production-php": "COMPOSER_MIRROR_PATH_REPOS=1 COMPOSER_ROOT_VERSION=dev-master composer install -o --no-dev --classmap-authoritative --prefer-dist",
Expand All @@ -20,7 +20,7 @@
"install-if-deps-outdated": "pnpm install --no-prod --frozen-lockfile",
"test": "pnpx concurrently 'pnpm:test-scripts' 'pnpm:test-size'",
"test-scripts": "jest --passWithNoTests",
"test-size": "echo 'Not yet implemented.'",
"test-size": "NODE_ENV=production BABEL_ENV=production pnpm run build-instant && size-limit",
"validate": "pnpm exec validate-es --no-error-on-unmatched-pattern build/"
},
"repository": {
Expand Down Expand Up @@ -56,8 +56,8 @@
"preact": "10.5.15",
"q-flat": "1.0.7",
"qss": "2.0.3",
"react": "16.14.0",
"react-dom": "16.14.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.1",
"refx": "3.1.1",
Expand Down
Empty file.
28 changes: 24 additions & 4 deletions projects/packages/search/src/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public static function ensure_post_types_on_remove_url( $filters, $post_types )
public static function are_filters_by_widget_disabled() {
/**
* Allows developers to disable filters being set by widget, in favor of manually
* setting filters via `Jetpack_Search::set_filters()`.
* setting filters via `Classic_Search::set_filters()`.
*
* @module search
*
Expand Down Expand Up @@ -863,9 +863,7 @@ public static function generate_initial_javascript_state() {
'postsPerPage' => $posts_per_page,
'siteId' => class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'get_option' ) ? Jetpack::get_option( 'id' ) : get_current_blog_id(),
'postTypes' => $post_type_labels,
// TODO: Enable this once instant search build pipeline has been moved to the Search package.
// 'webpackPublicPath' => plugins_url( '/build/instant-search/', __DIR__ ).
'webpackPublicPath' => plugins_url( '_inc/build/instant-search/', JETPACK__PLUGIN_FILE ),
'webpackPublicPath' => plugins_url( '/build/instant-search/', __DIR__ ),
'isPhotonEnabled' => ( $is_wpcom || $is_jetpack_photon_enabled ) && ! $is_private_site,

// config values related to private site support.
Expand Down Expand Up @@ -905,4 +903,26 @@ public static function print_instant_search_sidebar() {
</div>
<?php
}

/**
* Gets all of the active plugins via site options.
* Forked from Jetpack::get_active_plugins from the Jetpack plugin.
*
* @return string[]
*/
public static function get_active_plugins() {
// active_plugins plugins as values.
$active_plugins = (array) get_option( 'active_plugins', array() );

// active_sitewide_plugins stores plugins as keys.
if ( is_multisite() ) {
$network_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
if ( $network_plugins ) {
$active_plugins = array_merge( $active_plugins, $network_plugins );
}
}

sort( $active_plugins );
return array_unique( $active_plugins );
}
}
9 changes: 3 additions & 6 deletions projects/packages/search/src/class-template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class Template_Tags {
*/
public static function render_available_filters( $filters = null, $post_types = null ) {
if ( is_null( $filters ) ) {
// TODO: Must be migrated to use Classic_Search once the migration is underway.
$filters = \Jetpack_Search::instance()->get_filters();
$filters = Classic_Search::instance()->get_filters();
}

if ( is_null( $post_types ) ) {
Expand All @@ -44,8 +43,7 @@ public static function render_available_filters( $filters = null, $post_types =
$active_post_types = array();
if ( Helper::post_types_differ_searchable( $post_types ) ) {
// get the active filter buckets from the query.
// TODO: Must be migrated to use Classic_Search once the migration is underway.
$active_buckets = \Jetpack_Search::instance()->get_active_filter_buckets();
$active_buckets = Classic_Search::instance()->get_active_filter_buckets();
$post_types_differ_query = Helper::post_types_differ_query( $post_types );

// remove any post_type filters from display if the current query
Expand Down Expand Up @@ -84,8 +82,7 @@ public static function render_available_filters( $filters = null, $post_types =
*/
public static function render_instant_filters( $filters = null ) {
if ( is_null( $filters ) ) {
// TODO: Must be migrated to use Classic_Search once the migration is underway.
$filters = \Jetpack_Search::instance()->get_filters();
$filters = Classic_Search::instance()->get_filters();
}

foreach ( (array) $filters as $filter ) {
Expand Down
Loading