@takazudo/zudo-doc-history-server 10.0.0 → 10.0.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to `@takazudo/zudo-doc-history-server` are documented in thi
4
4
 
5
5
  The format is based on Keep a Changelog, and release notes are generated from the changelog MDX pages.
6
6
 
7
+ ## [10.0.2] - 2026-11-11
8
+
9
+ - No package-specific changes.
10
+
11
+ ## [10.0.1] - 2026-11-11
12
+
13
+ - No package-specific changes.
14
+
7
15
  ## [10.0.0] - 2026-11-10
8
16
 
9
17
  - No package-specific changes.
package/dist/args.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ /** Shared argument parsing utilities for CLI and server entry points */
2
+ export interface LocaleEntry {
3
+ key: string;
4
+ dir: string;
5
+ }
6
+ /**
7
+ * Resolve a relative content/locale path to an absolute, existing directory.
8
+ *
9
+ * When invoked via `pnpm --filter <pkg>`, process.cwd() is the package
10
+ * directory, not the repo root. pnpm sets INIT_CWD to the directory where pnpm
11
+ * was originally invoked — typically the repo root — so the canonical clean
12
+ * form "src/content/docs" resolves correctly via INIT_CWD without any "../../"
13
+ * prefix. CI (`build-history`) and `dev:history` both pass this clean form.
14
+ *
15
+ * Resolution order:
16
+ * 1. Absolute path → use as-is
17
+ * 2. Relative + INIT_CWD set + resolves to an existing directory → use that
18
+ * 3. Relative → fall back to process.cwd()
19
+ *
20
+ * The resolved path MUST be an existing directory. A non-existent path is a
21
+ * HARD error (exit 1), not a silent fallthrough: scanning a missing dir yields
22
+ * zero history entries while the process still exits 0, hiding a misconfigured
23
+ * `--content-dir` behind a green CI run (the silent-empty-history class behind
24
+ * #1907 / #1913). Failing loud turns that into a visible CI failure.
25
+ */
26
+ export declare function resolveContentPath(p: string): string;
27
+ export interface CommonArgs {
28
+ contentDir: string;
29
+ locales: LocaleEntry[];
30
+ maxEntries: number;
31
+ exclude: string[];
32
+ }
33
+ export interface ServerArgs extends CommonArgs {
34
+ port: number;
35
+ /** Network interface to bind. Defaults to "127.0.0.1" (localhost only). */
36
+ host: string;
37
+ /**
38
+ * Whether the caller explicitly opted in to LAN exposure via --allow-lan-history.
39
+ * Required when --host is a non-loopback address; the server refuses to bind
40
+ * a non-loopback address without this flag, preventing accidental LAN exposure
41
+ * of full git history (including unpublished content).
42
+ */
43
+ allowLan: boolean;
44
+ }
45
+ export interface CliArgs extends CommonArgs {
46
+ outDir: string;
47
+ }
48
+ /** Parse shared flags (--content-dir, --locale, --max-entries, --exclude) */
49
+ export declare function parseCommonArgs(args: string[], extra: {
50
+ onFlag: (flag: string, nextArg: () => string) => boolean;
51
+ }): CommonArgs;
52
+ /** Parse server-specific args */
53
+ export declare function parseServerArgs(args: string[]): ServerArgs;
54
+ /** Parse CLI-specific args */
55
+ export declare function parseCliArgs(args: string[]): CliArgs;
package/dist/cli.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #!/usr/bin/env node
2
+ export {};
@@ -2,7 +2,7 @@
2
2
  * Tiny semaphore for bounded parallelism — avoids a p-limit dependency.
3
3
  * Limits concurrent async tasks to `concurrency` at a time.
4
4
  */
