Merge pull request #32500 from woocommerce/fix/feature-config-file-location

Move feature flag config files to Woocommerce plugin
This commit is contained in:
Christopher Allford 2022-04-07 12:49:03 -07:00 committed by GitHub
commit 1e3a3d8af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 14 additions and 9 deletions

View File

@ -69,7 +69,7 @@ jobs:
- name: Build Admin feature config
working-directory: ./
run: pnpm nx build:feature-config woocommerce-admin
run: pnpm nx build:feature-config woocommerce
- name: Add PHP8 Compatibility.
run: |

View File

@ -61,7 +61,7 @@ jobs:
- name: Build Admin feature config
working-directory: ./
run: |
pnpm nx build:feature-config woocommerce-admin
pnpm nx build:feature-config woocommerce
- name: Init DB and WP
run: pnpm nx install-unit-test-db woocommerce

View File

@ -69,7 +69,7 @@ jobs:
- name: Build Admin feature config
working-directory: ./
run: |
pnpm nx build:feature-config woocommerce-admin
pnpm nx build:feature-config woocommerce
- name: Add PHP8 Compatibility.
run: |

View File

@ -25,7 +25,7 @@
"build": "pnpm run build:feature-config && cross-env NODE_ENV=production webpack",
"analyze": "cross-env NODE_ENV=production ANALYZE=true webpack",
"postbuild": "pnpm run -s i18n:pot && pnpm run -s i18n:build",
"build:feature-config": "php bin/generate-feature-config.php",
"build:feature-config": "php ../woocommerce/bin/generate-feature-config.php",
"build:packages": "cross-env NODE_ENV=production pnpm run:packages -- build",
"build:release": "./bin/build-plugin-zip.sh",
"clean": "rimraf ./dist && pnpm run:packages -- clean --parallel",

View File

@ -17,7 +17,7 @@ $phase = getenv( 'WC_ADMIN_PHASE' );
if ( ! in_array( $phase, array( 'development', 'plugin', 'core' ), true ) ) {
$phase = 'plugin'; // Default to plugin when running `pnpm run build`.
}
$config_json = file_get_contents( __DIR__ . '/../config/' . $phase . '.json' );
$config_json = file_get_contents( __DIR__ . '/../client/admin/config/' . $phase . '.json' );
$config = json_decode( $config_json );
$write = "<?php\n";
@ -33,7 +33,7 @@ $write .= "\t\t);\n";
$write .= "\t}\n";
$write .= "}\n";
$config_file = fopen( __DIR__ . '/../../woocommerce/includes/react-admin/feature-config.php', 'w' );
$config_file = fopen( __DIR__ . '/../includes/react-admin/feature-config.php', 'w' );
fwrite( $config_file, $write );
fclose( $config_file );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Move feature flag config files to Woocommerce plugin to support unit test execution in the wp-env environment.

View File

@ -14,7 +14,8 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "./bin/build-zip.sh",
"build:core": "pnpm nx build woocommerce-admin && pnpm nx build woocommerce-legacy-assets && pnpm run makepot",
"build:feature-config": "php bin/generate-feature-config.php",
"build:core": "pnpm run build:feature-config && pnpm nx build woocommerce-admin && pnpm nx build woocommerce-legacy-assets && pnpm run makepot",
"build:zip": "pnpm run build",
"lint:js": "eslint assets/js --ext=js",
"docker:down": "pnpx wc-e2e docker:down",

View File

@ -57,7 +57,7 @@
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"pnpm nx build:feature-config woocommerce-admin",
"pnpm nx build:feature-config woocommerce",
"pnpm nx watch-assets woocommerce"
]
}

View File

@ -259,7 +259,7 @@ class WC_Unit_Tests_Bootstrap {
* @return array Filtered feature flags.
*/
public function add_development_features( $flags ) {
$config = json_decode( file_get_contents( $this->plugin_dir . '/../woocommerce-admin/config/development.json' ) ); // @codingStandardsIgnoreLine.
$config = json_decode( file_get_contents( $this->plugin_dir . '/client/admin/config/development.json' ) ); // @codingStandardsIgnoreLine.
foreach ( $config->features as $feature => $bool ) {
$flags[ $feature ] = $bool;
}