@onproper/cli 0.0.0-stage → 1.0.2
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/proper +4 -0
- package/package.json +18 -3
- package/postinstall.js +84 -0
- package/README.md +0 -3
package/bin/proper
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onproper/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "The Zero-Trust Entity Orchestration & Compliance Engine",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"proper": "bin/proper"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node postinstall.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cdc",
|
|
14
|
+
"postgres",
|
|
15
|
+
"compliance",
|
|
16
|
+
"webhook",
|
|
17
|
+
"proper"
|
|
18
|
+
],
|
|
19
|
+
"author": "Proper",
|
|
20
|
+
"license": "MIT"
|
|
6
21
|
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// 🔥 THE FIX: Dynamically read the version NPM just installed
|
|
8
|
+
const packageJson = require('./package.json');
|
|
9
|
+
const VERSION = `v${packageJson.version}`; // Translates "1.0.0" to "v1.0.0"
|
|
10
|
+
const REPO = 'vulsys/proper-engine';
|
|
11
|
+
|
|
12
|
+
// 1. Map Node's OS/Arch to Go's OS/Arch
|
|
13
|
+
const platformMap = {
|
|
14
|
+
darwin: 'darwin',
|
|
15
|
+
linux: 'linux',
|
|
16
|
+
win32: 'windows'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const archMap = {
|
|
20
|
+
x64: 'amd64',
|
|
21
|
+
arm64: 'arm64'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const platform = platformMap[os.platform()];
|
|
25
|
+
const arch = archMap[os.arch()];
|
|
26
|
+
|
|
27
|
+
if (!platform || !arch) {
|
|
28
|
+
console.error(`❌ @onproper/cli does not support ${os.platform()} ${os.arch()}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 2. Build the exact GitHub Release URL
|
|
33
|
+
let binaryName = `proper-${platform}-${arch}`;
|
|
34
|
+
if (platform === 'windows') {
|
|
35
|
+
binaryName += '.exe';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const downloadUrl = `https://github.com/${REPO}/releases/download/${VERSION}/${binaryName}`;
|
|
39
|
+
|
|
40
|
+
// 3. Prepare the destination folder
|
|
41
|
+
const binDir = path.join(__dirname, 'bin');
|
|
42
|
+
if (!fs.existsSync(binDir)) {
|
|
43
|
+
fs.mkdirSync(binDir);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const destFile = path.join(binDir, platform === 'windows' ? 'proper.exe' : 'proper');
|
|
47
|
+
|
|
48
|
+
// 4. Download the binary
|
|
49
|
+
console.log(`⬇️ Downloading Proper CDC Engine (${binaryName})...`);
|
|
50
|
+
|
|
51
|
+
https.get(downloadUrl, (res) => {
|
|
52
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
53
|
+
// Follow GitHub's redirect to the actual AWS S3 bucket
|
|
54
|
+
https.get(res.headers.location, handleDownload).on('error', handleError);
|
|
55
|
+
} else {
|
|
56
|
+
handleDownload(res);
|
|
57
|
+
}
|
|
58
|
+
}).on('error', handleError);
|
|
59
|
+
|
|
60
|
+
function handleDownload(res) {
|
|
61
|
+
if (res.statusCode !== 200) {
|
|
62
|
+
console.error(`❌ Failed to download binary. Status Code: ${res.statusCode}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const fileStream = fs.createWriteStream(destFile);
|
|
67
|
+
res.pipe(fileStream);
|
|
68
|
+
|
|
69
|
+
fileStream.on('finish', () => {
|
|
70
|
+
fileStream.close();
|
|
71
|
+
|
|
72
|
+
// 5. Make it executable for Mac/Linux
|
|
73
|
+
if (platform !== 'windows') {
|
|
74
|
+
execSync(`chmod +x ${destFile}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('✅ Proper installed successfully. Run `proper init` to begin.');
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function handleError(err) {
|
|
82
|
+
console.error(`❌ Download error: ${err.message}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
package/README.md
DELETED