HostFn

hostfn init

Initialize HostFn configuration in your project.

Usage

hostfn init

Description

Initializes a new hostfn.config.json configuration file in the current directory. This is an interactive command that:

  1. Detects the project runtime by scanning for package.json, go.mod, etc.
  2. Prompts for project settings including name, version, server, port, domain, build and start commands
  3. Generates the configuration file with smart defaults based on detection

Interactive Prompts

PromptDescriptionDefault
Application nameUsed for PM2 service name and remote directoryFrom package.json name
Runtime versionNode.js major versionFrom engines.node or 18
Production serverSSH connection string
Production portPort the app listens on3000
DomainCustom domain for Nginx
Build commandCommand to build the projectFrom scripts.build
Start commandCommand to start the projectFrom scripts.start

Behavior

  • If hostfn.config.json already exists, prompts for confirmation before overwriting
  • Detects runtime with a confidence score (warns if below 80%)
  • Reads package.json to suggest smart defaults for Node.js projects

Example

$ hostfn init

  Initialize hostfn

 Detected nodejs (confidence: 95%)

  ── Project Configuration ──
  ? Application name: my-api
  ? nodejs version: 20

  ── Environment Configuration ──
  ? Production server (user@host): ubuntu@my-server.com
  ? Production port: 3000
  ? Domain (optional): api.example.com

  ── Build & Start Configuration ──
  ? Build command: npm run build
  ? Start command: npm start

 Configuration created

 hostfn initialized successfully!

  Next steps:
  $ hostfn server setup ubuntu@my-server.com
  $ hostfn deploy production