@angular-modernizer/plugin-analyzer 0.3.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-modernizer/plugin-analyzer",
3
- "version": "0.3.0",
3
+ "version": "1.0.0",
4
4
  "description": "Analysis plugin for detecting project architecture, framework, and layers.",
5
5
  "keywords": [
6
6
  "angular",
@@ -11,6 +11,7 @@
11
11
  "code-analysis"
12
12
  ],
13
13
  "license": "MIT",
14
+ "author": "Christian Weiss",
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "git+https://github.com/eiweiss/tsanalyzer.git",
@@ -18,19 +19,16 @@
18
19
  },
19
20
  "homepage": "https://github.com/eiweiss/tsanalyzer#readme",
20
21
  "bugs": "https://github.com/eiweiss/tsanalyzer/issues",
21
- "main": "dist/index.js",
22
+ "main": "./dist/index.js",
22
23
  "files": [
23
24
  "dist",
24
- "src",
25
25
  "!dist/**/__tests__/**",
26
- "!src/**/__tests__/**",
27
- "!src/**/*.test.ts",
28
- "!src/**/*.spec.ts"
26
+ "!dist/**/*.map"
29
27
  ],
30
28
  "dependencies": {
31
- "@angular-modernizer/plugin-system": "0.3.0",
32
- "@angular-modernizer/core": "0.3.0",
33
- "@angular-modernizer/api": "0.3.0"
29
+ "@angular-modernizer/core": "1.0.0",
30
+ "@angular-modernizer/plugin-system": "1.0.0",
31
+ "@angular-modernizer/api": "1.0.0"
34
32
  },
35
33
  "devDependencies": {
36
34
  "@types/jest": "^30.0.0",
@@ -46,6 +44,18 @@
46
44
  ],
47
45
  "tsconfig": "./tsconfig.json"
48
46
  },
