optiprune 2.1.4 → 2.1.7
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 +52 -22
- package/bin/runner.js +26 -0
- package/package.json +10 -37
- package/dist/ast-utils.d.ts +0 -149
- package/dist/ast-utils.js +0 -36
- package/dist/ast-utils.js.map +0 -1
- package/dist/cache.d.ts +0 -14
- package/dist/cache.js +0 -36
- package/dist/cache.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -68
- package/dist/cli.js.map +0 -1
- package/dist/config-loader.d.ts +0 -4
- package/dist/config-loader.js +0 -84
- package/dist/config-loader.js.map +0 -1
- package/dist/coverage-tracker.d.ts +0 -39
- package/dist/coverage-tracker.js +0 -61
- package/dist/coverage-tracker.js.map +0 -1
- package/dist/engine.d.ts +0 -17
- package/dist/engine.js +0 -215
- package/dist/engine.js.map +0 -1
- package/dist/framework-plugins.d.ts +0 -16
- package/dist/framework-plugins.js +0 -127
- package/dist/framework-plugins.js.map +0 -1
- package/dist/fs-utils.d.ts +0 -32
- package/dist/fs-utils.js +0 -415
- package/dist/fs-utils.js.map +0 -1
- package/dist/graph.d.ts +0 -42
- package/dist/graph.js +0 -583
- package/dist/graph.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -451
- package/dist/index.js.map +0 -1
- package/dist/instrument.d.ts +0 -5
- package/dist/instrument.js +0 -108
- package/dist/instrument.js.map +0 -1
- package/dist/layer2.d.ts +0 -6
- package/dist/layer2.js +0 -224
- package/dist/layer2.js.map +0 -1
- package/dist/layer3.d.ts +0 -7
- package/dist/layer3.js +0 -346
- package/dist/layer3.js.map +0 -1
- package/dist/layer4.d.ts +0 -8
- package/dist/layer4.js +0 -627
- package/dist/layer4.js.map +0 -1
- package/dist/layer5.d.ts +0 -6
- package/dist/layer5.js +0 -141
- package/dist/layer5.js.map +0 -1
- package/dist/layer6.d.ts +0 -26
- package/dist/layer6.js +0 -268
- package/dist/layer6.js.map +0 -1
- package/dist/layer7.d.ts +0 -28
- package/dist/layer7.js +0 -267
- package/dist/layer7.js.map +0 -1
- package/dist/parser.d.ts +0 -20
- package/dist/parser.js +0 -832
- package/dist/parser.js.map +0 -1
- package/dist/plugins/angular-plugin.d.ts +0 -7
- package/dist/plugins/angular-plugin.js +0 -60
- package/dist/plugins/angular-plugin.js.map +0 -1
- package/dist/plugins/astro-plugin.d.ts +0 -7
- package/dist/plugins/astro-plugin.js +0 -88
- package/dist/plugins/astro-plugin.js.map +0 -1
- package/dist/plugins/babel-plugin.d.ts +0 -8
- package/dist/plugins/babel-plugin.js +0 -132
- package/dist/plugins/babel-plugin.js.map +0 -1
- package/dist/plugins/esbuild-plugin.d.ts +0 -8
- package/dist/plugins/esbuild-plugin.js +0 -121
- package/dist/plugins/esbuild-plugin.js.map +0 -1
- package/dist/plugins/nestjs-plugin.d.ts +0 -7
- package/dist/plugins/nestjs-plugin.js +0 -69
- package/dist/plugins/nestjs-plugin.js.map +0 -1
- package/dist/plugins/nextjs-plugin.d.ts +0 -7
- package/dist/plugins/nextjs-plugin.js +0 -66
- package/dist/plugins/nextjs-plugin.js.map +0 -1
- package/dist/plugins/nuxtjs-plugin.d.ts +0 -7
- package/dist/plugins/nuxtjs-plugin.js +0 -80
- package/dist/plugins/nuxtjs-plugin.js.map +0 -1
- package/dist/plugins/svelte-plugin.d.ts +0 -7
- package/dist/plugins/svelte-plugin.js +0 -38
- package/dist/plugins/svelte-plugin.js.map +0 -1
- package/dist/plugins/vuejs-plugin.d.ts +0 -7
- package/dist/plugins/vuejs-plugin.js +0 -63
- package/dist/plugins/vuejs-plugin.js.map +0 -1
- package/dist/reporters.d.ts +0 -3
- package/dist/reporters.js +0 -75
- package/dist/reporters.js.map +0 -1
- package/dist/semantic-graph.d.ts +0 -44
- package/dist/semantic-graph.js +0 -88
- package/dist/semantic-graph.js.map +0 -1
- package/dist/symbolic-engine.d.ts +0 -19
- package/dist/symbolic-engine.js +0 -51
- package/dist/symbolic-engine.js.map +0 -1
- package/dist/topology-manager.d.ts +0 -23
- package/dist/topology-manager.js +0 -144
- package/dist/topology-manager.js.map +0 -1
- package/dist/types.d.ts +0 -265
- package/dist/types.js +0 -11
- package/dist/types.js.map +0 -1
- package/dist/workspace.d.ts +0 -6
- package/dist/workspace.js +0 -105
- package/dist/workspace.js.map +0 -1
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
interface BranchCoverage {
|
|
2
|
-
file: string;
|
|
3
|
-
line: number;
|
|
4
|
-
condition: any;
|
|
5
|
-
hit: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface FunctionCoverage {
|
|
8
|
-
file: string;
|
|
9
|
-
line: number;
|
|
10
|
-
name: string;
|
|
11
|
-
hit: boolean;
|
|
12
|
-
}
|
|
13
|
-
interface CallCoverage {
|
|
14
|
-
file: string;
|
|
15
|
-
line: number;
|
|
16
|
-
callee: string;
|
|
17
|
-
hit: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare class CoverageTracker {
|
|
20
|
-
private branches;
|
|
21
|
-
private functions;
|
|
22
|
-
private calls;
|
|
23
|
-
private currentFile;
|
|
24
|
-
private z3;
|
|
25
|
-
constructor(z3Context: any);
|
|
26
|
-
init(file: string): void;
|
|
27
|
-
traceBranch(file: string, line: number, condition: any): void;
|
|
28
|
-
traceFunction(file: string, line: number, name: string): void;
|
|
29
|
-
traceCall(file: string, line: number, callee: string): void;
|
|
30
|
-
traceAndExecuteCall(file: string, line: number, calleeName: string, callee: Function, args: any[]): any;
|
|
31
|
-
getCoverage(): {
|
|
32
|
-
branches: BranchCoverage[];
|
|
33
|
-
functions: FunctionCoverage[];
|
|
34
|
-
calls: CallCoverage[];
|
|
35
|
-
};
|
|
36
|
-
reset(): void;
|
|
37
|
-
}
|
|
38
|
-
export declare function createCoverageTracker(): Promise<CoverageTracker>;
|
|
39
|
-
export {};
|
package/dist/coverage-tracker.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { init } from "z3-solver";
|
|
2
|
-
export class CoverageTracker {
|
|
3
|
-
branches = new Map();
|
|
4
|
-
functions = new Map();
|
|
5
|
-
calls = new Map();
|
|
6
|
-
currentFile = "";
|
|
7
|
-
z3;
|
|
8
|
-
constructor(z3Context) {
|
|
9
|
-
this.z3 = z3Context;
|
|
10
|
-
}
|
|
11
|
-
init(file) {
|
|
12
|
-
this.currentFile = file;
|
|
13
|
-
}
|
|
14
|
-
traceBranch(file, line, condition) {
|
|
15
|
-
const key = `${file}:${line}`;
|
|
16
|
-
if (!this.branches.has(key)) {
|
|
17
|
-
this.branches.set(key, { file, line, condition, hit: false });
|
|
18
|
-
}
|
|
19
|
-
this.branches.get(key).hit = true;
|
|
20
|
-
}
|
|
21
|
-
traceFunction(file, line, name) {
|
|
22
|
-
const key = `${file}:${line}:${name}`;
|
|
23
|
-
if (!this.functions.has(key)) {
|
|
24
|
-
this.functions.set(key, { file, line, name, hit: false });
|
|
25
|
-
}
|
|
26
|
-
this.functions.get(key).hit = true;
|
|
27
|
-
}
|
|
28
|
-
traceCall(file, line, callee) {
|
|
29
|
-
const key = `${file}:${line}:${callee}`;
|
|
30
|
-
if (!this.calls.has(key)) {
|
|
31
|
-
this.calls.set(key, { file, line, callee, hit: false });
|
|
32
|
-
}
|
|
33
|
-
this.calls.get(key).hit = true;
|
|
34
|
-
}
|
|
35
|
-
// New method to trace and execute calls
|
|
36
|
-
traceAndExecuteCall(file, line, calleeName, callee, args) {
|
|
37
|
-
this.traceCall(file, line, calleeName);
|
|
38
|
-
// Execute the original function call
|
|
39
|
-
return callee(...args);
|
|
40
|
-
}
|
|
41
|
-
getCoverage() {
|
|
42
|
-
return {
|
|
43
|
-
branches: Array.from(this.branches.values()),
|
|
44
|
-
functions: Array.from(this.functions.values()),
|
|
45
|
-
calls: Array.from(this.calls.values()),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
reset() {
|
|
49
|
-
this.branches.clear();
|
|
50
|
-
this.functions.clear();
|
|
51
|
-
this.calls.clear();
|
|
52
|
-
this.currentFile = "";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// This will be initialized once in Layer 4 and passed to the sandbox
|
|
56
|
-
export async function createCoverageTracker() {
|
|
57
|
-
const { Context } = await init();
|
|
58
|
-
const z3 = Context("main");
|
|
59
|
-
return new CoverageTracker(z3);
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=coverage-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coverage-tracker.js","sourceRoot":"","sources":["../src/coverage-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAuBjC,MAAM,OAAO,eAAe;IAClB,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAC;IAClD,SAAS,GAAkC,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,GAA8B,IAAI,GAAG,EAAE,CAAC;IAC7C,WAAW,GAAW,EAAE,CAAC;IACzB,EAAE,CAAM;IAEhB,YAAY,SAAc;QACxB,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,IAAY,EAAE,SAAc;QACpD,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,GAAG,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,aAAa,CAAC,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AAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC9C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SACvC,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;CACF;AAED,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACvC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IACjC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/engine.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AnalysisContext, AnalyzerPlugin, Finding } from "./types.js";
|
|
2
|
-
export declare class PluginEngine {
|
|
3
|
-
private plugins;
|
|
4
|
-
private findings;
|
|
5
|
-
register(plugin: AnalyzerPlugin): void;
|
|
6
|
-
/**
|
|
7
|
-
* Dynamically loads all plugins from the src/plugins directory.
|
|
8
|
-
* Handles errors gracefully to ensure the core analysis continues.
|
|
9
|
-
*/
|
|
10
|
-
loadDynamicPlugins(): Promise<void>;
|
|
11
|
-
run(context: AnalysisContext): Promise<Finding[]>;
|
|
12
|
-
private createAdapter;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Legacy ZodPlugin refactored to new architecture
|
|
16
|
-
*/
|
|
17
|
-
export declare const ZodPlugin: AnalyzerPlugin;
|
package/dist/engine.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { walkAst as yukuWalk } from "./parser.js";
|
|
2
|
-
import { t } from "./ast-utils.js";
|
|
3
|
-
import fs from "node:fs/promises";
|
|
4
|
-
import path from "pathe";
|
|
5
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
export class PluginEngine {
|
|
7
|
-
plugins = [];
|
|
8
|
-
findings = [];
|
|
9
|
-
register(plugin) {
|
|
10
|
-
this.plugins.push(plugin);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Dynamically loads all plugins from the src/plugins directory.
|
|
14
|
-
* Handles errors gracefully to ensure the core analysis continues.
|
|
15
|
-
*/
|
|
16
|
-
async loadDynamicPlugins() {
|
|
17
|
-
try {
|
|
18
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const pluginsDir = path.join(__dirname, "plugins");
|
|
20
|
-
let files = [];
|
|
21
|
-
try {
|
|
22
|
-
files = await fs.readdir(pluginsDir);
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
// Directory might not exist or be inaccessible
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
for (const file of files) {
|
|
29
|
-
if ((file.endsWith(".ts") || file.endsWith(".js")) && !file.endsWith(".d.ts")) {
|
|
30
|
-
try {
|
|
31
|
-
const pluginPath = pathToFileURL(path.join(pluginsDir, file)).href;
|
|
32
|
-
const module = await import(pluginPath);
|
|
33
|
-
const keys = Object.keys(module);
|
|
34
|
-
const firstKey = keys[0];
|
|
35
|
-
const plugin = module.default || (firstKey ? module[firstKey] : null);
|
|
36
|
-
if (plugin && typeof plugin === "object" && plugin.name && plugin.lifecycle) {
|
|
37
|
-
this.register(plugin);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
console.warn(`[Plugin Engine] Failed to load plugin ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
console.warn(`[Plugin Engine] Error during dynamic plugin loading: ${err instanceof Error ? err.message : String(err)}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async run(context) {
|
|
51
|
-
const adapter = this.createAdapter(context);
|
|
52
|
-
// 0. Dynamic Loading
|
|
53
|
-
await this.loadDynamicPlugins();
|
|
54
|
-
// 1. Detection Phase
|
|
55
|
-
for (const plugin of this.plugins) {
|
|
56
|
-
try {
|
|
57
|
-
if (plugin.detect) {
|
|
58
|
-
plugin.enabled = await plugin.detect(adapter);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
plugin.enabled = true; // Enabled by default if no detect method
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
console.error(`[Plugin Engine] Error in detect phase for ${plugin.name}:`, err);
|
|
66
|
-
plugin.enabled = false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// 2. onProjectInit
|
|
70
|
-
for (const plugin of this.plugins) {
|
|
71
|
-
if (plugin.enabled && plugin.lifecycle.onProjectInit) {
|
|
72
|
-
try {
|
|
73
|
-
await plugin.lifecycle.onProjectInit(adapter);
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
console.error(`[Plugin Engine] Error in onProjectInit for ${plugin.name}:`, err);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// 3. File-level processing
|
|
81
|
-
for (const module of context.modules.values()) {
|
|
82
|
-
if (!module.ast)
|
|
83
|
-
continue;
|
|
84
|
-
// onFileStart
|
|
85
|
-
for (const plugin of this.plugins) {
|
|
86
|
-
if (plugin.enabled && plugin.lifecycle.onFileStart) {
|
|
87
|
-
try {
|
|
88
|
-
await plugin.lifecycle.onFileStart(module.id, adapter);
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
console.error(`[Plugin Engine] Error in onFileStart for ${plugin.name} on ${module.id}:`, err);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// onASTNode (Traversal)
|
|
96
|
-
// Use yuku-parser's walk instead of @babel/traverse
|
|
97
|
-
try {
|
|
98
|
-
yukuWalk(module.ast, (node) => {
|
|
99
|
-
for (const plugin of this.plugins) {
|
|
100
|
-
if (plugin.enabled && plugin.lifecycle.onASTNode) {
|
|
101
|
-
try {
|
|
102
|
-
plugin.lifecycle.onASTNode(node, module.id, adapter);
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
// Suppress per-node errors to avoid flooding logs, but ensure isolation
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
console.error(`[Plugin Engine] Error during AST traversal for ${module.id}:`, err);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// 4. onAnalysisComplete
|
|
116
|
-
for (const plugin of this.plugins) {
|
|
117
|
-
if (plugin.enabled && plugin.lifecycle.onAnalysisComplete) {
|
|
118
|
-
try {
|
|
119
|
-
await plugin.lifecycle.onAnalysisComplete(adapter);
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
console.error(`[Plugin Engine] Error in onAnalysisComplete for ${plugin.name}:`, err);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return this.findings;
|
|
127
|
-
}
|
|
128
|
-
createAdapter(context) {
|
|
129
|
-
return {
|
|
130
|
-
getAst: (fileId) => context.modules.get(fileId)?.ast,
|
|
131
|
-
getSymbol: (name, fileId) => {
|
|
132
|
-
const module = context.modules.get(fileId);
|
|
133
|
-
return module?.exports.find(e => e.name === name || e.exportedAs === name);
|
|
134
|
-
},
|
|
135
|
-
getType: (node) => {
|
|
136
|
-
// Simplified type inference
|
|
137
|
-
if (t.isStringLiteral(node))
|
|
138
|
-
return 'string';
|
|
139
|
-
if (t.isNumericLiteral(node))
|
|
140
|
-
return 'number';
|
|
141
|
-
if (t.isBooleanLiteral(node))
|
|
142
|
-
return 'boolean';
|
|
143
|
-
return undefined;
|
|
144
|
-
},
|
|
145
|
-
getDependencies: (fileId) => {
|
|
146
|
-
const module = context.modules.get(fileId);
|
|
147
|
-
return module?.edges.map(e => e.target).filter(Boolean) || [];
|
|
148
|
-
},
|
|
149
|
-
getConfig: () => context.options,
|
|
150
|
-
readFile: async (filename) => {
|
|
151
|
-
try {
|
|
152
|
-
const fullPath = path.isAbsolute(filename) ? filename : path.join(context.options.rootDir, filename);
|
|
153
|
-
return await fs.readFile(fullPath, 'utf8');
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
readJson: async (filename) => {
|
|
160
|
-
try {
|
|
161
|
-
const fullPath = path.isAbsolute(filename) ? filename : path.join(context.options.rootDir, filename);
|
|
162
|
-
const content = await fs.readFile(fullPath, 'utf8');
|
|
163
|
-
return JSON.parse(content);
|
|
164
|
-
}
|
|
165
|
-
catch {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
emitFinding: (finding) => {
|
|
170
|
-
this.findings.push({
|
|
171
|
-
rule: 'plugin-finding', // default fallback
|
|
172
|
-
...finding, // overrides 'rule' if finding.rule was provided
|
|
173
|
-
});
|
|
174
|
-
},
|
|
175
|
-
markAsUsed: (fileId, symbol) => {
|
|
176
|
-
context.reachable.add(fileId);
|
|
177
|
-
if (symbol) {
|
|
178
|
-
context.usedExports.add(`${fileId}:${symbol}`);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
attachMetadata: (node, key, value) => {
|
|
182
|
-
node.metadata = node.metadata || {};
|
|
183
|
-
node.metadata[key] = value;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Legacy ZodPlugin refactored to new architecture
|
|
190
|
-
*/
|
|
191
|
-
export const ZodPlugin = {
|
|
192
|
-
name: "zod-plugin",
|
|
193
|
-
version: "2.0.0",
|
|
194
|
-
lifecycle: {
|
|
195
|
-
onASTNode: (node, fileId, adapter) => {
|
|
196
|
-
// Pattern: const User = z.object(...)
|
|
197
|
-
if (t.isVariableDeclarator(node) && t.isIdentifier(node.id)) {
|
|
198
|
-
const init = node.init;
|
|
199
|
-
const isZod = t.isCallExpression(init) &&
|
|
200
|
-
((t.isMemberExpression(init.callee) && t.isIdentifier(init.callee.object) && (init.callee.object.name === 'z' || init.callee.object.name === 'zod')) ||
|
|
201
|
-
(t.isIdentifier(init.callee) && init.callee.name === 'z'));
|
|
202
|
-
if (isZod) {
|
|
203
|
-
adapter.markAsUsed(fileId, node.id.name);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
// Dynamic property access: controller[method]()
|
|
207
|
-
if (t.isMemberExpression(node) && node.computed) {
|
|
208
|
-
if (t.isStringLiteral(node.property)) {
|
|
209
|
-
adapter.markAsUsed(fileId, node.property.value);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
//# sourceMappingURL=engine.js.map
|
package/dist/engine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,OAAO,YAAY;IACf,OAAO,GAAqB,EAAE,CAAC;IAC/B,QAAQ,GAAc,EAAE,CAAC;IAEjC,QAAQ,CAAC,MAAsB;QAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,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in
|
|
4
|
-
* Handles React-specific patterns like components and hooks.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ReactPlugin: AnalyzerPlugin;
|
|
7
|
-
/**
|
|
8
|
-
* Next.js Plugin
|
|
9
|
-
* Handles Next.js specific entry points and conventions.
|
|
10
|
-
*/
|
|
11
|
-
export declare const NextjsPlugin: AnalyzerPlugin;
|
|
12
|
-
/**
|
|
13
|
-
* Nuxt Plugin
|
|
14
|
-
* Handles Nuxt-specific directory conventions and auto-imports.
|
|
15
|
-
*/
|
|
16
|
-
export declare const NuxtPlugin: AnalyzerPlugin;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility to check for dependencies in package.json
|
|
3
|
-
*/
|
|
4
|
-
async function hasDependency(adapter, name) {
|
|
5
|
-
const pkg = await adapter.readJson('package.json');
|
|
6
|
-
if (!pkg)
|
|
7
|
-
return false;
|
|
8
|
-
return !!(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.peerDependencies?.[name]);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* React Plugin
|
|
12
|
-
* Handles React-specific patterns like components and hooks.
|
|
13
|
-
*/
|
|
14
|
-
export const ReactPlugin = {
|
|
15
|
-
name: "react-plugin",
|
|
16
|
-
version: "1.1.0",
|
|
17
|
-
detect: async (adapter) => {
|
|
18
|
-
return await hasDependency(adapter, 'react');
|
|
19
|
-
},
|
|
20
|
-
lifecycle: {
|
|
21
|
-
onASTNode: (node, fileId, adapter) => {
|
|
22
|
-
let targetNode = node;
|
|
23
|
-
// Unwrap export declarations
|
|
24
|
-
if ((node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') &&
|
|
25
|
-
node.declaration) {
|
|
26
|
-
targetNode = node.declaration;
|
|
27
|
-
}
|
|
28
|
-
// 1. Function Declarations: function MyComponent() {}
|
|
29
|
-
if (targetNode.type === 'FunctionDeclaration' && targetNode.id && /^[A-Z]/.test(targetNode.id.name)) {
|
|
30
|
-
adapter.markAsUsed(fileId, targetNode.id.name);
|
|
31
|
-
}
|
|
32
|
-
// 2. Variable Declarations: const MyComponent = () => ... or function expression / JSX
|
|
33
|
-
if (targetNode.type === 'VariableDeclaration' && Array.isArray(targetNode.declarations)) {
|
|
34
|
-
for (const decl of targetNode.declarations) {
|
|
35
|
-
if (decl.id?.type === 'Identifier' && /^[A-Z]/.test(decl.id.name)) {
|
|
36
|
-
const init = decl.init;
|
|
37
|
-
if (init &&
|
|
38
|
-
(init.type === 'ArrowFunctionExpression' ||
|
|
39
|
-
init.type === 'FunctionExpression' ||
|
|
40
|
-
init.type === 'JSXElement')) {
|
|
41
|
-
adapter.markAsUsed(fileId, decl.id.name);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// 3. Hooks: useFoo() call expressions
|
|
47
|
-
if (node.type === 'CallExpression' &&
|
|
48
|
-
node.callee?.type === 'Identifier' &&
|
|
49
|
-
typeof node.callee.name === 'string' &&
|
|
50
|
-
node.callee.name.startsWith('use')) {
|
|
51
|
-
adapter.markAsUsed(fileId);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Next.js Plugin
|
|
58
|
-
* Handles Next.js specific entry points and conventions.
|
|
59
|
-
*/
|
|
60
|
-
export const NextjsPlugin = {
|
|
61
|
-
name: "nextjs-plugin",
|
|
62
|
-
version: "1.1.0",
|
|
63
|
-
detect: async (adapter) => {
|
|
64
|
-
return await hasDependency(adapter, 'next');
|
|
65
|
-
},
|
|
66
|
-
lifecycle: {
|
|
67
|
-
onProjectInit: async (adapter) => {
|
|
68
|
-
const nextConfig = await adapter.readFile('next.config.js') || await adapter.readFile('next.config.mjs');
|
|
69
|
-
if (nextConfig) {
|
|
70
|
-
// Logged/handled if present
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
onFileStart: (fileId, adapter) => {
|
|
74
|
-
const filename = fileId.split('/').pop() || '';
|
|
75
|
-
if (['page.tsx', 'page.js', 'layout.tsx', 'layout.js', 'route.ts', 'route.js', 'error.tsx', 'loading.tsx'].includes(filename)) {
|
|
76
|
-
adapter.markAsUsed(fileId);
|
|
77
|
-
}
|
|
78
|
-
if (fileId.includes('/pages/api/')) {
|
|
79
|
-
adapter.markAsUsed(fileId);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
onASTNode: (node, fileId, adapter) => {
|
|
83
|
-
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
84
|
-
const decl = node.declaration;
|
|
85
|
-
if (decl.type === 'FunctionDeclaration' && decl.id) {
|
|
86
|
-
const name = decl.id.name;
|
|
87
|
-
if (['getStaticProps', 'getServerSideProps', 'getStaticPaths', 'generateMetadata', 'generateStaticParams'].includes(name)) {
|
|
88
|
-
adapter.markAsUsed(fileId, name);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Nuxt Plugin
|
|
97
|
-
* Handles Nuxt-specific directory conventions and auto-imports.
|
|
98
|
-
*/
|
|
99
|
-
export const NuxtPlugin = {
|
|
100
|
-
name: "nuxt-plugin",
|
|
101
|
-
version: "1.1.0",
|
|
102
|
-
detect: async (adapter) => {
|
|
103
|
-
return await hasDependency(adapter, 'nuxt');
|
|
104
|
-
},
|
|
105
|
-
lifecycle: {
|
|
106
|
-
onProjectInit: async (adapter) => {
|
|
107
|
-
const nuxtConfig = await adapter.readFile('nuxt.config.ts') || await adapter.readFile('nuxt.config.js');
|
|
108
|
-
if (nuxtConfig) {
|
|
109
|
-
// Custom directory configs
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
onFileStart: (fileId, adapter) => {
|
|
113
|
-
const pathParts = fileId.split('/');
|
|
114
|
-
if (pathParts.includes('pages') || pathParts.includes('layouts') || pathParts.includes('middleware') || pathParts.includes('server') || pathParts.includes('composables')) {
|
|
115
|
-
adapter.markAsUsed(fileId);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
onASTNode: (node, fileId, adapter) => {
|
|
119
|
-
if (node.type === 'CallExpression' && node.callee?.type === 'Identifier') {
|
|
120
|
-
if (['definePageMeta', 'defineNuxtComponent', 'useNuxtApp', 'useFetch', 'defineEventHandler'].includes(node.callee.name)) {
|
|
121
|
-
adapter.markAsUsed(fileId);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=framework-plugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framework-plugins.js","sourceRoot":"","sources":["../src/framework-plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,OAAY,EAAE,IAAY;IACrD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACrG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,OAAO,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,SAAS,EAAE;QACT,SAAS,EAAE,CAAC,IAAS,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YACxC,IAAI,UAAU,GAAG,IAAI,CAAC;YAEtB,6BAA6B;YA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AC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC1K,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,SAAS,EAAE,CAAC,IAAS,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;gBACzE,IAAI,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzH,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;KACF;CACF,CAAC"}
|
package/dist/fs-utils.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_EXTENSIONS: string[];
|
|
2
|
-
export declare const DEFAULT_IGNORE: string[];
|
|
3
|
-
export declare function normalizeCanonicalPath(filePath: string): string;
|
|
4
|
-
export declare function toPosix(value: string): string;
|
|
5
|
-
export declare function normalizeAbsolute(value: string): string;
|
|
6
|
-
export declare function pathInside(parent: string, candidate: string): boolean;
|
|
7
|
-
export declare function globToRegExp(pattern: string): RegExp;
|
|
8
|
-
export declare function compileGlobs(patterns: string[]): RegExp[];
|
|
9
|
-
export declare function matchesAnyGlob(relativePath: string, compiledPatterns: RegExp[]): boolean;
|
|
10
|
-
export declare function fileExists(candidate: string): Promise<boolean>;
|
|
11
|
-
export declare function directoryExists(candidate: string): Promise<boolean>;
|
|
12
|
-
export declare function discoverSourceFiles(rootDir: string, extensions: string[], compiledIgnorePatterns: RegExp[]): Promise<string[]>;
|
|
13
|
-
export declare function isLikelyLocalSpecifier(specifier: string): boolean;
|
|
14
|
-
export declare function removeQueryAndHash(specifier: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Resolves an import specifier against a set of known files.
|
|
17
|
-
* Handles .js -> .ts / .tsx extension mapping.
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveLocalSpecifier(sourceFilePath: string, rawSpecifier: string, knownFiles: Set<string> | Map<string, unknown>, extensions?: string[]): string | undefined;
|
|
20
|
-
export declare function resolveDynamicPattern(fromFile: string, prefix: string, suffix: string, knownFiles: Set<string>): string[];
|
|
21
|
-
export declare function expandEntryPatterns(sourceFiles: string[], rootDir: string, patterns: string[]): string[];
|
|
22
|
-
export declare function discoverPackageEntryPatterns(rootDir: string): Promise<string[]>;
|
|
23
|
-
export declare function conventionalEntryPatterns(): string[];
|
|
24
|
-
export declare function normalizedConventionalEntryPatterns(): string[];
|
|
25
|
-
export declare function readJsonFile<T>(candidate: string): Promise<T | undefined>;
|
|
26
|
-
export declare function findNearestConfig(startDirectory: string): Promise<string | undefined>;
|
|
27
|
-
export declare function relativeDisplayPath(rootDir: string, candidate: string): string;
|
|
28
|
-
export declare function rootLooksValid(rootDir: string): Promise<boolean>;
|
|
29
|
-
export declare function ingestTsConfigPaths(rootDir: string, configPath?: string): Promise<{
|
|
30
|
-
paths: Map<string, string[]>;
|
|
31
|
-
baseUrl: string | undefined;
|
|
32
|
-
}>;
|