title | description |
---|---|
Development |
Learn how to develop and contribute to the Lando Mailpit service |
Development of this plugin happens on GitHub.
At the very least you will need to have the following installed:
- Lando 3.21.0+ preferably installed from source
- Git
- Node 20
-
Clone the repository:
git clone https://github.com/lando/mailpit.git cd mailpit
-
Install dependencies:
npm install
-
Set up your development environment:
- Ensure you have Node.js 20 or later installed
- If you're using VS Code, consider installing the ESLint extension for real-time linting feedback
This plugin contains various working and tested Lando apps in the examples/
folder. You should use these or create new ones to help with plugin development.
Each example contains the following section in its Landofile:
plugins:
"@lando/mailpit": ../..
This tells Lando that this app should use the source version of the @lando/mailpit
plugin you cloned down in the installation. This is useful because it allows you to isolate development within this repo without interfering with any other apps using the stable and global version of the plugin.
You should almost always develop against apps in the examples
folder and those apps should always contain the above plugins
config. If you have an existing Lando application you want to develop against, you can temporarily tell it to use the cloned down version of the plugin with:
plugins:
"@lando/mailpit": /path/to/plugin
This repository is structured as follows:
builders/
: Contains the main service builder for the Mailpit pluginconfig/
: Contains configuration files used in services managed by the Mailpit plugindocs/
: Documentation for the Mailpit pluginexamples/
: Example configurations and usage scenarios executed by Leia for testingscripts/
: Contains scripts used by the Mailpit plugin inside appstasks/
: Contains Lando command implementationstest/
: Contains unit test filesutils/
: Utility functions used by the Mailpit plugin
If you want to help with contributing documentation, you can use these commands:
# launch local docs site
npm run docs:dev
# build docs locally
npm run docs:build
# preview built docs locally
npm run docs:build
The documentation uses VitePress with our custom theme.
This project uses both unit tests and integration tests:
# Run unit tests
npm run test:unit
# Run integration tests
npm run test:leia
# Run all tests
npm test
We use Leia for end-to-end testing. Leia is our custom testing framework that allows us to define tests as a series of shell commands in markdown files, making our tests both executable and human-readable documentation.
Each example in the examples/
directory serves as a test case. The README.md in each example contains the test steps in this format:
Start up tests
--------------
# Should start up successfully
lando start
Verification commands
---------------------
# Should be able to send mail
lando php /app/mail.php
# Should be able to see mail in the UI
lando exec mailpit -- curl localhost:8025/api/v1/messages
Destroy tests
-------------
# Should be able to destroy our app
lando destroy -y
The headers in these files are important:
Start up tests
: Commands that run before the main testsVerification commands
: The main test steps (required)Destroy tests
: Clean up commands to run after tests
To run the tests:
# Run all integration tests
npm run test:leia
# Run a specific test
npx leia examples/basic/README.md -c 'Destroy tests'
When adding new test examples:
- Create a new directory in
examples/
- Add a README.md with your test steps
- Add the test to GitHub Actions by modifying the workflow file:
jobs:
leia-tests:
strategy:
fail-fast: false
matrix:
leia-test:
- examples/basic
- examples/advanced
# Add your new test here
This project uses ESLint for code linting. The configuration is defined in eslint.config.js
using the new flat config format:
npm run lint
To deploy and publish a new version:
- Create a release on GitHub
- Use semantic versioning for the release title (e.g.
v1.1.2
) - The GitHub release will automatically prepare and deploy to NPM
Note:
- Creating a "pre-release" will tag the NPM package with
edge
instead oflatest
- To install specific versions:
# Latest stable release npm install @lando/mailpit # Latest pre-release npm install @lando/mailpit@edge
We welcome contributions! Please follow GitHub flow for contributions.