import { Command } from "commander"; import { BaseCommand } from "./base.command"; import { CliStartup } from "../cli-startup"; import { ServeMiddleware } from "../middlewares/serve.middleware"; export class ServeCommand extends BaseCommand { register(command: Command): void { command .command("serve") .argument("[targetPath]", "Target directory path") .description("Serve static web by @ipare/static and @ipare/native") .option("-p, --port ", "The port on http listens") .option("--hostname ", "The hostname on http listens") .option("--hideDir", "Do not list dir") .option( "--exclude ", 'Exclude files, glob string, separate with space (e.g. "**/*.key secret/*.crt")' ) .option("--prefix ", "File prefix") .option("--encoding ", "Buffer encoding (e.g. utf8)") .action( async ( targetPath: string, command: Record ) => { await new CliStartup("serve", { targetPath }, command) .add(ServeMiddleware) .run(); } ); } }