import { readFile } from 'node:fs/promises';
import { dirname } from 'node:path';
import { globby } from 'globby';
const isApplication = async (cwd) => {
    const content = await readFile(cwd, { encoding: 'utf-8' });
    const jsonContent = JSON.parse(content);
    return Boolean(jsonContent?.['generator-jhipster']?.baseName);
};
export const applicationsLookup = async (cwd) => {
    const yoRcFiles = await globby('**/.yo-rc.json', { cwd });
    const result = await Promise.all(yoRcFiles.map(async (file) => ({ file, isApp: await isApplication(file) })));
    return result.filter(({ isApp }) => isApp).map(({ file }) => dirname(file));
};
