browser4-cli 4.12.2 → 4.12.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "4.12.2",
3
+ "version": "4.12.3",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [
@@ -13,6 +13,8 @@
13
13
  "browser4": "bin/browser4-cli.js"
14
14
  },
15
15
  "scripts": {
16
+ "sync:readme": "node scripts/sync-readme.mjs sync",
17
+ "restore:readme": "node scripts/sync-readme.mjs restore",
16
18
  "version:sync": "node ../bin/version.mjs cli sync",
17
19
  "version": "npm run version:sync && git add browser4-cli/Cargo.toml browser4-cli/Cargo.lock",
18
20
  "build:native": "npm run version:sync && cargo build --release --manifest-path browser4-cli/Cargo.toml && node scripts/copy-native.js",
@@ -21,6 +23,8 @@
21
23
  "build:windows": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-windows",
22
24
  "build:all-platforms": "npm run version:sync && (npm run build:linux & npm run build:windows & wait)",
23
25
  "build:docker": "docker build -t browser4-builder -f docker/Dockerfile.build .",
26
+ "prepack": "npm run sync:readme",
27
+ "postpack": "npm run restore:readme",
24
28
  "publish:if-needed": "node scripts/publish-if-needed.js",
25
29
  "release": "npm run publish:if-needed",
26
30
  "postinstall": "node scripts/postinstall.js"
package/scripts/README.md CHANGED
@@ -89,6 +89,7 @@ Runs a full CLI smoke test suitable for CI and local development:
89
89
  | `npm-publish-check.js` | Shared library: reads package metadata and compares local vs npm registry version |
90
90
  | `check-npm-publish-needed.js` | CLI wrapper: checks whether a publish is needed and prints the decision |
91
91
  | `publish-if-needed.js` | Publishes to npm only when the local version differs from the registry. Uses `--tag next` for prerelease versions (containing `-`). |
92
+ | `sync-readme.mjs` | Temporarily copies the repository root `README.md` to `cli/README.md` for npm pack/publish, then restores the original CLI README in `postpack`. |
92
93
  | `postinstall.js` | npm `postinstall` hook: downloads the platform native binary after `npm install` |
93
94
 
94
95
  ### Version check
@@ -109,6 +110,23 @@ node scripts/publish-if-needed.js --dry-run # print what would happen
109
110
 
110
111
  Optional env: `BROWSER4_CLI_NPM_REMOTE_VERSION` to override the remote version for testing.
111
112
 
113
+ ### README sync for npm package
114
+
115
+ `cli/package.json` wires the README sync into npm packaging hooks:
116
+
117
+ ```shell
118
+ npm run sync:readme # copy root README.md over cli/README.md
119
+ npm run restore:readme # restore the original cli/README.md
120
+ ```
121
+
122
+ During `npm pack` / `npm publish`, npm runs:
123
+
124
+ 1. `prepack` → `npm run sync:readme`
125
+ 2. package creation / publish
126
+ 3. `postpack` → `npm run restore:readme`
127
+
128
+ This makes the npm package README match the repository root README without leaving the working tree permanently overwritten after publishing.
129
+
112
130
  ### Postinstall
113
131
 
114
132
  `postinstall.js` runs automatically after `npm install browser4-cli`. It detects the platform and downloads the matching native binary to `bin/`. On global installs, it also patches npm's bin shims to invoke the native binary directly.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { copyFileSync, existsSync, unlinkSync } from 'node:fs';
4
+ import { dirname, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ const cliRootDir = resolve(__dirname, '..');
11
+ const repoRootDir = resolve(cliRootDir, '..');
12
+ const rootReadme = resolve(repoRootDir, 'README.md');
13
+ const cliReadme = resolve(cliRootDir, 'README.md');
14
+ const backupReadme = resolve(cliRootDir, '.README.prepack.backup.md');
15
+
16
+ function syncReadme() {
17
+ if (!existsSync(backupReadme)) {
18
+ copyFileSync(cliReadme, backupReadme);
19
+ }
20
+ copyFileSync(rootReadme, cliReadme);
21
+ console.log(`Synced ${rootReadme} -> ${cliReadme}`);
22
+ }
23
+
24
+ function restoreReadme() {
25
+ if (!existsSync(backupReadme)) {
26
+ console.log(`No README backup found at ${backupReadme}; nothing to restore.`);
27
+ return;
28
+ }
29
+
30
+ copyFileSync(backupReadme, cliReadme);
31
+ unlinkSync(backupReadme);
32
+ console.log(`Restored ${cliReadme} from ${backupReadme}`);
33
+ }
34
+
35
+ const mode = process.argv[2] ?? 'sync';
36
+
37
+ if (mode === 'sync') {
38
+ syncReadme();
39
+ } else if (mode === 'restore') {
40
+ restoreReadme();
41
+ } else {
42
+ console.error(`Unsupported mode: ${mode}. Use "sync" or "restore".`);
43
+ process.exit(1);
44
+ }