ecrypto-cli 1.0.1
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/ecrypto +0 -0
- package/package.json +28 -0
- package/postinstall.js +76 -0
package/bin/ecrypto
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ecrypto-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Military-grade folder encryption tool (npm global installer)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ecrypto": "bin/ecrypto.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node postinstall.js"
|
|
10
|
+
},
|
|
11
|
+
"os": [
|
|
12
|
+
"darwin",
|
|
13
|
+
"linux",
|
|
14
|
+
"win32"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/pandarudra/ecrypto",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/pandarudra/ecrypto.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"encryption",
|
|
23
|
+
"crypto",
|
|
24
|
+
"security",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT"
|
|
28
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const os = require("os");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const https = require("https");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
const version = "v1.0.6";
|
|
9
|
+
|
|
10
|
+
function getBinaryName() {
|
|
11
|
+
const platform = os.platform();
|
|
12
|
+
const arch = os.arch();
|
|
13
|
+
|
|
14
|
+
const archMap = {
|
|
15
|
+
x64: "amd64",
|
|
16
|
+
arm64: "arm64",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const platformMap = {
|
|
20
|
+
win32: "windows",
|
|
21
|
+
darwin: "darwin",
|
|
22
|
+
linux: "linux",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const goos = platformMap[platform];
|
|
26
|
+
const goarch = archMap[arch];
|
|
27
|
+
|
|
28
|
+
if (!goos || !goarch) {
|
|
29
|
+
console.error(`Unsupported platform or architecture: ${platform} ${arch}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return goos === "windows"
|
|
35
|
+
? `ecrypto-${goos}-${goarch}.exe`
|
|
36
|
+
: `ecrypto-${goos}-${goarch}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function download(url, dest, cb) {
|
|
40
|
+
https.get(url, (res) => {
|
|
41
|
+
|
|
42
|
+
// Follow redirects (GitHub releases always redirect once)
|
|
43
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
44
|
+
return download(res.headers.location, dest, cb);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (res.statusCode !== 200) {
|
|
48
|
+
console.error("❌ Failed to download:", res.statusCode, url);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const file = fs.createWriteStream(dest);
|
|
53
|
+
res.pipe(file);
|
|
54
|
+
|
|
55
|
+
file.on("finish", () => file.close(cb));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fileName = getBinaryName();
|
|
60
|
+
const downloadUrl = `https://github.com/pandarudra/ecrypto/releases/download/${version}/${fileName}`;
|
|
61
|
+
|
|
62
|
+
console.log(`⬇️ Downloading ECRYPTO binary: ${downloadUrl}`);
|
|
63
|
+
|
|
64
|
+
// FIX: bin folder should be inside npm/ folder, not root/
|
|
65
|
+
const binDir = path.join(__dirname, "bin");
|
|
66
|
+
const outputPath = path.join(binDir, "ecrypto");
|
|
67
|
+
|
|
68
|
+
// Ensure bin/ exists
|
|
69
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
70
|
+
|
|
71
|
+
download(downloadUrl, outputPath, () => {
|
|
72
|
+
if (os.platform() !== "win32") {
|
|
73
|
+
fs.chmodSync(outputPath, 0o755);
|
|
74
|
+
}
|
|
75
|
+
console.log("✅ ECRYPTO installed successfully.");
|
|
76
|
+
});
|