### Quick Start Project Initialization Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx These commands initiate the project setup and development environment. 'make init' is used for initial setup, and 'make dev' starts the development server. 'make dev' is not required if Docker is running in 'full mode'. ```bash make init make dev # This is not required if running Docker in "full mode" ``` -------------------------------- ### Create .env File from Example Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Copies the example environment file (.env.example) to a new file named .env. This is necessary for projects installed via GitHub integration to set up environment variables and secrets. ```bash cp .env.example .env ``` -------------------------------- ### Build and Run Front End with npm Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Standard npm commands to install front-end dependencies and start the development server for your application's front end. Assumes Node.js and npm are installed. ```bash npm install npm run dev ``` -------------------------------- ### Install and Run Pegasus Project Locally Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Commands to clone the Pegasus project, install dependencies using npm, and start the development server with auto-reloading. Also includes commands for building the project for production. ```bash # Clone repository git clone https://github.com/saaspegasus/pegasus-docs.git cd pegasus-docs # Install dependencies npm install # Start development server with auto-reload npm run dev # Server runs at http://localhost:4321 # Build for production npm run build # Output goes to dist/ directory ``` -------------------------------- ### Run Django Development Server Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Commands to start the Django development server. You can use either the 'uv' tool or a standard Python virtual environment for execution. ```bash # with uv uv run manage.py runserver ``` ```bash # or with normal venv python ./manage.py runserver ``` -------------------------------- ### Install Python Package Requirements Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Installs Python package requirements using either 'uv' for dependency synchronization or 'pip-tools' with a requirements file. It also provides troubleshooting tips for 'psycopg2' installation on Linux and OpenSSL on macOS. ```bash # with uv uv sync # or if using pip tools pip install -r dev-requirements.txt ``` -------------------------------- ### Run Django Database Migrations Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Commands to apply pending database migrations to your project's database. Supports execution via 'uv' or a standard Python virtual environment. ```bash # with uv uv run manage.py migrate ``` ```bash # or with normal venv python ./manage.py migrate ``` -------------------------------- ### Initialize Git Repository and Commit Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Commands to initialize a new Git repository in a project directory downloaded as a zip file. It adds all files to staging, commits them with an initial message, and creates a 'pegasus' branch for future upgrades. ```bash git init git add . ``` ```bash git commit -am "initial project creation" ``` ```bash git branch pegasus ``` -------------------------------- ### Setup and Run Vite React Frontend Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/experimental/react-front-end.mdx Commands to navigate to the frontend directory, install npm packages, create the environment file, and start the development server for a standalone Vite/React application. This requires the Django backend to be running. ```bash cd frontend npm install cp .env.example .env npm run dev ``` -------------------------------- ### Clone Project from GitHub Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx This command clones a Pegasus project from a GitHub repository. It requires the project's Git URL, typically found on its GitHub page. This method is recommended for easier future upgrades and changes. ```bash git clone https://github.com/user/project-id.git ``` -------------------------------- ### Create Postgres Database Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Command to create a new PostgreSQL database for your project. It requires specifying the username, host, port, and project name. You may be prompted for the postgres user's password. ```bash createdb -U postgres -h localhost -p 5432 {{ project_name }} ``` ```bash sudo -u postgres createdb {{ project_name }} ``` -------------------------------- ### Create Django Database Migrations Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Commands to generate database migration files for your Django application. This can be executed using either the 'uv' tool or a standard Python virtual environment. ```bash # with uv uv run manage.py makemigrations ``` ```bash # or with normal venv python ./manage.py makemigrations ``` -------------------------------- ### Install uv Package Manager (Windows) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx Installs the uv package manager on Windows systems using a PowerShell script. This command bypasses execution policy restrictions to fetch and run the installation script. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Synchronize Project Dependencies with uv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx Synchronizes project dependencies and sets up a Python virtual environment using the uv package manager. This command installs the correct Python version (if needed), creates a .venv folder, and installs all project dependencies. ```bash uv sync ``` -------------------------------- ### Install Front-End Dependencies (Docker) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/overview.mdx Installs front-end dependencies using Docker. This command is an alternative to `npm install` for users who prefer or require a Dockerized environment for building. It ensures that dependencies are installed within a containerized setup. ```bash make npm-install ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Changes the current working directory to the project's root folder. This is a standard command-line operation necessary before executing project-specific commands. ```bash cd {{ project_name }} ``` -------------------------------- ### Initial Kamal Deployment Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Executes the Kamal setup command to perform all necessary tasks for the initial deployment of the application. This includes server connection, Docker installation, registry login, image building and pushing, and container orchestration. ```bash kamal setup ``` -------------------------------- ### Start Docker Services and Initialize Application Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/docker.mdx Commands to start the Docker services for the application. `make start` initiates the database services (PostgreSQL and Redis) and, in full-Docker mode, all application processes. `make init` additionally handles database migrations and application bootstrapping, intended for the first run. ```bash make start ``` ```bash make init ``` -------------------------------- ### macOS OpenSSL Reinstallation and Path Export Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/getting-started.mdx Commands for macOS users to reinstall OpenSSL using Homebrew and export the library path. This is often required to resolve linking issues with libraries like OpenSSL during Python package installations. ```bash brew reinstall openssl export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ ``` -------------------------------- ### Webpack Entry Configuration Example Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/migrating.md This JavaScript code snippet demonstrates the 'entry' configuration in a Webpack setup. It specifies the input files for various bundles, including base styles, Tailwind CSS, global site JavaScript, and application-specific JavaScript/React components. This configuration is crucial for understanding how Webpack processes and bundles project assets. ```javascript entry: { 'site-base': './assets/site-base.js', // base styles shared between frameworks 'site-tailwind': './assets/site-tailwind.js', // required for tailwindcss styles site: './assets/javascript/site.js', // global site javascript app: './assets/javascript/app.js', // logged-in javascript dashboard: './assets/javascript/shadcn-dashboard/index.jsx', teams: './assets/javascript/teams/teams.jsx', 'edit-team': './assets/javascript/teams/edit-team.jsx', 'chat': './assets/javascript/chat/chat.jsx', } ``` -------------------------------- ### Add Simple-Datatables Library Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/design-patterns.mdx This example shows how to install and integrate the `simple-datatables` library into a Pegasus project. It involves installing the package via npm, importing it into `site.js`, and exposing it globally as `window.DataTable` for use throughout the application. ```bash npm install simple-datatables ``` ```javascript import { DataTable } from 'simple-datatables'; window.DataTable = DataTable; ``` ```javascript // initialize the table with id "mytable" const dataTable = new DataTable("#mytable", { searchable: true, fixedHeight: true, }); ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/saaspegasus/pegasus-docs/blob/main/README.md Installs all necessary project dependencies using the npm package manager. This is a prerequisite for building or running the documentation locally. ```bash npm install ``` -------------------------------- ### Install Daphne for Development (Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/async.mdx Installs the Daphne ASGI server for development environments. This involves compiling development requirements and then installing them. Ensure 'channels[daphne]' is listed in your 'dev-requirements.in' file. ```bash pip-compile requirements/dev-requirements.in pip install -r requirements/dev-requirements.txt ``` -------------------------------- ### Serve Documentation Locally with Auto-reload Source: https://github.com/saaspegasus/pegasus-docs/blob/main/README.md Starts a local development server to view the documentation with live-reloading. Changes made to the documentation content will be reflected automatically in the browser. ```bash npm run dev ``` -------------------------------- ### Install and Run Pre-commit Hooks (Bash) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/code-structure.mdx Demonstrates how to install pre-commit hooks and run them manually against staged or all files. Pre-commit hooks automate code formatting and style checks before committing. ```bash $ pre-commit install --install-hooks pre-commit installed at .git/hooks/pre-commit # run all hooks against currently staged files pre-commit run # run all the hooks against all the files. This is a useful invocation if you are using pre-commit in CI. pre-commit run --all-files ``` -------------------------------- ### Install uv Package Manager Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/cookbooks.mdx This command installs the uv package manager using a curl script. It fetches the installation script from the provided URL and executes it. Ensure you have curl installed to use this command. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install OpenAPI Generator CLI Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/apis.mdx Installs the OpenAPI Generator CLI globally. This command requires Node.js and npm to be installed. Java is also a prerequisite for running the generator natively. ```bash npm install @openapitools/openapi-generator-cli -g ``` -------------------------------- ### Create Fly.io App and Services Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/fly.md Initializes a new Fly.io application, sets up its configuration, and prompts for service additions like PostgreSQL and Redis. Requires the flyctl CLI to be installed and authenticated. ```bash $ fly launch --dockerfile Dockerfile.web \ --dockerignore-from-gitignore \ --no-deploy \ --name {app-name} \ --region ord ``` -------------------------------- ### Stripe CLI for Local Webhook Setup Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx Commands to use the Stripe CLI for setting up local webhook endpoints during development. This involves printing the webhook secret and forwarding events to a local server. ```bash stripe listen --print-secret ``` ```bash docker run --network host --rm -it stripe/stripe-cli listen \ --print-secret \ --api-key sk_test_ ``` ```bash ./manage.py bootstrap_dev_webhooks --secret ``` ```bash stripe listen \ --forward-to http://localhost:8000/stripe/webhook//" ``` ```bash docker run --network host --rm -it stripe-cli listen \ --forward-to localhost:8000/stripe/webhook// \ --api-key sk_test_ ``` -------------------------------- ### Celery Beat Configuration Example (Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This snippet provides an example of how to configure Celery Beat for scheduled tasks within a Pegasus deployment. Celery Beat is a scheduler that lets you dispatch the Celery tasks periodically. This configuration is now supported out-of-the-box with Kamal deployments, simplifying the setup of background jobs and recurring processes. ```python # Example Celery Beat configuration (celeryconfig.py or similar) from celery.schedules import crontab CELERY_BEAT_SCHEDULE = { 'add-every-30-seconds': { 'task': 'tasks.add', 'schedule': crontab(minute='*/1'), 'args': (16, 16), }, } CELERY_TIMEZONE = 'UTC' ``` -------------------------------- ### Python Package Installation with uv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md Illustrates the use of 'uv' for installing Python packages, as adopted in Dockerfiles and GitHub actions for the Pegasus project. ```bash make pip-compile ``` -------------------------------- ### Install Python Packages Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/packages.mdx Instructions for installing Python packages. Natively, this is done using `pip install -r requirements.txt` after activating the virtual environment. Within Docker, packages are installed at build time, requiring a container rebuild. ```bash # Native installation pip install -r requirements/requirements.txt # Docker container rebuild docker compose build ``` -------------------------------- ### Install Node.js with GPG Key and Apt Source Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md Installs Node.js by adding the Nodesource GPG key and defining the package source list in the system's APT configuration. This ensures that `apt-get update` and `apt-get install nodejs` can retrieve and install the specified Node.js version. It's crucial for environments needing a specific Node.js version managed by the system's package manager. ```dockerfile # install node/npm RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ gpg --dearmor -o /usr/share/keyrings/nodesource.gpg RUN echo \ "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" \ tee /etc/apt/sources.list.d/nodesource.list && \ apt-get update && \ apt-get install nodejs -yqq ``` -------------------------------- ### Start Development Server with Docker Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/css/tailwind.mdx Starts the development server using Docker, which rebuilds CSS files as you make changes to your templates. This is an alternative to the npm command. ```bash make npm-dev ``` -------------------------------- ### Create New Documentation Page in Markdown Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Example of a Markdown file for creating a new documentation page within an Astro project using the Starlight theme. It includes frontmatter for title and description, and demonstrates embedding code snippets. ```markdown --- title: My Feature Guide description: Complete guide for implementing my feature with code examples and configuration details. --- ## Overview Feature description here. ## Setup Step-by-step instructions. ### Configuration ```python # settings.py MY_FEATURE_ENABLED = env('MY_FEATURE_ENABLED', default=True) MY_FEATURE_API_KEY = env('MY_FEATURE_API_KEY') ``` ### Usage example ```python from apps.my_feature import FeatureClient client = FeatureClient(api_key=settings.MY_FEATURE_API_KEY) result = client.process(data={'user_id': 123}) ``` ``` -------------------------------- ### Install Kamal using RubyGems Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Installs the Kamal deployment tool globally using RubyGems. Ensure you have a Ruby environment set up. It's recommended to use a Ruby version manager like rbenv. ```bash gem install kamal ``` -------------------------------- ### Test Docker Installation Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Verifies if Docker is installed on the system by checking its version. This is a prerequisite for running Kamal and Docker commands as a non-root user. ```bash docker -v ``` -------------------------------- ### Create Kamal Secrets File Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Copies the example secrets file to create the actual secrets file required by Kamal. This file should not be committed to source control. ```bash cp .kamal/secrets.example .kamal/secrets ``` -------------------------------- ### Run Vite Development Server using npm or make Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/vite.md Commands to start the Vite development server. This server serves front-end assets directly and enables fast page updates without browser reloads. Ensure this server is running throughout development. It also automatically refreshes the front end on file changes. ```bash npm run dev ``` ```bash make npm-dev ``` -------------------------------- ### Build Front-End Production Bundle (Shell) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/production-checklist.md This command sequence is used in a CI/CD process to build optimized front-end files for production. It involves installing dependencies and running the build script. Ensure `.gitignore` is updated to exclude compiled files. ```shell npm install && npm run build ``` -------------------------------- ### Default Kamal setup environment variable declarations Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This snippet includes additional environment variable declarations for the default Kamal setup. This enhances the configuration options available for deploying applications using Kamal. ```yaml # Example environment variables for Kamal ENV DEPLOY_ENV=production ENV DATABASE_URL=postgres://user:pass@host:port/db ``` -------------------------------- ### Copy and Source Environment File using bash Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/google-cloud.md These commands copy an example environment file to a new file and then load the variables defined in that file into the current shell environment. This is crucial for setting up project-specific configurations and secrets. ```bash cp deploy/.env.google.example deploy/.env.google source deploy/.env.google ``` -------------------------------- ### Build API Client using Docker Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/apis.mdx Builds the API client using Docker. This method avoids the need to install Java and other native dependencies. Assumes the Django server is running. ```bash make build-api-client ``` -------------------------------- ### Run Celery Worker (uv) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/celery.md Starts a Celery worker using uv for project management. This command is suitable for development environments, utilizing the 'solo' pool for simplicity. For production, consider 'prefork' or 'gevent' pools. ```bash uv run celery -A {{ project_name }} worker -l info --pool=solo ``` -------------------------------- ### Reboot and Deploy Commands for Kamal Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx A collection of Kamal CLI commands to manage application services, including rebooting PostgreSQL, Redis, and proxy containers, booting the proxy, and deploying the application. These commands are useful when initial setup fails. ```bash kamal accessory reboot postgres kamal accessory reboot redis kamal proxy reboot kamal proxy boot kamal deploy ``` -------------------------------- ### Configure Production Email Backend via Environment Variable Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md Provides an example of how to set the `EMAIL_BACKEND` setting using an environment variable. It also includes a commented-out example for configuring Mailgun for production email delivery. ```python import os EMAIL_BACKEND = os.environ.get("EMAIL_BACKEND", "django.core.mail.backends.console.EmailBackend") # Example for Mailgun (commented out): # EMAIL_BACKEND = "django_mailgun.MailgunBackend" # MAILGUN_DOMAIN = os.environ.get("MAILGUN_DOMAIN") # MAILGUN_API_KEY = os.environ.get("MAILGUN_API_KEY") ``` -------------------------------- ### Activate Python Virtual Environment using venv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx This command activates a previously created virtual environment. The `source` command modifies the current shell session to use the Python interpreter and packages installed within the specified environment. Remember to activate the environment each time you work on your project. ```bash source /path/to/environment/bin/activate ``` -------------------------------- ### Activate uv Virtual Environment Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx Activates the Python virtual environment created by uv. Once activated, standard Python commands can be used directly. ```bash source .venv/bin/activate ``` -------------------------------- ### Run Python Shell with uv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx Executes a Django management shell command within the context of a uv-managed Python environment. This is used to verify the uv environment setup. ```bash uv run manage.py shell ``` -------------------------------- ### Example of Unified Diff Format Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/upgrading.md Illustrates the unified diff format used in patch and reject files, showing lines removed (prefixed with '-') and lines added (prefixed with '+'). This example shows type annotations added to a Python function signature. ```diff -def is_member(user, team): +def is_member(user: CustomUser, team: apps.teams.models.Team) -> bool: ``` -------------------------------- ### Run Webpack Development Watch Mode Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/webpack.md Starts Webpack in watch mode, automatically rebuilding assets when front-end files are modified. ```bash npm run dev-watch ``` -------------------------------- ### Activate Python Virtual Environment using virtualenvwrapper Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx This command activates a virtual environment managed by `virtualenvwrapper`. Simply provide the name of your project's virtual environment (e.g., `{{ project_name }}`). `virtualenvwrapper` simplifies environment switching and management. ```bash workon {{ project_name }} ``` -------------------------------- ### Fix Dall-E example for latest OpenAI API Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This fix ensures that the Dall-E example works correctly with the latest OpenAI API. It addresses any compatibility issues that may have arisen due to API updates. ```python from openai import OpenAI client = OpenAI( # This is the default and can be omitted api_key=os.environ.get("OPENAI_API_KEY"), ) response = client.images.generate( model="dall-e-3", prompt="A cute baby sea otter playing with a ball.", size="1024x1024", quality="hd", n=1, ) image_url = response.data[0].url print(image_url) ``` -------------------------------- ### Fix ChatGPT example for latest OpenAI API Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This fix updates the ChatGPT example to be compatible with the latest OpenAI API. It ensures that the demo continues to function correctly with recent changes to the API. ```python from openai import OpenAI client = OpenAI( # This is the default and can be omitted api_key=os.environ.get("OPENAI_API_KEY"), ) chat_completion = client.chat.completions.create( model="gpt-4", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello, world!"} ] ) print(chat_completion.choices[0].message.content) ``` -------------------------------- ### Create Python Virtual Environment using virtualenvwrapper Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx This command utilizes `virtualenvwrapper` to create a new virtual environment. The `-p` flag specifies the Python interpreter, and `{{ project_name }}` is a placeholder for your project's name. `virtualenvwrapper` automatically manages environment locations, typically in `/home//.virtualenvs/`. ```bash mkvirtualenv -p python3.12 {{ project_name }} ``` -------------------------------- ### Install Tailwind CSS v3 for Upgrade Tool Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/css/tailwind.mdx This bash command installs Tailwind CSS version 3. This is a prerequisite for running the Tailwind upgrade tool, which helps automate migrations from older versions. ```bash npm install tailwindcss@3 ``` -------------------------------- ### Project Configuration Variables in TypeScript Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Example of defining project configuration variables using TypeScript, such as default Python and Node.js versions. These can be referenced within documentation content. ```typescript // src/config.ts export const defaultPythonVersion = '3.12'; export const defaultNodeVersion = '22'; // Use in documentation // Pegasus uses Python {{ defaultPythonVersion }} by default ``` -------------------------------- ### View Kamal Application Logs Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Command to view the logs of your Docker containers managed by Kamal. This is a crucial step for diagnosing deployment failures that persist after initial setup. ```bash kamal app logs ``` -------------------------------- ### Generate TypeScript Fetch API Client Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/apis.mdx Generates a TypeScript fetch API client using the OpenAPI Generator. This command requires the OpenAPI Generator CLI to be installed and a running Django server to fetch the schema from. The output is saved to the `./api-client/` directory. ```bash openapi-generator-cli generate -i http://localhost:8000/api/schema/ -g typescript-fetch -o ./api-client/ ``` -------------------------------- ### Run Application with Debugger Enabled Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/docker.mdx Start the web container with service ports enabled to allow for debugging tools like pdb or ipdb. This command ensures the container is accessible for debugging sessions. ```bash docker compose run --service-ports web ``` -------------------------------- ### Dynamic Stripe Product ID Configuration Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx Shows how to dynamically set Stripe product IDs in Django settings based on a `STRIPE_LIVE_MODE` flag. This allows for seamless switching between test and live Stripe accounts by referencing environment variables or settings. ```python STRIPE_LIVE_MODE = env.bool("STRIPE_LIVE_MODE", False) STRIPE_PRICE_STARTER = "prod_xyz" if STRIPE_LIVE_MODE else "prod_abc" ``` -------------------------------- ### Django Model for Workspace Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx Defines a Django model for a workspace, including a foreign key to the user who owns it. This is a foundational piece for user-based billing where user actions are tracked. ```python class Workspace(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='workspaces') # other workspace fields here ``` -------------------------------- ### Create .env.docker from .env.example with make setup-env Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This command automates the creation of the `.env.docker` file from `.env.example`, which is necessary for Docker-based environments. It simplifies environment configuration for local development and deployment. ```makefile make setup-env ``` -------------------------------- ### Initialize project and create .env.docker with make init Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md The `make init` command initializes the project and ensures that the `.env.docker` file is created from `.env.example` if it does not already exist. This is crucial for setting up the development environment, especially when using Docker. ```makefile make init ``` -------------------------------- ### Preview Deployments with Cloudflare (Bash) Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Explains how Cloudflare Pages automatically generates preview URLs for pull requests and how to run a local preview of the documentation site. ```bash # Cloudflare automatically creates preview URLs for pull requests # Format: https://[hash].pegasus-docs.pages.dev npm run preview # Local preview at http://localhost:4321 ``` -------------------------------- ### Define Product Price Displays (Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx This snippet shows how to define display text for product prices, particularly useful for per-unit billing where the exact price might vary. It uses the `ProductMetadata` class and specifies different display strings for monthly and yearly plans. ```python ProductMetadata( stripe_id='', name=_('Graduated Pricing'), description='A Graduated Pricing plan', price_displays={ PlanInterval.month: 'From $10 per user', PlanInterval.year: 'From $100 per user', } ), ``` -------------------------------- ### Environment Variable Configuration in Bash Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This snippet demonstrates how environment variables are utilized for configuration, specifically moving example environment files (.env.dev.example, .env.production.example) to actual configuration files (.env.dev, .env.production). This is common in Dockerized development environments to avoid manual copying during builds. ```bash # Move example environment files to active configuration files # For Docker builds only cp .env.dev.example .env.dev cp .env.production.example .env.production ``` -------------------------------- ### Create Python Virtual Environment using venv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx This command utilizes Python's built-in `venv` module to create a virtual environment. Replace `python3.12` with your desired Python version and `/path/to/environment/` with the desired location for the environment files. This method is recommended for modern Python versions. ```bash python3.12 -m venv /path/to/environment ``` -------------------------------- ### Migrate Requirements to pyproject.toml using reqs-sync Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/cookbooks.mdx These commands utilize the 'reqs-sync' package to migrate project requirements from '.in' files to 'pyproject.toml'. They handle different groups like 'dev' and 'prod'. Ensure 'reqs-sync' is installed and the paths to your requirements files are correct. ```bash uv tool run reqs-sync reqs-to-toml requirements/requirements.in ``` ```bash uv tool run reqs-sync reqs-to-toml requirements/dev-requirements.in --group=dev ``` ```bash uv tool run reqs-sync reqs-to-toml requirements/prod-requirements.in --group=prod ``` -------------------------------- ### Dynamic ACTIVE_PRODUCTS List Configuration Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx Illustrates modifying the `ACTIVE_PRODUCTS` list in Django's metadata to use dynamic Stripe Product IDs fetched from settings, rather than hard-coded values. This is essential for managing product IDs across test and live Stripe environments. ```python ACTIVE_PRODUCTS = [ ProductMetadata( stripe_id=settings.STRIPE_PRICE_STARTER, # to something like this slug='starter', ... ] ``` -------------------------------- ### Rebuild Requirements Files with pip-compile Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/packages.mdx Commands to rebuild the `requirements.txt` file from `requirements.in` using pip-tools. This is done either natively or via a Dockerized build process. Ensure pip-tools is installed and the virtual environment is activated for native builds. ```bash # native version pip-compile requirements/requirements.in # docker version make pip-compile ``` -------------------------------- ### Run Celery Worker with Gevent Pool Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/celery.md Configures and runs a Celery worker utilizing the 'gevent' concurrency pool. This is beneficial for I/O-bound tasks and can also be used on Windows. Ensure 'gevent' is installed and that your Celery version supports it. ```bash pip install gevent celery -A {{ project_name }} worker -l info -P gevent ``` -------------------------------- ### Create and Store Application Settings Secret using gcloud Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/google-cloud.md These commands first copy a production environment example file and then save its contents as a secret named 'application_settings' in Google Cloud Secret Manager. It requires updating specific URL and IP values in the .env.production file before creation. ```bash cp .env.production.example .env.production gcloud secrets create application_settings --data-file .env.production ``` -------------------------------- ### Run Celery Worker (Standard Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/celery.md Starts a Celery worker using standard Python. This command is intended for development and uses the 'solo' pool. Production environments should opt for 'prefork' (CPU-bound tasks) or 'gevent' (I/O-bound tasks) pools for better performance and stability. ```bash celery -A {{ project_name }} worker -l info --pool=solo ``` -------------------------------- ### Access AI-optimized Documentation (Bash) Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Demonstrates how to fetch AI-friendly documentation using curl from the provided URLs. It showcases fetching essential, compact, and complete documentation sets. ```bash # Fetch AI-friendly documentation curl https://docs.saaspegasus.com/llms.txt # Returns prioritized documentation optimized for LLMs curl https://docs.saaspegasus.com/llms-small.txt # Returns compact version curl https://docs.saaspegasus.com/llms-full.txt # Returns complete documentation set ``` -------------------------------- ### Get Feature Gate Check Result (Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx The `get_feature_gate_check` function helps control access to features based on subscription plans. It takes a subscription holder and an optional list of plans to check against. It returns a `FeatureGateCheckResult` object indicating if the check passed and an optional message. ```python from apps.subscriptions.feature_gating import get_feature_gate_check def my_view(request): check_result = get_feature_gate_check(request.team, ["professional"]) if check_result.passed: do_actions_pro_only() else: logging.info(f"Pro actions skipped: {check_result.message}") ``` -------------------------------- ### Configure Stripe Confirmation URL (Production) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/subscriptions.mdx Sets the custom confirmation URL for Stripe products in a production environment. This directs Stripe to your live website for processing subscriptions after purchase. It requires replacing 'localhost:8000' with your site's URL and enabling HTTPS. ```text https:///subscriptions/confirm/?session_id={CHECKOUT_SESSION_ID} ``` -------------------------------- ### Create Python Virtual Environment using virtualenv Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/python/setup.mdx This command uses the `virtualenv` package to create a Python virtual environment. Specify the Python interpreter version with `-p` and the desired environment path. `virtualenv` is an alternative to `venv`, though `venv` is generally preferred for newer Python versions. ```bash virtualenv -p python3.12 /path/to/environment ``` -------------------------------- ### Vite Rollup Input Configuration Example Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/migrating.md This TypeScript code snippet shows the 'input' configuration within the 'build.rollupOptions' in a Vite project's configuration file. It mirrors the structure of Webpack's entry points, specifying the source files for various application bundles. This configuration is essential for Vite to correctly process and bundle assets, especially when migrating from Webpack. ```typescript build: { rollupOptions: { input: { 'site-base': path.resolve(__dirname, './assets/site-base.js'), 'site-tailwind': path.resolve(__dirname, './assets/site-tailwind.js'), 'site': path.resolve(__dirname, './assets/javascript/site.js'), 'app': path.resolve(__dirname, './assets/javascript/app.js'), 'dashboard': path.resolve(__dirname, './assets/javascript/shadcn-dashboard/index.jsx'), 'teams': path.resolve(__dirname, './assets/javascript/teams/teams.jsx'), 'edit-team': path.resolve(__dirname, './assets/javascript/teams/edit-team.jsx'), 'chat': path.resolve(__dirname, './assets/javascript/chat/chat.jsx'), }, } ``` -------------------------------- ### Apply Code Formatting with Ruff Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/cookbooks.mdx These commands use the 'ruff' tool to lint and format Python code. They fix linting issues and apply consistent formatting, including line length. Ensure 'ruff' is installed via pip. The `--extend-exclude migrations` flag prevents formatting of migration files. ```bash pip install ruff ``` ```bash ruff check --extend-exclude migrations --line-length 120 . --fix ``` ```bash ruff format --line-length 120 . ``` -------------------------------- ### Run Celery Beat with uv in Development Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/celery.md Demonstrates two ways to run Celery Beat using the `uv` package manager alongside Celery workers in a development environment. The first command runs Celery Beat alongside the worker with the `--beat` flag. The second command runs Celery Beat as a dedicated standalone process. Ensure a separate Celery worker is running if using the standalone process. ```bash # Alongside the Celery worker, you can run Celery Beat uv run celery -A {{ project_name }} worker -l info --beat # AS a dedicated process uv run celery -A {{ project_name }} beat -l info ``` -------------------------------- ### Full Deployment Shortcut for GCP Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/google-cloud.md A shortcut command that executes the complete deployment process, from building to deploying the Docker container to Google Cloud. ```bash make gcp-full-deploy ``` -------------------------------- ### Upgrade Pegasus Installer (Bash) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md Command to upgrade the Pegasus installer to version 0.0.2 or higher. This is a prerequisite for applying the latest changes in version 0.9.0. ```bash pip install --upgrade pegasus-installer>=0.0.2 ``` -------------------------------- ### Bootstrap Wagtail Content - Bash Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/wagtail.mdx Initializes Wagtail content within a Pegasus application. This command sets up default pages and blog posts. Ensure you have enabled the 'Use Wagtail' option during project creation. ```bash ./manage.py bootstrap_content ``` -------------------------------- ### Add Translations in .po File (Example) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/internationalization.mdx An example demonstrating how to add a French translation for a specific English string within a `.po` file. This involves finding the `msgid` and providing the corresponding `msgstr`. ```po msgid "My Team" msgstr "Mon Équipe" ``` -------------------------------- ### Database Backup using pg_dump Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/kamal.mdx Commands to perform a database backup. It first dumps the PostgreSQL database to a file on the host machine using `pg_dump`, and then demonstrates how to copy this dump file to your local machine using `scp`. ```bash kamal accessory exec postgres 'pg_dump -h localhost -p 5432 -U > db_dump.sql' --reuse scp kamal@yourapp.com:db_dump.sql ./ ``` -------------------------------- ### Create Database and User using gcloud Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/google-cloud.md These commands create a new database and a user for the PostgreSQL instance. The database name and user credentials (password) are expected to be defined in environment variables, which should be set by sourcing the .env.google file previously. ```bash gcloud sql databases create $DATABASE_NAME --instance $DATABASE_INSTANCE_NAME gcloud sql users create ${DATABASE_USER} --instance ${DATABASE_INSTANCE_NAME} --password ${DATABASE_PASSWORD} ``` -------------------------------- ### Initialize and Use TypeScript API Client Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/apis.mdx Demonstrates how to initialize the Pegasus API client with configuration, including base path and headers, and how to make a basic API call to fetch employee data. This client is auto-generated and should not be modified manually. ```javascript import {Cookies} from "./app"; import {Configuration, PegasusApi} from "./api-client"; const apiConfig = new Configuration({ basePath: 'https://yourserver.com/', // or pass this in via {{server_url}} template variable headers: { 'X-CSRFToken': Cookies.get('csrftoken'), } }) const client = new PegasusApi(apiConfig); client.employeesList().then((result) => { // do something with the API result here console.log('your employees are ', result.results); }); ``` -------------------------------- ### Catching Stripe Card Errors in Payments Example (Python) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This Python snippet illustrates how to catch potential Stripe card errors within the payments example. This ensures a more robust handling of payment processing failures. ```python from stripe.error import CardError try: # Stripe payment processing logic pass except CardError as e: # Handle card errors, e.g., display message to user print(f"Card error: {e.user_message}") except Exception as e: # Handle other potential errors print(f"An unexpected error occurred: {e}") ``` -------------------------------- ### Cloudflare Pages Deployment Configuration (Bash) Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Details the build and deployment configuration for Cloudflare Pages. It specifies the build command, output directory, required environment variables, and the deployment URL. ```bash # Automatic deployment configured # Pushes to main branch trigger builds # Build command npm run build # Output directory dist/ # Environment variables (set in Cloudflare dashboard) NODE_VERSION=22 NPM_VERSION=latest # Deployment URL https://docs.saaspegasus.com/ ``` -------------------------------- ### Configure Webpack for AI Chat JavaScript Setup (JavaScript) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This code snippet illustrates how to move the chat JavaScript setup to the end of `module.exports` within the `webpack.config.js` file. This organizational change ensures that the JavaScript for chat functionalities is processed correctly in the build process. ```javascript module.exports = { // ... other webpack configurations // Moved chat JavaScript setup here // ... }; ``` -------------------------------- ### Configure dj-stripe Settings in Python Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md These settings are crucial for configuring dj-stripe, particularly when upgrading from previous versions. DJSTRIPE_FOREIGN_KEY_TO_FIELD should be set to 'id' for new installations or 'djstripe_id' for existing ones. DJSTRIPE_USE_NATIVE_JSONFIELD should be set to True for new installations or False for older ones to manage JSON field compatibility. ```python DJSTRIPE_FOREIGN_KEY_TO_FIELD = 'id' # change to 'djstripe_id' if not a new installation DJSTRIPE_USE_NATIVE_JSONFIELD = True # change to False if not a new installation ``` -------------------------------- ### Update Dockerfile for Node.js 22 Installation (Dockerfile) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This snippet shows how to update the Dockerfile.dev to install Node.js version 22. It replaces the previous method of adding a NodeSource repository with a curl command and bash script execution. This ensures the correct Node.js version is available in the development environment. ```diff RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ --mount=target=/var/cache/apt,type=cache,sharing=locked \ rm -f /etc/apt/apt.conf.d/docker-clean && \ - echo "deb https://deb.nodesource.com/node_22.x bookworm main" > /etc/apt/sources.list.d/nodesource.list && \ - wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ apt-get update && \ apt-get install -yqq nodejs \ ``` -------------------------------- ### Create PostgreSQL Database on Fly.io Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/fly.md Creates a new PostgreSQL database instance on Fly.io. This command requires the flyctl CLI and will prompt for organization and configuration details. ```bash $ fly postgres create --name {app-name}-db --region ord ``` -------------------------------- ### Promote User to Django Superuser (Docker/Native) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/cookbooks.mdx This command promotes a user to a superuser in Django. It can be run either via Docker or natively. Replace 'yourname@example.com' with the actual user's email. This is useful for accessing the Django admin interface. ```bash docker compose exec web python ./manage.py promote_user_to_superuser yourname@example.com ``` ```bash python ./manage.py promote_user_to_superuser yourname@example.com ``` -------------------------------- ### Upgrade Pegasus CLI (Shell) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md Instructions on how to install a specific older version of the pegasus-cli to fix a bug that prevented it from running on Windows machines. ```bash pip install pegasus-cli==0.2.1 ``` -------------------------------- ### Run Ecommerce Data Migration Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/release-notes.md This command executes the custom `migrate_ecommerce` management command to create ProductConfiguration objects and associate them with existing Purchase models. ```bash ./manage.py migrate_ecommerce ``` -------------------------------- ### List Available Google Cloud Projects Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/google-cloud.md Lists all Google Cloud projects associated with your authenticated account. This helps verify that your project has been created and is accessible. ```bash gcloud projects list ``` -------------------------------- ### Use Starlight Components in MDX (MDX) Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Demonstrates how to use Starlight's built-in UI components like CardGrid, LinkCard, Steps, and Aside within MDX files to create rich and interactive documentation pages. ```mdx --- title: Feature Overview --- import { CardGrid, LinkCard } from '@astrojs/starlight/components'; import { Steps } from '@astrojs/starlight/components'; import { Aside } from '@astrojs/starlight/components'; ## Quick Links ## Setup Instructions 1. Install dependencies with `npm install` 2. Create your `.env` file from `.env.example` 3. Run database migrations with `./manage.py migrate` 4. Start the server with `./manage.py runserver` ``` -------------------------------- ### Override Default Components (JavaScript) Source: https://context7.com/saaspegasus/pegasus-docs/llms.txt Allows customization of Starlight's default components by specifying custom Astro components in the configuration. This example shows how to override the PageSidebar component. ```javascript // astro.config.mjs starlight({ components: { PageSidebar: './src/components/PageSidebar.astro', }, }) ``` -------------------------------- ### Build Front-End for Production (Docker) Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/front-end/overview.mdx Builds the front-end assets for production within a Docker environment. This is an alternative to `npm run build` for users operating within Docker. It performs the same optimization and compression steps for production deployment. ```bash make npm-build ``` -------------------------------- ### Create PostgreSQL Database with Fly CLI Source: https://github.com/saaspegasus/pegasus-docs/blob/main/src/content/docs/deployment/fly.md Command to create a new PostgreSQL database instance using the Fly CLI. This is useful when your application requires a new database. ```bash fly postgres create --name {your-app-db} ```