Skip to main content

Programmatic Usage

Kosko provides a programmatic API. You can generate manifests directly from Node.js.

Install

npm install @kosko/env @kosko/generate

Example

import env from "@kosko/env";
import { generate, print, PrintFormat } from "@kosko/generate";
import path from "node:path";

(async () => {
// Set environment
env.env = "dev";

// Set CWD (Optional)
env.cwd = __dirname;

// Generate manifests
const result = await generate({
path: path.join(env.cwd, "components"),
components: ["*"]
});

// Print manifests to stdout
print(result, {
format: PrintFormat.YAML,
writer: process.stdout
});
})();