mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 16:32:08 +01:00
Improves the dashboard with additional metrics and visualizations to provide a more comprehensive overview of application usage and performance. Adds new charts, including: - Word cloud for category analysis - Geographic map for user distribution (simulated data) - Response time distribution chart Refactors existing components for improved clarity and reusability, including the introduction of a generic `MetricCard` component. Improves error handling and user feedback during data refresh and session loading. Adds recommended VSCode extensions for ESLint and Prettier.
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
// Fix Trailing Whitespace
|
|
// This script removes trailing whitespace from specified file types
|
|
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
// Configure which file types to process
|
|
const fileTypes = [".ts", ".tsx", ".js", ".jsx", ".json", ".md", ".css"];
|
|
|
|
// Configure directories to ignore
|
|
const ignoreDirs = ["node_modules", ".next", ".git", "out", "build", "dist"];
|
|
|
|
// Recursively process directories
|
|
async function processDirectory(dir) {
|
|
try {
|
|
const files = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
|
|
for (const file of files) {
|
|
const fullPath = path.join(dir, file.name);
|
|
|
|
// Skip ignored directories
|
|
if (file.isDirectory()) {
|
|
if (!ignoreDirs.includes(file.name)) {
|
|
await processDirectory(fullPath);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
// Process only files with matching extensions
|
|
const ext = path.extname(file.name);
|
|
if (!fileTypes.includes(ext)) {
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
// Read and process the file
|
|
const content = await fs.promises.readFile(fullPath, "utf8");
|
|
|
|
// Remove trailing whitespace from each line
|
|
const processedContent = content
|
|
.split("\n")
|
|
.map((line) => line.replace(/\s+$/, ""))
|
|
.join("\n");
|
|
|
|
// Only write if changes were made
|
|
if (processedContent !== content) {
|
|
await fs.promises.writeFile(fullPath, processedContent, "utf8");
|
|
console.log(`Fixed trailing whitespace in ${fullPath}`);
|
|
}
|
|
} catch (fileError) {
|
|
console.error(`Error processing file ${fullPath}:`, fileError);
|
|
}
|
|
}
|
|
} catch (dirError) {
|
|
console.error(`Error reading directory ${dir}:`, dirError);
|
|
}
|
|
}
|
|
|
|
// Start processing from root directory
|
|
const rootDir = process.cwd();
|
|
console.log(`Starting whitespace cleanup from ${rootDir}`);
|
|
processDirectory(rootDir)
|
|
.then(() => console.log("Whitespace cleanup completed"))
|
|
.catch((err) => console.error("Error in whitespace cleanup:", err));
|