ouch4ts 0.0.0-stage → 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.
@@ -0,0 +1,340 @@
1
+ import ts from "typescript";
2
+ import { recursiveCallNodes } from "./cycles.js";
3
+ import { assignmentContainer, definitionExpressions, hasImplementation, isAccessor, isAssignment, isAssignmentReference, isAssignmentTo, isInitializedDeclaration, isInvocation, isPropertyAccess, isUpdate, unwrapExpression, } from "./syntax.js";
4
+ const noWrittenSymbols = new Set();
5
+ /** Identify functions in direct or indirect cycles of statically resolved calls. */
6
+ export function recursiveFunctions(sources, checker) {
7
+ const builder = new CallGraphBuilder(checker, writtenSymbols(sources, checker));
8
+ for (const source of sources)
9
+ builder.visit(source);
10
+ return recursiveCallNodes(builder.graph);
11
+ }
12
+ class CallGraphBuilder {
13
+ checker;
14
+ written;
15
+ graph = new Map();
16
+ constructor(checker, written) {
17
+ this.checker = checker;
18
+ this.written = written;
19
+ }
20
+ visit(node, caller) {
21
+ if (ts.isFunctionLike(node)) {
22
+ this.visitFunction(node, caller);
23
+ return;
24
+ }
25
+ if (caller)
26
+ this.recordCalls(node, caller);
27
+ ts.forEachChild(node, child => this.visit(child, caller));
28
+ }
29
+ visitFunction(node, caller) {
30
+ if (!hasImplementation(node))
31
+ return;
32
+ this.graph.set(node, new Set());
33
+ definitionExpressions(node).forEach(expression => this.visit(expression, caller));
34
+ node.parameters.forEach(parameter => this.visit(parameter, node));
35
+ this.visit(node.body, node);
36
+ }
37
+ recordCalls(node, caller) {
38
+ if (isInvocation(node))
39
+ this.addTarget(caller, callTarget(node, this.checker, this.written));
40
+ for (const target of accessorTargets(node, this.checker, this.written))
41
+ this.addTarget(caller, target);
42
+ }
43
+ addTarget(caller, target) {
44
+ if (target)
45
+ this.graph.get(caller).add(target);
46
+ }
47
+ }
48
+ function accessorTargets(node, checker, written) {
49
+ if (!isPropertyAccess(node))
50
+ return [];
51
+ if (isWrittenAccess(node, checker, written))
52
+ return [];
53
+ const use = propertyUse(node);
54
+ return memberDeclarations(node, checker, written).filter(declaration => isUsedAccessor(declaration, use));
55
+ }
56
+ function isWrittenAccess(node, checker, written) {
57
+ return written !== undefined && isWrittenTarget(node, checker, written);
58
+ }
59
+ function memberDeclarations(node, checker, written = noWrittenSymbols) {
60
+ return new BindingLookup(checker, written).resolveMembers(node);
61
+ }
62
+ function symbolDeclarations(symbol) {
63
+ return symbol?.declarations ?? [];
64
+ }
65
+ function isUsedAccessor(node, use) {
66
+ if (ts.isGetAccessorDeclaration(node))
67
+ return use.read;
68
+ return ts.isSetAccessorDeclaration(node) && use.write;
69
+ }
70
+ function propertyUse(node) {
71
+ let expression = node;
72
+ for (let container = assignmentContainer(expression); container; container = assignmentContainer(expression))
73
+ expression = container;
74
+ return assignedPropertyUse(expression);
75
+ }
76
+ function assignedPropertyUse(expression) {
77
+ const parent = expression.parent;
78
+ if (ts.isDeleteExpression(parent))
79
+ return { read: false, write: false };
80
+ return assignmentUse(expression) ?? { read: true, write: isUpdate(parent) };
81
+ }
82
+ function assignmentUse(expression) {
83
+ const parent = expression.parent;
84
+ if (isAssignmentTo(parent, expression)) {
85
+ return { read: parent.operatorToken.kind !== ts.SyntaxKind.EqualsToken, write: true };
86
+ }
87
+ if (loopAssignmentTarget(parent) === expression)
88
+ return { read: false, write: true };
89
+ }
90
+ function callTarget(node, checker, written) {
91
+ const expression = invocationExpression(node);
92
+ if (!isResolvableCall(expression, checker, written))
93
+ return;
94
+ const value = new BindingLookup(checker, written).resolveValue(expression);
95
+ return invocationImplementation(node, value, checker, written);
96
+ }
97
+ function invocationImplementation(node, value, checker, written) {
98
+ if (!value)
99
+ return;
100
+ if (isCallableImplementation(value))
101
+ return value;
102
+ return signatureImplementation(checker.getResolvedSignature(node)?.declaration, checker, written);
103
+ }
104
+ function invocationExpression(node) {
105
+ return ts.isTaggedTemplateExpression(node) ? node.tag : node.expression;
106
+ }
107
+ function isResolvableCall(expression, checker, written) {
108
+ if (isWrittenTarget(expression, checker, written))
109
+ return false;
110
+ return !ts.isElementAccessExpression(expression) || constantKey(expression.argumentExpression, checker) !== undefined;
111
+ }
112
+ function isCallableImplementation(node) {
113
+ return node !== undefined && hasImplementation(node) && !isAccessor(node);
114
+ }
115
+ function declarationSymbol(node, checker) {
116
+ if ("name" in node && node.name)
117
+ return checker.getSymbolAtLocation(node.name);
118
+ }
119
+ function signatureImplementation(declaration, checker, written) {
120
+ if (!declaration)
121
+ return;
122
+ const symbol = declarationSymbol(declaration, checker);
123
+ if (isWrittenSymbol(symbol, written))
124
+ return;
125
+ return implementationDeclaration(declaration, symbol);
126
+ }
127
+ function implementationDeclaration(declaration, symbol) {
128
+ if (hasImplementation(declaration))
129
+ return declaration;
130
+ if (ts.isConstructorDeclaration(declaration))
131
+ return declaration.parent.members.find(isImplementedConstructor);
132
+ return symbolImplementation(symbol);
133
+ }
134
+ function symbolImplementation(symbol) {
135
+ return symbol?.declarations?.find(hasImplementation);
136
+ }
137
+ function isImplementedConstructor(node) {
138
+ return ts.isConstructorDeclaration(node) && node.body !== undefined;
139
+ }
140
+ function writtenSymbols(sources, checker) {
141
+ const collector = new WrittenSymbolCollector(checker);
142
+ for (const source of sources)
143
+ collector.visit(source);
144
+ return collector.written;
145
+ }
146
+ class WrittenSymbolCollector {
147
+ checker;
148
+ written = new Set();
149
+ constructor(checker) {
150
+ this.checker = checker;
151
+ }
152
+ record(node) {
153
+ if (isAssignmentReference(node)) {
154
+ this.recordSymbol(assignedSymbol(node, this.checker));
155
+ return;
156
+ }
157
+ ts.forEachChild(node, child => this.recordAssignmentChild(node, child));
158
+ }
159
+ recordAssignmentChild(parent, child) {
160
+ if (assignmentContainer(child) === parent || isAssignmentTo(parent, child))
161
+ this.record(child);
162
+ }
163
+ recordSymbol(symbol) {
164
+ if (symbol)
165
+ this.written.add(symbol);
166
+ }
167
+ visit(node) {
168
+ const target = reassignedExpression(node);
169
+ if (target)
170
+ this.record(target);
171
+ ts.forEachChild(node, child => this.visit(child));
172
+ }
173
+ }
174
+ function reassignedExpression(node) {
175
+ if (isAssignment(node))
176
+ return node.left;
177
+ if (isUpdate(node))
178
+ return node.operand;
179
+ return loopAssignmentTarget(node);
180
+ }
181
+ function loopAssignmentTarget(node) {
182
+ if (!isForInOrOf(node))
183
+ return;
184
+ if (!ts.isVariableDeclarationList(node.initializer))
185
+ return node.initializer;
186
+ }
187
+ function isForInOrOf(node) {
188
+ return ts.isForInStatement(node) || ts.isForOfStatement(node);
189
+ }
190
+ function assignedSymbol(node, checker) {
191
+ if (writesAccessor(node, checker))
192
+ return;
193
+ const symbol = assignmentSymbol(node, checker);
194
+ if (!isAccessorSymbol(symbol))
195
+ return symbol;
196
+ }
197
+ function writesAccessor(node, checker) {
198
+ return isPropertyAccess(node) && accessorTargets(node, checker).length > 0;
199
+ }
200
+ function isAccessorSymbol(symbol) {
201
+ return symbol?.declarations?.some(isAccessor) === true;
202
+ }
203
+ function assignmentSymbol(node, checker) {
204
+ const symbol = expressionSymbol(node, checker);
205
+ if (symbol || !isPropertyAccess(node))
206
+ return symbol;
207
+ return expressionSymbol(node.expression, checker);
208
+ }
209
+ function expressionSymbol(node, checker) {
210
+ const symbol = referencedSymbol(node, checker);
211
+ return resolveAlias(symbol, checker);
212
+ }
213
+ function referencedSymbol(node, checker) {
214
+ if (isPropertyAccess(node))
215
+ return propertySymbol(node, checker);
216
+ if (ts.isShorthandPropertyAssignment(node.parent))
217
+ return checker.getShorthandAssignmentValueSymbol(node.parent);
218
+ return checker.getSymbolAtLocation(node);
219
+ }
220
+ function propertySymbol(node, checker) {
221
+ return ts.isElementAccessExpression(node) ? elementSymbol(node, checker) : checker.getSymbolAtLocation(node.name);
222
+ }
223
+ function elementSymbol(node, checker) {
224
+ const key = constantKey(node.argumentExpression, checker);
225
+ return key === undefined ? undefined : checker.getTypeAtLocation(node.expression).getProperty(key);
226
+ }
227
+ function resolveAlias(symbol, checker) {
228
+ if (symbol && (symbol.flags & ts.SymbolFlags.Alias))
229
+ return checker.getAliasedSymbol(symbol);
230
+ return symbol;
231
+ }
232
+ function isWrittenTarget(value, checker, written) {
233
+ const node = unwrapExpression(value);
234
+ const symbol = expressionSymbol(node, checker);
235
+ if (isWrittenSymbol(symbol, written))
236
+ return true;
237
+ return isWrittenOwner(node, checker, written);
238
+ }
239
+ function isWrittenSymbol(symbol, written) {
240
+ return symbol !== undefined && written.has(symbol);
241
+ }
242
+ function isWrittenOwner(node, checker, written) {
243
+ return isPropertyAccess(node) && isWrittenTarget(node.expression, checker, written);
244
+ }
245
+ /** Each lookup owns its alias-cycle guard; independent calls never share visited bindings. */
246
+ class BindingLookup {
247
+ checker;
248
+ written;
249
+ seen;
250
+ constructor(checker, written, seen = new Set()) {
251
+ this.checker = checker;
252
+ this.written = written;
253
+ this.seen = seen;
254
+ }
255
+ resolveValue(node) {
256
+ const expression = unwrapExpression(node);
257
+ if (ts.isIdentifier(expression))
258
+ return this.symbolValue(this.checker.getSymbolAtLocation(expression));
259
+ if (isPropertyAccess(expression))
260
+ return this.memberValue(this.resolveMembers(expression).at(-1));
261
+ return expression;
262
+ }
263
+ memberValue(member) {
264
+ if (!member)
265
+ return;
266
+ if (ts.isShorthandPropertyAssignment(member))
267
+ return this.symbolValue(this.checker.getShorthandAssignmentValueSymbol(member));
268
+ return this.declarationValue(member);
269
+ }
270
+ resolveMembers(node) {
271
+ const owner = this.resolveValue(node.expression);
272
+ if (!owner)
273
+ return [];
274
+ if (!ts.isObjectLiteralExpression(owner))
275
+ return symbolDeclarations(expressionSymbol(node, this.checker));
276
+ const name = accessName(node, this.checker);
277
+ return name === undefined ? [] : this.objectMembers(owner, name) ?? [];
278
+ }
279
+ /** Undefined means absent; an empty list means a spread left the target unresolved. */
280
+ objectMembers(owner, name) {
281
+ const accessors = [];
282
+ let members;
283
+ for (const property of [...owner.properties].reverse()) {
284
+ if (ts.isSpreadAssignment(property)) {
285
+ members = this.spreadMembers(property.expression, name);
286
+ if (members !== undefined)
287
+ break;
288
+ }
289
+ else if (propertyName(property.name, this.checker) === name) {
290
+ if (!isAccessor(property)) {
291
+ members = [property];
292
+ break;
293
+ }
294
+ if (!accessors.some(accessor => accessor.kind === property.kind))
295
+ accessors.push(property);
296
+ }
297
+ }
298
+ return accessors.length ? accessors : members;
299
+ }
300
+ spreadMembers(expression, name) {
301
+ const lookup = new BindingLookup(this.checker, this.written, new Set(this.seen));
302
+ const owner = lookup.resolveValue(expression);
303
+ if (!owner)
304
+ return [];
305
+ if (ts.isObjectLiteralExpression(owner))
306
+ return lookup.objectMembers(owner, name);
307
+ return symbolDeclarations(this.checker.getTypeAtLocation(expression).getProperty(name));
308
+ }
309
+ symbolValue(symbol) {
310
+ const resolved = resolveAlias(symbol, this.checker);
311
+ if (!this.canResolveSymbol(resolved))
312
+ return;
313
+ this.seen.add(resolved);
314
+ return this.declaredValue(resolved);
315
+ }
316
+ canResolveSymbol(symbol) {
317
+ return symbol !== undefined && !this.written.has(symbol) && !this.seen.has(symbol);
318
+ }
319
+ declaredValue(symbol) {
320
+ const declaration = symbol.valueDeclaration;
321
+ if (declaration)
322
+ return this.declarationValue(declaration);
323
+ }
324
+ declarationValue(node) {
325
+ if (isInitializedDeclaration(node) || ts.isPropertyAssignment(node))
326
+ return this.resolveValue(node.initializer);
327
+ return node;
328
+ }
329
+ }
330
+ function accessName(node, checker) {
331
+ return ts.isPropertyAccessExpression(node) ? node.name.text : constantKey(node.argumentExpression, checker);
332
+ }
333
+ function propertyName(name, checker) {
334
+ return ts.isComputedPropertyName(name) ? constantKey(name.expression, checker) : name.text;
335
+ }
336
+ function constantKey(node, checker) {
337
+ const type = checker.getTypeAtLocation(node);
338
+ if (type.isStringLiteral() || type.isNumberLiteral())
339
+ return String(type.value);
340
+ }
@@ -0,0 +1,30 @@
1
+ export declare function validatedReport(data: Record<string, unknown>): {
2
+ entries: ({
3
+ coverage: null;
4
+ crap: null;
5
+ ouch: null;
6
+ name: string;
7
+ file: string;
8
+ line: number;
9
+ endLine: number;
10
+ complexity: number;
11
+ cognitive: number;
12
+ } | {
13
+ coverage: number;
14
+ crap: number;
15
+ ouch: number;
16
+ name: string;
17
+ file: string;
18
+ line: number;
19
+ endLine: number;
20
+ complexity: number;
21
+ cognitive: number;
22
+ })[];
23
+ files: {
24
+ complexity: number;
25
+ cognitive: number;
26
+ functions: number;
27
+ file: string;
28
+ }[];
29
+ } | null;
30
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
package/dist/report.js ADDED
@@ -0,0 +1,57 @@
1
+ export function validatedReport(data) {
2
+ if (!isMetricArray(data.entries))
3
+ return null;
4
+ if (!isFileMetricArray(data.files))
5
+ return null;
6
+ return { entries: data.entries, files: data.files };
7
+ }
8
+ function isMetricArray(value) {
9
+ return Array.isArray(value) && value.every(isMetric);
10
+ }
11
+ function isFileMetricArray(value) {
12
+ return Array.isArray(value) && value.every(isFileMetric);
13
+ }
14
+ function isMetric(value) {
15
+ if (!isRecord(value))
16
+ return false;
17
+ return [hasFunctionIdentity, hasFunctionRange, hasComplexities, hasCoverageAndScores].every(validate => validate(value));
18
+ }
19
+ function hasComplexities(value) {
20
+ return isIntegerAtLeast(value.complexity, 1) && isIntegerAtLeast(value.cognitive, 0);
21
+ }
22
+ function isFileMetric(value) {
23
+ return isRecord(value) && typeof value.file === "string" && isIntegerAtLeast(value.complexity, 0)
24
+ && isIntegerAtLeast(value.cognitive, 0) && isIntegerAtLeast(value.functions, 0);
25
+ }
26
+ export function isRecord(value) {
27
+ return typeof value === "object" && value !== null;
28
+ }
29
+ function hasFunctionIdentity(value) {
30
+ return typeof value.name === "string" && typeof value.file === "string";
31
+ }
32
+ function hasFunctionRange(value) {
33
+ return isIntegerAtLeast(value.line, 1) && isIntegerAtLeast(value.endLine, 1) && value.endLine >= value.line;
34
+ }
35
+ function isIntegerAtLeast(value, minimum) {
36
+ return isNumber(value) && Number.isInteger(value) && value >= minimum;
37
+ }
38
+ function hasCoverageAndScores(value) {
39
+ if (value.coverage === null)
40
+ return hasUnknownScores(value);
41
+ return hasMeasuredScores(value);
42
+ }
43
+ function hasUnknownScores(value) {
44
+ return value.crap === null && value.ouch === null;
45
+ }
46
+ function hasMeasuredScores(value) {
47
+ return isCoverage(value.coverage) && isScore(value.crap) && isScore(value.ouch);
48
+ }
49
+ function isScore(value) {
50
+ return isNumber(value) && value >= 1;
51
+ }
52
+ function isCoverage(value) {
53
+ return isNumber(value) && value >= 0 && value <= 100;
54
+ }
55
+ function isNumber(value) {
56
+ return typeof value === "number" && Number.isFinite(value);
57
+ }
@@ -0,0 +1,21 @@
1
+ import ts from "typescript";
2
+ export type PropertyAccess = ts.PropertyAccessExpression | ts.ElementAccessExpression;
3
+ export type Invocation = ts.CallExpression | ts.NewExpression | ts.TaggedTemplateExpression;
4
+ export type ImplementedFunction = ts.FunctionLikeDeclaration & {
5
+ body: ts.ConciseBody;
6
+ };
7
+ export declare function isInvocation(node: ts.Node): node is Invocation;
8
+ export declare function isPropertyAccess(node: ts.Node): node is PropertyAccess;
9
+ export declare function assignmentContainer(node: ts.Node): ts.Node | undefined;
10
+ export declare function isAssignmentTo(parent: ts.Node, expression: ts.Node): parent is ts.BinaryExpression;
11
+ export declare function isAssignmentReference(node: ts.Node): node is ts.Identifier | PropertyAccess;
12
+ export declare function isAssignment(node: ts.Node): node is ts.BinaryExpression;
13
+ export declare function isUpdate(node: ts.Node): node is ts.PrefixUnaryExpression | ts.PostfixUnaryExpression;
14
+ export declare function isAccessor(node: ts.Node): node is ts.GetAccessorDeclaration | ts.SetAccessorDeclaration;
15
+ export declare function unwrapExpression(node: ts.Expression): ts.Expression;
16
+ export declare function isInitializedDeclaration(node: ts.Node): node is (ts.VariableDeclaration | ts.PropertyDeclaration) & {
17
+ initializer: ts.Expression;
18
+ };
19
+ export declare function hasImplementation(node: ts.Node): node is ImplementedFunction;
20
+ export declare function definitionExpressions(node: ts.SignatureDeclaration): ts.Expression[];
21
+ export declare function isSimpleAssignment(node: ts.Node): node is ts.BinaryExpression;
package/dist/syntax.js ADDED
@@ -0,0 +1,93 @@
1
+ import ts from "typescript";
2
+ export function isInvocation(node) {
3
+ return ts.isCallExpression(node) || ts.isNewExpression(node) || ts.isTaggedTemplateExpression(node);
4
+ }
5
+ export function isPropertyAccess(node) {
6
+ return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node);
7
+ }
8
+ export function assignmentContainer(node) {
9
+ const parent = node.parent;
10
+ if (isExpressionWrapper(parent))
11
+ return parent;
12
+ if (isDestructuringContainer(parent, node))
13
+ return parent;
14
+ }
15
+ function isDestructuringContainer(parent, child) {
16
+ if (ts.isArrayLiteralExpression(parent))
17
+ return true;
18
+ if (ts.isObjectLiteralExpression(parent))
19
+ return isObjectAssignmentElement(child);
20
+ return containsAssignedExpression(parent, child);
21
+ }
22
+ function isObjectAssignmentElement(node) {
23
+ return objectAssignmentKinds.has(node.kind);
24
+ }
25
+ function containsAssignedExpression(parent, child) {
26
+ if (ts.isShorthandPropertyAssignment(parent))
27
+ return parent.name === child;
28
+ return assignedElementExpression(parent) === child;
29
+ }
30
+ function assignedElementExpression(node) {
31
+ if (ts.isPropertyAssignment(node))
32
+ return node.initializer;
33
+ if (isSpread(node))
34
+ return node.expression;
35
+ }
36
+ const objectAssignmentKinds = new Set([
37
+ ts.SyntaxKind.PropertyAssignment, ts.SyntaxKind.ShorthandPropertyAssignment, ts.SyntaxKind.SpreadAssignment,
38
+ ]);
39
+ function isSpread(node) {
40
+ return ts.isSpreadElement(node) || ts.isSpreadAssignment(node);
41
+ }
42
+ export function isAssignmentTo(parent, expression) {
43
+ return isAssignment(parent) && parent.left === expression;
44
+ }
45
+ export function isAssignmentReference(node) {
46
+ return ts.isIdentifier(node) || isPropertyAccess(node);
47
+ }
48
+ export function isAssignment(node) {
49
+ return ts.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind);
50
+ }
51
+ function isAssignmentOperator(kind) {
52
+ return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
53
+ }
54
+ export function isUpdate(node) {
55
+ return isUnaryExpression(node) && updateOperators.has(node.operator);
56
+ }
57
+ function isUnaryExpression(node) {
58
+ return ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node);
59
+ }
60
+ export function isAccessor(node) {
61
+ return ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node);
62
+ }
63
+ function isExpressionWrapper(node) {
64
+ return ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node)
65
+ || ts.isNonNullExpression(node) || ts.isSatisfiesExpression(node);
66
+ }
67
+ export function unwrapExpression(node) {
68
+ while (isExpressionWrapper(node))
69
+ node = node.expression;
70
+ return node;
71
+ }
72
+ export function isInitializedDeclaration(node) {
73
+ return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node)) && node.initializer !== undefined;
74
+ }
75
+ export function hasImplementation(node) {
76
+ return ts.isFunctionLike(node) && "body" in node && node.body !== undefined;
77
+ }
78
+ export function definitionExpressions(node) {
79
+ if (!hasImplementation(node))
80
+ return [];
81
+ const decorators = functionDecorators(node);
82
+ return [...computedNameExpressions(node.name), ...decorators.map(decorator => decorator.expression)];
83
+ }
84
+ function functionDecorators(node) {
85
+ return ts.canHaveDecorators(node) ? ts.getDecorators(node) ?? [] : [];
86
+ }
87
+ function computedNameExpressions(name) {
88
+ return name !== undefined && ts.isComputedPropertyName(name) ? [name.expression] : [];
89
+ }
90
+ export function isSimpleAssignment(node) {
91
+ return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken;
92
+ }
93
+ const updateOperators = new Set([ts.SyntaxKind.PlusPlusToken, ts.SyntaxKind.MinusMinusToken]);
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "ouch4ts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "OUCH scores for JavaScript and TypeScript functions",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/dumptruckman/ouch4ts.git"
9
+ },
10
+ "type": "module",
11
+ "bin": {
12
+ "ouch4ts": "dist/cli.js"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/**/*.js",
22
+ "dist/**/*.d.ts"
23
+ ],
24
+ "engines": {
25
+ "node": ">=22"
26
+ },
27
+ "scripts": {
28
+ "release:version": "node scripts/release.ts version",
29
+ "clean": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\"",
30
+ "build": "npm run clean && tsc -p tsconfig.build.json",
31
+ "typecheck": "tsc --noEmit && tsc --noEmit -p scripts/tsconfig.json",
32
+ "test": "vitest run",
33
+ "test:coverage": "vitest run --coverage",
34
+ "ouch": "npm run build --silent && node dist/cli.js",
35
+ "prepack": "npm run build"
36
+ },
37
+ "dependencies": {
38
+ "picomatch": "4.0.7",
39
+ "typescript": "6.0.3"
40
+ },
41
+ "devDependencies": {
42
+ "@changesets/cli": "3.0.3",
43
+ "@types/node": "24.19.2",
44
+ "@types/picomatch": "4.0.3",
45
+ "@types/semver": "7.8.0",
46
+ "@vitest/coverage-v8": "5.0.5",
47
+ "semver": "7.8.6",
48
+ "vitest": "5.0.5",
49
+ "zod": "4.6.7"
50
+ }
51
+ }