yaver-cli 1.96.4 → 1.96.6

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.
Files changed (2) hide show
  1. package/package.json +5 -1
  2. package/src/postinstall.js +59 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaver-cli",
3
- "version": "1.96.4",
3
+ "version": "1.96.6",
4
4
  "mcpName": "io.github.kivanccakmak/yaver",
5
5
  "description": "Unified npm bootstrap for the Yaver agent and push-to-device React Native tooling",
6
6
  "bin": {
@@ -10,6 +10,10 @@
10
10
  "yaver-cli": "bin/yaver-mcp"
11
11
  },
12
12
  "main": "src/index.js",
13
+ "scripts": {
14
+ "postinstall": "node src/postinstall.js",
15
+ "preuninstall": "node src/preuninstall.js"
16
+ },
13
17
  "files": [
14
18
  "bin/",
15
19
  "src/",
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ // npm postinstall hook — prefetch the Yaver agent and provision the
3
+ // Yaver-managed Hermes reload stack on global installs so a fresh
4
+ // Linux/WSL/macOS box can get to headless auth + Open in Yaver
5
+ // without an extra `yaver install mobile` step.
6
+ //
7
+ // Must NEVER fail npm install. This is best-effort bootstrap only.
8
+
9
+ const { ensureAgentBinary, runAgentCommand } = require("./agent-runtime");
10
+
11
+ function envEnabled(name) {
12
+ const raw = String(process.env[name] || "").trim().toLowerCase();
13
+ return raw === "1" || raw === "true" || raw === "yes";
14
+ }
15
+
16
+ function isGlobalInstall() {
17
+ if (envEnabled("YAVER_FORCE_POSTINSTALL_BOOTSTRAP")) {
18
+ return true;
19
+ }
20
+ return String(process.env.npm_config_global || "").trim().toLowerCase() === "true";
21
+ }
22
+
23
+ function log(message) {
24
+ console.error(`[yaver postinstall] ${message}`);
25
+ }
26
+
27
+ async function main() {
28
+ if (envEnabled("YAVER_SKIP_POSTINSTALL") || envEnabled("YAVER_SKIP_POSTINSTALL_BOOTSTRAP")) {
29
+ return;
30
+ }
31
+ if (!isGlobalInstall()) {
32
+ return;
33
+ }
34
+
35
+ try {
36
+ await ensureAgentBinary({ quiet: true });
37
+ } catch (error) {
38
+ log(`Skipping agent prefetch: ${error.message}`);
39
+ return;
40
+ }
41
+
42
+ if (process.platform !== "linux" && process.platform !== "darwin") {
43
+ return;
44
+ }
45
+ if (envEnabled("YAVER_SKIP_POSTINSTALL_MOBILE")) {
46
+ return;
47
+ }
48
+
49
+ try {
50
+ await runAgentCommand(["install", "mobile"], { quiet: true });
51
+ log("Provisioned Hermes reload stack for Yaver mobile.");
52
+ } catch (error) {
53
+ log(`Skipping mobile bootstrap: ${error.message}`);
54
+ }
55
+ }
56
+
57
+ main()
58
+ .then(() => process.exit(0))
59
+ .catch(() => process.exit(0));