Main command-line interface for gts providing TypeScript project management operations including initialization, linting, fixing, and cleanup.
Main entry point for executing gts CLI commands programmatically.
/**
* Execute gts commands programmatically
* @param verb - Command to execute: 'init', 'lint', 'check', 'fix', or 'clean'
* @param files - Array of file patterns to process (optional for most commands)
* @returns Promise resolving to true on success, false on failure
*/
function run(verb: string, files: string[]): Promise<boolean>;Usage Examples:
import { run } from "gts/build/src/cli";
// Initialize gts in current directory
const success = await run("init", []);
// Lint specific files
const lintResult = await run("lint", ["src/**/*.ts"]);
// Fix all TypeScript files
const fixResult = await run("fix", []);
// Clean build output
const cleanResult = await run("clean", []);Command-line interface accessible via the gts command after installation.
Initialize gts configuration in a TypeScript project.
gts init [options]Options:
--yes, -y: Assume yes answer for all prompts--no, -n: Assume no answer for all prompts--dry-run: Preview changes without making them--yarn: Use yarn instead of npmActions performed:
Check code for formatting and linting issues.
gts lint [file-patterns...]
gts check [file-patterns...] # Alias for lintExamples:
gts lint # Lint all TypeScript files
gts lint src/**/*.ts # Lint specific patterns
gts check src/index.ts # Check single fileDefault patterns when no files specified:
**/*.ts**/*.js**/*.tsx**/*.jsxAutomatically fix formatting and linting issues.
gts fix [file-patterns...] [options]Options:
--dry-run: Preview fixes without applying themExamples:
gts fix # Fix all TypeScript files
gts fix src/**/*.ts # Fix specific patterns
gts fix --dry-run # Preview fixesRemove build output files based on tsconfig.json outDir setting.
gts clean [options]Options:
--dry-run: Preview cleanup without deleting filesBuilt-in Node.js version validation.
/**
* Get the current version of Node.js being run
* @returns Node.js version string (e.g., "v18.17.0")
*/
function getNodeVersion(): string;The CLI automatically validates that Node.js version 10 or higher is being used and throws an error for older versions. However, the package.json specifies "node": ">=18" as the engine requirement, so in practice Node.js 18+ is required.
All CLI commands return boolean success indicators:
true: Command completed successfullyfalse: Command failed (linting errors, build failures, etc.)For programmatic usage, catch exceptions for system-level errors:
import { run } from "gts/build/src/cli";
try {
const success = await run("lint", []);
if (!success) {
console.error("Linting failed");
process.exit(1);
}
} catch (error) {
console.error("System error:", error.message);
process.exit(1);
}