import { buildCommandContext } from '../../../app/command-context.js';
import { withScopeOption } from '../../shared/scope-option.js';
import { readGlobalOptions } from '../../shared/shared.utils.js';
import { scanTools } from '../../tools/shared/scan-tools.js';
import { resolveAssetsRoot } from '../../../fs/assets.js';
import { resolveProjectRoot, resolveScopeRoot } from '../../../fs/paths.js';
import { Command } from 'commander';
import { runOutdatedTools, } from './outdated-tools.js';
const defaultDependencies = {
    scanTools,
    resolveScopeRoot: async (scope, cwd, home) => {
        if (scope === 'project')
            return resolveProjectRoot(cwd);
        return resolveScopeRoot(scope, cwd, home);
    },
    resolveAssetsRoot,
};
export function createToolsOutdatedCommand(dependencies = defaultDependencies) {
    return withScopeOption(new Command('outdated'))
        .description('Show tools with available updates')
        .action(async (_opts, command) => {
        const globalOptions = readGlobalOptions(command);
        const context = buildCommandContext(globalOptions);
        await runOutdatedTools(context, dependencies);
    });
}
