-
Notifications
You must be signed in to change notification settings - Fork 147
feat: added documentation for patternfly cli. #5009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+149
−0
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
113709f
feat: added documentation for patternfly cli.
dlabaj 10229ed
chore: updated with comments from team.
dlabaj 2a4b164
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj a24d088
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj f4d07e2
fix: updated with review comments.
dlabaj 58cd3ac
chore: updated with additional review comments.
dlabaj ff6bbd2
chore: prereq. section.
dlabaj 22dc0b7
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj 019cc41
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj 7ce8865
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj 1310e4b
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj fca5d68
Update packages/documentation-site/patternfly-docs/content/AI/pattern…
dlabaj 78c08c7
Merge branch 'main' into pfcli-dev-update
dlabaj 4e0975d
chore: fixed code format
dlabaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
packages/documentation-site/patternfly-docs/content/AI/patternfly-cli.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| --- | ||
| id: PatternFly CLI | ||
| title: PatternFly CLI | ||
| section: AI | ||
| --- | ||
|
|
||
| The [PatternFly CLI](https://github.com/patternfly/patternfly-cli) is a command-line tool for scaffolding projects, performing code modifications, and running project-related tasks. It streamlines everyday development work and PatternFly upgrades, making it convenient and easy to work straight from the terminal. You can run it in the terminal on its own, or use it from an AI-enabled editor (such as [Cursor](https://www.cursor.com/)) so coding agents can rely on the same predictable commands for scaffolding, updates, and git workflows. The published package is [`@patternfly/patternfly-cli` on npm](https://www.npmjs.com/package/@patternfly/patternfly-cli). | ||
|
|
||
| The npm package installs two equivalent entry points: `patternfly-cli` and the shorter alias `pfcli`. The examples below use `patternfly-cli`; substitute `pfcli` if you prefer. | ||
|
|
||
| ## What does the PatternFly CLI help with? | ||
|
|
||
| - **Project scaffolding:** Quickly set up new PatternFly based projects for development and prototyping via predefined templates. | ||
| - **Code modifications:** Automate repetitive code changes to help accelerate PatternFly version upgrades. | ||
| - **Task execution:** Run project-related tasks such as committing and pushing changes, pulling updates, and deploying your app to GitHub Pages. | ||
|
|
||
|
|
||
| ## How do I set up PatternFly CLI? | ||
|
|
||
| ### Prerequisites | ||
| There are a few key prerequisites to meet before using PatternFly CLI. For macOS, WSL, and Linux, we recommend using [install script](#install-script-macos-and-linux) to address the following prerequisites (you might still need administrator access for system packages). For a Windows-based system, you will need to install the following items manually: | ||
|
|
||
| - [Node.js](https://nodejs.org/) (Versions 20–24) and [npm](https://www.npmjs.com/) | ||
| - [Corepack](https://nodejs.org/api/corepack.html), which is included with Node.js. After installing npm, enable via `corepack enable` | ||
| - [GitHub CLI](https://cli.github.com/) | ||
|
|
||
| ## Installation | ||
|
|
||
|
edonehoo marked this conversation as resolved.
|
||
| ### Install script (macOS and Linux) | ||
|
|
||
| You can pipe the repository install script into `bash`. This installs Node.js with [nvm](https://github.com/nvm-sh/nvm) when `node` is not available, enables Corepack, installs GitHub CLI when it is missing, and installs the CLI globally from npm: | ||
|
|
||
| ```sh | ||
| curl -fsSL https://raw.githubusercontent.com/patternfly/patternfly-cli/main/scripts/install.sh | bash | ||
| ``` | ||
|
|
||
|
edonehoo marked this conversation as resolved.
|
||
| The script might prompt you to include `sudo` when your system package manager installs GitHub CLI. | ||
|
|
||
| ### Windows | ||
|
|
||
| After installing the [prerequisites](#prerequisites) on your machine, install the published package globally: | ||
|
|
||
| ```sh | ||
| npm install -g @patternfly/patternfly-cli | ||
| ``` | ||
|
|
||
| ## How do I use PatternFly CLI? | ||
|
|
||
| After installation, you can verify the latest version of the CLI has been installed by running the following terminal command: | ||
|
|
||
| ```sh | ||
| patternfly-cli --version | ||
| ``` | ||
|
|
||
|
dlabaj marked this conversation as resolved.
|
||
| ### Available CLI commands | ||
| Once the PatternFly CLI is installed, you can run the following commands via `patternfly-cli [command]`: | ||
|
|
||
| | Command | Usage | | ||
|
edonehoo marked this conversation as resolved.
|
||
| | --- | --- | | ||
| | `create` | Create a new project from the available templates. | | ||
| | `list` | List all available templates (built-in and optional custom). | | ||
| | `update` | Migrate your project to a newer PatternFly version using codemods, which handle import changes, component renames, and other breaking changes automatically.| | ||
| | `cli-upgrade` | Upgrade the globally installed CLI to the latest npm release. It runs `npm install -g @patternfly/patternfly-cli@latest`—use your package manager’s equivalent if you did not install with npm. | | ||
| | `init` | Initialize a git repository and optionally create a GitHub repository. | | ||
| | `save` | Commit and push changes to the current branch. | | ||
| | `load` | Pull the latest updates from GitHub. | | ||
| | `deploy` | Build and deploy your app to GitHub Pages. | | ||
|
|
||
| For the most up-to-date flags and behavior guidance, refer to [PatternFly CLI README](https://github.com/patternfly/patternfly-cli/blob/main/README.md) on GitHub. | ||
|
|
||
| ### Predefined templates | ||
|
|
||
| Built-in templates ship with the CLI. Each row is the template `name` you pass to `patternfly-cli create` (or choose from the interactive prompt). To print the list from your installed version, run `patternfly-cli list`. | ||
|
dlabaj marked this conversation as resolved.
Outdated
|
||
|
|
||
| | Template name | Description | | ||
| | --- | --- | | ||
| | `starter` | Starter template for a PatternFly React TypeScript project | | ||
| | `compass-starter` | Starter template for a PatternFly Compass theme TypeScript project | | ||
| | `nextjs-starter` | Starter template for a PatternFly Next.js project | | ||
|
|
||
| Template definitions in source: [patternfly-cli `src/templates.ts`](https://github.com/patternfly/patternfly-cli/blob/main/src/templates.ts). | ||
|
dlabaj marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Custom templates | ||
|
edonehoo marked this conversation as resolved.
|
||
|
|
||
| In addition to the built-in templates, you can add your own templates by passing a JSON file with `--template-file` (or `-t`). Custom templates are merged with the built-in list—if a custom template has the same `name` as a built-in template, the custom definition is used. | ||
|
dlabaj marked this conversation as resolved.
Outdated
|
||
|
|
||
| **Create a project based on custom templates:** | ||
|
|
||
| ```sh | ||
| patternfly-cli create my-app --template-file ./my-templates.json | ||
| ``` | ||
|
|
||
| **List templates included in custom file:** | ||
|
|
||
| ```sh | ||
| patternfly-cli list --template-file ./my-templates.json | ||
| ``` | ||
|
|
||
| **JSON format** (Array of template objects, shown in the same shape as the built-in templates): | ||
|
|
||
| ```json | ||
| [ | ||
| { | ||
| "name": "my-template", | ||
| "description": "My custom project template", | ||
| "repo": "https://github.com/org/repo.git", | ||
| "options": ["--single-branch", "--branch", "main"], | ||
| "packageManager": "npm" | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| - **`name`** (required): Template identifier | ||
| - **`description`** (required): Short description shown in prompts and `list` | ||
| - **`repo`** (required): Git clone URL | ||
| - **`options`** (optional): Array of extra arguments for `git clone` (such as `["--single-branch", "--branch", "main"]`) | ||
| - **`packageManager`** (optional): `npm`, `yarn`, or `pnpm`; defaults to `npm` if omitted | ||
|
|
||
| ## Uninstalling PatternFly CLI | ||
|
|
||
| ### Uninstall script (macOS and Linux) | ||
|
|
||
| You can pipe the repository uninstall script into `bash`. It removes the globally installed `@patternfly/patternfly-cli` package with npm. It does **not** remove Node.js, nvm, Corepack, or GitHub CLI: | ||
|
|
||
| ```sh | ||
| curl -fsSL https://raw.githubusercontent.com/patternfly/patternfly-cli/main/scripts/uninstall.sh | bash | ||
| ``` | ||
|
|
||
| ### Windows | ||
|
|
||
| If you installed the published package globally with npm, remove it with: | ||
|
|
||
| ```sh | ||
| npm uninstall -g @patternfly/patternfly-cli | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.