diff --git a/.distignore b/.distignore index 6128c2a7..6b029adc 100644 --- a/.distignore +++ b/.distignore @@ -13,3 +13,4 @@ hookdoc-conf.json package.json yarn.lock php-scoper +generate_autoload.php diff --git a/.gitignore b/.gitignore index 34134a85..cb8a646b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ yarn.lock hookdocs *.cache phpunit.xml +tests/logs/junit.xml diff --git a/.phpunit.xml.dist b/.phpunit.xml.dist index a392ebaf..c2ea78ab 100644 --- a/.phpunit.xml.dist +++ b/.phpunit.xml.dist @@ -19,6 +19,7 @@ - - + + + diff --git a/README.md b/README.md index 3b194c39..087a8822 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Deploy to WordPress.org - Discord chat + Discord chat

diff --git a/includes/API/Customers_Controller.php b/includes/API/Customers_Controller.php index ddba36eb..9c98c075 100644 --- a/includes/API/Customers_Controller.php +++ b/includes/API/Customers_Controller.php @@ -313,21 +313,21 @@ public function wcpos_get_all_posts( $request ) { } } } else { - function format_results( $users, $last_updates, $id_with_modified_date ) { - foreach ( $users as $user ) { - $user_info = array( 'id' => (int) $user->ID ); - if ( $id_with_modified_date ) { - if ( isset( $last_updates[ $user->ID ] ) && ! empty( $last_updates[ $user->ID ] ) ) { - $user_info['date_modified_gmt'] = $last_updates[ $user->ID ]; - } else { - $user_info['date_modified_gmt'] = null; // users can have null date_modified_gmt + $formatted_results = iterator_to_array( + ( function () use ( $users, $last_updates, $id_with_modified_date ) { + foreach ( $users as $user ) { + $user_info = array( 'id' => (int) $user->ID ); + if ( $id_with_modified_date ) { + if ( isset( $last_updates[ $user->ID ] ) && ! empty( $last_updates[ $user->ID ] ) ) { + $user_info['date_modified_gmt'] = $last_updates[ $user->ID ]; + } else { + $user_info['date_modified_gmt'] = null; // users can have null date_modified_gmt + } } + yield $user_info; } - yield $user_info; - } - } - - $formatted_results = iterator_to_array( format_results( $users, $last_updates, $id_with_modified_date ) ); + } )() + ); } // Get the total number of orders for the given criteria. diff --git a/includes/API/Product_Tags_Controller.php b/includes/API/Product_Tags_Controller.php index f9a37300..e19983a8 100644 --- a/includes/API/Product_Tags_Controller.php +++ b/includes/API/Product_Tags_Controller.php @@ -145,7 +145,7 @@ public function wcpos_terms_clauses_include_exclude( array $clauses, array $taxo * * @return WP_REST_Response|WP_Error */ - public function wcpos_get_all_posts( $request ): array { + public function wcpos_get_all_posts( $request ) { // Start timing execution. $start_time = microtime( true ); $modified_after = $request->get_param( 'modified_after' ); diff --git a/includes/API/Products_Controller.php b/includes/API/Products_Controller.php index 8dc9af44..35a5a4bf 100644 --- a/includes/API/Products_Controller.php +++ b/includes/API/Products_Controller.php @@ -485,7 +485,11 @@ public function wcpos_get_all_posts( $request ) { return $response; } catch ( Exception $e ) { Logger::log( 'Error fetching product data: ' . $e->getMessage() ); - return new WP_Error( 'woocommerce_pos_rest_cannot_fetch', 'Error fetching product data.', array( 'status' => 500 ) ); + return new WP_Error( + 'woocommerce_pos_rest_cannot_fetch', + 'Error fetching product data.', + array( 'status' => 500 ) + ); } } diff --git a/includes/API/Traits/WCPOS_REST_API.php b/includes/API/Traits/WCPOS_REST_API.php index 6cb67ed2..0a609354 100644 --- a/includes/API/Traits/WCPOS_REST_API.php +++ b/includes/API/Traits/WCPOS_REST_API.php @@ -5,6 +5,7 @@ use WC_Data; use WCPOS\WooCommercePOS\Logger; use WP_REST_Response; +use Exception; trait WCPOS_REST_API { /** @@ -21,23 +22,23 @@ public function wcpos_format_all_posts_response( $results ) { * * This resulted in execution time of 10% of the original time. */ - function format_results( $results ) { - foreach ( $results as $result ) { - $result['id'] = (int) $result['id']; + return iterator_to_array( + ( function () use ( $results ) { + foreach ( $results as $result ) { + $result['id'] = (int) $result['id']; - if ( isset( $result['date_modified_gmt'] ) ) { - if ( preg_match( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $result['date_modified_gmt'] ) ) { + if ( isset( $result['date_modified_gmt'] ) ) { + if ( preg_match( '/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $result['date_modified_gmt'] ) ) { $result['date_modified_gmt'] = preg_replace( '/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})/', '$1T$2', $result['date_modified_gmt'] ); - } else { - $result['date_modified_gmt'] = wc_rest_prepare_date_response( $result['date_modified_gmt'] ); + } else { + $result['date_modified_gmt'] = wc_rest_prepare_date_response( $result['date_modified_gmt'] ); + } } - } - - yield $result; - } - } - return iterator_to_array( format_results( $results ) ); + yield $result; + } + } )() + ); } /** diff --git a/package.json b/package.json index 6680e4e5..c728cc8d 100644 --- a/package.json +++ b/package.json @@ -43,10 +43,10 @@ }, "homepage": "https://wcpos.com", "devDependencies": { - "@wordpress/babel-plugin-makepot": "5.20.0", - "@wordpress/env": "8.2.0", - "husky": "8.0.3", - "jsdoc": "^4.0.2", + "@wordpress/babel-plugin-makepot": "6.0.0", + "@wordpress/env": "10.0.0", + "husky": "9.0.11", + "jsdoc": "^4.0.3", "npm-run-all": "4.1.5", "taffydb": "^2.7.3", "wp-hookdoc": "0.2.0" diff --git a/packages/analytics/package.json b/packages/analytics/package.json index b4a47d50..80042e03 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -5,65 +5,65 @@ "start": "../../node_modules/.bin/webpack --watch" }, "dependencies": { - "@tanstack/react-query": "^4.29.19", - "@transifex/native": "^5.4.0", - "@transifex/react": "^5.4.0", - "@woocommerce/components": "^12.0.0", - "@wordpress/api-fetch": "6.33.0", - "@wordpress/components": "^25.2.0", - "@wordpress/element": "5.13.0", - "@wordpress/hooks": "^3.36.0", - "@wordpress/url": "3.37.0", - "classnames": "2.3.2", + "@tanstack/react-query": "^5.45.0", + "@transifex/native": "^7.1.1", + "@transifex/react": "^7.1.1", + "@woocommerce/components": "^12.3.0", + "@wordpress/api-fetch": "7.0.0", + "@wordpress/components": "^28.0.0", + "@wordpress/element": "6.0.0", + "@wordpress/hooks": "^4.0.0", + "@wordpress/url": "4.0.0", + "classnames": "2.5.1", "lodash": "4.17.21", - "react": "18.2.0", - "react-dom": "18.2.0", - "react-error-boundary": "4.0.10" + "react": "18.3.1", + "react-dom": "18.3.1", + "react-error-boundary": "4.0.13" }, "devDependencies": { - "@babel/core": "7.22.6", - "@babel/plugin-transform-runtime": "7.22.6", - "@babel/preset-env": "7.22.6", - "@babel/preset-react": "7.22.5", - "@babel/preset-typescript": "7.22.5", - "@babel/runtime": "7.22.6", - "@svgr/webpack": "8.0.1", - "@tanstack/react-query-devtools": "^4.29.19", - "@transifex/cli": "^5.4.0", - "@types/jest": "29.5.2", - "@types/lodash": "4.14.195", - "@types/react": "18.2.14", - "@types/react-beautiful-dnd": "13.1.4", - "@types/react-dom": "18.2.6", - "@types/wordpress__components": "^23.0.1", - "@typescript-eslint/eslint-plugin": "5.61.0", - "@typescript-eslint/parser": "5.61.0", + "@babel/core": "7.24.7", + "@babel/plugin-transform-runtime": "7.24.7", + "@babel/preset-env": "7.24.7", + "@babel/preset-react": "7.24.7", + "@babel/preset-typescript": "7.24.7", + "@babel/runtime": "7.24.7", + "@svgr/webpack": "8.1.0", + "@tanstack/react-query-devtools": "^5.45.0", + "@transifex/cli": "^7.1.1", + "@types/jest": "29.5.12", + "@types/lodash": "4.17.5", + "@types/react": "18.3.3", + "@types/react-beautiful-dnd": "13.1.8", + "@types/react-dom": "18.3.0", + "@types/wordpress__components": "^23.8.0", + "@typescript-eslint/eslint-plugin": "7.13.0", + "@typescript-eslint/parser": "7.13.0", "@wcpos/eslint-config": "*", - "@wordpress/env": "8.2.0", - "autoprefixer": "10.4.14", - "babel-loader": "9.1.2", - "css-loader": "6.8.1", - "css-minimizer-webpack-plugin": "^5.0.1", + "@wordpress/env": "10.0.0", + "autoprefixer": "10.4.19", + "babel-loader": "9.1.3", + "css-loader": "7.1.2", + "css-minimizer-webpack-plugin": "^7.0.0", "file-loader": "6.2.0", - "fork-ts-checker-webpack-plugin": "8.0.0", - "html-webpack-plugin": "5.5.3", - "husky": "8.0.3", - "jest": "29.6.0", - "jsdoc": "4.0.2", - "mini-css-extract-plugin": "2.7.6", + "fork-ts-checker-webpack-plugin": "9.0.2", + "html-webpack-plugin": "5.6.0", + "husky": "9.0.11", + "jest": "29.7.0", + "jsdoc": "4.0.3", + "mini-css-extract-plugin": "2.9.0", "node-sass": "9.0.0", "npm-run-all": "4.1.5", - "postcss": "8.4.24", - "postcss-cli": "10.1.0", - "postcss-loader": "7.3.3", - "prettier": "2.8.8", - "sass-loader": "13.3.2", - "style-loader": "3.3.3", - "terser-webpack-plugin": "5.3.9", - "ts-loader": "^9.4.4", - "typescript": "5.1.6", - "webpack": "5.88.1", - "webpack-bundle-analyzer": "^4.9.0", + "postcss": "8.4.38", + "postcss-cli": "11.0.0", + "postcss-loader": "8.1.1", + "prettier": "3.3.2", + "sass-loader": "14.2.1", + "style-loader": "4.0.0", + "terser-webpack-plugin": "5.3.10", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "5.92.0", + "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "5.1.4", "webpack-livereload-plugin": "3.0.2", "wp-hookdoc": "0.2.0" diff --git a/packages/eslint/package.json b/packages/eslint/package.json index c64259a2..e9e40962 100644 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -11,22 +11,22 @@ "test": "echo 'Nothing to test'" }, "dependencies": { - "@rushstack/eslint-patch": "^1.3.2", - "@typescript-eslint/eslint-plugin": "^5.61.0", - "@typescript-eslint/parser": "5.61.0", + "@rushstack/eslint-patch": "^1.10.3", + "@typescript-eslint/eslint-plugin": "^7.13.0", + "@typescript-eslint/parser": "7.13.0", "@wcpos/tsconfig": "*", - "eslint": "8.44.0", + "eslint": "9.5.0", "eslint-config-airbnb": "19.0.4", - "eslint-config-prettier": "8.8.0", - "eslint-config-universe": "^11.3.0", - "eslint-plugin-import": "2.27.5", - "eslint-plugin-jest": "27.2.2", - "eslint-plugin-jsx-a11y": "6.7.1", - "eslint-plugin-prettier": "4.2.1", - "eslint-plugin-react": "7.32.2", - "eslint-plugin-react-hooks": "4.6.0", - "eslint-plugin-react-native": "4.0.0", - "prettier": "2.8.8", - "typescript": "^5.1.6" + "eslint-config-prettier": "9.1.0", + "eslint-config-universe": "^13.0.0", + "eslint-plugin-import": "2.29.1", + "eslint-plugin-jest": "28.6.0", + "eslint-plugin-jsx-a11y": "6.8.0", + "eslint-plugin-prettier": "5.1.3", + "eslint-plugin-react": "7.34.2", + "eslint-plugin-react-hooks": "4.6.2", + "eslint-plugin-react-native": "4.1.0", + "prettier": "3.3.2", + "typescript": "^5.4.5" } } diff --git a/packages/settings/package.json b/packages/settings/package.json index 2d84a882..b5710482 100644 --- a/packages/settings/package.json +++ b/packages/settings/package.json @@ -5,67 +5,67 @@ "start": "../../node_modules/.bin/webpack --watch" }, "dependencies": { - "@headlessui/react": "^1.7.15", - "@headlessui/tailwindcss": "^0.1.3", - "@tanstack/react-query": "^4.29.19", - "@transifex/native": "^5.4.0", - "@transifex/react": "^5.4.0", - "@wordpress/api-fetch": "6.33.0", - "@wordpress/components": "^25.2.0", - "@wordpress/element": "5.13.0", - "@wordpress/url": "3.37.0", - "classnames": "2.3.2", + "@headlessui/react": "^2.0.4", + "@headlessui/tailwindcss": "^0.2.1", + "@tanstack/react-query": "^5.45.0", + "@transifex/native": "^7.1.1", + "@transifex/react": "^7.1.1", + "@wordpress/api-fetch": "7.0.0", + "@wordpress/components": "^28.0.0", + "@wordpress/element": "6.0.0", + "@wordpress/url": "4.0.0", + "classnames": "2.5.1", "lodash": "4.17.21", - "react": "18.2.0", + "react": "18.3.1", "react-beautiful-dnd": "13.1.1", - "react-dom": "18.2.0", - "react-error-boundary": "4.0.10" + "react-dom": "18.3.1", + "react-error-boundary": "4.0.13" }, "devDependencies": { - "@babel/core": "7.22.6", - "@babel/plugin-transform-runtime": "7.22.6", - "@babel/preset-env": "7.22.6", - "@babel/preset-react": "7.22.5", - "@babel/preset-typescript": "7.22.5", - "@babel/runtime": "7.22.6", - "@svgr/webpack": "8.0.1", - "@tanstack/react-query-devtools": "^4.29.19", - "@transifex/cli": "^5.4.0", - "@types/jest": "29.5.2", - "@types/lodash": "4.14.195", - "@types/react": "18.2.14", - "@types/react-beautiful-dnd": "13.1.4", - "@types/react-dom": "18.2.6", - "@types/wordpress__components": "^23.0.1", - "@typescript-eslint/eslint-plugin": "5.61.0", - "@typescript-eslint/parser": "5.61.0", + "@babel/core": "7.24.7", + "@babel/plugin-transform-runtime": "7.24.7", + "@babel/preset-env": "7.24.7", + "@babel/preset-react": "7.24.7", + "@babel/preset-typescript": "7.24.7", + "@babel/runtime": "7.24.7", + "@svgr/webpack": "8.1.0", + "@tanstack/react-query-devtools": "^5.45.0", + "@transifex/cli": "^7.1.1", + "@types/jest": "29.5.12", + "@types/lodash": "4.17.5", + "@types/react": "18.3.3", + "@types/react-beautiful-dnd": "13.1.8", + "@types/react-dom": "18.3.0", + "@types/wordpress__components": "^23.8.0", + "@typescript-eslint/eslint-plugin": "7.13.0", + "@typescript-eslint/parser": "7.13.0", "@wcpos/eslint-config": "*", - "@wordpress/env": "8.2.0", - "autoprefixer": "10.4.14", - "babel-loader": "9.1.2", - "css-loader": "6.8.1", - "css-minimizer-webpack-plugin": "^5.0.1", + "@wordpress/env": "10.0.0", + "autoprefixer": "10.4.19", + "babel-loader": "9.1.3", + "css-loader": "7.1.2", + "css-minimizer-webpack-plugin": "^7.0.0", "file-loader": "6.2.0", - "fork-ts-checker-webpack-plugin": "8.0.0", - "html-webpack-plugin": "5.5.3", - "husky": "8.0.3", - "jest": "29.6.0", - "jsdoc": "4.0.2", - "mini-css-extract-plugin": "2.7.6", + "fork-ts-checker-webpack-plugin": "9.0.2", + "html-webpack-plugin": "5.6.0", + "husky": "9.0.11", + "jest": "29.7.0", + "jsdoc": "4.0.3", + "mini-css-extract-plugin": "2.9.0", "node-sass": "9.0.0", "npm-run-all": "4.1.5", - "postcss": "8.4.24", - "postcss-cli": "10.1.0", - "postcss-loader": "7.3.3", - "prettier": "2.8.8", - "sass-loader": "13.3.2", - "style-loader": "3.3.3", - "tailwindcss": "3.3.2", - "terser-webpack-plugin": "5.3.9", - "ts-loader": "^9.4.4", - "typescript": "5.1.6", - "webpack": "5.88.1", - "webpack-bundle-analyzer": "^4.9.0", + "postcss": "8.4.38", + "postcss-cli": "11.0.0", + "postcss-loader": "8.1.1", + "prettier": "3.3.2", + "sass-loader": "14.2.1", + "style-loader": "4.0.0", + "tailwindcss": "3.4.4", + "terser-webpack-plugin": "5.3.10", + "ts-loader": "^9.5.1", + "typescript": "5.4.5", + "webpack": "5.92.0", + "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "5.1.4", "webpack-livereload-plugin": "3.0.2", "wp-hookdoc": "0.2.0" diff --git a/packages/settings/src/screens/footer.tsx b/packages/settings/src/screens/footer.tsx index 1f91ced0..f3c4b434 100644 --- a/packages/settings/src/screens/footer.tsx +++ b/packages/settings/src/screens/footer.tsx @@ -44,7 +44,7 @@ const Footer = () => { Discord Chat diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5abdf6fe..58cc0ce2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,6 +11,9 @@ use ReflectionException; use ReflectionProperty; +error_reporting( E_ALL ); +ini_set( 'display_errors', 1 ); + class Bootstrap { public $tests_dir; public $plugin_dir;