@waltcow/claude-code-spec-workflow
Version:
Automated spec-driven workflow for Claude Code. Transforms feature ideas into complete implementations through Requirements → Design → Tasks → Implementation.
77 lines • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectProjectType = detectProjectType;
exports.validateClaudeCode = validateClaudeCode;
exports.fileExists = fileExists;
exports.ensureDirectory = ensureDirectory;
const fs_1 = require("fs");
const path_1 = require("path");
const child_process_1 = require("child_process");
const util_1 = require("util");
const execAsync = (0, util_1.promisify)(child_process_1.exec);
async function detectProjectType(projectPath) {
const indicators = {
'Node.js': ['package.json', 'node_modules'],
'Python': ['requirements.txt', 'setup.py', 'pyproject.toml', '__pycache__'],
'Java': ['pom.xml', 'build.gradle'],
'C#': ['*.csproj', '*.sln'],
'Go': ['go.mod', 'go.sum'],
'Rust': ['Cargo.toml', 'Cargo.lock'],
'PHP': ['composer.json', 'vendor'],
'Ruby': ['Gemfile', 'Gemfile.lock'],
};
const detected = [];
for (const [projectType, files] of Object.entries(indicators)) {
for (const file of files) {
try {
if (file.includes('*')) {
// Handle glob patterns - simplified check
const dirContents = await fs_1.promises.readdir(projectPath);
const extension = file.replace('*', '');
if (dirContents.some(f => f.endsWith(extension))) {
detected.push(projectType);
break;
}
}
else {
await fs_1.promises.access((0, path_1.join)(projectPath, file));
detected.push(projectType);
break;
}
}
catch {
// File doesn't exist, continue
}
}
}
return detected;
}
async function validateClaudeCode() {
try {
await execAsync('claude --version');
return true;
}
catch {
return false;
}
}
async function fileExists(filePath) {
try {
await fs_1.promises.access(filePath);
return true;
}
catch {
return false;
}
}
async function ensureDirectory(dirPath) {
try {
await fs_1.promises.mkdir(dirPath, { recursive: true });
}
catch (error) {
if (error.code !== 'EEXIST') {
throw error;
}
}
}
//# sourceMappingURL=utils.js.map