Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

976 B
Raw Blame
import { readFileSync } from "node:fs";
import type { Plugin } from "vite";
import { defineConfig } from "vitest/config";

/**
 * tsup bundles the template with the `text` loader. Vite would hand a `.html`
 * import to its page plugin, so tests load the same file as a string module.
 */
const templateAsText: Plugin = {
  name: "cogit-template-as-text",
  enforce: "pre",
  load(id) {
    const file = id.split("?")[0] ?? "";
    if (!file.endsWith(".html") || !file.includes("/packages/template/dist/")) return null;
    return `export default ${JSON.stringify(readFileSync(file, "utf8"))};`;
  },
};

export default defineConfig({
  plugins: [templateAsText],
  test: {
    include: ["packages/*/test/**/*.test.{ts,tsx}"],
    globalSetup: ["./packages/cli/test/global-setup.ts"],
    coverage: {
      provider: "v8",
      include: ["packages/*/src/**", "scripts/**"],
      exclude: ["packages/cli/src/cli.ts"],
      reporter: ["text-summary", "lcov"],
    },
  },
});