47
+ "engines": {
48
+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"
49
+ },
50
+ "types": "./dist/index.d.ts",
51
+ "exports": {
52
+ ".": {
53
+ "types": "./dist/index.d.ts",
54
+ "require": "./dist/index.js",
55
+ "default": "./dist/index.js"
56
+ },
57
+ "./package.json": "./package.json"
58
+ },
49
59
  "scripts": {
50
60
  "build": "tsc --build",
51
61
  "test": "jest --passWithNoTests",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,mCAAmC,CAAC;AAG3C;;;;;;;GAOG;AACH,qBAAa,cAAe,YAAW,MAAM;IAC3C,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,WAAW,iDAAiD;IACrE,QAAQ,CAAC,MAAM,wBAAwB;IAEvC,OAAO,CAAC,qBAAqB,CAAwB;;IAOrD;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD;;OAEG;IACH,gBAAgB,IAAI,YAAY,EAAE;IAIlC;;;OAGG;IACH,iBAAiB,IAAI,aAAa,EAAE;IAIpC;;;OAGG;IACH,kBAAkB,IAAI,cAAc,EAAE;CAGvC;AAGD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AASH,mFAA2E;AAE3E;;;;;;;GAOG;AACH,MAAa,cAAc;IAChB,IAAI,GAAG,UAAU,CAAC;IAClB,OAAO,GAAG,OAAO,CAAC;IAClB,WAAW,GAAG,6CAA6C,CAAC;IAC5D,MAAM,GAAG,oBAAoB,CAAC;IAE/B,qBAAqB,CAAwB;IAErD;QACE,mBAAmB;QACnB,IAAI,CAAC,qBAAqB,GAAG,IAAI,kDAAqB,EAAE,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,MAAe;QAC9B,+CAA+C;QAC/C,gEAAgE;QAChE,KAAK,MAAM,CAAC,CAAC,sCAAsC;IACrD,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,iBAAiB;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA7CD,wCA6CC;AAED,oCAAoC;AACpC,iFAA2E;AAAlE,mIAAA,qBAAqB,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-detector.rule.d.ts","sourceRoot":"","sources":["../../src/rules/framework-detector.rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,mCAAmC,CAAC;AAG3C;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,YAAY;IACxD,QAAQ,CAAC,EAAE,iCAAiC;IAC5C,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,WAAW,wDAAwD;IAC5E,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IACpC,QAAQ,CAAC,QAAQ,sBAAsB;IACvC,QAAQ,CAAC,IAAI,WAAyC;IAEhD,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA+ClE;;;OAGG;IACH,OAAO,CAAC,cAAc;IAatB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAcvB;;;OAGG;YACW,UAAU;CA2BzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-detector.rule.js","sourceRoot":"","sources":["../../src/rules/framework-detector.rule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAOH,yCAA0C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C;YAED,8BAA8B;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAzHD,sDAyHC"}
package/src/index.ts DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * @angular-modernizer/plugin-analyzer
3
- *
4
- * Analysis plugin for detecting project architecture, framework, and layers.
5
- * This plugin provides rules for high-level project analysis.
6
- *
7
- * Philosophy: "Know Before You Transform"
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
11
- */
12
-
13
- import type { IKernel } from '@angular-modernizer/plugin-system';
14
- import type {
15
- Plugin,
16
- AnalysisRule,
17
- TransformRule,
18
- ValidationRule,
19
- } from '@angular-modernizer/plugin-system';
20
- import { FrameworkDetectorRule } from './rules/framework-detector.rule.js';
21
-
22
- /**
23
- * Analyzer Plugin - Provides project-level analysis capabilities.
24
- *
25
- * Rules provided:
26
- * - FrameworkDetectorRule: Detects Angular CLI vs Nx
27
- * - [Future] LayerDetectorRule: Identifies architectural layers
28
- * - [Future] DependencyAnalyzerRule: Analyzes dependency structure
29
- */
30
- export class AnalyzerPlugin implements Plugin {
31
- readonly name = 'analyzer';
32
- readonly version = '1.0.0';
33
- readonly description = 'Project architecture and framework analysis';
34
- readonly author = 'Angular Modernizer';
35
-
36
- private frameworkDetectorRule: FrameworkDetectorRule;
37
-
38
- constructor() {
39
- // Initialize rules
40
- this.frameworkDetectorRule = new FrameworkDetectorRule();
41
- }
42
-
43
- /**
44
- * Initialize the plugin.
45
- * Called once during Kernel initialization.
46
- */
47
- async initialize(kernel: IKernel): Promise<void> {
48
- // No initialization needed for this plugin yet
49
- // Future: Could load configuration, validate dependencies, etc.
50
- void kernel; // Mark as used to avoid linting error
51
- }
52
-
53
- /**
54
- * Get all analysis rules provided by this plugin.
55
- */
56
- getAnalysisRules(): AnalysisRule[] {
57
- return [this.frameworkDetectorRule];
58
- }
59
-
60
- /**
61
- * Get all transformation rules provided by this plugin.
62
- * This plugin doesn't provide transformations.
63
- */
64
- getTransformRules(): TransformRule[] {
65
- return [];
66
- }
67
-
68
- /**
69
- * Get all validation rules provided by this plugin.
70
- * This plugin doesn't provide validations.
71
- */
72
- getValidationRules(): ValidationRule[] {
73
- return [];
74
- }
75
- }
76
-
77
- // Export the plugin class and rules
78
- export { FrameworkDetectorRule } from './rules/framework-detector.rule.js';
@@ -1,145 +0,0 @@
1
- /**
2
- * @angular-modernizer/plugin-analyzer - Framework Detector Rule
3
- *
4
- * Detects the Angular framework type (Angular CLI vs Nx) by analyzing
5
- * configuration files in the project root.
6
- *
7
- * Detection Logic:
8
- * - If nx.json exists: Framework is "Nx"
9
- * - If angular.json exists: Framework is "Angular CLI"
10
- * - If neither exists: Framework is "Unknown"
11
- */
12
-
13
- import type {
14
- AnalysisRule,
15
- AnalysisContext,
16
- AnalysisResult,
17
- } from '@angular-modernizer/plugin-system';
18
- import { dirname, join } from 'node:path';
19
-
20
- /**
21
- * Framework detection rule.
22
- * This is a project-level rule that examines configuration files.
23
- */
24
- export class FrameworkDetectorRule implements AnalysisRule {
25
- readonly id = 'analyzer:framework-detector';
26
- readonly name = 'Framework Detector';
27
- readonly description = 'Detects whether the project uses Angular CLI or Nx';
28
- readonly severity = 'info' as const;
29
- readonly category = 'project-analysis';
30
- readonly tags = ['framework', 'detection', 'project'];
31
-
32
- async analyze(context: AnalysisContext): Promise<AnalysisResult[]> {
33
- // Get the project root directory
34
- // We'll use the directory containing the tsconfig file as the project root
35
- const projectRoot = this.getProjectRoot(context);
36
-
37
- // Check for framework configuration files
38
- const hasNxConfig = await this.fileExists(
39
- context,
40
- join(projectRoot, 'nx.json'),
41
- );
42
- const hasAngularConfig = await this.fileExists(
43
- context,
44
- join(projectRoot, 'angular.json'),
45
- );
46
-
47
- // Determine framework type
48
- let framework: string;
49
- let message: string;
50
-
51
- if (hasNxConfig) {
52
- framework = 'Nx';
53
- message = 'Project uses Nx workspace';
54
- } else if (hasAngularConfig) {
55
- framework = 'Angular CLI';
56
- message = 'Project uses Angular CLI';
57
- } else {
58
- framework = 'Unknown';
59
- message =
60
- 'Could not determine framework type (no nx.json or angular.json found)';
61
- }
62
-
63
- // Return analysis result
64
- return [
65
- {
66
- ruleId: this.id,
67
- message,
68
- filePath: context.filePath,
69
- metadata: {
70
- framework,
71
- hasNxConfig,
72
- hasAngularConfig,
73
- projectRoot,
74
- },
75
- },
76
- ];
77
- }
78
-
79
- /**
80
- * Get the project root directory.
81
- * Uses the directory containing the first tsconfig.json found.
82
- */
83
- private getProjectRoot(context: AnalysisContext): string {
84
- // Get all tsconfig files from the project
85
- const compilerOptions = context.project.getCompilerOptions();
86
- const configFiles = compilerOptions['configFilePath'];
87
-
88
- if (configFiles && typeof configFiles === 'string') {
89
- return dirname(configFiles);
90
- }
91
-
92
- // Fallback: use the directory of the current source file and traverse up
93
- return this.findProjectRoot(context.filePath);
94
- }
95
-
96
- /**
97
- * Find project root by traversing up the directory tree.
98
- * Looks for tsconfig.json, package.json, or stops at root.
99
- */
100
- private findProjectRoot(startPath: string): string {
101
- const current = dirname(startPath);
102
- const root = '/';
103
-
104
- // Keep traversing up until we find a project marker or hit root
105
- while (current !== root) {
106
- // TODO: In a real implementation, we'd check for files here
107
- // For now, just return the directory
108
- return current;
109
- }
110
-
111
- return current;
112
- }
113
-
114
- /**
115
- * Check if a file exists in the file system.
116
- * Uses the file system adapter from the context if available.
117
- */
118
- private async fileExists(
119
- context: AnalysisContext,
120
- filePath: string,
121
- ): Promise<boolean> {
122
- try {
123
- // Try using ts-morph to check if the file exists
124
- const sourceFile = context.project.getSourceFile(filePath);
125
- if (sourceFile) {
126
- return true;
127
- }
128
-
129
- // Try using the file system directly
130
- // The project should have a file system we can query
131
- const projectWithFs = context.project as unknown as {
132
- getFileSystem?: () => { fileExistsSync?: (path: string) => boolean };
133
- };
134
- const fileSystem = projectWithFs.getFileSystem?.();
135
- if (fileSystem && typeof fileSystem.fileExistsSync === 'function') {
136
- return fileSystem.fileExistsSync(filePath);
137
- }
138
-
139
- // Fallback: just return false
140
- return false;
141
- } catch {
142
- return false;
143
- }
144
- }
145
- }