UNPKG

path-validator-cli

Version:

A CLI tool to validate and fix broken paths in a project. Prevent deployment issues by validating and correcting paths directly in your codebase.

70 lines (64 loc) β€’ 3.32 kB
export const errorMessages = { absolutePath: { message: "Path is absolute", suggestion: (correctPath) => `Try a relative path instead: "${correctPath}"`, }, missingFile: { message: "File does not exist", suggestion: (correctPath = null) => correctPath ? `File not found in expected location. Did you mean: "${correctPath}"?` : "Check if the file was moved or renamed manually.", }, tooManyBack: { message: "Path goes too far back in the directory", suggestion: "Adjust the path to stay within the project root.", }, incorrectRelative: { message: "Incorrect relative path", suggestion: "Try './' instead of '../' if the file is in the same folder.", }, unknownPath: { message: "Unknown error", suggestion: "This path could not be classified. Please check manually.", } }; export const messages = { validationStart: "\nRunning path validation...\n", validationComplete: (count, isCheckOnly = false) => { let message = count > 0 ? isCheckOnly ? `\n ${count} ISSUES FOUND. Run 'path-validator' without '--check-only' to fix them.\n` : `\n ${count} ISSUES FOUND.\n` : "\n🀯 No issues found. Your paths are clean!🀯\n"; if (count >= 7) { message += '\n================================================================================\n' + "\n 😞Oof... this is bad. Your paths are a total mess. Maybe time to rethink your approach?😞\n" + '\n================================================================================\n'; } else if (count >= 4) { message += '\n================================================================================\n' + "\n πŸ˜”Yikes! Not the worst, but definitely not great. You *do* know how paths work, right?πŸ˜”\n" + '\n================================================================================\n'; } else if (count > 0) { message += '\n================================================================================\n' + "\n πŸ˜•Hm... a few minor mistakes. Almost like someone wasn't paying attention.πŸ˜•\n" + '\n================================================================================\n'; } return message; }, fixingPaths: "\nπŸ”§ Fixing invalid paths...\n", allFixed: "\n All paths have been fixed!\n", noChanges: "\n No changes were made. Exiting.\n", errorOccurred: "❌ An error occurred during validation.", // Fixing messages fixingPathsStart: "πŸ”§ Fixing invalid paths...", fixingPath: (oldPath, newPath) => `πŸ”§ Fixing ${oldPath} β†’ ${newPath}`, cannotFix: (path) => `Cannot fix: πŸ”§ πŸ‘·(Manual fix required) ---> ${path} `, fixComplete: "βœ… Path correction complete!", noInvalidPaths: "βœ… No invalid paths found!", foundInvalidPaths: (count) => `πŸ”Ž Found ${count} invalid paths. Attempting to fix...\n`, // Label messages fileReference: "File referenced in", lineReference: "Line", suggestionLabel: "Suggestion" };