optiprune 2.1.5 → 2.1.8
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/bin/runner.js +26 -0
- package/package.json +8 -43
- 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
package/bin/runner.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import path from "pathe";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
let cliPath;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// 1. Try standard package resolution
|
|
12
|
+
const pkgPath = require.resolve("@optiprune/cli/package.json");
|
|
13
|
+
cliPath = path.join(path.dirname(pkgPath), "dist/cli.js");
|
|
14
|
+
} catch {
|
|
15
|
+
// 2. Monorepo / global symlink fallback
|
|
16
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
cliPath = path.resolve(currentDir, "../../cli/dist/cli.js");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Convert absolute Windows path (E:\...) into a valid file:// URL
|
|
21
|
+
const cliUrl = pathToFileURL(cliPath).href;
|
|
22
|
+
|
|
23
|
+
import(cliUrl).catch((err) => {
|
|
24
|
+
console.error("Failed to execute @optiprune/cli:", err);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "optiprune",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "Resilient static dead-code analyzer for TypeScript and JavaScript workspaces.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/cli.js",
|
|
8
7
|
"homepage": "https://opti.drml.int.yt/",
|
|
9
8
|
"repository": {
|
|
10
9
|
"type": "git",
|
|
@@ -50,57 +49,23 @@
|
|
|
50
49
|
"optimization"
|
|
51
50
|
],
|
|
52
51
|
"bin": {
|
|
53
|
-
"optiprune": "
|
|
54
|
-
},
|
|
55
|
-
"exports": {
|
|
56
|
-
".": {
|
|
57
|
-
"types": "./dist/index.d.ts",
|
|
58
|
-
"import": "./dist/index.js"
|
|
59
|
-
}
|
|
52
|
+
"optiprune": "./bin/runner.js"
|
|
60
53
|
},
|
|
61
54
|
"files": [
|
|
62
|
-
"
|
|
55
|
+
"bin",
|
|
63
56
|
"README.md",
|
|
64
57
|
"LICENSE"
|
|
65
58
|
],
|
|
66
|
-
"scripts": {
|
|
67
|
-
"build": "npx tsc -p tsconfig.json",
|
|
68
|
-
"check": "npx tsc -p tsconfig.json --noEmit",
|
|
69
|
-
"test": "vitest run --no-file-parallelism",
|
|
70
|
-
"test:watch": "vitest",
|
|
71
|
-
"analyze": "node ./dist/cli.js",
|
|
72
|
-
"docs:dev": "vitepress dev docs",
|
|
73
|
-
"docs:build": "vitepress build docs",
|
|
74
|
-
"docs:preview": "vitepress preview docs",
|
|
75
|
-
"prepublishOnly": "npm run build",
|
|
76
|
-
"release": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\" && npm ci && npm run build"
|
|
77
|
-
},
|
|
78
59
|
"dependencies": {
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"fast-glob": "^3.3.3",
|
|
82
|
-
"js-yaml": "^5.2.2",
|
|
83
|
-
"pathe": "2.0.3",
|
|
84
|
-
"quickjs-emscripten": "^0.32.0",
|
|
85
|
-
"yuku-ast": "^0.8.3",
|
|
86
|
-
"yuku-codegen": "^0.8.3",
|
|
87
|
-
"yuku-parser": "^0.8.3",
|
|
88
|
-
"z3-solver": "^5.0.0"
|
|
89
|
-
},
|
|
90
|
-
"devDependencies": {
|
|
91
|
-
"@types/node": "^22.15.3",
|
|
92
|
-
"typescript": "^5.8.3",
|
|
93
|
-
"vitepress": "^1.6.4",
|
|
94
|
-
"vitest": "^3.2.4",
|
|
95
|
-
"vue": "^3.5.40"
|
|
60
|
+
"@optiprune/cli": "^1.2.9",
|
|
61
|
+
"pathe": "2.0.3"
|
|
96
62
|
},
|
|
97
63
|
"engines": {
|
|
98
64
|
"node": "^22.18.0 || >=24.11.0"
|
|
99
65
|
},
|
|
100
66
|
"license": "MIT",
|
|
101
67
|
"directories": {
|
|
102
|
-
"doc": "docs"
|
|
103
|
-
"test": "tests"
|
|
68
|
+
"doc": "docs"
|
|
104
69
|
},
|
|
105
70
|
"author": "DreamLongYT"
|
|
106
|
-
}
|
|
71
|
+
}
|
package/dist/ast-utils.d.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared AST Utilities for Yuku-compatible ESTree ASTs.
|
|
3
|
-
* Replaces @babel/types for common type-guarding tasks.
|
|
4
|
-
*/
|
|
5
|
-
export declare const t: {
|
|
6
|
-
isStringLiteral: (n: unknown) => n is {
|
|
7
|
-
type: "Literal";
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
isNumericLiteral: (n: unknown) => n is {
|
|
11
|
-
type: "Literal";
|
|
12
|
-
value: number;
|
|
13
|
-
};
|
|
14
|
-
isBooleanLiteral: (n: unknown) => n is {
|
|
15
|
-
type: "Literal";
|
|
16
|
-
value: boolean;
|
|
17
|
-
};
|
|
18
|
-
isIdentifier: (n: unknown) => n is {
|
|
19
|
-
type: "Identifier";
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
isCallExpression: (n: unknown) => n is {
|
|
23
|
-
type: "CallExpression";
|
|
24
|
-
callee: any;
|
|
25
|
-
arguments: any[];
|
|
26
|
-
};
|
|
27
|
-
isMemberExpression: (n: unknown) => n is {
|
|
28
|
-
type: "MemberExpression";
|
|
29
|
-
object: any;
|
|
30
|
-
property: any;
|
|
31
|
-
computed: boolean;
|
|
32
|
-
};
|
|
33
|
-
isVariableDeclarator: (n: unknown) => n is {
|
|
34
|
-
type: "VariableDeclarator";
|
|
35
|
-
id: any;
|
|
36
|
-
init: any;
|
|
37
|
-
};
|
|
38
|
-
isFunctionDeclaration: (n: unknown) => n is {
|
|
39
|
-
type: "FunctionDeclaration";
|
|
40
|
-
id: {
|
|
41
|
-
name: string;
|
|
42
|
-
} | null;
|
|
43
|
-
};
|
|
44
|
-
isExportNamedDeclaration: (n: unknown) => n is {
|
|
45
|
-
type: "ExportNamedDeclaration";
|
|
46
|
-
declaration: any;
|
|
47
|
-
specifiers: any[];
|
|
48
|
-
};
|
|
49
|
-
isImportDeclaration: (n: unknown) => n is {
|
|
50
|
-
type: "ImportDeclaration";
|
|
51
|
-
source: {
|
|
52
|
-
value: string;
|
|
53
|
-
};
|
|
54
|
-
specifiers: any[];
|
|
55
|
-
};
|
|
56
|
-
isObjectProperty: (n: unknown) => n is {
|
|
57
|
-
type: "Property";
|
|
58
|
-
key: any;
|
|
59
|
-
value: any;
|
|
60
|
-
computed: boolean;
|
|
61
|
-
};
|
|
62
|
-
isObjectMethod: (n: unknown) => n is {
|
|
63
|
-
type: "ObjectMethod";
|
|
64
|
-
key: any;
|
|
65
|
-
};
|
|
66
|
-
isTSInterfaceDeclaration: (n: unknown) => n is {
|
|
67
|
-
type: "TSInterfaceDeclaration";
|
|
68
|
-
id: {
|
|
69
|
-
name: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
isTSTypeAliasDeclaration: (n: unknown) => n is {
|
|
73
|
-
type: "TSTypeAliasDeclaration";
|
|
74
|
-
id: {
|
|
75
|
-
name: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
isTSEnumDeclaration: (n: unknown) => n is {
|
|
79
|
-
type: "TSEnumDeclaration";
|
|
80
|
-
id: {
|
|
81
|
-
name: string;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
isClassDeclaration: (n: unknown) => n is {
|
|
85
|
-
type: "ClassDeclaration";
|
|
86
|
-
id: {
|
|
87
|
-
name: string;
|
|
88
|
-
} | null;
|
|
89
|
-
};
|
|
90
|
-
isClassExpression: (n: unknown) => n is {
|
|
91
|
-
type: "ClassExpression";
|
|
92
|
-
id: {
|
|
93
|
-
name: string;
|
|
94
|
-
} | null;
|
|
95
|
-
};
|
|
96
|
-
isClassMethod: (n: unknown) => n is {
|
|
97
|
-
type: "ClassMethod";
|
|
98
|
-
key: any;
|
|
99
|
-
};
|
|
100
|
-
isClassProperty: (n: unknown) => n is {
|
|
101
|
-
type: "ClassProperty";
|
|
102
|
-
key: any;
|
|
103
|
-
};
|
|
104
|
-
isExportDefaultDeclaration: (n: unknown) => n is {
|
|
105
|
-
type: "ExportDefaultDeclaration";
|
|
106
|
-
declaration: any;
|
|
107
|
-
};
|
|
108
|
-
isFunctionExpression: (n: unknown) => n is {
|
|
109
|
-
type: "FunctionExpression";
|
|
110
|
-
id: {
|
|
111
|
-
name: string;
|
|
112
|
-
} | null;
|
|
113
|
-
};
|
|
114
|
-
isJSXElement: (n: unknown) => n is {
|
|
115
|
-
type: "JSXElement";
|
|
116
|
-
openingElement: any;
|
|
117
|
-
};
|
|
118
|
-
isJSXIdentifier: (n: unknown) => n is {
|
|
119
|
-
type: "JSXIdentifier";
|
|
120
|
-
name: string;
|
|
121
|
-
};
|
|
122
|
-
isObjectExpression: (n: unknown) => n is {
|
|
123
|
-
type: "ObjectExpression";
|
|
124
|
-
properties: any[];
|
|
125
|
-
};
|
|
126
|
-
isLiteral: (n: unknown) => n is {
|
|
127
|
-
type: "Literal";
|
|
128
|
-
value: any;
|
|
129
|
-
};
|
|
130
|
-
isJSXAttribute: (n: unknown) => n is {
|
|
131
|
-
type: "JSXAttribute";
|
|
132
|
-
name: any;
|
|
133
|
-
value: any;
|
|
134
|
-
};
|
|
135
|
-
isNewExpression: (n: unknown) => n is {
|
|
136
|
-
type: "NewExpression";
|
|
137
|
-
callee: any;
|
|
138
|
-
arguments: any[];
|
|
139
|
-
};
|
|
140
|
-
isTemplateLiteral: (n: unknown) => n is {
|
|
141
|
-
type: "TemplateLiteral";
|
|
142
|
-
quasis: any[];
|
|
143
|
-
expressions: any[];
|
|
144
|
-
};
|
|
145
|
-
isDecorator: (n: unknown) => n is {
|
|
146
|
-
type: "Decorator";
|
|
147
|
-
expression: any;
|
|
148
|
-
};
|
|
149
|
-
};
|
package/dist/ast-utils.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared AST Utilities for Yuku-compatible ESTree ASTs.
|
|
3
|
-
* Replaces @babel/types for common type-guarding tasks.
|
|
4
|
-
*/
|
|
5
|
-
export const t = {
|
|
6
|
-
isStringLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'string',
|
|
7
|
-
isNumericLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'number',
|
|
8
|
-
isBooleanLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal' && typeof n.value === 'boolean',
|
|
9
|
-
isIdentifier: (n) => !!n && typeof n === 'object' && n.type === 'Identifier',
|
|
10
|
-
isCallExpression: (n) => !!n && typeof n === 'object' && n.type === 'CallExpression',
|
|
11
|
-
isMemberExpression: (n) => !!n && typeof n === 'object' && n.type === 'MemberExpression',
|
|
12
|
-
isVariableDeclarator: (n) => !!n && typeof n === 'object' && n.type === 'VariableDeclarator',
|
|
13
|
-
isFunctionDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'FunctionDeclaration',
|
|
14
|
-
isExportNamedDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ExportNamedDeclaration',
|
|
15
|
-
isImportDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ImportDeclaration',
|
|
16
|
-
isObjectProperty: (n) => !!n && typeof n === 'object' && (n.type === 'Property' || n.type === 'ObjectProperty'),
|
|
17
|
-
isObjectMethod: (n) => !!n && typeof n === 'object' && n.type === 'ObjectMethod',
|
|
18
|
-
isTSInterfaceDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSInterfaceDeclaration',
|
|
19
|
-
isTSTypeAliasDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSTypeAliasDeclaration',
|
|
20
|
-
isTSEnumDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'TSEnumDeclaration',
|
|
21
|
-
isClassDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ClassDeclaration',
|
|
22
|
-
isClassExpression: (n) => !!n && typeof n === 'object' && n.type === 'ClassExpression',
|
|
23
|
-
isClassMethod: (n) => !!n && typeof n === 'object' && n.type === 'ClassMethod',
|
|
24
|
-
isClassProperty: (n) => !!n && typeof n === 'object' && (n.type === 'ClassProperty' || n.type === 'PropertyDefinition'),
|
|
25
|
-
isExportDefaultDeclaration: (n) => !!n && typeof n === 'object' && n.type === 'ExportDefaultDeclaration',
|
|
26
|
-
isFunctionExpression: (n) => !!n && typeof n === 'object' && n.type === 'FunctionExpression',
|
|
27
|
-
isJSXElement: (n) => !!n && typeof n === 'object' && n.type === 'JSXElement',
|
|
28
|
-
isJSXIdentifier: (n) => !!n && typeof n === 'object' && n.type === 'JSXIdentifier',
|
|
29
|
-
isObjectExpression: (n) => !!n && typeof n === 'object' && n.type === 'ObjectExpression',
|
|
30
|
-
isLiteral: (n) => !!n && typeof n === 'object' && n.type === 'Literal',
|
|
31
|
-
isJSXAttribute: (n) => !!n && typeof n === 'object' && n.type === 'JSXAttribute',
|
|
32
|
-
isNewExpression: (n) => !!n && typeof n === 'object' && n.type === 'NewExpression',
|
|
33
|
-
isTemplateLiteral: (n) => !!n && typeof n === 'object' && n.type === 'TemplateLiteral',
|
|
34
|
-
isDecorator: (n) => !!n && typeof n === 'object' && n.type === 'Decorator',
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=ast-utils.js.map
|
package/dist/ast-utils.js.map
DELETED
|
@@ -1 +0,0 @@
|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B;IAExE,SAAS,EAAE,CAAC,CAAU,EAAwC,EAAE,CAC9D,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,SAAS;IAE/D,cAAc,EAAE,CAAC,CAAU,EAAwD,EAAE,CACnF,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,cAAc;IAEpE,eAAe,EAAE,CAAC,CAAU,EAAiE,EAAE,CAC7F,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,eAAe;IAErE,iBAAiB,EAAE,CAAC,CAAU,EAAuE,EAAE,CACrG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,iBAAiB;IAEvE,WAAW,EAAE,CAAC,CAAU,EAA+C,EAAE,CACvE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,IAAI,KAAK,WAAW;CAClE,CAAC"}
|
package/dist/cache.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ModuleRecord } from "./types.js";
|
|
2
|
-
export interface CacheEntry {
|
|
3
|
-
hash: string;
|
|
4
|
-
moduleRecord: ModuleRecord;
|
|
5
|
-
timestamp: number;
|
|
6
|
-
}
|
|
7
|
-
export interface AnalysisCache {
|
|
8
|
-
version: string;
|
|
9
|
-
entries: Record<string, CacheEntry>;
|
|
10
|
-
}
|
|
11
|
-
export declare function getFileHash(content: string): string;
|
|
12
|
-
export declare function loadCache(rootDir: string): AnalysisCache;
|
|
13
|
-
export declare function saveCache(rootDir: string, cache: AnalysisCache): void;
|
|
14
|
-
export declare function isCacheValid(entry: CacheEntry, currentContent: string): boolean;
|
package/dist/cache.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import crypto from "node:crypto";
|
|
4
|
-
const CACHE_DIR = ".optiprune";
|
|
5
|
-
const CACHE_FILE = "cache.json";
|
|
6
|
-
export function getFileHash(content) {
|
|
7
|
-
return crypto.createHash("sha256").update(content).digest("hex");
|
|
8
|
-
}
|
|
9
|
-
export function loadCache(rootDir) {
|
|
10
|
-
const cachePath = path.join(rootDir, CACHE_DIR, CACHE_FILE);
|
|
11
|
-
if (fs.existsSync(cachePath)) {
|
|
12
|
-
try {
|
|
13
|
-
return JSON.parse(fs.readFileSync(cachePath, "utf-8"));
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
// Ignore
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return { version: "1.0", entries: {} };
|
|
20
|
-
}
|
|
21
|
-
export function saveCache(rootDir, cache) {
|
|
22
|
-
try {
|
|
23
|
-
const dirPath = path.join(rootDir, CACHE_DIR);
|
|
24
|
-
if (!fs.existsSync(dirPath)) {
|
|
25
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
26
|
-
}
|
|
27
|
-
fs.writeFileSync(path.join(dirPath, CACHE_FILE), JSON.stringify(cache, null, 2));
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
// Ignore cache write errors in environments like tests where rootDir might be problematic
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function isCacheValid(entry, currentContent) {
|
|
34
|
-
return entry.hash === getFileHash(currentContent);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=cache.js.map
|
package/dist/cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAcjC,MAAM,SAAS,GAAG,YAA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AAY,CAAC,KAAiB,EAAE,cAAsB;IACpE,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
const program = new Command();
|
|
5
|
-
import { analyze, shouldFail } from "./index.js";
|
|
6
|
-
import { readJsonFile } from "./fs-utils.js";
|
|
7
|
-
import { formatTerminal, formatSarif } from "./reporters.js";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const PKG_JSON = await readJsonFile(path.join(__dirname, "..", "package.json"));
|
|
11
|
-
program
|
|
12
|
-
.name("optiprune")
|
|
13
|
-
.version(PKG_JSON && typeof PKG_JSON.version === "string" ? PKG_JSON.version : "1.8.2")
|
|
14
|
-
.description("Finds dead code in TypeScript/JavaScript projects.")
|
|
15
|
-
.option("-r, --rootDir <path>", "Root directory of the project", process.cwd())
|
|
16
|
-
.option("-e, --entry <patterns...>", "Entry point patterns (glob or file paths)", [])
|
|
17
|
-
.option("-x, --extensions <exts...>", "File extensions to analyze", [".ts", ".tsx", ".js", ".jsx"])
|
|
18
|
-
.option("-i, --ignore <patterns...>", "Ignore patterns (glob)", [])
|
|
19
|
-
.option("--no-report-unused-exports", "Do not report unused exports")
|
|
20
|
-
.option("--no-conventional-entries", "Do not include conventional entry points (e.g., src/index.ts)")
|
|
21
|
-
.option("--fail-on <confidence>", "Fail on findings with confidence level (high, medium, low, none)", "high")
|
|
22
|
-
.option("--json", "Output results as JSON")
|
|
23
|
-
.option("--sarif", "Output results in SARIF format")
|
|
24
|
-
.option("--skip-3", "Skip Layer 3 (SMT Constraint Solver)")
|
|
25
|
-
.option("--skip-4", "Skip Layer 4 (Concolic Execution Proofs)")
|
|
26
|
-
.action(async (options) => {
|
|
27
|
-
try {
|
|
28
|
-
const analyzerOptions = {
|
|
29
|
-
rootDir: options.rootDir,
|
|
30
|
-
entry: options.entry,
|
|
31
|
-
extensions: options.extensions,
|
|
32
|
-
ignore: options.ignore,
|
|
33
|
-
reportUnusedExports: options.reportUnusedExports,
|
|
34
|
-
includeConventionalEntries: options.conventionalEntries,
|
|
35
|
-
failOn: options.failOn,
|
|
36
|
-
json: options.json || options.sarif,
|
|
37
|
-
skip3: options.skip3,
|
|
38
|
-
skip4: options.skip4,
|
|
39
|
-
};
|
|
40
|
-
const report = await analyze(analyzerOptions);
|
|
41
|
-
if (options.sarif) {
|
|
42
|
-
console.log(formatSarif(report));
|
|
43
|
-
}
|
|
44
|
-
else if (options.json) {
|
|
45
|
-
try {
|
|
46
|
-
// Use a replacer to handle potential BigInt or other non-serializable types if any
|
|
47
|
-
const json = JSON.stringify(report, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2);
|
|
48
|
-
console.log(json);
|
|
49
|
-
}
|
|
50
|
-
catch (jsonError) {
|
|
51
|
-
console.error("Failed to generate JSON output:", jsonError);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
console.log(formatTerminal(report));
|
|
57
|
-
}
|
|
58
|
-
if (shouldFail(report, options.failOn)) {
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
console.error("An unexpected error occurred:", error);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
program.parse(process.argv);
|
|
68
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,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AAK,CAAC,iCAAiC,EAAE,SAAS,CAAC,CAAC;gBAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,MAAa,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/config-loader.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Config, ResolvedOptions } from "./types.js";
|
|
2
|
-
export declare const DEFAULT_CONFIG: ResolvedOptions;
|
|
3
|
-
export declare function loadConfig(rootDir: string): Promise<Config>;
|
|
4
|
-
export declare function mergeConfig(base: ResolvedOptions, userConfig: Config): ResolvedOptions;
|
package/dist/config-loader.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import path from "pathe";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
4
|
-
import { DEFAULT_EXTENSIONS, DEFAULT_IGNORE, normalizeAbsolute } from "./fs-utils.js";
|
|
5
|
-
export const DEFAULT_CONFIG = {
|
|
6
|
-
rootDir: normalizeAbsolute(process.cwd()),
|
|
7
|
-
entry: [],
|
|
8
|
-
extensions: DEFAULT_EXTENSIONS,
|
|
9
|
-
ignore: DEFAULT_IGNORE,
|
|
10
|
-
reportUnusedExports: true,
|
|
11
|
-
schemaEnums: {},
|
|
12
|
-
failOn: "high",
|
|
13
|
-
json: false,
|
|
14
|
-
includeConventionalEntries: true,
|
|
15
|
-
externalContracts: [],
|
|
16
|
-
verbose: false,
|
|
17
|
-
pathAliases: new Map(),
|
|
18
|
-
layers: {
|
|
19
|
-
smtTimeoutMs: 100,
|
|
20
|
-
isolateMemoryLimitMb: 16,
|
|
21
|
-
enableConcolicProof: true,
|
|
22
|
-
skip3: false,
|
|
23
|
-
skip4: false,
|
|
24
|
-
},
|
|
25
|
-
rules: {
|
|
26
|
-
'unused-export': 'warning',
|
|
27
|
-
'unreachable-file': 'warning',
|
|
28
|
-
'constant-condition': 'warning',
|
|
29
|
-
'unreachable-dynamic-path': 'warning',
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export async function loadConfig(rootDir) {
|
|
33
|
-
const configPaths = [
|
|
34
|
-
path.join(rootDir, "optiprune.config.ts"),
|
|
35
|
-
path.join(rootDir, "optiprune.config.js"),
|
|
36
|
-
path.join(rootDir, "optiprune.config.mjs"),
|
|
37
|
-
];
|
|
38
|
-
for (const configPath of configPaths) {
|
|
39
|
-
if (fs.existsSync(configPath)) {
|
|
40
|
-
try {
|
|
41
|
-
const configUrl = pathToFileURL(configPath).href;
|
|
42
|
-
const module = await import(configUrl);
|
|
43
|
-
return module.default || module;
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
console.warn(`[Config] Failed to load config from ${configPath}:`, e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
export function mergeConfig(base, userConfig) {
|
|
53
|
-
// 1. Check if user explicitly passed non-empty entry array
|
|
54
|
-
const hasUserEntries = Array.isArray(userConfig.entry) && userConfig.entry.length > 0;
|
|
55
|
-
// 2. Normalize rootDir to POSIX
|
|
56
|
-
const rootDir = userConfig.rootDir ? normalizeAbsolute(userConfig.rootDir) : base.rootDir;
|
|
57
|
-
// 3. Normalize entries to POSIX absolute paths
|
|
58
|
-
const rawEntries = hasUserEntries ? userConfig.entry : (userConfig.entry || base.entry);
|
|
59
|
-
const entry = rawEntries.map(e => normalizeAbsolute(path.resolve(rootDir, e)));
|
|
60
|
-
// 4. If explicit entries are supplied, force includeConventionalEntries to false unless user explicitly said otherwise
|
|
61
|
-
const includeConventionalEntries = hasUserEntries
|
|
62
|
-
? (userConfig.includeConventionalEntries ?? false)
|
|
63
|
-
: (userConfig.includeConventionalEntries ?? base.includeConventionalEntries);
|
|
64
|
-
return {
|
|
65
|
-
...base,
|
|
66
|
-
...userConfig,
|
|
67
|
-
rootDir,
|
|
68
|
-
entry,
|
|
69
|
-
includeConventionalEntries,
|
|
70
|
-
layers: {
|
|
71
|
-
...base.layers,
|
|
72
|
-
...userConfig.layers,
|
|
73
|
-
},
|
|
74
|
-
rules: {
|
|
75
|
-
...base.rules,
|
|
76
|
-
...userConfig.rules,
|
|
77
|
-
},
|
|
78
|
-
externalContracts: [
|
|
79
|
-
...base.externalContracts,
|
|
80
|
-
...(userConfig.externalContracts || []),
|
|
81
|
-
],
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=config-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEtF,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,kBAAkB;IAC9B,MAAM,EAAE,cAAc;IACtB,mBAAmB,EAAE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|
|
@@ -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
|
-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ACtB,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;
|