aurix-ai 2.7.8 → 2.7.9
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/package.json +1 -1
- package/scripts/postinstall.mjs +69 -46
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,63 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
// Runs automatically after `npm install` (postinstall hook).
|
|
3
|
+
// Fixes the two things that commonly break aurix on Windows:
|
|
4
|
+
// 1. @opentui/core-win32-x64 optional dependency sometimes gets skipped
|
|
5
|
+
// (network glitch, --omit=optional, pnpm strict).
|
|
6
|
+
// 2. Bun runtime (preferred over Node because it has built-in FFI,
|
|
7
|
+
// no --experimental-ffi flag needed).
|
|
8
|
+
// Safe to re-run; idempotent and skips when already satisfied.
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'fs';
|
|
3
11
|
import { join, dirname } from 'path';
|
|
4
12
|
import { fileURLToPath } from 'url';
|
|
13
|
+
import { spawnSync, execSync } from 'child_process';
|
|
5
14
|
|
|
6
15
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const projectRoot = join(__dirname, '..');
|
|
7
17
|
|
|
8
|
-
console.log(
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
function log(msg) { console.log(`[aurix postinstall] ${msg}`); }
|
|
19
|
+
function run(cmd, args, opts = {}) {
|
|
20
|
+
return spawnSync(cmd, args, { stdio: 'inherit', ...opts }).status === 0;
|
|
21
|
+
}
|
|
11
22
|
|
|
12
|
-
|
|
23
|
+
// ─── 1. Ensure native OpenTUI binary is installed (Windows only) ───────────
|
|
24
|
+
if (process.platform === 'win32') {
|
|
25
|
+
const pkgName = process.arch === 'arm64'
|
|
26
|
+
? '@opentui/core-win32-arm64'
|
|
27
|
+
: '@opentui/core-win32-x64';
|
|
28
|
+
const expected = join(projectRoot, 'node_modules', '@opentui', pkgName.replace('@opentui/', ''));
|
|
13
29
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const pkgPath = join(__dirname, '..', 'node_modules', 'react-reconciler', 'package.json');
|
|
17
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
18
|
-
if (!pkg.exports) {
|
|
19
|
-
pkg.exports = {
|
|
20
|
-
'.': './index.js',
|
|
21
|
-
'./constants': './constants.js',
|
|
22
|
-
'./reflection': './reflection.js',
|
|
23
|
-
'./package.json': './package.json',
|
|
24
|
-
};
|
|
25
|
-
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
|
|
26
|
-
console.log(' ✓ React-reconciler patched\n');
|
|
27
|
-
results.push(['React-reconciler patch', 'success']);
|
|
30
|
+
if (existsSync(expected)) {
|
|
31
|
+
log(`✓ ${pkgName} already installed`);
|
|
28
32
|
} else {
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
log(`⚠ ${pkgName} missing — installing (this optionalDependency is sometimes skipped by npm)`);
|
|
34
|
+
// shell:true needed on Windows so `npm` resolves through npm.cmd
|
|
35
|
+
const ok = run('npm', [
|
|
36
|
+
'install', '--no-save', '--no-audit', '--no-fund', `${pkgName}@0.4.1`,
|
|
37
|
+
], { cwd: projectRoot, shell: true });
|
|
38
|
+
if (!ok) log(`⚠ failed to install ${pkgName} — TUI may fail to start`);
|
|
39
|
+
else log(`✓ ${pkgName} installed`);
|
|
31
40
|
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.warn(' ⚠ Could not patch react-reconciler:', e.message, '\n');
|
|
34
|
-
results.push(['React-reconciler patch', 'failed']);
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
// ─── 2. Hint about Bun (don't auto-install on Windows — UAC prompt) ───────
|
|
37
44
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
execSync('bun --version', { stdio: 'ignore' });
|
|
46
|
+
log('✓ Bun already installed');
|
|
47
|
+
} catch {
|
|
48
|
+
if (process.platform === 'win32') {
|
|
49
|
+
log('');
|
|
50
|
+
log('⚠ Bun not found. Bun is RECOMMENDED on Windows because it has');
|
|
51
|
+
log(' built-in FFI (no --experimental-ffi flag needed).');
|
|
52
|
+
log('');
|
|
53
|
+
log(' To install, run in PowerShell:');
|
|
54
|
+
log(' powershell -c "irm bun.sh/install.ps1 | iex"');
|
|
55
|
+
log('');
|
|
56
|
+
log(' Skipping auto-install to avoid UAC prompts in non-interactive mode.');
|
|
57
|
+
} else {
|
|
58
|
+
log('Installing Bun...');
|
|
59
|
+
if (run('bash', ['-c', 'curl -fsSL https://bun.sh/install | bash'])) {
|
|
60
|
+
log('✓ Bun installed');
|
|
61
|
+
} else {
|
|
62
|
+
log('⚠ Bun install failed — aurix will fall back to Node');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
// ─── 3. Node FFI probe (informative) ──────────────────────────────────────
|
|
68
|
+
try {
|
|
69
|
+
execSync(`"${process.execPath}" -e "require(\\"node:ffi\\")"`, { stdio: 'ignore' });
|
|
70
|
+
log('✓ node:ffi available without flag');
|
|
71
|
+
} catch {
|
|
72
|
+
let flagWorks = false;
|
|
73
|
+
try {
|
|
74
|
+
execSync(`"${process.execPath}" --experimental-ffi -e "0"`, { stdio: 'ignore' });
|
|
75
|
+
flagWorks = true;
|
|
76
|
+
} catch {}
|
|
77
|
+
if (flagWorks) {
|
|
78
|
+
log('ℹ node:ffi requires --experimental-ffi (launcher injects it automatically)');
|
|
79
|
+
} else {
|
|
80
|
+
log('⚠ node:ffi not available on this Node build.');
|
|
81
|
+
log(' Install Bun (recommended) or use official Node from nodejs.org.');
|
|
82
|
+
}
|
|
58
83
|
}
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log('║ For issues: https://github.com/DekaPrayoga/AurixAgent ║');
|
|
63
|
-
console.log('╚═══════════════════════════════════════════════════════════╝\n');
|
|
85
|
+
log('');
|
|
86
|
+
log('✓ postinstall complete. Run `aurix` to start.');
|