Skip to content

Know the latest updates #970

@Angelk90

Description

@Angelk90

Is your feature request related to a problem? Please describe.
It would be useful to know the recent updates.
I currently do something like this, if it could be integrated, it would be useful.

I have tested it, but it would be better to check it further.

async function getRecentUpdates() {
    let updates = [];
    if (os.platform() === 'linux') {
        try {
            const aptList = await execCommand("apt list --installed");
            const aptLines = aptList.split('\n').slice(1);

            const aptHistory = await execCommand("grep 'Upgrade:' /var/log/apt/history.log", true);
            const aptHistoryLines = aptHistory.split('\n');

            updates = aptLines.map(line => {
                const parts = line.split(' ');
                let date = 'Unknown';

                aptHistoryLines.forEach(historyLine => {
                    if (historyLine.includes(parts[0])) {
                        const dateMatch = historyLine.match(/\d{4}-\d{2}-\d{2}/);
                        if (dateMatch) {
                            date = dateMatch[0];
                        }
                    }
                });

                return {
                    displayName: parts[0],
                    version: parts[1] || 'Unknown',
                    date: date
                };
            });
        } catch (error) {
            console.error('Error fetching recent updates:', error);
        }
    } else if (os.platform() === 'darwin') {
        const softwareUpdateHistory = execCommand("softwareupdate --history");
        const softwareLines = softwareUpdateHistory.split('\n').slice(2);
        updates = softwareLines.map(line => {
            const parts = line.trim().split(/\s{2,}/);
            if (parts.length >= 3) {
                return {
                    displayName: parts[0].trim(),
                    version: parts[1].trim(),
                    date: parts[2].trim()
                };
            }
            return null;
        }).filter(update => update !== null);
    } else if (os.platform() === 'win32') {
        const recentUpdatesCmd = execCommand("wmic qfe list");
        const recentUpdatesLines = recentUpdatesCmd.split('\n').slice(1);
        updates = recentUpdatesLines.map(line => {
            const parts = line.trim().split(/\s+/);
            return {
                displayName: parts[0],
                version: parts.length > 3 ? parts[3] : 'Unknown',
                date: parts[2] || 'Unknown'
            };
        });
    }
    return updates;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions