Jetpack CLI

The Jetpack CLI is our internal tool to help manage common tasks and provide a common interface across different packages within the repository. It’s accessible through pnpm jetpack after the initial pnpm install, or you can optionally run pnpm jetpack cli link in order to be able to call jetpack directly, globally.

This document aims to provide a complete overview of its current functionality.

Projects

The following commands are shortcuts for various project-related tasks. They’re especially handy when doing working within multiple project at the same time as they allow you to control all of that from a single place.

install

Installs one or more projects in the Jetpack Monorepo, including their dependencies.

jetpack install [...projects]
  • projects
    A space-separated list of projects to install in a type/name format. For example: plugins/jetpack.
  • -a, --all
    Install all projects. This can take a while.
  • -r, --root
    Install the monorepo dependencies.

build

Builds one or more projects in the Jetpack Monorepo. Note that it won’t build the projects’ dependencies by default.

jetpack build [...projects] <options>
  • projects
    A space-separated list of projects to build in a type/name format. For example: plugins/jetpack.
  • -a, --all
    Build all projects. This can take a while.
  • --deps
    Build dependencies of specified projects too.

watch

Watches a single project for changes and performs builds on the fly.

jetpack watch [project] <options>
  • project
    The project to watch in a type/name format. For example: plugins/jetpack.
  • -a, --all
    Watch all projects. (Experimental)

test

Runs tests for a specific project.

jetpack test [project] [test]
  • project
    The project to run the tests in, in a type/name format. For example: plugins/jetpack.
  • test
    The test to run. Optional.

clean

Removes all unversioned files and folders from a specific project.

jetpack clean [project] [include] <options>
  • project
    The project to clean in a type/name format. For example: plugins/jetpack.
  • include
    A space separated list of folders to include for deletion. Available choices are: untracked, ignored, docker, node_modules, composer.lock and vendor.
  • -a, --all
    Clean all projects in the monorepo.
  • --dist
    Remove package manager directories (vendor, node_modules).

Git Workflow

The following helpers are sometimes useful when dealing with our Git workflow.

changelog

Runs the changelogger wizzard, allowing you to add, validate and squash changelog files. As well as write the changes to the project’s README.md or display entries since the given version.

jetpack changelog [[command] [project]]
  • command
    The changelogger command to run. One of add, validate, write, version or project.
  • project
    The project for which to run the changelogger command, in a type/name format. For example plugins/jetpack.

draft

Toggles draft mode, which reduces the strictness of pre-commit and pre-push checks, to make it easier to share your code with others while it’s still work in progress.

jetpack draft [state]
  • state
    Use enable or disable to toggle the desired mode.

Docker

The following commands are for working on and with the monorepo’s Docker environment.

docker up

Starts the Jetpack docker containers.

jetpack docker up

docker down

Stops and removes the Jetpack docker containers.

jetpack docker down

docker stop

Stops the Jetpack docker containers.

jetpack docker stop

docker clean

Removes the Jetpack docker containers, volumes, MySQL and WordPress data and logs.

jetpack docker clean

docker exec

Executes the given shell command inside the development container.

jetpack docker exec [command]
  • command
    The command to execute.

docker db

Gives access to the MySQL CLI from the database container.

jetpack docker db

docker sh

Opens a new shell on the development container.

jetpack docker sh

docker tail

Watches WordPress’ debug.log inside the development container.

jetpack docker tail

docker wp

Gives access to the WP-CLI inside the development container.

jetpack docker wp [command]
  • command
    A WP-CLI command to execute.

docker select-php

Allows switching to a specific PHP version within the development container. Note that every new version will need to be downloaded when selected for the first time.

docker select-php [version]
  • version
    The PHP version to use or default.

docker phpunit

Runs PHPUnit tests inside the development container.

jetpack docker phpunit
  • --php [version]
    Use the specified PHP version when running the tests.

docker phpunit-crm

Runs PHPUnit tests suite for Jetpack CRM inside the development container.

jetpack docker phpunit-crm
  • --php [version]
    Use the specified PHP version when running the tests.

docker phpunit-woocommerce

Runs PHPUnit tests with WooCommerce inside the development container.

jetpack docker phpunit-woocommerce
  • --php [version]
    Use the specified PHP version when running the tests.

docker phpunit-multisite

Runs multisite PHPUnit tests inside the development container.

jetpack docker phpunit-multisite
  • --php [version]
    Use the specified PHP version when running the tests.

docker multisite-convert

Converts the WordPress installation inside the development container into a multisite.

jetpack docker multisite-convert

docker update-core-unit-tests

Pulls the latest WordPress Core unit test files from SVN.

jetpack docker update-core-unit-tests

Links a monorepo plugin folder with the plugin folder of the WordPress install in the development container. The plugin will be considered installed.

jetpack docker link-plugin [plugin]
  • plugin
    The slug for the plugin to link.

Unlinks a monorepo plugin folder with the plugin folder of the WordPress install in the development container. The plugin will be considered uninstalled.

jetpack docker unlink-plugin [plugin]
  • plugin
    The slug for the plugin to link.

Syncing changes

rsync

Syncs a plugin from projects/plugins to a remote destination. Useful for testing and developing against a remote host.

jetpack rsync [plugin] [destination] <options>
  • plugin
    The name of the plugin to sync.
  • destination
    Rsync destination path to the WordPress plugins directory on a remote host.
  • --watch
    Watch the plugin for changes and rsync on change.

PHP Static Analysis

phan

jetpack phan [...projects] <options>
  • projects
    A space separated list of projects in a type/name format, for example plugins/jetpack. In addition, the following pseudo-projects are also available: monorepo, monorepo/actions-tool-setup-composer-plugin, monorepo/cli-doc-parser, monorepo/e2e-commons.
  • -a, --all
    phan all the things!
  • --no-baseline
    Do not use the baseline file to mute any previously existing issues.
  • --update-baseline
    Update Phan baseline to the current state.
  • --no-use-uncommitted-composer-lock
    Don’t use an uncommitted composer.lock when running the analysis.
  • --concurrency [n]
    The maximum number of phan tasks to run concurrently. 10 by default.
  • --format
    Output format. One of: text, emacs, github or json.
  • --width
    Report text width for the text format. 181 by default.
  • --automatic-fix
    Enable Phan’s automatic fixing.
  • --debug
    Run Phan with the debug option enabled.
  • --include-analysis-file-list
    Comma-separated list of files to analyze.
  • --filter-issues [list]
    Comma-separated list of issue codes to filter for. Only these issues will be reported.

Project Management

generate

Generates a new project and the basic boilerplate.

jetpack generate [type] <options>
  • type
    The type of the project to generate: package, js-package or plugin.
  • --name [name]
    The name of the new project.

dependencies

Lists the dependencies for a monorepo project.

jetpack dependencies [subcommand] [...projects] <options>
  • subcommand
    Whether to print json dependency data, a list of projects, or a build-order.
  • projects
    A space separated list of projects for which to print the dependencies in a type/name format. For example plugins/jetpack.
  • --git-changed
    Include projects changed in git. Value is appropriate for git diff.
  • --ignore-root
    Ignore the monorepo root.
  • --no-dev
    Ignore dev dependencies.
  • --pretty
    Pretty-print json or build-order output.

release

Runs a release script for a project.

jetpack release [project] [script]
  • project
    The project for which to run the release script in a type/name format. For example plugins/jetpack.
  • script
    The release script to run. One of: changelog, readme, release-branch, amend or version.