Skip to content

Commit

Permalink
Merge ccd5918 into 223f67b
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube authored Dec 5, 2024
2 parents 223f67b + ccd5918 commit bcfa629
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 11 deletions.
63 changes: 52 additions & 11 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -53,22 +51,31 @@ 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-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js',
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Store/**',
] );
}

// 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',
] );
}

on('task', {
log(message) {
console.log(message)
Expand Down Expand Up @@ -100,3 +107,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;
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions set-version-bump.js
Original file line number Diff line number Diff line change
@@ -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 );
}

0 comments on commit bcfa629

Please sign in to comment.