mafit 1.0.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.
Binary file
Binary file
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+ const { spawnSync } = require("node:child_process");
5
+
6
+ const binaryByPlatform = {
7
+ "linux-x64": "mafit-linux-x64",
8
+ "darwin-x64": "mafit-darwin-x64",
9
+ "darwin-arm64": "mafit-darwin-arm64",
10
+ "win32-x64": "mafit-win32-x64.exe"
11
+ };
12
+ const fallbackByPlatform = {
13
+ "win32-arm64": "win32-x64"
14
+ };
15
+ const key = `${process.platform}-${process.arch}`;
16
+ const resolvedKey = binaryByPlatform[key] ? key : (fallbackByPlatform[key] || "");
17
+ const binaryName = binaryByPlatform[resolvedKey];
18
+
19
+ if (!binaryName) {
20
+ console.error(`mafit: unsupported platform ${key}`);
21
+ console.error("supported: linux-x64, darwin-x64, darwin-arm64, win32-x64");
22
+ process.exit(1);
23
+ }
24
+
25
+ if (resolvedKey && resolvedKey !== key) {
26
+ console.error(`mafit: ${key} fallback to ${resolvedKey}`);
27
+ }
28
+
29
+ const binaryPath = path.join(__dirname, binaryName);
30
+ if (!fs.existsSync(binaryPath)) {
31
+ console.error(`mafit: missing binary for ${key}`);
32
+ console.error(`expected file: ${binaryPath}`);
33
+ process.exit(1);
34
+ }
35
+
36
+ if (process.platform !== "win32") {
37
+ try {
38
+ fs.chmodSync(binaryPath, 0o755);
39
+ } catch {}
40
+ }
41
+
42
+ const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
43
+
44
+ if (result.error) {
45
+ console.error(`mafit: failed to start binary: ${binaryPath}`);
46
+ console.error(result.error.message);
47
+ process.exit(1);
48
+ }
49
+
50
+ if (typeof result.status === "number") {
51
+ process.exit(result.status);
52
+ }
53
+
54
+ process.exit(1);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "mafit",
3
+ "version": "1.0.0",
4
+ "description": "mafit tui app",
5
+ "bin": {
6
+ "mafit": "dist/bin/mafit.cjs"
7
+ },
8
+ "files": [
9
+ "dist/bin/**"
10
+ ],
11
+ "scripts": {
12
+ "sync:rust-version": "node scripts/sync-rust-version.cjs",
13
+ "clean": "node scripts/clean-dist.cjs",
14
+ "build:rust": "node scripts/build-rust.cjs",
15
+ "build:launcher": "node scripts/build-launcher.cjs",
16
+ "stage:binary": "node scripts/stage-binary.cjs",
17
+ "verify:binaries": "node scripts/verify-release-binaries.cjs",
18
+ "verify:binaries:core": "node scripts/verify-release-binaries.cjs --required linux-x64,win32-x64",
19
+ "build": "npm run sync:rust-version && npm run clean && npm run build:rust && npm run build:launcher",
20
+ "build:target": "npm run sync:rust-version && npm run build:rust && npm run build:launcher",
21
+ "start": "node scripts/run-bin.cjs",
22
+ "dev": "npm run build && npm run start",
23
+ "prepack": "npm run build:launcher && npm run verify:binaries:core"
24
+ },
25
+ "license": "MIT"
26
+ }