Skip to content

Know the latest updates #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Angelk90 opened this issue Feb 14, 2025 · 0 comments
Open

Know the latest updates #970

Angelk90 opened this issue Feb 14, 2025 · 0 comments

Comments

@Angelk90
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant