VOOZH about

URL: https://deepwiki.com/calevans/staticforge/9-cli-commands

⇱ CLI Commands | calevans/staticforge | DeepWiki


Loading...
Last indexed: 11 February 2026 (5f6a2a)
Menu

CLI Commands

This page documents StaticForge's command-line interface, including all built-in commands, their options, and usage patterns. The CLI is the primary interface for building, auditing, and managing StaticForge sites.

For information about the event system that commands interact with, see Event System. For configuration options that commands use, see Configuration System.


Command Architecture Overview

StaticForge's CLI is built on Symfony Console and implements a two-tier command registration system: core commands are registered directly in the bootstrap, while feature commands are registered dynamically via the CONSOLE_INIT event.

Command Registration Flow


Sources:

Command Class Hierarchy

StaticForge commands extend Symfony's Command class and follow a consistent structure:


Sources:


Core Command Registration

Core commands are registered directly in the CLI bootstrap sequence, ensuring they are always available regardless of feature configuration.

CommandClassPurpose
site:initInitCommandInitialize new project structure
audit:configConfigCommandValidate configuration completeness
audit:contentContentCommandValidate content file integrity
audit:linksLinksCommandValidate internal and external links
audit:liveLiveCommandAudit deployed site security and performance
audit:seoSeoCommandValidate SEO metadata and structure
make:htaccessHtaccessCommandGenerate production .htaccess file

Sources:


Site Commands

site:init - Project Initialization

Initializes a new StaticForge project by creating the standard directory structure, configuration files, and sample content.

Usage:


Options:

OptionDescription
--force, -fOverwrite existing files

Execution Flow:


Directory Structure Created:

DirectoryPurpose
content/Source content files (Markdown, HTML)
templates/Twig template files
public/Generated static site output
config/Additional configuration files
logs/Application log files

Configuration Files Created:

FileSourcePurpose
.env.env.exampleEnvironment-specific configuration
siteconfig.yamlsiteconfig.yaml.exampleSite structure and metadata
content/index.mdGeneratedSample homepage content

Template Resolution:

The command searches for bundled templates using a multi-path strategy:

  1. Development mode: __DIR__ . '/../../'
  2. Installed as dependency: getcwd() . '/vendor/eicc/staticforge/'
  3. Alternative vendor structure: __DIR__ . '/../../../../../eicc/staticforge/'

Force Behavior:

Without --force, the command preserves existing files and displays notes:

  • Existing directories are skipped
  • Existing .env and siteconfig.yaml are preserved
  • Existing template files are not overwritten

With --force, all files are overwritten, enabling project reinitialization.

Sources:


Audit Commands

Audit commands validate project integrity at multiple levels: configuration, content, links, live deployment, and SEO. These commands support CI/CD integration and quality assurance workflows.

audit:config - Configuration Validation

Validates project configuration by checking environment variables, site configuration, and feature requirements.

Usage:


Validation Layers:


Core Configuration Checks:

CheckTypeLocationRequirement
SITE_BASE_URLEnvironment.envRequired
TEMPLATEEnvironment/Config.env or siteconfig.yamlRequired
site.nameConfigurationsiteconfig.yamlBest practice
content/FilesystemProject rootDirectory must exist
templates/FilesystemProject rootDirectory must exist
.envFilesystemProject rootFile must exist

Feature Configuration Checks:

For each feature implementing ConfigurableFeatureInterface, the command validates:

  1. Required Config Keys: Dot-notation paths in siteconfig.yaml (e.g., search.engine)
  2. Required Environment Variables: Keys that must exist in $_ENV, getenv(), or $_SERVER
  3. Configuration Help: If validation fails, displays example configuration from getConfigHelp()

Example Feature Check (Search):


Output Format:

Configuration Audit
===================

Core Configuration
------------------
[INFO] Found .env file.

Environment
-----------
[INFO] Found .env file.

Feature Configuration
---------------------
Scanned 5 configurable features.

Audit Summary
=============

[ERROR] Found 2 configuration errors.

Core
----
 [MISSING CONFIG] Missing 'SITE_BASE_URL' in environment (.env).

Feature: Search
---------------
 [CONFIG] Missing key in siteconfig.yaml: search

Example Configuration:
search:
 engine: minisearch

Exit Codes:

  • 0 (SUCCESS): No errors found
  • 1 (FAILURE): One or more errors found

Sources:

audit:content - Content Integrity Validation

