hermex 1.3.0-beta.4 → 2.0.0-beta.10

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,381 @@
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 PackageFieldRuleSchema: z.ZodObject<{
19
+ severity: z.ZodEnum<{
20
+ error: "error";
21
+ info: "info";
22
+ warn: "warn";
23
+ }>;
24
+ patterns: z.ZodArray<z.ZodString>;
25
+ message: z.ZodOptional<z.ZodString>;
26
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
+ }, z.core.$strip>;
28
+ declare const EngineVersionRuleSchema: z.ZodObject<{
29
+ severity: z.ZodEnum<{
30
+ error: "error";
31
+ info: "info";
32
+ warn: "warn";
33
+ }>;
34
+ range: z.ZodString;
35
+ message: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ declare const CodeownersRuleSchema: z.ZodObject<{
38
+ severity: z.ZodEnum<{
39
+ error: "error";
40
+ info: "info";
41
+ warn: "warn";
42
+ }>;
43
+ message: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ declare const HermexConfigSchema: z.ZodObject<{
46
+ includes: z.ZodDefault<z.ZodArray<z.ZodString>>;
47
+ excludes: z.ZodDefault<z.ZodArray<z.ZodString>>;
48
+ packages: z.ZodDefault<z.ZodObject<{
49
+ internal: z.ZodDefault<z.ZodArray<z.ZodString>>;
50
+ ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
51
+ }, z.core.$strip>>;
52
+ versus: z.ZodDefault<z.ZodArray<z.ZodObject<{
53
+ name: z.ZodString;
54
+ packages: z.ZodArray<z.ZodString>;
55
+ }, z.core.$strip>>>;
56
+ rules: z.ZodDefault<z.ZodObject<{
57
+ detect_files: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
58
+ severity: z.ZodEnum<{
59
+ error: "error";
60
+ info: "info";
61
+ warn: "warn";
62
+ }>;
63
+ patterns: z.ZodArray<z.ZodString>;
64
+ message: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
66
+ severity: z.ZodEnum<{
67
+ error: "error";
68
+ info: "info";
69
+ warn: "warn";
70
+ }>;
71
+ patterns: z.ZodArray<z.ZodString>;
72
+ message: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>>]>>;
74
+ require_files: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
75
+ severity: z.ZodEnum<{
76
+ error: "error";
77
+ info: "info";
78
+ warn: "warn";
79
+ }>;
80
+ patterns: z.ZodArray<z.ZodString>;
81
+ message: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
83
+ severity: z.ZodEnum<{
84
+ error: "error";
85
+ info: "info";
86
+ warn: "warn";
87
+ }>;
88
+ patterns: z.ZodArray<z.ZodString>;
89
+ message: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strip>>]>>;
91
+ forbid_packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
92
+ severity: z.ZodEnum<{
93
+ error: "error";
94
+ info: "info";
95
+ warn: "warn";
96
+ }>;
97
+ patterns: z.ZodArray<z.ZodString>;
98
+ message: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
100
+ severity: z.ZodEnum<{
101
+ error: "error";
102
+ info: "info";
103
+ warn: "warn";
104
+ }>;
105
+ patterns: z.ZodArray<z.ZodString>;
106
+ message: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strip>>]>>;
108
+ require_packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
109
+ severity: z.ZodEnum<{
110
+ error: "error";
111
+ info: "info";
112
+ warn: "warn";
113
+ }>;
114
+ patterns: z.ZodArray<z.ZodString>;
115
+ message: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
117
+ severity: z.ZodEnum<{
118
+ error: "error";
119
+ info: "info";
120
+ warn: "warn";
121
+ }>;
122
+ patterns: z.ZodArray<z.ZodString>;
123
+ message: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>>]>>;
125
+ require_scripts: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
126
+ severity: z.ZodEnum<{
127
+ error: "error";
128
+ info: "info";
129
+ warn: "warn";
130
+ }>;
131
+ patterns: z.ZodArray<z.ZodString>;
132
+ message: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
134
+ severity: z.ZodEnum<{
135
+ error: "error";
136
+ info: "info";
137
+ warn: "warn";
138
+ }>;
139
+ patterns: z.ZodArray<z.ZodString>;
140
+ message: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strip>>]>>;
142
+ require_package_fields: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
143
+ severity: z.ZodEnum<{
144
+ error: "error";
145
+ info: "info";
146
+ warn: "warn";
147
+ }>;
148
+ patterns: z.ZodArray<z.ZodString>;
149
+ message: z.ZodOptional<z.ZodString>;
150
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
152
+ severity: z.ZodEnum<{
153
+ error: "error";
154
+ info: "info";
155
+ warn: "warn";
156
+ }>;
157
+ patterns: z.ZodArray<z.ZodString>;
158
+ message: z.ZodOptional<z.ZodString>;
159
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
+ }, z.core.$strip>>]>>;
161
+ forbid_package_fields: z.ZodDefault<z.ZodUnion<readonly [z.ZodObject<{
162
+ severity: z.ZodEnum<{
163
+ error: "error";
164
+ info: "info";
165
+ warn: "warn";
166
+ }>;
167
+ patterns: z.ZodArray<z.ZodString>;
168
+ message: z.ZodOptional<z.ZodString>;
169
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
170
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
171
+ severity: z.ZodEnum<{
172
+ error: "error";
173
+ info: "info";
174
+ warn: "warn";
175
+ }>;
176
+ patterns: z.ZodArray<z.ZodString>;
177
+ message: z.ZodOptional<z.ZodString>;
178
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
179
+ }, z.core.$strip>>]>>;
180
+ engine_version: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
181
+ severity: z.ZodEnum<{
182
+ error: "error";
183
+ info: "info";
184
+ warn: "warn";
185
+ }>;
186
+ range: z.ZodString;
187
+ message: z.ZodOptional<z.ZodString>;
188
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
189
+ severity: z.ZodEnum<{
190
+ error: "error";
191
+ info: "info";
192
+ warn: "warn";
193
+ }>;
194
+ range: z.ZodString;
195
+ message: z.ZodOptional<z.ZodString>;
196
+ }, z.core.$strip>>]>>;
197
+ codeowners: z.ZodOptional<z.ZodObject<{
198
+ severity: z.ZodEnum<{
199
+ error: "error";
200
+ info: "info";
201
+ warn: "warn";
202
+ }>;
203
+ message: z.ZodOptional<z.ZodString>;
204
+ }, z.core.$strip>>;
205
+ }, z.core.$strip>>;
206
+ output: z.ZodDefault<z.ZodObject<{
207
+ summary: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"log">, z.ZodLiteral<false>]>>;
208
+ components: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
209
+ chart: "chart";
210
+ table: "table";
211
+ }>, z.ZodLiteral<false>]>>;
212
+ packages: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
213
+ chart: "chart";
214
+ table: "table";
215
+ }>, z.ZodLiteral<false>]>>;
216
+ patterns: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
217
+ chart: "chart";
218
+ table: "table";
219
+ }>, z.ZodLiteral<false>]>>;
220
+ details: z.ZodDefault<z.ZodBoolean>;
221
+ versus: z.ZodDefault<z.ZodBoolean>;
222
+ rules: z.ZodDefault<z.ZodBoolean>;
223
+ format: z.ZodDefault<z.ZodEnum<{
224
+ human: "human";
225
+ json: "json";
226
+ }>>;
227
+ }, z.core.$strip>>;
228
+ releaseAge: z.ZodDefault<z.ZodObject<{
229
+ enabled: z.ZodDefault<z.ZodBoolean>;
230
+ registry: z.ZodDefault<z.ZodString>;
231
+ authToken: z.ZodOptional<z.ZodString>;
232
+ thresholds: z.ZodDefault<z.ZodObject<{
233
+ patch: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
234
+ minor: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
235
+ major: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
236
+ }, z.core.$strip>>;
237
+ enforceOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
238
+ cacheTtlMs: z.ZodOptional<z.ZodNumber>;
239
+ cacheDisabled: z.ZodDefault<z.ZodBoolean>;
240
+ }, z.core.$strip>>;
241
+ }, z.core.$strip>;
242
+ /** Config as returned after parsing — all defaults applied, all fields required */
243
+ type HermexConfig = z.infer<typeof HermexConfigSchema>;
244
+ /** Config as accepted by the user — everything optional */
245
+ type HermexConfigInput = z.input<typeof HermexConfigSchema>;
246
+ type RuleSeverity = z.infer<typeof RuleSeveritySchema>;
247
+ type RuleConfig = z.infer<typeof RuleConfigSchema>;
248
+ type PackageFieldRule = z.infer<typeof PackageFieldRuleSchema>;
249
+ type EngineVersionRule = z.infer<typeof EngineVersionRuleSchema>;
250
+ type CodeownersRule = z.infer<typeof CodeownersRuleSchema>;
251
+ type PackagesConfig = HermexConfig['packages'];
252
+ type VersusConfig = HermexConfig['versus'][number];
253
+ type RulesConfig = HermexConfig['rules'];
254
+ type OutputConfig = HermexConfig['output'];
255
+ type ReleaseAgeConfig = HermexConfig['releaseAge'];
256
+ type ReleaseAgeThresholds = HermexConfig['releaseAge']['thresholds'];
257
+ //#endregion
258
+ //#region src/npm-registry/types.d.ts
259
+ type UpgradeLevel = 'needs_upgrade' | 'mandatory_upgrade';
260
+ type SemverBump = 'patch' | 'minor' | 'major';
261
+ interface AvailableUpgrade {
262
+ version: string;
263
+ releasedDaysAgo: number;
264
+ semverBump: SemverBump;
265
+ level: UpgradeLevel;
266
+ thresholdDays: number;
267
+ isLatest?: boolean;
268
+ }
269
+ /** An upgrade candidate that hasn't yet breached its bump tier's age threshold. */
270
+ interface PendingUpgrade {
271
+ version: string;
272
+ semverBump: SemverBump;
273
+ releasedDaysAgo: number;
274
+ thresholdDays: number;
275
+ daysRemaining: number;
276
+ }
277
+ interface ReleaseAgeEntry {
278
+ installedVersion: string;
279
+ upgrades: AvailableUpgrade[];
280
+ worstLevel: UpgradeLevel | null;
281
+ pendingUpgrade?: PendingUpgrade;
282
+ deprecated?: string;
283
+ latestVersion?: string;
284
+ latestReleasedDaysAgo?: number;
285
+ minCompliantVersion?: string;
286
+ minCompliantReleasedDaysAgo?: number;
287
+ severity: 'error' | 'warn';
288
+ }
289
+ //#endregion
290
+ //#region src/utils/package-distribution.d.ts
291
+ interface ComponentUsage {
292
+ name: string;
293
+ source: string;
294
+ count: number;
295
+ files: Set<string>;
296
+ }
297
+ interface PackageDistribution {
298
+ packageName: string;
299
+ version: string | null;
300
+ componentCount: number;
301
+ usageCount: number;
302
+ percentage: number;
303
+ components: string[];
304
+ internal: boolean;
305
+ hasVersionConflict: boolean;
306
+ allVersions: string[];
307
+ releaseAge?: ReleaseAgeEntry;
308
+ }
309
+ //#endregion
310
+ //#region src/utils/pattern-counter.d.ts
311
+ interface PatternCount {
312
+ patternType: string;
313
+ displayName: string;
314
+ count: number;
315
+ }
316
+ //#endregion
317
+ //#region src/utils/versus.d.ts
318
+ interface VersusEntry {
319
+ packageName: string;
320
+ count: number;
321
+ percentage: number;
322
+ components: string[];
323
+ }
324
+ interface VersusResult {
325
+ name: string;
326
+ packages: string[];
327
+ entries: VersusEntry[];
328
+ totalCount: number;
329
+ }
330
+ //#endregion
331
+ //#region src/rules/shared.d.ts
332
+ interface RuleViolation {
333
+ type: 'detect_files' | 'require_files' | 'require_packages' | 'require_scripts' | 'require_package_fields' | 'forbid_package_fields' | 'engine_version' | 'codeowners';
334
+ severity: 'error' | 'warn' | 'info';
335
+ patterns: string[];
336
+ message?: string;
337
+ matchedFiles: string[];
338
+ installedRange?: string;
339
+ requiredRange?: string;
340
+ fieldPath?: string;
341
+ actualValue?: string;
342
+ }
343
+ //#endregion
344
+ //#region src/utils/package-rules.d.ts
345
+ interface BannedPackageViolation {
346
+ packageName: string;
347
+ severity: 'error' | 'warn' | 'info';
348
+ message?: string;
349
+ }
350
+ //#endregion
351
+ //#region src/index.d.ts
352
+ /**
353
+ * Identity helper for authoring `hermex.config.ts` with full type inference
354
+ * and autocomplete — mirrors the same `defineConfig` convention used by
355
+ * Vite, ESLint's flat config, and Vitest. Returns its argument unchanged;
356
+ * `loadConfig` (`src/config/loader.ts`) accepts a plain object default
357
+ * export either way, so this is purely a DX affordance, not a requirement.
358
+ */
359
+ declare function defineConfig(config: HermexConfigInput): HermexConfigInput;
360
+ /** Shape of a single entry in `components` — same as `ComponentUsage`, but with `files` as an array (JSON has no `Set`) */
361
+ interface HermexScanComponent extends Omit<ComponentUsage, 'files'> {
362
+ files: string[];
363
+ }
364
+ /** Shape of the JSON emitted by `hermex scan --format json` (see `printJson`) */
365
+ interface HermexScanResult {
366
+ version: string;
367
+ summary: {
368
+ filesAnalyzed: number;
369
+ totalImports: number;
370
+ totalComponents: number;
371
+ totalUsagePatterns: number;
372
+ };
373
+ packages: PackageDistribution[];
374
+ components: HermexScanComponent[];
375
+ patterns: PatternCount[];
376
+ versus: VersusResult[];
377
+ ruleViolations: RuleViolation[];
378
+ bannedPackageViolations: BannedPackageViolation[];
379
+ }
380
+ //#endregion
381
+ export { type BannedPackageViolation, type CodeownersRule, type ComponentUsage, type EngineVersionRule, type HermexConfig, type HermexConfigInput, HermexScanComponent, HermexScanResult, type OutputConfig, type PackageDistribution, type PackageFieldRule, type PackagesConfig, type PatternCount, type ReleaseAgeConfig, type ReleaseAgeThresholds, type RuleConfig, type RuleSeverity, type RuleViolation, type RulesConfig, type VersusConfig, type VersusEntry, type VersusResult, defineConfig };
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ //#region src/index.ts
2
+ /**
3
+ * Identity helper for authoring `hermex.config.ts` with full type inference
4
+ * and autocomplete — mirrors the same `defineConfig` convention used by
5
+ * Vite, ESLint's flat config, and Vitest. Returns its argument unchanged;
6
+ * `loadConfig` (`src/config/loader.ts`) accepts a plain object default
7
+ * export either way, so this is purely a DX affordance, not a requirement.
8
+ */
9
+ function defineConfig(config) {
10
+ return config;
11
+ }
12
+ //#endregion
13
+ export { defineConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermex",
3
- "version": "1.3.0-beta.4",
3
+ "version": "2.0.0-beta.10",
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/cli.mjs",
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",
@@ -77,5 +84,10 @@
77
84
  },
78
85
  "engines": {
79
86
  "node": ">=24.11.1"
87
+ },
88
+ "pnpm": {
89
+ "overrides": {
90
+ "micromatch>picomatch": "^2.3.2"
91
+ }
80
92
  }
81
93
  }