A command-line interface for Panfactum that helps with infrastructure setup and management for the Panfactum framework.
All commands are run from the root of the project (packages/cli), from a terminal:
| Command | Action |
|---|---|
bun run build:binary |
Builds the binary to packages/cli/bin/pf |
bun run check |
Runs the typechecker |
bun run lint |
Checks for linting errors (read-only) |
bun run lint:fix |
Auto-fix lint errors (some errors won't be autofixable) |
bun test |
Runs the unit tests |
This is an CLI built on Clipanion. This CLI expects to be run in the Panfactum devShell and is built with Bun.
All code is written in Typescript and uses bun as the package manager. We aim to enable the strictest possible type-checking and linting whenever possible.
Besides Clipanion and Bun, take note of the following key dependencies:
- listr2 - For running multi-step tasks with a pleasing UX
- Inquirer.js - For getting user input in various formats through the terminal
- picocolors - For terminal output formatting
- open - For opening browser windows
- AWS SDK v3 - For interacting with the AWS API
- Kubernetes SDK - For interacting with the Kubernetes API
- Zod v3 - For input validation
- yaml - For parsing and outputting YAML-formatted strings
- ini - For parsing and outputting INI-formatted strings
src/- Contains the CLI source codefiles/- Static files that are bundled directly with the CLI (the CLI is often used to generate files)templates/- Files that are templated by the CLI during file creationcommands/- Contains the actual command definitions and command-specific helper utilitiesutil/- All utility code that is used throughout the CLIindex.ts- The main entrypoint that is run when the CLI is executed.
The command directory structure follows the CLI command structure. For example, the code for pf cluster add can be found
at src/commands/cluster/add. The main entrypoint for every command is the command.ts file; all other files in the
command directory are command-specific helpers.
We have the following top-level groups for commands:
aws- Commands that perform operations against the AWS APIbuildkit- Commands that perform operations against the Buildkit resources (optionally deployed as a part of the Panfactum installation)cluster- Commands for installing and managing Kubernetes clustersconfig- Commands for managing and debugging the Panfactum installation's configurationdb- Commands for interacting with databases in the Panfactum installationdevshell- Commands for managing the local DevShelldocker- Docker credential helpersdomain- Commands for adding and managing DNS connected to the Panfactum installationenv- Commands for installing and managing Panfactum environmentsiac- Commands for interacting with the IaC configurationkube- (Deprecated) Needs to be moved toclustersso- Commands for interacting with the single sign-on configuration for the Panfactum installationtunnel- Commands for creating and managing network tunnels using the Panfactum SSH bastionsvault- Commands for interacting with Hashicorp Vault installationswelcome- (Deprecated) Needs to be moved todevshellwf- Commands used as a part of the Panfactum-provided CI/CD workflows
If we re-use logic across multiple commands, we attempt to group those in src/util. We have the following groupings in that directory:
aws- Interacting with AWSbrowser- Interacting with web browsersbuildkit- Interacting with Moby Buildkitcommand- High-level command utilitiesconfig- Interacting with the Panfactum configurationcontext- (Deprecated) Move tocommanddb- Interacting with databases installed by Panfactumdevshell- Interacting with the local DevShelldocker- (Deprecated) Move toimagesdomains- Interacting with DNSeks- (Deprecated) Move toawserror- Utilities for creating and handling JS Errorsfs- Interacting with the filesystemgit- Interacting withgitjson- Handling JSON strings and fileskube- Interacting with Kuberneteslistr- Wrappers and utilities for interacting with thelistr2task runnernetwork- Network primitivesposthog- Interacting with Posthogsops- Interacting with sops (encrypted files)sso- Interacting with the Panfactum SSO configurationstreams- Managing Bun streamssubprocess- Managing subprocesses created by CLI invocationsterragrunt- Managing calls to Terragrunttunnel- Managing network tunnelsvault- Interacting with Hashicorp Vaultyaml- Handling YAML strings and fileszod- Zod utilities and validation wrappers
Be sure to review and follow the guidelines documented in our STYLEGUIDE when making contributions.