Skip to content

cwp inventory snapshot

shipped 1.0.0
cwp inventory snapshot [env] [flags]

This name is an alias. The work moved to cwp pull --only inventory, and that page documents it. This spelling still runs for one minor cycle.

Acts on the local site. Name an environment to act there instead.

tree ← site

ArgumentWhat it isDefault
[env]environment to read (default: default_environment in cwp.yml)
FlagWhat it doesDefault
--with-agentwith —dry-run on a host with no shell: install and remove the PHP agent so the plan is realoff

Plus the shared flags --json, -v, --verbose, -q, --quiet and --dry-run.

What it does

snapshot writes inventory.yml from what the site has installed, and touches nothing else.

snapshot reads the site and writes nothing to it, so you can point it at production. That is often the right move: cwp inventory snapshot prod records what production has, and a fresh clone needs exactly that to reproduce it.

Four sections, because a site is all four:

version: 1
core:
  version: "7.0.3"
  locale: de_DE
languages: [de_DE]
plugins: [...]
themes: [...]

snapshot records the core version as observed and does not pin it. A host that applies its own updates makes a written version stale within days. A file that is wrong every Tuesday teaches people to ignore it. apply reads the version as a floor and never comes back down to it.

languages lists the translations on the site beyond the built-in one. snapshot never records en_US. It is the source language rather than a translation of it, so every site in the world reports it and no site can remove it.

core.locale and languages answer two different questions, and a site can disagree with itself about them. locale is what WPLANG names: the language the site means to run in. languages is what is on disk. WP-CLI marks the site’s own locale active whether or not anyone ever downloaded its translation, so snapshot checks the disk rather than the status column. A locale that appears in core: and not in languages is exactly that state, and apply installs it.

What it preserves rather than observes

A site records neither where a plugin came from nor which environments it belongs on. So snapshot reads the existing inventory.yml before it writes one and carries both fields forward:

  • an entry’s source: and environments: survive the run; its version and status still come from the site;
  • snapshot keeps an entry this side does not have when its environments: name somewhere else, and drops it otherwise. A plugin scoped to local is not missing from production.

The run names both: a source: it carried without checking, and an entry it kept for another environment. A line you did not expect in the diff has its explanation on the screen above it.

Without that carry-over, every snapshot would delete the fields, and you would re-add them by hand after each run.

Your comments survive too. Both fields are decisions, and a decision in a config file wants a line saying why. So snapshot edits the file rather than rewriting it:

themes:
  # Not on wordpress.org and licensed, so it travels as a ZIP rather than a
  # slug. Whoever builds an environment fetches it from the vendor account.
  - name: acme
    version: 2.4
    status: parent
    source: media/acme.zip

The comment stays where you put it, and so does anything else the file holds that cwp does not write. An entry cwp removes takes the comment directly above it along. A comment above the first entry of a list belongs to the list in YAML’s own model. That one stays, and it is yours to remove.

cwp’s own header at the top is the exception. It explains these fields, so it counts as generated text, and cwp brings it up to date on every run. Anything you write below a blank line under it stays as it is.

The same holds for roles.yml and the files under settings/.

Example

cwp inventory snapshot        # record what is installed locally
cwp inventory snapshot prod   # …or what production has

What it does not do

It writes nothing to the site: not an install, not an activation, not a core update. The only file it changes is inventory.yml in your repository.

It records no plugin under a tracked path, no must-use plugin and no drop-in.