5
- declare function makeSemaphore(concurrency: number): () => Promise<() => void>;
5
+ export declare function makeSemaphore(concurrency: number): () => Promise<() => void>;
6
6
  /**
7
7
  * Default concurrency for git-history tasks: CPU count clamped to [2, 8].
8
8
  * Each getDocHistoryAsync call issues one git process, so this saturates git
@@ -10,6 +10,4 @@ declare function makeSemaphore(concurrency: number): () => Promise<() => void>;
10
10
  * / postBuild per-file fan-out; the preBuild meta pass no longer uses it — it
11
11
  * walks history once via getAllFilesFirstLastMetaAsync (#2517).
12
12
  */
13
- declare function defaultGitConcurrency(): number;
14
-
15
- export { defaultGitConcurrency, makeSemaphore };
13
+ export declare function defaultGitConcurrency(): number;
package/dist/exclude.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  /** Compile doc-history exclude globs into a reusable slug predicate. */
2
- declare function compileExclude(patterns: string[]): (slug: string) => boolean;
3
-
4
- export { compileExclude };
2
+ export declare function compileExclude(patterns: string[]): (slug: string) => boolean;
@@ -1,5 +1,4 @@
1
- import { DocHistoryData } from './types.js';
2
-
1
+ import type { DocHistoryData } from "./types.js";
3
2
  /**
4
3
  * True when the current working tree is inside a git repository. Public entry
5
4
  * points call this first and return empty results when it is false, so no git
@@ -7,7 +6,7 @@ import { DocHistoryData } from './types.js';
7
6
  * what lets `pnpm dev` / `pnpm build` succeed in a project that has not been
8
7
  * `git init`-ed yet, instead of crashing the doc-history preBuild hook.
9
8
  */
10
- declare function isGitRepo(): boolean;
9
+ export declare function isGitRepo(): boolean;
11
10
  /**
12
11
  * Pure parser for `git log --follow --format=%H --name-only` output.
13
12
  *
@@ -26,7 +25,7 @@ declare function isGitRepo(): boolean;
26
25
  * avoids the previous two-pass approach (collect all hashes → re-classify)
27
26
  * and is robust against file paths that happen to be 40-char hex strings.
28
27
  */
29
- declare function parseHashToPathMap(output: string): Map<string, string>;
28
+ export declare function parseHashToPathMap(output: string): Map<string, string>;
30
29
  /**
31
30
  * Get the complete history for a document file.
32
31
  *
@@ -40,9 +39,9 @@ declare function parseHashToPathMap(output: string): Map<string, string>;
40
39
  * Issues all git commands via execFile / spawn (non-blocking) so the CLI's
41
40
  * semaphore-bounded concurrency actually parallelizes across files (#1986).
42
41
  */
43
- declare function getDocHistoryAsync(filePath: string, slug: string, maxEntries?: number): Promise<DocHistoryData>;
42
+ export declare function getDocHistoryAsync(filePath: string, slug: string, maxEntries?: number): Promise<DocHistoryData>;
44
43
  /** Oldest + newest author/date for a single current-path key. */
