deepdeps 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.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ const { join } = require('path');
3
+ const { spawnSync } = require('child_process');
4
+ const { existsSync } = require('fs');
5
+
6
+ const binaryName = process.platform === 'win32' ? 'deepdeps.exe' : 'deepdeps';
7
+ const binaryPath = join(__dirname, binaryName);
8
+
9
+ if (!existsSync(binaryPath)) {
10
+ console.error('deepdeps binary not found. Run npm install to download it.');
11
+ console.error('Or install from source: cargo install deepdeps');
12
+ process.exit(1);
13
+ }
14
+
15
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
16
+ stdio: 'inherit',
17
+ env: process.env,
18
+ });
19
+
20
+ process.exit(result.status ?? 1);
package/install.js ADDED
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env node
2
+ const {
3
+ existsSync,
4
+ mkdirSync,
5
+ createWriteStream,
6
+ chmodSync,
7
+ readFileSync,
8
+ writeFileSync,
9
+ renameSync,
10
+ unlinkSync,
11
+ rmSync,
12
+ readdirSync,
13
+ } = require("fs");
14
+ const { join, resolve } = require("path");
15
+ const https = require("https");
16
+ const http = require("http");
17
+ const { platform, arch } = process;
18
+ const { execSync } = require("child_process");
19
+
20
+ function detectPlatform() {
21
+ const osMap = {
22
+ linux: "linux",
23
+ darwin: "darwin",
24
+ win32: "win32",
25
+ };
26
+ const archMap = {
27
+ x64: "x64",
28
+ arm64: "arm64",
29
+ };
30
+ const os = osMap[platform];
31
+ const cpu = archMap[arch];
32
+ if (!os || !cpu) {
33
+ console.error(`Unsupported platform: ${platform}-${arch}`);
34
+ console.error("Please install from source: cargo install deepdeps");
35
+ process.exit(1);
36
+ }
37
+ return `${os}-${cpu}`;
38
+ }
39
+
40
+ function getPlatformConfig(platformKey) {
41
+ const configPath = join(__dirname, "platforms.json");
42
+ const platforms = JSON.parse(readFileSync(configPath, "utf-8"));
43
+ const cfg = platforms[platformKey];
44
+ if (!cfg) {
45
+ console.error(`No build available for ${platformKey}`);
46
+ process.exit(1);
47
+ }
48
+ return cfg;
49
+ }
50
+
51
+ function download(url, dest) {
52
+ return new Promise((resolve, reject) => {
53
+ const file = createWriteStream(dest);
54
+ const protocol = url.startsWith("https") ? https : http;
55
+ protocol
56
+ .get(url, (response) => {
57
+ if (
58
+ response.statusCode >= 300 &&
59
+ response.statusCode < 400 &&
60
+ response.headers.location
61
+ ) {
62
+ download(response.headers.location, dest).then(resolve).catch(reject);
63
+ return;
64
+ }
65
+ if (response.statusCode !== 200) {
66
+ reject(
67
+ new Error(`Download failed with status ${response.statusCode}`),
68
+ );
69
+ return;
70
+ }
71
+ response.pipe(file);
72
+ file.on("finish", () => {
73
+ file.close();
74
+ resolve();
75
+ });
76
+ })
77
+ .on("error", reject);
78
+ });
79
+ }
80
+
81
+ async function install() {
82
+ const binDir = join(__dirname, "bin");
83
+ if (!existsSync(binDir)) mkdirSync(binDir, { recursive: true });
84
+
85
+ const platformKey = detectPlatform();
86
+ const config = getPlatformConfig(platformKey);
87
+ const binaryName = platform === "win32" ? "deepdeps.exe" : "deepdeps";
88
+ const binaryPath = join(binDir, binaryName);
89
+
90
+ if (existsSync(binaryPath)) {
91
+ console.log("deepdeps binary already installed");
92
+ return;
93
+ }
94
+
95
+ console.log(`Downloading deepdeps for ${platformKey}...`);
96
+ const archivePath = join(
97
+ binDir,
98
+ `deepdeps.${platform === "win32" ? "zip" : "tar.gz"}`,
99
+ );
100
+
101
+ try {
102
+ await download(config.url, archivePath);
103
+ console.log("Extracting...");
104
+ const extractDir = join(binDir, "extract");
105
+ if (!existsSync(extractDir)) mkdirSync(extractDir);
106
+
107
+ if (platform === "win32") {
108
+ execSync(
109
+ `powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force"`,
110
+ { stdio: "pipe" },
111
+ );
112
+ } else {
113
+ execSync(`tar xzf "${archivePath}" -C "${extractDir}"`, {
114
+ stdio: "pipe",
115
+ });
116
+ }
117
+
118
+ const extractedBinary = join(extractDir, binaryName);
119
+ if (existsSync(extractedBinary)) {
120
+ renameSync(extractedBinary, binaryPath);
121
+ } else {
122
+ const files = readdirSync(extractDir);
123
+ const bin = files.find((f) => f === binaryName || f.endsWith(binaryName));
124
+ if (bin) {
125
+ renameSync(join(extractDir, bin), binaryPath);
126
+ }
127
+ }
128
+
129
+ chmodSync(binaryPath, 0o755);
130
+
131
+ unlinkSync(archivePath);
132
+ rmSync(extractDir, { recursive: true, force: true });
133
+
134
+ console.log(`deepdeps installed successfully`);
135
+ } catch (err) {
136
+ console.error("Installation failed:", err.message);
137
+ console.error("Please install via cargo: cargo install deepdeps");
138
+ process.exit(1);
139
+ }
140
+ }
141
+
142
+ install();
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "deepdeps",
3
+ "version": "0.1.0",
4
+ "description": "See what you're really installing — dependency analysis tool",
5
+ "bin": {
6
+ "deepdeps": "bin/deepdeps.js"
7
+ },
8
+ "scripts": {
9
+ "install": "node install.js",
10
+ "postinstall": "node bin/deepdeps.js --help || true"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "install.js",
15
+ "platforms.json"
16
+ ],
17
+ "keywords": [
18
+ "dependencies",
19
+ "analysis",
20
+ "security",
21
+ "supply-chain",
22
+ "dependency-graph"
23
+ ],
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/sqrilizz/deepdeps.git"
28
+ },
29
+ "engines": {
30
+ "node": ">=16"
31
+ },
32
+ "preferUnplugged": true
33
+ }
package/platforms.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "linux-x64": {
3
+ "rust-target": "x86_64-unknown-linux-gnu",
4
+ "url": "https://github.com/sqrilizz/deepdeps/releases/download/v0.1.0/deepdeps-x86_64-unknown-linux-gnu.tar.gz"
5
+ },
6
+ "linux-arm64": {
7
+ "rust-target": "aarch64-unknown-linux-gnu",
8
+ "url": "https://github.com/sqrilizz/deepdeps/releases/download/v0.1.0/deepdeps-aarch64-unknown-linux-gnu.tar.gz"
9
+ },
10
+ "darwin-x64": {
11
+ "rust-target": "x86_64-apple-darwin",
12
+ "url": "https://github.com/sqrilizz/deepdeps/releases/download/v0.1.0/deepdeps-x86_64-apple-darwin.tar.gz"
13
+ },
14
+ "darwin-arm64": {
15
+ "rust-target": "aarch64-apple-darwin",
16
+ "url": "https://github.com/sqrilizz/deepdeps/releases/download/v0.1.0/deepdeps-aarch64-apple-darwin.tar.gz"
17
+ },
18
+ "win32-x64": {
19
+ "rust-target": "x86_64-pc-windows-msvc",
20
+ "url": "https://github.com/sqrilizz/deepdeps/releases/download/v0.1.0/deepdeps-x86_64-pc-windows-msvc.zip"
21
+ }
22
+ }