MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / checkForUpdates

Function checkForUpdates

cli-node/lib/updater.js:5–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3const package = require('../package.json');
4
5async function checkForUpdates() {
6 console.log(chalk.blue('🔍 Checking for updates...'));
7
8 try {
9 // Check latest version from npm
10 const latestVersion = execSync(`npm view ${package.name} version`, {
11 encoding: 'utf8'
12 }).trim();
13
14 const currentVersion = package.version;
15
16 console.log('');
17 console.log(chalk.gray('Current version: ') + chalk.yellow(currentVersion));
18 console.log(chalk.gray('Latest version: ') + chalk.green(latestVersion));
19 console.log('');
20
21 if (currentVersion === latestVersion) {
22 console.log(chalk.green('✅ You are using the latest version!'));
23 console.log('');
24 return;
25 }
26
27 // Offer to update
28 console.log(chalk.yellow('🆕 A new version is available!'));
29 console.log('');
30 console.log(chalk.blue('To update, run:'));
31 console.log(chalk.cyan(` npm install -g ${package.name}@latest`));
32 console.log('');
33
34 // Show what's new (if we have release notes)
35 console.log(chalk.gray('📝 For release notes, visit:'));
36 console.log(chalk.cyan(` ${package.homepage}/releases`));
37 console.log('');
38
39 } catch (error) {
40 if (error.message.includes('404')) {
41 console.log(chalk.yellow('⚠️ Could not find package on npm registry'));
42 console.log(chalk.gray('This might be a local development version'));
43 } else {
44 console.log(chalk.red('❌ Failed to check for updates'));
45 console.log(chalk.gray('Please check your internet connection'));
46 }
47 console.log('');
48 }
49}
50
51module.exports = { checkForUpdates };

Callers 1

datakit.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected