frontend-standards-checker
Version:
A comprehensive frontend standards validation tool with TypeScript support
61 lines • 2.27 kB
JavaScript
;
const fs = require('fs');
const path = require('path');
/**
* Script to copy frontend standards files from the package directory to the project root.
*
* This script checks for the existence of specific files in the package directory and copies them
* to the project root if they do not already exist. It logs the process and handles errors gracefully.
*
* Files copied:
* - checkFrontendStandards.config.mjs
* - checkFrontendStandards.COMPLETE-GUIDE.md
*
* Usage:
* Run this script using Node.js. It determines the package root based on the current directory,
* and copies the files to the current working directory.
*
* Logging:
* - Logs the source and destination paths for each file.
* - Indicates whether files were copied, already exist, or were not found.
* - Logs errors encountered during the copy process.
*/
const files = [
'checkFrontendStandards.config.mjs',
'checkFrontendStandards.COMPLETE-GUIDE.md',
];
const projectRoot = process.cwd();
let packageRoot;
if (__dirname.includes('node_modules')) {
packageRoot = path.resolve(__dirname, '../');
}
else {
packageRoot = path.resolve(__dirname, '../');
}
console.log(`[frontend-standards-checker] Package directory: ${packageRoot}`);
console.log(`[frontend-standards-checker] Project directory: ${projectRoot}`);
files.forEach((file) => {
const src = path.join(packageRoot, file);
const dest = path.join(projectRoot, file);
console.log(`[frontend-standards-checker] Trying to copy from: ${src}`);
console.log(`[frontend-standards-checker] To: ${dest}`);
if (!fs.existsSync(dest)) {
if (fs.existsSync(src)) {
try {
fs.copyFileSync(src, dest);
console.log(`[frontend-standards-checker] ✅ Copied: ${file}`);
}
catch (error) {
console.error(`[frontend-standards-checker] ❌ Error copying ${file}:`, error.message);
}
}
else {
console.warn(`[frontend-standards-checker] ⚠️ File not found: ${src}`);
}
}
else {
console.log(`[frontend-standards-checker] ℹ️ Already exists: ${file}`);
}
});
//# sourceMappingURL=copy-frontend-standards-files.cjs.map