@qablehq/atto 0.0.28 → 0.0.29

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/atto.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Opens the built Atto desktop window. Installed as the `atto` command.
3
3
  // If a silent update was queued on the previous quit, kick it off in the
4
4
  // background — never block the window on npm install.
5
- const { spawn } = require("node:child_process");
5
+ const { spawn, spawnSync } = require("node:child_process");
6
6
  const fs = require("node:fs");
7
7
  const os = require("node:os");
8
8
  const path = require("node:path");
@@ -48,17 +48,63 @@ function kickPendingSilentUpdate() {
48
48
  }
49
49
  }
50
50
 
51
+ /** True when Electron's extracted binary looks complete (not a half-finished download). */
52
+ function electronLooksReady(electronPkgDir) {
53
+ const pathFile = path.join(electronPkgDir, "path.txt");
54
+ if (!fs.existsSync(pathFile)) return false;
55
+ const rel = fs.readFileSync(pathFile, "utf8").trim();
56
+ if (!rel) return false;
57
+ const binary = path.join(electronPkgDir, "dist", rel);
58
+ try {
59
+ const st = fs.statSync(binary);
60
+ // A real Electron binary is tens of MB; a stub/partial extract is tiny.
61
+ return st.isFile() && st.size > 1_000_000;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+
67
+ function ensureElectronBinary(electronPkgDir) {
68
+ if (electronLooksReady(electronPkgDir)) return true;
69
+ console.log("Downloading Electron binary...");
70
+ const installJs = path.join(electronPkgDir, "install.js");
71
+ if (!fs.existsSync(installJs)) return false;
72
+ const result = spawnSync(process.execPath, [installJs], { stdio: "inherit" });
73
+ return result.status === 0 && electronLooksReady(electronPkgDir);
74
+ }
75
+
51
76
  kickPendingSilentUpdate();
52
77
 
78
+ const appDir = path.resolve(__dirname, "..");
79
+ const rendererHtml = path.join(appDir, "out", "renderer", "index.html");
80
+ if (!fs.existsSync(rendererHtml)) {
81
+ console.error(
82
+ "Atto UI files are missing (out/renderer/index.html). Reinstall with:\n npm install -g @qablehq/atto@latest --prefix \"$HOME/.local\""
83
+ );
84
+ process.exit(1);
85
+ }
86
+
53
87
  let electronPath;
54
88
  try {
55
- electronPath = require("electron");
56
- } catch {
89
+ // Prefer resolving from this package so global/prefix installs find the right copy.
90
+ const electronPkgDir = path.dirname(require.resolve("electron/package.json", { paths: [appDir] }));
91
+ if (!ensureElectronBinary(electronPkgDir)) {
92
+ console.error(
93
+ "Electron failed to install. Fix with:\n cd \"" +
94
+ path.join(appDir, "node_modules", "electron") +
95
+ '" && node install.js'
96
+ );
97
+ process.exit(1);
98
+ }
99
+ // Fresh require after install.js may have written path.txt / dist.
100
+ delete require.cache[require.resolve("electron", { paths: [appDir] })];
101
+ electronPath = require(require.resolve("electron", { paths: [appDir] }));
102
+ } catch (error) {
57
103
  console.error("Atto could not find Electron. Install again with: npm install -g @qablehq/atto");
104
+ console.error(error instanceof Error ? error.message : String(error));
58
105
  process.exit(1);
59
106
  }
60
107
 
61
- const appDir = path.resolve(__dirname, "..");
62
108
  const child = spawn(electronPath, [appDir], {
63
109
  stdio: "inherit",
64
110
  env: { ...process.env, ATTO_NPM_PACKAGE: "1" },
package/out/main/index.js CHANGED
@@ -12708,15 +12708,6 @@ function setupAutoUpdater() {
12708
12708
  });
12709
12709
  }
12710
12710
  registerMediaProtocolScheme();
12711
- function warmChromiumInBackground() {
12712
- const check = chromiumExecutable();
12713
- if (check.available) return;
12714
- console.log("[atto] Chromium missing — downloading in background");
12715
- void installChromium().then((result) => {
12716
- if (result.ok) console.log("[atto] Chromium ready");
12717
- else console.warn("[atto] Chromium download failed:", result.error);
12718
- });
12719
- }
12720
12711
  function createMainWindow() {
12721
12712
  const mainWindow = new electron.BrowserWindow({
12722
12713
  width: 1320,
@@ -12751,7 +12742,6 @@ function createMainWindow() {
12751
12742
  electron.app.whenReady().then(() => {
12752
12743
  registerMediaProtocol();
12753
12744
  createMainWindow();
12754
- warmChromiumInBackground();
12755
12745
  const engine = process.env.TAA_ENGINE === "mock" ? new MockFixturePlayer() : new RealEngine();
12756
12746
  registerIpcHandlers(engine);
12757
12747
  electron.app.on("before-quit", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qablehq/atto",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Atto — AI-assisted desktop test automation",
5
5
  "homepage": "https://github.com/QAbleHQ/Atto",
6
6
  "author": {
@@ -1,6 +1,75 @@
1
1
  #!/usr/bin/env node
2
- // Intentionally a no-op on npm install.
3
- // Chromium is large; downloading it during `npm install -g` makes first setup feel stuck.
4
- // The desktop app fetches Chromium in the background after the window opens (and again
5
- // before the first browser session if needed).
2
+ // Global install: download Electron (if incomplete) + Playwright Chromium together,
3
+ // same as the original setup flow — finish install with binaries ready.
4
+ const { spawnSync } = require("node:child_process");
5
+ const { createRequire } = require("node:module");
6
+ const fs = require("node:fs");
7
+ const path = require("node:path");
8
+
9
+ if (process.env.npm_config_global !== "true") {
10
+ process.exit(0);
11
+ }
12
+
13
+ const pkgRoot = path.join(__dirname, "..");
14
+ const requireFromPackage = createRequire(path.join(pkgRoot, "package.json"));
15
+
16
+ function electronLooksReady(electronPkgDir) {
17
+ const pathFile = path.join(electronPkgDir, "path.txt");
18
+ if (!fs.existsSync(pathFile)) return false;
19
+ const rel = fs.readFileSync(pathFile, "utf8").trim();
20
+ if (!rel) return false;
21
+ const binary = path.join(electronPkgDir, "dist", rel);
22
+ try {
23
+ const st = fs.statSync(binary);
24
+ return st.isFile() && st.size > 1_000_000;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+
30
+ function ensureElectron() {
31
+ let electronPkgDir;
32
+ try {
33
+ electronPkgDir = path.dirname(requireFromPackage.resolve("electron/package.json"));
34
+ } catch {
35
+ console.warn("[atto] Electron package missing. Re-run: npm install -g @qablehq/atto");
36
+ return;
37
+ }
38
+ if (electronLooksReady(electronPkgDir)) {
39
+ console.log("[atto] Electron ready.");
40
+ return;
41
+ }
42
+ console.log("[atto] Downloading Electron binary...");
43
+ const installJs = path.join(electronPkgDir, "install.js");
44
+ if (!fs.existsSync(installJs)) {
45
+ console.warn("[atto] Electron install.js missing.");
46
+ return;
47
+ }
48
+ const result = spawnSync(process.execPath, [installJs], { stdio: "inherit" });
49
+ if (result.status !== 0 || !electronLooksReady(electronPkgDir)) {
50
+ console.warn("[atto] Electron download did not finish. Opening Atto will retry once.");
51
+ } else {
52
+ console.log("[atto] Electron ready.");
53
+ }
54
+ }
55
+
56
+ function ensureChromium() {
57
+ let cliPath;
58
+ try {
59
+ cliPath = requireFromPackage.resolve("playwright/cli");
60
+ } catch {
61
+ console.warn("[atto] Playwright is not installed. The app will download Chromium on the first test.");
62
+ return;
63
+ }
64
+ console.log("[atto] Downloading Chromium...");
65
+ const result = spawnSync(process.execPath, [cliPath, "install", "chromium"], { stdio: "inherit" });
66
+ if (result.status !== 0) {
67
+ console.warn("[atto] Chromium download did not finish. The app will try again on the first test.");
68
+ } else {
69
+ console.log("[atto] Chromium ready.");
70
+ }
71
+ }
72
+
73
+ ensureElectron();
74
+ ensureChromium();
6
75
  process.exit(0);