An open API service indexing awesome lists of open source software.

https://github.com/adamjohnlea/leastudios-dev-tools

Shared scaffolding and tooling for the leaStudios family of WordPress plugins.
https://github.com/adamjohnlea/leastudios-dev-tools

developer-tools mysql php wordpress wordpress-plugin

Last synced: about 1 month ago
JSON representation

Shared scaffolding and tooling for the leaStudios family of WordPress plugins.

Awesome Lists containing this project

README

          

# leaStudios Dev Tools

Shared scaffolding and tooling for the leaStudios family of WordPress plugins.

This repo is **not a plugin**. It's the development home for:

- **`_boilerplate/`** — the starting scaffold for any new leaStudios plugin (PSR-4, modern PHP 8.1+, REST controller stub, security helpers, sample test).
- **`bin/install-wp-tests.sh`** — installs the WordPress test library (`wordpress-tests-lib`) into a temp dir so each plugin can run `phpunit` against a real WordPress.
- **`bin/package.sh`** — packages a plugin into a distributable `.zip` (respecting each plugin's `.distignore`).
- **`bin/check-shared.sh`** — verifies that files intentionally duplicated across the plugins (`Security/Nonce.php`, `Encryption/Options_Encryptor.php`, `Shared/Datetime_Util.php`, and their duplicated tests) remain in sync. Exits non-zero on drift, with a normalized diff so you can see exactly what changed. Enforced automatically — see "Check shared files for drift" below.
- **`bin/git-hooks/`** + **`bin/install-hooks.sh`** — a shared `pre-push` hook that runs `check-shared.sh` before every push, plus a one-time installer that wires it into each suite repo.
- **`config-templates/`** — canonical `phpcs.xml.dist`, `phpstan.neon`, `phpunit.xml.dist`, and `tests/bootstrap.php` templates that every plugin repo copies in.
- **`CLAUDE.md`** — project-wide development conventions (coding standards, security rules, WordPress patterns) that apply across all leaStudios plugins.
- **`CODE_REVIEW.md`** — historical code-review notes for the plugin family.

## How it relates to the plugins

Each leaStudios plugin lives in its own git repository alongside this one in `wp-content/plugins/`:

```
wp-content/plugins/
├── leastudios-dev-tools/ (this repo)
├── leastudios-payments/ (own repo)
├── leastudios-email-templates/ (own repo)
├── leastudios-forms/ (own repo)
├── leastudios-mailer/ (own repo)
└── leastudios-snippets/ (own repo)
```

Each plugin is **self-contained** — it has its own `composer.json` with dev dependencies, its own `phpcs.xml.dist`, `phpstan.neon`, `phpunit.xml.dist`, and `tests/bootstrap.php`. A plugin can be cloned, linted, tested, and packaged on its own without this repo being present.

This repo is the **canonical source** of those configs. When you change a config template here, propagate the change to each plugin repo manually (or via a small sync script).

## Common workflows

### Bootstrap a new plugin

```bash
cp -R leastudios-dev-tools/_boilerplate leastudios-newthing
cd leastudios-newthing
# Find/replace plugin-name → newthing, PluginName → Newthing, etc.
# (See _boilerplate/README — todo)
composer install
git init
```

### Install the WordPress test library (one-time, shared across all plugins)

```bash
bash leastudios-dev-tools/bin/install-wp-tests.sh wordpress_test root '' localhost latest
```

This drops the test library into `/tmp/wordpress-tests-lib/`. Every plugin's `tests/bootstrap.php` looks for it there (or via the `WP_TESTS_DIR` env var).

### Run a plugin's tests / lint

From inside any plugin directory:

```bash
composer install # one-time
composer lint # phpcs + phpstan
composer test # phpunit
composer phpcbf # auto-fix WPCS issues
```

### Package a plugin for distribution

```bash
bash leastudios-dev-tools/bin/package.sh leastudios-payments
# → produces leastudios-payments-X.Y.Z.zip
```

Or `bash leastudios-dev-tools/bin/package.sh all` to package every plugin.

### Check shared files for drift

```bash
bash leastudios-dev-tools/bin/check-shared.sh
```

Confirms that files duplicated across plugins by design (e.g. `Security/Nonce.php` and its tests) haven't drifted. Exits 0 if everything's in sync, 1 with a normalized diff if anything has changed. Add new shared files by appending to `SHARED_FILES` in the script (paths are relative to each plugin root).

This check runs automatically, so drift is caught without anyone remembering to run it:

- **Pre-push hook (local).** Run the one-time installer after cloning the suite:

```bash
bash leastudios-dev-tools/bin/install-hooks.sh
```

It points each repo's `core.hooksPath` at `bin/git-hooks`, so a push that would introduce drift is blocked before it leaves your machine. Re-run it after adding a new plugin repo.

- **CI (GitHub Actions).** `.github/workflows/check-shared.yml` in this repo checks out the suite and runs the same check on every push to `leastudios-dev-tools`, on a weekly schedule, and on demand (`workflow_dispatch`). The private `leastudios-siteaudit` repo is not cloned in CI; the pre-push hook covers it.

`check-shared.sh` still needs the whole suite checked out as siblings — it cannot run inside a single isolated plugin clone.

## Versioning

This repo isn't published as a Composer package — its contents are copy-in templates. Each plugin pins its own versions of `phpstan/phpstan`, `wp-coding-standards/wpcs`, etc. in its own `composer.json`.

## License

GPL-2.0-or-later, matching the plugins.