nansen-cli 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,41 @@ function isNewer(latest, current) {
28
28
  return lp > cp;
29
29
  }
30
30
 
31
+ const LAST_VERSION_FILE = path.join(CONFIG_DIR, 'last-version.json');
32
+
33
+ /**
34
+ * After an update, show a one-time "what's new" notice on the first run.
35
+ * Compares current version against the stored last-seen version.
36
+ * Returns a notice string or null. Writes current version to disk.
37
+ */
38
+ export function getUpgradeNotice(currentVersion) {
39
+ try {
40
+ if (process.env.NO_UPDATE_NOTIFIER || process.env.CI) return null;
41
+
42
+ let previousVersion = null;
43
+ if (fs.existsSync(LAST_VERSION_FILE)) {
44
+ const raw = fs.readFileSync(LAST_VERSION_FILE, 'utf8');
45
+ const data = JSON.parse(raw);
46
+ previousVersion = data.version;
47
+ }
48
+
49
+ // Always update the stored version
50
+ if (!fs.existsSync(CONFIG_DIR)) fs.mkdirSync(CONFIG_DIR, { mode: 0o700, recursive: true });
51
+ fs.writeFileSync(LAST_VERSION_FILE, JSON.stringify({ version: currentVersion }));
52
+
53
+ // If no previous version stored, this is a fresh install — no notice
54
+ if (!previousVersion) return null;
55
+
56
+ // If versions match, no update happened
57
+ if (previousVersion === currentVersion) return null;
58
+
59
+ // Version changed — show notice
60
+ return `\n ✨ Updated to ${currentVersion} (was ${previousVersion}). Run \`nansen changelog --since ${previousVersion}\` for details.\n`;
61
+ } catch {
62
+ return null;
63
+ }
64
+ }
65
+
31
66
  /**
32
67
  * Read the cached check result and return a notification string (or null).
33
68
  */