@unwita-insights/vaxis 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.
- package/bin/vaxis-native +0 -0
- package/bin/vaxis.js +51 -0
- package/package.json +33 -0
- package/scripts/postinstall.js +113 -0
package/bin/vaxis-native
ADDED
|
Binary file
|
package/bin/vaxis.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
import { existsSync, chmodSync } from 'fs';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { platform, arch } from 'os';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
function getPlatformKey() {
|
|
12
|
+
const os = platform();
|
|
13
|
+
const cpu = arch();
|
|
14
|
+
|
|
15
|
+
if (os === 'linux') {
|
|
16
|
+
// Detect musl libc (Alpine Linux, slim Docker images)
|
|
17
|
+
if (existsSync('/lib/ld-musl-x86_64.so.1') || existsSync('/lib/ld-musl-aarch64.so.1')) {
|
|
18
|
+
return `linux-musl-${cpu}`;
|
|
19
|
+
}
|
|
20
|
+
return `linux-${cpu}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (os === 'win32') return `windows-${cpu}`;
|
|
24
|
+
return `${os}-${cpu}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getBinPath() {
|
|
28
|
+
const os = platform();
|
|
29
|
+
const ext = os === 'win32' ? '.exe' : '';
|
|
30
|
+
return join(__dirname, `vaxis-native${ext}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const binPath = getBinPath();
|
|
34
|
+
|
|
35
|
+
if (!existsSync(binPath)) {
|
|
36
|
+
const platformKey = getPlatformKey();
|
|
37
|
+
process.stderr.write(
|
|
38
|
+
`[vaxis] Native binary not found for platform: ${platformKey}\n` +
|
|
39
|
+
`[vaxis] Try reinstalling: npm install -g @unwita-insights/vaxis\n` +
|
|
40
|
+
`[vaxis] Or install from source: cargo install vaxis\n`
|
|
41
|
+
);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Ensure executable bit is set (may be missing if postinstall was skipped)
|
|
46
|
+
if (platform() !== 'win32') {
|
|
47
|
+
try { chmodSync(binPath, 0o755); } catch {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
51
|
+
process.exit(result.status ?? 0);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unwita-insights/vaxis",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vaxis CLI — diagram and architecture tool for AI-assisted software design",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vaxis": "./bin/vaxis.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/postinstall.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"scripts/"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vaxis",
|
|
18
|
+
"diagram",
|
|
19
|
+
"architecture",
|
|
20
|
+
"mermaid",
|
|
21
|
+
"cli",
|
|
22
|
+
"ai"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/unwita/vaxis-cli"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/unwita/vaxis-cli#readme"
|
|
33
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createWriteStream, existsSync, chmodSync, symlinkSync, unlinkSync, renameSync } from 'fs';
|
|
4
|
+
import { join, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { platform, arch } from 'os';
|
|
7
|
+
import https from 'https';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const BIN_DIR = join(__dirname, '..', 'bin');
|
|
11
|
+
const VERSION = process.env.npm_package_version;
|
|
12
|
+
const IS_GLOBAL = process.env.npm_config_global === 'true';
|
|
13
|
+
|
|
14
|
+
function getPlatformKey() {
|
|
15
|
+
const os = platform();
|
|
16
|
+
const cpu = arch();
|
|
17
|
+
|
|
18
|
+
if (os === 'linux') {
|
|
19
|
+
if (existsSync('/lib/ld-musl-x86_64.so.1') || existsSync('/lib/ld-musl-aarch64.so.1')) {
|
|
20
|
+
return `linux-musl-${cpu}`;
|
|
21
|
+
}
|
|
22
|
+
return `linux-${cpu}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (os === 'win32') return `windows-${cpu}`;
|
|
26
|
+
return `${os}-${cpu}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const PLATFORM_MAP = {
|
|
30
|
+
'darwin-arm64': 'vaxis-darwin-arm64',
|
|
31
|
+
'darwin-x64': 'vaxis-darwin-x64',
|
|
32
|
+
'linux-x64': 'vaxis-linux-x64',
|
|
33
|
+
'linux-arm64': 'vaxis-linux-arm64',
|
|
34
|
+
'linux-musl-x64': 'vaxis-linux-musl-x64',
|
|
35
|
+
'windows-x64': 'vaxis-windows-x64.exe',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function downloadFile(url, dest) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const follow = (u) => {
|
|
41
|
+
https.get(u, (res) => {
|
|
42
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
43
|
+
return follow(res.headers.location);
|
|
44
|
+
}
|
|
45
|
+
if (res.statusCode !== 200) {
|
|
46
|
+
res.resume();
|
|
47
|
+
return reject(new Error(`HTTP ${res.statusCode} from ${u}`));
|
|
48
|
+
}
|
|
49
|
+
const tmp = `${dest}.tmp`;
|
|
50
|
+
const file = createWriteStream(tmp);
|
|
51
|
+
res.pipe(file);
|
|
52
|
+
file.on('finish', () => {
|
|
53
|
+
file.close(() => {
|
|
54
|
+
renameSync(tmp, dest);
|
|
55
|
+
resolve();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
file.on('error', reject);
|
|
59
|
+
}).on('error', reject);
|
|
60
|
+
};
|
|
61
|
+
follow(url);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function main() {
|
|
66
|
+
const platformKey = getPlatformKey();
|
|
67
|
+
const binaryName = PLATFORM_MAP[platformKey];
|
|
68
|
+
|
|
69
|
+
if (!binaryName) {
|
|
70
|
+
process.stderr.write(
|
|
71
|
+
`[vaxis] Unsupported platform: ${platformKey}\n` +
|
|
72
|
+
`[vaxis] Install from source: cargo install vaxis\n`
|
|
73
|
+
);
|
|
74
|
+
process.exit(0); // Don't fail the install
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const ext = platform() === 'win32' ? '.exe' : '';
|
|
78
|
+
const dest = join(BIN_DIR, `vaxis-native${ext}`);
|
|
79
|
+
const url = `https://github.com/Unwita-Insights/vaxis-cli/releases/download/v${VERSION}/${binaryName}`;
|
|
80
|
+
|
|
81
|
+
process.stdout.write(`[vaxis] Downloading binary for ${platformKey}...\n`);
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await downloadFile(url, dest);
|
|
85
|
+
|
|
86
|
+
if (platform() !== 'win32') {
|
|
87
|
+
chmodSync(dest, 0o755);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
process.stdout.write(`[vaxis] Installed successfully.\n`);
|
|
91
|
+
|
|
92
|
+
// Global install optimization: replace Node.js shim with direct symlink
|
|
93
|
+
// This eliminates Node.js startup time on every `vaxis` invocation
|
|
94
|
+
if (IS_GLOBAL && platform() !== 'win32') {
|
|
95
|
+
const shim = join(BIN_DIR, 'vaxis.js');
|
|
96
|
+
try {
|
|
97
|
+
unlinkSync(shim);
|
|
98
|
+
symlinkSync(dest, shim);
|
|
99
|
+
process.stdout.write(`[vaxis] Optimized: using native binary directly.\n`);
|
|
100
|
+
} catch {
|
|
101
|
+
// Non-fatal — shim still works
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
process.stderr.write(
|
|
106
|
+
`[vaxis] Binary download failed: ${err.message}\n` +
|
|
107
|
+
`[vaxis] Install from source: cargo install vaxis\n`
|
|
108
|
+
);
|
|
109
|
+
process.exit(0); // Don't fail the install — degrade gracefully
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main();
|