UNPKG

stackrun

Version:

stackrun is a wrapper around [concurrently](https://www.npmjs.com/package/concurrently) and [cf-tunnel](https://www.npmjs.com/package/cf-tunnel) that simplifies running multiple services with optional integrated Cloudflare tunneling.

76 lines (73 loc) 3.13 kB
import concurrently, { Command } from 'concurrently'; import { TunnelConfig } from 'cf-tunnel'; type ConcurrentlyOptions = Parameters<typeof concurrently>[1]; /** * Configuration for a command to be run by stackrun. * Extends all concurrently Command options (command, name, prefixColor, cwd, env, etc.) * with additional tunnel-specific properties. * @see https://www.npmjs.com/package/concurrently#command */ type StackrunConfigCommands = Partial<Command> & { /** * The local URL that will be tunneled to when tunneling is enabled. * Required with tunnelUrl for tunnel creation. */ url?: string; /** * Environment variables for the command when tunneling is enabled. * These override the regular env variables when tunnelEnabled is true. */ tunnelEnv?: Record<string, string | boolean | undefined>; /** * The public URL for the tunnel. * Required with url for tunnel creation. */ tunnelUrl?: string; }; /** * Configuration for stackrun. * @property concurrentlyOptions - All options from concurrently are supported. * @see https://www.npmjs.com/package/concurrently#api */ type StackrunConfig = { /** * All concurrently options are supported. * @see https://www.npmjs.com/package/concurrently#concurrentlycommands-options */ concurrentlyOptions?: ConcurrentlyOptions; /** When true, creates tunnels for services with url and tunnelUrl defined */ tunnelEnabled?: boolean; /** * Configuration for Cloudflare Tunnel using cf-tunnel package. * All cf-tunnel configuration options are supported EXCEPT 'ingress', * which is automatically generated from commands with url and tunnelUrl properties. * @see https://www.npmjs.com/package/cf-tunnel#configuration-options */ cfTunnelConfig?: Omit<Partial<TunnelConfig>, "ingress"> & { /** * Options for the concurrently command that runs the tunnel. * These customize how the tunnel command appears in the output. */ commandOptions?: { /** Name for the tunnel command in the output */ name?: string; /** Color for the tunnel command prefix */ prefixColor?: string; /** Environment variables for the tunnel command */ env?: Record<string, string | boolean | undefined>; /** Working directory for the tunnel command */ cwd?: string; /** Whether to enable IPC for the tunnel command */ ipc?: number; }; }; /** Commands to run before starting the concurrent processes */ beforeCommands?: string[]; /** Commands to run after all concurrent processes have completed */ afterCommands?: string[]; /** List of commands to run concurrently, with optional tunnel configuration */ commands?: StackrunConfigCommands[]; }; declare function defineStackrunConfig(config: StackrunConfig): StackrunConfig; declare function stackrun(config: StackrunConfig): Promise<void>; export { type StackrunConfig, type StackrunConfigCommands, defineStackrunConfig, stackrun };