Static web publishing CLI tool for deploying web applications to a CDN with a single command
—
Core authentication functionality for managing user credentials and account access. All publishing operations require authentication.
Authenticate with Surge platform and store credentials locally for subsequent commands.
/**
* Authenticate user with email/password and store credentials
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function login(hooks?: HookConfig): CommandFunction;CLI Usage:
surge loginInteractive prompts for email and password. Credentials are stored in .netrc format for automatic authentication in future commands.
Library Usage:
const surge = require('surge')();
surge.login({})(process.argv.slice(2));Remove stored authentication credentials and expire the current session.
/**
* Remove stored credentials and expire session
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function logout(hooks?: HookConfig): CommandFunction;CLI Usage:
surge logoutLibrary Usage:
surge.logout({})(process.argv.slice(2));Display information about the currently authenticated user.
/**
* Display current authenticated user information
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function whoami(hooks?: HookConfig): CommandFunction;CLI Usage:
surge whoamiDisplays the email address and account plan of the currently authenticated user.
Library Usage:
surge.whoami({})(process.argv.slice(2));Generate an API token for automation and CI/CD integration.
/**
* Generate API token for programmatic access
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function token(hooks?: HookConfig): CommandFunction;CLI Usage:
surge tokenGenerates and displays an API token that can be used for automated deployments. Store in environment variable SURGE_TOKEN for CI/CD systems.
Library Usage:
surge.token({})(process.argv.slice(2));SURGE_TOKEN: API token for non-interactive authenticationTRAVIS_SURGE_TOKEN: Legacy Travis CI integration tokenUsage Example:
export SURGE_TOKEN="your-api-token-here"
surge publish ./build example.surge.shSurge stores authentication credentials in .netrc format in the user's home directory. The format follows standard netrc conventions:
machine surge.surge.sh
login user@example.com
password api-token-hereAll authentication commands handle these errors gracefully with informative error messages.
Install with Tessl CLI
npx tessl i tessl/npm-surge