omnicrawl-cli 0.1.68

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 ADDED
@@ -0,0 +1,63 @@
1
+ # omnicrawl-cli
2
+
3
+ OmniCrawl 启动器:按 `platform-arch` 选包node_modules的内核二进制,把 stdio 转交给它。
4
+ 它不做协议转换——宿主直接与内核进程对话(协议见 `rust/docs/protocol-v1.md`)。
5
+
6
+ ## 分发形态
7
+
8
+ | npm 包 | 内容 |
9
+ | --- | --- |
10
+ | `omnicrawl-cli` | JS 启动器(`bin/omnicrawl.mjs`) |
11
+ | `@omnicrawl/cli-linux-x64` | 内核二进制(Linux x64,musl 静态) |
12
+ | `@omnicrawl/cli-linux-arm64-musl` | 内核二进制(Linux arm64,嵌入式目标) |
13
+ | `@omnicrawl/cli-win32-x64` | 内核二进制(Windows x64) |
14
+
15
+ **平台分包、`os`/`cpu` 与平台依赖只出现在发布产物里**(`dist/npm/`)。仓库内的 `packages/cli*/package.json`
16
+ 刻意不带 `os`/`cpu`、也不声明平台分包依赖:npm 安装时会校验工作区成员的 `os`/`cpu`,带上就直接
17
+ `notsup` 失败。发布产物由 `scripts/prepare.mjs` 生成。
18
+
19
+ ## 本地开发
20
+
21
+ ```bash
22
+ cargo build --release -p omnicrawl-cli # 产物:rust/target/release/omnicrawl[.exe]
23
+ node packages/cli/scripts/prepare.mjs # 暂存发布产物(缺的平台只警告)
24
+ npm test -w omnicrawl-cli # e2e:真二进制 + 协议 v1
25
+ OMNICRAWL_BINARY=/path/to/omnicrawl node packages/cli/bin/omnicrawl.mjs --version
26
+ ```
27
+
28
+ 工作区里 `@omnicrawl/cli-*` 都是 workspace 成员,启动器靠 `createRequire` 解析到它们;
29
+ `OMNICRAWL_BINARY` 是直接指定二进制的逃生口(e2e 用的就是它)。e2e 需要 `rust/target/release`
30
+ 里有产物,否则跳过并打印构建命令。
31
+
32
+ ## 发布
33
+
34
+ 1. 交叉编译三个平台(Linux 走 musl 静态,嵌入式目标优先):
35
+
36
+ ```bash
37
+ cargo build --release -p omnicrawl-cli --target x86_64-pc-windows-msvc
38
+ cargo build --release -p omnicrawl-cli --target x86_64-unknown-linux-musl
39
+ cargo build --release -p omnicrawl-cli --target aarch64-unknown-linux-musl
40
+ ```
41
+
42
+ 2. 门槛检查(缺任何平台会失败并列出缺失平台):
43
+
44
+ ```bash
45
+ node packages/cli/scripts/prepare.mjs --require-all
46
+ ```
47
+
48
+ 3. 按顺序发布暂存产物:平台包在前,启动器在后(启动器的 `optionalDependencies` 是精确版本,顺序反了会装不到):
49
+
50
+ ```bash
51
+ npm publish dist/npm/cli-linux-x64
52
+ npm publish dist/npm/cli-linux-arm64-musl
53
+ npm publish dist/npm/cli-win32-x64
54
+ npm publish dist/npm/cli
55
+ ```
56
+
57
+ 脚本跑完会把这几行命令直接打出来。
58
+
59
+ 4. 版本reproducibility:四个包同版本;平台包只装二进制,升级它们就是换内核。
60
+
61
+ ## 发布前自检
62
+
63
+ `cargo test --workspace`、`npm test --workspaces`,以及 `prepare --require-all` 门槛。
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ // OmniCrawl 启动器:按 platform/arch 选出内核二进制并转交 stdio。
3
+ //
4
+ // 它不做任何协议转换——宿主直接与内核进程对话,启动器只是平台分包的解析器。
5
+ import { spawn } from 'node:child_process'
6
+ import { existsSync } from 'node:fs'
7
+ import { createRequire } from 'node:module'
8
+ import { dirname, join } from 'node:path'
9
+ import process from 'node:process'
10
+
11
+ const PLATFORM_PACKAGES = {
12
+ 'linux-x64': '@omnicrawl/cli-linux-x64',
13
+ 'linux-arm64': '@omnicrawl/cli-linux-arm64-musl',
14
+ 'win32-x64': '@omnicrawl/cli-win32-x64',
15
+ 'win32-ia32': '@omnicrawl/cli-win32-ia32',
16
+ }
17
+
18
+ function resolveBinary() {
19
+ // 开发与测试用的逃生口:跳过分包直接指定二进制。
20
+ if (process.env.OMNICRAWL_BINARY) return process.env.OMNICRAWL_BINARY
21
+
22
+ const key = `${process.platform}-${process.arch}`
23
+ const packageName = PLATFORM_PACKAGES[key]
24
+ if (!packageName) {
25
+ throw new Error(`不支持的平台 ${key};已支持:${Object.keys(PLATFORM_PACKAGES).join('、')}`)
26
+ }
27
+
28
+ const require = createRequire(import.meta.url)
29
+ const packageRoot = dirname(require.resolve(`${packageName}/package.json`))
30
+ const binary = join(packageRoot, 'bin', process.platform === 'win32' ? 'omnicrawl.exe' : 'omnicrawl')
31
+ if (!existsSync(binary)) {
32
+ throw new Error(`平台分包 ${packageName} 里没有二进制:${binary}\n请重装该包,或用 OMNICRAWL_BINARY 指定。`)
33
+ }
34
+ return binary
35
+ }
36
+
37
+ let binary
38
+ try {
39
+ binary = resolveBinary()
40
+ } catch (error) {
41
+ console.error(`omnicrawl:${error.message}`)
42
+ process.exit(1)
43
+ }
44
+
45
+ const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' })
46
+
47
+ child.on('error', (error) => {
48
+ console.error(`omnicrawl:无法启动 ${binary}:${error.message}`)
49
+ process.exit(1)
50
+ })
51
+
52
+ child.on('exit', (code, signal) => {
53
+ if (signal) {
54
+ console.error(`omnicrawl:内核被信号 ${signal} 终止`)
55
+ process.exit(1)
56
+ }
57
+ process.exit(code ?? 0)
58
+ })
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "omnicrawl-cli",
3
+ "version": "0.1.68",
4
+ "description": "OmniCrawl 启动器:按平台选择内核二进制并转交 stdio",
5
+ "type": "module",
6
+ "bin": {
7
+ "omnicrawl": "bin/omnicrawl.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "scripts": {
17
+ "test": "node --test",
18
+ "prepare:binaries": "node scripts/prepare.mjs"
19
+ },
20
+ "license": "MIT",
21
+ "optionalDependencies": {
22
+ "@omnicrawl/cli-win32-x64": "0.1.68",
23
+ "@omnicrawl/cli-win32-ia32": "0.1.68",
24
+ "@omnicrawl/cli-linux-x64": "0.1.68",
25
+ "@omnicrawl/cli-linux-arm64-musl": "0.1.68"
26
+ }
27
+ }