claude-usage-dashboard 1.0.2 → 1.0.4

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/bin/cli.js CHANGED
@@ -1,7 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import { spawn } from 'child_process';
3
+ import { fileURLToPath } from 'url';
4
+ import path from 'path';
2
5
 
3
- // Keep stdin open so the process stays in the terminal foreground
4
- // (workaround for npx not attaching the child to the foreground process group)
5
- process.stdin.resume();
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ const server = path.join(__dirname, '..', 'server', 'index.js');
6
8
 
7
- import '../server/index.js';
9
+ const child = spawn(process.execPath, [server], {
10
+ stdio: 'inherit',
11
+ // Attach child to the terminal's foreground process group
12
+ detached: false,
13
+ });
14
+
15
+ child.on('exit', (code) => process.exit(code ?? 0));
16
+
17
+ // Forward signals to child
18
+ for (const sig of ['SIGINT', 'SIGTERM']) {
19
+ process.on(sig, () => child.kill(sig));
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-usage-dashboard",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Dashboard that visualizes Claude Code usage from local session logs",
5
5
  "main": "server/index.js",
6
6
  "bin": {
package/server/index.js CHANGED
@@ -1,15 +1,20 @@
1
1
  import express from 'express';
2
2
  import path from 'path';
3
3
  import os from 'os';
4
+ import { createRequire } from 'module';
4
5
  import { fileURLToPath } from 'url';
5
6
  import { createApiRouter } from './routes/api.js';
6
7
 
7
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+ const require = createRequire(import.meta.url);
8
10
  const PORT = process.env.PORT || 3000;
9
11
  const LOG_DIR = path.join(os.homedir(), '.claude', 'projects');
10
12
 
13
+ // Resolve d3 via Node module resolution so it works when dependencies are hoisted (e.g. npx)
14
+ const d3Dir = path.dirname(require.resolve('d3/dist/d3.min.js'));
15
+
11
16
  const app = express();
12
- app.use('/lib/d3', express.static(path.join(__dirname, '..', 'node_modules', 'd3', 'dist')));
17
+ app.use('/lib/d3', express.static(d3Dir));
13
18
  app.use(express.static(path.join(__dirname, '..', 'public')));
14
19
  app.use('/api', createApiRouter(LOG_DIR));
15
20