All files / core validator.ts

100% Statements 14/14
100% Branches 3/3
100% Functions 2/2
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38      1x 1x             1x 13x     13x 13x     13x 13x 13x 13x             13x 13x   13x 34x        
// Copyright 2026 ForgeKit Contributors
// SPDX-License-Identifier: Apache-2.0
// https://github.com/SubhanshuMG/ForgeKit
import * as path from 'path';
import * as fs from 'fs-extra';
 
export interface ValidationResult {
  passed: boolean;
  checks: { name: string; passed: boolean; message?: string }[];
}
 
export async function validateScaffoldOutput(projectPath: string): Promise<ValidationResult> {
  const checks = [];
 
  // Check directory exists
  const dirExists = await fs.pathExists(projectPath);
  checks.push({ name: 'output directory exists', passed: dirExists });
 
  // Check package.json or pyproject.toml exists
  const hasPackageJson = await fs.pathExists(path.join(projectPath, 'package.json'));
  const hasPyProject = await fs.pathExists(path.join(projectPath, 'pyproject.toml'));
  const hasRequirements = await fs.pathExists(path.join(projectPath, 'requirements.txt'));
  checks.push({
    name: 'project manifest exists',
    passed: hasPackageJson || hasPyProject || hasRequirements,
    message: 'Expected package.json, pyproject.toml, or requirements.txt',
  });
 
  // Check README exists
  const hasReadme = await fs.pathExists(path.join(projectPath, 'README.md'));
  checks.push({ name: 'README.md exists', passed: hasReadme });
 
  return {
    passed: checks.every(c => c.passed),
    checks,
  };
}