@azula-app/cli 0.1.1
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/azula.js +95 -0
- package/package.json +37 -0
package/bin/azula.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Launcher for the `@azula-app/cli` meta package. Resolves the platform-specific
|
|
5
|
+
// binary published as an npm optionalDependency and execs it, passing
|
|
6
|
+
// through argv/stdio untouched. This is the file that ships inside the
|
|
7
|
+
// published `@azula-app/cli` package at `bin/azula.js` (see ../package.json's
|
|
8
|
+
// "bin" field and ../generate.mjs, which copies it in place).
|
|
9
|
+
//
|
|
10
|
+
// Layout this expects, matching what dist/npm/generate.mjs emits:
|
|
11
|
+
// node_modules/@azula-app/cli/bin/azula.js (this file)
|
|
12
|
+
// node_modules/@azula-app/cli-<platform>/bin/azula (the real binary)
|
|
13
|
+
|
|
14
|
+
const { spawnSync } = require("node:child_process");
|
|
15
|
+
const path = require("node:path");
|
|
16
|
+
|
|
17
|
+
// process.platform + process.arch -> the npm platform package carrying the
|
|
18
|
+
// matching prebuilt `azula` binary. Keep in sync with:
|
|
19
|
+
// - the release matrix in .github/workflows/release.yml
|
|
20
|
+
// - the TARGETS list in dist/npm/generate.mjs
|
|
21
|
+
const PLATFORM_PACKAGES = {
|
|
22
|
+
"darwin-arm64": "@azula-app/cli-darwin-arm64",
|
|
23
|
+
"darwin-x64": "@azula-app/cli-darwin-x64",
|
|
24
|
+
"linux-x64": "@azula-app/cli-linux-x64",
|
|
25
|
+
"linux-arm64": "@azula-app/cli-linux-arm64",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function unsupportedPlatformMessage(key) {
|
|
29
|
+
const supported = Object.keys(PLATFORM_PACKAGES).sort().join(", ");
|
|
30
|
+
return [
|
|
31
|
+
`azula: no prebuilt binary for this platform (${key}).`,
|
|
32
|
+
`Supported platforms: ${supported}.`,
|
|
33
|
+
"Build from source instead: `cargo install azula` (requires a Rust toolchain).",
|
|
34
|
+
"https://github.com/Azula-App/azula-cli",
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function missingPackageMessage(pkgName) {
|
|
39
|
+
return [
|
|
40
|
+
`azula: the platform package "${pkgName}" is not installed.`,
|
|
41
|
+
"This usually means npm skipped an optionalDependency — a lockfile from",
|
|
42
|
+
"a different platform, an offline/cached install, or `--omit=optional`.",
|
|
43
|
+
`Try: npm install ${pkgName}`,
|
|
44
|
+
"Or reinstall clean: npm install @azula-app/cli --force",
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function resolveBinaryPath() {
|
|
49
|
+
const key = `${process.platform}-${process.arch}`;
|
|
50
|
+
const pkgName = PLATFORM_PACKAGES[key];
|
|
51
|
+
if (!pkgName) {
|
|
52
|
+
return { error: unsupportedPlatformMessage(key) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let pkgDir;
|
|
56
|
+
try {
|
|
57
|
+
// require.resolve walks node_modules resolution, so this finds the
|
|
58
|
+
// package whether it landed flat or nested (older npm hoisting).
|
|
59
|
+
pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
|
|
60
|
+
} catch {
|
|
61
|
+
return { error: missingPackageMessage(pkgName) };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const binName = process.platform === "win32" ? "azula.exe" : "azula";
|
|
65
|
+
return { binaryPath: path.join(pkgDir, "bin", binName) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function main() {
|
|
69
|
+
const { binaryPath, error } = resolveBinaryPath();
|
|
70
|
+
if (error) {
|
|
71
|
+
console.error(error);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
77
|
+
stdio: "inherit",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (result.error) {
|
|
81
|
+
console.error(`azula: failed to launch "${binaryPath}": ${result.error.message}`);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (result.signal) {
|
|
87
|
+
// Mirror the child's termination signal as best node allows.
|
|
88
|
+
process.exitCode = 1;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
process.exitCode = result.status === null ? 1 : result.status;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@azula-app/cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "azula CLI — pair, message, and drive the azula p2p app from the command line, and run it as an MCP server (`npx -y @azula-app/cli mcp`).",
|
|
5
|
+
"homepage": "https://azula.app",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Azula-App/azula-cli.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT OR Apache-2.0",
|
|
11
|
+
"bin": {
|
|
12
|
+
"azula": "bin/azula.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=16"
|
|
19
|
+
},
|
|
20
|
+
"os": [
|
|
21
|
+
"darwin",
|
|
22
|
+
"linux"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"azula",
|
|
26
|
+
"iroh",
|
|
27
|
+
"p2p",
|
|
28
|
+
"mcp",
|
|
29
|
+
"cli"
|
|
30
|
+
],
|
|
31
|
+
"optionalDependencies": {
|
|
32
|
+
"@azula-app/cli-darwin-arm64": "0.1.1",
|
|
33
|
+
"@azula-app/cli-darwin-x64": "0.1.1",
|
|
34
|
+
"@azula-app/cli-linux-x64": "0.1.1",
|
|
35
|
+
"@azula-app/cli-linux-arm64": "0.1.1"
|
|
36
|
+
}
|
|
37
|
+
}
|