There are many ways to contribute to this project.
- Discuss open issues to help define the future of the project.
- Submit bugs and help us verify fixes as they are checked in.
- Review and discuss the source code changes.
- Contribute bug fixes
/internal/legacy.faustjs.org
- legacy faustjs documentation site/packages
- NPM packages/examples
- Example projects/plugins
- WordPress Plugins/scripts
- Packaging scripts
NPM packages are managed from the project root using Workspaces. To get started, run:
npm install
npm run dev
The local copy of each package is automatically symlinked in node_modules
when running npm install
from the project root. Likewise, each package is automatically built when running npm run dev
.
When switching git branch, run npm run clean
from the root and then re-run npm run dev
.
As this is a monorepo, you will not be able to check out this repository into wp-content/themes
or wp-content/plugins
.
Instead, you can create symlinks to the themes/plugins in this repository. Best of all, this will also sync your work across multiple local sites!
Setup To begin working with the FaustWP WordPress plugin, you will need to symlink the plugin from the monorepo to your WordPress plugin development directory.
ln -s /path/to/faustjs/plugins/faustwp /path/to/wordpress/wp-content/plugins/faustwp
PHP Code Sniffer PHP Code Sniffer is configured for the WordPress code standards.
Install the composer packages from within plugins/faustwp
directory if you haven't already.
composer install
Run the syntax check.
composer phpcs
Use phpcs
to fix some syntax errors:
composer phpcs:fix
WordPress Unit Tests
To run WordPress unit tests, first start the Docker application from the plugins/faustwp
directory:
composer run docker:start
If desired, you may specify the WP_VERSION you'd like to run tests against:
WP_VERSION=6.4.2 composer run docker:start
Once the containers are up, set up the test framework. If you want to enable code coverage reporting, make sure you provide the COVERAGE=1
environment variable as a parameter:
docker-compose exec -e COVERAGE=1 wordpress init-testing-environment.sh
Install and activate WP GraphQL:
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root
Run the unit tests:
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) composer test
Finally, to remove the containers:
composer run docker:stop
Use Codeception for running end-2-end tests in the browser.
- Install Docker.
- Install Composer.
- Install Google Chrome.
- Install Chromedriver
- The major version will need to match your Google Chrome version. See Chromedriver Version Selection.
- Unzip the chromedriver zip file and move
chromedriver
application into the/usr/local/bin
directory.mv chromedriver /usr/local/bin
- In shell, run
chromedriver --version
. Note: If you are using OS X, it may prevent this program from opening. Open "Security & Privacy" and allow chromedriver. - Run
chromedriver --version
again. Note: On OS X, you may be prompted for a final time, click "Open". When you can see the version, chromedriver is ready.
- Create the following
.env.test
inexamples/next/getting-started
.
# Your WordPress site URL
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8080
# Plugin secret found in WordPress Settings->Headless
FAUST_SECRET_KEY=00000000-0000-4000-8000-000000000001
- From within
examples/next/getting-started
, runNODE_ENV=test npm run dev
.
- Leave the node server running and open a new shell.
- Move into the FaustWP plugin directory
plugins/faustwp
. - Run
composer install
if you haven't already. - Prepare a test WordPress site.
- Run
docker-compose up -d --build
. If building for the first time, it could take some time to download and build the images. - Run
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root
- Run
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp db export tests/_data/dump.sql --allow-root
- Run
- Copy
.env.testing.example
to.env.testing
. - Run
vendor/bin/codecept run acceptance
to start the end-2-end tests.
- Codeception Acceptance Tests
- Base framework for browser testing in php.
- WPBrowser
- WordPress framework wrapping Codeception for browser testing WordPress.
We have three notable branches:
canary
- This branch has the latest changesmain
- This branch is used to deploy changes to faustjs.org
We use the feature branch workflow. The workflow for a typical code change looks like:
- Create a new branch for the feature
- Make changes to the code
- Use
npm run changeset
to create a changeset describing any package or plugin updates - Commit your changes
- Open a pull request to the
canary
branch - Squash and Merge the pull request into the
canary
branch
Note: We use Squash and Merge when merging pull requests into the canary
branch.
Developers with full GitHub repository access can create public releases. We use Changesets to automate the versioning and deployment process for all of our packages and plugins.
To add a new changeset for a new feature, bugfix or other change please see the changeset documentation.
When you are ready to release, you should first create the new package and plugin versions.
- Go to pull requests, and view the "Version Packages" PR.
- Review the PR:
- Changelog entries were created in all updated packages or plugins.
- Version numbers were appropriately bumped in the relevant package.json files.
- All
.changeset/*.md
files were removed. - Version number updated in the main plugin file and readme.txt (Plugin versioning only)
- The plugin's readme.txt changelog has been updated with the latest 3 versions (Plugin versioning only)
- Approve, then "Squash and merge" the "Version Packages" PR into
canary
.
The @faustwp packages are automatically published to NPM through a GitHub action once the "Version Packages" PR is merged.
Once the "Version Packages" PR is merged, create a new release on GitHub with a tag of plugin/faustwp/v[version]
. This will kick off our GitHub Action to deploy the faustwp
plugin to WordPress.org.
Once deployed, the updated packages and plugin will be visible here:
- https://www.npmjs.com/package/@faustwp/core
- https://www.npmjs.com/package/@faustwp/cli
- https://www.npmjs.com/package/@faustwp/experimental-app-router
- https://www.npmjs.com/package/@faustwp/block-editor-utils
- https://www.npmjs.com/package/@faustwp/blocks
- https://plugins.trac.wordpress.org/browser/faustwp/tags
This section offers guidance for developers working within the monorepo environment, which utilizes npm for package management.
- Use your terminal or IDE to navigate the file structure.
- To locate a specific project, navigate to its directory within the packages folder. For example,
cd packages/faustwp-core
would take you to thefaustwp-core
project directory.
- We use npm for managing dependencies and running build scripts.
- Individual projects often have their own package.json file with project-specific scripts for building and deploying. You can run these scripts using commands like
npm run build
ornpm run test
within the project directory (e.g.,packages/faustwp-core
). - Refer to the project's README file or internal documentation for specific build and deploy instructions.
For deploying the entire monorepo, there might be a top-level build script which you can invoke with
npm run build
.
Use the --workspaces
or -w
flag to run a specific script command of a specified workspace. For example:
$ npm run build -w examples/next/faustwp-getting-started
It runs the build
npm script for the faustwp-getting-started
example project.