@angular-modernizer/plugin-system 0.3.0 → 1.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 +127 -203
- package/dist/contexts.d.ts +5 -12
- package/dist/contexts.js +0 -12
- package/dist/index.d.ts +11 -6
- package/dist/index.js +11 -6
- package/dist/plugin-interface.d.ts +14 -12
- package/dist/plugin-interface.js +0 -12
- package/package.json +8 -13
- package/dist/contexts.d.ts.map +0 -1
- package/dist/contexts.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin-interface.d.ts.map +0 -1
- package/dist/plugin-interface.js.map +0 -1
- package/src/contexts.ts +0 -223
- package/src/index.ts +0 -33
- package/src/plugin-interface.ts +0 -359
package/src/plugin-interface.ts
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system - Plugin Interface
|
|
3
|
-
*
|
|
4
|
-
* Core contracts for the plugin ecosystem. This defines how plugins
|
|
5
|
-
* integrate with the Angular Modernization Platform.
|
|
6
|
-
*
|
|
7
|
-
* Design Philosophy: "API-Driven Plugins"
|
|
8
|
-
* - Plugins are powerless on their own
|
|
9
|
-
* - They receive capabilities through Context objects
|
|
10
|
-
* - The Context contains the PublicApi with all tools
|
|
11
|
-
* - This ensures plugins use battle-tested, reusable logic
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
AnalysisContext,
|
|
16
|
-
TransformContext,
|
|
17
|
-
ValidationContext,
|
|
18
|
-
} from './contexts.ts';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Minimal Kernel interface to avoid circular dependency.
|
|
22
|
-
* The actual Kernel implementation is in @angular-modernizer/core.
|
|
23
|
-
*
|
|
24
|
-
* Exposes a single accessor method for the project root, derived from
|
|
25
|
-
* tsConfigPath (if set) via path.dirname, or process.cwd() as a fallback.
|
|
26
|
-
* Safe to call during plugin.initialize() before Kernel.initialize() completes.
|
|
27
|
-
*/
|
|
28
|
-
export interface IKernel {
|
|
29
|
-
readonly __brand?: 'Kernel';
|
|
30
|
-
getProjectRoot(): string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Core plugin interface.
|
|
35
|
-
* Every plugin must implement this interface to integrate with the platform.
|
|
36
|
-
*/
|
|
37
|
-
export interface Plugin {
|
|
38
|
-
/**
|
|
39
|
-
* Unique plugin identifier.
|
|
40
|
-
* Must be unique across all plugins in the system.
|
|
41
|
-
*/
|
|
42
|
-
readonly name: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Plugin version (semantic versioning recommended).
|
|
46
|
-
*/
|
|
47
|
-
readonly version: string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Plugin description for documentation and tooling.
|
|
51
|
-
*/
|
|
52
|
-
readonly description?: string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Plugin author information.
|
|
56
|
-
*/
|
|
57
|
-
readonly author?: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Initialize the plugin.
|
|
61
|
-
* Called once during Kernel initialization.
|
|
62
|
-
*
|
|
63
|
-
* @param kernel - The Kernel instance for accessing infrastructure
|
|
64
|
-
* @throws Error if initialization fails
|
|
65
|
-
*/
|
|
66
|
-
initialize(kernel: IKernel): Promise<void>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get all analysis rules provided by this plugin.
|
|
70
|
-
* Analysis rules examine code and report violations/insights.
|
|
71
|
-
*
|
|
72
|
-
* @returns Array of analysis rules
|
|
73
|
-
*/
|
|
74
|
-
getAnalysisRules(): AnalysisRule[];
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get all transformation rules provided by this plugin.
|
|
78
|
-
* Transformation rules modify code to fix violations or modernize patterns.
|
|
79
|
-
*
|
|
80
|
-
* @returns Array of transformation rules
|
|
81
|
-
*/
|
|
82
|
-
getTransformRules(): TransformRule[];
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get all validation rules provided by this plugin.
|
|
86
|
-
* Validation rules verify that transformations were successful.
|
|
87
|
-
*
|
|
88
|
-
* @returns Array of validation rules
|
|
89
|
-
*/
|
|
90
|
-
getValidationRules(): ValidationRule[];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Analysis Rule - examines code and reports findings.
|
|
95
|
-
*
|
|
96
|
-
* Analysis rules are READ-ONLY. They must never modify code.
|
|
97
|
-
* Their purpose is to identify patterns, violations, and opportunities.
|
|
98
|
-
*/
|
|
99
|
-
export interface AnalysisRule {
|
|
100
|
-
/**
|
|
101
|
-
* Unique rule identifier (scoped to plugin).
|
|
102
|
-
* Format: "plugin-name:rule-name" (e.g., "angular-standalone:component-not-standalone")
|
|
103
|
-
*/
|
|
104
|
-
readonly id: string;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Human-readable rule name.
|
|
108
|
-
*/
|
|
109
|
-
readonly name: string;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Rule description explaining what it checks.
|
|
113
|
-
*/
|
|
114
|
-
readonly description: string;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Rule severity level.
|
|
118
|
-
*/
|
|
119
|
-
readonly severity: 'error' | 'warning' | 'info';
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Rule category for grouping.
|
|
123
|
-
*/
|
|
124
|
-
readonly category: string;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Tags for filtering and search.
|
|
128
|
-
*/
|
|
129
|
-
readonly tags?: string[];
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Analyze a source file and return findings.
|
|
133
|
-
*
|
|
134
|
-
* @param context - Analysis context with file, project, and API access
|
|
135
|
-
* @returns Promise resolving to array of analysis results
|
|
136
|
-
*/
|
|
137
|
-
analyze(context: AnalysisContext): Promise<AnalysisResult[]>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Result from an analysis rule execution.
|
|
142
|
-
*/
|
|
143
|
-
export interface AnalysisResult {
|
|
144
|
-
/**
|
|
145
|
-
* Rule that produced this result.
|
|
146
|
-
*/
|
|
147
|
-
ruleId: string;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Result message for display.
|
|
151
|
-
*/
|
|
152
|
-
message: string;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* File path where the issue was found.
|
|
156
|
-
*/
|
|
157
|
-
filePath: string;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Line number (1-indexed) where the issue starts.
|
|
161
|
-
*/
|
|
162
|
-
line?: number;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Column number (0-indexed) where the issue starts.
|
|
166
|
-
*/
|
|
167
|
-
column?: number;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Suggested fix (if applicable).
|
|
171
|
-
*/
|
|
172
|
-
suggestedFix?: string;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Additional metadata.
|
|
176
|
-
*/
|
|
177
|
-
metadata?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Transform Rule - modifies code to fix issues or modernize patterns.
|
|
182
|
-
*
|
|
183
|
-
* Transform rules are WRITE operations. They must be:
|
|
184
|
-
* - Idempotent: Running twice should be safe
|
|
185
|
-
* - Atomic: Either fully succeed or fully fail
|
|
186
|
-
* - Reversible: Should not cause data loss
|
|
187
|
-
*/
|
|
188
|
-
export interface TransformRule {
|
|
189
|
-
/**
|
|
190
|
-
* Unique rule identifier (scoped to plugin).
|
|
191
|
-
*/
|
|
192
|
-
readonly id: string;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Human-readable rule name.
|
|
196
|
-
*/
|
|
197
|
-
readonly name: string;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Rule description explaining what it does.
|
|
201
|
-
*/
|
|
202
|
-
readonly description: string;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Rule category for grouping.
|
|
206
|
-
*/
|
|
207
|
-
readonly category: string;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Tags for filtering and search.
|
|
211
|
-
*/
|
|
212
|
-
readonly tags?: string[];
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Transform a source file.
|
|
216
|
-
*
|
|
217
|
-
* @param context - Transform context with file, project, and API access
|
|
218
|
-
* @returns Promise resolving to transform result
|
|
219
|
-
*/
|
|
220
|
-
transform(context: TransformContext): Promise<TransformResult>;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Result from a transform rule execution.
|
|
225
|
-
*/
|
|
226
|
-
export interface TransformResult {
|
|
227
|
-
/**
|
|
228
|
-
* Rule that produced this result.
|
|
229
|
-
*/
|
|
230
|
-
ruleId: string;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Whether the file was modified.
|
|
234
|
-
*/
|
|
235
|
-
modified: boolean;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Human-readable message describing what was done.
|
|
239
|
-
*/
|
|
240
|
-
message: string;
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* File path that was transformed.
|
|
244
|
-
*/
|
|
245
|
-
filePath: string;
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Number of changes made.
|
|
249
|
-
*/
|
|
250
|
-
changeCount?: number;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Additional metadata.
|
|
254
|
-
*/
|
|
255
|
-
metadata?: Record<string, unknown>;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Validation Rule - verifies that code meets requirements.
|
|
260
|
-
*
|
|
261
|
-
* Validation rules are READ-ONLY checks that run after transformations
|
|
262
|
-
* to ensure correctness. They're like analysis rules, but focused on
|
|
263
|
-
* post-transformation verification.
|
|
264
|
-
*/
|
|
265
|
-
export interface ValidationRule {
|
|
266
|
-
/**
|
|
267
|
-
* Unique rule identifier (scoped to plugin).
|
|
268
|
-
*/
|
|
269
|
-
readonly id: string;
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Human-readable rule name.
|
|
273
|
-
*/
|
|
274
|
-
readonly name: string;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Rule description explaining what it validates.
|
|
278
|
-
*/
|
|
279
|
-
readonly description: string;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Rule category for grouping.
|
|
283
|
-
*/
|
|
284
|
-
readonly category: string;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Validate a source file.
|
|
288
|
-
*
|
|
289
|
-
* @param context - Validation context with file, project, and API access
|
|
290
|
-
* @returns Promise resolving to validation result
|
|
291
|
-
*/
|
|
292
|
-
validate(context: ValidationContext): Promise<ValidationResult>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Result from a validation rule execution.
|
|
297
|
-
*/
|
|
298
|
-
export interface ValidationResult {
|
|
299
|
-
/**
|
|
300
|
-
* Rule that produced this result.
|
|
301
|
-
*/
|
|
302
|
-
ruleId: string;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Whether validation passed.
|
|
306
|
-
*/
|
|
307
|
-
passed: boolean;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Validation message.
|
|
311
|
-
*/
|
|
312
|
-
message: string;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* File path that was validated.
|
|
316
|
-
*/
|
|
317
|
-
filePath: string;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Additional details if validation failed.
|
|
321
|
-
*/
|
|
322
|
-
details?: string;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Additional metadata.
|
|
326
|
-
*/
|
|
327
|
-
metadata?: Record<string, unknown>;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Plugin lifecycle events.
|
|
332
|
-
* Plugins can optionally implement these hooks for advanced scenarios.
|
|
333
|
-
*/
|
|
334
|
-
export interface PluginLifecycle {
|
|
335
|
-
/**
|
|
336
|
-
* Called before analysis begins.
|
|
337
|
-
*/
|
|
338
|
-
onBeforeAnalysis?(): Promise<void>;
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Called after analysis completes.
|
|
342
|
-
*/
|
|
343
|
-
onAfterAnalysis?(): Promise<void>;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Called before transformations begin.
|
|
347
|
-
*/
|
|
348
|
-
onBeforeTransform?(): Promise<void>;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Called after transformations complete.
|
|
352
|
-
*/
|
|
353
|
-
onAfterTransform?(): Promise<void>;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Called when the plugin is being shut down.
|
|
357
|
-
*/
|
|
358
|
-
onShutdown?(): Promise<void>;
|
|
359
|
-
}
|