@angular-modernizer/plugin-analyzer 1.0.0 → 1.2.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 +82 -205
- package/dist/index.d.ts +8 -12
- package/dist/index.js +8 -12
- package/dist/rules/framework-detector.rule.d.ts +10 -12
- package/dist/rules/framework-detector.rule.js +11 -13
- package/package.json +5 -11
package/README.md
CHANGED
|
@@ -4,20 +4,17 @@ Framework detection and project structure analysis plugin for the Angular Modern
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
The `@angular-modernizer/plugin-analyzer` package provides analysis rules for
|
|
7
|
+
The `@angular-modernizer/plugin-analyzer` package provides general analysis rules for Angular projects. It currently ships one rule, the framework detector. The `analyze-project` MCP tool runs this plugin (registered under the name `analyzer`).
|
|
8
8
|
|
|
9
9
|
## Architecture
|
|
10
10
|
|
|
11
|
-
This plugin follows the
|
|
11
|
+
This plugin follows the plugin contract from `@angular-modernizer/plugin-system`. The framework detector needs no `PublicApi` tool; it reads the project and its file system from the context:
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
class FrameworkDetectorRule implements AnalysisRule {
|
|
15
|
-
analyze(context: AnalysisContext) {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
const dependencies =
|
|
19
|
-
api.analysis.dependencyAnalyzer.analyzeDependencies(sourceFile);
|
|
20
|
-
// analysis logic
|
|
15
|
+
async analyze(context: AnalysisContext): Promise<AnalysisResult[]> {
|
|
16
|
+
const { project, filePath } = context;
|
|
17
|
+
// checks nx.json and angular.json in the project root
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
```
|
|
@@ -26,78 +23,35 @@ class FrameworkDetectorRule implements AnalysisRule {
|
|
|
26
23
|
|
|
27
24
|
### FrameworkDetectorRule
|
|
28
25
|
|
|
29
|
-
**Rule ID:** `analyzer:framework-
|
|
26
|
+
**Rule ID:** `analyzer:framework-detector`
|
|
30
27
|
|
|
31
|
-
Detects whether a project uses Angular CLI or Nx,
|
|
28
|
+
Detects whether a project uses Angular CLI or Nx from the configuration files in the project root (the directory of the tsconfig, otherwise the directory of the analyzed file).
|
|
32
29
|
|
|
33
30
|
**Detection Priority:**
|
|
34
31
|
|
|
35
|
-
1. Nx
|
|
36
|
-
2. Angular CLI
|
|
37
|
-
3. Unknown
|
|
32
|
+
1. Nx: `nx.json` present
|
|
33
|
+
2. Angular CLI: `angular.json` present
|
|
34
|
+
3. Unknown: neither file present
|
|
38
35
|
|
|
39
36
|
**Example Output:**
|
|
40
37
|
|
|
41
38
|
```json
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
],
|
|
53
|
-
"projectType": "application",
|
|
54
|
-
"technologyStack": {
|
|
55
|
-
"angular": "17.x",
|
|
56
|
-
"typescript": "5.x",
|
|
57
|
-
"rxjs": "7.x"
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
"ruleId": "analyzer:framework-detector",
|
|
42
|
+
"message": "Project uses Angular CLI",
|
|
43
|
+
"filePath": "/path/to/project/src/main.ts",
|
|
44
|
+
"metadata": {
|
|
45
|
+
"framework": "Angular CLI",
|
|
46
|
+
"hasNxConfig": false,
|
|
47
|
+
"hasAngularConfig": true,
|
|
48
|
+
"projectRoot": "/path/to/project"
|
|
58
49
|
}
|
|
59
50
|
}
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Detection Logic:**
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
class FrameworkDetectorRule implements AnalysisRule {
|
|
67
|
-
async analyze(context: AnalysisContext): Promise<AnalysisResult> {
|
|
68
|
-
const { project } = context;
|
|
69
|
-
|
|
70
|
-
const nxIndicators = await this.checkNxIndicators(project);
|
|
71
|
-
const angularIndicators = await this.checkAngularIndicators(project);
|
|
72
|
-
const framework = this.determineFramework(nxIndicators, angularIndicators);
|
|
73
|
-
const structure = await this.analyzeProjectStructure(project);
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
ruleId: this.id,
|
|
77
|
-
violations: [],
|
|
78
|
-
metadata: {
|
|
79
|
-
framework: framework.type,
|
|
80
|
-
confidence: framework.confidence,
|
|
81
|
-
evidence: framework.evidence,
|
|
82
|
-
projectType: structure.type,
|
|
83
|
-
technologyStack: structure.stack,
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
51
|
+
]
|
|
88
52
|
```
|
|
89
53
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
**Rule ID:** `layer-detector`
|
|
93
|
-
|
|
94
|
-
Analyzes project layering and architectural boundaries via directory structure and import patterns.
|
|
95
|
-
|
|
96
|
-
### TechnologyStackAnalyzerRule (Planned)
|
|
97
|
-
|
|
98
|
-
**Rule ID:** `technology-stack-analyzer`
|
|
99
|
-
|
|
100
|
-
Identifies technologies and versions used in the project via `package.json` analysis.
|
|
54
|
+
`framework` is `Nx`, `Angular CLI` or `Unknown`.
|
|
101
55
|
|
|
102
56
|
## Usage Examples
|
|
103
57
|
|
|
@@ -105,6 +59,8 @@ Identifies technologies and versions used in the project via `package.json` anal
|
|
|
105
59
|
|
|
106
60
|
```typescript
|
|
107
61
|
import { Kernel, RealFileSystemAdapter } from '@angular-modernizer/core';
|
|
62
|
+
import { createPublicApi } from '@angular-modernizer/api';
|
|
63
|
+
import { ContextFactory } from '@angular-modernizer/plugin-system';
|
|
108
64
|
import { AnalyzerPlugin } from '@angular-modernizer/plugin-analyzer';
|
|
109
65
|
|
|
110
66
|
const kernel = new Kernel({
|
|
@@ -115,29 +71,28 @@ const kernel = new Kernel({
|
|
|
115
71
|
|
|
116
72
|
await kernel.initialize();
|
|
117
73
|
|
|
118
|
-
const plugin = kernel.getPlugin('
|
|
119
|
-
const
|
|
120
|
-
|
|
74
|
+
const plugin = kernel.getPlugin('analyzer')!;
|
|
75
|
+
const frameworkRule = plugin
|
|
76
|
+
.getAnalysisRules()
|
|
77
|
+
.find((r) => r.id === 'analyzer:framework-detector')!;
|
|
121
78
|
|
|
122
79
|
const project = kernel.getProject();
|
|
123
|
-
const sourceFile = project.
|
|
80
|
+
const sourceFile = project.getSourceFiles()[0]!;
|
|
124
81
|
|
|
125
82
|
const context = ContextFactory.createAnalysisContext({
|
|
126
83
|
sourceFile,
|
|
127
84
|
project,
|
|
128
|
-
api: createPublicApi(),
|
|
129
|
-
config: {},
|
|
85
|
+
api: createPublicApi(project),
|
|
130
86
|
});
|
|
131
87
|
|
|
132
|
-
const result = await frameworkRule.analyze(context);
|
|
88
|
+
const [result] = await frameworkRule.analyze(context);
|
|
133
89
|
|
|
134
|
-
console.log('Framework detected:', result
|
|
135
|
-
console.log('Confidence:', result.metadata.confidence);
|
|
90
|
+
console.log('Framework detected:', result?.metadata?.framework);
|
|
136
91
|
```
|
|
137
92
|
|
|
138
93
|
### MCP Tool Integration
|
|
139
94
|
|
|
140
|
-
|
|
95
|
+
The `analyze-project` MCP tool creates a kernel with `AnalyzerPlugin` and runs its rules over the project files; with `includeDetails` the rule findings are returned in `results`. Framework, architecture and technology stack in the tool result are detected by the tool itself:
|
|
141
96
|
|
|
142
97
|
```typescript
|
|
143
98
|
const analysis = await callTool('analyze-project', {
|
|
@@ -145,75 +100,15 @@ const analysis = await callTool('analyze-project', {
|
|
|
145
100
|
includeDetails: true,
|
|
146
101
|
});
|
|
147
102
|
|
|
148
|
-
//
|
|
103
|
+
// structuredContent (abridged)
|
|
149
104
|
{
|
|
150
|
-
"framework": "
|
|
151
|
-
"architecture": {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"confidence": 0.98
|
|
155
|
-
},
|
|
156
|
-
"technologyStack": {
|
|
157
|
-
"angular": "17.0.0",
|
|
158
|
-
"nx": "16.0.0",
|
|
159
|
-
"typescript": "5.1.0"
|
|
160
|
-
},
|
|
161
|
-
"migrationReadiness": {
|
|
162
|
-
"standaloneComponents": 0.75,
|
|
163
|
-
"modernSyntax": 0.60,
|
|
164
|
-
"overall": 0.68
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Configuration Options
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
interface FrameworkDetectorConfig {
|
|
173
|
-
/**
|
|
174
|
-
* Minimum confidence threshold for framework detection.
|
|
175
|
-
* Default: 0.5
|
|
176
|
-
*/
|
|
177
|
-
minConfidence?: number;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Include detailed evidence in results.
|
|
181
|
-
* Default: true
|
|
182
|
-
*/
|
|
183
|
-
includeEvidence?: boolean;
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Custom framework indicators.
|
|
187
|
-
*/
|
|
188
|
-
customIndicators?: FrameworkIndicators;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
interface FrameworkIndicators {
|
|
192
|
-
angular: string[];
|
|
193
|
-
nx: string[];
|
|
194
|
-
custom: Record<string, string[]>;
|
|
105
|
+
"framework": { "detected": true, "type": "...", "confidence": 0.9, "indicators": ["..."] },
|
|
106
|
+
"architecture": { "pattern": "...", "confidence": 0.8, "layers": [] },
|
|
107
|
+
"technologyStack": { "languages": [], "frameworks": [], "buildTools": [], "packageManager": "pnpm" },
|
|
108
|
+
"results": [{ "ruleId": "analyzer:framework-detector", "message": "...", "filePath": "..." }]
|
|
195
109
|
}
|
|
196
110
|
```
|
|
197
111
|
|
|
198
|
-
### Example Configuration
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
const context = ContextFactory.createAnalysisContext({
|
|
202
|
-
sourceFile,
|
|
203
|
-
project,
|
|
204
|
-
api: createPublicApi(),
|
|
205
|
-
config: {
|
|
206
|
-
minConfidence: 0.8,
|
|
207
|
-
includeEvidence: true,
|
|
208
|
-
customIndicators: {
|
|
209
|
-
custom: {
|
|
210
|
-
'my-framework': ['my-framework.json', 'custom-config.js'],
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
```
|
|
216
|
-
|
|
217
112
|
## Package Structure
|
|
218
113
|
|
|
219
114
|
```
|
|
@@ -221,15 +116,10 @@ packages/plugin-analyzer/
|
|
|
221
116
|
src/
|
|
222
117
|
rules/
|
|
223
118
|
framework-detector.rule.ts
|
|
224
|
-
|
|
225
|
-
technology-stack-analyzer.rule.ts (planned)
|
|
226
|
-
analyzer-plugin.ts
|
|
227
|
-
index.ts
|
|
228
|
-
types.ts
|
|
119
|
+
index.ts # AnalyzerPlugin, FrameworkDetectorRule
|
|
229
120
|
__tests__/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
analyzer-plugin.test.ts
|
|
121
|
+
framework-detector.rule.test.ts
|
|
122
|
+
fixtures/
|
|
233
123
|
package.json
|
|
234
124
|
tsconfig.json
|
|
235
125
|
jest.config.js
|
|
@@ -240,7 +130,7 @@ packages/plugin-analyzer/
|
|
|
240
130
|
|
|
241
131
|
```bash
|
|
242
132
|
pnpm --filter @angular-modernizer/plugin-analyzer test
|
|
243
|
-
pnpm --filter @angular-modernizer/plugin-analyzer test --coverage
|
|
133
|
+
pnpm --filter @angular-modernizer/plugin-analyzer test -- --coverage
|
|
244
134
|
```
|
|
245
135
|
|
|
246
136
|
### Test Fixtures
|
|
@@ -249,56 +139,52 @@ pnpm --filter @angular-modernizer/plugin-analyzer test --coverage
|
|
|
249
139
|
__tests__/fixtures/
|
|
250
140
|
sample-angular-cli-app/
|
|
251
141
|
angular.json
|
|
252
|
-
|
|
142
|
+
tsconfig.json
|
|
253
143
|
src/main.ts
|
|
254
144
|
sample-nx-app/
|
|
255
145
|
nx.json
|
|
256
|
-
|
|
257
|
-
|
|
146
|
+
tsconfig.json
|
|
147
|
+
src/main.ts
|
|
258
148
|
sample-unknown-app/
|
|
259
|
-
|
|
149
|
+
tsconfig.json
|
|
150
|
+
src/main.ts
|
|
151
|
+
sample-app/
|
|
152
|
+
legacy.component.ts
|
|
153
|
+
legacy.directive.ts
|
|
154
|
+
modern.component.ts
|
|
260
155
|
```
|
|
261
156
|
|
|
262
157
|
### Test Example
|
|
263
158
|
|
|
264
159
|
```typescript
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
rule = new FrameworkDetectorRule();
|
|
270
|
-
});
|
|
160
|
+
import { Kernel } from '@angular-modernizer/core';
|
|
161
|
+
import { ContextFactory } from '@angular-modernizer/plugin-system';
|
|
162
|
+
import { AnalyzerPlugin } from '../src/index.js';
|
|
163
|
+
import { resolve } from 'path';
|
|
271
164
|
|
|
165
|
+
describe('FrameworkDetectorRule', () => {
|
|
272
166
|
it('should detect Angular CLI project', async () => {
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
sourceFile: project.getSourceFile('package.json')!,
|
|
278
|
-
project,
|
|
279
|
-
api: createPublicApi(),
|
|
167
|
+
const plugin = new AnalyzerPlugin();
|
|
168
|
+
const kernel = new Kernel({
|
|
169
|
+
tsConfigPath: resolve(__dirname, './fixtures/sample-angular-cli-app/tsconfig.json'),
|
|
170
|
+
plugins: [plugin],
|
|
280
171
|
});
|
|
172
|
+
await kernel.initialize();
|
|
281
173
|
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('should detect Nx project', async () => {
|
|
289
|
-
const project = new Project();
|
|
290
|
-
project.addSourceFilesAtPaths('__tests__/fixtures/sample-nx-app/**/*');
|
|
174
|
+
const project = kernel.getProject();
|
|
175
|
+
const rule = plugin
|
|
176
|
+
.getAnalysisRules()
|
|
177
|
+
.find((r) => r.id === 'analyzer:framework-detector')!;
|
|
291
178
|
|
|
292
179
|
const context = ContextFactory.createAnalysisContext({
|
|
293
|
-
sourceFile: project.
|
|
180
|
+
sourceFile: project.getSourceFiles()[0]!,
|
|
294
181
|
project,
|
|
295
|
-
api:
|
|
182
|
+
api: {},
|
|
296
183
|
});
|
|
297
184
|
|
|
298
|
-
const result = await rule.analyze(context);
|
|
185
|
+
const [result] = await rule.analyze(context);
|
|
299
186
|
|
|
300
|
-
expect(result
|
|
301
|
-
expect(result.metadata.confidence).toBeGreaterThan(0.9);
|
|
187
|
+
expect(result?.metadata?.framework).toBe('Angular CLI');
|
|
302
188
|
});
|
|
303
189
|
});
|
|
304
190
|
```
|
|
@@ -313,44 +199,35 @@ describe('FrameworkDetectorRule', () => {
|
|
|
313
199
|
|
|
314
200
|
When adding new analysis rules:
|
|
315
201
|
|
|
316
|
-
1. Follow the `AnalysisRule` interface
|
|
317
|
-
2. Use `PublicApi` tools
|
|
202
|
+
1. Follow the `AnalysisRule` interface: implement all required members
|
|
203
|
+
2. Use `PublicApi` tools: do not implement low-level AST logic directly
|
|
318
204
|
3. Include comprehensive tests using real fixtures where possible
|
|
319
|
-
4. Provide meaningful metadata
|
|
205
|
+
4. Provide meaningful metadata
|
|
320
206
|
5. Update this README with configuration options
|
|
321
207
|
|
|
322
208
|
### Adding a New Analysis Rule
|
|
323
209
|
|
|
324
210
|
```typescript
|
|
325
|
-
// 1. Implement the rule
|
|
211
|
+
// 1. Implement the rule in src/rules/
|
|
326
212
|
class MyAnalysisRule implements AnalysisRule {
|
|
327
|
-
readonly id = 'my-analysis';
|
|
213
|
+
readonly id = 'analyzer:my-analysis';
|
|
328
214
|
readonly name = 'My Analysis Rule';
|
|
329
215
|
readonly description = 'Analyzes something specific';
|
|
216
|
+
readonly severity = 'info' as const;
|
|
217
|
+
readonly category = 'project-analysis';
|
|
330
218
|
|
|
331
|
-
async analyze(context: AnalysisContext): Promise<AnalysisResult> {
|
|
332
|
-
const { api, sourceFile } = context;
|
|
333
|
-
|
|
334
|
-
const findings = await api.analysis.someTool.analyze(sourceFile);
|
|
219
|
+
async analyze(context: AnalysisContext): Promise<AnalysisResult[]> {
|
|
220
|
+
const { api, sourceFile, filePath } = context;
|
|
221
|
+
const usesInject = api.transformation.importManager.hasImport(sourceFile, 'inject', '@angular/core');
|
|
335
222
|
|
|
336
|
-
return {
|
|
337
|
-
ruleId: this.id,
|
|
338
|
-
violations: [],
|
|
339
|
-
metadata: {
|
|
340
|
-
findings,
|
|
341
|
-
confidence: 0.9,
|
|
342
|
-
},
|
|
343
|
-
};
|
|
223
|
+
return [{ ruleId: this.id, message: `inject imported: ${usesInject}`, filePath }];
|
|
344
224
|
}
|
|
345
225
|
}
|
|
346
226
|
|
|
347
|
-
// 2. Add to plugin
|
|
227
|
+
// 2. Add to the plugin (src/index.ts)
|
|
348
228
|
class AnalyzerPlugin implements Plugin {
|
|
349
229
|
getAnalysisRules(): AnalysisRule[] {
|
|
350
|
-
return [
|
|
351
|
-
new FrameworkDetectorRule(),
|
|
352
|
-
new MyAnalysisRule(),
|
|
353
|
-
];
|
|
230
|
+
return [this.frameworkDetectorRule, new MyAnalysisRule()];
|
|
354
231
|
}
|
|
355
232
|
}
|
|
356
233
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Project-level analysis plugin for the Angular Modernizer.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* {@link AnalyzerPlugin} registers {@link FrameworkDetectorRule}, which
|
|
5
|
+
* reports whether the project is an Angular CLI or an Nx workspace. The rules
|
|
6
|
+
* of this plugin only report; they never modify code.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* - Analysis rules run first to understand the codebase
|
|
9
|
-
* - They provide insights that guide transformation decisions
|
|
10
|
-
* - They never modify code, only observe and report
|
|
8
|
+
* @packageDocumentation
|
|
11
9
|
*/
|
|
12
10
|
import type { IKernel } from '@angular-modernizer/plugin-system';
|
|
13
11
|
import type { Plugin, AnalysisRule, TransformRule, ValidationRule } from '@angular-modernizer/plugin-system';
|
|
14
12
|
/**
|
|
15
|
-
* Analyzer
|
|
13
|
+
* Analyzer plugin (`analyzer`): project-level analysis.
|
|
16
14
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - [Future] LayerDetectorRule: Identifies architectural layers
|
|
20
|
-
* - [Future] DependencyAnalyzerRule: Analyzes dependency structure
|
|
15
|
+
* Provides one analysis rule, {@link FrameworkDetectorRule}, and no
|
|
16
|
+
* transformation or validation rules.
|
|
21
17
|
*/
|
|
22
18
|
export declare class AnalyzerPlugin implements Plugin {
|
|
23
19
|
readonly name = "analyzer";
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Project-level analysis plugin for the Angular Modernizer.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* {@link AnalyzerPlugin} registers {@link FrameworkDetectorRule}, which
|
|
6
|
+
* reports whether the project is an Angular CLI or an Nx workspace. The rules
|
|
7
|
+
* of this plugin only report; they never modify code.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
* - Analysis rules run first to understand the codebase
|
|
10
|
-
* - They provide insights that guide transformation decisions
|
|
11
|
-
* - They never modify code, only observe and report
|
|
9
|
+
* @packageDocumentation
|
|
12
10
|
*/
|
|
13
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
12
|
exports.FrameworkDetectorRule = exports.AnalyzerPlugin = void 0;
|
|
15
13
|
const framework_detector_rule_js_1 = require("./rules/framework-detector.rule.js");
|
|
16
14
|
/**
|
|
17
|
-
* Analyzer
|
|
15
|
+
* Analyzer plugin (`analyzer`): project-level analysis.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* - [Future] LayerDetectorRule: Identifies architectural layers
|
|
22
|
-
* - [Future] DependencyAnalyzerRule: Analyzes dependency structure
|
|
17
|
+
* Provides one analysis rule, {@link FrameworkDetectorRule}, and no
|
|
18
|
+
* transformation or validation rules.
|
|
23
19
|
*/
|
|
24
20
|
class AnalyzerPlugin {
|
|
25
21
|
name = 'analyzer';
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Framework detection rule (`analyzer:framework-detector`).
|
|
3
4
|
*
|
|
4
|
-
* Detects the
|
|
5
|
-
*
|
|
5
|
+
* Detects the workspace type from configuration files in the project root
|
|
6
|
+
* (the directory of the tsconfig, otherwise the directory of the analyzed
|
|
7
|
+
* file):
|
|
8
|
+
* - `nx.json` exists: framework is `Nx`
|
|
9
|
+
* - `angular.json` exists: framework is `Angular CLI`
|
|
10
|
+
* - neither exists: framework is `Unknown`
|
|
6
11
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - If angular.json exists: Framework is "Angular CLI"
|
|
10
|
-
* - If neither exists: Framework is "Unknown"
|
|
11
|
-
*/
|
|
12
|
-
import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
|
|
13
|
-
/**
|
|
14
|
-
* Framework detection rule.
|
|
15
|
-
* This is a project-level rule that examines configuration files.
|
|
12
|
+
* Reports one `info` result with `framework`, `hasNxConfig`,
|
|
13
|
+
* `hasAngularConfig` and `projectRoot` in its metadata.
|
|
16
14
|
*/
|
|
17
15
|
export declare class FrameworkDetectorRule implements AnalysisRule {
|
|
18
16
|
readonly id = "analyzer:framework-detector";
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @angular-modernizer/plugin-analyzer - Framework Detector Rule
|
|
4
|
-
*
|
|
5
|
-
* Detects the Angular framework type (Angular CLI vs Nx) by analyzing
|
|
6
|
-
* configuration files in the project root.
|
|
7
|
-
*
|
|
8
|
-
* Detection Logic:
|
|
9
|
-
* - If nx.json exists: Framework is "Nx"
|
|
10
|
-
* - If angular.json exists: Framework is "Angular CLI"
|
|
11
|
-
* - If neither exists: Framework is "Unknown"
|
|
12
|
-
*/
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.FrameworkDetectorRule = void 0;
|
|
15
4
|
const node_path_1 = require("node:path");
|
|
16
5
|
/**
|
|
17
|
-
* Framework detection rule.
|
|
18
|
-
*
|
|
6
|
+
* Framework detection rule (`analyzer:framework-detector`).
|
|
7
|
+
*
|
|
8
|
+
* Detects the workspace type from configuration files in the project root
|
|
9
|
+
* (the directory of the tsconfig, otherwise the directory of the analyzed
|
|
10
|
+
* file):
|
|
11
|
+
* - `nx.json` exists: framework is `Nx`
|
|
12
|
+
* - `angular.json` exists: framework is `Angular CLI`
|
|
13
|
+
* - neither exists: framework is `Unknown`
|
|
14
|
+
*
|
|
15
|
+
* Reports one `info` result with `framework`, `hasNxConfig`,
|
|
16
|
+
* `hasAngularConfig` and `projectRoot` in its metadata.
|
|
19
17
|
*/
|
|
20
18
|
class FrameworkDetectorRule {
|
|
21
19
|
id = 'analyzer:framework-detector';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-modernizer/plugin-analyzer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Analysis plugin for detecting project architecture, framework, and layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -12,13 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Christian Weiss",
|
|
15
|
-
"
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/eiweiss/tsanalyzer.git",
|
|
18
|
-
"directory": "packages/plugin-analyzer"
|
|
19
|
-
},
|
|
20
|
-
"homepage": "https://github.com/eiweiss/tsanalyzer#readme",
|
|
21
|
-
"bugs": "https://github.com/eiweiss/tsanalyzer/issues",
|
|
15
|
+
"homepage": "https://eiweiss.github.io/angular-modernizer-docs/",
|
|
22
16
|
"main": "./dist/index.js",
|
|
23
17
|
"files": [
|
|
24
18
|
"dist",
|
|
@@ -26,9 +20,9 @@
|
|
|
26
20
|
"!dist/**/*.map"
|
|
27
21
|
],
|
|
28
22
|
"dependencies": {
|
|
29
|
-
"@angular-modernizer/
|
|
30
|
-
"@angular-modernizer/
|
|
31
|
-
"@angular-modernizer/
|
|
23
|
+
"@angular-modernizer/plugin-system": "1.2.0",
|
|
24
|
+
"@angular-modernizer/api": "1.2.0",
|
|
25
|
+
"@angular-modernizer/core": "1.2.0"
|
|
32
26
|
},
|
|
33
27
|
"devDependencies": {
|
|
34
28
|
"@types/jest": "^30.0.0",
|