UNPKG

@sirhc77/postman-sdk-gen

Version:

Generate a fully-typed TypeScript SDK from a Postman collection, with support for Axios or Fetch, folder-based namespacing, and auto-inferred types.

36 lines (29 loc) 1.1 kB
#!/usr/bin/env node import { Command } from "commander"; import { loadConfig } from "./config"; import { generateSdk } from "./index"; const program = new Command(); program .name("postman-sdk-gen") .description("Generate a TypeScript SDK from a Postman collection") .argument("<collection>", "Path or URL to Postman collection") .option("-o, --output <dir>", "Output directory", "./sdk") .option("--client-name <name>", "Name of the generated client class", "ApiClient") .option("--use-fetch", "Use native fetch instead of axios", false) .option("--single-file", "Generate a single output file", false) .option("--quiet", "Suppress logs", false) .option("--version", "Show version", () => { console.log("postman-sdk-gen v0.2.0"); process.exit(0); }) .parse(); const opts = program.opts(); const collectionArg = program.args[0]; async function main() { const config = await loadConfig(collectionArg, opts); await generateSdk(config); } main().catch((err) => { console.error("❌ Error:", err); process.exit(1); });