import { readdir, stat } from 'fs/promises';
import { join } from 'path';

async function listDirectory(path, indent = 0) {
  try {
    const items = await readdir(path);
    for (const item of items) {
      const itemPath = join(path, item);
      const stats = await stat(itemPath);
      const prefix = '  '.repeat(indent);
      
      if (stats.isDirectory()) {
        console.log(`${prefix}[DIR] ${item}`);
        await listDirectory(itemPath, indent + 1);
      } else {
        console.log(`${prefix}[FILE] ${item}`);
      }
    }
  } catch (error) {
    console.error(`Error reading directory ${path}:`, error.message);
  }
}

// 显示项目中的example目录结构
console.log('项目中的example目录结构:');
await listDirectory('J:\\git\\cssEngine\\template-example');