From 442ad3758c3cc8c4806db3dafff3a663b86a9a1e Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 5 Dec 2024 15:50:42 -0500 Subject: [PATCH 1/3] add versioning script and command --- package.json | 1 + set-version-bump.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 set-version-bump.js diff --git a/package.json b/package.json index 49d7d60..2884ba8 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "log:watch": "wp-env run wordpress 'tail -f /var/www/html/wp-content/debug.log'", "php-deps": "composer install --no-dev --optimize-autoloader", "postprepare": "npm run set-wp-version", + "set-version-bump": "node ./set-version-bump.js && npm i && rm -rf ./build && npm run build && composer run i18n", "set-wp-version": "node ./set-latest-wp-version.js", "prebuild:cleanup": "rm -rf ./build ./wp-plugin-crazy-domains ./wp-plugin-crazy-domains.zip ./vendor", "simulate-runner-build": "npm run prebuild:cleanup && npm i && npm run php-deps && npm run build && npm run create:dist && npm run create:zip", diff --git a/set-version-bump.js b/set-version-bump.js new file mode 100644 index 0000000..3ed7fe9 --- /dev/null +++ b/set-version-bump.js @@ -0,0 +1,32 @@ +const fs = require( 'fs' ); +const semver = require( 'semver' ); +const packagefile = './package.json'; +const pluginfile = './wp-plugin-crazy-domains.php'; + +if ( fs.existsSync( packagefile ) && fs.existsSync( pluginfile ) ) { + const packageData = require( packagefile ); + const currentVersion = packageData.version; + let type = process.argv[ 2 ]; + if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) { + type = 'patch'; + } + + const newVersion = semver.inc( packageData.version, type ); + packageData.version = newVersion; + fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 4 ) ); + + fs.readFile( pluginfile, 'utf8', function ( err, data ) { + if ( err ) { + return console.log( err ); + } + const result = data.replaceAll( currentVersion, newVersion ); + + fs.writeFile( pluginfile, result, 'utf8', function ( err ) { + if ( err ) { + return console.log( err ); + } + } ); + } ); + + console.log( 'Version updated', currentVersion, '=>', newVersion ); +} From 2633db58f48bddc2940d95dcf90d828f9b02efae Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 5 Dec 2024 15:56:29 -0500 Subject: [PATCH 2/3] update cypress config to exclude dependent tests when dependency is not supported --- cypress.config.js | 64 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index 30bc2bf..00e5582 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -29,8 +29,6 @@ module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { - const semver = require('semver'); - // Ensure that the base URL is always properly set. if (config.env && config.env.baseUrl) { config.baseUrl = config.env.baseUrl; @@ -53,19 +51,27 @@ module.exports = defineConfig({ } } - // Exclude tests for WordPress lower than 6.5 (6.4 or 6.3) or PHP lower than 7.4 (7.1, 7.2 and 7.3) - // Since WooCommerce is unsupported, activation/deactivation/installation is going to fail - if ( - semver.satisfies( config.env.wpSemverVersion, '<6.5.0' ) || - semver.satisfies( config.env.phpSemverVersion, '<7.4.0' ) - ) { + // Tests require Wondor Theme, exclude if not supported due to WP or PHP versions + if ( ! supportsWonderTheme( config.env ) ) { + config.excludeSpecPattern = config.excludeSpecPattern.concat( [ + 'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/**', // Onboarding requires Wonder Theme + 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/ecommerce-next-steps.cy.js', // Requires Onboarding + ] ); + } + + // Tests requires Woo, so exclude if not supported due to WP or PHP versions + if ( ! supportsWoo( config.env ) ) { config.excludeSpecPattern = config.excludeSpecPattern.concat( [ 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Site-Capabilities/**', 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/homePageWithWoo.cy.js', - 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/ecommerce-next-steps.cy.js', // Skip this since Onboarding does not support this version - 'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/**', // Onboarding requires WP 6.5 or greater, as it uses the Wonder Theme which has the same requirement - 'vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js', // woo is required and is not supported in older WP or PHP - 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Store/**', + 'vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js', + ] ); + } + + // Test requires Jetpack, so exclude if not supported due to WP or PHP versions + if ( ! supportsJetpack( config.env ) ) { + config.excludeSpecPattern = config.excludeSpecPattern.concat( [ + 'vendor/newfold-labs/wp-module-solutions/tests/cypress/integration/wp-plugins-installation-check.cy.js', ] ); } @@ -100,3 +106,37 @@ module.exports = defineConfig({ retries: 1, experimentalMemoryManagement: true, }) + +// Check against plugin support at https://wordpress.org/plugins/woocommerce/ +const supportsWoo = ( env ) => { + const semver = require( 'semver' ); + if ( + semver.satisfies( env.wpSemverVersion, '>=6.5.0' ) && + semver.satisfies( env.phpSemverVersion, '>=7.4.0' ) + ) { + return true; + } + return false; +}; +// Check against plugin support at https://wordpress.org/plugins/jetpack/ +const supportsJetpack = ( env ) => { + const semver = require( 'semver' ); + if ( + semver.satisfies( env.wpSemverVersion, '>=6.6.0' ) && + semver.satisfies( env.phpSemverVersion, '>=7.2.0' ) + ) { + return true; + } + return false; +}; +// Check against theme support at https://github.com/newfold-labs/yith-wonder/blob/master/style.css +const supportsWonderTheme = ( env ) => { + const semver = require( 'semver' ); + if ( + semver.satisfies( env.wpSemverVersion, '>=6.5.0' ) && + semver.satisfies( env.phpSemverVersion, '>=7.0.0' ) + ) { + return true; + } + return false; +}; From ccd59186077623717648aff0236f723ebf4d8cb1 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 5 Dec 2024 15:56:45 -0500 Subject: [PATCH 3/3] keep store exclusion --- cypress.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress.config.js b/cypress.config.js index 00e5582..8169fc7 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -65,6 +65,7 @@ module.exports = defineConfig({ 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Site-Capabilities/**', 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/homePageWithWoo.cy.js', 'vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js', + 'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Store/**', ] ); }