sails-decl-rs 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,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+
7
+ function getBinaryPath() {
8
+ const base = path.join(__dirname, "..", "native");
9
+ const exe = process.platform === "win32" ? "sails-decl-rs.exe" : "sails-decl-rs";
10
+ return path.join(base, exe);
11
+ }
12
+
13
+ const binPath = getBinaryPath();
14
+
15
+ if (!fs.existsSync(binPath)) {
16
+ console.error("sails-decl-rs binary not found. Try reinstalling the package.");
17
+ process.exit(1);
18
+ }
19
+
20
+ const result = spawnSync(binPath, process.argv.slice(2), {
21
+ stdio: "inherit"
22
+ });
23
+
24
+ process.exit(result.status ?? 1);
package/install.js ADDED
@@ -0,0 +1,61 @@
1
+ const https = require("https");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const os = require("os");
5
+
6
+ const VERSION = "v0.1.0";
7
+ const REPO = "rsolizPL/sails-decl-rs";
8
+
9
+ function targetTriple() {
10
+ const platform = process.platform;
11
+ const arch = process.arch;
12
+
13
+ if (platform === "darwin" && arch === "x64") return "x86_64-apple-darwin";
14
+ if (platform === "darwin" && arch === "arm64") return "aarch64-apple-darwin";
15
+ if (platform === "linux" && arch === "x64") return "x86_64-unknown-linux-gnu";
16
+ if (platform === "linux" && arch === "arm64") return "aarch64-unknown-linux-gnu";
17
+ if (platform === "win32" && arch === "x64") return "x86_64-pc-windows-msvc";
18
+
19
+ throw new Error(`Unsupported platform: ${platform} ${arch}`);
20
+ }
21
+
22
+ function binaryName() {
23
+ return process.platform === "win32" ? "sails-decl-rs.exe" : "sails-decl-rs";
24
+ }
25
+
26
+ function download(url, dest) {
27
+ return new Promise((resolve, reject) => {
28
+ https.get(url, res => {
29
+ if (res.statusCode !== 200) {
30
+ reject(new Error(`Download failed: ${res.statusCode}`));
31
+ return;
32
+ }
33
+
34
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
35
+ const file = fs.createWriteStream(dest);
36
+ res.pipe(file);
37
+ file.on("finish", () => file.close(resolve));
38
+ }).on("error", reject);
39
+ });
40
+ }
41
+
42
+ (async () => {
43
+ try {
44
+ const triple = targetTriple();
45
+ const name = binaryName();
46
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${name}-${triple}`;
47
+ const out = path.join(__dirname, "native", name);
48
+
49
+ console.log(`Downloading sails-decl-rs (${triple})...`);
50
+ await download(url, out);
51
+
52
+ if (process.platform !== "win32") {
53
+ fs.chmodSync(out, 0o755);
54
+ }
55
+
56
+ console.log("sails-decl-rs installed successfully");
57
+ } catch (err) {
58
+ console.error(err.message);
59
+ process.exit(1);
60
+ }
61
+ })();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "sails-decl-rs",
3
+ "version": "0.1.0",
4
+ "description": "Rust-powered CLI for sails-decl",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rsolizPL/sails-decl-rs.git"
9
+ },
10
+ "bin": {
11
+ "sails-decl-rs": "bin/sails-decl-rs.js"
12
+ },
13
+ "scripts": {
14
+ "postinstall": "node install.js"
15
+ },
16
+ "os": ["darwin", "linux", "win32"],
17
+ "cpu": ["x64", "arm64"],
18
+ "files": [
19
+ "bin",
20
+ "install.js"
21
+ ]
22
+ }