feat(quality-rails): migrate @mosaic/quality-rails from v0 to v1
Implements the full quality-rails scaffolding package in v1: - types.ts: ProjectKind, QualityProfile, RailsConfig, ScaffoldResult - detect.ts: project kind detection (node/python/rust/unknown) - templates.ts: ESLint, Biome, pyproject, rustfmt, pre-commit, PR checklist templates - scaffolder.ts: core scaffolding engine with file writing and dependency installation - cli.ts: Commander.js CLI with init/check/doctor subcommands - index.ts: re-exports all public API - package.json: adds commander dep, type=module, @types/node devDep All three quality gates pass (format:check, typecheck, lint). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
30
packages/quality-rails/src/detect.ts
Normal file
30
packages/quality-rails/src/detect.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { constants } from 'node:fs';
|
||||
import { access } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import type { ProjectKind } from './types.js';
|
||||
|
||||
async function fileExists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
await access(filePath, constants.F_OK);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function detectProjectKind(projectPath: string): Promise<ProjectKind> {
|
||||
if (await fileExists(join(projectPath, 'package.json'))) {
|
||||
return 'node';
|
||||
}
|
||||
|
||||
if (await fileExists(join(projectPath, 'pyproject.toml'))) {
|
||||
return 'python';
|
||||
}
|
||||
|
||||
if (await fileExists(join(projectPath, 'Cargo.toml'))) {
|
||||
return 'rust';
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
Reference in New Issue
Block a user