Stackable icon indicating copy to clipboard operation
Stackable copied to clipboard

Use @wordpress/env instead of php composer

Open bfintal opened this issue 1 year ago • 0 comments

Use @wordpress/env for convenience. This can greatly simplify the installation, building and testing process, even in Github actions.

To add @wordpress/env we need to add it as a dependency:

npm install --save-dev @wordpress/env

Add in package.json:

{
    "scripts":  {
        "wp-env": "wp-env",
    }
}

By doing this, we can do npm run wp-env start to run the WP environment in https://localhost:8888. This can be very easy to set up our e2e tests.

If we go this route, we will need to change the following:

  • [ ] Remove the dependency on composer
  • [ ] Change the run script for build:translations-pot

We will need to change the translation building to:

npm run wp-env -- run cli "wp i18n make-pot . languages/stackable-ultimate-gutenberg-blocks.pot --slug=stackable-ultimate-gutenberg-blocks --domain=stackable-ultimate-gutenberg-blocks --ignore-domain --include=\"*.php,src/,pro__premium_only/\" --exclude=\"pro__premium_only/dist,pro__premium_only/node_modules,pro__premium_only/tests,*.test.js,*.config.js,__test__,wordpress,build,tools,vendor,docs\""

The output translation file will be placed in https://localhost:8888/languages/stackable-ultimate-gutenberg-blocks.pot, we'll need to grab it and place it in the languages/ folder of the plugin.

  • [ ] Update the workflows in .github/workflows/*.yml to remove all the composer stuff, and replace it with just wp-env:

Remove:

    - name: Install dependencies
      run: |
        composer require phpunit/phpunit:5.6.8 --dev
        composer require wp-phpunit/wp-phpunit:${{ matrix.wp-versions }} --dev
        composer require roots/wordpress:${{ matrix.wp-versions }} --dev
        composer install --prefer-dist --no-progress

Replace with:

  - name: Start WordPress
    run: npm run wp-env start

bfintal avatar Aug 11 '22 14:08 bfintal