claude-code-templates 1.5.0 → 1.5.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/analytics.js +73 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-templates",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "CLI tool to setup Claude Code configurations with framework-specific commands, automation hooks and MCP Servers for your projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/analytics.js CHANGED
@@ -240,13 +240,15 @@ class ClaudeAnalytics {
240
240
  });
241
241
 
242
242
  conversationWatcher.on('change', async () => {
243
+ console.log(chalk.yellow('🔄 Conversation file changed, updating data...'));
243
244
  await this.loadInitialData();
244
- console.log(chalk.green('🔄 Conversation data updated'));
245
+ console.log(chalk.green(' Data updated'));
245
246
  });
246
247
 
247
248
  conversationWatcher.on('add', async () => {
249
+ console.log(chalk.yellow('📝 New conversation file detected...'));
248
250
  await this.loadInitialData();
249
- console.log(chalk.green('📝 New conversation detected'));
251
+ console.log(chalk.green(' Data updated'));
250
252
  });
251
253
 
252
254
  this.watchers.push(conversationWatcher);
@@ -259,11 +261,24 @@ class ClaudeAnalytics {
259
261
  });
260
262
 
261
263
  projectWatcher.on('addDir', async () => {
264
+ console.log(chalk.yellow('📁 New project directory detected...'));
262
265
  await this.loadInitialData();
263
- console.log(chalk.green('📁 New project detected'));
266
+ console.log(chalk.green(' Data updated'));
267
+ });
268
+
269
+ projectWatcher.on('change', async () => {
270
+ console.log(chalk.yellow('📁 Project directory changed...'));
271
+ await this.loadInitialData();
272
+ console.log(chalk.green('✅ Data updated'));
264
273
  });
265
274
 
266
275
  this.watchers.push(projectWatcher);
276
+
277
+ // Also set up periodic refresh to catch any missed changes
278
+ setInterval(async () => {
279
+ console.log(chalk.blue('⏱️ Periodic data refresh...'));
280
+ await this.loadInitialData();
281
+ }, 30000); // Every 30 seconds
267
282
  }
268
283
 
269
284
  setupWebServer() {
@@ -271,12 +286,34 @@ class ClaudeAnalytics {
271
286
  this.app.use(express.static(path.join(__dirname, 'analytics-web')));
272
287
 
273
288
  // API endpoints
274
- this.app.get('/api/data', (req, res) => {
275
- res.json(this.data);
289
+ this.app.get('/api/data', async (req, res) => {
290
+ // Add timestamp to verify data freshness
291
+ const dataWithTimestamp = {
292
+ ...this.data,
293
+ timestamp: new Date().toISOString(),
294
+ lastUpdate: new Date().toLocaleString()
295
+ };
296
+ res.json(dataWithTimestamp);
276
297
  });
277
298
 
278
- this.app.get('/api/realtime', (req, res) => {
279
- res.json(this.data.realtimeStats);
299
+ this.app.get('/api/realtime', async (req, res) => {
300
+ const realtimeWithTimestamp = {
301
+ ...this.data.realtimeStats,
302
+ timestamp: new Date().toISOString(),
303
+ lastUpdate: new Date().toLocaleString()
304
+ };
305
+ res.json(realtimeWithTimestamp);
306
+ });
307
+
308
+ // Force refresh endpoint
309
+ this.app.get('/api/refresh', async (req, res) => {
310
+ console.log(chalk.blue('🔄 Manual refresh requested...'));
311
+ await this.loadInitialData();
312
+ res.json({
313
+ success: true,
314
+ message: 'Data refreshed',
315
+ timestamp: new Date().toISOString()
316
+ });
280
317
  });
281
318
 
282
319
  // Main dashboard route
@@ -543,6 +580,7 @@ async function createWebDashboard() {
543
580
  Claude Code Analytics
544
581
  </h1>
545
582
  <p>Real-time monitoring of your Claude Code usage</p>
583
+ <p id="lastUpdate" style="font-size: 0.75rem; opacity: 0.8;"></p>
546
584
  </div>
547
585
 
548
586
  <div id="loading" class="loading">
@@ -601,9 +639,15 @@ async function createWebDashboard() {
601
639
  const response = await fetch('/api/data');
602
640
  const data = await response.json();
603
641
 
642
+ console.log('Data loaded:', data.timestamp);
643
+
604
644
  document.getElementById('loading').style.display = 'none';
605
645
  document.getElementById('dashboard').style.display = 'block';
606
646
 
647
+ // Update timestamp
648
+ document.getElementById('lastUpdate').textContent =
649
+ \`Last updated: \${data.lastUpdate}\`;
650
+
607
651
  updateStats(data.summary);
608
652
  updateConversations(data.conversations);
609
653
  updateProjects(data.activeProjects);
@@ -660,11 +704,31 @@ async function createWebDashboard() {
660
704
  \`).join('');
661
705
  }
662
706
 
707
+ // Manual refresh function
708
+ async function forceRefresh() {
709
+ try {
710
+ const response = await fetch('/api/refresh');
711
+ const result = await response.json();
712
+ console.log('Manual refresh:', result);
713
+ await loadData();
714
+ } catch (error) {
715
+ console.error('Failed to refresh:', error);
716
+ }
717
+ }
718
+
663
719
  // Load initial data
664
720
  loadData();
665
721
 
666
- // Refresh data every 10 seconds
667
- setInterval(loadData, 10000);
722
+ // Refresh data every 5 seconds
723
+ setInterval(loadData, 5000);
724
+
725
+ // Add keyboard shortcut for refresh (F5 or Ctrl+R)
726
+ document.addEventListener('keydown', function(e) {
727
+ if (e.key === 'F5' || (e.ctrlKey && e.key === 'r')) {
728
+ e.preventDefault();
729
+ forceRefresh();
730
+ }
731
+ });
668
732
  </script>
669
733
  </body>
670
734
  </html>`;