From a3b908bcbc9afee05381851c12a641859b64298d Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Wed, 23 Aug 2023 14:49:07 -0600 Subject: [PATCH 1/3] Add an env:destroy command --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index b8c9820..05989c3 100755 --- a/index.js +++ b/index.js @@ -37,6 +37,7 @@ const scripts = { "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", + "env:destroy": "wp-env destroy", "postenv:start": "./tests/bin/initialize.sh", }; From 9e47f6f1a0726df08542816774db8a09de243f2f Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Wed, 23 Aug 2023 15:08:06 -0600 Subject: [PATCH 2/3] Update the init script for newer version of wp-env --- src/tests/bin/initialize.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/bin/initialize.sh b/src/tests/bin/initialize.sh index 9d06a85..51ba8ea 100755 --- a/src/tests/bin/initialize.sh +++ b/src/tests/bin/initialize.sh @@ -1,3 +1,3 @@ #!/bin/bash -npm run env run tests-wordpress "chmod -c ugo+w /var/www/html" -npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard" +npm run env run tests-wordpress chmod -- -c ugo+w /var/www/html +npm run env run tests-cli wp rewrite structure '/%postname%/' -- --hard From 23a3f65b8ef7f82b5a7ea4dbac6cd87075ff9404 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Wed, 23 Aug 2023 15:16:23 -0600 Subject: [PATCH 3/3] Change how we load the wp-env config to account for new changes in that library --- src/tests/cypress/config.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tests/cypress/config.js b/src/tests/cypress/config.js index 297c75b..e620727 100644 --- a/src/tests/cypress/config.js +++ b/src/tests/cypress/config.js @@ -1,5 +1,6 @@ const { defineConfig } = require('cypress'); -const { readConfig } = require('@wordpress/env/lib/config'); +const { loadConfig } = require( '@wordpress/env/lib/config' ); +const getCacheDirectory = require( '@wordpress/env/lib/config/get-cache-directory' ); module.exports = defineConfig({ fixturesFolder: 'tests/cypress/fixtures', @@ -18,13 +19,14 @@ module.exports = defineConfig({ /** * Set WP URL as baseUrl in Cypress config. - * + * * @param {Function} on function that used to register listeners on various events. * @param {object} config Cypress Config object. * @returns config Updated Cypress Config object. */ const setBaseUrl = async (on, config) => { - const wpEnvConfig = await readConfig('wp-env'); + const cacheDirectory = await getCacheDirectory(); + const wpEnvConfig = await loadConfig( cacheDirectory ); if (wpEnvConfig) { const port = wpEnvConfig.env.tests.port || null;