Static web publishing CLI tool for deploying web applications to a CDN with a single command
—
Version control functionality for managing different revisions of deployed projects, enabling rollbacks, staged deployments, and revision history management.
Revert a project to the previous revision.
/**
* Revert project to previous revision
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function rollback(hooks?: HookConfig): CommandFunction;CLI Usage:
# Rollback interactive domain selection
surge rollback
# Rollback specific domain
surge rollback example.surge.shReverts the live project to the previously deployed revision. Useful for quickly undoing problematic deployments.
Library Usage:
surge.rollback({})(process.argv.slice(2));Advance a project to the next revision (opposite of rollback).
/**
* Advance project to next revision
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function rollfore(hooks?: HookConfig): CommandFunction;CLI Usage:
# Roll forward interactive domain selection
surge rollfore
# Roll forward specific domain
surge rollfore example.surge.shMoves the live project forward to the next available revision in history.
Library Usage:
surge.rollfore({})(process.argv.slice(2));Switch to the latest revision of a project.
/**
* Switch project to latest revision
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function cutover(hooks?: HookConfig): CommandFunction;CLI Usage:
# Cutover interactive domain selection
surge cutover
# Cutover specific domain
surge cutover example.surge.shSwitches the live project to the most recent revision, effectively "catching up" if the project is behind.
Library Usage:
surge.cutover({})(process.argv.slice(2));Remove a specific revision from the system permanently.
/**
* Remove revision from system permanently
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function discard(hooks?: HookConfig): CommandFunction;CLI Usage:
# Discard with interactive selection
surge discard
# Discard from specific domain
surge discard example.surge.shPermanently removes a revision from the system. This action cannot be undone.
Library Usage:
surge.discard({})(process.argv.slice(2));Select a specific revision to make it the active deployment.
/**
* Select specific revision as active deployment
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function select(hooks?: HookConfig): CommandFunction;CLI Usage:
# Select with interactive menu
surge select
# Select from specific domain
surge select example.surge.shPresents an interactive menu of available revisions and allows selection of which one should be live.
Library Usage:
surge.select({})(process.argv.slice(2));surge publish creates a new revisionEach revision contains:
Use revisions to implement blue-green deployment patterns:
cutover to switch live trafficDeploy with preview mode, then promote:
# Deploy to preview
surge --preview ./build preview.example.surge.sh
# After testing, deploy to production
surge ./build example.surge.sh
# If issues arise, rollback
surge rollback example.surge.shCombine revision management with traffic splitting:
Add descriptive messages to revisions:
surge --message "Fix navigation bug" ./build example.surge.shThe message helps identify revisions in the revision history.
Use preview mode for testing revisions:
# Deploy to staging first
surge --stage ./build staging.example.surge.sh
# After verification, deploy to production
surge ./build example.surge.shSync revisions with git commits:
# Use git commit message for revision
COMMIT_MSG=$(git log -1 --pretty=%B)
surge --message "$COMMIT_MSG" ./build example.surge.shIntegrate revision management in CI/CD:
# GitHub Actions example
- name: Deploy to staging
run: surge --stage ./build staging.example.surge.sh
- name: Run tests against staging
run: npm run test:e2e
- name: Deploy to production
run: surge ./build example.surge.sh
if: success()
- name: Rollback on failure
run: surge rollback example.surge.sh
if: failure()Use surge list to view revision history:
surge list example.surge.shShows table with:
Monitor revision changes:
All revision commands provide clear error messages and suggested actions.
Install with Tessl CLI
npx tessl i tessl/npm-surge