UNPKG

@reliverse/rse-sdk

Version:

@reliverse/rse-sdk allows you to create new plugins for @reliverse/rse CLI, interact with reliverse.org, and even extend your own CLI functionality (you may also try @reliverse/dler-sdk for this case).

45 lines (44 loc) 1.57 kB
import path from "@reliverse/pathkit"; import fs from "@reliverse/relifso"; import { relinka } from "@reliverse/relinka"; import { defineTSConfig, writeTSConfig } from "pkg-types"; export async function createTSConfig(projectPath, isLib, isDev) { const tsconfig = defineTSConfig({ compilerOptions: { esModuleInterop: true, skipLibCheck: true, target: "es2022", allowJs: true, resolveJsonModule: true, moduleDetection: "force", isolatedModules: true, verbatimModuleSyntax: true, strict: true, noUncheckedIndexedAccess: true, noImplicitOverride: true, ...isLib ? { lib: ["es2022"] } : { module: "preserve", noEmit: true, lib: ["es2022", "dom", "dom.iterable"] } }, ...isLib ? { include: ["**/*.ts"] } : { include: ["**/*.ts", "**/*.tsx"] }, exclude: ["node_modules"] }); const useTxt = isDev && projectPath.includes("tests-runtime"); const filename = useTxt ? "tsconfig.txt" : "tsconfig.json"; const tsconfigPath = path.join(projectPath, filename); if (useTxt) { const rawContent = JSON.stringify(tsconfig, null, 2); await fs.writeFile(tsconfigPath, rawContent, "utf-8"); } else { await writeTSConfig(tsconfigPath, tsconfig); const content = await fs.readFile(tsconfigPath, "utf-8"); const formatted = JSON.stringify(JSON.parse(content), null, 2); await fs.writeFile(tsconfigPath, formatted, "utf-8"); } relinka( "verbose", `Created ${filename} with ${isLib ? "library" : "application"} configuration` ); }