Skip to content

Commit d0dbfbb

Browse files
committed
refactor: update file structure and imports
1 parent a73f371 commit d0dbfbb

33 files changed

Lines changed: 139 additions & 103 deletions

build.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineBuildConfig({
44
entries: [
55
{ input: "src/cli/index", name: "cli" },
66
{ input: "src/api", name: "api" },
7-
{ input: "src/lock", name: "lock" },
7+
{ input: "src/cache/lock", name: "lock" },
88
],
99
declaration: true,
1010
clean: true,

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
"name": "docs-cache",
33
"private": false,
44
"type": "module",
5+
"imports": {
6+
"#cache/*": "./src/cache/*.ts",
7+
"#cli/*": "./src/cli/*.ts",
8+
"#commands/*": "./src/commands/*.ts",
9+
"#core/*": "./src/*.ts",
10+
"#config": "./src/config/index.ts",
11+
"#config/*": "./src/config/*.ts",
12+
"#git/*": "./src/git/*.ts"
13+
},
514
"version": "0.4.3",
615
"packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748",
716
"description": "CLI for deterministic local caching of external documentation for agents and tools",

src/api.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export { parseArgs } from "./cli/parse-args";
2-
export { cleanCache } from "./commands/clean";
3-
export { cleanGitCache } from "./commands/clean-git-cache";
4-
export { initConfig } from "./commands/init";
5-
export { pruneCache } from "./commands/prune";
6-
export { removeSources } from "./commands/remove";
7-
export { printSyncPlan, runSync } from "./commands/sync";
8-
export { verifyCache } from "./commands/verify";
9-
export { loadConfig } from "./config";
10-
export { redactRepoUrl } from "./git/redact";
11-
export { enforceHostAllowlist, parseLsRemote } from "./git/resolve-remote";
12-
export { DEFAULT_LOCK_FILENAME } from "./lock";
13-
export { resolveRepoInput } from "./resolve-repo";
14-
export { applyTargetDir } from "./targets";
1+
export { DEFAULT_LOCK_FILENAME } from "#cache/lock";
2+
export { applyTargetDir } from "#cache/targets";
3+
export { parseArgs } from "#cli/parse-args";
4+
export { cleanCache } from "#commands/clean";
5+
export { cleanGitCache } from "#commands/clean-git-cache";
6+
export { initConfig } from "#commands/init";
7+
export { pruneCache } from "#commands/prune";
8+
export { removeSources } from "#commands/remove";
9+
export { printSyncPlan, runSync } from "#commands/sync";
10+
export { verifyCache } from "#commands/verify";
11+
export { loadConfig } from "#config";
12+
export { redactRepoUrl } from "#git/redact";
13+
export { enforceHostAllowlist, parseLsRemote } from "#git/resolve-remote";
14+
export { resolveRepoInput } from "#git/resolve-repo";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mkdir } from "node:fs/promises";
22

3-
import { getCacheLayout } from "./paths";
3+
import { getCacheLayout } from "#core/paths";
44

55
export const ensureCacheLayout = async (
66
cacheDir: string,
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import os from "node:os";
1414
import path from "node:path";
1515
import { pipeline } from "node:stream/promises";
1616
import fg from "fast-glob";
17-
import { symbols, ui } from "./cli/ui";
18-
import { getErrnoCode } from "./errors";
19-
import { MANIFEST_FILENAME } from "./manifest";
20-
import { getCacheLayout, toPosixPath } from "./paths";
21-
import { assertSafeSourceId } from "./source-id";
17+
import { MANIFEST_FILENAME } from "#cache/manifest";
18+
import { symbols, ui } from "#cli/ui";
19+
import { getErrnoCode } from "#core/errors";
20+
import { getCacheLayout, toPosixPath } from "#core/paths";
21+
import { assertSafeSourceId } from "#core/source-id";
2222

2323
type MaterializeParams = {
2424
sourceId: string;

src/targets.ts renamed to src/cache/targets.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { cp, mkdir, readdir, rm, symlink } from "node:fs/promises";
22
import path from "node:path";
3-
import { getErrnoCode } from "./errors";
4-
import { MANIFEST_FILENAME } from "./manifest";
5-
import { DEFAULT_TOC_FILENAME } from "./paths";
3+
import { MANIFEST_FILENAME } from "#cache/manifest";
4+
import { getErrnoCode } from "#core/errors";
5+
import { DEFAULT_TOC_FILENAME } from "#core/paths";
66

77
type TargetDeps = {
88
cp: typeof cp;

src/toc.ts renamed to src/cache/toc.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { access, readFile, rm, writeFile } from "node:fs/promises";
22
import path from "node:path";
3-
import { symbols, ui } from "./cli/ui";
4-
import type { DocsCacheResolvedSource, TocFormat } from "./config";
5-
import type { DocsCacheLock } from "./lock";
6-
import { DEFAULT_TOC_FILENAME, resolveTargetDir, toPosixPath } from "./paths";
3+
import type { DocsCacheLock } from "#cache/lock";
4+
import { symbols, ui } from "#cli/ui";
5+
import type { DocsCacheResolvedSource, TocFormat } from "#config";
6+
import {
7+
DEFAULT_TOC_FILENAME,
8+
resolveTargetDir,
9+
toPosixPath,
10+
} from "#core/paths";
711

812
type TocEntry = {
913
id: string;

src/cli/exit-code.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*
44
* @see https://nodejs.org/api/process.html#process_exit_codes
55
*/
6-
export enum ExitCode {
7-
Success = 0,
8-
FatalError = 1,
9-
InvalidArgument = 9,
10-
}
6+
export const ExitCode = {
7+
Success: 0,
8+
FatalError: 1,
9+
InvalidArgument: 9,
10+
};
11+
12+
export type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];

0 commit comments

Comments
 (0)