@polymerix-labs/facts-extract 0.7.4
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 +61 -0
- package/bin.js +22 -0
- package/index.js +54 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @polymerix-labs/facts-extract
|
|
2
|
+
|
|
3
|
+
Native **Polymerix front extractor**. It walks a repository and emits a `FactsBundle` JSON
|
|
4
|
+
(faithful, language-neutral facts produced with tree-sitter). It carries **no business logic**
|
|
5
|
+
(no semantic resolution, no graph assembly), so it is safe to ship to client machines.
|
|
6
|
+
|
|
7
|
+
The matching native binary is installed automatically for your platform via an optional
|
|
8
|
+
dependency (the same pattern as `esbuild`): nothing is downloaded at runtime.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @polymerix-labs/facts-extract
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Supported platforms
|
|
17
|
+
|
|
18
|
+
| OS | Arch | Package |
|
|
19
|
+
|----|------|---------|
|
|
20
|
+
| Linux | x64 | `@polymerix-labs/facts-extract-linux-x64` |
|
|
21
|
+
| Linux | arm64 | `@polymerix-labs/facts-extract-linux-arm64` |
|
|
22
|
+
| macOS | x64 (Intel) | `@polymerix-labs/facts-extract-darwin-x64` |
|
|
23
|
+
| macOS | arm64 (Apple Silicon) | `@polymerix-labs/facts-extract-darwin-arm64` |
|
|
24
|
+
| Windows | x64 | `@polymerix-labs/facts-extract-win32-x64` |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Resolve the binary path (spawn it yourself)
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const { binaryPath } = require("@polymerix-labs/facts-extract");
|
|
32
|
+
const { spawnSync } = require("child_process");
|
|
33
|
+
|
|
34
|
+
const out = spawnSync(binaryPath, ["--repo-root", "/abs/path/to/project"], {
|
|
35
|
+
encoding: "utf8",
|
|
36
|
+
});
|
|
37
|
+
const bundle = JSON.parse(out.stdout); // FactsBundle
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Run as a CLI
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx @polymerix-labs/facts-extract --repo-root /abs/path/to/project -o bundle.json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Flags
|
|
47
|
+
|
|
48
|
+
| Flag | Effet |
|
|
49
|
+
|------|-------|
|
|
50
|
+
| `--repo-root <PATH>` | Absolute path to the repository root (required) |
|
|
51
|
+
| `--output, -o <FILE>` | Write the FactsBundle JSON to a file (default: stdout) |
|
|
52
|
+
| `--verbose` | Real-time logs on stderr |
|
|
53
|
+
| `--progress` | Progress bar on stderr during the parallel parse pass |
|
|
54
|
+
|
|
55
|
+
Exit codes: `0` success, `1` usage error, `2` repo not found, `3` extraction/serialize error.
|
|
56
|
+
|
|
57
|
+
## Output
|
|
58
|
+
|
|
59
|
+
A `FactsBundle` JSON (the front to back transport contract), versioned by
|
|
60
|
+
`FACTS_SCHEMA_VERSION`. Feed it to the back (`facts-build`) to produce a `graph.json`. See the
|
|
61
|
+
[Polymerix parser repository](https://gitlab.com/polymerix/parser) for the bundle format.
|
package/bin.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// CLI shim: forwards every argument to the native `facts-extract` binary and propagates its
|
|
5
|
+
// exit code. Lets consumers run `npx @polymerix-labs/facts-extract --repo-root <dir>` directly.
|
|
6
|
+
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
8
|
+
const { binaryPath } = require("./index.js");
|
|
9
|
+
|
|
10
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
11
|
+
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(`facts-extract: failed to launch binary: ${result.error.message}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Mirror signal-terminated children with the conventional 128 + signal code.
|
|
18
|
+
if (result.signal) {
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Resolves the path to the native `facts-extract` binary for the current platform.
|
|
4
|
+
//
|
|
5
|
+
// Each supported platform ships as its own package (e.g. `@polymerix-labs/facts-extract-darwin-arm64`)
|
|
6
|
+
// declared as an optional dependency of this wrapper. npm installs only the one matching the
|
|
7
|
+
// host's `os`/`cpu`, so exactly one of them is present at runtime; we resolve its binary here.
|
|
8
|
+
|
|
9
|
+
const os = require("os");
|
|
10
|
+
|
|
11
|
+
// Maps Node's `${platform}-${arch}` to the platform package suffix. The keys mirror
|
|
12
|
+
// `process.platform` + `process.arch` for a trivial, direct lookup.
|
|
13
|
+
const SUPPORTED = {
|
|
14
|
+
"linux-x64": "linux-x64",
|
|
15
|
+
"linux-arm64": "linux-arm64",
|
|
16
|
+
"darwin-x64": "darwin-x64",
|
|
17
|
+
"darwin-arm64": "darwin-arm64",
|
|
18
|
+
"win32-x64": "win32-x64",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Returns the `${platform}-${arch}` key for the current host. */
|
|
22
|
+
function platformKey() {
|
|
23
|
+
return `${process.platform}-${process.arch}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Resolves the absolute path to the native binary, throwing a clear error if unsupported. */
|
|
27
|
+
function resolveBinaryPath() {
|
|
28
|
+
const key = platformKey();
|
|
29
|
+
const suffix = SUPPORTED[key];
|
|
30
|
+
if (!suffix) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`@polymerix-labs/facts-extract: unsupported platform "${key}". ` +
|
|
33
|
+
`Supported: ${Object.keys(SUPPORTED).join(", ")}.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const binName = process.platform === "win32" ? "facts-extract.exe" : "facts-extract";
|
|
38
|
+
const pkg = `@polymerix-labs/facts-extract-${suffix}/${binName}`;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
return require.resolve(pkg);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`@polymerix-labs/facts-extract: the native package for "${key}" is not installed. ` +
|
|
45
|
+
`If you disabled optional dependencies, re-install with them enabled. ` +
|
|
46
|
+
`(host: ${os.type()} ${os.release()})\nCause: ${err.message}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Absolute path to the native `facts-extract` executable for this platform. */
|
|
52
|
+
const binaryPath = resolveBinaryPath();
|
|
53
|
+
|
|
54
|
+
module.exports = { binaryPath, resolveBinaryPath, platformKey };
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@polymerix-labs/facts-extract",
|
|
3
|
+
"version": "0.7.4",
|
|
4
|
+
"description": "Polymerix front extractor: walk a repository and emit a FactsBundle JSON (tree-sitter only, no business logic). Ships the native binary per platform.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"polymerix",
|
|
7
|
+
"facts",
|
|
8
|
+
"tree-sitter",
|
|
9
|
+
"code-analysis",
|
|
10
|
+
"parser"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://gitlab.com/polymerix/parser",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://gitlab.com/polymerix/parser.git",
|
|
16
|
+
"directory": "npm/facts-extract"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"type": "commonjs",
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"bin": {
|
|
22
|
+
"facts-extract": "bin.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"index.js",
|
|
26
|
+
"bin.js"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=16"
|
|
30
|
+
},
|
|
31
|
+
"optionalDependencies": {
|
|
32
|
+
"@polymerix-labs/facts-extract-linux-x64": "0.7.4",
|
|
33
|
+
"@polymerix-labs/facts-extract-linux-arm64": "0.7.4",
|
|
34
|
+
"@polymerix-labs/facts-extract-darwin-x64": "0.7.4",
|
|
35
|
+
"@polymerix-labs/facts-extract-darwin-arm64": "0.7.4",
|
|
36
|
+
"@polymerix-labs/facts-extract-win32-x64": "0.7.4"
|
|
37
|
+
}
|
|
38
|
+
}
|