legacy-modernizer 0.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 +290 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +534 -0
- package/dist/index.mjs +497 -0
- package/dist/reporters/analysis.d.ts +8 -0
- package/dist/reporters/analysis.test.d.ts +1 -0
- package/dist/reporters/locale.d.ts +2 -0
- package/dist/scanners/legacy-scanner.d.ts +16 -0
- package/dist/scanners/legacy-scanner.test.d.ts +1 -0
- package/dist/scanners/rules/eslint-modernize.d.ts +3 -0
- package/dist/scanners/rules/index.d.ts +3 -0
- package/dist/scanners/rules/jest-to-vitest.d.ts +2 -0
- package/dist/scanners/rules/js-to-ts.d.ts +3 -0
- package/dist/scanners/rules/vue2-to-vue3.d.ts +2 -0
- package/dist/scanners/rules/vuex-to-pinia.d.ts +2 -0
- package/dist/scanners/rules/webpack-to-vite.d.ts +2 -0
- package/dist/types.d.ts +140 -0
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/format.d.ts +13 -0
- package/package.json +73 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy Modernizer — Core type definitions
|
|
3
|
+
*/
|
|
4
|
+
/** Migration dimension — each represents a major upgrade path */
|
|
5
|
+
export type MigrationDimension = 'vue2-to-vue3' | 'js-to-ts' | 'webpack-to-vite' | 'jest-to-vitest' | 'vuex-to-pinia' | 'eslint-modernize';
|
|
6
|
+
/** Severity of a detected legacy pattern */
|
|
7
|
+
export type PatternSeverity = 'critical' | 'warning' | 'info';
|
|
8
|
+
/** Risk level for the overall migration */
|
|
9
|
+
export type RiskLevel = 'low' | 'medium' | 'high';
|
|
10
|
+
/** Branded line number type — ensures non-negative values */
|
|
11
|
+
export type PatternLine = number & {
|
|
12
|
+
readonly __brand: unique symbol;
|
|
13
|
+
};
|
|
14
|
+
/** Create a PatternLine, clamping negative values to 0 */
|
|
15
|
+
export declare function createPatternLine(n: number): PatternLine;
|
|
16
|
+
/** A single detected legacy pattern in a file */
|
|
17
|
+
export interface LegacyPattern {
|
|
18
|
+
/** Pattern identifier, e.g. "vue2-options-api" */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Human-readable name */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Which migration dimension this belongs to */
|
|
23
|
+
dimension: MigrationDimension;
|
|
24
|
+
/** Severity level */
|
|
25
|
+
severity: PatternSeverity;
|
|
26
|
+
/** File path (relative to project root) */
|
|
27
|
+
file: string;
|
|
28
|
+
/** Line number (1-based, 0 if unknown) — branded to prevent negative values */
|
|
29
|
+
line: PatternLine;
|
|
30
|
+
/** The matched text snippet */
|
|
31
|
+
snippet: string;
|
|
32
|
+
/** Suggested replacement (optional) */
|
|
33
|
+
suggestion?: string;
|
|
34
|
+
}
|
|
35
|
+
/** A detection rule for legacy pattern scanning (Fix #1: centralized) */
|
|
36
|
+
export interface PatternRule {
|
|
37
|
+
/** Unique rule identifier */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Human-readable name */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Which migration dimension this belongs to */
|
|
42
|
+
dimension: MigrationDimension;
|
|
43
|
+
/** Severity level */
|
|
44
|
+
severity: PatternSeverity;
|
|
45
|
+
/** Regex to detect the pattern */
|
|
46
|
+
regex: RegExp;
|
|
47
|
+
/** Suggested replacement */
|
|
48
|
+
suggestion: string;
|
|
49
|
+
}
|
|
50
|
+
/** Statistics grouped by dimension */
|
|
51
|
+
export interface DimensionStats {
|
|
52
|
+
dimension: MigrationDimension;
|
|
53
|
+
/** Total patterns found */
|
|
54
|
+
count: number;
|
|
55
|
+
/** Unique files affected */
|
|
56
|
+
files: number;
|
|
57
|
+
/** Breakdown by severity */
|
|
58
|
+
bySeverity: Record<PatternSeverity, number>;
|
|
59
|
+
}
|
|
60
|
+
/** Full project analysis report */
|
|
61
|
+
export interface AnalysisReport {
|
|
62
|
+
/** Project root path */
|
|
63
|
+
projectRoot: string;
|
|
64
|
+
/** Scan time */
|
|
65
|
+
scannedAt: string;
|
|
66
|
+
/** Total files scanned */
|
|
67
|
+
totalFiles: number;
|
|
68
|
+
/** Total patterns found */
|
|
69
|
+
totalPatterns: number;
|
|
70
|
+
/** All detected patterns */
|
|
71
|
+
patterns: LegacyPattern[];
|
|
72
|
+
/** Statistics by dimension */
|
|
73
|
+
dimensions: DimensionStats[];
|
|
74
|
+
/** Risk assessment */
|
|
75
|
+
risk: RiskAssessment;
|
|
76
|
+
/** Scan duration in ms */
|
|
77
|
+
duration: number;
|
|
78
|
+
}
|
|
79
|
+
export interface RiskAssessment {
|
|
80
|
+
/** Overall risk level */
|
|
81
|
+
level: RiskLevel;
|
|
82
|
+
/** Reasoning */
|
|
83
|
+
reason: string;
|
|
84
|
+
/** Recommended migration order (dimensions) */
|
|
85
|
+
recommendedOrder: MigrationDimension[];
|
|
86
|
+
/** Estimated effort (person-days) */
|
|
87
|
+
estimatedEffort: number;
|
|
88
|
+
}
|
|
89
|
+
/** Risk assessment thresholds (configurable, Fix #6) */
|
|
90
|
+
export interface RiskThresholds {
|
|
91
|
+
/** Critical pattern count above which risk is high (default: 20) */
|
|
92
|
+
criticalHigh: number;
|
|
93
|
+
/** Critical pattern count above which risk is medium (default: 5) */
|
|
94
|
+
criticalMedium: number;
|
|
95
|
+
/** Warning count above which risk is medium (default: 30) */
|
|
96
|
+
warningMedium: number;
|
|
97
|
+
/** Total file count above which risk is high (default: 200) */
|
|
98
|
+
filesHigh: number;
|
|
99
|
+
/** Total file count above which risk is medium (default: 50) */
|
|
100
|
+
filesMedium: number;
|
|
101
|
+
/** Effort divisor for high-risk (default: 15) */
|
|
102
|
+
effortHigh: number;
|
|
103
|
+
/** Effort divisor for medium-risk (default: 25) */
|
|
104
|
+
effortMedium: number;
|
|
105
|
+
/** Effort divisor for low-risk (default: 40) */
|
|
106
|
+
effortLow: number;
|
|
107
|
+
}
|
|
108
|
+
/** Scanner options derived from ModernizerConfig + runtime params (Fix #2) */
|
|
109
|
+
export interface ScannerOptions {
|
|
110
|
+
/** Project root directory (always required at runtime) */
|
|
111
|
+
root: string;
|
|
112
|
+
/** File globs to include */
|
|
113
|
+
include?: string[];
|
|
114
|
+
/** File globs to exclude */
|
|
115
|
+
exclude?: string[];
|
|
116
|
+
/** Max files to scan, 0 = unlimited */
|
|
117
|
+
maxFiles?: number;
|
|
118
|
+
/** Max matches per rule per file (default: 10) */
|
|
119
|
+
maxMatchesPerRule?: number;
|
|
120
|
+
/** Risk thresholds override */
|
|
121
|
+
riskThresholds?: Partial<RiskThresholds>;
|
|
122
|
+
}
|
|
123
|
+
/** Scanner configuration per dimension */
|
|
124
|
+
export interface DimensionConfig {
|
|
125
|
+
/** Whether this dimension is enabled */
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
/** File globs to scan */
|
|
128
|
+
include: string[];
|
|
129
|
+
/** File globs to exclude */
|
|
130
|
+
exclude: string[];
|
|
131
|
+
}
|
|
132
|
+
export interface ModernizerConfig {
|
|
133
|
+
/** Per-dimension configuration */
|
|
134
|
+
dimensions: Record<MigrationDimension, DimensionConfig>;
|
|
135
|
+
/** Max files to scan (0 = unlimited) */
|
|
136
|
+
maxFiles: number;
|
|
137
|
+
/** Whether to include suggestions in report */
|
|
138
|
+
includeSuggestions: boolean;
|
|
139
|
+
}
|
|
140
|
+
export declare const VERSION: "0.1.0";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management
|
|
3
|
+
*/
|
|
4
|
+
import type { ModernizerConfig } from '../types';
|
|
5
|
+
/** Deep merge user config with defaults (Issue #9: guard unknown dimension keys) */
|
|
6
|
+
export declare function mergeConfig(user: Partial<ModernizerConfig>): ModernizerConfig;
|
|
7
|
+
/** Get default configuration */
|
|
8
|
+
export declare function getDefaultConfig(): ModernizerConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utility functions
|
|
3
|
+
*/
|
|
4
|
+
import type { Locale } from '../reporters/locale';
|
|
5
|
+
import type { LegacyPattern, MigrationDimension, PatternSeverity } from '../types';
|
|
6
|
+
/** Format a legacy pattern as a Markdown list item */
|
|
7
|
+
export declare function patternToMarkdown(p: LegacyPattern): string;
|
|
8
|
+
/** Get emoji badge for severity */
|
|
9
|
+
export declare function severityBadge(severity: PatternSeverity): string;
|
|
10
|
+
/** Get display label for dimension (locale-aware) */
|
|
11
|
+
export declare function dimensionLabel(dimension: MigrationDimension, locale?: Locale): string;
|
|
12
|
+
/** Format duration in ms to human-readable */
|
|
13
|
+
export declare function formatDuration(ms: number): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "legacy-modernizer",
|
|
3
|
+
"description": "AI-powered legacy code modernizer for frontend projects — Vue 2→3, JS→TS, Webpack→Vite semantic migration via Claude Code Skill",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
".claude"
|
|
17
|
+
],
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@eslint-sets/eslint-config": "^6.3.1",
|
|
20
|
+
"@types/node": "^26.0.0",
|
|
21
|
+
"eslint": "^9.39.4",
|
|
22
|
+
"npm-run-all": "^4.1.5",
|
|
23
|
+
"prettier": "^3.8.4",
|
|
24
|
+
"prettier-config-common": "^1.5.0",
|
|
25
|
+
"rm-all": "^1.1.1",
|
|
26
|
+
"tsup": "^8.5.1",
|
|
27
|
+
"typescript": "^5.9.3",
|
|
28
|
+
"vitepress": "^1.6.4",
|
|
29
|
+
"vitest": "^3.2.6"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.20"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"keywords": [
|
|
36
|
+
"legacy-modernizer",
|
|
37
|
+
"vue2-to-vue3",
|
|
38
|
+
"js-to-ts",
|
|
39
|
+
"webpack-to-vite",
|
|
40
|
+
"migration",
|
|
41
|
+
"modernization",
|
|
42
|
+
"claude-code",
|
|
43
|
+
"claude-code-skill"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"author": "saqqdy<https://github.com/saqqdy>",
|
|
47
|
+
"homepage": "https://github.com/saqqdy/legacy-modernizer#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/saqqdy/legacy-modernizer/issues"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/saqqdy/legacy-modernizer.git"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "run-s clean build:bundle build:types",
|
|
57
|
+
"build:bundle": "tsup",
|
|
58
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
59
|
+
"clean": "rm-all dist",
|
|
60
|
+
"dev": "tsup --watch",
|
|
61
|
+
"lint": "eslint --fix .",
|
|
62
|
+
"prettier": "prettier --write \"**/*.{js,ts,mjs,yml,json,md}\"",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
66
|
+
"dist": "run-s lint build",
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
68
|
+
"docs:dev": "vitepress dev docs",
|
|
69
|
+
"docs:build": "vitepress build docs",
|
|
70
|
+
"docs:preview": "vitepress preview docs",
|
|
71
|
+
"playground": "npx sirv . --dev --port 5174 --single playground/index.html"
|
|
72
|
+
}
|
|
73
|
+
}
|