45
- interface FirstLastMeta {
44
+ export interface FirstLastMeta {
46
45
  /** The file's creation-side commit (author = page author, date = createdDate). */
47
46
  oldest: {
48
47
  author: string;
@@ -59,7 +58,7 @@ interface FirstLastMeta {
59
58
  * Keyed by CURRENT repo-relative path (exactly what git emits). Exported for
60
59
  * unit tests; the streaming walk uses the same accumulator incrementally.
61
60
  */
62
- declare function parseFirstLastMeta(output: string): Map<string, FirstLastMeta>;
61
+ export declare function parseFirstLastMeta(output: string): Map<string, FirstLastMeta>;
63
62
  /**
64
63
  * Walk the WHOLE git history ONCE and return `{oldest, newest}` author/date for
65
64
  * every current file, keyed by ABSOLUTE path (`<repoRoot>/<relPath>`) so a
@@ -90,15 +89,12 @@ declare function parseFirstLastMeta(output: string): Map<string, FirstLastMeta>;
90
89
  * cwd = repo root (#1907). Returns an empty Map outside a git repo so callers
91
90
  * degrade to an empty manifest instead of crashing.
92
91
  */
93
- declare function getAllFilesFirstLastMetaAsync(pathspecs?: string[]): Promise<Map<string, FirstLastMeta>>;
92
+ export declare function getAllFilesFirstLastMetaAsync(pathspecs?: string[]): Promise<Map<string, FirstLastMeta>>;
94
93
  /**
95
94
  * Collect all MDX/md files in a content directory.
96
95
  * Returns array of { filePath, slug } pairs.
97
96
  */
98
- declare function collectContentFiles(dir: string): Array<{
97
+ export declare function collectContentFiles(dir: string): Array<{
99
98
  filePath: string;
100
99
  slug: string;
101
100
  }>;
102
-
103
- export { collectContentFiles, getAllFilesFirstLastMetaAsync, getDocHistoryAsync, isGitRepo, parseFirstLastMeta, parseHashToPathMap };
104
- export type { FirstLastMeta };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,14 @@
1
+ export interface ServerOptions {
2
+ port: number;
3
+ /** Network interface to bind. Defaults to "127.0.0.1" (localhost only). */
4
+ host: string;
5
+ contentDir: string;
6
+ locales: Array<{
7
+ key: string;
8
+ dir: string;
9
+ }>;
10
+ maxEntries: number;
11
+ exclude: string[];
12
+ }
13
+ /** Create and start the HTTP server */
14
+ export declare function startServer(options: ServerOptions): void;
@@ -0,0 +1,5 @@
1
+ /** Build list of [localeKey | null, absoluteDir] pairs from content config */
2
+ export declare function getContentDirEntries(contentDir: string, locales: Array<{
3
+ key: string;
4
+ dir: string;
5
+ }>): Array<[string | null, string]>;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** A single git revision entry for a document */
2
- interface DocHistoryEntry {
2
+ export interface DocHistoryEntry {
3
3
  /** Full commit hash (use .slice(0, 7) for display) */
4
4
  hash: string;
5
5
  /** ISO 8601 date string */
@@ -12,7 +12,7 @@ interface DocHistoryEntry {
12
12
  content: string;
13
13
  }
14
14
  /** Complete history data for a single document */
15
- interface DocHistoryData {
15
+ export interface DocHistoryData {
16
16
  /** Document slug (route path) */
17
17
  slug: string;
18
18
  /** Relative file path in the repository */
@@ -20,5 +20,3 @@ interface DocHistoryData {
20
20
  /** Git revision entries, newest first */
21
21
  entries: DocHistoryEntry[];
22
22
  }
23
-
24
- export type { DocHistoryData, DocHistoryEntry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takazudo/zudo-doc-history-server",
3
- "version": "10.0.0",
3
+ "version": "10.0.2",
4
4
  "type": "module",
5
5
  "description": "Standalone doc git-history service for zudo-doc — HTTP server + CLI batch generator. Decouples expensive `git log --follow` calls from the main build pipeline.",
6
6
  "license": "MIT",
@@ -57,14 +57,15 @@
57
57
  "CHANGELOG.md"
58
58
  ],
59
59
  "devDependencies": {
60
- "@types/node": "^22.0.0",
60
+ "@types/node": "^26.6.6",
61
+ "@typescript/typescript6": "^6.0.2",
61
62
  "tsup": "^9.0.0",
62
63
  "tsx": "^4.23.15",
63
- "typescript": "^5.9.3",
64
+ "typescript": "^7.0.2",
64
65
  "vitest": "^4.1.12"
65
66
  },
66
67
  "scripts": {
67
- "build": "tsup src/index.ts src/cli.ts src/git-history.ts src/types.ts src/concurrency.ts src/exclude.ts --format esm --dts",
68
+ "build": "tsup src/index.ts src/cli.ts src/git-history.ts src/types.ts src/concurrency.ts src/exclude.ts --format esm && tsc -p tsconfig.build.json",
68
69
  "dev": "tsx src/index.ts",
69
70
  "generate": "tsx src/cli.ts",
70
71
  "test": "vitest run",