UNPKG

codemodctl

Version:

CLI tool and utilities for workflow engine operations, file sharding, and codeowner analysis

26 lines (24 loc) 987 B
#!/usr/bin/env node import { execSync } from "node:child_process"; //#region src/utils/codemod-cli.ts /** * Executes the codemod CLI command and returns applicable file paths */ async function getApplicableFiles(rulePath, language, projectRoot) { try { const command = `npx -y codemod@latest jssg list-applicable --language ${language} --target ${projectRoot} ${rulePath}`; console.debug(`Executing: ${command}`); const applicableFiles = execSync(command, { encoding: "utf8", cwd: projectRoot, maxBuffer: 10 * 1024 * 1024 }).split("\n").filter((line) => line.startsWith("[Applicable] ")).map((line) => line.replace("[Applicable] ", "").trim()).filter((filePath) => filePath.length > 0); console.debug(`Found ${applicableFiles.length} applicable files`); return applicableFiles; } catch (error) { console.error("Error executing codemod CLI:", error); throw new Error(`Failed to execute codemod CLI: ${error}`); } } //#endregion export { getApplicableFiles };