@maton/cli 0.1.5 → 0.1.6-darwin-x64

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/README.md CHANGED
@@ -1,24 +1,9 @@
1
- # Maton CLI
1
+ # Maton CLI — platform binary
2
2
 
3
- Maton's official command line tool, distributed as a thin Node.js wrapper around
4
- a native binary.
5
-
6
- ## Install
7
-
8
- ```sh
9
- npm install -g @maton/cli
10
- ```
11
-
12
- This installs the `maton` command. The wrapper detects your platform at install
13
- time and pulls the matching native binary via npm `optionalDependencies`. Do not
14
- pass `--no-optional` or `--omit=optional`; without the platform package the
15
- wrapper has nothing to launch.
16
-
17
- ## Supported platforms
18
-
19
- - macOS: arm64, x64
20
- - Linux: arm64, x64 (glibc and musl)
21
- - Windows: arm64, x64
3
+ This package contains a precompiled `maton` binary for one specific platform. It
4
+ is not meant to be installed directly. Install [`@maton/cli`](https://www.npmjs.com/package/@maton/cli)
5
+ instead, which selects the right platform package automatically via
6
+ `optionalDependencies`.
22
7
 
23
8
  For source code, releases, and issues, see
24
9
  [github.com/maton-ai/cli](https://github.com/maton-ai/cli).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maton/cli",
3
- "version": "0.1.5",
4
- "description": "Maton's official command line tool",
3
+ "version": "0.1.6-darwin-x64",
4
+ "description": "darwin x64 binary for @maton/cli",
5
5
  "homepage": "https://github.com/maton-ai/cli#readme",
6
6
  "bugs": {
7
7
  "url": "https://github.com/maton-ai/cli/issues"
@@ -11,31 +11,15 @@
11
11
  "url": "git+https://github.com/maton-ai/cli.git"
12
12
  },
13
13
  "license": "SEE LICENSE IN LICENSE",
14
- "type": "module",
15
- "bin": {
16
- "maton": "bin/maton.js"
17
- },
14
+ "os": [
15
+ "darwin"
16
+ ],
17
+ "cpu": [
18
+ "x64"
19
+ ],
18
20
  "files": [
19
- "bin/maton.js",
21
+ "vendor",
20
22
  "LICENSE",
21
23
  "README.md"
22
- ],
23
- "engines": {
24
- "node": ">=16"
25
- },
26
- "optionalDependencies": {
27
- "@maton/cli-darwin-arm64": "npm:@maton/cli@0.1.5-darwin-arm64",
28
- "@maton/cli-darwin-x64": "npm:@maton/cli@0.1.5-darwin-x64",
29
- "@maton/cli-linux-arm": "npm:@maton/cli@0.1.5-linux-arm",
30
- "@maton/cli-linux-arm-musl": "npm:@maton/cli@0.1.5-linux-arm-musl",
31
- "@maton/cli-linux-arm64": "npm:@maton/cli@0.1.5-linux-arm64",
32
- "@maton/cli-linux-arm64-musl": "npm:@maton/cli@0.1.5-linux-arm64-musl",
33
- "@maton/cli-linux-ia32": "npm:@maton/cli@0.1.5-linux-ia32",
34
- "@maton/cli-linux-ia32-musl": "npm:@maton/cli@0.1.5-linux-ia32-musl",
35
- "@maton/cli-linux-x64": "npm:@maton/cli@0.1.5-linux-x64",
36
- "@maton/cli-linux-x64-musl": "npm:@maton/cli@0.1.5-linux-x64-musl",
37
- "@maton/cli-win32-arm64": "npm:@maton/cli@0.1.5-win32-arm64",
38
- "@maton/cli-win32-ia32": "npm:@maton/cli@0.1.5-win32-ia32",
39
- "@maton/cli-win32-x64": "npm:@maton/cli@0.1.5-win32-x64"
40
- }
24
+ ]
41
25
  }
