import path from "path";

export function tsconfigCodegen(convexPackageFromFunctions: string) {
  const env = path.join(
    convexPackageFromFunctions,
    "dist/esm/environment/index.d.ts"
  );
  return `{
  /* This TypeScript project config describes the environment that
   * Convex functions run in and is used to typecheck them.
   * You can modify it, but some settings required to use Convex.
   */
  "compilerOptions": {
    /* These settings are not required by Convex and can be modified. */
    "allowJs": true,
    "strict": true,

    /* These compiler options are required by Convex */
    "target": "ESNext",
    "lib": ["ES2021"],
    "forceConsistentCasingInFileNames": true,
    "allowSyntheticDefaultImports": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "isolatedModules": true,
    "noEmit": true,
    /* Prevents node_modules from adding additional global types e.g. node types */
    "types": []
  },
  "include": ["./**/*", ${JSON.stringify(env)}],
  "exclude": ["./_generated"]
}`;
}
