Skip to main content

Programmatic Usage

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

Install

In order to use the programmatic API, you have to install @kosko/env and @kosko/generate package.

npm install @kosko/env @kosko/generate

Example

import env from "@kosko/env";
import { generate, print, PrintFormat } from "@kosko/generate";
import path from "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
});
})();