Binary file
package/bin/maton.js DELETED
@@ -1,184 +0,0 @@
1
- #!/usr/bin/env node
2
- // Unified entry point for the Maton CLI.
3
-
4
- import { spawn } from "node:child_process";
5
- import { existsSync } from "fs";
6
- import { createRequire } from "node:module";
7
- import path from "path";
8
- import { fileURLToPath } from "url";
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
- const require = createRequire(import.meta.url);
13
-
14
- const SUPPORTED_PLATFORMS = [
15
- "darwin-arm64",
16
- "darwin-x64",
17
- "linux-arm",
18
- "linux-arm-musl",
19
- "linux-arm64",
20
- "linux-arm64-musl",
21
- "linux-ia32",
22
- "linux-ia32-musl",
23
- "linux-x64",
24
- "linux-x64-musl",
25
- "win32-arm64",
26
- "win32-ia32",
27
- "win32-x64",
28
- ];
29
-
30
- function detectLinuxLibc() {
31
- try {
32
- const report = process.report && process.report.getReport();
33
- if (report && report.header && report.header.glibcVersionRuntime) {
34
- return "glibc";
35
- }
36
- } catch (_) {}
37
- return "musl";
38
- }
39
-
40
- function platformKey() {
41
- const { platform, arch } = process;
42
-
43
- if (platform === "darwin" && (arch === "arm64" || arch === "x64")) {
44
- return `darwin-${arch}`;
45
- }
46
- if (
47
- platform === "win32" &&
48
- (arch === "arm64" || arch === "x64" || arch === "ia32")
49
- ) {
50
- return `win32-${arch}`;
51
- }
52
- if (
53
- platform === "linux" &&
54
- (arch === "arm" || arch === "arm64" || arch === "ia32" || arch === "x64")
55
- ) {
56
- const suffix = detectLinuxLibc() === "musl" ? "-musl" : "";
57
- return `linux-${arch}${suffix}`;
58
- }
59
- return null;
60
- }
61
-
62
- const key = platformKey();
63
- if (!key) {
64
- console.error(
65
- `@maton/cli: unsupported platform ${process.platform}-${process.arch}.`
66
- );
67
- console.error("Supported: " + SUPPORTED_PLATFORMS.join(", ") + ".");
68
- process.exit(1);
69
- }
70
-
71
- const platformPackage = `@maton/cli-${key}`;
72
- const binaryName = process.platform === "win32" ? "maton.exe" : "maton";
73
- const localVendorRoot = path.join(__dirname, "..", "vendor");
74
- const localBinaryPath = path.join(localVendorRoot, key, "maton", binaryName);
75
-
76
- function detectPackageManager() {
77
- const userAgent = process.env.npm_config_user_agent || "";
78
- if (/\bbun\//.test(userAgent)) return "bun";
79
- if (/\bpnpm\//.test(userAgent)) return "pnpm";
80
- if (/\byarn\//.test(userAgent)) return "yarn";
81
- if (/\bnpm\//.test(userAgent)) return "npm";
82
-
83
- const execPath = process.env.npm_execpath || "";
84
- if (execPath.includes("bun")) return "bun";
85
- if (execPath.includes("pnpm")) return "pnpm";
86
- if (execPath.includes("yarn")) return "yarn";
87
-
88
- if (
89
- __dirname.includes(".bun/install/global") ||
90
- __dirname.includes(".bun\\install\\global")
91
- ) {
92
- return "bun";
93
- }
94
- if (
95
- __dirname.includes("/pnpm/global/") ||
96
- __dirname.includes("\\pnpm\\global\\")
97
- ) {
98
- return "pnpm";
99
- }
100
-
101
- return userAgent ? "npm" : null;
102
- }
103
-
104
- function reinstallCommand(pm) {
105
- switch (pm) {
106
- case "bun":
107
- return "bun install -g @maton/cli@latest";
108
- case "pnpm":
109
- return "pnpm install -g @maton/cli@latest";
110
- case "yarn":
111
- return "yarn global add @maton/cli@latest";
112
- case "npm":
113
- default:
114
- return "npm install -g @maton/cli@latest";
115
- }
116
- }
117
-
118
- let vendorRoot;
119
- try {
120
- const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
121
- vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
122
- } catch {
123
- if (existsSync(localBinaryPath)) {
124
- vendorRoot = localVendorRoot;
125
- } else {
126
- const cmd = reinstallCommand(detectPackageManager());
127
- throw new Error(
128
- `Missing optional dependency ${platformPackage}. ` +
129
- `If you used --no-optional or --omit=optional during install, reinstall without it. ` +
130
- `Reinstall Maton: ${cmd}`
131
- );
132
- }
133
- }
134
-
135
- const binaryPath = path.join(vendorRoot, key, "maton", binaryName);
136
-
137
- const env = { ...process.env };
138
- const packageManagerEnvVar =
139
- detectPackageManager() === "bun"
140
- ? "MATON_MANAGED_BY_BUN"
141
- : "MATON_MANAGED_BY_NPM";
142
- env[packageManagerEnvVar] = "1";
143
-
144
- const child = spawn(binaryPath, process.argv.slice(2), {
145
- stdio: "inherit",
146
- env,
147
- windowsHide: true,
148
- });
149
-
150
- child.on("error", (err) => {
151
- console.error(`@maton/cli: failed to launch ${binaryPath}: ${err.message}`);
152
- process.exit(1);
153
- });
154
-
155
- const forwardSignal = (signal) => {
156
- if (child.killed) {
157
- return;
158
- }
159
- try {
160
- child.kill(signal);
161
- } catch {
162
- /* ignore */
163
- }
164
- };
165
-
166
- ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
167
- process.on(sig, () => forwardSignal(sig));
168
- });
169
-
170
- const childResult = await new Promise((resolve) => {
171
- child.on("exit", (code, signal) => {
172
- if (signal) {
173
- resolve({ type: "signal", signal });
174
- } else {
175
- resolve({ type: "code", exitCode: code ?? 1 });
176
- }
177
- });
178
- });
179
-
180
- if (childResult.type === "signal") {
181
- process.kill(process.pid, childResult.signal);
182
- } else {
183
- process.exit(childResult.exitCode);
184
- }