hermex 2.0.0-beta.2 → 2.0.0-beta.3
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/dist/index.d.mts +310 -0
- package/dist/index.mjs +1 -0
- package/package.json +9 -2
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/config/schema.d.ts
|
|
4
|
+
declare const RuleSeveritySchema: z.ZodEnum<{
|
|
5
|
+
error: "error";
|
|
6
|
+
info: "info";
|
|
7
|
+
warn: "warn";
|
|
8
|
+
}>;
|
|
9
|
+
declare const RuleConfigSchema: z.ZodObject<{
|
|
10
|
+
severity: z.ZodEnum<{
|
|
11
|
+
error: "error";
|
|
12
|
+
info: "info";
|
|
13
|
+
warn: "warn";
|
|
14
|
+
}>;
|
|
15
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
16
|
+
message: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const EngineVersionRuleSchema: z.ZodObject<{
|
|
19
|
+
severity: z.ZodEnum<{
|
|
20
|
+
error: "error";
|
|
21
|
+
info: "info";
|
|
22
|
+
warn: "warn";
|
|
23
|
+
}>;
|
|
24
|
+
range: z.ZodString;
|
|
25
|
+
message: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
declare const HermexConfigSchema: z.ZodObject<{
|
|
28
|
+
includes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
29
|
+
excludes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
30
|
+
packages: z.ZodDefault<z.ZodObject<{
|
|
31
|
+
internal: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
32
|
+
ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
versus: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
packages: z.ZodArray<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>>;
|
|
38
|
+
rules: z.ZodDefault<z.ZodObject<{
|
|
39
|
+
detect_files: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
40
|
+
severity: z.ZodEnum<{
|
|
41
|
+
error: "error";
|
|
42
|
+
info: "info";
|
|
43
|
+
warn: "warn";
|
|
44
|
+
}>;
|
|
45
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
46
|
+
message: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
48
|
+
severity: z.ZodEnum<{
|
|
49
|
+
error: "error";
|
|
50
|
+
info: "info";
|
|
51
|
+
warn: "warn";
|
|
52
|
+
}>;
|
|
53
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
54
|
+
message: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>>]>>;
|
|
56
|
+
require_files: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
57
|
+
severity: z.ZodEnum<{
|
|
58
|
+
error: "error";
|
|
59
|
+
info: "info";
|
|
60
|
+
warn: "warn";
|
|
61
|
+
}>;
|
|
62
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
63
|
+
message: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
65
|
+
severity: z.ZodEnum<{
|
|
66
|
+
error: "error";
|
|
67
|
+
info: "info";
|
|
68
|
+
warn: "warn";
|
|
69
|
+
}>;
|
|
70
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
71
|
+
message: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>>]>>;
|
|
73
|
+
forbid_packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
74
|
+
severity: z.ZodEnum<{
|
|
75
|
+
error: "error";
|
|
76
|
+
info: "info";
|
|
77
|
+
warn: "warn";
|
|
78
|
+
}>;
|
|
79
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
80
|
+
message: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
82
|
+
severity: z.ZodEnum<{
|
|
83
|
+
error: "error";
|
|
84
|
+
info: "info";
|
|
85
|
+
warn: "warn";
|
|
86
|
+
}>;
|
|
87
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
88
|
+
message: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>>]>>;
|
|
90
|
+
require_packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
91
|
+
severity: z.ZodEnum<{
|
|
92
|
+
error: "error";
|
|
93
|
+
info: "info";
|
|
94
|
+
warn: "warn";
|
|
95
|
+
}>;
|
|
96
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
97
|
+
message: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
99
|
+
severity: z.ZodEnum<{
|
|
100
|
+
error: "error";
|
|
101
|
+
info: "info";
|
|
102
|
+
warn: "warn";
|
|
103
|
+
}>;
|
|
104
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
105
|
+
message: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>]>>;
|
|
107
|
+
require_scripts: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
108
|
+
severity: z.ZodEnum<{
|
|
109
|
+
error: "error";
|
|
110
|
+
info: "info";
|
|
111
|
+
warn: "warn";
|
|
112
|
+
}>;
|
|
113
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
114
|
+
message: z.ZodOptional<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
116
|
+
severity: z.ZodEnum<{
|
|
117
|
+
error: "error";
|
|
118
|
+
info: "info";
|
|
119
|
+
warn: "warn";
|
|
120
|
+
}>;
|
|
121
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
122
|
+
message: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strip>>]>>;
|
|
124
|
+
require_package_fields: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
|
|
125
|
+
severity: z.ZodEnum<{
|
|
126
|
+
error: "error";
|
|
127
|
+
info: "info";
|
|
128
|
+
warn: "warn";
|
|
129
|
+
}>;
|
|
130
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
131
|
+
message: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
133
|
+
severity: z.ZodEnum<{
|
|
134
|
+
error: "error";
|
|
135
|
+
info: "info";
|
|
136
|
+
warn: "warn";
|
|
137
|
+
}>;
|
|
138
|
+
patterns: z.ZodArray<z.ZodString>;
|
|
139
|
+
message: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strip>>]>>;
|
|
141
|
+
engine_version: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
142
|
+
severity: z.ZodEnum<{
|
|
143
|
+
error: "error";
|
|
144
|
+
info: "info";
|
|
145
|
+
warn: "warn";
|
|
146
|
+
}>;
|
|
147
|
+
range: z.ZodString;
|
|
148
|
+
message: z.ZodOptional<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
150
|
+
severity: z.ZodEnum<{
|
|
151
|
+
error: "error";
|
|
152
|
+
info: "info";
|
|
153
|
+
warn: "warn";
|
|
154
|
+
}>;
|
|
155
|
+
range: z.ZodString;
|
|
156
|
+
message: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>>]>>;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
output: z.ZodDefault<z.ZodObject<{
|
|
160
|
+
summary: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"log">, z.ZodLiteral<false>]>>;
|
|
161
|
+
components: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
162
|
+
chart: "chart";
|
|
163
|
+
table: "table";
|
|
164
|
+
}>, z.ZodLiteral<false>]>>;
|
|
165
|
+
packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
166
|
+
chart: "chart";
|
|
167
|
+
table: "table";
|
|
168
|
+
}>, z.ZodLiteral<false>]>>;
|
|
169
|
+
patterns: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
170
|
+
chart: "chart";
|
|
171
|
+
table: "table";
|
|
172
|
+
}>, z.ZodLiteral<false>]>>;
|
|
173
|
+
details: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
versus: z.ZodDefault<z.ZodBoolean>;
|
|
175
|
+
rules: z.ZodDefault<z.ZodBoolean>;
|
|
176
|
+
format: z.ZodDefault<z.ZodEnum<{
|
|
177
|
+
human: "human";
|
|
178
|
+
json: "json";
|
|
179
|
+
}>>;
|
|
180
|
+
}, z.core.$strip>>;
|
|
181
|
+
releaseAge: z.ZodDefault<z.ZodObject<{
|
|
182
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
183
|
+
registry: z.ZodDefault<z.ZodString>;
|
|
184
|
+
authToken: z.ZodOptional<z.ZodString>;
|
|
185
|
+
thresholds: z.ZodDefault<z.ZodObject<{
|
|
186
|
+
patch: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
|
|
187
|
+
minor: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
|
|
188
|
+
major: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
enforceOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
191
|
+
}, z.core.$strip>>;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
/** Config as returned after parsing — all defaults applied, all fields required */
|
|
194
|
+
type HermexConfig = z.infer<typeof HermexConfigSchema>;
|
|
195
|
+
/** Config as accepted by the user — everything optional */
|
|
196
|
+
type HermexConfigInput = z.input<typeof HermexConfigSchema>;
|
|
197
|
+
type RuleSeverity = z.infer<typeof RuleSeveritySchema>;
|
|
198
|
+
type RuleConfig = z.infer<typeof RuleConfigSchema>;
|
|
199
|
+
type EngineVersionRule = z.infer<typeof EngineVersionRuleSchema>;
|
|
200
|
+
type PackagesConfig = HermexConfig['packages'];
|
|
201
|
+
type VersusConfig = HermexConfig['versus'][number];
|
|
202
|
+
type RulesConfig = HermexConfig['rules'];
|
|
203
|
+
type OutputConfig = HermexConfig['output'];
|
|
204
|
+
type ReleaseAgeConfig = HermexConfig['releaseAge'];
|
|
205
|
+
type ReleaseAgeThresholds = HermexConfig['releaseAge']['thresholds'];
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/npm-registry/types.d.ts
|
|
208
|
+
type UpgradeLevel = 'needs_upgrade' | 'mandatory_upgrade';
|
|
209
|
+
type SemverBump = 'patch' | 'minor' | 'major';
|
|
210
|
+
interface AvailableUpgrade {
|
|
211
|
+
version: string;
|
|
212
|
+
releasedDaysAgo: number;
|
|
213
|
+
semverBump: SemverBump;
|
|
214
|
+
level: UpgradeLevel;
|
|
215
|
+
isLatest?: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface ReleaseAgeEntry {
|
|
218
|
+
installedVersion: string;
|
|
219
|
+
upgrades: AvailableUpgrade[];
|
|
220
|
+
worstLevel: UpgradeLevel | null;
|
|
221
|
+
deprecated?: string;
|
|
222
|
+
latestVersion?: string;
|
|
223
|
+
latestReleasedDaysAgo?: number;
|
|
224
|
+
minCompliantVersion?: string;
|
|
225
|
+
minCompliantReleasedDaysAgo?: number;
|
|
226
|
+
severity: 'error' | 'warn';
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/utils/package-distribution.d.ts
|
|
230
|
+
interface ComponentUsage {
|
|
231
|
+
name: string;
|
|
232
|
+
source: string;
|
|
233
|
+
count: number;
|
|
234
|
+
files: Set<string>;
|
|
235
|
+
}
|
|
236
|
+
interface PackageDistribution {
|
|
237
|
+
packageName: string;
|
|
238
|
+
version: string | null;
|
|
239
|
+
componentCount: number;
|
|
240
|
+
usageCount: number;
|
|
241
|
+
percentage: number;
|
|
242
|
+
components: string[];
|
|
243
|
+
internal: boolean;
|
|
244
|
+
hasVersionConflict: boolean;
|
|
245
|
+
allVersions: string[];
|
|
246
|
+
releaseAge?: ReleaseAgeEntry;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/utils/pattern-counter.d.ts
|
|
250
|
+
interface PatternCount {
|
|
251
|
+
patternType: string;
|
|
252
|
+
displayName: string;
|
|
253
|
+
count: number;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/utils/versus.d.ts
|
|
257
|
+
interface VersusEntry {
|
|
258
|
+
packageName: string;
|
|
259
|
+
count: number;
|
|
260
|
+
percentage: number;
|
|
261
|
+
components: string[];
|
|
262
|
+
}
|
|
263
|
+
interface VersusResult {
|
|
264
|
+
name: string;
|
|
265
|
+
packages: string[];
|
|
266
|
+
entries: VersusEntry[];
|
|
267
|
+
totalCount: number;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/rules/shared.d.ts
|
|
271
|
+
interface RuleViolation {
|
|
272
|
+
type: 'detect_files' | 'require_files' | 'forbid_packages' | 'require_packages' | 'require_scripts' | 'require_package_fields' | 'engine_version';
|
|
273
|
+
severity: 'error' | 'warn' | 'info';
|
|
274
|
+
patterns: string[];
|
|
275
|
+
message?: string;
|
|
276
|
+
matchedFiles: string[];
|
|
277
|
+
installedRange?: string;
|
|
278
|
+
requiredRange?: string;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/utils/package-rules.d.ts
|
|
282
|
+
interface BannedPackageViolation {
|
|
283
|
+
packageName: string;
|
|
284
|
+
severity: 'error' | 'warn' | 'info';
|
|
285
|
+
message?: string;
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/index.d.ts
|
|
289
|
+
/** Shape of a single entry in `components` — same as `ComponentUsage`, but with `files` as an array (JSON has no `Set`) */
|
|
290
|
+
interface HermexScanComponent extends Omit<ComponentUsage, 'files'> {
|
|
291
|
+
files: string[];
|
|
292
|
+
}
|
|
293
|
+
/** Shape of the JSON emitted by `hermex scan --format json` (see `printJson`) */
|
|
294
|
+
interface HermexScanResult {
|
|
295
|
+
version: string;
|
|
296
|
+
summary: {
|
|
297
|
+
filesAnalyzed: number;
|
|
298
|
+
totalImports: number;
|
|
299
|
+
totalComponents: number;
|
|
300
|
+
totalUsagePatterns: number;
|
|
301
|
+
};
|
|
302
|
+
packages: PackageDistribution[];
|
|
303
|
+
components: HermexScanComponent[];
|
|
304
|
+
patterns: PatternCount[];
|
|
305
|
+
versus: VersusResult[];
|
|
306
|
+
ruleViolations: RuleViolation[];
|
|
307
|
+
bannedPackageViolations: BannedPackageViolation[];
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
export { type BannedPackageViolation, type ComponentUsage, type EngineVersionRule, type HermexConfig, type HermexConfigInput, HermexScanComponent, HermexScanResult, type OutputConfig, type PackageDistribution, type PackagesConfig, type PatternCount, type ReleaseAgeConfig, type ReleaseAgeThresholds, type RuleConfig, type RuleSeverity, type RuleViolation, type RulesConfig, type VersusConfig, type VersusEntry, type VersusResult };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermex",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "SWC-based AST parser for analyzing code and React component usage patterns across entire codebases",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -30,7 +30,14 @@
|
|
|
30
30
|
"LICENSE.md"
|
|
31
31
|
],
|
|
32
32
|
"type": "module",
|
|
33
|
-
"main": "./dist/
|
|
33
|
+
"main": "./dist/index.mjs",
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.mts",
|
|
38
|
+
"default": "./dist/index.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
34
41
|
"scripts": {
|
|
35
42
|
"format": "oxfmt --write",
|
|
36
43
|
"format:ci": "oxfmt --check",
|