feat(cli): add ultracite, oxlint, fumadocs addons (#427)

This commit is contained in:
Aman Varshney
2025-07-29 00:13:51 +05:30
committed by GitHub
parent 82a4f42eca
commit 216c242f7d
66 changed files with 794 additions and 251 deletions

View File

@@ -1,7 +1,11 @@
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { execSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import Papa from "papaparse";
// TODO: write a more effiecient way of handling analytics
interface AnalyticsData {
date: string;
hour: number;
@@ -36,7 +40,7 @@ interface ProcessedAnalyticsData {
totalRecords: number;
}
async function generateAnalyticsData(): Promise<void> {
async function generateAnalyticsData() {
try {
console.log("🔄 Fetching analytics data...");
@@ -157,18 +161,29 @@ async function generateAnalyticsData(): Promise<void> {
totalRecords: processedData.length,
};
const publicDir = join(process.cwd(), "public");
if (!existsSync(publicDir)) {
mkdirSync(publicDir, { recursive: true });
}
console.log("📤 Uploading to Cloudflare R2...");
const outputPath = join(publicDir, "analytics-data.json");
writeFileSync(outputPath, JSON.stringify(analyticsData, null, 2));
const tempDir = mkdtempSync(join(tmpdir(), "analytics-"));
const tempFilePath = join(tempDir, "analytics-data.json");
writeFileSync(tempFilePath, JSON.stringify(analyticsData, null, 2));
const BUCKET_NAME = "bucket";
const key = "analytics-data.json";
const cmd = `npx wrangler r2 object put "${BUCKET_NAME}/${key}" --file="${tempFilePath}" --remote`;
console.log(`Uploading ${tempFilePath} to r2://${BUCKET_NAME}/${key} ...`);
try {
execSync(cmd, { stdio: "inherit" });
} catch (err) {
console.error("Failed to upload analytics data:", err);
throw err;
}
console.log(
`✅ Generated analytics data with ${processedData.length} records`,
);
console.log(`📁 Saved to: ${outputPath}`);
console.log("📤 Uploaded to R2 bucket: bucket/analytics-data.json");
console.log(`🕒 Last data update: ${lastUpdated}`);
} catch (error) {
console.error("❌ Error generating analytics data:", error);