@ishlabs/cli 0.8.2 → 0.8.3

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.
@@ -3,14 +3,7 @@
3
3
  * Uses playwright-core to download and manage Chromium in Playwright's
4
4
  * default cache (`~/Library/Caches/ms-playwright` on macOS, etc.).
5
5
  */
6
- /**
7
- * Check if Chromium is installed in Playwright's default cache.
8
- */
9
6
  export declare function isBrowserInstalled(): boolean;
10
- /**
11
- * Install Chromium browser for local simulations.
12
- * Downloads ~120 MB on first use into Playwright's default cache.
13
- */
14
7
  export declare function installBrowser(quiet?: boolean): Promise<void>;
15
8
  /**
16
9
  * Ensure Chromium is available, installing if needed.
@@ -3,12 +3,24 @@
3
3
  * Uses playwright-core to download and manage Chromium in Playwright's
4
4
  * default cache (`~/Library/Caches/ms-playwright` on macOS, etc.).
5
5
  */
6
- import { execSync } from "node:child_process";
7
6
  import { existsSync } from "node:fs";
8
7
  import { chromium } from "playwright-core";
9
- /**
10
- * Check if Chromium is installed in Playwright's default cache.
11
- */
8
+ // Deep-import the bundled registry so this works in both the npm-install path
9
+ // and the standalone bun binary (which has no `npx` to spawn).
10
+ import { registry } from "playwright-core/lib/server/registry/index";
11
+ // playwright-core's userAgent module does `require("../../../package.json")`
12
+ // at runtime to read its version. bun's --compile bundler is unreliable about
13
+ // embedding that JSON, which causes install to crash in the standalone binary
14
+ // with "Cannot find module ../../../package.json". Setting PW_VERSION_OVERRIDE
15
+ // makes that code path skip the require entirely.
16
+ //
17
+ // Keep this string in sync with the playwright-core dep in package.json. It
18
+ // only feeds the User-Agent string sent to download CDN, so a slight mismatch
19
+ // is harmless.
20
+ const PLAYWRIGHT_CORE_VERSION = "1.59.1";
21
+ if (!process.env.PW_VERSION_OVERRIDE) {
22
+ process.env.PW_VERSION_OVERRIDE = PLAYWRIGHT_CORE_VERSION;
23
+ }
12
24
  export function isBrowserInstalled() {
13
25
  try {
14
26
  const execPath = chromium.executablePath();
@@ -18,23 +30,18 @@ export function isBrowserInstalled() {
18
30
  return false;
19
31
  }
20
32
  }
21
- /**
22
- * Install Chromium browser for local simulations.
23
- * Downloads ~120 MB on first use into Playwright's default cache.
24
- */
25
33
  export async function installBrowser(quiet = false) {
26
34
  const log = (msg) => { if (!quiet)
27
35
  console.error(msg); };
28
36
  log("Installing Chromium for local simulations (~120 MB)...");
29
37
  try {
30
- execSync("npx playwright-core install chromium", {
31
- stdio: quiet ? "ignore" : "inherit",
32
- });
38
+ const executables = registry.resolveBrowsers(["chromium"], {});
39
+ await registry.install(executables, { force: false });
33
40
  log("Chromium installed successfully.");
34
41
  }
35
42
  catch (err) {
36
- throw new Error(`Failed to install Chromium. You can install manually:\n` +
37
- ` npx playwright-core install chromium`);
43
+ const detail = err instanceof Error ? err.message : String(err);
44
+ throw new Error(`Failed to install Chromium: ${detail}`);
38
45
  }
39
46
  }
40
47
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ishlabs/cli",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "The command-line interface for Ish",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc",
11
- "build:binary": "bun build --compile --external playwright-core --external chromium-bidi --external electron src/index.ts --outfile ish",
11
+ "patch:playwright": "node scripts/patch-playwright-core.mjs",
12
+ "build:binary": "npm run patch:playwright && bun build --compile --external chromium-bidi --external electron src/index.ts --outfile ish",
12
13
  "dev": "tsc --watch",
13
14
  "prepublishOnly": "npm run build"
14
15
  },