import { readdir } from 'node:fs/promises';
import { compareVersions } from '../update/index.js';
import { resolveFirstPartyInstallLayout } from './installLayout.js';
export async function listInstalledVersionIdsNewestFirst(params) {
    const layout = resolveFirstPartyInstallLayout({
        componentId: params.componentId,
        channel: params.channel,
        releaseRing: params.releaseRing,
        processEnv: params.processEnv,
    });
    const entries = await readdir(layout.versionsDir, { withFileTypes: true }).catch(() => []);
    return entries
        .filter((entry) => entry.isDirectory())
        .map((entry) => entry.name)
        .sort((left, right) => compareVersions(right, left));
}
//# sourceMappingURL=listInstalledVersionIdsNewestFirst.js.map