Fixed `@woocommerce/block-library` Build Dependencies & Output (#41992)
This commit is contained in:
commit
cc25b78cc1
|
@ -20,7 +20,7 @@ const runner = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const newAssets = require( '../../build/assets.json' );
|
||||
const newAssets = require( '../../../woocommerce/assets/client/blocks/assets.json' );
|
||||
|
||||
if ( ! newAssets ) {
|
||||
return;
|
||||
|
|
|
@ -1,25 +1,11 @@
|
|||
# WooCommerce Blocks <!-- omit in toc -->
|
||||
|
||||
[![Latest Tag](https://img.shields.io/github/tag/woocommerce/woocommerce-gutenberg-products-block.svg?style=flat&label=Latest%20Tag)](https://github.com/woocommerce/woocommerce-gutenberg-products-block/releases)
|
||||
[![View](https://img.shields.io/badge/Project%20Components-brightgreen.svg?style=flat)](https://woocommerce.github.io/woocommerce-blocks/)
|
||||
![JavaScript and CSS Linting](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/JavaScript%20and%20CSS%20Linting/badge.svg?branch=trunk)
|
||||
![PHP Coding Standards](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/PHP%20Coding%20Standards/badge.svg?branch=trunk)
|
||||
![Unit Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/E2E%20tests/badge.svg?branch=trunk)
|
||||
![E2E Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/Unit%20Tests/badge.svg?branch=trunk)
|
||||
|
||||
This is the feature plugin for WooCommerce + the Gutenberg. This plugin serves as a space to iterate and explore new Blocks and updates to existing blocks for WooCommerce, and how WooCommerce might work with the block editor.
|
||||
|
||||
Use this plugin if you want access to the bleeding edge of available blocks for WooCommerce. However, stable blocks are bundled into WooCommerce, and can be added from the "WooCommerce" section in the block inserter.
|
||||
|
||||
- [WCCOM product page](https://woocommerce.com/products/woocommerce-gutenberg-products-block/)
|
||||
- [User documentation](https://docs.woocommerce.com/document/woocommerce-blocks/)
|
||||
This is the client for WooCommerce + Gutenberg. This package serves as a space to iterate and explore new Blocks and updates to existing blocks for WooCommerce, and how WooCommerce might work with the block editor.
|
||||
|
||||
## Table of Contents <!-- omit in toc -->
|
||||
|
||||
- [Documentation](#documentation)
|
||||
- [Code Documentation](#code-documentation)
|
||||
- [Installing the plugin version](#installing-the-plugin-version)
|
||||
- [Installing the development version](#installing-the-development-version)
|
||||
- [Getting started with block development](#getting-started-with-block-development)
|
||||
- [Long-term vision](#long-term-vision)
|
||||
|
||||
|
@ -36,39 +22,12 @@ If you want to see what we're working on for future versions, or want to help ou
|
|||
- [WooCommerce Blocks Handbook](./docs) - Documentation for designers and developers on how to extend or contribute to blocks, and how internal developers should handle new releases.
|
||||
- [WooCommerce Blocks Storybook](https://woocommerce.github.io/woocommerce-blocks/) - Contains a list and demo of components used in the plugin.
|
||||
|
||||
## Installing the plugin version
|
||||
|
||||
We release a new version of WooCommerce Blocks onto WordPress.org every few weeks, which can be used as an easier way to preview the features.
|
||||
|
||||
> Note: The plugin follows a policy of supporting the "L0" strategy for version support. What this means is that the plugin will require the most recent version of WordPress. It will also require the most recent version of WooCommerce core at the time of a release. You can read more about [this policy here](https://developer.woocommerce.com/?p=9998).
|
||||
|
||||
1.Ensure you have the latest available versions of WordPress and WooCommerce installed on your site.
|
||||
2. The plugin version is available on WordPress.org. [Download the plugin version here.](https://wordpress.org/plugins/woo-gutenberg-products-block/)
|
||||
3. Activate the plugin.
|
||||
|
||||
## Installing the development version
|
||||
|
||||
1. Ensure you have the latest versions of WordPress and WooCommerce installed on your site.
|
||||
2. Get a copy of this plugin using the green "Clone or download" button on the right.
|
||||
3. Make sure you're using Node.js v16.15. If you use a Node version management tool such as `nvm` or `n`, you can do so by running `nvm use` or `n auto`, respectively.
|
||||
4. `npm install` to install the dependencies.
|
||||
5. `composer install` to install core dependencies.
|
||||
6. To compile the code, run any of the following commands
|
||||
1. `npm run build` (production build).
|
||||
2. `npm run dev` (development build).
|
||||
3. `npm start` (development build + watching for changes).
|
||||
7. Activate the plugin.
|
||||
|
||||
The source code is in the `assets/` folder, and the compiled code is stored into `build/`.
|
||||
|
||||
## Getting started with block development
|
||||
|
||||
Run through the ["Writing Your First Block Type" tutorial](https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/) for a quick course in block-building.
|
||||
|
||||
For deeper dive, try looking at the [core blocks code,](https://github.com/WordPress/gutenberg/tree/master/packages/block-library/src) or see what [components are available.](https://github.com/WordPress/gutenberg/tree/master/packages/components/src)
|
||||
|
||||
To begin contributing to the WooCommerce Blocks plugin, see our [getting started guide](./docs/contributors/getting-started.md) and [developer handbook](./docs/README.md).
|
||||
|
||||
Other useful docs to explore:
|
||||
|
||||
- [`InnerBlocks`](https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md)
|
||||
|
|
|
@ -30,8 +30,8 @@ export const blocksConfig = getSetting( 'wcBlocksConfig', {
|
|||
wordCountType: 'words',
|
||||
} ) as WcBlocksConfig;
|
||||
|
||||
export const WC_BLOCKS_IMAGE_URL = blocksConfig.pluginUrl + 'images/';
|
||||
export const WC_BLOCKS_BUILD_URL = blocksConfig.pluginUrl + 'build/';
|
||||
export const WC_BLOCKS_IMAGE_URL = blocksConfig.pluginUrl + 'assets/images/';
|
||||
export const WC_BLOCKS_BUILD_URL = blocksConfig.pluginUrl + 'assets/client/blocks/';
|
||||
export const WC_BLOCKS_PHASE = blocksConfig.buildPhase;
|
||||
export const SHOP_URL = STORE_PAGES.shop?.permalink;
|
||||
export const CHECKOUT_PAGE_ID = STORE_PAGES.checkout?.id;
|
||||
|
|
|
@ -84,7 +84,7 @@ const getCoreConfig = ( options = {} ) => {
|
|||
filename: ( chunkData ) => {
|
||||
return `${ paramCase( chunkData.chunk.name ) }.js`;
|
||||
},
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
library: [ 'wc', '[name]' ],
|
||||
libraryTarget: 'this',
|
||||
uniqueName: 'webpackWcBlocksJsonp',
|
||||
|
@ -117,7 +117,7 @@ const getCoreConfig = ( options = {} ) => {
|
|||
...getSharedPlugins( { bundleAnalyzerReportTitle: 'Core' } ),
|
||||
new ProgressBarPlugin( getProgressBarPluginConfig( 'Core' ) ),
|
||||
new CreateFileWebpack( {
|
||||
path: './',
|
||||
path: '../woocommerce',
|
||||
// file name
|
||||
fileName: 'blocks.ini',
|
||||
// content of the file
|
||||
|
@ -183,7 +183,7 @@ const getMainConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'main', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
// This is a cache busting mechanism which ensures that the script is loaded via the browser with a ?ver=hash
|
||||
// string. The hash is based on the built file contents.
|
||||
// @see https://github.com/webpack/webpack/issues/2329
|
||||
|
@ -317,7 +317,7 @@ const getFrontConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'frontend', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
// This is a cache busting mechanism which ensures that the script is loaded via the browser with a ?ver=hash
|
||||
// string. The hash is based on the built file contents.
|
||||
// @see https://github.com/webpack/webpack/issues/2329
|
||||
|
@ -442,7 +442,7 @@ const getPaymentsConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'payments', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
filename: `[name].js`,
|
||||
uniqueName: 'webpackWcBlocksPaymentMethodExtensionJsonp',
|
||||
},
|
||||
|
@ -549,7 +549,7 @@ const getExtensionsConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'extensions', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
filename: `[name].js`,
|
||||
uniqueName: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
|
||||
},
|
||||
|
@ -656,7 +656,7 @@ const getSiteEditorConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'editor', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
filename: `[name].js`,
|
||||
chunkLoadingGlobal: 'webpackWcBlocksExtensionsMethodExtensionJsonp',
|
||||
},
|
||||
|
@ -763,7 +763,7 @@ const getStylingConfig = ( options = {} ) => {
|
|||
entry: getEntryConfig( 'styling', options.exclude || [] ),
|
||||
output: {
|
||||
devtoolNamespace: 'wc',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
filename: `[name]-style${ fileSuffix }.js`,
|
||||
library: [ 'wc', 'blocks', '[name]' ],
|
||||
libraryTarget: 'this',
|
||||
|
@ -914,7 +914,7 @@ const getInteractivityAPIConfig = ( options = {} ) => {
|
|||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
path: path.resolve( __dirname, '../build/' ),
|
||||
path: path.resolve( __dirname, '../../woocommerce/assets/client/blocks/' ),
|
||||
library: [ 'wc', '__experimentalInteractivity' ],
|
||||
libraryTarget: 'this',
|
||||
chunkLoadingGlobal: 'webpackWcBlocksJsonp',
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
"@babel/plugin-proposal-class-properties": "7.18.6",
|
||||
"@babel/plugin-proposal-optional-chaining": "7.21.0",
|
||||
"@babel/plugin-syntax-jsx": "7.22.5",
|
||||
"@babel/preset-react": "7.23.3",
|
||||
"@babel/polyfill": "7.12.1",
|
||||
"@babel/preset-typescript": "7.23.2",
|
||||
"@bartekbp/typescript-checkstyle": "5.0.0",
|
||||
|
@ -144,6 +145,7 @@
|
|||
"@types/jest-environment-puppeteer": "5.0.2",
|
||||
"@types/jquery": "3.5.14",
|
||||
"@types/lodash": "4.14.182",
|
||||
"@types/prop-types": "^15.7.11",
|
||||
"@types/puppeteer": "5.4.6",
|
||||
"@types/react": "^17.0.71",
|
||||
"@types/react-dom": "18.0.10",
|
||||
|
@ -292,6 +294,7 @@
|
|||
"html-react-parser": "3.0.4",
|
||||
"postcode-validator": "3.8.15",
|
||||
"preact": "^10.19.3",
|
||||
"prop-types": "^15.8.1",
|
||||
"react-number-format": "4.9.3",
|
||||
"react-transition-group": "^4.4.5",
|
||||
"reakit": "1.3.11",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @package WooCommerce Blocks
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks;
|
||||
|
||||
// Require composer dependencies.
|
||||
require_once dirname( __DIR__ ) . '/vendor/autoload.php';
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# Built JS
|
||||
/assets/js/*
|
||||
/assets/client/*
|
||||
/blocks.ini
|
||||
|
||||
# Behat/CLI Tests
|
||||
tests/cli/installer
|
||||
|
|
|
@ -54,6 +54,19 @@ pnpm run --filter=woocommerce/client/admin lint
|
|||
pnpm run --filter=woocommerce/client/admin test
|
||||
```
|
||||
|
||||
### `plugins/woocommerce-blocks`
|
||||
|
||||
This directory contains the client for WooCommerce + Gutenberg.
|
||||
|
||||
```bash
|
||||
# Build the Blocks client.
|
||||
pnpm run --filter=@woocommerce/block-library build
|
||||
# Lint the Blocks client.
|
||||
pnpm run --filter=@woocommerce/block-library lint
|
||||
# Test the Blocks client.
|
||||
pnpm run --filter=@woocommerce/block-library test
|
||||
```
|
||||
|
||||
#### Helper Scripts
|
||||
|
||||
Here is a collection of scripts that can help when developing the React-based admin interface.
|
||||
|
|
|
@ -67,7 +67,11 @@
|
|||
},
|
||||
"psr-0": {
|
||||
"Automattic\\WooCommerce\\Vendor\\": "lib/packages/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"src/StoreApi/deprecated.php",
|
||||
"src/StoreApi/functions.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -3808,7 +3808,7 @@
|
|||
},
|
||||
{
|
||||
"name": "woocommerce/monorepo-plugin",
|
||||
"version": "dev-merge/move-blocks-php-and-assets",
|
||||
"version": "dev-fix/block-library-build",
|
||||
"dist": {
|
||||
"type": "path",
|
||||
"url": "../../packages/php/monorepo-plugin",
|
||||
|
|
|
@ -103,12 +103,12 @@ class Api {
|
|||
* Get the path to a block's metadata
|
||||
*
|
||||
* @param string $block_name The block to get metadata for.
|
||||
* @param string $path Optional. The path to the metadata file inside the 'build' folder.
|
||||
* @param string $path Optional. The path to the metadata file inside the 'assets/client/blocks' folder.
|
||||
*
|
||||
* @return string|boolean False if metadata file is not found for the block.
|
||||
*/
|
||||
public function get_block_metadata_path( $block_name, $path = '' ) {
|
||||
$path_to_metadata_from_plugin_root = $this->package->get_path( 'build/' . $path . $block_name . '/block.json' );
|
||||
$path_to_metadata_from_plugin_root = $this->package->get_path( 'assets/client/blocks/' . $path . $block_name . '/block.json' );
|
||||
if ( ! file_exists( $path_to_metadata_from_plugin_root ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ class Api {
|
|||
* @param boolean $rtl Optional. Whether or not to register RTL styles.
|
||||
*/
|
||||
public function register_style( $handle, $relative_src, $deps = [], $media = 'all', $rtl = false ) {
|
||||
$filename = str_replace( plugins_url( '/', __DIR__ ), '', $relative_src );
|
||||
$filename = str_replace( plugins_url( '/', dirname( __DIR__ ) ), '', $relative_src );
|
||||
$src = $this->get_asset_url( $relative_src );
|
||||
$ver = $this->get_file_version( $filename );
|
||||
wp_register_style( $handle, $src, $deps, $ver, $media );
|
||||
|
@ -302,7 +302,7 @@ class Api {
|
|||
* @return string The generated path.
|
||||
*/
|
||||
public function get_block_asset_build_path( $filename, $type = 'js' ) {
|
||||
return "build/$filename.$type";
|
||||
return "assets/client/blocks/$filename.$type";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -373,7 +373,7 @@ class AssetDataRegistry {
|
|||
public function register_data_script() {
|
||||
$this->api->register_script(
|
||||
$this->handle,
|
||||
'build/wc-settings.js',
|
||||
'assets/client/blocks/wc-settings.js',
|
||||
[ 'wp-api-fetch' ],
|
||||
true
|
||||
);
|
||||
|
|
|
@ -46,26 +46,26 @@ final class AssetsController {
|
|||
* Register block scripts & styles.
|
||||
*/
|
||||
public function register_assets() {
|
||||
$this->register_style( 'wc-blocks-packages-style', plugins_url( $this->api->get_block_asset_build_path( 'packages-style', 'css' ), __DIR__ ), [], 'all', true );
|
||||
$this->register_style( 'wc-blocks-style', plugins_url( $this->api->get_block_asset_build_path( 'wc-blocks', 'css' ), __DIR__ ), [], 'all', true );
|
||||
$this->register_style( 'wc-blocks-editor-style', plugins_url( $this->api->get_block_asset_build_path( 'wc-blocks-editor-style', 'css' ), __DIR__ ), [ 'wp-edit-blocks' ], 'all', true );
|
||||
$this->register_style( 'wc-blocks-packages-style', plugins_url( $this->api->get_block_asset_build_path( 'packages-style', 'css' ), dirname( __DIR__ ) ), [], 'all', true );
|
||||
$this->register_style( 'wc-blocks-style', plugins_url( $this->api->get_block_asset_build_path( 'wc-blocks', 'css' ), dirname( __DIR__ ) ), [], 'all', true );
|
||||
$this->register_style( 'wc-blocks-editor-style', plugins_url( $this->api->get_block_asset_build_path( 'wc-blocks-editor-style', 'css' ), dirname( __DIR__ ) ), [ 'wp-edit-blocks' ], 'all', true );
|
||||
|
||||
$this->api->register_script( 'wc-blocks-middleware', 'build/wc-blocks-middleware.js', [], false );
|
||||
$this->api->register_script( 'wc-blocks-data-store', 'build/wc-blocks-data.js', [ 'wc-blocks-middleware' ] );
|
||||
$this->api->register_script( 'wc-blocks-middleware', 'assets/client/blocks/wc-blocks-middleware.js', [], false );
|
||||
$this->api->register_script( 'wc-blocks-data-store', 'assets/client/blocks/wc-blocks-data.js', [ 'wc-blocks-middleware' ] );
|
||||
$this->api->register_script( 'wc-blocks-vendors', $this->api->get_block_asset_build_path( 'wc-blocks-vendors' ), [], false );
|
||||
$this->api->register_script( 'wc-blocks-registry', 'build/wc-blocks-registry.js', [], false );
|
||||
$this->api->register_script( 'wc-blocks-registry', 'assets/client/blocks/wc-blocks-registry.js', [], false );
|
||||
$this->api->register_script( 'wc-blocks', $this->api->get_block_asset_build_path( 'wc-blocks' ), [ 'wc-blocks-vendors' ], false );
|
||||
$this->api->register_script( 'wc-blocks-shared-context', 'build/wc-blocks-shared-context.js' );
|
||||
$this->api->register_script( 'wc-blocks-shared-hocs', 'build/wc-blocks-shared-hocs.js', [], false );
|
||||
$this->api->register_script( 'wc-blocks-shared-context', 'assets/client/blocks/wc-blocks-shared-context.js' );
|
||||
$this->api->register_script( 'wc-blocks-shared-hocs', 'assets/client/blocks/wc-blocks-shared-hocs.js', [], false );
|
||||
|
||||
// The price package is shared externally so has no blocks prefix.
|
||||
$this->api->register_script( 'wc-price-format', 'build/price-format.js', [], false );
|
||||
$this->api->register_script( 'wc-price-format', 'assets/client/blocks/price-format.js', [], false );
|
||||
|
||||
$this->api->register_script( 'wc-blocks-checkout', 'build/blocks-checkout.js', [] );
|
||||
$this->api->register_script( 'wc-blocks-components', 'build/blocks-components.js', [] );
|
||||
$this->api->register_script( 'wc-blocks-checkout', 'assets/client/blocks/blocks-checkout.js', [] );
|
||||
$this->api->register_script( 'wc-blocks-components', 'assets/client/blocks/blocks-components.js', [] );
|
||||
|
||||
// Register the interactivity components here for now.
|
||||
$this->api->register_script( 'wc-interactivity-dropdown', 'build/wc-interactivity-dropdown.js', [] );
|
||||
$this->api->register_script( 'wc-interactivity-dropdown', 'assets/client/blocks/wc-interactivity-dropdown.js', [] );
|
||||
|
||||
wp_add_inline_script(
|
||||
'wc-blocks-middleware',
|
||||
|
@ -83,8 +83,8 @@ final class AssetsController {
|
|||
* Register and enqueue assets for exclusive usage within the Site Editor.
|
||||
*/
|
||||
public function register_and_enqueue_site_editor_assets() {
|
||||
$this->api->register_script( 'wc-blocks-classic-template-revert-button', 'build/wc-blocks-classic-template-revert-button.js' );
|
||||
$this->api->register_style( 'wc-blocks-classic-template-revert-button-style', 'build/wc-blocks-classic-template-revert-button-style.css' );
|
||||
$this->api->register_script( 'wc-blocks-classic-template-revert-button', 'assets/client/blocks/wc-blocks-classic-template-revert-button.js' );
|
||||
$this->api->register_style( 'wc-blocks-classic-template-revert-button-style', 'assets/client/blocks/wc-blocks-classic-template-revert-button-style.css' );
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
if ( $current_screen instanceof \WP_Screen && 'site-editor' === $current_screen->base ) {
|
||||
|
@ -290,7 +290,7 @@ final class AssetsController {
|
|||
* @param boolean $rtl Optional. Whether or not to register RTL styles.
|
||||
*/
|
||||
protected function register_style( $handle, $src, $deps = [], $media = 'all', $rtl = false ) {
|
||||
$filename = str_replace( plugins_url( '/', __DIR__ ), '', $src );
|
||||
$filename = str_replace( plugins_url( '/', dirname( __DIR__ ) ), '', $src );
|
||||
$ver = self::get_file_version( $filename );
|
||||
|
||||
wp_register_style( $handle, $src, $deps, $ver, $media );
|
||||
|
|
|
@ -180,7 +180,7 @@ abstract class AbstractBlock {
|
|||
* @return string[] $chunks list of chunks to load.
|
||||
*/
|
||||
protected function get_chunks_paths( $chunks_folder ) {
|
||||
$build_path = \Automattic\WooCommerce\Blocks\Package::get_path() . 'build/';
|
||||
$build_path = \Automattic\WooCommerce\Blocks\Package::get_path() . 'assets/client/blocks/';
|
||||
$blocks = [];
|
||||
if ( ! is_dir( $build_path . $chunks_folder ) ) {
|
||||
return [];
|
||||
|
@ -429,7 +429,7 @@ abstract class AbstractBlock {
|
|||
'wcBlocksConfig',
|
||||
[
|
||||
'buildPhase' => Package::feature()->get_flag(),
|
||||
'pluginUrl' => plugins_url( '/', dirname( __DIR__ ) ),
|
||||
'pluginUrl' => plugins_url( '/', dirname( __DIR__, 2 ) ),
|
||||
'productCount' => array_sum( (array) wp_count_posts( 'product' ) ),
|
||||
'restApiRoutes' => [
|
||||
'/wc/store/v1' => array_keys( $this->get_routes_from_namespace( 'wc/store/v1' ) ),
|
||||
|
|
|
@ -353,7 +353,7 @@ class Checkout extends AbstractBlock {
|
|||
$declared_extensions['incompatible'],
|
||||
function( $acc, $item ) use ( $all_plugins ) {
|
||||
$plugin = $all_plugins[ $item ] ?? null;
|
||||
$plugin_id = $plugin['TextDomain'] ?? dirname( $item );
|
||||
$plugin_id = $plugin['TextDomain'] ?? dirname( $item, 2 );
|
||||
$plugin_name = $plugin['Name'] ?? $plugin_id;
|
||||
$acc[] = [
|
||||
'id' => $plugin_id,
|
||||
|
|
|
@ -206,7 +206,7 @@ class MiniCart extends AbstractBlock {
|
|||
* Prints the variable containing information about the scripts to lazy load.
|
||||
*/
|
||||
public function print_lazy_load_scripts() {
|
||||
$script_data = $this->asset_api->get_script_data( 'build/mini-cart-component-frontend.js' );
|
||||
$script_data = $this->asset_api->get_script_data( 'assets/client/blocks/mini-cart-component-frontend.js' );
|
||||
|
||||
$num_dependencies = is_countable( $script_data['dependencies'] ) ? count( $script_data['dependencies'] ) : 0;
|
||||
$wp_scripts = wp_scripts();
|
||||
|
@ -261,7 +261,7 @@ class MiniCart extends AbstractBlock {
|
|||
);
|
||||
}
|
||||
foreach ( $inner_blocks_frontend_scripts as $inner_block_frontend_script ) {
|
||||
$script_data = $this->asset_api->get_script_data( 'build/mini-cart-contents-block/' . $inner_block_frontend_script . '.js' );
|
||||
$script_data = $this->asset_api->get_script_data( 'assets/client/blocks/mini-cart-contents-block/' . $inner_block_frontend_script . '.js' );
|
||||
$this->scripts_to_lazy_load[ 'wc-block-' . $inner_block_frontend_script ] = array(
|
||||
'src' => $script_data['src'],
|
||||
'version' => $script_data['version'],
|
||||
|
|
|
@ -77,22 +77,20 @@ class Bootstrap {
|
|||
$this->package = $container->get( Package::class );
|
||||
$this->migration = $container->get( Migration::class );
|
||||
|
||||
if ( $this->has_core_dependencies() ) {
|
||||
$this->init();
|
||||
/**
|
||||
* Fires when the woocommerce blocks are loaded and ready to use.
|
||||
*
|
||||
* This hook is intended to be used as a safe event hook for when the plugin
|
||||
* has been loaded, and all dependency requirements have been met.
|
||||
*
|
||||
* To ensure blocks are initialized, you must use the `woocommerce_blocks_loaded`
|
||||
* hook instead of the `plugins_loaded` hook. This is because the functions
|
||||
* hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
do_action( 'woocommerce_blocks_loaded' );
|
||||
}
|
||||
$this->init();
|
||||
/**
|
||||
* Fires when the woocommerce blocks are loaded and ready to use.
|
||||
*
|
||||
* This hook is intended to be used as a safe event hook for when the plugin
|
||||
* has been loaded, and all dependency requirements have been met.
|
||||
*
|
||||
* To ensure blocks are initialized, you must use the `woocommerce_blocks_loaded`
|
||||
* hook instead of the `plugins_loaded` hook. This is because the functions
|
||||
* hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
do_action( 'woocommerce_blocks_loaded' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,39 +159,6 @@ class Bootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check core dependencies exist.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function has_core_dependencies() {
|
||||
$has_needed_dependencies = class_exists( 'WooCommerce', false );
|
||||
if ( $has_needed_dependencies ) {
|
||||
$plugin_data = \get_file_data(
|
||||
$this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
|
||||
[
|
||||
'RequiredWCVersion' => 'WC requires at least',
|
||||
]
|
||||
);
|
||||
if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
|
||||
$has_needed_dependencies = false;
|
||||
add_action(
|
||||
'admin_notices',
|
||||
function() {
|
||||
if ( should_display_compatibility_notices() ) {
|
||||
?>
|
||||
<div class="notice notice-error">
|
||||
<p><?php esc_html_e( 'The WooCommerce Blocks plugin requires a more recent version of WooCommerce and has been deactivated. Please update to the latest version of WooCommerce.', 'woo-gutenberg-products-block' ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
return $has_needed_dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* See if files have been built or not.
|
||||
*
|
||||
|
@ -201,7 +166,7 @@ class Bootstrap {
|
|||
*/
|
||||
protected function is_built() {
|
||||
return file_exists(
|
||||
$this->package->get_path( 'build/featured-product.js' )
|
||||
$this->package->get_path( 'assets/client/blocks/featured-product.js' )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ class FeatureGating {
|
|||
public function load_flag() {
|
||||
if ( 0 === $this->flag ) {
|
||||
$default_flag = defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ? self::FEATURE_PLUGIN_FLAG : self::CORE_FLAG;
|
||||
if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
|
||||
if ( file_exists( __DIR__ . '/../../../../blocks.ini' ) ) {
|
||||
$allowed_flags = [ self::EXPERIMENTAL_FLAG, self::FEATURE_PLUGIN_FLAG, self::CORE_FLAG ];
|
||||
$woo_options = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
|
||||
$woo_options = parse_ini_file( __DIR__ . '/../../../../blocks.ini' );
|
||||
$this->flag = is_array( $woo_options ) && in_array( intval( $woo_options['woocommerce_blocks_phase'] ), $allowed_flags, true ) ? $woo_options['woocommerce_blocks_phase'] : $default_flag;
|
||||
} else {
|
||||
$this->flag = $default_flag;
|
||||
|
@ -64,9 +64,9 @@ class FeatureGating {
|
|||
*/
|
||||
public function load_environment() {
|
||||
if ( 'unset' === $this->environment ) {
|
||||
if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
|
||||
if ( file_exists( __DIR__ . '/../../../../blocks.ini' ) ) {
|
||||
$allowed_environments = [ self::PRODUCTION_ENVIRONMENT, self::DEVELOPMENT_ENVIRONMENT, self::TEST_ENVIRONMENT ];
|
||||
$woo_options = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
|
||||
$woo_options = parse_ini_file( __DIR__ . '/../../../../blocks.ini' );
|
||||
$this->environment = is_array( $woo_options ) && in_array( $woo_options['woocommerce_blocks_env'], $allowed_environments, true ) ? $woo_options['woocommerce_blocks_env'] : self::PRODUCTION_ENVIRONMENT;
|
||||
} else {
|
||||
$this->environment = self::PRODUCTION_ENVIRONMENT;
|
||||
|
@ -171,8 +171,8 @@ class FeatureGating {
|
|||
* @return boolean
|
||||
*/
|
||||
public function is_block_templates_controller_refactor_enabled() {
|
||||
if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
|
||||
$conf = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
|
||||
if ( file_exists( __DIR__ . '/../../../../blocks.ini' ) ) {
|
||||
$conf = parse_ini_file( __DIR__ . '/../../../../blocks.ini' );
|
||||
return $this->is_development_environment() && isset( $conf['use_block_templates_controller_refactor'] ) && true === (bool) $conf['use_block_templates_controller_refactor'];
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -41,7 +41,7 @@ class GoogleAnalytics {
|
|||
* Register scripts.
|
||||
*/
|
||||
public function register_assets() {
|
||||
$this->asset_api->register_script( 'wc-blocks-google-analytics', 'build/wc-blocks-google-analytics.js', [ 'google-tag-manager' ] );
|
||||
$this->asset_api->register_script( 'wc-blocks-google-analytics', 'assets/client/blocks/wc-blocks-google-analytics.js', [ 'google-tag-manager' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ function woocommerce_interactivity_register_runtime() {
|
|||
$plugin_path = \Automattic\WooCommerce\Blocks\Package::get_path();
|
||||
$plugin_url = plugin_dir_url( $plugin_path . '/index.php' );
|
||||
|
||||
$file = 'build/wc-interactivity.js';
|
||||
$file = 'assets/client/blocks/wc-interactivity.js';
|
||||
|
||||
$file_path = $plugin_path . $file;
|
||||
$file_url = $plugin_url . $file;
|
||||
|
|
|
@ -112,7 +112,7 @@ class Package {
|
|||
$version = '11.8.0-dev';
|
||||
return new NewPackage(
|
||||
$version,
|
||||
dirname( __DIR__ ),
|
||||
dirname( __DIR__, 2 ),
|
||||
new FeatureGating()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class PatternsHelper {
|
|||
public static function get_image_url( array $images, int $index, string $default_image ): string {
|
||||
$image = filter_var( $default_image, FILTER_VALIDATE_URL )
|
||||
? $default_image
|
||||
: plugins_url( $default_image, dirname( __DIR__ ) );
|
||||
: plugins_url( $default_image, dirname( __DIR__, 2 ) );
|
||||
|
||||
if ( isset( $images[ $index ] ) ) {
|
||||
$image = $images[ $index ];
|
||||
|
|
|
@ -11,37 +11,37 @@ class ProductUpdater {
|
|||
const DUMMY_PRODUCTS = [
|
||||
[
|
||||
'title' => 'Vintage Typewriter',
|
||||
'image' => 'images/pattern-placeholders/writing-typing-keyboard-technology-white-vintage.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/writing-typing-keyboard-technology-white-vintage.jpg',
|
||||
'description' => 'A hit spy novel or a love letter? Anything you type using this vintage typewriter from the 20s is bound to make a mark.',
|
||||
'price' => 90,
|
||||
],
|
||||
[
|
||||
'title' => 'Leather-Clad Leisure Chair',
|
||||
'image' => 'images/pattern-placeholders/table-wood-house-chair-floor-window.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/table-wood-house-chair-floor-window.jpg',
|
||||
'description' => 'Sit back and relax in this comfy designer chair. High-grain leather and steel frame add luxury to your your leisure.',
|
||||
'price' => 249,
|
||||
],
|
||||
[
|
||||
'title' => 'Black and White Summer Portrait',
|
||||
'image' => 'images/pattern-placeholders/white-black-black-and-white-photograph-monochrome-photography.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/white-black-black-and-white-photograph-monochrome-photography.jpg',
|
||||
'description' => 'This 24" x 30" high-quality print just exudes summer. Hang it on the wall and forget about the world outside.',
|
||||
'price' => 115,
|
||||
],
|
||||
[
|
||||
'title' => '3-Speed Bike',
|
||||
'image' => 'images/pattern-placeholders/road-sport-vintage-wheel-retro-old.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/road-sport-vintage-wheel-retro-old.jpg',
|
||||
'description' => 'Zoom through the streets on this premium 3-speed bike. Manufactured and assembled in Germany in the 80s.',
|
||||
'price' => 115,
|
||||
],
|
||||
[
|
||||
'title' => 'Hi-Fi Headphones',
|
||||
'image' => 'images/pattern-placeholders/man-person-music-black-and-white-white-photography.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/man-person-music-black-and-white-white-photography.jpg',
|
||||
'description' => 'Experience your favorite songs in a new way with these premium hi-fi headphones.',
|
||||
'price' => 125,
|
||||
],
|
||||
[
|
||||
'title' => 'Retro Glass Jug (330 ml)',
|
||||
'image' => 'images/pattern-placeholders/drinkware-liquid-tableware-dishware-bottle-fluid.jpg',
|
||||
'image' => 'assets/images/pattern-placeholders/drinkware-liquid-tableware-dishware-bottle-fluid.jpg',
|
||||
'description' => 'Thick glass and a classic silhouette make this jug a must-have for any retro-inspired kitchen.',
|
||||
'price' => 115,
|
||||
],
|
||||
|
@ -208,7 +208,7 @@ class ProductUpdater {
|
|||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image.php';
|
||||
|
||||
$product_image_id = media_sideload_image( plugins_url( $product_data['image'], dirname( __DIR__ ) ), $product->get_id(), $product_data['title'], 'id' );
|
||||
$product_image_id = media_sideload_image( plugins_url( $product_data['image'], dirname( __DIR__, 2 ) ), $product->get_id(), $product_data['title'], 'id' );
|
||||
if ( is_wp_error( $product_image_id ) ) {
|
||||
return new \WP_Error( 'error_uploading_image', $product_image_id->get_error_message() );
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ class ProductUpdater {
|
|||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image.php';
|
||||
|
||||
$product_image_id = media_sideload_image( plugins_url( self::DUMMY_PRODUCTS[ $i ]['image'], dirname( __DIR__ ) ), $product->get_id(), self::DUMMY_PRODUCTS[ $i ]['title'], 'id' );
|
||||
$product_image_id = media_sideload_image( plugins_url( self::DUMMY_PRODUCTS[ $i ]['image'], dirname( __DIR__, 2 ) ), $product->get_id(), self::DUMMY_PRODUCTS[ $i ]['title'], 'id' );
|
||||
$product_image_id = $product->set_image_id( $product_image_id );
|
||||
|
||||
$product->save();
|
||||
|
|
|
@ -56,7 +56,7 @@ final class BankTransfer extends AbstractPaymentMethodType {
|
|||
public function get_payment_method_script_handles() {
|
||||
$this->asset_api->register_script(
|
||||
'wc-payment-method-bacs',
|
||||
'build/wc-payment-method-bacs.js'
|
||||
'assets/client/blocks/wc-payment-method-bacs.js'
|
||||
);
|
||||
return [ 'wc-payment-method-bacs' ];
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ final class CashOnDelivery extends AbstractPaymentMethodType {
|
|||
public function get_payment_method_script_handles() {
|
||||
$this->asset_api->register_script(
|
||||
'wc-payment-method-cod',
|
||||
'build/wc-payment-method-cod.js'
|
||||
'assets/client/blocks/wc-payment-method-cod.js'
|
||||
);
|
||||
return [ 'wc-payment-method-cod' ];
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ final class Cheque extends AbstractPaymentMethodType {
|
|||
public function get_payment_method_script_handles() {
|
||||
$this->asset_api->register_script(
|
||||
'wc-payment-method-cheque',
|
||||
'build/wc-payment-method-cheque.js'
|
||||
'assets/client/blocks/wc-payment-method-cheque.js'
|
||||
);
|
||||
return [ 'wc-payment-method-cheque' ];
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ final class PayPal extends AbstractPaymentMethodType {
|
|||
public function get_payment_method_script_handles() {
|
||||
$this->asset_api->register_script(
|
||||
'wc-payment-method-paypal',
|
||||
'build/wc-payment-method-paypal.js'
|
||||
'assets/client/blocks/wc-payment-method-paypal.js'
|
||||
);
|
||||
return [ 'wc-payment-method-paypal' ];
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ class ShippingController {
|
|||
* Load admin scripts.
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
$this->asset_api->register_script( 'wc-shipping-method-pickup-location', 'build/wc-shipping-method-pickup-location.js', [], true );
|
||||
$this->asset_api->register_script( 'wc-shipping-method-pickup-location', 'assets/client/blocks/wc-shipping-method-pickup-location.js', [], true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -293,7 +293,7 @@ class BlockTemplateUtils {
|
|||
* @return string
|
||||
*/
|
||||
public static function get_templates_directory( $template_type = 'wp_template' ) {
|
||||
$root_path = dirname( __DIR__, 2 ) . '/' . self::TEMPLATES_ROOT_DIR . DIRECTORY_SEPARATOR;
|
||||
$root_path = dirname( __DIR__, 3 ) . '/' . self::TEMPLATES_ROOT_DIR . DIRECTORY_SEPARATOR;
|
||||
$templates_directory = $root_path . self::DIRECTORY_NAMES['TEMPLATES'];
|
||||
$template_parts_directory = $root_path . self::DIRECTORY_NAMES['TEMPLATE_PARTS'];
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @package WooCommerce\AI\Tests
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\AI;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\AI;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\AI\Connection;
|
||||
use \WP_UnitTestCase;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Assets;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Assets;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Assets\Api;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Mocks\AssetDataRegistryMock;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Mocks\AssetDataRegistryMock;
|
||||
use Automattic\WooCommerce\Blocks\Package;
|
||||
use InvalidArgumentException;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\BlockTypes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\BlockTypes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\Mocks\CartCheckoutUtilsMock;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Mocks\CartCheckoutUtilsMock;
|
||||
|
||||
/**
|
||||
* Tests for the Cart block type
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\BlockTypes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\BlockTypes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\Mocks\ProductCollectionMock;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Mocks\ProductCollectionMock;
|
||||
|
||||
/**
|
||||
* Tests for the ProductCollection block type
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\BlockTypes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\BlockTypes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\Mocks\ProductQueryMock;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Mocks\ProductQueryMock;
|
||||
|
||||
/**
|
||||
* Tests for the ProductQuery block type
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* bootstrap.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Bootstrap;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Bootstrap;
|
||||
|
||||
use \WP_UnitTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Bootstrap;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Domain\Package;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Domain\Package;
|
||||
|
||||
use \WP_UnitTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Package as TestedPackage;
|
||||
|
@ -27,8 +27,8 @@ class Package extends WP_UnitTestCase {
|
|||
$this->assertEquals( __DIR__ . '/', $package->get_path() );
|
||||
|
||||
//test with relative
|
||||
$expect = __DIR__ . '/build/test';
|
||||
$this->assertEquals( $expect, $package->get_path( 'build/test') );
|
||||
$expect = __DIR__ . '/assets/client/blocks/test';
|
||||
$this->assertEquals( $expect, $package->get_path( 'assets/client/blocks/test') );
|
||||
}
|
||||
|
||||
public function test_get_url() {
|
||||
|
@ -39,8 +39,8 @@ class Package extends WP_UnitTestCase {
|
|||
|
||||
//test with relative
|
||||
$this->assertEquals(
|
||||
$test_url . 'build/test',
|
||||
$package->get_url( 'build/test' )
|
||||
$test_url . 'assets/client/blocks',
|
||||
$package->get_url( 'assets/client/blocks' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Library;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Library;
|
||||
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
use \WC_Order;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Helper used to create fixture data for tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Helpers;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Helpers;
|
||||
|
||||
/**
|
||||
* FixtureData class.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Ensures the helper works.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Helpers;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Helpers;
|
||||
|
||||
require_once __DIR__ . '/ValidateSchema.php';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Helper used to validate schema differences.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Helpers;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Helpers;
|
||||
|
||||
/**
|
||||
* Validate schema.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Utils;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Utils;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Migration;
|
||||
use Automattic\WooCommerce\Blocks\Options;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Registry;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Registry;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Registry\Container as ContainerTest;
|
||||
use Automattic\WooCommerce\Blocks\Registry\FactoryType;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Mocks\MockTestDependency;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Mocks\MockTestDependency;
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi;
|
||||
|
||||
/**
|
||||
* ControllerTests
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi;
|
||||
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Formatters;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Formatters;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Formatters\CurrencyFormatter;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Formatters;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Formatters;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Formatters;
|
||||
use Automattic\WooCommerce\StoreApi\Formatters\MoneyFormatter;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Formatters;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Formatters;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Formatters\HtmlFormatter;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Formatters;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Formatters;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Formatters\MoneyFormatter;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Rate Limits Tests
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Authentication;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\RateLimits;
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
|
||||
/**
|
||||
* Batch Controller Tests.
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\StoreApi\SessionHandler;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\JsonWebToken;
|
||||
use Spy_REST_Server;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Cart Coupons Controller Tests.
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* Cart extensions route tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
|
||||
/**
|
||||
* Cart Controller Tests.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Cart Controller Tests.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema;
|
||||
use Automattic\WooCommerce\StoreApi\Formatters;
|
||||
|
@ -11,7 +11,7 @@ use Automattic\WooCommerce\StoreApi\Formatters\MoneyFormatter;
|
|||
use Automattic\WooCommerce\StoreApi\Formatters\HtmlFormatter;
|
||||
use Automattic\WooCommerce\StoreApi\Formatters\CurrencyFormatter;
|
||||
use Automattic\WooCommerce\StoreApi\Schemas\V1\CheckoutSchema;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\StoreApi\Routes\V1\Checkout as CheckoutRoute;
|
||||
use Automattic\WooCommerce\StoreApi\SchemaController;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* ControllerTestCase Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema;
|
||||
use Automattic\WooCommerce\StoreApi\Formatters;
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Product Attributes Controller Tests.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Product Attributes Controller Tests.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Controller Tests.
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
* Controller Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
|
||||
use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
|
||||
|
||||
/**
|
||||
* Products Controller Tests.
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* CartController Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Utilities;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\CartController;
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* NoticeHandler Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Utilities;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Exceptions\RouteException;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\NoticeHandler;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* OrderController Tests.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Utilities;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Exceptions\RouteException;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\OrderController;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Utilities;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\ProductQueryFilters;
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
use Automattic\WooCommerce\Blocks\Tests\Helpers\FixtureData;
|
||||
use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
|
||||
|
||||
class ProductQueryFiltersTest extends TestCase {
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Templates;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Templates;
|
||||
|
||||
use \WP_UnitTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Templates\SingleProductTemplateCompatibility;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Templates;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Templates;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Templates\SingleProductTemplate;
|
||||
use \WP_UnitTestCase;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Utils;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Utils;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Migration;
|
||||
use Automattic\WooCommerce\Blocks\Options;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\BlockTypes;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\BlockTypes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Utils\MiniCartUtils;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Mocks;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Mocks;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Mocks;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Mocks;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Mocks;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Mocks;
|
||||
|
||||
class MockTestDependency {
|
||||
public $dependency;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Mocks;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Mocks;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection;
|
||||
use Automattic\WooCommerce\Blocks\Package;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\Tests\Mocks;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Mocks;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\BlockTypes\ProductQuery;
|
||||
use Automattic\WooCommerce\Blocks\Package;
|
||||
|
|
|
@ -20,6 +20,10 @@ if ( ! defined( 'WC_PLUGIN_FILE' ) ) {
|
|||
define( 'WC_PLUGIN_FILE', __FILE__ );
|
||||
}
|
||||
|
||||
if ( ! defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ) {
|
||||
define( 'WC_BLOCKS_IS_FEATURE_PLUGIN', true );
|
||||
}
|
||||
|
||||
// Load core packages and the autoloader.
|
||||
require __DIR__ . '/src/Autoloader.php';
|
||||
require __DIR__ . '/src/Packages.php';
|
||||
|
|
434
pnpm-lock.yaml
434
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue