repoview 0.1.0 → 0.1.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/DEVELOPMENT.md CHANGED
@@ -20,7 +20,7 @@ npm start -- --repo /path/to/repo --port 3000
20
20
 
21
21
  Useful flags:
22
22
  - `--watch` / `--no-watch` (watch is on by default)
23
- - `--host 0.0.0.0` to access from other devices on the network
23
+ - `--host 127.0.0.1` to bind locally only
24
24
 
25
25
  ## Routes
26
26
 
@@ -67,3 +67,20 @@ Notes:
67
67
  npm run lint
68
68
  ```
69
69
 
70
+ ## Release checklist
71
+
72
+ Before publishing to npm, run a quick smoke test from a clean install context (this catches issues where the server accidentally serves assets from the *repo* instead of the installed package):
73
+
74
+ ```bash
75
+ npm run lint
76
+ npm pack
77
+
78
+ # install the tarball somewhere else
79
+ tmp=$(mktemp -d)
80
+ cd "$tmp"
81
+ npm init -y
82
+ npm install /path/to/repoview-*.tgz
83
+
84
+ # serve any repo and verify vendor assets load (no ENOENT)
85
+ node ./node_modules/.bin/repoview --repo /path/to/repo --port 3000
86
+ ```
package/README.md CHANGED
@@ -25,12 +25,18 @@ Then open `http://localhost:3000`.
25
25
 
26
26
  ## Quick start (npx)
27
27
 
28
- After publishing to npm:
28
+ From anywhere:
29
29
 
30
30
  ```bash
31
31
  npx repoview --repo /path/to/your/repo --port 3000
32
32
  ```
33
33
 
34
+ By default, `repoview` binds to `0.0.0.0` (LAN-accessible). For localhost-only:
35
+
36
+ ```bash
37
+ npx repoview --repo /path/to/your/repo --host 127.0.0.1 --port 3000
38
+ ```
39
+
34
40
  ## Why
35
41
 
36
42
  - Keep GitHub as a remote, not your developer portal.
@@ -40,7 +46,7 @@ npx repoview --repo /path/to/your/repo --port 3000
40
46
  ## Usage
41
47
 
42
48
  ```bash
43
- npm start -- --repo /path/to/repo [--host 127.0.0.1] [--port 3000] [--no-watch]
49
+ npm start -- [--repo /path/to/repo] [--host 0.0.0.0] [--port 3000] [--no-watch]
44
50
  ```
45
51
 
46
52
  Common flags:
@@ -66,6 +72,10 @@ npm start -- --repo /path/to/repo --host 0.0.0.0 --port 8890
66
72
  - Implementation details: [`DEVELOPMENT.md`](DEVELOPMENT.md)
67
73
  - CLI usage: `npm start -- --help`
68
74
 
75
+ ## Troubleshooting
76
+
77
+ - Seeing `ENOENT .../node_modules/...` in server logs: upgrade to `repoview@>=0.1.2` (older versions incorrectly looked for vendor assets inside the repo you’re serving).
78
+
69
79
  ## Contributing
70
80
 
71
81
  - Contributing guide: [`CONTRIBUTING.md`](CONTRIBUTING.md)
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "repoview",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "GitHub-like repo browsing for local Git repositories (Markdown, live reload, broken link scanner).",
7
+ "homepage": "https://github.com/h4x3rotab/repoview#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/h4x3rotab/repoview/issues"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/h4x3rotab/repoview.git"
14
+ },
7
15
  "license": "MIT",
8
16
  "author": "Hang Yin <hangyin@phala.com>",
9
17
  "bin": {
package/src/cli.js CHANGED
@@ -6,17 +6,18 @@ import { startServer } from "./server.js";
6
6
 
7
7
  function printHelp() {
8
8
  // Keep this in sync with README.md
9
- process.stdout.write(`repo-viewer
9
+ process.stdout.write(`repoview
10
10
 
11
11
  Serve a local Git repository as a GitHub-like website.
12
12
 
13
13
  Usage:
14
- npm start -- --repo /path/to/repo [--host 127.0.0.1] [--port 3000] [--no-watch]
15
- node src/cli.js --repo /path/to/repo [--host 127.0.0.1] [--port 3000] [--no-watch]
14
+ npx repoview [--repo /path/to/repo] [--host 0.0.0.0] [--port 3000] [--no-watch]
15
+ repoview [--repo /path/to/repo] [--host 0.0.0.0] [--port 3000] [--no-watch]
16
+ npm start -- [--repo /path/to/repo] [--host 0.0.0.0] [--port 3000] [--no-watch]
16
17
 
17
18
  Options:
18
- --repo <path> Repository root (default: REPO_ROOT or project dir)
19
- --host <host> Bind address (default: 127.0.0.1)
19
+ --repo <path> Repository root (default: REPO_ROOT or current dir)
20
+ --host <host> Bind address (default: 0.0.0.0)
20
21
  --port <port> Bind port (default: 3000)
21
22
  --watch Enable live reload (default)
22
23
  --no-watch Disable live reload
@@ -62,11 +63,11 @@ if (port != null && !Number.isFinite(port)) {
62
63
  const repoRoot =
63
64
  repo ??
64
65
  process.env.REPO_ROOT ??
65
- path.resolve(__dirname, "..");
66
+ process.cwd();
66
67
 
67
68
  await startServer({
68
69
  repoRoot,
69
70
  port: port || Number(process.env.PORT) || 3000,
70
- host: host || process.env.HOST || "127.0.0.1",
71
+ host: host || process.env.HOST || "0.0.0.0",
71
72
  watch,
72
73
  });
package/src/markdown.js CHANGED
@@ -288,7 +288,7 @@ export function createMarkdownRenderer() {
288
288
  "input",
289
289
  ],
290
290
  allowedAttributes: {
291
- "*": ["class", "id", "aria-label", "aria-hidden", "role"],
291
+ "*": ["class", "id", "aria-label", "aria-hidden", "role", "align"],
292
292
  a: ["href", "name", "title", "target", "rel", "tabindex"],
293
293
  img: ["src", "alt", "title", "width", "height", "loading"],
294
294
  input: ["type", "checked", "disabled"],
package/src/server.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import fs from "node:fs/promises";
2
2
  import http from "node:http";
3
+ import { createRequire } from "node:module";
3
4
  import path from "node:path";
4
5
  import { spawn } from "node:child_process";
6
+ import { fileURLToPath } from "node:url";
5
7
  import express from "express";
6
8
  import chokidar from "chokidar";
7
9
  import mime from "mime-types";
@@ -141,6 +143,16 @@ function createReloadHub() {
141
143
  }
142
144
 
143
145
  export async function startServer({ repoRoot, host, port, watch }) {
146
+ const __filename = fileURLToPath(import.meta.url);
147
+ const __dirname = path.dirname(__filename);
148
+ const packageRoot = path.resolve(__dirname, "..");
149
+ const require = createRequire(import.meta.url);
150
+
151
+ const resolvePackageDir = (name) => {
152
+ const pkgJson = require.resolve(`${name}/package.json`);
153
+ return path.dirname(pkgJson);
154
+ };
155
+
144
156
  const repoRootReal = await fs.realpath(repoRoot);
145
157
  const repoName = path.basename(repoRootReal);
146
158
  const gitInfo = await getGitInfo(repoRootReal);
@@ -153,29 +165,29 @@ export async function startServer({ repoRoot, host, port, watch }) {
153
165
  const app = express();
154
166
  app.disable("x-powered-by");
155
167
 
156
- const publicDir = path.join(process.cwd(), "public");
168
+ const publicDir = path.join(packageRoot, "public");
157
169
  app.use("/static", express.static(publicDir, { fallthrough: true }));
158
170
  app.use(
159
171
  "/static/vendor/github-markdown-css",
160
- express.static(path.join(process.cwd(), "node_modules/github-markdown-css"), {
172
+ express.static(resolvePackageDir("github-markdown-css"), {
161
173
  fallthrough: false,
162
174
  }),
163
175
  );
164
176
  app.use(
165
177
  "/static/vendor/highlight.js",
166
- express.static(path.join(process.cwd(), "node_modules/highlight.js"), {
178
+ express.static(resolvePackageDir("highlight.js"), {
167
179
  fallthrough: false,
168
180
  }),
169
181
  );
170
182
  app.use(
171
183
  "/static/vendor/katex",
172
- express.static(path.join(process.cwd(), "node_modules/katex/dist"), {
184
+ express.static(path.join(resolvePackageDir("katex"), "dist"), {
173
185
  fallthrough: false,
174
186
  }),
175
187
  );
176
188
  app.use(
177
189
  "/static/vendor/mermaid",
178
- express.static(path.join(process.cwd(), "node_modules/mermaid/dist"), {
190
+ express.static(path.join(resolvePackageDir("mermaid"), "dist"), {
179
191
  fallthrough: false,
180
192
  }),
181
193
  );
@@ -481,7 +493,7 @@ export async function startServer({ repoRoot, host, port, watch }) {
481
493
  }
482
494
 
483
495
  // eslint-disable-next-line no-console
484
- console.log(`repo-viewer: ${repoRootReal}`);
496
+ console.log(`repoview: ${repoRootReal}`);
485
497
  // eslint-disable-next-line no-console
486
498
  console.log(`listening: http://${host}:${port}`);
487
499
  }