@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
|
@@ -1,15 +1,3 @@
|
|
|
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
1
|
import type { AnalysisContext, TransformContext, ValidationContext } from './contexts.ts';
|
|
14
2
|
/**
|
|
15
3
|
* Minimal Kernel interface to avoid circular dependency.
|
|
@@ -20,12 +8,21 @@ import type { AnalysisContext, TransformContext, ValidationContext } from './con
|
|
|
20
8
|
* Safe to call during plugin.initialize() before Kernel.initialize() completes.
|
|
21
9
|
*/
|
|
22
10
|
export interface IKernel {
|
|
11
|
+
/** Optional type marker; the kernel does not set it. */
|
|
23
12
|
readonly __brand?: 'Kernel';
|
|
13
|
+
/**
|
|
14
|
+
* Returns the project root: the directory of `tsConfigPath` when set,
|
|
15
|
+
* otherwise `process.cwd()`.
|
|
16
|
+
*/
|
|
24
17
|
getProjectRoot(): string;
|
|
25
18
|
}
|
|
26
19
|
/**
|
|
27
20
|
* Core plugin interface.
|
|
28
21
|
* Every plugin must implement this interface to integrate with the platform.
|
|
22
|
+
*
|
|
23
|
+
* A plugin only groups rules. The rules get their capabilities through the
|
|
24
|
+
* context objects ({@link AnalysisContext}, {@link TransformContext},
|
|
25
|
+
* {@link ValidationContext}), which carry the public API.
|
|
29
26
|
*/
|
|
30
27
|
export interface Plugin {
|
|
31
28
|
/**
|
|
@@ -143,6 +140,11 @@ export interface AnalysisResult {
|
|
|
143
140
|
* Suggested fix (if applicable).
|
|
144
141
|
*/
|
|
145
142
|
suggestedFix?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Severity of this finding when it differs from the rule severity
|
|
145
|
+
* (e.g. an informational hint from a rule whose findings are errors).
|
|
146
|
+
*/
|
|
147
|
+
severity?: 'error' | 'warning' | 'info';
|
|
146
148
|
/**
|
|
147
149
|
* Additional metadata.
|
|
148
150
|
*/
|
package/dist/plugin-interface.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
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
1
|
export {};
|
|
14
2
|
//# sourceMappingURL=plugin-interface.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-modernizer/plugin-system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Plugin infrastructure for the Angular Modernization Platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -11,13 +11,8 @@
|
|
|
11
11
|
"plugin-system"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"url": "git+https://github.com/eiweiss/tsanalyzer.git",
|
|
17
|
-
"directory": "packages/plugin-system"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://github.com/eiweiss/tsanalyzer#readme",
|
|
20
|
-
"bugs": "https://github.com/eiweiss/tsanalyzer/issues",
|
|
14
|
+
"author": "Christian Weiss",
|
|
15
|
+
"homepage": "https://eiweiss.github.io/angular-modernizer-docs/",
|
|
21
16
|
"type": "module",
|
|
22
17
|
"main": "./dist/index.js",
|
|
23
18
|
"types": "./dist/index.d.ts",
|
|
@@ -30,17 +25,14 @@
|
|
|
30
25
|
},
|
|
31
26
|
"files": [
|
|
32
27
|
"dist",
|
|
33
|
-
"src",
|
|
34
28
|
"!dist/**/__tests__/**",
|
|
35
|
-
"!
|
|
36
|
-
"!src/**/*.test.ts",
|
|
37
|
-
"!src/**/*.spec.ts"
|
|
29
|
+
"!dist/**/*.map"
|
|
38
30
|
],
|
|
39
31
|
"dependencies": {
|
|
40
32
|
"ts-morph": "^27.0.2"
|
|
41
33
|
},
|
|
42
34
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
35
|
+
"@types/node": "^20.19.0",
|
|
44
36
|
"rimraf": "^6.1.0",
|
|
45
37
|
"typescript": "^5.9.3"
|
|
46
38
|
},
|
|
@@ -53,6 +45,9 @@
|
|
|
53
45
|
],
|
|
54
46
|
"tsconfig": "./tsconfig.json"
|
|
55
47
|
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
50
|
+
},
|
|
56
51
|
"scripts": {
|
|
57
52
|
"build": "tsc --build",
|
|
58
53
|
"test": "jest --passWithNoTests",
|
package/dist/contexts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../src/contexts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,GAAG,aAAa;IAC/C;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,aAAa,CACnD,SAAQ,WAAW,CAAC,IAAI,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE;QACjB;;;WAGG;QACH,IAAI,CAAC,EAAE,OAAO,CAAC;QAEf;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,aAAa,CACpD,SAAQ,WAAW,CAAC,IAAI,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,E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AAC,uBAAuB,CAAuB,MAMpD;QACC,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;YAC3B,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE;YACzC,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,OAAO,GACR,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuBH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-interface.d.ts","sourceRoot":"","sources":["../src/plugin-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,CAAC,E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,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,eAAe,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;OAEG;IACH,iBAAiB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC;;OAEG;IACH,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-interface.js","sourceRoot":"","sources":["../src/plugin-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
package/src/contexts.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system - Context Objects
|
|
3
|
-
*
|
|
4
|
-
* Context objects are the mechanism by which we pass capabilities to plugins.
|
|
5
|
-
* They contain the PublicApi and provide scoped access to the codebase.
|
|
6
|
-
*
|
|
7
|
-
* Design Philosophy: "Context is the API Gateway"
|
|
8
|
-
* - Plugins receive a context object, not raw infrastructure
|
|
9
|
-
* - Context contains the PublicApi with battle-tested helpers
|
|
10
|
-
* - Context is immutable and scoped to a single operation
|
|
11
|
-
* - This enforces plugins to use standardized, high-quality tools
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { Project, SourceFile } from 'ts-morph';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generic type for the Public API.
|
|
18
|
-
* The actual PublicApi interface is defined in `@angular-modernizer/api`.
|
|
19
|
-
* Uses `any` here to avoid circular dependencies between packages.
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
export type PublicApiType = any;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base context shared by all plugin operations.
|
|
26
|
-
* Contains common elements needed across analysis, transformation, and validation.
|
|
27
|
-
*/
|
|
28
|
-
export interface BaseContext<TApi = PublicApiType> {
|
|
29
|
-
/**
|
|
30
|
-
* The source file being operated on.
|
|
31
|
-
* This is the primary entry point for all plugin operations.
|
|
32
|
-
*/
|
|
33
|
-
readonly sourceFile: SourceFile;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The ts-morph Project instance.
|
|
37
|
-
* Provides access to the entire codebase for cross-file analysis.
|
|
38
|
-
*/
|
|
39
|
-
readonly project: Project;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The Public API - the plugin's toolbox.
|
|
43
|
-
* Contains all high-level helpers for analysis and transformation.
|
|
44
|
-
*
|
|
45
|
-
* This is THE critical design decision:
|
|
46
|
-
* Plugins don't implement low-level logic. They consume the API.
|
|
47
|
-
*/
|
|
48
|
-
readonly api: TApi;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Plugin-specific configuration.
|
|
52
|
-
* Allows users to customize plugin behavior.
|
|
53
|
-
*/
|
|
54
|
-
readonly config: Record<string, unknown>;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* File path for convenience (derived from sourceFile).
|
|
58
|
-
*/
|
|
59
|
-
readonly filePath: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Context for analysis operations.
|
|
64
|
-
* Passed to AnalysisRule.analyze() methods.
|
|
65
|
-
*
|
|
66
|
-
* Analysis contexts are READ-ONLY. They must not modify code.
|
|
67
|
-
*/
|
|
68
|
-
export interface AnalysisContext<TApi = PublicApiType>
|
|
69
|
-
extends BaseContext<TApi> {
|
|
70
|
-
/**
|
|
71
|
-
* Type discriminator for type safety.
|
|
72
|
-
*/
|
|
73
|
-
readonly type: 'analysis';
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Analysis-specific options.
|
|
77
|
-
*/
|
|
78
|
-
readonly options?: {
|
|
79
|
-
/**
|
|
80
|
-
* Whether to perform deep analysis (cross-file).
|
|
81
|
-
* Default: false (single-file analysis only)
|
|
82
|
-
*/
|
|
83
|
-
deep?: boolean;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Maximum depth for cross-file analysis.
|
|
87
|
-
* Only relevant if deep=true.
|
|
88
|
-
*/
|
|
89
|
-
maxDepth?: number;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Context for transformation operations.
|
|
95
|
-
* Passed to TransformRule.transform() methods.
|
|
96
|
-
*
|
|
97
|
-
* Transform contexts allow WRITE operations.
|
|
98
|
-
* Plugins can modify the sourceFile through ts-morph APIs.
|
|
99
|
-
*/
|
|
100
|
-
export interface TransformContext<TApi = PublicApiType>
|
|
101
|
-
extends BaseContext<TApi> {
|
|
102
|
-
/**
|
|
103
|
-
* Type discriminator for type safety.
|
|
104
|
-
*/
|
|
105
|
-
readonly type: 'transform';
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Transform-specific options.
|
|
109
|
-
*/
|
|
110
|
-
readonly options?: {
|
|
111
|
-
/**
|
|
112
|
-
* Whether to perform a dry-run (no actual changes).
|
|
113
|
-
* Default: false
|
|
114
|
-
*/
|
|
115
|
-
dryRun?: boolean;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Whether to auto-save changes after transformation.
|
|
119
|
-
* Default: true
|
|
120
|
-
*/
|
|
121
|
-
autoSave?: boolean;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Whether to format code after transformation.
|
|
125
|
-
* Default: true
|
|
126
|
-
*/
|
|
127
|
-
format?: boolean;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Context for validation operations.
|
|
133
|
-
* Passed to ValidationRule.validate() methods.
|
|
134
|
-
*
|
|
135
|
-
* Validation contexts are READ-ONLY post-transformation checks.
|
|
136
|
-
*/
|
|
137
|
-
export interface ValidationContext<TApi = PublicApiType>
|
|
138
|
-
extends BaseContext<TApi> {
|
|
139
|
-
/**
|
|
140
|
-
* Type discriminator for type safety.
|
|
141
|
-
*/
|
|
142
|
-
readonly type: 'validation';
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Validation-specific options.
|
|
146
|
-
*/
|
|
147
|
-
readonly options?: {
|
|
148
|
-
/**
|
|
149
|
-
* Whether to fail fast on first validation error.
|
|
150
|
-
* Default: false (collect all validation errors)
|
|
151
|
-
*/
|
|
152
|
-
failFast?: boolean;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Factory for creating context objects.
|
|
158
|
-
* This is used internally by the orchestration layer.
|
|
159
|
-
*/
|
|
160
|
-
export class ContextFactory {
|
|
161
|
-
/**
|
|
162
|
-
* Create an analysis context.
|
|
163
|
-
*/
|
|
164
|
-
static createAnalysisContext<TApi = PublicApiType>(params: {
|
|
165
|
-
sourceFile: SourceFile;
|
|
166
|
-
project: Project;
|
|
167
|
-
api: TApi;
|
|
168
|
-
config?: Record<string, unknown>;
|
|
169
|
-
options?: AnalysisContext<TApi>['options'];
|
|
170
|
-
}): AnalysisContext<TApi> {
|
|
171
|
-
return {
|
|
172
|
-
type: 'analysis',
|
|
173
|
-
sourceFile: params.sourceFile,
|
|
174
|
-
project: params.project,
|
|
175
|
-
api: params.api,
|
|
176
|
-
config: params.config ?? {},
|
|
177
|
-
filePath: params.sourceFile.getFilePath(),
|
|
178
|
-
options: params.options,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Create a transform context.
|
|
184
|
-
*/
|
|
185
|
-
static createTransformContext<TApi = PublicApiType>(params: {
|
|
186
|
-
sourceFile: SourceFile;
|
|
187
|
-
project: Project;
|
|
188
|
-
api: TApi;
|
|
189
|
-
config?: Record<string, unknown>;
|
|
190
|
-
options?: TransformContext<TApi>['options'];
|
|
191
|
-
}): TransformContext<TApi> {
|
|
192
|
-
return {
|
|
193
|
-
type: 'transform',
|
|
194
|
-
sourceFile: params.sourceFile,
|
|
195
|
-
project: params.project,
|
|
196
|
-
api: params.api,
|
|
197
|
-
config: params.config ?? {},
|
|
198
|
-
filePath: params.sourceFile.getFilePath(),
|
|
199
|
-
options: params.options,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Create a validation context.
|
|
205
|
-
*/
|
|
206
|
-
static createValidationContext<TApi = PublicApiType>(params: {
|
|
207
|
-
sourceFile: SourceFile;
|
|
208
|
-
project: Project;
|
|
209
|
-
api: TApi;
|
|
210
|
-
config?: Record<string, unknown>;
|
|
211
|
-
options?: ValidationContext<TApi>['options'];
|
|
212
|
-
}): ValidationContext<TApi> {
|
|
213
|
-
return {
|
|
214
|
-
type: 'validation',
|
|
215
|
-
sourceFile: params.sourceFile,
|
|
216
|
-
project: params.project,
|
|
217
|
-
api: params.api,
|
|
218
|
-
config: params.config ?? {},
|
|
219
|
-
filePath: params.sourceFile.getFilePath(),
|
|
220
|
-
options: params.options,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @angular-modernizer/plugin-system
|
|
3
|
-
*
|
|
4
|
-
* Plugin infrastructure for the Angular Modernization Platform.
|
|
5
|
-
* This package defines the contracts and interfaces for the plugin ecosystem.
|
|
6
|
-
*
|
|
7
|
-
* Export Strategy: "Export Everything"
|
|
8
|
-
* - All public interfaces are exported through this index
|
|
9
|
-
* - Plugin authors should only import from '@angular-modernizer/plugin-system'
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Plugin interfaces
|
|
13
|
-
export type {
|
|
14
|
-
Plugin,
|
|
15
|
-
AnalysisRule,
|
|
16
|
-
AnalysisResult,
|
|
17
|
-
TransformRule,
|
|
18
|
-
TransformResult,
|
|
19
|
-
ValidationRule,
|
|
20
|
-
ValidationResult,
|
|
21
|
-
PluginLifecycle,
|
|
22
|
-
IKernel,
|
|
23
|
-
} from './plugin-interface.js';
|
|
24
|
-
|
|
25
|
-
// Context objects
|
|
26
|
-
export type {
|
|
27
|
-
BaseContext,
|
|
28
|
-
AnalysisContext,
|
|
29
|
-
TransformContext,
|
|
30
|
-
ValidationContext,
|
|
31
|
-
} from './contexts.js';
|
|
32
|
-
|
|
33
|
-
export { ContextFactory } from './contexts.js';
|