console.log('DEBUG SCRIPT STARTING...');

async function debug() {
  console.log('Importing dependencies...');
  try {
    const { getAllProductsMetadata } = await import('./lib/mdx');
    const { getAllPostsMetadata } = await import('./lib/blog');
    const { getAllPagesMetadata } = await import('./lib/pages');

    console.log('Dependencies imported.');

    const locales = ['de', 'en'];
    for (const locale of locales) {
      console.log(`--- Locale: ${locale} ---`);

      try {
        const products = await getAllProductsMetadata(locale);
        console.log(`Products (${locale}): ${products.length}`);
      } catch (e) {
        console.error(`Failed to get products for ${locale}:`, e);
      }

      try {
        const posts = await getAllPostsMetadata(locale);
        console.log(`Posts (${locale}): ${posts.length}`);
      } catch (e) {
        console.error(`Failed to get posts for ${locale}:`, e);
      }

      try {
        const pages = await getAllPagesMetadata(locale);
        console.log(`Pages (${locale}): ${pages.length}`);
      } catch (e) {
        console.error(`Failed to get pages for ${locale}:`, e);
      }
    }
  } catch (err) {
    console.error('Debug failed during setup/imports:', err);
  }
  console.log('DEBUG SCRIPT FINISHED.');
  process.exit(0);
}

debug().catch((err) => {
  console.error('Unhandled retransmission error in debug():', err);
  process.exit(1);
});
