Plugin Machine CLI


The Plugin Machine CLI lets you add features to existing plugins from the command line in your IDE. You can also use it to create release-ready ZIP files from your plugins.

The CLI is under development. It is fairly stable, but may change before version 1.

Install

Requires Node 16 or later.

Some commands require Docker

To install from npm:

npm i plugin-machine -g

Test Things Worked

Check that the version command works:

plugin-machine version

Usage

Login

To login, you will need an API token. This can be found in the “Settings” page of the Plugin Machine dashboard. Go here when logged in. Copy that and use it in place of <token>

plugin-machine login <token>

Finding Your API Token

Screenshot of API tokens screen.

It shows that you can copy the token, or cycle your token.
The API tokens screen. I clicked “Generate New Token” after taking this screenshot, so this token is no longer valid.

Working With Plugins

The “pluginMachine.json” file contains important information for the CLI and for the plugin builder, and webpack. If you created your plugin with Plugin Machine, it should include a pluginMachine.json To update that file, based on the latest settings:

plugin-machine plugin config <pluginId>

All “plugin” commands require Docker, which you can download here. Docker is used to run npm, composer and wpcli commands during the build process of your plugins.

Add A Feature

To add a feature to your plugin:

plugin-machine add

Build Plugin For Release

This command runs the build steps (npm, composer, etc.) specified in the pluginMachine.json’s build.prod key:

plugin-machine plugin build

Optionally, you can run the build process and then copy the files that are supposed to be included in a release:

plugin-machine plugin build --buildDir=output

The buildDir argument is relative to the plugin’s main dir.

Zip Plugin For Release

This command does not run the build process. Make sure to run build command first.

Create a ZIP file, with only the files that are supposed to be included in a release:

plugin-machine plugin zip

Alternatively, you can zip any folder:

plugin-machine plugin zip --buildDir=output

Build A WordPress Plugin For Release And Zip Results

Run the build commands and then create a ZIP of the plugin:

plugin-machine plugin build
plugin-machine plugin zip

Run the build commands, copy needed files to a separate directory and then zip that directory:

plugin-machine plugin build --buildDir=space-people
plugin-machine plugin zip --buildDir=space-people

Uploading A Release Zip File

View Source

The Plugin Machine CLI is open-source. You can view source on Github:

https://github.com/imaginarymachines/plugin-machine-cli