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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts options that apply to every Regoof command before Stricli routes the
|
|
3
|
+
* remaining inputs. Add future CLI-wide options here instead of duplicating
|
|
4
|
+
* them in every command definition.
|
|
5
|
+
*/
|
|
6
|
+
export function extractGlobalOptions(inputs) {
|
|
7
|
+
const commandInputs = [];
|
|
8
|
+
let cacheMode = "default";
|
|
9
|
+
let projectPath;
|
|
10
|
+
let argumentsEscaped = false;
|
|
11
|
+
for (let index = 0; index < inputs.length; index += 1) {
|
|
12
|
+
const input = inputs[index];
|
|
13
|
+
if (input === undefined) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (argumentsEscaped) {
|
|
17
|
+
commandInputs.push(input);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (input === "--") {
|
|
21
|
+
argumentsEscaped = true;
|
|
22
|
+
commandInputs.push(input);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (input === "--project" || input === "-p") {
|
|
26
|
+
const value = inputs[index + 1];
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
throw new Error(`${input} requires a tsconfig path or project directory.`);
|
|
29
|
+
}
|
|
30
|
+
if (projectPath !== undefined) {
|
|
31
|
+
throw new Error("--project may only be provided once.");
|
|
32
|
+
}
|
|
33
|
+
projectPath = value;
|
|
34
|
+
index += 1;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (input.startsWith("--project=")) {
|
|
38
|
+
const value = input.slice("--project=".length);
|
|
39
|
+
if (value.length === 0) {
|
|
40
|
+
throw new Error("--project requires a tsconfig path or project directory.");
|
|
41
|
+
}
|
|
42
|
+
if (projectPath !== undefined) {
|
|
43
|
+
throw new Error("--project may only be provided once.");
|
|
44
|
+
}
|
|
45
|
+
projectPath = value;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (input === "--no-cache") {
|
|
49
|
+
if (cacheMode === "clear") {
|
|
50
|
+
throw new Error("--no-cache cannot be combined with --clear-cache.");
|
|
51
|
+
}
|
|
52
|
+
cacheMode = "bypass";
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (input === "--clear-cache") {
|
|
56
|
+
if (cacheMode === "bypass") {
|
|
57
|
+
throw new Error("--clear-cache cannot be combined with --no-cache.");
|
|
58
|
+
}
|
|
59
|
+
cacheMode = "clear";
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
commandInputs.push(input);
|
|
63
|
+
}
|
|
64
|
+
return { cacheMode, commandInputs, projectPath };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=global-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-options.js","sourceRoot":"","sources":["../src/global-options.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB;IAEzB,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,SAAS,GAA+B,SAAS,CAAC;IACtD,IAAI,WAA+B,CAAC;IACpC,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,IAAI,gBAAgB,EAAE,CAAC;YACrB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,gBAAgB,GAAG,IAAI,CAAC;YACxB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,iDAAiD,CAAC,CAAC;YAC7E,CAAC;YACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YAC1D,CAAC;YACD,WAAW,GAAG,KAAK,CAAC;YACpB,KAAK,IAAI,CAAC,CAAC;YACX,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAC9E,CAAC;YACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YAC1D,CAAC;YACD,WAAW,GAAG,KAAK,CAAC;YACpB,SAAS;QACX,CAAC;QAED,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YAC3B,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACvE,CAAC;YACD,SAAS,GAAG,QAAQ,CAAC;YACrB,SAAS;QACX,CAAC;QAED,IAAI,KAAK,KAAK,eAAe,EAAE,CAAC;YAC9B,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACvE,CAAC;YACD,SAAS,GAAG,OAAO,CAAC;YACpB,SAAS;QACX,CAAC;QAED,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;AACnD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { type CommandContext } from "@stricli/core";
|
|
3
|
+
import { type CacheMode } from "./find.js";
|
|
4
|
+
export type RegoofContext = CommandContext & Readonly<{
|
|
5
|
+
cacheMode: CacheMode;
|
|
6
|
+
projectPath?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const app: import("@stricli/core").Application<RegoofContext>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,aAAa,GAAG,cAAc,GACxC,QAAQ,CAAC;IACP,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAmKL,eAAO,MAAM,GAAG,oDAsBf,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { buildApplication, buildCommand, buildRouteMap, help, } from "@stricli/core";
|
|
3
|
+
import { findDeclarations, } from "./find.js";
|
|
4
|
+
import { peekSymbol } from "./peek.js";
|
|
5
|
+
import { isPointerAmbiguity, renameSymbol } from "./rename.js";
|
|
6
|
+
const findCommand = buildCommand({
|
|
7
|
+
docs: {
|
|
8
|
+
brief: "Find named TypeScript declarations in a project.",
|
|
9
|
+
},
|
|
10
|
+
parameters: {
|
|
11
|
+
flags: {
|
|
12
|
+
exact: {
|
|
13
|
+
kind: "boolean",
|
|
14
|
+
brief: "Match the declaration name exactly and case-sensitively.",
|
|
15
|
+
},
|
|
16
|
+
includePointers: {
|
|
17
|
+
kind: "boolean",
|
|
18
|
+
brief: "Include canonical stateless pointers in the results.",
|
|
19
|
+
},
|
|
20
|
+
json: {
|
|
21
|
+
kind: "boolean",
|
|
22
|
+
brief: "Print the matching declarations as JSON.",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
positional: {
|
|
26
|
+
kind: "tuple",
|
|
27
|
+
parameters: [
|
|
28
|
+
{
|
|
29
|
+
brief: "Case-insensitive declaration-name search term.",
|
|
30
|
+
placeholder: "searchTerm",
|
|
31
|
+
parse: (input) => input,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
brief: "Optional project-root-relative or absolute file path/glob.",
|
|
35
|
+
placeholder: "filePath",
|
|
36
|
+
optional: true,
|
|
37
|
+
parse: (input) => input,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
func(flags, searchTerm, filePath) {
|
|
43
|
+
try {
|
|
44
|
+
const results = findDeclarations(searchTerm, {
|
|
45
|
+
cacheMode: this.cacheMode,
|
|
46
|
+
exact: flags.exact,
|
|
47
|
+
filePath,
|
|
48
|
+
includePointers: flags.includePointers,
|
|
49
|
+
projectPath: this.projectPath,
|
|
50
|
+
});
|
|
51
|
+
writeStructuredResult(this, results, flags.json);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const renameCommand = buildCommand({
|
|
59
|
+
docs: {
|
|
60
|
+
brief: "Rename a declaration selected by a stateless project pointer.",
|
|
61
|
+
},
|
|
62
|
+
parameters: {
|
|
63
|
+
flags: {
|
|
64
|
+
json: {
|
|
65
|
+
kind: "boolean",
|
|
66
|
+
brief: "Print the result or pointer candidates as JSON.",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
positional: {
|
|
70
|
+
kind: "tuple",
|
|
71
|
+
parameters: [
|
|
72
|
+
{
|
|
73
|
+
brief: "Project-relative symbol pointer.",
|
|
74
|
+
placeholder: "pointer",
|
|
75
|
+
parse: (input) => input,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
brief: "New TypeScript identifier name.",
|
|
79
|
+
placeholder: "newName",
|
|
80
|
+
parse: (input) => input,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
func(flags, pointer, newName) {
|
|
86
|
+
try {
|
|
87
|
+
const result = renameSymbol(pointer, newName, {
|
|
88
|
+
cacheMode: this.cacheMode,
|
|
89
|
+
projectPath: this.projectPath,
|
|
90
|
+
});
|
|
91
|
+
writeStructuredResult(this, isPointerAmbiguity(result) ? result.candidates : result, flags.json);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const peekCommand = buildCommand({
|
|
99
|
+
docs: {
|
|
100
|
+
brief: "Print syntax-highlighted source surrounding a project pointer.",
|
|
101
|
+
},
|
|
102
|
+
parameters: {
|
|
103
|
+
flags: {
|
|
104
|
+
json: {
|
|
105
|
+
kind: "boolean",
|
|
106
|
+
brief: "Print the result or pointer candidates as JSON.",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
positional: {
|
|
110
|
+
kind: "tuple",
|
|
111
|
+
parameters: [
|
|
112
|
+
{
|
|
113
|
+
brief: "Project-relative symbol pointer.",
|
|
114
|
+
placeholder: "pointer",
|
|
115
|
+
parse: (input) => input,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
brief: "Number of surrounding lines to print (default: 5).",
|
|
119
|
+
placeholder: "radius",
|
|
120
|
+
optional: true,
|
|
121
|
+
parse: (input) => {
|
|
122
|
+
const radius = Number(input);
|
|
123
|
+
if (!Number.isSafeInteger(radius) || radius < 0) {
|
|
124
|
+
throw new Error("radius must be a non-negative integer.");
|
|
125
|
+
}
|
|
126
|
+
return radius;
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
async func(flags, pointer, radius) {
|
|
133
|
+
try {
|
|
134
|
+
const result = await peekSymbol(pointer, radius, {
|
|
135
|
+
cacheMode: this.cacheMode,
|
|
136
|
+
projectPath: this.projectPath,
|
|
137
|
+
});
|
|
138
|
+
if (isPointerAmbiguity(result) || flags.json) {
|
|
139
|
+
writeStructuredResult(this, isPointerAmbiguity(result) ? result.candidates : result, flags.json);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.process.stdout.write(`${result.output}\n`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
export const app = buildApplication(buildRouteMap({
|
|
151
|
+
routes: { find: findCommand, peek: peekCommand, rename: renameCommand },
|
|
152
|
+
docs: {
|
|
153
|
+
brief: "TypeScript project refactoring tools.",
|
|
154
|
+
fullDescription: "Use --project <directory-or-tsconfig> (or -p) to select a project. Use --no-cache to bypass the local find index or --clear-cache to rebuild it.",
|
|
155
|
+
},
|
|
156
|
+
}), {
|
|
157
|
+
name: "regoof",
|
|
158
|
+
}, {
|
|
159
|
+
help: help({
|
|
160
|
+
brief: "Print help information and exit.",
|
|
161
|
+
formatting: {
|
|
162
|
+
caseStyle: "original",
|
|
163
|
+
onlyRequiredInUsageLine: false,
|
|
164
|
+
useAliasInUsageLine: false,
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
});
|
|
168
|
+
function writeStructuredResult(context, value, json) {
|
|
169
|
+
if (json) {
|
|
170
|
+
context.process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
console.table(Array.isArray(value) ? value : [value]);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,IAAI,GAEL,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAA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 @@
|
|
|
1
|
+
import type { DeclarationIndexOptions } from "./declaration-index.js";
|
|
2
|
+
import { type PointerAmbiguity } from "./rename.js";
|
|
3
|
+
export type PeekOptions = DeclarationIndexOptions;
|
|
4
|
+
export type PeekResult = Readonly<{
|
|
5
|
+
endLine: number;
|
|
6
|
+
filePath: string;
|
|
7
|
+
line: number;
|
|
8
|
+
output: string;
|
|
9
|
+
pointer: string;
|
|
10
|
+
startLine: number;
|
|
11
|
+
}>;
|
|
12
|
+
/** Renders a syntax-highlighted source window around a stateless project pointer. */
|
|
13
|
+
export declare function peekSymbol(pointer: string, radius?: number, options?: PeekOptions): Promise<PeekResult | PointerAmbiguity>;
|
|
14
|
+
//# sourceMappingURL=peek.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peek.d.ts","sourceRoot":"","sources":["../src/peek.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAqB,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAMrB,MAAM,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,qFAAqF;AACrF,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,SAAiB,EACvB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,gBAAgB,CAAC,CAsCxC"}
|
package/dist/peek.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, relative } from "node:path";
|
|
4
|
+
import { highlightANSI } from "@speed-highlight/core";
|
|
5
|
+
import theme from "@speed-highlight/core/themes/default.js";
|
|
6
|
+
import { isPointerAmbiguity, resolveSinglePointer, } from "./rename.js";
|
|
7
|
+
const DEFAULT_RADIUS = 5;
|
|
8
|
+
const TARGET_LINE_BACKGROUND = "\u001B[48;5;236m";
|
|
9
|
+
const RESET = "\u001B[0m";
|
|
10
|
+
/** Renders a syntax-highlighted source window around a stateless project pointer. */
|
|
11
|
+
export async function peekSymbol(pointer, radius = DEFAULT_RADIUS, options = {}) {
|
|
12
|
+
if (!Number.isSafeInteger(radius) || radius < 0) {
|
|
13
|
+
throw new Error("radius must be a non-negative integer.");
|
|
14
|
+
}
|
|
15
|
+
const resolution = resolveSinglePointer(pointer, options);
|
|
16
|
+
if (isPointerAmbiguity(resolution)) {
|
|
17
|
+
return resolution;
|
|
18
|
+
}
|
|
19
|
+
const source = readCurrentSource(resolution.declaration);
|
|
20
|
+
const lines = source.split(/\r\n|\r|\n/);
|
|
21
|
+
const line = resolution.declaration.line;
|
|
22
|
+
const startLine = Math.max(1, line - radius);
|
|
23
|
+
const endLine = Math.min(lines.length, line + radius);
|
|
24
|
+
const snippet = lines.slice(startLine - 1, endLine).join("\n");
|
|
25
|
+
const highlightedLines = (await highlightANSI(snippet, "ts", theme)).split("\n");
|
|
26
|
+
const lineNumberWidth = String(endLine).length;
|
|
27
|
+
const filePath = relative(dirname(resolution.rootTsConfigPath), resolution.declaration.filePath);
|
|
28
|
+
const renderedLines = highlightedLines.map((highlightedLine, index) => {
|
|
29
|
+
const sourceLine = startLine + index;
|
|
30
|
+
const isTarget = sourceLine === line;
|
|
31
|
+
const marker = isTarget ? "\u001B[1;33m>\u001B[0m" : " ";
|
|
32
|
+
const gutter = `${marker} ${String(sourceLine).padStart(lineNumberWidth)} | `;
|
|
33
|
+
return `${gutter}${isTarget ? highlightTargetLine(highlightedLine) : highlightedLine}`;
|
|
34
|
+
});
|
|
35
|
+
return Object.freeze({
|
|
36
|
+
pointer: resolution.pointer,
|
|
37
|
+
filePath,
|
|
38
|
+
line,
|
|
39
|
+
startLine,
|
|
40
|
+
endLine,
|
|
41
|
+
output: `${filePath}:${line}\n${renderedLines.join("\n")}`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function readCurrentSource(declaration) {
|
|
45
|
+
if (!existsSync(declaration.filePath)) {
|
|
46
|
+
throw new Error("The file recorded for this declaration no longer exists.");
|
|
47
|
+
}
|
|
48
|
+
const source = readFileSync(declaration.filePath, "utf8");
|
|
49
|
+
const contentHash = createHash("sha256").update(source).digest("hex");
|
|
50
|
+
if (contentHash !== declaration.contentHash) {
|
|
51
|
+
throw new Error("The declaration file changed while resolving its pointer. Try again.");
|
|
52
|
+
}
|
|
53
|
+
return source;
|
|
54
|
+
}
|
|
55
|
+
function highlightTargetLine(highlightedLine) {
|
|
56
|
+
return `${TARGET_LINE_BACKGROUND}${highlightedLine.replaceAll(RESET, `${RESET}${TARGET_LINE_BACKGROUND}`)}${RESET}`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=peek.js.map
|
package/dist/peek.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peek.js","sourceRoot":"","sources":["../src/peek.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,MAAM,yCAAyC,CAAC;AAE5D,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,aAAa,CAAC;AAErB,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AACl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QAC5C,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,eAAuB;IAClD,OAAO,GAAG,sBAAsB,GAAG,eAAe,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,sBAAsB,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC;AACtH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DeclarationIndexOptions, type DeclarationRecord } from "./declaration-index.js";
|
|
2
|
+
export type ParsedPointer = Readonly<{
|
|
3
|
+
filePattern?: string;
|
|
4
|
+
line?: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type PointerCandidate = Readonly<{
|
|
8
|
+
filePath: string;
|
|
9
|
+
line: number;
|
|
10
|
+
name: string;
|
|
11
|
+
pointer: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type ResolvedPointer = PointerCandidate & Readonly<{
|
|
14
|
+
declaration: DeclarationRecord;
|
|
15
|
+
rootTsConfigPath: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Parses a self-contained pointer into its optional file and line selectors. */
|
|
18
|
+
export declare function parsePointer(pointer: string): ParsedPointer;
|
|
19
|
+
/** Resolves a pointer against the current project declaration index. */
|
|
20
|
+
export declare function resolvePointer(pointer: string, options?: DeclarationIndexOptions): readonly ResolvedPointer[];
|
|
21
|
+
/** Creates an unambiguous, project-root-relative pointer for a declaration. */
|
|
22
|
+
export declare function createCanonicalPointer(filePath: string, declaration: Pick<DeclarationRecord, "line" | "name">): string;
|
|
23
|
+
export declare function toPointerCandidate(candidate: ResolvedPointer): PointerCandidate;
|
|
24
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../src/pointer.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAC5C,QAAQ,CAAC;IACP,WAAW,EAAE,iBAAiB,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC,CAAC;AAEL,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CA6B3D;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,SAAS,eAAe,EAAE,CA0B5B;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAAC,GACpD,MAAM,CAER;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,eAAe,GAAG,gBAAgB,CAG/E"}
|
package/dist/pointer.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { minimatch } from "minimatch";
|
|
3
|
+
import { getDeclarationIndex, } from "./declaration-index.js";
|
|
4
|
+
/** Parses a self-contained pointer into its optional file and line selectors. */
|
|
5
|
+
export function parsePointer(pointer) {
|
|
6
|
+
if (pointer.length === 0 || pointer.includes("\0")) {
|
|
7
|
+
throw new Error("pointer must contain a symbol name and no null bytes.");
|
|
8
|
+
}
|
|
9
|
+
const nameSeparator = pointer.lastIndexOf(":");
|
|
10
|
+
if (nameSeparator === -1) {
|
|
11
|
+
return { name: pointer };
|
|
12
|
+
}
|
|
13
|
+
const name = pointer.slice(nameSeparator + 1);
|
|
14
|
+
const prefix = pointer.slice(0, nameSeparator);
|
|
15
|
+
if (name.length === 0 || prefix.length === 0) {
|
|
16
|
+
throw new Error("pointer must use SymbolName, globPattern:SymbolName, or globPattern:line:SymbolName.");
|
|
17
|
+
}
|
|
18
|
+
const lineSeparator = prefix.lastIndexOf(":");
|
|
19
|
+
if (lineSeparator === -1) {
|
|
20
|
+
return { filePattern: prefix, name };
|
|
21
|
+
}
|
|
22
|
+
const possibleLine = prefix.slice(lineSeparator + 1);
|
|
23
|
+
if (!/^\d+$/.test(possibleLine)) {
|
|
24
|
+
return { filePattern: prefix, name };
|
|
25
|
+
}
|
|
26
|
+
const line = Number(possibleLine);
|
|
27
|
+
const filePattern = prefix.slice(0, lineSeparator);
|
|
28
|
+
if (!Number.isSafeInteger(line) || line < 1 || filePattern.length === 0) {
|
|
29
|
+
throw new Error("pointer line numbers must be positive integers.");
|
|
30
|
+
}
|
|
31
|
+
return { filePattern, line, name };
|
|
32
|
+
}
|
|
33
|
+
/** Resolves a pointer against the current project declaration index. */
|
|
34
|
+
export function resolvePointer(pointer, options = {}) {
|
|
35
|
+
const parsed = parsePointer(pointer);
|
|
36
|
+
const index = getDeclarationIndex(options);
|
|
37
|
+
return index.declarations
|
|
38
|
+
.flatMap((declaration) => {
|
|
39
|
+
const filePath = relative(index.rootDirectory, declaration.filePath);
|
|
40
|
+
if (declaration.name !== parsed.name ||
|
|
41
|
+
(parsed.line !== undefined && declaration.line !== parsed.line) ||
|
|
42
|
+
(parsed.filePattern !== undefined && !minimatch(filePath, parsed.filePattern))) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return [
|
|
46
|
+
Object.freeze({
|
|
47
|
+
declaration,
|
|
48
|
+
rootTsConfigPath: index.rootTsConfigPath,
|
|
49
|
+
filePath,
|
|
50
|
+
line: declaration.line,
|
|
51
|
+
name: declaration.name,
|
|
52
|
+
pointer: createCanonicalPointer(filePath, declaration),
|
|
53
|
+
}),
|
|
54
|
+
];
|
|
55
|
+
})
|
|
56
|
+
.sort(compareCandidates);
|
|
57
|
+
}
|
|
58
|
+
/** Creates an unambiguous, project-root-relative pointer for a declaration. */
|
|
59
|
+
export function createCanonicalPointer(filePath, declaration) {
|
|
60
|
+
return `${filePath}:${declaration.line}:${declaration.name}`;
|
|
61
|
+
}
|
|
62
|
+
export function toPointerCandidate(candidate) {
|
|
63
|
+
const { declaration: _declaration, rootTsConfigPath: _rootTsConfigPath, ...result } = candidate;
|
|
64
|
+
return Object.freeze(result);
|
|
65
|
+
}
|
|
66
|
+
function compareCandidates(left, right) {
|
|
67
|
+
return (left.filePath.localeCompare(right.filePath) ||
|
|
68
|
+
left.declaration.start - right.declaration.start ||
|
|
69
|
+
left.name.localeCompare(right.name) ||
|
|
70
|
+
left.declaration.kind.localeCompare(right.declaration.kind));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sourceRoot":"","sources":["../src/pointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,mBAAmB,GAGpB,MAAM,wBAAwB,CAAC;AAqBhC,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,aAAa,GAA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,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAChG,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAqB,EAAE,KAAsB;IACtE,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK;QAChD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAC5D,CAAC;AACJ,CAAC"}
|
package/dist/rename.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DeclarationIndexOptions } from "./declaration-index.js";
|
|
2
|
+
import { type PointerCandidate, type ResolvedPointer } from "./pointer.js";
|
|
3
|
+
export type RenameOptions = DeclarationIndexOptions;
|
|
4
|
+
export type RenameResult = Readonly<{
|
|
5
|
+
filesChanged: number;
|
|
6
|
+
newName: string;
|
|
7
|
+
oldName: string;
|
|
8
|
+
referencesRenamed: number;
|
|
9
|
+
pointer: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type PointerAmbiguity = Readonly<{
|
|
12
|
+
candidates: readonly PointerCandidate[];
|
|
13
|
+
}>;
|
|
14
|
+
export declare function isPointerAmbiguity(result: unknown): result is PointerAmbiguity;
|
|
15
|
+
/** Renames the declaration selected by a stateless project pointer. */
|
|
16
|
+
export declare function renameSymbol(pointer: string, newName: string, options?: RenameOptions): RenameResult | PointerAmbiguity;
|
|
17
|
+
export declare function resolveSinglePointer(pointer: string, options?: DeclarationIndexOptions): ResolvedPointer | PointerAmbiguity;
|
|
18
|
+
//# sourceMappingURL=rename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../src/rename.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,uBAAuB,EAE7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzC,CAAC,CAAC;AAEH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,gBAAgB,CAM9E;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAkB,GAC1B,YAAY,GAAG,gBAAgB,CAoDjC;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,eAAe,GAAG,gBAAgB,CAWpC"}
|
package/dist/rename.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { Project, Node, ts } from "ts-morph";
|
|
4
|
+
import { clearDeclarationIndexCache, getProjectSourceFiles, } from "./declaration-index.js";
|
|
5
|
+
import { resolvePointer, toPointerCandidate, } from "./pointer.js";
|
|
6
|
+
export function isPointerAmbiguity(result) {
|
|
7
|
+
return (result !== null &&
|
|
8
|
+
typeof result === "object" &&
|
|
9
|
+
"candidates" in result);
|
|
10
|
+
}
|
|
11
|
+
/** Renames the declaration selected by a stateless project pointer. */
|
|
12
|
+
export function renameSymbol(pointer, newName, options = {}) {
|
|
13
|
+
if (!isTypeScriptIdentifier(newName)) {
|
|
14
|
+
throw new Error(`'${newName}' is not a valid TypeScript identifier.`);
|
|
15
|
+
}
|
|
16
|
+
const resolution = resolveSinglePointer(pointer, options);
|
|
17
|
+
if (isPointerAmbiguity(resolution)) {
|
|
18
|
+
return resolution;
|
|
19
|
+
}
|
|
20
|
+
const { declaration } = resolution;
|
|
21
|
+
ensureDeclarationIsCurrent(declaration);
|
|
22
|
+
const project = new Project({
|
|
23
|
+
tsConfigFilePath: declaration.ownerTsConfigPath,
|
|
24
|
+
skipAddingFilesFromTsConfig: true,
|
|
25
|
+
});
|
|
26
|
+
for (const sourceFile of getProjectSourceFiles(resolution.rootTsConfigPath)) {
|
|
27
|
+
project.addSourceFileAtPath(sourceFile.filePath);
|
|
28
|
+
}
|
|
29
|
+
const target = findTarget(project, declaration);
|
|
30
|
+
if (target === undefined) {
|
|
31
|
+
throw new Error(`Pointer '${pointer}' no longer identifies the recorded declaration.`);
|
|
32
|
+
}
|
|
33
|
+
if (!Node.isRenameable(target)) {
|
|
34
|
+
throw new Error(`The declaration for pointer '${pointer}' cannot be renamed.`);
|
|
35
|
+
}
|
|
36
|
+
const referencesRenamed = project
|
|
37
|
+
.getLanguageService()
|
|
38
|
+
.findReferencesAsNodes(target).length;
|
|
39
|
+
target.rename(newName, {
|
|
40
|
+
renameInComments: false,
|
|
41
|
+
renameInStrings: false,
|
|
42
|
+
usePrefixAndSuffixText: true,
|
|
43
|
+
});
|
|
44
|
+
const filesChanged = project.getSourceFiles().filter((sourceFile) => !sourceFile.isSaved());
|
|
45
|
+
project.saveSync();
|
|
46
|
+
clearDeclarationIndexCache({
|
|
47
|
+
cacheDirectory: options.cacheDirectory,
|
|
48
|
+
cwd: options.cwd,
|
|
49
|
+
projectPath: resolution.rootTsConfigPath,
|
|
50
|
+
});
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
pointer: resolution.pointer,
|
|
53
|
+
oldName: declaration.name,
|
|
54
|
+
newName,
|
|
55
|
+
filesChanged: filesChanged.length,
|
|
56
|
+
referencesRenamed,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function resolveSinglePointer(pointer, options = {}) {
|
|
60
|
+
const candidates = resolvePointer(pointer, options);
|
|
61
|
+
if (candidates.length === 0) {
|
|
62
|
+
throw new Error(`No declaration matches pointer '${pointer}'.`);
|
|
63
|
+
}
|
|
64
|
+
if (candidates.length > 1) {
|
|
65
|
+
return Object.freeze({
|
|
66
|
+
candidates: Object.freeze(candidates.map(toPointerCandidate)),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return candidates[0];
|
|
70
|
+
}
|
|
71
|
+
function isTypeScriptIdentifier(value) {
|
|
72
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, ts.LanguageVariant.Standard, value);
|
|
73
|
+
return (scanner.scan() === ts.SyntaxKind.Identifier &&
|
|
74
|
+
scanner.getTokenText() === value &&
|
|
75
|
+
scanner.scan() === ts.SyntaxKind.EndOfFileToken);
|
|
76
|
+
}
|
|
77
|
+
function ensureDeclarationIsCurrent(declaration) {
|
|
78
|
+
if (!existsSync(declaration.filePath)) {
|
|
79
|
+
throw new Error("The file recorded for this declaration no longer exists.");
|
|
80
|
+
}
|
|
81
|
+
const contentHash = createHash("sha256")
|
|
82
|
+
.update(readFileSync(declaration.filePath))
|
|
83
|
+
.digest("hex");
|
|
84
|
+
if (contentHash !== declaration.contentHash) {
|
|
85
|
+
throw new Error("The declaration file changed while resolving its pointer. Try again.");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function findTarget(project, declaration) {
|
|
89
|
+
const sourceFile = project.getSourceFile(declaration.filePath);
|
|
90
|
+
if (sourceFile === undefined) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return sourceFile
|
|
94
|
+
.getDescendants()
|
|
95
|
+
.find((node) => isRecordedDeclaration(node, declaration));
|
|
96
|
+
}
|
|
97
|
+
function isRecordedDeclaration(node, declaration) {
|
|
98
|
+
return (node.getKindName() === declaration.kind &&
|
|
99
|
+
node.getStart() === declaration.start &&
|
|
100
|
+
"getName" in node &&
|
|
101
|
+
typeof node.getName === "function" &&
|
|
102
|
+
node.getName() === declaration.name);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../src/rename.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,kBAAkB,GAGnB,MAAM,cAAc,CAAC;AAgBtB,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,OAAO,CACL,MAAM,KAAK,IAAI;QACf,OAAO,MAAM,KAAK,QAAQ;QAC1B,YAAY,IAAI,MAAM,CACvB,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,OAAe,EACf,OAAO,GAAkB,EAAE;IAE3B,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,yCAAyC,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,kBAA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
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/isaacwasserman/regoof.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/isaacwasserman/regoof#readme",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": {
|
|
15
|
+
"regoof": "./dist/bin.js"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "README.md"],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "bun run scripts/build.ts",
|
|
23
|
+
"cli": "bun run src/bin.ts",
|
|
24
|
+
"test": "bun test",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"changeset": "changeset",
|
|
27
|
+
"prepack": "bun run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/bun": "latest",
|
|
31
|
+
"@types/node": "^26.4.1",
|
|
32
|
+
"@changesets/cli": "^2.30.0",
|
|
33
|
+
"typescript": "^7.0.2"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"typescript": "^7"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@stricli/core": "^1.3.0",
|
|
40
|
+
"@speed-highlight/core": "^2.1.0",
|
|
41
|
+
"env-paths": "^4.0.0",
|
|
42
|
+
"minimatch": "^10.2.6",
|
|
43
|
+
"ts-morph": "^28.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|