Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 38s
Build & Deploy / 🧪 QA (push) Failing after 36s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 3s
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
'use server';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
export async function getAnnotatorAssets() {
|
|
// Try /app/public first (docker), then process.cwd()/public
|
|
let publicDir = '/app/public';
|
|
if (!fs.existsSync(publicDir)) {
|
|
publicDir = path.join(process.cwd(), 'public');
|
|
}
|
|
|
|
const walk = (dir: string): string[] => {
|
|
let results: string[] = [];
|
|
if (!fs.existsSync(dir)) return results;
|
|
const list = fs.readdirSync(dir);
|
|
list.forEach((file) => {
|
|
const filePath = path.join(dir, file);
|
|
const stat = fs.statSync(filePath);
|
|
if (stat && stat.isDirectory()) {
|
|
results = results.concat(walk(filePath));
|
|
} else {
|
|
if (filePath.match(/\.(png|jpg|jpeg|webp|mp4|svg)$/i)) {
|
|
results.push(filePath.replace(publicDir, ''));
|
|
}
|
|
}
|
|
});
|
|
return results;
|
|
};
|
|
const results = walk(publicDir);
|
|
console.log('[Annotator] publicDir:', publicDir);
|
|
console.log('[Annotator] Assets found:', results.length);
|
|
console.log('[Annotator] First 5 paths:', results.slice(0, 5));
|
|
|
|
return results;
|
|
}
|