@optiprune/cli 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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 DreamLongYT
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,67 @@
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 "@optiprune/core";
6
+ import { formatTerminal, formatSarif } from "@optiprune/core/reporters";
7
+ import { fileURLToPath } from "node:url";
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
+ const VERSION = "2.1.5"; // Assuming same version as core for now
10
+ program
11
+ .name("optiprune")
12
+ .version(VERSION)
13
+ .description("Finds dead code in TypeScript/JavaScript projects.")
14
+ .option("-r, --rootDir <path>", "Root directory of the project", process.cwd())
15
+ .option("-e, --entry <patterns...>", "Entry point patterns (glob or file paths)", [])
16
+ .option("-x, --extensions <exts...>", "File extensions to analyze", [".ts", ".tsx", ".js", ".jsx"])
17
+ .option("-i, --ignore <patterns...>", "Ignore patterns (glob)", [])
18
+ .option("--no-report-unused-exports", "Do not report unused exports")
19
+ .option("--no-conventional-entries", "Do not include conventional entry points (e.g., src/index.ts)")
20
+ .option("--fail-on <confidence>", "Fail on findings with confidence level (high, medium, low, none)", "high")
21
+ .option("--json", "Output results as JSON")
22
+ .option("--sarif", "Output results in SARIF format")
23
+ .option("--skip-3", "Skip Layer 3 (SMT Constraint Solver)")
24
+ .option("--skip-4", "Skip Layer 4 (Concolic Execution Proofs)")
25
+ .action(async (options) => {
26
+ try {
27
+ const analyzerOptions = {
28
+ rootDir: options.rootDir,
29
+ entry: options.entry,
30
+ extensions: options.extensions,
31
+ ignore: options.ignore,
32
+ reportUnusedExports: options.reportUnusedExports,
33
+ includeConventionalEntries: options.conventionalEntries,
34
+ failOn: options.failOn,
35
+ json: options.json || options.sarif,
36
+ skip3: options.skip3,
37
+ skip4: options.skip4,
38
+ };
39
+ const report = await analyze(analyzerOptions);
40
+ if (options.sarif) {
41
+ console.log(formatSarif(report));
42
+ }
43
+ else if (options.json) {
44
+ try {
45
+ // Use a replacer to handle potential BigInt or other non-serializable types if any
46
+ const json = JSON.stringify(report, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2);
47
+ console.log(json);
48
+ }
49
+ catch (jsonError) {
50
+ console.error("Failed to generate JSON output:", jsonError);
51
+ process.exit(1);
52
+ }
53
+ }
54
+ else {
55
+ console.log(formatTerminal(report));
56
+ }
57
+ if (shouldFail(report, options.failOn)) {
58
+ process.exit(1);
59
+ }
60
+ }
61
+ catch (error) {
62
+ console.error("An unexpected error occurred:", error);
63
+ process.exit(1);
64
+ }
65
+ });
66
+ program.parse(process.argv);
67
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["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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/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@optiprune/cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI for resilient static dead-code analyzer for TypeScript and JavaScript workspaces.",
5
+ "type": "module",
6
+ "bin": {
7
+ "optiprune": "./dist/cli.js"
8
+ },
9
+ "homepage": "https://opti.drml.int.yt/",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/DreamLongYT/optiprune.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/DreamLongYT/optiprune/issues"
16
+ },
17
+ "keywords": [
18
+ "analysis",
19
+ "analyze",
20
+ "cli",
21
+ "dead code",
22
+ "typescript",
23
+ "javascript",
24
+ "optiprune"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "dependencies": {
32
+ "commander": "^15.0.0",
33
+ "pathe": "2.0.3",
34
+ "@optiprune/core": "1.0.2"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.15.3",
38
+ "typescript": "^5.8.3"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc -p tsconfig.json",
42
+ "prepublishOnly": "npm run build"
43
+ },
44
+ "engines": {
45
+ "node": "^22.18.0 || >=24.11.0"
46
+ },
47
+ "license": "MIT",
48
+ "author": "DreamLongYT"
49
+ }