Scans source content files for frontmatter validity, taxonomy consistency, and broken internal links.

Usage:


Validation Checks:


Frontmatter Validation:

CheckTypeDescription
YAML SyntaxErrorFrontmatter must be valid YAML between --- delimiters
Required FieldsErrortitle field must be present
Draft StatusWarningFiles with draft: true are flagged

Link Validation:

Link TypeValidation
External (http, https)Skipped
Email (mailto:)Skipped
Telephone (tel:)Skipped
Anchors (#fragment)Skipped
Generated (.html extension)Skipped (validated by audit:links post-build)
Internal relativeResolved relative to current file, checked with file_exists()
Internal absolute (/path)Resolved relative to content/ directory

Path Resolution Logic:

Link: ../images/diagram.png
Current file: content/blog/post.md
Resolved path: content/blog/../images/diagram.png
 → content/images/diagram.png

Link: /assets/style.css
Current file: content/docs/page.md
Resolved path: content/assets/style.css

Output Format:

Content Audit
=============

Found 15 Content files to audit.

Checking Frontmatter...
Checking Markdown Internal Links...

Content Issues
==============

content/blog/post.md
--------------------
 [ERROR] Missing required field: title
 [WARNING] Post is marked as draft

content/docs/guide.md
---------------------
 [ERROR] Link target not found: ../missing.png

Audit Summary
=============
Files Scanned: 15
Errors: 2
Warnings: 1

Exit Codes:

  • 0 (SUCCESS): No errors (warnings are tolerated)
  • 1 (FAILURE): One or more errors found

Sources:

audit:live - Live Site Validation

Performs remote validation of a deployed site, checking SSL certificates, security headers, performance optimizations, and deployment integrity.

Usage:


Options:

OptionDescription
--url, -uTarget URL to audit (overrides UPLOAD_URL from .env)

Audit Categories:


Connectivity & SSL Checks:

CheckTypeConditionResult
SSL Certificate ExpiredErrorvalidTo_time_t < time()Certificate expired
SSL Certificate Expiring SoonWarningvalidTo_time_t - time() < 14 daysCertificate expires in N days
SSL Certificate ValidSuccessvalidTo_time_t - time() >= 14 daysCertificate valid for N days
No HTTPSWarningscheme !== 'https'Site not using HTTPS

Security Header Checks:

HeaderExpected ValueMissing Result
Strict-Transport-SecurityAny valueWarning (HTTPS sites only)
X-Content-Type-OptionsnosniffWarning
X-Frame-OptionsAny valueWarning

Performance Header Checks:

HeaderExpected ValueMissing Result
Content-Encodinggzip, deflate, or brWarning
Cache-ControlAny valueWarning
ETag or Last-ModifiedAny valueWarning

Deployment Integrity Checks:

ResourceCheckExpectedMissing Result
robots.txtHTTP Status200Warning
sitemap.xmlHTTP Status200Warning
sitemap.xmlContent-TypeContains xmlWarning

Output Format:

Live Site Audit
===============

Auditing target: https://example.com/

 > Checking connectivity and SSL...
 > Checking security headers...
 > Checking performance headers...
 > Checking deployment integrity...

Live Audit Results
==================
 [SUCCESS] [SSL] SSL Certificate is valid for 89 days.
 [SUCCESS] [Security] 'Strict-Transport-Security' header found.
 [SUCCESS] [Security] 'X-Content-Type-Options: nosniff' header found.
 [SUCCESS] [Security] 'X-Frame-Options' header found.
 [SUCCESS] [Performance] Content-Encoding enabled (gzip).
 [SUCCESS] [Performance] 'Cache-Control' header found.
 [SUCCESS] [Performance] Cache validator found (ETag).
 [SUCCESS] [Integrity] robots.txt found.
 [SUCCESS] [Integrity] sitemap.xml found and appears valid.

Audit Summary
=============
Errors: 0
Warnings: 0
Passed Checks: 9

CURL Configuration:

The command uses cURL with the following defaults:

  • CURLOPT_TIMEOUT: 10 seconds
  • CURLOPT_SSL_VERIFYPEER: false (allows self-signed certificates for testing)
  • CURLOPT_SSL_VERIFYHOST: false
  • CURLOPT_FOLLOWLOCATION: true (follows redirects)

Exit Codes:

  • 0 (SUCCESS): No errors (warnings are tolerated)
  • 1 (FAILURE): One or more errors found (connectivity failures, expired certificates)

Sources:

audit:links and audit:seo

These commands are registered in the bootstrap but their implementations are not provided in the available source files. Based on the registration pattern:

  • audit:links: Validates links in generated HTML output (post-build validation)
  • audit:seo: Validates SEO metadata, meta tags, and structured data

Sources:


Make Commands

make:htaccess - .htaccess Generator

Generates a production-ready .htaccess file with security headers, performance optimizations, and StaticForge-specific protections.

Usage:


Options:

OptionDescriptionDefault
--write, -wWrite output to file instead of stdout(disabled)
--output, -oOutput filename when using --writehtaccess.txt

Generated Configuration:


Protection Rules:

RuleDirectivePurpose
Manifest Protection<Files "staticforge-manifest.json">Deny access to build metadata
Require all denied

Security Headers:

HeaderValuePurpose
Strict-Transport-Securitymax-age=31536000; includeSubDomainsEnforce HTTPS for 1 year
X-Content-Type-OptionsnosniffPrevent MIME-type sniffing
X-Frame-OptionsSAMEORIGINPrevent clickjacking

Caching Strategy:

Content TypeCache DurationAssets Covered
HTML/Data (default)1 hour (3600s)All files not matched below
Static Assets1 week (604800s).ico, .pdf, .flv, .jpg, .jpeg, .png, .gif, .svg, .webp, .js, .css, .woff, .woff2, .ttf

Output Behavior:

Without --write:

  • Prints .htaccess content to stdout
  • Displays usage tip: Use --write to save this content to htaccess.txt
  • Returns SUCCESS

With --write:

  • Writes content to specified file (default: htaccess.txt)
  • Displays success message or error
  • Warns if overwriting existing .htaccess

Safety Note:

The command defaults to htaccess.txt rather than .htaccess to prevent accidental overwriting of existing server configuration. Users must manually rename or copy the file to .htaccess after review.

Usage Examples:


Sources:


Feature Command Registration

Features can register custom commands by listening to the CONSOLE_INIT event during bootstrap. This pattern enables features to contribute commands without modifying core code.

CONSOLE_INIT Event Flow


Event Parameters:

The CONSOLE_INIT event receives:

  • application: The Symfony Console Application instance

Example: RenderSiteCommand Registration


Common Feature Commands:

CommandFeaturePurpose
site:renderRendererBuild static site from content
site:devserverDevServerLaunch local development server
site:uploadUploadDeploy site to remote server
feature:setupFeatureManagerConfigure external features

Sources:


Command Development Patterns

Container Access Pattern

Commands that need access to configuration and services receive the Container instance via constructor injection:


Sources:

SymfonyStyle Usage Pattern

Commands use SymfonyStyle for consistent, formatted output:


Output Methods:

MethodPurpose
title()Display command title
section()Display section header
text()Display regular text
note()Display informational note (blue)
success()Display success message (green)
error()Display error message (red)
warning()Display warning message (yellow)
listing()Display bulleted list
table()Display formatted table
writeln()Write line with custom formatting
newLine()Insert blank line

Sources:

Error Grouping Pattern

Commands that perform multiple checks group errors by scope or file for readable output:


Sources:

File System Scanning Pattern

Commands that process files use RecursiveDirectoryIterator for efficient traversal:


Sources:

HTTP Request Pattern (LiveCommand)

Commands that audit remote sites use cURL with consistent configuration:


Sources:


Testing Commands

Commands are tested using Symfony's CommandTester class, which captures output and provides assertion methods.

Command Test Structure


CommandTester Methods:

MethodPurpose
execute(array $input)Execute command with options/arguments
getStatusCode()Get command exit code
getDisplay()Get command output as string
getInput()Get command input object
getOutput()Get command output object

Sources:


Complete Command Reference:

CommandTypeStatusPurpose
site:initCoreAvailableInitialize project structure
site:renderFeatureVia CONSOLE_INITBuild static site
site:devserverFeatureVia CONSOLE_INITLaunch development server
site:uploadFeatureVia CONSOLE_INITDeploy to remote server
audit:configCoreAvailableValidate configuration
audit:contentCoreAvailableValidate content integrity
audit:linksCoreRegisteredValidate links (implementation not shown)
audit:liveCoreAvailableAudit deployed site
audit:seoCoreRegisteredValidate SEO (implementation not shown)
make:htaccessCoreAvailableGenerate .htaccess file
feature:setupFeatureVia CONSOLE_INITConfigure external features