Build WordPress plugin or theme distribution ZIPs from a consumer project root.
- Node.js >= 18.12.0
rsyncandzipon the PATH- Composer and git are optional (only needed when the consumer project uses them)
npm install -D @wpsyntex/distributenpx distribute [options]--mode <production|dev> Default: production
--version <strategy|text> Default: commit (strategies: commit, tag, or a literal version)
--output <path> Output directory or ZIP file (default: {cwd}/dist)
--slug <name> Override slug (default: from package.json name)
--tmp-dir <path> Temp working directory (default: {cwd}/.distribute-tmp)
--sequential Run composer then npm (default: parallel when both apply)
--npm-cmd <script> Override npm script (default: build or build:dev per mode)
--cwd <path> Project root (default: process.cwd())
-h, --help
- Add a
.distignorefile at the project root (required). - Add
composer.jsononly if the project needs a Composer install step. - Add
package.jsonscriptsbuildand/orbuild:devonly if the project needs an NPM build step.
The tool runs against the consumer project root (process.cwd() by default). Composer and NPM steps are auto-detected and skipped when the corresponding manifest is missing.
When both Composer and NPM steps apply, they run in parallel by default. Use --sequential when the NPM build depends on Composer output (for example, when vendor/ must exist before npm run build).
npx distribute --sequentialAfter building a ZIP, verify its contents against a dist-manifest.json file at the project root:
npx distribute
npx verify-dist --zip dist/my-plugin-abc1234.zipList expected paths relative to the plugin folder inside the ZIP:
{
"files": [
"my-plugin.php",
"readme.txt",
"src/",
"js/build/*.js"
]
}| Entry | Meaning |
|---|---|
plugin.php |
Exact file (required) |
src/ |
Any file under src/ (at least one required) |
js/build/*.js |
Glob pattern (at least one match required) |
Failures:
- Unexpected files — not covered by the manifest (often a
.distignoreleak). - Unsatisfied entries — required file, directory, or glob missing from the ZIP.
--zip <path> Path to distribution ZIP (required)
--manifest <path> Path to dist-manifest.json (default: {cwd}/dist-manifest.json)
--tmp-dir <path> Temp working directory (default: {cwd}/tmp)
--cwd <path> Consumer project root (default: process.cwd())
-h, --help
git clone https://github.com/polylang/distribute.git
cd distribute
npm installRun the CLI from the repo:
node bin/distribute.js --helpScripts:
npm run test:unit # Jest unit tests
npm run test:coverage # Jest unit tests with coverage report
npm run test:smoke # Polylang distribution smoke test
npm run lint # ESLintGPL-3.0-or-later