zebflow 0.6.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.
Files changed (3) hide show
  1. package/install.js +100 -0
  2. package/package.json +39 -0
  3. package/run.js +25 -0
package/install.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const https = require("https");
8
+ const { createWriteStream, mkdirSync } = fs;
9
+
10
+ const REPO = "zebflow/zebflow";
11
+ const VERSION = process.env.ZEBFLOW_VERSION || `v${require("./package.json").version}`;
12
+ const BIN_DIR = path.join(__dirname, "bin");
13
+
14
+ function getPlatform() {
15
+ const platform = process.platform;
16
+ const arch = process.arch;
17
+
18
+ const map = {
19
+ "darwin-arm64": { asset: "zebflow-darwin-arm64.tar.gz", binary: "zebflow" },
20
+ "linux-x64": { asset: "zebflow-linux-amd64.tar.gz", binary: "zebflow" },
21
+ "linux-arm64": { asset: "zebflow-linux-arm64.tar.gz", binary: "zebflow" },
22
+ "win32-x64": { asset: "zebflow-windows-amd64.zip", binary: "zebflow.exe" },
23
+ };
24
+
25
+ const key = `${platform}-${arch}`;
26
+ const entry = map[key];
27
+ if (!entry) {
28
+ console.error(`Unsupported platform: ${key}`);
29
+ console.error(`Supported: ${Object.keys(map).join(", ")}`);
30
+ process.exit(1);
31
+ }
32
+ return entry;
33
+ }
34
+
35
+ function downloadFile(url) {
36
+ return new Promise((resolve, reject) => {
37
+ const follow = (url, redirects = 0) => {
38
+ if (redirects > 5) return reject(new Error("Too many redirects"));
39
+ const mod = url.startsWith("https") ? https : require("http");
40
+ mod.get(url, { headers: { "User-Agent": "zebflow-npm-installer" } }, (res) => {
41
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
42
+ return follow(res.headers.location, redirects + 1);
43
+ }
44
+ if (res.statusCode !== 200) {
45
+ return reject(new Error(`Download failed: HTTP ${res.statusCode} from ${url}`));
46
+ }
47
+ const chunks = [];
48
+ res.on("data", (chunk) => chunks.push(chunk));
49
+ res.on("end", () => resolve(Buffer.concat(chunks)));
50
+ res.on("error", reject);
51
+ }).on("error", reject);
52
+ };
53
+ follow(url);
54
+ });
55
+ }
56
+
57
+ async function extractTarGz(buffer, destDir) {
58
+ const tmpFile = path.join(destDir, "_tmp.tar.gz");
59
+ fs.writeFileSync(tmpFile, buffer);
60
+ execSync(`tar -xzf "${tmpFile}" -C "${destDir}"`, { stdio: "pipe" });
61
+ fs.unlinkSync(tmpFile);
62
+ }
63
+
64
+ async function extractZip(buffer, destDir) {
65
+ const tmpFile = path.join(destDir, "_tmp.zip");
66
+ fs.writeFileSync(tmpFile, buffer);
67
+ execSync(`tar -xf "${tmpFile}" -C "${destDir}"`, { stdio: "pipe" });
68
+ fs.unlinkSync(tmpFile);
69
+ }
70
+
71
+ async function main() {
72
+ const { asset, binary } = getPlatform();
73
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${asset}`;
74
+
75
+ console.log(`[zebflow] Downloading ${asset} (${VERSION})...`);
76
+
77
+ const buffer = await downloadFile(url);
78
+
79
+ mkdirSync(BIN_DIR, { recursive: true });
80
+
81
+ if (asset.endsWith(".tar.gz")) {
82
+ await extractTarGz(buffer, BIN_DIR);
83
+ } else {
84
+ await extractZip(buffer, BIN_DIR);
85
+ }
86
+
87
+ const binaryPath = path.join(BIN_DIR, binary);
88
+ if (!fs.existsSync(binaryPath)) {
89
+ console.error(`[zebflow] Binary not found after extraction: ${binaryPath}`);
90
+ process.exit(1);
91
+ }
92
+
93
+ fs.chmodSync(binaryPath, 0o755);
94
+ console.log(`[zebflow] Installed ${binary} to ${BIN_DIR}`);
95
+ }
96
+
97
+ main().catch((err) => {
98
+ console.error(`[zebflow] Installation failed: ${err.message}`);
99
+ process.exit(1);
100
+ });
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "zebflow",
3
+ "version": "0.6.0",
4
+ "description": "Reactive web automation platform — pipelines, templates, and real-time collaboration in a single binary.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/zebflow/zebflow"
9
+ },
10
+ "homepage": "https://github.com/zebflow/zebflow",
11
+ "bin": {
12
+ "zebflow": "run.js"
13
+ },
14
+ "scripts": {
15
+ "postinstall": "node install.js"
16
+ },
17
+ "keywords": [
18
+ "zebflow",
19
+ "pipeline",
20
+ "automation",
21
+ "reactive",
22
+ "web",
23
+ "server",
24
+ "wasm",
25
+ "mcp"
26
+ ],
27
+ "os": [
28
+ "darwin",
29
+ "linux",
30
+ "win32"
31
+ ],
32
+ "cpu": [
33
+ "x64",
34
+ "arm64"
35
+ ],
36
+ "engines": {
37
+ "node": ">=16"
38
+ }
39
+ }
package/run.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("child_process");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+
8
+ const binary = process.platform === "win32" ? "zebflow.exe" : "zebflow";
9
+ const binaryPath = path.join(__dirname, "bin", binary);
10
+
11
+ if (!fs.existsSync(binaryPath)) {
12
+ console.error("[zebflow] Binary not found. Run `npm rebuild zebflow` or reinstall.");
13
+ process.exit(1);
14
+ }
15
+
16
+ const child = spawn(binaryPath, process.argv.slice(2), {
17
+ stdio: "inherit",
18
+ env: process.env,
19
+ });
20
+
21
+ child.on("close", (code) => process.exit(code ?? 1));
22
+ child.on("error", (err) => {
23
+ console.error(`[zebflow] Failed to start: ${err.message}`);
24
+ process.exit(1);
25
+ });