|
| 1 | +--- |
| 2 | +id: PatternFly CLI |
| 3 | +title: PatternFly CLI |
| 4 | +section: get-started |
| 5 | +--- |
| 6 | + |
| 7 | +import './get-started.css'; |
| 8 | +import { Alert } from '@patternfly/react-core'; |
| 9 | + |
| 10 | +The [PatternFly CLI](https://github.com/patternfly/patternfly-cli) is a command-line tool for scaffolding projects, applying code changes, and running common project tasks. It is published as [`@patternfly/patternfly-cli` on npm](https://www.npmjs.com/package/@patternfly/patternfly-cli). |
| 11 | + |
| 12 | +## What you can do |
| 13 | + |
| 14 | +- **Scaffold projects** from built-in or custom templates. |
| 15 | +- **Automate code updates** for repetitive changes. |
| 16 | +- **Run workflows** such as init, sync with GitHub, updates, and deploys to GitHub Pages. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +Before you install the CLI, set up: |
| 21 | + |
| 22 | +1. **[Node.js and npm](https://nodejs.org/)** (supported versions **20–24**). |
| 23 | +1. **[Corepack](https://nodejs.org/api/corepack.html)** — included with Node.js; enable it with `corepack enable` after installing Node. |
| 24 | +1. **[GitHub CLI](https://cli.github.com/)** (`gh`) — required for commands that talk to GitHub. |
| 25 | + |
| 26 | +## Install |
| 27 | + |
| 28 | +Install the CLI globally: |
| 29 | + |
| 30 | +```sh |
| 31 | +npm install -g @patternfly/patternfly-cli |
| 32 | +``` |
| 33 | + |
| 34 | +## Check your setup |
| 35 | + |
| 36 | +Run the doctor command to verify prerequisites: |
| 37 | + |
| 38 | +```sh |
| 39 | +patternfly-cli doctor |
| 40 | +``` |
| 41 | + |
| 42 | +To try to fix missing pieces automatically (Corepack and GitHub CLI only): |
| 43 | + |
| 44 | +```sh |
| 45 | +patternfly-cli doctor --fix |
| 46 | +``` |
| 47 | + |
| 48 | +<Alert title="Node.js must be installed separately" variant="warning" isInline> |
| 49 | +The `doctor --fix` option does not install or upgrade Node.js. If Node.js is missing or below version 20, install the current **LTS** release from [nodejs.org](https://nodejs.org/). |
| 50 | +</Alert> |
| 51 | + |
| 52 | +## Commands |
| 53 | + |
| 54 | +After installation, run: |
| 55 | + |
| 56 | +```sh |
| 57 | +patternfly-cli [command] |
| 58 | +``` |
| 59 | + |
| 60 | +| Command | Description | |
| 61 | +| --- | --- | |
| 62 | +| `doctor` | Check requirements; use `--fix` to enable Corepack and install `gh` where supported. | |
| 63 | +| `create` | Create a new project from a template. | |
| 64 | +| `list` | List available templates (built-in and custom). | |
| 65 | +| `update` | Update the project to a newer PatternFly-oriented version where applicable. | |
| 66 | +| `init` | Initialize a git repository and optionally create a GitHub repo. | |
| 67 | +| `save` | Commit and push changes on the current branch. | |
| 68 | +| `load` | Pull the latest changes from GitHub. | |
| 69 | +| `deploy` | Build and deploy the app to GitHub Pages. | |
| 70 | + |
| 71 | +For the most up-to-date flags and behavior, see the [PatternFly CLI README](https://github.com/patternfly/patternfly-cli/blob/main/README.md) on GitHub. |
| 72 | + |
| 73 | +## Custom templates |
| 74 | + |
| 75 | +You can merge your own templates with the built-ins by passing a JSON file with `--template-file` (or `-t`): |
| 76 | + |
| 77 | +```sh |
| 78 | +patternfly-cli create my-app --template-file ./my-templates.json |
| 79 | +patternfly-cli list --template-file ./my-templates.json |
| 80 | +``` |
| 81 | + |
| 82 | +Each entry is an object with at least `name`, `description`, and `repo` (clone URL). Optional fields include `options` (extra `git clone` arguments) and `packageManager` (`npm`, `yarn`, or `pnpm`; default is `npm`). If a custom template uses the same `name` as a built-in one, the custom definition wins. |
| 83 | + |
| 84 | +Example: |
| 85 | + |
| 86 | +```json |
| 87 | +[ |
| 88 | + { |
| 89 | + "name": "my-template", |
| 90 | + "description": "My custom project template", |
| 91 | + "repo": "https://github.com/org/repo.git", |
| 92 | + "options": ["--single-branch", "--branch", "main"], |
| 93 | + "packageManager": "npm" |
| 94 | + } |
| 95 | +] |
| 96 | +``` |
| 97 | + |
| 98 | +## Source and releases |
| 99 | + |
| 100 | +The CLI is developed in the open at [github.com/patternfly/patternfly-cli](https://github.com/patternfly/patternfly-cli). Report issues or contribute there; release notes and tags are published on the repository’s [Releases](https://github.com/patternfly/patternfly-cli/releases) page. |
0 commit comments