browser4-cli 4.12.1 → 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.
- package/README.md +525 -663
- package/bin/browser4-cli-darwin-arm64 +0 -0
- package/bin/browser4-cli-darwin-x64 +0 -0
- package/bin/browser4-cli-linux-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-x64 +0 -0
- package/bin/browser4-cli-linux-x64 +0 -0
- package/bin/browser4-cli-win32-x64.exe +0 -0
- package/package.json +5 -1
- package/scripts/README.md +22 -3
- package/scripts/sync-readme.mjs +44 -0
|
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.
|
|
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
|
@@ -36,7 +36,7 @@ Both scripts auto-detect OS, CPU architecture, and libc variant (glibc vs musl o
|
|
|
36
36
|
|
|
37
37
|
| Option | Description |
|
|
38
38
|
|--------|-------------|
|
|
39
|
-
| `--version, -v TAG` | Release tag (e.g. `v4.
|
|
39
|
+
| `--version, -v TAG` | Release tag (e.g. `v4.12.0`). Default: latest. |
|
|
40
40
|
| `--install-dir, -d DIR` | Install directory (default: `~/.local/bin` on Unix, `%LOCALAPPDATA%\Programs\browser4-cli` on Windows). |
|
|
41
41
|
| `--source SRC` | Force download source: `github` or `oss`. Default: auto (locale-aware). |
|
|
42
42
|
| `--no-path` / `-AddToPath:$false` | Skip adding the install directory to PATH. |
|
|
@@ -44,7 +44,8 @@ Both scripts auto-detect OS, CPU architecture, and libc variant (glibc vs musl o
|
|
|
44
44
|
| `--dry-run` / `-DryRun` | Print what would be done without doing it. |
|
|
45
45
|
| `--skip-if-installed` / `-SkipIfInstalled` | Skip download if binary already exists. |
|
|
46
46
|
| `--skip-local` / `-SkipLocal` | Skip local bundled binary check; always download. |
|
|
47
|
-
| `--
|
|
47
|
+
| `--force` / `-Force` (pwsh) | Force reinstallation even if the binary already exists at the target path. |
|
|
48
|
+
| `--locate` / `-Locate` | Print detection results (OS, arch, locale) and exit (no install). |
|
|
48
49
|
|
|
49
50
|
### One-liner install
|
|
50
51
|
|
|
@@ -87,7 +88,8 @@ Runs a full CLI smoke test suitable for CI and local development:
|
|
|
87
88
|
|--------|---------|
|
|
88
89
|
| `npm-publish-check.js` | Shared library: reads package metadata and compares local vs npm registry version |
|
|
89
90
|
| `check-npm-publish-needed.js` | CLI wrapper: checks whether a publish is needed and prints the decision |
|
|
90
|
-
| `publish-if-needed.js` | Publishes to npm only when the local version differs from the registry |
|
|
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`. |
|
|
91
93
|
| `postinstall.js` | npm `postinstall` hook: downloads the platform native binary after `npm install` |
|
|
92
94
|
|
|
93
95
|
### Version check
|
|
@@ -108,6 +110,23 @@ node scripts/publish-if-needed.js --dry-run # print what would happen
|
|
|
108
110
|
|
|
109
111
|
Optional env: `BROWSER4_CLI_NPM_REMOTE_VERSION` to override the remote version for testing.
|
|
110
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
|
+
|
|
111
130
|
### Postinstall
|
|
112
131
|
|
|
113
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
|
+
}
|