regoof 0.1.0
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/README.md +78 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/bin.js.map +1 -0
- package/dist/declaration-index.d.ts +43 -0
- package/dist/declaration-index.d.ts.map +1 -0
- package/dist/declaration-index.js +326 -0
- package/dist/declaration-index.js.map +1 -0
- package/dist/find.d.ts +17 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +63 -0
- package/dist/find.js.map +1 -0
- package/dist/global-options.d.ts +12 -0
- package/dist/global-options.d.ts.map +1 -0
- package/dist/global-options.js +66 -0
- package/dist/global-options.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +175 -0
- package/dist/index.js.map +1 -0
- package/dist/peek.d.ts +14 -0
- package/dist/peek.d.ts.map +1 -0
- package/dist/peek.js +58 -0
- package/dist/peek.js.map +1 -0
- package/dist/pointer.d.ts +24 -0
- package/dist/pointer.d.ts.map +1 -0
- package/dist/pointer.js +72 -0
- package/dist/pointer.js.map +1 -0
- package/dist/rename.d.ts +18 -0
- package/dist/rename.d.ts.map +1 -0
- package/dist/rename.js +104 -0
- package/dist/rename.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# regoof
|
|
2
|
+
|
|
3
|
+
Regoof is a Bun CLI for discovering named TypeScript declarations before a
|
|
4
|
+
refactor. It loads the closest `tsconfig.json` and recursively follows project
|
|
5
|
+
references.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Find declarations
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
regoof [--project <directory-or-tsconfig>] find <searchTerm> [filePath] [--exact] [--json]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
During development, run the command with Bun:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun run src/bin.ts find User packages/shared-types/src/**/*.ts --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Names match case-insensitively by substring by default. Pass `--exact` for a
|
|
26
|
+
case-sensitive exact-name match. A relative `filePath` is resolved from the
|
|
27
|
+
located project root; it may be a file path or glob. Results include the name,
|
|
28
|
+
root-relative file path, and declaration line. Pass `--includePointers` to add
|
|
29
|
+
a canonical stateless pointer such as `src/rename.ts:21:RenameResult`.
|
|
30
|
+
|
|
31
|
+
Pass `--project` (or `-p`) with a project directory or `tsconfig.json` path to
|
|
32
|
+
override automatic project discovery. This is a CLI-wide option and applies to
|
|
33
|
+
all current and future commands.
|
|
34
|
+
|
|
35
|
+
Regoof stores a local declaration index in the operating system cache directory
|
|
36
|
+
to accelerate subsequent commands. Use `--no-cache` to bypass it once, or
|
|
37
|
+
`--clear-cache` to discard and rebuild the selected project's index.
|
|
38
|
+
|
|
39
|
+
## Rename a declaration
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
regoof rename <pointer> <newName> [--json]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Pointers are self-contained and can be used without first running `find`.
|
|
46
|
+
`SymbolName`, `globPattern:SymbolName`, and
|
|
47
|
+
`globPattern:lineNumber:SymbolName` are supported. Pointer names are exact and
|
|
48
|
+
case-sensitive. If a pointer is ambiguous, Regoof prints canonical choices
|
|
49
|
+
instead of modifying files. `rename` uses ts-morph to update the declaration
|
|
50
|
+
and its references throughout the root project and referenced packages.
|
|
51
|
+
|
|
52
|
+
The declaration index caches plain facts, rather than live ASTs. A rename builds
|
|
53
|
+
a fresh ts-morph project to ensure TypeScript reference resolution is current.
|
|
54
|
+
|
|
55
|
+
## Peek at a declaration
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
regoof peek <pointer> [radius] [--json]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`peek` prints a syntax-highlighted TypeScript window around the declaration
|
|
62
|
+
selected by a pointer. The optional radius is the number of lines on
|
|
63
|
+
either side of the declaration line and defaults to 5; the declaration line is
|
|
64
|
+
marked with `>` and a distinct background.
|
|
65
|
+
|
|
66
|
+
Published versions can be run without a global installation:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx regoof find User --json
|
|
70
|
+
bunx regoof find User --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Checks
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
bun run typecheck
|
|
77
|
+
bun test
|
|
78
|
+
```
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from "@stricli/core";
|
|
3
|
+
import { extractGlobalOptions } from "./global-options.js";
|
|
4
|
+
import { app } from "./index.js";
|
|
5
|
+
try {
|
|
6
|
+
const { cacheMode, commandInputs, projectPath } = extractGlobalOptions(process.argv.slice(2));
|
|
7
|
+
const context = { process, cacheMode, projectPath };
|
|
8
|
+
await run(app, commandInputs, context);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
+
process.stderr.write(`regoof: ${message}\n`);
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAsB,MAAM,YAAY,CAAC;AAErD,IAAI,CAAC;IACH,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9F,MAAM,OAAO,GAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IACnE,MAAM,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type CacheMode = "default" | "bypass" | "clear";
|
|
2
|
+
export type DeclarationRecord = Readonly<{
|
|
3
|
+
contentHash: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
line: number;
|
|
7
|
+
name: string;
|
|
8
|
+
ownerTsConfigPath: string;
|
|
9
|
+
start: number;
|
|
10
|
+
}>;
|
|
11
|
+
export type DeclarationIndexOptions = Readonly<{
|
|
12
|
+
cacheDirectory?: string;
|
|
13
|
+
cacheMode?: CacheMode;
|
|
14
|
+
cwd?: string;
|
|
15
|
+
projectPath?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type ProjectSourceFile = Readonly<{
|
|
18
|
+
filePath: string;
|
|
19
|
+
tsConfigPath: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type DeclarationIndex = Readonly<{
|
|
22
|
+
declarations: readonly DeclarationRecord[];
|
|
23
|
+
rootDirectory: string;
|
|
24
|
+
rootTsConfigPath: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** Finds the closest tsconfig.json at or above a working directory. */
|
|
27
|
+
export declare function resolveProjectRoot(cwd?: string): string;
|
|
28
|
+
/** Resolves an explicit project path or discovers the nearest tsconfig.json. */
|
|
29
|
+
export declare function resolveProjectTsConfig(cwd?: string, projectPath?: string): string;
|
|
30
|
+
/** Resolves a solution tsconfig, project references, and local extends files. */
|
|
31
|
+
export declare function collectTsConfigPaths(rootTsConfigPath: string): readonly string[];
|
|
32
|
+
/** Returns the stable cache location for a project's canonical root tsconfig. */
|
|
33
|
+
export declare function getProjectCachePath(rootTsConfigPath: string, cacheDirectory?: string): string;
|
|
34
|
+
/** Deletes only the snapshot belonging to the selected project. */
|
|
35
|
+
export declare function clearDeclarationIndexCache(options?: Omit<DeclarationIndexOptions, "cacheMode">): void;
|
|
36
|
+
/**
|
|
37
|
+
* Produces a complete, reusable declaration index. Cache entries store facts,
|
|
38
|
+
* never ts-morph nodes, so each command gets immutable plain data.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getDeclarationIndex(options?: DeclarationIndexOptions): DeclarationIndex;
|
|
41
|
+
/** Returns each project source once, paired with the tsconfig that owns it. */
|
|
42
|
+
export declare function getProjectSourceFiles(rootTsConfigPath: string): readonly ProjectSourceFile[];
|
|
43
|
+
//# sourceMappingURL=declaration-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration-index.d.ts","sourceRoot":"","sources":["../src/declaration-index.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAA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E,MAAM,GACvB,SAAS,iBAAiB,EAAE,CAO9B"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import envPaths from "env-paths";
|
|
5
|
+
import { Project, ts } from "ts-morph";
|
|
6
|
+
const CACHE_VERSION = 2;
|
|
7
|
+
/** Finds the closest tsconfig.json at or above a working directory. */
|
|
8
|
+
export function resolveProjectRoot(cwd = process.cwd()) {
|
|
9
|
+
let directory = resolve(cwd);
|
|
10
|
+
while (true) {
|
|
11
|
+
if (existsSync(join(directory, "tsconfig.json"))) {
|
|
12
|
+
return directory;
|
|
13
|
+
}
|
|
14
|
+
const parent = dirname(directory);
|
|
15
|
+
if (parent === directory) {
|
|
16
|
+
throw new Error(`Could not find a tsconfig.json at or above '${cwd}'.`);
|
|
17
|
+
}
|
|
18
|
+
directory = parent;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Resolves an explicit project path or discovers the nearest tsconfig.json. */
|
|
22
|
+
export function resolveProjectTsConfig(cwd = process.cwd(), projectPath) {
|
|
23
|
+
if (projectPath === undefined) {
|
|
24
|
+
return canonicalPath(join(resolveProjectRoot(cwd), "tsconfig.json"));
|
|
25
|
+
}
|
|
26
|
+
const resolvedProjectPath = resolve(cwd, projectPath);
|
|
27
|
+
const tsConfigPath = resolvedProjectPath.endsWith(".json")
|
|
28
|
+
? resolvedProjectPath
|
|
29
|
+
: join(resolvedProjectPath, "tsconfig.json");
|
|
30
|
+
if (!existsSync(tsConfigPath)) {
|
|
31
|
+
throw new Error(`Project tsconfig does not exist: '${tsConfigPath}'.`);
|
|
32
|
+
}
|
|
33
|
+
return canonicalPath(tsConfigPath);
|
|
34
|
+
}
|
|
35
|
+
/** Resolves a solution tsconfig, project references, and local extends files. */
|
|
36
|
+
export function collectTsConfigPaths(rootTsConfigPath) {
|
|
37
|
+
const collected = [];
|
|
38
|
+
const visited = new Set();
|
|
39
|
+
const visit = (inputPath) => {
|
|
40
|
+
const tsConfigPath = resolveTsConfigPath(inputPath);
|
|
41
|
+
if (visited.has(tsConfigPath)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
visited.add(tsConfigPath);
|
|
45
|
+
const parsed = parseTsConfig(tsConfigPath);
|
|
46
|
+
collected.push(tsConfigPath);
|
|
47
|
+
for (const extendedConfigPath of getExtendedConfigPaths(tsConfigPath, parsed.raw)) {
|
|
48
|
+
visit(extendedConfigPath);
|
|
49
|
+
}
|
|
50
|
+
for (const projectReference of parsed.projectReferences ?? []) {
|
|
51
|
+
visit(projectReference.path);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
visit(rootTsConfigPath);
|
|
55
|
+
return collected;
|
|
56
|
+
}
|
|
57
|
+
/** Returns the stable cache location for a project's canonical root tsconfig. */
|
|
58
|
+
export function getProjectCachePath(rootTsConfigPath, cacheDirectory = envPaths("regoof").cache) {
|
|
59
|
+
const cacheKey = hashText(canonicalPath(rootTsConfigPath));
|
|
60
|
+
return join(cacheDirectory, `${cacheKey}.json`);
|
|
61
|
+
}
|
|
62
|
+
/** Deletes only the snapshot belonging to the selected project. */
|
|
63
|
+
export function clearDeclarationIndexCache(options = {}) {
|
|
64
|
+
const rootTsConfigPath = resolveProjectTsConfig(options.cwd, options.projectPath);
|
|
65
|
+
rmSync(getProjectCachePath(rootTsConfigPath, options.cacheDirectory), {
|
|
66
|
+
force: true,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Produces a complete, reusable declaration index. Cache entries store facts,
|
|
71
|
+
* never ts-morph nodes, so each command gets immutable plain data.
|
|
72
|
+
*/
|
|
73
|
+
export function getDeclarationIndex(options = {}) {
|
|
74
|
+
const cacheMode = options.cacheMode ?? "default";
|
|
75
|
+
const rootTsConfigPath = resolveProjectTsConfig(options.cwd, options.projectPath);
|
|
76
|
+
const rootDirectory = dirname(rootTsConfigPath);
|
|
77
|
+
const projectConfigs = getProjectConfigs(rootTsConfigPath);
|
|
78
|
+
const configFingerprint = getConfigFingerprint(rootTsConfigPath);
|
|
79
|
+
const cachePath = getProjectCachePath(rootTsConfigPath, options.cacheDirectory);
|
|
80
|
+
if (cacheMode === "clear") {
|
|
81
|
+
rmSync(cachePath, { force: true });
|
|
82
|
+
}
|
|
83
|
+
const snapshot = cacheMode === "default" ? readSnapshot(cachePath, rootTsConfigPath, configFingerprint) : undefined;
|
|
84
|
+
const nextFiles = {};
|
|
85
|
+
const sourceFiles = new Map();
|
|
86
|
+
for (const projectConfig of projectConfigs) {
|
|
87
|
+
for (const sourceFilePath of projectConfig.filePaths) {
|
|
88
|
+
sourceFiles.set(sourceFilePath, projectConfig.tsConfigPath);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const projects = new Map();
|
|
92
|
+
let changed = snapshot === undefined;
|
|
93
|
+
for (const [sourceFilePath, tsConfigPath] of sourceFiles) {
|
|
94
|
+
const contentHash = hashFile(sourceFilePath);
|
|
95
|
+
const cachedFile = snapshot?.files[sourceFilePath];
|
|
96
|
+
if (cachedFile?.contentHash === contentHash) {
|
|
97
|
+
nextFiles[sourceFilePath] = cachedFile;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
changed = true;
|
|
101
|
+
const project = projects.get(tsConfigPath) ??
|
|
102
|
+
new Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
|
|
103
|
+
projects.set(tsConfigPath, project);
|
|
104
|
+
const sourceFile = project.addSourceFileAtPath(sourceFilePath);
|
|
105
|
+
nextFiles[sourceFilePath] = {
|
|
106
|
+
contentHash,
|
|
107
|
+
declarations: sourceFile.isDeclarationFile() || sourceFile.isFromExternalLibrary()
|
|
108
|
+
? []
|
|
109
|
+
: extractDeclarations(sourceFile),
|
|
110
|
+
};
|
|
111
|
+
sourceFile.forget();
|
|
112
|
+
}
|
|
113
|
+
if (snapshot !== undefined && Object.keys(snapshot.files).length !== sourceFiles.size) {
|
|
114
|
+
changed = true;
|
|
115
|
+
}
|
|
116
|
+
const nextSnapshot = {
|
|
117
|
+
version: CACHE_VERSION,
|
|
118
|
+
rootTsConfigPath,
|
|
119
|
+
configFingerprint,
|
|
120
|
+
files: nextFiles,
|
|
121
|
+
};
|
|
122
|
+
if (cacheMode !== "bypass" && changed) {
|
|
123
|
+
writeSnapshot(cachePath, nextSnapshot);
|
|
124
|
+
}
|
|
125
|
+
const declarations = Object.entries(nextFiles)
|
|
126
|
+
.flatMap(([filePath, cachedFile]) => {
|
|
127
|
+
const ownerTsConfigPath = sourceFiles.get(filePath);
|
|
128
|
+
if (ownerTsConfigPath === undefined) {
|
|
129
|
+
throw new Error(`Missing owning tsconfig for '${filePath}'.`);
|
|
130
|
+
}
|
|
131
|
+
return cachedFile.declarations.map((declaration) => ({
|
|
132
|
+
...declaration,
|
|
133
|
+
contentHash: cachedFile.contentHash,
|
|
134
|
+
filePath,
|
|
135
|
+
ownerTsConfigPath,
|
|
136
|
+
}));
|
|
137
|
+
})
|
|
138
|
+
.sort(compareDeclarations)
|
|
139
|
+
.map((declaration) => Object.freeze(declaration));
|
|
140
|
+
return Object.freeze({
|
|
141
|
+
declarations: Object.freeze(declarations),
|
|
142
|
+
rootDirectory,
|
|
143
|
+
rootTsConfigPath,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** Returns each project source once, paired with the tsconfig that owns it. */
|
|
147
|
+
export function getProjectSourceFiles(rootTsConfigPath) {
|
|
148
|
+
return getProjectConfigs(rootTsConfigPath).flatMap((projectConfig) => projectConfig.filePaths.map((filePath) => ({
|
|
149
|
+
filePath,
|
|
150
|
+
tsConfigPath: projectConfig.tsConfigPath,
|
|
151
|
+
})));
|
|
152
|
+
}
|
|
153
|
+
function getProjectConfigs(rootTsConfigPath) {
|
|
154
|
+
const configPaths = collectProjectReferencePaths(rootTsConfigPath);
|
|
155
|
+
const seenSourceFiles = new Set();
|
|
156
|
+
return configPaths.map((tsConfigPath) => {
|
|
157
|
+
const filePaths = parseTsConfig(tsConfigPath).fileNames
|
|
158
|
+
.map(canonicalPath)
|
|
159
|
+
.filter((filePath) => !filePath.endsWith(".d.ts"))
|
|
160
|
+
.filter((filePath) => {
|
|
161
|
+
if (seenSourceFiles.has(filePath)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
seenSourceFiles.add(filePath);
|
|
165
|
+
return true;
|
|
166
|
+
});
|
|
167
|
+
return { tsConfigPath, filePaths };
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function getConfigFingerprint(rootTsConfigPath) {
|
|
171
|
+
return hashText(collectTsConfigPaths(rootTsConfigPath)
|
|
172
|
+
.map((tsConfigPath) => `${tsConfigPath}\0${hashFile(tsConfigPath)}`)
|
|
173
|
+
.join("\n"));
|
|
174
|
+
}
|
|
175
|
+
function collectProjectReferencePaths(rootTsConfigPath) {
|
|
176
|
+
const collected = [];
|
|
177
|
+
const visited = new Set();
|
|
178
|
+
const visit = (inputPath) => {
|
|
179
|
+
const tsConfigPath = resolveTsConfigPath(inputPath);
|
|
180
|
+
if (visited.has(tsConfigPath)) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
visited.add(tsConfigPath);
|
|
184
|
+
collected.push(tsConfigPath);
|
|
185
|
+
for (const projectReference of parseTsConfig(tsConfigPath).projectReferences ?? []) {
|
|
186
|
+
visit(projectReference.path);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
visit(rootTsConfigPath);
|
|
190
|
+
return collected;
|
|
191
|
+
}
|
|
192
|
+
function getExtendedConfigPaths(tsConfigPath, rawConfig) {
|
|
193
|
+
if (rawConfig === null ||
|
|
194
|
+
typeof rawConfig !== "object" ||
|
|
195
|
+
!("extends" in rawConfig)) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const rawExtends = rawConfig.extends;
|
|
199
|
+
const extendsValues = Array.isArray(rawExtends) ? rawExtends : [rawExtends];
|
|
200
|
+
return extendsValues.flatMap((value) => {
|
|
201
|
+
if (typeof value !== "string") {
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
const candidate = value.endsWith(".json") ? value : `${value}.json`;
|
|
205
|
+
const resolved = resolve(dirname(tsConfigPath), candidate);
|
|
206
|
+
return existsSync(resolved) ? [resolved] : [];
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function readSnapshot(cachePath, rootTsConfigPath, configFingerprint) {
|
|
210
|
+
try {
|
|
211
|
+
const snapshot = JSON.parse(readFileSync(cachePath, "utf8"));
|
|
212
|
+
if (!isValidSnapshot(snapshot, rootTsConfigPath, configFingerprint)) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
return snapshot;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function isValidSnapshot(value, rootTsConfigPath, configFingerprint) {
|
|
222
|
+
return (value !== null &&
|
|
223
|
+
typeof value === "object" &&
|
|
224
|
+
"version" in value &&
|
|
225
|
+
value.version === CACHE_VERSION &&
|
|
226
|
+
"rootTsConfigPath" in value &&
|
|
227
|
+
value.rootTsConfigPath === rootTsConfigPath &&
|
|
228
|
+
"configFingerprint" in value &&
|
|
229
|
+
value.configFingerprint === configFingerprint &&
|
|
230
|
+
"files" in value &&
|
|
231
|
+
value.files !== null &&
|
|
232
|
+
typeof value.files === "object" &&
|
|
233
|
+
Object.values(value.files).every(isValidCachedFile));
|
|
234
|
+
}
|
|
235
|
+
function isValidCachedFile(value) {
|
|
236
|
+
return (value !== null &&
|
|
237
|
+
typeof value === "object" &&
|
|
238
|
+
"contentHash" in value &&
|
|
239
|
+
typeof value.contentHash === "string" &&
|
|
240
|
+
"declarations" in value &&
|
|
241
|
+
Array.isArray(value.declarations) &&
|
|
242
|
+
value.declarations.every((declaration) => declaration !== null &&
|
|
243
|
+
typeof declaration === "object" &&
|
|
244
|
+
"kind" in declaration &&
|
|
245
|
+
typeof declaration.kind === "string" &&
|
|
246
|
+
"line" in declaration &&
|
|
247
|
+
typeof declaration.line === "number" &&
|
|
248
|
+
"name" in declaration &&
|
|
249
|
+
typeof declaration.name === "string" &&
|
|
250
|
+
"start" in declaration &&
|
|
251
|
+
typeof declaration.start === "number"));
|
|
252
|
+
}
|
|
253
|
+
function writeSnapshot(cachePath, snapshot) {
|
|
254
|
+
mkdirSync(dirname(cachePath), { recursive: true });
|
|
255
|
+
const temporaryPath = `${cachePath}.${process.pid}.${Date.now()}.tmp`;
|
|
256
|
+
writeFileSync(temporaryPath, JSON.stringify(snapshot));
|
|
257
|
+
renameSync(temporaryPath, cachePath);
|
|
258
|
+
}
|
|
259
|
+
function extractDeclarations(sourceFile) {
|
|
260
|
+
const declarations = [];
|
|
261
|
+
for (const node of sourceFile.getDescendants()) {
|
|
262
|
+
if (!isNamedDeclaration(node)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const name = node.getName();
|
|
266
|
+
if (name === undefined) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
declarations.push({
|
|
270
|
+
name,
|
|
271
|
+
kind: node.getKindName(),
|
|
272
|
+
start: node.getStart(),
|
|
273
|
+
line: node.getStartLineNumber(),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return declarations;
|
|
277
|
+
}
|
|
278
|
+
function resolveTsConfigPath(inputPath) {
|
|
279
|
+
const absolutePath = resolve(inputPath);
|
|
280
|
+
const tsConfigPath = absolutePath.endsWith(".json")
|
|
281
|
+
? absolutePath
|
|
282
|
+
: join(absolutePath, "tsconfig.json");
|
|
283
|
+
if (!existsSync(tsConfigPath)) {
|
|
284
|
+
throw new Error(`Referenced tsconfig does not exist: '${tsConfigPath}'.`);
|
|
285
|
+
}
|
|
286
|
+
return canonicalPath(tsConfigPath);
|
|
287
|
+
}
|
|
288
|
+
function parseTsConfig(tsConfigPath) {
|
|
289
|
+
const readResult = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
290
|
+
if (readResult.error !== undefined) {
|
|
291
|
+
throw new Error(`Could not read '${tsConfigPath}': ${formatDiagnostic(readResult.error)}`);
|
|
292
|
+
}
|
|
293
|
+
const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys, dirname(tsConfigPath), undefined, tsConfigPath);
|
|
294
|
+
const errors = parsed.errors.filter((error) => error.code !== 18003);
|
|
295
|
+
if (errors.length > 0) {
|
|
296
|
+
throw new Error(`Could not parse '${tsConfigPath}': ${errors
|
|
297
|
+
.map(formatDiagnostic)
|
|
298
|
+
.join("\n")}`);
|
|
299
|
+
}
|
|
300
|
+
return parsed;
|
|
301
|
+
}
|
|
302
|
+
function canonicalPath(filePath) {
|
|
303
|
+
return realpathSync(resolve(filePath));
|
|
304
|
+
}
|
|
305
|
+
function hashFile(filePath) {
|
|
306
|
+
return createHash("sha256").update(readFileSync(filePath)).digest("hex");
|
|
307
|
+
}
|
|
308
|
+
function hashText(value) {
|
|
309
|
+
return createHash("sha256").update(value).digest("hex");
|
|
310
|
+
}
|
|
311
|
+
function formatDiagnostic(diagnostic) {
|
|
312
|
+
return ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
313
|
+
}
|
|
314
|
+
function isNamedDeclaration(node) {
|
|
315
|
+
const isDeclaration = ts.isDeclaration;
|
|
316
|
+
return (isDeclaration(node.compilerNode) &&
|
|
317
|
+
"getName" in node &&
|
|
318
|
+
typeof node.getName === "function");
|
|
319
|
+
}
|
|
320
|
+
function compareDeclarations(left, right) {
|
|
321
|
+
return (left.filePath.localeCompare(right.filePath) ||
|
|
322
|
+
left.start - right.start ||
|
|
323
|
+
left.name.localeCompare(right.name) ||
|
|
324
|
+
left.kind.localeCompare(right.kind));
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=declaration-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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A8B,CAAC,OAAO,KAAK,UAAU,CAC9D,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAuB,EAAE,KAAwB;IAC5E,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;QACxB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CACpC,CAAC;AACJ,CAAC"}
|
package/dist/find.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type DeclarationIndexOptions } from "./declaration-index.js";
|
|
2
|
+
export { collectTsConfigPaths, getProjectCachePath, resolveProjectRoot, resolveProjectTsConfig, } from "./declaration-index.js";
|
|
3
|
+
export type { CacheMode, DeclarationIndex, DeclarationRecord } from "./declaration-index.js";
|
|
4
|
+
export type FindResult = Readonly<{
|
|
5
|
+
filePath: string;
|
|
6
|
+
line: number;
|
|
7
|
+
name: string;
|
|
8
|
+
pointer?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type FindOptions = DeclarationIndexOptions & Readonly<{
|
|
11
|
+
exact?: boolean;
|
|
12
|
+
filePath?: string;
|
|
13
|
+
includePointers?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/** Queries the reusable declaration index for matching names and file paths. */
|
|
16
|
+
export declare function findDeclarations(searchTerm: string, options?: FindOptions): readonly FindResult[];
|
|
17
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE7F,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAC/C,QAAQ,CAAC;IACP,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC,CAAC;AAEL,gFAAgF;AAChF,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,WAAgB,GACxB,SAAS,UAAU,EAAE,CA+BvB"}
|
package/dist/find.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
import { minimatch } from "minimatch";
|
|
4
|
+
import { getDeclarationIndex, } from "./declaration-index.js";
|
|
5
|
+
import { createCanonicalPointer } from "./pointer.js";
|
|
6
|
+
export { collectTsConfigPaths, getProjectCachePath, resolveProjectRoot, resolveProjectTsConfig, } from "./declaration-index.js";
|
|
7
|
+
/** Queries the reusable declaration index for matching names and file paths. */
|
|
8
|
+
export function findDeclarations(searchTerm, options = {}) {
|
|
9
|
+
const index = getDeclarationIndex(options);
|
|
10
|
+
const normalizedSearchTerm = searchTerm.toLocaleLowerCase();
|
|
11
|
+
const filePattern = getFilePattern(index.rootDirectory, options.filePath);
|
|
12
|
+
return index.declarations
|
|
13
|
+
.flatMap((declaration) => {
|
|
14
|
+
if (!matchesName(declaration.name, searchTerm, normalizedSearchTerm, options.exact === true) ||
|
|
15
|
+
(filePattern !== undefined && !minimatch(declaration.filePath, filePattern))) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const filePath = relative(index.rootDirectory, declaration.filePath);
|
|
19
|
+
return [
|
|
20
|
+
Object.freeze({
|
|
21
|
+
name: declaration.name,
|
|
22
|
+
filePath,
|
|
23
|
+
line: declaration.line,
|
|
24
|
+
...(options.includePointers === true
|
|
25
|
+
? { pointer: createCanonicalPointer(filePath, declaration) }
|
|
26
|
+
: {}),
|
|
27
|
+
}),
|
|
28
|
+
];
|
|
29
|
+
})
|
|
30
|
+
.sort(compareResults);
|
|
31
|
+
}
|
|
32
|
+
function getFilePattern(rootDirectory, filePath) {
|
|
33
|
+
if (filePath?.includes("\0")) {
|
|
34
|
+
throw new Error("filePath must not contain a null byte.");
|
|
35
|
+
}
|
|
36
|
+
if (filePath === undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const pattern = isAbsolute(filePath) ? filePath : resolve(rootDirectory, filePath);
|
|
40
|
+
return canonicalizePattern(pattern);
|
|
41
|
+
}
|
|
42
|
+
function canonicalizePattern(pattern) {
|
|
43
|
+
const firstGlob = pattern.search(/[!*?{[]/);
|
|
44
|
+
if (firstGlob === -1) {
|
|
45
|
+
return existsSync(pattern) ? realpathSync(pattern) : pattern;
|
|
46
|
+
}
|
|
47
|
+
const staticDirectory = dirname(pattern.slice(0, firstGlob));
|
|
48
|
+
if (!existsSync(staticDirectory)) {
|
|
49
|
+
return pattern;
|
|
50
|
+
}
|
|
51
|
+
return `${realpathSync(staticDirectory)}${pattern.slice(staticDirectory.length)}`;
|
|
52
|
+
}
|
|
53
|
+
function matchesName(name, searchTerm, normalizedSearchTerm, exact) {
|
|
54
|
+
return exact
|
|
55
|
+
? name === searchTerm
|
|
56
|
+
: name.toLocaleLowerCase().includes(normalizedSearchTerm);
|
|
57
|
+
}
|
|
58
|
+
function compareResults(left, right) {
|
|
59
|
+
return (left.filePath.localeCompare(right.filePath) ||
|
|
60
|
+
left.line - right.line ||
|
|
61
|
+
left.name.localeCompare(right.name));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,mBAAmB,GAGpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAiBhC,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAC9B,UAAkB,EAClB,OAAO,GAAgB,EAAE;IAEzB,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,oBAAoB,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAC;IAC5D,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1E,OAAO,KAAK,CAAC,YAAY;SACtB,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACvB,IACE,CAAC,WAAW,CACV,WAAW,CAAC,IAAI,EAChB,UAAU,EACV,oBAAoB,EACpB,OAAO,CAAC,KAAK,KAAK,IAAI,CACvB;YACD,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,EAC5E,CAAC;YACD,OAAO,EAAE,CAAC;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OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7D,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;AACpF,CAAC;AAED,SAAS,WAAW,CAClB,IAAY,EACZ,UAAkB,EAClB,oBAA4B,EAC5B,KAAc;IAEd,OAAO,KAAK;QACV,CAAC,CAAC,IAAI,KAAK,UAAU;QACrB,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,cAAc,CAAC,IAAgB,EAAE,KAAiB;IACzD,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type GlobalOptions = Readonly<{
|
|
2
|
+
cacheMode: "default" | "bypass" | "clear";
|
|
3
|
+
commandInputs: readonly string[];
|
|
4
|
+
projectPath?: string;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Extracts options that apply to every Regoof command before Stricli routes the
|
|
8
|
+
* remaining inputs. Add future CLI-wide options here instead of duplicating
|
|
9
|
+
* them in every command definition.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractGlobalOptions(inputs: readonly string[]): GlobalOptions;
|
|
12
|
+
//# sourceMappingURL=global-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-options.d.ts","sourceRoot":"","sources":["../src/global-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,aAAa,CAmEf"}
|