mumei-dashboard 0.4.0 → 0.4.2

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.
@@ -1,14 +1,36 @@
1
1
  #!/usr/bin/env node
2
- // Entry point for `npx @mumei/dashboard`. Boots the Fastify server in
2
+ // Entry point for `npx mumei-dashboard`. Boots the Fastify server in
3
3
  // the user's current working directory (which is read as the project
4
4
  // root). The Vite dev server is a separate concern handled by
5
5
  // `npm run dev` from the dashboard repo; the published bin always
6
6
  // runs the prebuilt server bundle (`dist/server/index.js`).
7
- import { existsSync } from 'node:fs'
7
+ import { existsSync, readFileSync } from 'node:fs'
8
8
  import path from 'node:path'
9
9
  import { fileURLToPath, pathToFileURL } from 'node:url'
10
10
 
11
11
  const here = path.dirname(fileURLToPath(import.meta.url))
12
+
13
+ const arg = process.argv[2]
14
+ if (arg === '--version' || arg === '-v' || arg === 'version') {
15
+ const pkg = JSON.parse(readFileSync(path.resolve(here, '../package.json'), 'utf8'))
16
+ process.stdout.write(`${pkg.version}\n`)
17
+ process.exit(0)
18
+ }
19
+ if (arg === '--help' || arg === '-h' || arg === 'help') {
20
+ process.stdout.write(`mumei-dashboard — local web UI for the mumei plugin
21
+
22
+ Usage:
23
+ mumei-dashboard Start the dashboard server (default port 3001)
24
+ mumei-dashboard --version Print version and exit
25
+ mumei-dashboard --help Show this help and exit
26
+
27
+ The server reads .mumei/ from the current working directory and serves
28
+ the dashboard at http://127.0.0.1:<port>. Override the port with the
29
+ MUMEI_DASHBOARD_PORT environment variable.
30
+ `)
31
+ process.exit(0)
32
+ }
33
+
12
34
  const builtEntry = path.resolve(here, '../dist/server/index.js')
13
35
  const sourceEntry = path.resolve(here, '../server/index.ts')
14
36
 
@@ -26,7 +48,7 @@ if (!existsSync(builtEntry)) {
26
48
  process.on('SIGTERM', () => child.kill('SIGTERM'))
27
49
  } else {
28
50
  console.error(
29
- '@mumei/dashboard: no built server found at dist/server/index.js. Run `npm run build:server`.',
51
+ 'mumei-dashboard: no built server found at dist/server/index.js. Run `npm run build:server`.',
30
52
  )
31
53
  process.exit(1)
32
54
  }