jscan 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 +43 -0
- package/bin/jscan +51 -0
- package/package.json +43 -0
- package/scripts/download-binary.js +125 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# jscan
|
|
2
|
+
|
|
3
|
+
Code quality analyzer for JavaScript/TypeScript projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g jscan
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx jscan analyze src/
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Analyze a directory
|
|
21
|
+
jscan analyze ./src
|
|
22
|
+
|
|
23
|
+
# Output as JSON
|
|
24
|
+
jscan analyze ./src --format json
|
|
25
|
+
|
|
26
|
+
# Output as HTML report
|
|
27
|
+
jscan analyze ./src --format html --output report.html
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Dead code detection
|
|
33
|
+
- Cyclomatic complexity analysis
|
|
34
|
+
- Duplicate code detection
|
|
35
|
+
- And more...
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
For full documentation, visit [GitHub](https://github.com/ludo-technologies/jscan).
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/bin/jscan
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const arch = process.arch;
|
|
9
|
+
|
|
10
|
+
// Map Node.js platform/arch to binary names
|
|
11
|
+
const platformMap = {
|
|
12
|
+
darwin: "darwin",
|
|
13
|
+
linux: "linux",
|
|
14
|
+
win32: "windows",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const archMap = {
|
|
18
|
+
x64: "amd64",
|
|
19
|
+
arm64: "arm64",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const platformName = platformMap[platform];
|
|
23
|
+
const archName = archMap[arch];
|
|
24
|
+
|
|
25
|
+
if (!platformName || !archName) {
|
|
26
|
+
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
31
|
+
const binaryName = `jscan-${platformName}-${archName}${ext}`;
|
|
32
|
+
const binaryPath = path.join(__dirname, "..", "bin", binaryName);
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync(binaryPath)) {
|
|
35
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
36
|
+
console.error("Please try reinstalling the package: npm install -g jscan");
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
41
|
+
stdio: "inherit",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
child.on("error", (err) => {
|
|
45
|
+
console.error(`Failed to start jscan: ${err.message}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
child.on("close", (code) => {
|
|
50
|
+
process.exit(code ?? 0);
|
|
51
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jscan",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Code quality analyzer for JavaScript/TypeScript projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"javascript",
|
|
7
|
+
"typescript",
|
|
8
|
+
"code-quality",
|
|
9
|
+
"static-analysis",
|
|
10
|
+
"linter",
|
|
11
|
+
"analyzer",
|
|
12
|
+
"complexity",
|
|
13
|
+
"dead-code"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/ludo-technologies/jscan",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/ludo-technologies/jscan/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ludo-technologies/jscan.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Ludo Technologies",
|
|
25
|
+
"bin": {
|
|
26
|
+
"jscan": "./bin/jscan"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node scripts/download-binary.js"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux",
|
|
37
|
+
"win32"
|
|
38
|
+
],
|
|
39
|
+
"cpu": [
|
|
40
|
+
"x64",
|
|
41
|
+
"arm64"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const https = require("https");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { execSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const packageJson = require("../package.json");
|
|
9
|
+
const version = packageJson.version;
|
|
10
|
+
|
|
11
|
+
const platform = process.platform;
|
|
12
|
+
const arch = process.arch;
|
|
13
|
+
|
|
14
|
+
// Map Node.js platform/arch to Go build names
|
|
15
|
+
const platformMap = {
|
|
16
|
+
darwin: "darwin",
|
|
17
|
+
linux: "linux",
|
|
18
|
+
win32: "windows",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const archMap = {
|
|
22
|
+
x64: "amd64",
|
|
23
|
+
arm64: "arm64",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const platformName = platformMap[platform];
|
|
27
|
+
const archName = archMap[arch];
|
|
28
|
+
|
|
29
|
+
if (!platformName || !archName) {
|
|
30
|
+
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ext = platform === "win32" ? ".exe" : "";
|
|
35
|
+
const binaryName = `jscan-${platformName}-${archName}${ext}`;
|
|
36
|
+
const archiveName = `jscan_${version}_${platformName}_${archName}.tar.gz`;
|
|
37
|
+
const downloadUrl = `https://github.com/ludo-technologies/jscan/releases/download/v${version}/${archiveName}`;
|
|
38
|
+
|
|
39
|
+
const binDir = path.join(__dirname, "..", "bin");
|
|
40
|
+
const binaryPath = path.join(binDir, binaryName);
|
|
41
|
+
const archivePath = path.join(binDir, archiveName);
|
|
42
|
+
|
|
43
|
+
// Skip download if binary already exists
|
|
44
|
+
if (fs.existsSync(binaryPath)) {
|
|
45
|
+
console.log(`jscan binary already exists at ${binaryPath}`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Create bin directory if it doesn't exist
|
|
50
|
+
if (!fs.existsSync(binDir)) {
|
|
51
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.log(`Downloading jscan v${version} for ${platformName}-${archName}...`);
|
|
55
|
+
console.log(`URL: ${downloadUrl}`);
|
|
56
|
+
|
|
57
|
+
function download(url, dest) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const file = fs.createWriteStream(dest);
|
|
60
|
+
|
|
61
|
+
const request = (url) => {
|
|
62
|
+
https
|
|
63
|
+
.get(url, (response) => {
|
|
64
|
+
// Handle redirects
|
|
65
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
66
|
+
request(response.headers.location);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (response.statusCode !== 200) {
|
|
71
|
+
reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
response.pipe(file);
|
|
76
|
+
file.on("finish", () => {
|
|
77
|
+
file.close();
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
})
|
|
81
|
+
.on("error", (err) => {
|
|
82
|
+
fs.unlink(dest, () => {});
|
|
83
|
+
reject(err);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
request(url);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function main() {
|
|
92
|
+
try {
|
|
93
|
+
// Download the archive
|
|
94
|
+
await download(downloadUrl, archivePath);
|
|
95
|
+
console.log("Download complete.");
|
|
96
|
+
|
|
97
|
+
// Extract the archive
|
|
98
|
+
console.log("Extracting...");
|
|
99
|
+
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
|
|
100
|
+
|
|
101
|
+
// Rename the binary
|
|
102
|
+
const extractedBinary = path.join(binDir, `jscan${ext}`);
|
|
103
|
+
if (fs.existsSync(extractedBinary)) {
|
|
104
|
+
fs.renameSync(extractedBinary, binaryPath);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Make it executable (Unix only)
|
|
108
|
+
if (platform !== "win32") {
|
|
109
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Clean up archive
|
|
113
|
+
fs.unlinkSync(archivePath);
|
|
114
|
+
|
|
115
|
+
console.log(`jscan v${version} installed successfully!`);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error(`Failed to install jscan: ${error.message}`);
|
|
118
|
+
console.error("");
|
|
119
|
+
console.error("You can manually download the binary from:");
|
|
120
|
+
console.error(`https://github.com/ludo-technologies/jscan/releases/tag/v${version}`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main();
|