Skip to content

CLI ​

The package installs a lifecycle command. With npx, run it by the package name, npx nx-lifecycle.

Every command takes --cwd, the directory other paths are resolved from (default .).

lifecycle ​

The default command. Writes lifecycle targets into nx.json and every project.json, like the executor. Configuration comes from a config file; it can't be passed inline.

sh
npx nx-lifecycle --config-file ./my-lifecycle.json --dry-run
FlagTypeDefaultDescription
--config-filestringlifecycle.jsonConfig file with stages and bindings.
--check, --cibooleantrue in CIWrite nothing, and fail if any file is out of date.
--dry-runbooleanfalseWrite nothing.

explain ​

Prints what runs, in which order, for the stages of a project: each stage after the stages it depends on, its hooks, and the bound targets the project declares. A ^ dependency lists the upstream projects it runs.

sh
npx nx-lifecycle explain <project> [stage]
sh
npx nx-lifecycle explain my-lib       # every stage
npx nx-lifecycle explain my-lib test  # test, and the stages it runs after
my-lib

1. build
   after: ^build (my-utils)
   build:pre (nothing bound)
   build:run
     tsc

2. test
   after: build
   test:run
     mocha
     e2e-test (also after: my-server:build)
   test:report
     coverage-report
ArgumentDescription
projectRequired. Name of the Nx project.
stageOnly this stage, and the stages it runs after.
--config-fileConfig file, used when nx.json doesn't register the plugin. Default lifecycle.json.

Stages and bindings come from the plugin options in nx.json, or else from --config-file. Bound targets and their other dependencies come from the project as Nx resolves it, after targetDefaults and project.json.