UNPKG

constatic

Version:

Constatic is a CLI for creating and managing modern TypeScript projects, providing an organized structure and features that streamline development.

44 lines (41 loc) 1.07 kB
// src/cli/index.ts import { cliLang } from "#helpers"; import { readPackageJSON } from "pkg-types"; import { CLIConfig } from "./config.js"; import { EnvManager } from "./env.js"; import { CLIShell } from "./shell.js"; import path from "node:path"; import { CLITemplates } from "./templates.js"; import { CLIFileSystem } from "./fs.js"; export * from "./env.js"; class CLI { static async init(rootname) { const packageJson = await readPackageJSON(path.join(rootname, "package.json")); const cli = new this(rootname, packageJson); await cli.templates.load(); return cli; } pkg; config; shell; templates; fs; get lang() { return cliLang.get(); } rootname; constructor(rootname, pkg) { this.pkg = { ...pkg, version: pkg.version ?? "0.0.0" }; this.config = CLIConfig.init(this.pkg.name); this.rootname = rootname; this.shell = new CLIShell; this.templates = new CLITemplates(rootname); this.fs = new CLIFileSystem; } createEnvManager(envPath) { return new EnvManager(envPath); } } export { CLI };