gnosys 5.4.2 → 5.4.3

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.
package/dist/cli.js CHANGED
@@ -65,6 +65,49 @@ const __dirname = path.dirname(__filename);
65
65
  const pkgPath = path.resolve(__dirname, "..", "package.json");
66
66
  const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
67
67
  const program = new Command();
68
+ /**
69
+ * v5.4.3 upgrade nudge — runs once per CLI invocation. If the installed
70
+ * version differs from the last-seen one stored in central DB meta, print
71
+ * a one-line stderr nudge so the user knows to run `gnosys upgrade`.
72
+ *
73
+ * Why stderr: doesn't pollute stdout consumers (agents parsing JSON, scripts
74
+ * piping the output). Visible to humans, invisible to most parsers.
75
+ *
76
+ * Why central DB meta: survives across CLI invocations and works whether
77
+ * gnosys is installed globally, locally, or via npx. Single source of truth
78
+ * for "what was the last version this user saw."
79
+ *
80
+ * Skipped when:
81
+ * - GNOSYS_SKIP_UPGRADE_NUDGE=1
82
+ * - Running `gnosys upgrade` itself (would be redundant)
83
+ * - Central DB unavailable (graceful — never blocks the actual command)
84
+ */
85
+ function maybePrintUpgradeNudge() {
86
+ if (process.env.GNOSYS_SKIP_UPGRADE_NUDGE === "1")
87
+ return;
88
+ // Avoid printing the nudge when the user is already running upgrade.
89
+ if (process.argv[2] === "upgrade")
90
+ return;
91
+ try {
92
+ const db = GnosysDB.openLocal();
93
+ if (!db.isAvailable() || !db.isMigrated()) {
94
+ db.close();
95
+ return;
96
+ }
97
+ const seen = db.getMeta("last_seen_version");
98
+ const current = pkg.version;
99
+ if (seen !== current) {
100
+ const prefix = seen ? `upgraded to v${current} (from v${seen})` : `installed v${current}`;
101
+ process.stderr.write(`gnosys: ${prefix}. Run 'gnosys upgrade' to sync registered projects.\n`);
102
+ db.setMeta("last_seen_version", current);
103
+ }
104
+ db.close();
105
+ }
106
+ catch {
107
+ // Never block actual commands — silently skip on any error.
108
+ }
109
+ }
110
+ maybePrintUpgradeNudge();
68
111
  async function getResolver() {
69
112
  const resolver = new GnosysResolver();
70
113
  await resolver.resolve();